Skip to content

Commit d3127c3

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 <[email protected]>
1 parent 973fe60 commit d3127c3

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,10 @@ static int cfe_start_streaming(struct vb2_queue *vq, unsigned int count)
11561156
goto err_pm_put;
11571157
}
11581158

1159+
cfe->csi2.dphy.noncontinuous_clock =
1160+
(!ret ? mbus_config.bus.mipi_csi2.flags : cfe->csi2.bus_flags) &
1161+
V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
1162+
11591163
cfe->csi2.dphy.active_lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
11601164
if (!cfe->csi2.dphy.active_lanes)
11611165
cfe->csi2.dphy.active_lanes = cfe->csi2.dphy.max_lanes;

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

Lines changed: 25 additions & 0 deletions
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,29 @@ 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_clock_term(struct dphy_data *dphy, bool set_auto)
133+
{
134+
/* See page 162 of the dphy databook */
135+
const u8 tst_manual = (1 << 0) + /* HS RX power on */
136+
(1 << 1) + /* Bypass HS RX power on */
137+
(1 << 2) + /* HS RX cal enable */
138+
(0 << 3) + /* Bypass HS RX cal */
139+
(1 << 4) + /* Term EN */
140+
(1 << 5) + /* Bypass Term EN control */
141+
(2 << 6); /* Set 0 */
142+
143+
const u8 tst_auto = (0 << 0) + /* HS RX power on */
144+
(0 << 1) + /* FSM HS RX power on */
145+
(0 << 2) + /* HS RX cal enable */
146+
(0 << 3) + /* FSM HS RX cal control */
147+
(0 << 4) + /* Term EN */
148+
(0 << 5) + /* FSM Term EN control */
149+
(2 << 6); /* Set 0 */
150+
151+
dphy_transaction(dphy, DPHY_HS_RX_CTRL_CLK_OFFSET,
152+
set_auto ? tst_auto : tst_manual);
153+
}
154+
131155
static void dphy_init(struct dphy_data *dphy)
132156
{
133157
dw_csi2_host_write(dphy, PHY_RSTZ, 0);
@@ -140,6 +164,7 @@ static void dphy_init(struct dphy_data *dphy)
140164
usleep_range(15, 20);
141165

142166
dphy_set_hsfreqrange(dphy, dphy->dphy_rate);
167+
dphy_set_clock_term(dphy, dphy->noncontinuous_clock);
143168

144169
usleep_range(5, 10);
145170
dw_csi2_host_write(dphy, PHY_SHUTDOWNZ, 1);

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

Lines changed: 1 addition & 0 deletions
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)