bcm27xx: update to latest patches from RPi foundation
[openwrt/staging/wigyori.git] / target / linux / bcm27xx / patches-5.4 / 950-0654-media-i2c-imx219-Fix-power-sequence.patch
1 From 0fec1c81707f5335d0b04b5e97d2ddd0b902377b Mon Sep 17 00:00:00 2001
2 From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
3 Date: Tue, 10 Mar 2020 14:17:07 +0100
4 Subject: [PATCH] media: i2c: imx219: Fix power sequence
5
6 Commit ca45448a56659c6df6e0436188e97f6cc65dea8a upstream.
7
8 When supporting Rpi Camera v2 Module on the RZ/G2E, found the driver had
9 some issues with rcar mipi-csi driver. The sensor never entered into LP-11
10 state.
11
12 The powerup sequence in the datasheet[1] shows the sensor entering into
13 LP-11 in streaming mode, so to fix this issue transitions are performed
14 from "streaming -> standby" in the probe() after power up.
15
16 With this commit the sensor is able to enter LP-11 mode during power up,
17 as expected by some CSI-2 controllers.
18
19 [1] https://publiclab.org/system/images/photos/000/023/294/original/
20 RASPBERRY_PI_CAMERA_V2_DATASHEET_IMX219PQH5_7.0.0_Datasheet_XXX.PDF
21
22 Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
23 Acked-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
24 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
25 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
26 ---
27 drivers/media/i2c/imx219.c | 17 +++++++++++++++++
28 1 file changed, 17 insertions(+)
29
30 --- a/drivers/media/i2c/imx219.c
31 +++ b/drivers/media/i2c/imx219.c
32 @@ -1224,6 +1224,23 @@ static int imx219_probe(struct i2c_clien
33 /* Set default mode to max resolution */
34 imx219->mode = &supported_modes[0];
35
36 + /* sensor doesn't enter LP-11 state upon power up until and unless
37 + * streaming is started, so upon power up switch the modes to:
38 + * streaming -> standby
39 + */
40 + ret = imx219_write_reg(imx219, IMX219_REG_MODE_SELECT,
41 + IMX219_REG_VALUE_08BIT, IMX219_MODE_STREAMING);
42 + if (ret < 0)
43 + goto error_power_off;
44 + usleep_range(100, 110);
45 +
46 + /* put sensor back to standby mode */
47 + ret = imx219_write_reg(imx219, IMX219_REG_MODE_SELECT,
48 + IMX219_REG_VALUE_08BIT, IMX219_MODE_STANDBY);
49 + if (ret < 0)
50 + goto error_power_off;
51 + usleep_range(100, 110);
52 +
53 ret = imx219_init_controls(imx219);
54 if (ret)
55 goto error_power_off;