|
@@ -1227,6 +1227,45 @@ int cam_sensor_util_request_gpio_table(
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
+static bool cam_sensor_util_check_gpio_is_shared(
|
|
|
+ struct cam_hw_soc_info *soc_info)
|
|
|
+{
|
|
|
+ int rc = 0;
|
|
|
+ uint8_t size = 0;
|
|
|
+ struct cam_soc_gpio_data *gpio_conf =
|
|
|
+ soc_info->gpio_data;
|
|
|
+ struct gpio *gpio_tbl = NULL;
|
|
|
+
|
|
|
+ if (!gpio_conf) {
|
|
|
+ CAM_DBG(CAM_SENSOR, "No GPIO data");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (gpio_conf->cam_gpio_common_tbl_size <= 0) {
|
|
|
+ CAM_DBG(CAM_SENSOR, "No GPIO entry");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ gpio_tbl = gpio_conf->cam_gpio_req_tbl;
|
|
|
+ size = gpio_conf->cam_gpio_req_tbl_size;
|
|
|
+
|
|
|
+ if (!gpio_tbl || !size) {
|
|
|
+ CAM_ERR(CAM_SENSOR, "invalid gpio_tbl %pK / size %d",
|
|
|
+ gpio_tbl, size);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ rc = cam_res_mgr_check_if_gpio_is_shared(
|
|
|
+ gpio_tbl, size);
|
|
|
+ if (!rc) {
|
|
|
+ CAM_DBG(CAM_SENSOR,
|
|
|
+ "dev: %s don't have shared gpio resources",
|
|
|
+ soc_info->dev_name);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
|
|
|
static int32_t cam_sensor_validate(void *ptr, size_t remain_buf)
|
|
|
{
|
|
@@ -1949,6 +1988,7 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
|
|
|
struct cam_hw_soc_info *soc_info)
|
|
|
{
|
|
|
int rc = 0, index = 0, no_gpio = 0, ret = 0, num_vreg, j = 0, i = 0;
|
|
|
+ bool shared_gpio = false;
|
|
|
int32_t vreg_idx = -1;
|
|
|
struct cam_sensor_power_setting *power_setting = NULL;
|
|
|
struct msm_camera_gpio_num_info *gpio_num_info = NULL;
|
|
@@ -1979,16 +2019,21 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
|
|
|
ctrl->cam_pinctrl_status = 1;
|
|
|
}
|
|
|
|
|
|
- if (cam_res_mgr_shared_pinctrl_init()) {
|
|
|
- CAM_ERR(CAM_SENSOR,
|
|
|
- "Failed to init shared pinctrl");
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
+ shared_gpio = cam_sensor_util_check_gpio_is_shared(soc_info);
|
|
|
rc = cam_sensor_util_request_gpio_table(soc_info, 1);
|
|
|
if (rc < 0)
|
|
|
no_gpio = rc;
|
|
|
|
|
|
+ if (shared_gpio) {
|
|
|
+ rc = cam_res_mgr_shared_pinctrl_init();
|
|
|
+ if (rc) {
|
|
|
+ CAM_ERR(CAM_SENSOR,
|
|
|
+ "Failed to init shared pinctrl");
|
|
|
+ shared_gpio = false;
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (ctrl->cam_pinctrl_status) {
|
|
|
ret = pinctrl_select_state(
|
|
|
ctrl->pinctrl_info.pinctrl,
|
|
@@ -1997,11 +2042,12 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
|
|
|
CAM_ERR(CAM_SENSOR, "cannot set pin to active state");
|
|
|
}
|
|
|
|
|
|
- ret = cam_res_mgr_shared_pinctrl_select_state(true);
|
|
|
- if (ret)
|
|
|
- CAM_ERR(CAM_SENSOR,
|
|
|
- "Cannot set shared pin to active state");
|
|
|
-
|
|
|
+ if (shared_gpio) {
|
|
|
+ ret = cam_res_mgr_shared_pinctrl_select_state(true);
|
|
|
+ if (ret)
|
|
|
+ CAM_ERR(CAM_SENSOR,
|
|
|
+ "Cannot set shared pin to active state");
|
|
|
+ }
|
|
|
CAM_DBG(CAM_SENSOR, "power setting size: %d", ctrl->power_setting_size);
|
|
|
|
|
|
for (index = 0; index < ctrl->power_setting_size; index++) {
|
|
@@ -2185,11 +2231,6 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
|
|
|
(power_setting->delay * 1000) + 1000);
|
|
|
}
|
|
|
|
|
|
- ret = cam_res_mgr_shared_pinctrl_post_init();
|
|
|
- if (ret)
|
|
|
- CAM_ERR(CAM_SENSOR,
|
|
|
- "Failed to post init shared pinctrl");
|
|
|
-
|
|
|
return 0;
|
|
|
power_up_failed:
|
|
|
CAM_ERR(CAM_SENSOR, "failed");
|
|
@@ -2294,8 +2335,10 @@ power_up_failed:
|
|
|
if (soc_info->use_shared_clk)
|
|
|
cam_res_mgr_shared_clk_config(false);
|
|
|
|
|
|
- cam_res_mgr_shared_pinctrl_select_state(false);
|
|
|
- cam_res_mgr_shared_pinctrl_put();
|
|
|
+ if (shared_gpio) {
|
|
|
+ cam_res_mgr_shared_pinctrl_select_state(false);
|
|
|
+ cam_res_mgr_shared_pinctrl_put();
|
|
|
+ }
|
|
|
|
|
|
ctrl->cam_pinctrl_status = 0;
|
|
|
|
|
@@ -2329,6 +2372,7 @@ int cam_sensor_util_power_down(struct cam_sensor_power_ctrl_t *ctrl,
|
|
|
struct cam_hw_soc_info *soc_info)
|
|
|
{
|
|
|
int index = 0, ret = 0, num_vreg = 0, i;
|
|
|
+ bool shared_gpio = false;
|
|
|
struct cam_sensor_power_setting *pd = NULL;
|
|
|
struct cam_sensor_power_setting *ps = NULL;
|
|
|
struct msm_camera_gpio_num_info *gpio_num_info = NULL;
|
|
@@ -2339,6 +2383,7 @@ int cam_sensor_util_power_down(struct cam_sensor_power_ctrl_t *ctrl,
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
+ shared_gpio = cam_sensor_util_check_gpio_is_shared(soc_info);
|
|
|
gpio_num_info = ctrl->gpio_num_info;
|
|
|
num_vreg = soc_info->num_rgltr;
|
|
|
|
|
@@ -2475,15 +2520,15 @@ int cam_sensor_util_power_down(struct cam_sensor_power_ctrl_t *ctrl,
|
|
|
devm_pinctrl_put(ctrl->pinctrl_info.pinctrl);
|
|
|
}
|
|
|
|
|
|
+ cam_sensor_util_request_gpio_table(soc_info, 0);
|
|
|
+
|
|
|
if (soc_info->use_shared_clk)
|
|
|
cam_res_mgr_shared_clk_config(false);
|
|
|
-
|
|
|
- cam_res_mgr_shared_pinctrl_select_state(false);
|
|
|
- cam_res_mgr_shared_pinctrl_put();
|
|
|
-
|
|
|
+ if (shared_gpio) {
|
|
|
+ cam_res_mgr_shared_pinctrl_select_state(false);
|
|
|
+ cam_res_mgr_shared_pinctrl_put();
|
|
|
+ }
|
|
|
ctrl->cam_pinctrl_status = 0;
|
|
|
|
|
|
- cam_sensor_util_request_gpio_table(soc_info, 0);
|
|
|
-
|
|
|
return 0;
|
|
|
}
|