For imx8qxp/qm, gpio will go to low level when system suspend and
will to high when system resume. It will lead ov5640 sensor to reset.
So add reinitialization for sensor when system resume at first time.
For imx815, gpio will have no this issue because GPIO will keep high
when system suspend. So the patch is for fixing issue introduced by
MLK-22202-1. More info, please refer to the ticket.
OV5640 will work at DVP mode by default, but in our use case, it need
to work on MIPI mode, so we can know whether sensor is resetted by
system by checking 0x300E[2] bits.
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
#define OV5640_CHIP_ID_HIGH_BYTE 0x300A
#define OV5640_CHIP_ID_LOW_BYTE 0x300B
+#define OV5640_MIPI_CONTROLL_00 0x300E
+#define MIPI_CONTROLL00_MIPI_MODE BIT(2)
+
#define OV5640_SENS_PAD_SOURCE 0
#define OV5640_SENS_PADS_NUM 1
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct ov5640 *sensor = to_ov5640(client);
int ret;
+ u8 val;
if (format->pad)
return -EINVAL;
if (format->which == V4L2_SUBDEV_FORMAT_TRY)
return 0;
+ /* Need to reinitialize sensor after system suspend/resume */
+ ov5640_read_reg(sensor, OV5640_MIPI_CONTROLL_00, &val);
+ if (!(val & MIPI_CONTROLL00_MIPI_MODE))
+ init_device(sensor);
+
ret = ov5640_change_mode(sensor);
sensor->fmt = fmt;