bcm27xx: 6.1: add kernel patches
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-6.1 / 950-0646-media-i2c-imx290-Simplify-imx290_set_data_lanes.patch
1 From 1551a08118c8e468b3afe0dd5ae0cfa47b7518e1 Mon Sep 17 00:00:00 2001
2 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 Date: Mon, 16 Jan 2023 15:44:53 +0100
4 Subject: [PATCH] media: i2c: imx290: Simplify imx290_set_data_lanes()
5
6 Upstream commit 76c001287f6a
7
8 There's no need to check for an incorrect number of data lanes in
9 imx290_set_data_lanes() as the value is validated at probe() time. Drop
10 the check.
11
12 The PHY_LANE_NUM and CSI_LANE_MODE registers are programmed with a value
13 equal to the number of lanes minus one. Compute it instead of handling
14 it in the switch/case.
15
16 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
17 Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com>
18 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
19 Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
20 ---
21 drivers/media/i2c/imx290.c | 17 +++++------------
22 1 file changed, 5 insertions(+), 12 deletions(-)
23
24 --- a/drivers/media/i2c/imx290.c
25 +++ b/drivers/media/i2c/imx290.c
26 @@ -512,28 +512,21 @@ static int imx290_set_register_array(str
27
28 static int imx290_set_data_lanes(struct imx290 *imx290)
29 {
30 - int ret = 0, laneval, frsel;
31 + int ret = 0;
32 + u32 frsel;
33
34 switch (imx290->nlanes) {
35 case 2:
36 - laneval = 0x01;
37 + default:
38 frsel = 0x02;
39 break;
40 case 4:
41 - laneval = 0x03;
42 frsel = 0x01;
43 break;
44 - default:
45 - /*
46 - * We should never hit this since the data lane count is
47 - * validated in probe itself
48 - */
49 - dev_err(imx290->dev, "Lane configuration not supported\n");
50 - return -EINVAL;
51 }
52
53 - imx290_write(imx290, IMX290_PHY_LANE_NUM, laneval, &ret);
54 - imx290_write(imx290, IMX290_CSI_LANE_MODE, laneval, &ret);
55 + imx290_write(imx290, IMX290_PHY_LANE_NUM, imx290->nlanes - 1, &ret);
56 + imx290_write(imx290, IMX290_CSI_LANE_MODE, imx290->nlanes - 1, &ret);
57 imx290_write(imx290, IMX290_FR_FDG_SEL, frsel, &ret);
58
59 return ret;