Browse Source

msm: camera: sensor: Add support fo multiple regulator sources

Currently image sensor need single source of the regulator per
category. Some sensor needs extra analog voltage for the functionality,
which require to draw power from multiple voltage regulator sources.
This change extends supports to add multiple voltage sources for
analog voltage.

CRs-Fixed: 2584631
Change-Id: I2d76cfb0fb971758c0d596ffd543aa3926a8886d
Signed-off-by: Jigarkumar Zala <[email protected]>
Jigarkumar Zala 5 years ago
parent
commit
b8d55f649d

+ 0 - 1
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h

@@ -40,7 +40,6 @@
 #define MAX_DATA_RATES              3
 #define MAX_DATA_RATE_REGS          30
 
-#define MAX_REGULATOR         5
 #define CAMX_CSIPHY_DEV_NAME "cam-csiphy-driver"
 
 #define CSIPHY_POWER_UP       0

+ 2 - 2
drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h

@@ -16,8 +16,7 @@
 #include <media/cam_sensor.h>
 #include <media/cam_req_mgr.h>
 
-#define MAX_REGULATOR 5
-#define MAX_POWER_CONFIG 12
+#define MAX_POWER_CONFIG    12
 
 #define MAX_PER_FRAME_ARRAY 32
 #define BATCH_SIZE_MAX      16
@@ -142,6 +141,7 @@ enum msm_camera_power_seq_type {
 	SENSOR_STANDBY,
 	SENSOR_CUSTOM_GPIO1,
 	SENSOR_CUSTOM_GPIO2,
+	SENSOR_VANA1,
 	SENSOR_SEQ_TYPE_MAX,
 };
 

+ 46 - 0
drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c

@@ -980,6 +980,29 @@ int32_t msm_camera_fill_vreg_params(
 				power_setting[i].seq_val = INVALID_VREG;
 			break;
 
+		case SENSOR_VANA1:
+			for (j = 0; j < num_vreg; j++) {
+				if (!strcmp(soc_info->rgltr_name[j],
+					"cam_vana1")) {
+					CAM_DBG(CAM_SENSOR,
+						"i: %d j: %d cam_vana1", i, j);
+					power_setting[i].seq_val = j;
+
+					if (VALIDATE_VOLTAGE(
+						soc_info->rgltr_min_volt[j],
+						soc_info->rgltr_max_volt[j],
+						power_setting[i].config_val)) {
+						soc_info->rgltr_min_volt[j] =
+						soc_info->rgltr_max_volt[j] =
+						power_setting[i].config_val;
+					}
+					break;
+				}
+			}
+			if (j == num_vreg)
+				power_setting[i].seq_val = INVALID_VREG;
+			break;
+
 		case SENSOR_VAF:
 			for (j = 0; j < num_vreg; j++) {
 
@@ -1406,6 +1429,8 @@ int cam_get_dt_power_setting_data(struct device_node *of_node,
 			ps[i].seq_type = SENSOR_VIO;
 		} else if (!strcmp(seq_name, "cam_vana")) {
 			ps[i].seq_type = SENSOR_VANA;
+		} else if (!strcmp(seq_name, "cam_vana1")) {
+			ps[i].seq_type = SENSOR_VANA1;
 		} else if (!strcmp(seq_name, "cam_clk")) {
 			ps[i].seq_type = SENSOR_MCLK;
 		} else {
@@ -1533,6 +1558,24 @@ int cam_sensor_util_init_gpio_pin_tbl(
 			gpio_num_info->gpio_num[SENSOR_VANA]);
 	}
 
+	rc = of_property_read_u32(of_node, "gpio-vana1", &val);
+	if (rc != -EINVAL) {
+		if (rc < 0) {
+			CAM_ERR(CAM_SENSOR, "read gpio-vana1 failed rc %d", rc);
+			goto free_gpio_info;
+		} else if (val >= gpio_array_size) {
+			CAM_ERR(CAM_SENSOR, "gpio-vana1 invalid %d", val);
+			rc = -EINVAL;
+			goto free_gpio_info;
+		}
+		gpio_num_info->gpio_num[SENSOR_VANA1] =
+			gconf->cam_gpio_common_tbl[val].gpio;
+		gpio_num_info->valid[SENSOR_VANA1] = 1;
+
+		CAM_DBG(CAM_SENSOR, "gpio-vana1 %d",
+			gpio_num_info->gpio_num[SENSOR_VANA1]);
+	}
+
 	rc = of_property_read_u32(of_node, "gpio-vio", &val);
 	if (rc != -EINVAL) {
 		if (rc < 0) {
@@ -1977,6 +2020,7 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
 			}
 			break;
 		case SENSOR_VANA:
+		case SENSOR_VANA1:
 		case SENSOR_VDIG:
 		case SENSOR_VIO:
 		case SENSOR_VAF:
@@ -2093,6 +2137,7 @@ power_up_failed:
 				[power_setting->seq_type], GPIOF_OUT_INIT_LOW);
 			break;
 		case SENSOR_VANA:
+		case SENSOR_VANA1:
 		case SENSOR_VDIG:
 		case SENSOR_VIO:
 		case SENSOR_VAF:
@@ -2261,6 +2306,7 @@ int cam_sensor_util_power_down(struct cam_sensor_power_ctrl_t *ctrl,
 
 			break;
 		case SENSOR_VANA:
+		case SENSOR_VANA1:
 		case SENSOR_VDIG:
 		case SENSOR_VIO:
 		case SENSOR_VAF:

+ 1 - 1
drivers/cam_utils/cam_soc_util.h

@@ -30,7 +30,7 @@
 #define CAM_SOC_MAX_BASE            CAM_SOC_MAX_BLOCK
 
 /* maximum number of device regulator */
-#define CAM_SOC_MAX_REGULATOR       5
+#define CAM_SOC_MAX_REGULATOR       10
 
 /* maximum number of device clock */
 #define CAM_SOC_MAX_CLK             32