[COMMON] fimc-is2: fix 2x5sp/5e9 otp load retry logic
authorWooyeon Kim <wooy88.kim@samsung.com>
Fri, 29 Mar 2019 07:16:40 +0000 (16:16 +0900)
committerlingsen1 <lingsen1@lenovo.com>
Mon, 10 Jun 2019 03:24:56 +0000 (11:24 +0800)
 PR JIRA ID: CPR-906

CRs-fixed: (CR)

Change-Id: Iba5d9e8e6af6404505dc8602b31b6614a2ba52f8
Signed-off-by: Wooyeon Kim <wooy88.kim@samsung.com>
Reviewed-on: https://gerrit.mot.com/1332494
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Biming Li <libm1@motorola.com>
Reviewed-by: Zhichao Chen <chenzc2@motorola.com>
Submit-Approved: Jira Key

drivers/media/platform/exynos/fimc-is2/sensor/module_framework/cis/fimc-is-cis-2x5sp.c
drivers/media/platform/exynos/fimc-is2/sensor/module_framework/cis/fimc-is-cis-5e9.c

index 3425d8e70208c817ade37c9f2dd92a4f4a6cee93..70b849bd3c8e8edf83bee2dd694ace9dce926b96 100644 (file)
@@ -286,9 +286,9 @@ int sensor_2x5sp_cis_otp_read(struct v4l2_subdev *subdev, struct fimc_is_device_
        int ret = 0;
        struct fimc_is_cis *cis;
        struct i2c_client *client;
-       u16 val, page;
+       u16 val = 1, page;
        int i;
-       int retry = 200;
+       int retry;
 
        FIMC_BUG(!subdev);
 
@@ -304,6 +304,7 @@ int sensor_2x5sp_cis_otp_read(struct v4l2_subdev *subdev, struct fimc_is_device_
                return -ENODEV;
        }
 
+       info("OTP read start\n");
        dbg_sensor(1, "%s, 1. sensor initial setting", __func__);
        CALL_CISOPS(cis, cis_set_global_setting, subdev);
        CALL_CISOPS(cis, cis_mode_change, subdev, 0);
@@ -324,14 +325,20 @@ int sensor_2x5sp_cis_otp_read(struct v4l2_subdev *subdev, struct fimc_is_device_
                fimc_is_sensor_write16(client, OTP_PAGE_CTRL, 0x0100);
 
                /* wait 0x0A00 == 0 [0]: read completed with no errors */
-               while (retry--) {
+               retry = 500;
+               while (retry > 0 && val) {
                        fimc_is_sensor_read16(client, OTP_PAGE_CTRL, &val);
                        if (val == 0)
                                break;
 
                        usleep_range(100, 100);
+                       retry--;
                }
 
+               if (!retry)
+                       err("%s: OTP page[%d] read fail with err(%d)\n",
+                               __func__, page, val);
+
                for (i = 0; i < OTP_PAGE_SIZE; i++) {
                        fimc_is_sensor_read8(client, OTP_PAGE_BASE + i, &device->otp_cal_buf[page][i]);
                        dbg_sensor(2, "cal: [%d][0x%x]: %x\n", page, OTP_PAGE_BASE + i, device->otp_cal_buf[page][i]);
@@ -343,7 +350,7 @@ int sensor_2x5sp_cis_otp_read(struct v4l2_subdev *subdev, struct fimc_is_device_
 
        fimc_is_sensor_write8(client, 0x0100, 0x00);
        msleep(20);
-       info("OTP end!!!!!\n");
+       info("OTP read end\n");
 
        I2C_MUTEX_UNLOCK(cis->i2c_lock);
 
index b5ce8fad09fe4e1a32e8a4a1e0fb32f6893edba9..9f4e414475e9ec6d808817c926c86a1b66fe0801 100755 (executable)
@@ -298,7 +298,7 @@ int sensor_5e9_cis_otp_read(struct v4l2_subdev *subdev, struct fimc_is_device_se
        struct i2c_client *client;
        u8 val, page;
        int i;
-       int retry = 200;
+       int retry;
 
        FIMC_BUG(!subdev);
 
@@ -314,6 +314,7 @@ int sensor_5e9_cis_otp_read(struct v4l2_subdev *subdev, struct fimc_is_device_se
                return -ENODEV;
        }
 
+       info("OTP read start\n");
        dbg_sensor(1, "%s, 1. sensor initial setting", __func__);
        CALL_CISOPS(cis, cis_set_global_setting, subdev);
        CALL_CISOPS(cis, cis_mode_change, subdev, 0);
@@ -334,14 +335,20 @@ int sensor_5e9_cis_otp_read(struct v4l2_subdev *subdev, struct fimc_is_device_se
                usleep_range(1000, 1001);
 
                /* wait 0x0A01 == 1 [0]: read completed with no errors */
-               while (retry--) {
+               retry = 500;
+               while (retry > 0) {
                        fimc_is_sensor_read8(client, OTP_PAGE_ERRCHK, &val);
                        if (val == 1)
                                break;
 
                        usleep_range(100, 100);
+                       retry--;
                }
 
+               if (!retry)
+                       err("%s: OTP page[%d] read fail with err(%d)\n",
+                               __func__, page, val);
+
                for (i = 0; i < OTP_PAGE_SIZE; i++) {
                        fimc_is_sensor_read8(client, OTP_PAGE_BASE + i, &device->otp_cal_buf[page][i]);
                        dbg_sensor(2, "cal: [%d][0x%x]: %x\n", page, OTP_PAGE_BASE + i, device->otp_cal_buf[page][i]);