1 From 84b781cb3722120bd0f54de194832378e547fe02 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 9 Feb 2024 18:52:02 +0000
4 Subject: [PATCH 0888/1085] media: rp1: cfe: Actually use the number of lanes
7 The driver was calling get_mbus_config to ask the sensor subdev
8 how many CSI2 data lanes it wished to use and with what other
9 properties, but then failed to pass that to the DPHY configuration.
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 .../media/platform/raspberrypi/rp1_cfe/cfe.c | 21 ++++++++-----------
14 .../media/platform/raspberrypi/rp1_cfe/csi2.h | 1 -
15 .../media/platform/raspberrypi/rp1_cfe/dphy.c | 2 +-
16 .../media/platform/raspberrypi/rp1_cfe/dphy.h | 3 ++-
17 4 files changed, 12 insertions(+), 15 deletions(-)
19 --- a/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
20 +++ b/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
21 @@ -1086,7 +1086,7 @@ static u64 sensor_link_rate(struct cfe_d
24 link_freq = v4l2_get_link_freq(subdev->ctrl_handler, fmt->depth,
25 - cfe->csi2.active_data_lanes * 2);
26 + cfe->csi2.dphy.active_lanes * 2);
30 @@ -1149,9 +1149,6 @@ static int cfe_start_streaming(struct vb
31 cfg_reg_write(cfe, MIPICFG_CFG, MIPICFG_CFG_SEL_CSI);
32 cfg_reg_write(cfe, MIPICFG_INTE, MIPICFG_INT_CSI_DMA | MIPICFG_INT_PISP_FE);
34 - cfe->csi2.active_data_lanes = cfe->csi2.dphy.num_lanes;
35 - cfe_dbg("Running with %u data lanes\n", cfe->csi2.active_data_lanes);
37 ret = v4l2_subdev_call(cfe->sensor, pad, get_mbus_config, 0,
39 if (ret < 0 && ret != -ENOIOCTLCMD) {
40 @@ -1159,17 +1156,17 @@ static int cfe_start_streaming(struct vb
44 - cfe->csi2.active_data_lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
45 - if (!cfe->csi2.active_data_lanes)
46 - cfe->csi2.active_data_lanes = cfe->csi2.dphy.num_lanes;
47 - if (cfe->csi2.active_data_lanes > cfe->csi2.dphy.num_lanes) {
48 + cfe->csi2.dphy.active_lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
49 + if (!cfe->csi2.dphy.active_lanes)
50 + cfe->csi2.dphy.active_lanes = cfe->csi2.dphy.max_lanes;
51 + if (cfe->csi2.dphy.active_lanes > cfe->csi2.dphy.max_lanes) {
52 cfe_err("Device has requested %u data lanes, which is >%u configured in DT\n",
53 - cfe->csi2.active_data_lanes, cfe->csi2.dphy.num_lanes);
54 + cfe->csi2.dphy.active_lanes, cfe->csi2.dphy.max_lanes);
59 - cfe_dbg("Configuring CSI-2 block\n");
60 + cfe_dbg("Configuring CSI-2 block - %u data lanes\n", cfe->csi2.dphy.active_lanes);
61 cfe->csi2.dphy.dphy_rate = sensor_link_rate(cfe) / 1000000UL;
62 csi2_open_rx(&cfe->csi2);
64 @@ -2167,11 +2164,11 @@ static int of_cfe_connect_subdevs(struct
68 - cfe->csi2.dphy.num_lanes = ep.bus.mipi_csi2.num_data_lanes;
69 + cfe->csi2.dphy.max_lanes = ep.bus.mipi_csi2.num_data_lanes;
70 cfe->csi2.bus_flags = ep.bus.mipi_csi2.flags;
72 cfe_dbg("subdevice %pOF: %u data lanes, flags=0x%08x, multipacket_line=%u\n",
73 - sensor_node, cfe->csi2.dphy.num_lanes, cfe->csi2.bus_flags,
74 + sensor_node, cfe->csi2.dphy.max_lanes, cfe->csi2.bus_flags,
75 cfe->csi2.multipacket_line);
77 /* Initialize and register the async notifier. */
78 --- a/drivers/media/platform/raspberrypi/rp1_cfe/csi2.h
79 +++ b/drivers/media/platform/raspberrypi/rp1_cfe/csi2.h
80 @@ -57,7 +57,6 @@ struct csi2_device {
82 enum v4l2_mbus_type bus_type;
83 unsigned int bus_flags;
84 - u32 active_data_lanes;
85 bool multipacket_line;
86 unsigned int num_lines[CSI2_NUM_CHANNELS];
88 --- a/drivers/media/platform/raspberrypi/rp1_cfe/dphy.c
89 +++ b/drivers/media/platform/raspberrypi/rp1_cfe/dphy.c
90 @@ -149,7 +149,7 @@ static void dphy_init(struct dphy_data *
92 void dphy_start(struct dphy_data *dphy)
94 - dw_csi2_host_write(dphy, N_LANES, (dphy->num_lanes - 1));
95 + dw_csi2_host_write(dphy, N_LANES, (dphy->active_lanes - 1));
97 dw_csi2_host_write(dphy, RESETN, 0xffffffff);
99 --- a/drivers/media/platform/raspberrypi/rp1_cfe/dphy.h
100 +++ b/drivers/media/platform/raspberrypi/rp1_cfe/dphy.h
101 @@ -16,7 +16,8 @@ struct dphy_data {
110 void dphy_probe(struct dphy_data *dphy);