Skip to content

Commit 092e8eb

Browse files
ezequielgarciamchehab
authored andcommitted
media: i2c: ov5645: Fix power sequence
This is mostly a port of Jacopo's fix: commit aa4bb8b Author: Jacopo Mondi <[email protected]> Date: Fri Jul 6 05:51:52 2018 -0400 media: ov5640: Re-work MIPI startup sequence In the OV5645 case, the changes are: - At set_power(1) time power up MIPI Tx/Rx and set data and clock lanes in LP11 during 'sleep' and 'idle' with MIPI clock in non-continuous mode. - At set_power(0) time power down MIPI Tx/Rx (in addition to the current power down of regulators and clock gating). - At s_stream time enable/disable the MIPI interface output. With this commit the sensor is able to enter LP-11 mode during power up, as expected by some CSI-2 controllers. Many thanks to Fabio Estevam for his help debugging this issue. Tested-by: Fabio Estevam <[email protected]> Signed-off-by: Ezequiel Garcia <[email protected]> Reviewed-by: Philipp Zabel <[email protected]> Reviewed-by: Jacopo Mondi <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 7ef57be commit 092e8eb

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

drivers/media/i2c/ov5645.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#define OV5645_CHIP_ID_HIGH_BYTE 0x56
4242
#define OV5645_CHIP_ID_LOW 0x300b
4343
#define OV5645_CHIP_ID_LOW_BYTE 0x45
44+
#define OV5645_IO_MIPI_CTRL00 0x300e
45+
#define OV5645_PAD_OUTPUT00 0x3019
4446
#define OV5645_AWB_MANUAL_CONTROL 0x3406
4547
#define OV5645_AWB_MANUAL_ENABLE BIT(0)
4648
#define OV5645_AEC_PK_MANUAL 0x3503
@@ -51,6 +53,7 @@
5153
#define OV5645_ISP_VFLIP BIT(2)
5254
#define OV5645_TIMING_TC_REG21 0x3821
5355
#define OV5645_SENSOR_MIRROR BIT(1)
56+
#define OV5645_MIPI_CTRL00 0x4800
5457
#define OV5645_PRE_ISP_TEST_SETTING_1 0x503d
5558
#define OV5645_TEST_PATTERN_MASK 0x3
5659
#define OV5645_SET_TEST_PATTERN(x) ((x) & OV5645_TEST_PATTERN_MASK)
@@ -124,7 +127,6 @@ static const struct reg_value ov5645_global_init_setting[] = {
124127
{ 0x3503, 0x07 },
125128
{ 0x3002, 0x1c },
126129
{ 0x3006, 0xc3 },
127-
{ 0x300e, 0x45 },
128130
{ 0x3017, 0x00 },
129131
{ 0x3018, 0x00 },
130132
{ 0x302e, 0x0b },
@@ -353,7 +355,10 @@ static const struct reg_value ov5645_global_init_setting[] = {
353355
{ 0x3a1f, 0x14 },
354356
{ 0x0601, 0x02 },
355357
{ 0x3008, 0x42 },
356-
{ 0x3008, 0x02 }
358+
{ 0x3008, 0x02 },
359+
{ OV5645_IO_MIPI_CTRL00, 0x40 },
360+
{ OV5645_MIPI_CTRL00, 0x24 },
361+
{ OV5645_PAD_OUTPUT00, 0x70 }
357362
};
358363

359364
static const struct reg_value ov5645_setting_sxga[] = {
@@ -690,13 +695,9 @@ static int ov5645_s_power(struct v4l2_subdev *sd, int on)
690695
goto exit;
691696
}
692697

693-
ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0,
694-
OV5645_SYSTEM_CTRL0_STOP);
695-
if (ret < 0) {
696-
ov5645_set_power_off(ov5645);
697-
goto exit;
698-
}
698+
usleep_range(500, 1000);
699699
} else {
700+
ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x58);
700701
ov5645_set_power_off(ov5645);
701702
}
702703
}
@@ -1002,11 +1003,20 @@ static int ov5645_s_stream(struct v4l2_subdev *subdev, int enable)
10021003
dev_err(ov5645->dev, "could not sync v4l2 controls\n");
10031004
return ret;
10041005
}
1006+
1007+
ret = ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x45);
1008+
if (ret < 0)
1009+
return ret;
1010+
10051011
ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0,
10061012
OV5645_SYSTEM_CTRL0_START);
10071013
if (ret < 0)
10081014
return ret;
10091015
} else {
1016+
ret = ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x40);
1017+
if (ret < 0)
1018+
return ret;
1019+
10101020
ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0,
10111021
OV5645_SYSTEM_CTRL0_STOP);
10121022
if (ret < 0)

0 commit comments

Comments
 (0)