Skip to content

Commit 0bee9c6

Browse files
committed
drivers: media: cfe: Add non-continuous CSI-2 clock mode
Set the DPHY block to manual clock lane termination enable and HS mode i V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK is absent in the bus flags. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent 973fe60 commit 0bee9c6

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

drivers/media/platform/raspberrypi/rp1_cfe/cfe.c

+3
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,9 @@ static int cfe_start_streaming(struct vb2_queue *vq, unsigned int count)
11661166
goto err_disable_cfe;
11671167
}
11681168

1169+
cfe->csi2.dphy.noncontinuous_clock = mbus_config.bus.mipi_csi2.flags &
1170+
V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
1171+
11691172
cfe_dbg("Configuring CSI-2 block - %u data lanes\n", cfe->csi2.dphy.active_lanes);
11701173
cfe->csi2.dphy.dphy_rate = sensor_link_rate(cfe) / 1000000UL;
11711174
csi2_open_rx(&cfe->csi2);

drivers/media/platform/raspberrypi/rp1_cfe/dphy.c

+17
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define PHY2_TST_CTRL1 0x05c
3131

3232
/* DW dphy Host Transactions */
33+
#define DPHY_HS_RX_CTRL_CLK_OFFSET 0x34
3334
#define DPHY_HS_RX_CTRL_LANE0_OFFSET 0x44
3435
#define DPHY_PLL_INPUT_DIV_OFFSET 0x17
3536
#define DPHY_PLL_LOOP_DIV_OFFSET 0x18
@@ -128,6 +129,19 @@ static void dphy_set_hsfreqrange(struct dphy_data *dphy, uint32_t mbps)
128129
hsfreqrange_table[i][1] << 1);
129130
}
130131

132+
static void dphy_set_manual_clock_term(struct dphy_data *dphy)
133+
{
134+
/* See page 162 of the dphy databook */
135+
const u8 tst = (1 << 0) + /* HS RX power on */
136+
(1 << 1) + /* Bypass HS RX power on */
137+
(1 << 2) + /* HS RX cal enable */
138+
(0 << 3) + /* HS RX cal control */
139+
(1 << 4) + /* Term EN */
140+
(1 << 5); /* Term EN control */
141+
142+
dphy_transaction(dphy, DPHY_HS_RX_CTRL_CLK_OFFSET, tst);
143+
}
144+
131145
static void dphy_init(struct dphy_data *dphy)
132146
{
133147
dw_csi2_host_write(dphy, PHY_RSTZ, 0);
@@ -141,6 +155,9 @@ static void dphy_init(struct dphy_data *dphy)
141155

142156
dphy_set_hsfreqrange(dphy, dphy->dphy_rate);
143157

158+
if (!dphy->noncontinuous_clock)
159+
dphy_set_manual_clock_term(dphy);
160+
144161
usleep_range(5, 10);
145162
dw_csi2_host_write(dphy, PHY_SHUTDOWNZ, 1);
146163
usleep_range(5, 10);

drivers/media/platform/raspberrypi/rp1_cfe/dphy.h

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct dphy_data {
1818
u32 dphy_rate;
1919
u32 max_lanes;
2020
u32 active_lanes;
21+
bool noncontinuous_clock;
2122
};
2223

2324
void dphy_probe(struct dphy_data *dphy);

0 commit comments

Comments
 (0)