MLK-22205-1: media: ov5640: remove HW reset for ov5640
authorGuoniu.Zhou <guoniu.zhou@nxp.com>
Tue, 9 Jul 2019 02:05:35 +0000 (10:05 +0800)
committerGuoniu.Zhou <guoniu.zhou@nxp.com>
Wed, 7 Aug 2019 06:29:03 +0000 (14:29 +0800)
Remove hardware reset pin for ov5640. Because the level of ov5640
reset pin will be low when system suspend and will be high when
system resume. The action will lead to reset ov5640 to default.
In order to fix the issue, driver load firmware before streaming
on every time, the expense is taking more time.

According to OV5640 datasheet, a reset can also be initiated through
the SCCB interface by setting register 0x3008[7] to high. So driver
can remove the hard reset and saving time of loading firmware.

Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
arch/arm64/boot/dts/freescale/fsl-imx8mn-ddr4-evk.dts
drivers/media/platform/imx8/ov5640_mipi_v3.c

index 578d386..774811d 100644 (file)
                assigned-clock-rates = <24000000>;
                csi_id = <0>;
                pwn-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
-               rst-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
                mclk = <24000000>;
                mclk_source = <0>;
                mipi_csi;
index 55f5294..b8fbc8a 100644 (file)
@@ -525,6 +525,9 @@ static inline void ov5640_power_down(struct ov5640 *sensor, int enable)
 
 static inline void ov5640_reset(struct ov5640 *sensor)
 {
+       if (sensor->pwn_gpio < 0 || sensor->rst_gpio < 0)
+               return;
+
        gpio_set_value_cansleep(sensor->pwn_gpio, 1);
        gpio_set_value_cansleep(sensor->rst_gpio, 0);
        udelay(5000);
@@ -708,6 +711,7 @@ static int ov5640_config_init(struct ov5640 *sensor)
 static void ov5640_start(struct ov5640 *sensor)
 {
        ov5640_write_reg(sensor, 0x4800, 0x04);
+       ov5640_write_reg(sensor, 0x3008, 0x02);
        ov5640_write_reg(sensor, 0x4202, 0x00);
 
        /* Color bar control */
@@ -749,6 +753,7 @@ static int ov5640_change_mode(struct ov5640 *sensor)
 static void ov5640_stop(struct ov5640 *sensor)
 {
        ov5640_write_reg(sensor, 0x4202, 0x0f);
+       ov5640_write_reg(sensor, 0x3008, 0x42);
        ov5640_write_reg(sensor, 0x4800, 0x24);
 }
 
@@ -1023,7 +1028,6 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd,
        if (format->which == V4L2_SUBDEV_FORMAT_TRY)
                return 0;
 
-       init_device(sensor);
        ret = ov5640_change_mode(sensor);
        sensor->fmt = fmt;
 
@@ -1282,7 +1286,7 @@ static int ov5640_probe(struct i2c_client *client,
 
        ov5640_regulator_enable(&client->dev);
 
-       ov5640_reset(sensor);
+       ov5640_power_down(sensor, 0);
 
        retval = ov5640_read_reg(sensor, OV5640_CHIP_ID_HIGH_BYTE,
                                &chip_id_high);