From 8c5d5fcb8a71788a595f2bc91d9cec3d344fe077 Mon Sep 17 00:00:00 2001 From: wangdw10 Date: Mon, 15 Apr 2019 11:16:50 +0800 Subject: [PATCH] [COMMON] fimc-is2: add power retry logic - when retried sensor module power off to on add to get delay more - sync power sequence from mainline to drvonly Change-Id: I98f5561e88b9db6812e3d15592aa058e143c6903 Signed-off-by: wangdw10 --- .../exynos/fimc-is2/fimc-is-device-sensor.h | 1 + .../fimc-is2/ischain/setup-fimc-is-module.c | 4 ++++ .../modules/fimc-is-device-module-2x5sp.c | 3 +++ .../modules/fimc-is-device-module-5e9.c | 22 ++++++++++--------- .../modules/fimc-is-device-module-base.c | 3 +++ .../modules/fimc-is-device-module-gm1sp.c | 7 ++++-- include/dt-bindings/camera/fimc_is.h | 1 + 7 files changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/exynos/fimc-is2/fimc-is-device-sensor.h b/drivers/media/platform/exynos/fimc-is2/fimc-is-device-sensor.h index c62096d9cf07..dd85c0649592 100644 --- a/drivers/media/platform/exynos/fimc-is2/fimc-is-device-sensor.h +++ b/drivers/media/platform/exynos/fimc-is2/fimc-is-device-sensor.h @@ -287,6 +287,7 @@ struct fimc_is_module_enum { struct fimc_is_sensor_cfg *cfg; struct fimc_is_sensor_vc_extra_info vc_extra_info[VC_BUF_DATA_TYPE_MAX]; u32 vc_buffer_offset[CSI_VIRTUAL_CH_MAX]; + u32 power_retry; struct i2c_client *client; struct sensor_open_extended ext; struct fimc_is_sensor_ops *ops; diff --git a/drivers/media/platform/exynos/fimc-is2/ischain/setup-fimc-is-module.c b/drivers/media/platform/exynos/fimc-is2/ischain/setup-fimc-is-module.c index d57f8eb2a869..88d8911d119c 100644 --- a/drivers/media/platform/exynos/fimc-is2/ischain/setup-fimc-is-module.c +++ b/drivers/media/platform/exynos/fimc-is2/ischain/setup-fimc-is-module.c @@ -172,6 +172,10 @@ static int exynos_fimc_is_module_pin_control(struct fimc_is_module_enum *module, case PIN_I2C: ret = fimc_is_i2c_pin_control(module, scenario, value); break; + case PIN_RETRY: + if (module->power_retry) + usleep_range(delay, delay); + break; default: pr_err("unknown act for pin\n"); break; diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-2x5sp.c b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-2x5sp.c index a97caca01c28..8a9120ff95c9 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-2x5sp.c +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-2x5sp.c @@ -195,6 +195,7 @@ static int sensor_module_2x5sp_power_setpin(struct device *dev, SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 0); SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 7000); + SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "retry delay", PIN_RETRY, 0, 2000); /* BACK CAEMRA - POWER OFF */ SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst", PIN_RESET, 0, 10); @@ -221,6 +222,7 @@ static int sensor_module_2x5sp_power_setpin(struct device *dev, SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 0); SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 7000); + SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_none, "retry delay", PIN_RETRY, 0, 2000); /* REAR VISION CAEMRA - POWER OFF */ @@ -244,6 +246,7 @@ static int sensor_module_2x5sp_power_setpin(struct device *dev, SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 0); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 7000); + SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "retry delay", PIN_RETRY, 0, 2000); /* REAR VISION CAEMRA - POWER OFF */ diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-5e9.c b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-5e9.c index 2dea743e0933..fefcc6bd062c 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-5e9.c +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-5e9.c @@ -277,7 +277,7 @@ static int sensor_module_5e9_power_setpin_1(struct device *dev, SET_PIN_INIT(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF); /* Normal On */ - SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_reset, "sen_rst low", PIN_OUTPUT, 0, 0); + SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_reset, "sen_rst low", PIN_OUTPUT, 0, 100); SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "VLDO44_PMIC_DCAM_DVDD_1P2", PIN_REGULATOR, 1, 0); /* TODO: need to check */ @@ -287,14 +287,15 @@ static int sensor_module_5e9_power_setpin_1(struct device *dev, SET_PIN_SHARED(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, SRT_ACQUIRE, &core->shared_rsc_slock[SHARED_PIN0], &core->shared_rsc_count[SHARED_PIN0], 1); - SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 0); - SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 2000); + SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 1000); + SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 2000); + SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "retry delay", PIN_RETRY, 0, 2000); /* Normal Off */ + SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst", PIN_OUTPUT, 0, 1000); SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0); SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 1, 0); - SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0); - SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst", PIN_OUTPUT, 0, 0); + SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 1000); SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_none, "VLDO44_PMIC_DCAM_DVDD_1P2", PIN_REGULATOR, 0, 0); SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_avdd_en, "avdd_en", PIN_OUTPUT, 0, 0); /* TODO: need to check */ @@ -304,18 +305,19 @@ static int sensor_module_5e9_power_setpin_1(struct device *dev, &core->shared_rsc_slock[SHARED_PIN0], &core->shared_rsc_count[SHARED_PIN0], 0); /* SENSOR FACTORY TEST - POWER ON */ - SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_reset, "sen_rst low", PIN_OUTPUT, 0, 0); + SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_reset, "sen_rst low", PIN_OUTPUT, 0, 100); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "VLDO44_PMIC_DCAM_DVDD_1P2", PIN_REGULATOR, 1, 0); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_avdd_en, "avdd_en", PIN_OUTPUT, 1, 0); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_iovdd_en, "iovdd_en", PIN_OUTPUT, 1, 1000); - SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 0); - SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 2000); + SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 1000); + SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 2000); + SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "retry delay", PIN_RETRY, 0, 2000); /* Normal Off */ + SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst", PIN_OUTPUT, 0, 1000); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 1, 0); - SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0); - SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst", PIN_OUTPUT, 0, 0); + SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 1000); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_none, "VLDO44_PMIC_DCAM_DVDD_1P2", PIN_REGULATOR, 0, 0); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_avdd_en, "avdd_en", PIN_OUTPUT, 0, 0); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_iovdd_en, "iovdd_en", PIN_OUTPUT, 0, 0); diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-base.c b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-base.c index 78fa0839934d..25d7adb71718 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-base.c +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-base.c @@ -212,13 +212,16 @@ int sensor_module_init(struct v4l2_subdev *subdev, u32 val) if (ret < 0) { if (ret == -EAGAIN) { err("Checking sensor revision is fail. So retry camera power sequence."); + module->power_retry = true; sensor_module_power_reset(subdev, device); ret = CALL_CISOPS(&sensor_peri->cis, cis_check_rev, subdev_cis); if (ret < 0) { + module->power_retry = false; goto p_err; } } } + module->power_retry = false; /* init kthread for sensor register setting when s_format */ ret = fimc_is_sensor_init_mode_change_thread(sensor_peri); diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-gm1sp.c b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-gm1sp.c index 96c3a74e06e8..141e70d915dd 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-gm1sp.c +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/modules/fimc-is-device-module-gm1sp.c @@ -188,7 +188,8 @@ static int sensor_module_gm1sp_power_setpin(struct device *dev, &core->shared_rsc_slock[SHARED_PIN0], &core->shared_rsc_count[SHARED_PIN0], 1); SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 0); - SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 2000); + SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 3000); + SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "retry delay", PIN_RETRY, 0, 2000); /* BACK CAEMRA - POWER OFF */ SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst", PIN_RESET, 0, 10); @@ -215,6 +216,7 @@ static int sensor_module_gm1sp_power_setpin(struct device *dev, SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 0); SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 2000); + SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_none, "retry delay", PIN_RETRY, 0, 2000); /* REAR VISION CAEMRA - POWER OFF */ @@ -239,7 +241,8 @@ static int sensor_module_gm1sp_power_setpin(struct device *dev, SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_iovdd_en, "iovdd_en", PIN_OUTPUT, 1, 1000); SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 0); - SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 2000); + SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 3000); + SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "retry delay", PIN_RETRY, 0, 2000); /* REAR VISION CAEMRA - POWER OFF */ diff --git a/include/dt-bindings/camera/fimc_is.h b/include/dt-bindings/camera/fimc_is.h index 59b7f2e72fa0..745765b04f66 100644 --- a/include/dt-bindings/camera/fimc_is.h +++ b/include/dt-bindings/camera/fimc_is.h @@ -62,6 +62,7 @@ #define PIN_FUNCTION 4 #define PIN_REGULATOR 5 #define PIN_I2C 6 +#define PIN_RETRY 8 #define DT_SET_PIN(p, n, a, v, t) \ seq@__LINE__ { \ -- 2.20.1