Skip to content

Commit a95253d

Browse files
Umang JainHans Verkuil
authored andcommitted
media: imx335: Support multiple link frequency
Support link frequency of 445MHz in addition to 594MHz. Break out the register set specific to each data lane rate and also add the general timing register set corresponding to the each data lane rate. Signed-off-by: Umang Jain <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 0862582 commit a95253d

File tree

1 file changed

+70
-14
lines changed

1 file changed

+70
-14
lines changed

drivers/media/i2c/imx335.c

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
#define IMX335_INCLK_RATE 24000000
5050

5151
/* CSI2 HW configuration */
52-
#define IMX335_LINK_FREQ 594000000LL
52+
#define IMX335_LINK_FREQ_594MHz 594000000LL
53+
#define IMX335_LINK_FREQ_445MHz 445500000LL
54+
5355
#define IMX335_NUM_DATA_LANES 4
5456

5557
#define IMX335_REG_MIN 0x00
@@ -99,7 +101,6 @@ static const char * const imx335_supply_name[] = {
99101
* @vblank_min: Minimum vertical blanking in lines
100102
* @vblank_max: Maximum vertical blanking in lines
101103
* @pclk: Sensor pixel clock
102-
* @link_freq_idx: Link frequency index
103104
* @reg_list: Register list for sensor mode
104105
*/
105106
struct imx335_mode {
@@ -111,7 +112,6 @@ struct imx335_mode {
111112
u32 vblank_min;
112113
u32 vblank_max;
113114
u64 pclk;
114-
u32 link_freq_idx;
115115
struct imx335_reg_list reg_list;
116116
};
117117

@@ -162,27 +162,17 @@ struct imx335 {
162162
u32 cur_mbus_code;
163163
};
164164

165-
static const s64 link_freq[] = {
166-
IMX335_LINK_FREQ,
167-
};
168-
169165
/* Sensor mode registers */
170166
static const struct imx335_reg mode_2592x1940_regs[] = {
171167
{0x3000, 0x01},
172168
{0x3002, 0x00},
173-
{0x300c, 0x3b},
174-
{0x300d, 0x2a},
175169
{0x3018, 0x04},
176170
{0x302c, 0x3c},
177171
{0x302e, 0x20},
178172
{0x3056, 0x94},
179173
{0x3074, 0xc8},
180174
{0x3076, 0x28},
181175
{0x304c, 0x00},
182-
{0x314c, 0xc6},
183-
{0x315a, 0x02},
184-
{0x3168, 0xa0},
185-
{0x316a, 0x7e},
186176
{0x31a1, 0x00},
187177
{0x3288, 0x21},
188178
{0x328a, 0x02},
@@ -268,6 +258,65 @@ static const struct imx335_reg raw12_framefmt_regs[] = {
268258
{0x341d, 0x00},
269259
};
270260

261+
static const struct imx335_reg mipi_data_rate_1188Mbps[] = {
262+
{0x300c, 0x3b},
263+
{0x300d, 0x2a},
264+
{0x314c, 0xc6},
265+
{0x314d, 0x00},
266+
{0x315a, 0x02},
267+
{0x3168, 0xa0},
268+
{0x316a, 0x7e},
269+
{0x319e, 0x01},
270+
{0x3a18, 0x8f},
271+
{0x3a1a, 0x4f},
272+
{0x3a1c, 0x47},
273+
{0x3a1e, 0x37},
274+
{0x3a1f, 0x01},
275+
{0x3a20, 0x4f},
276+
{0x3a22, 0x87},
277+
{0x3a24, 0x4f},
278+
{0x3a26, 0x7f},
279+
{0x3a28, 0x3f},
280+
};
281+
282+
static const struct imx335_reg mipi_data_rate_891Mbps[] = {
283+
{0x300c, 0x3b},
284+
{0x300d, 0x2a},
285+
{0x314c, 0x29},
286+
{0x314d, 0x01},
287+
{0x315a, 0x06},
288+
{0x3168, 0xa0},
289+
{0x316a, 0x7e},
290+
{0x319e, 0x02},
291+
{0x3a18, 0x7f},
292+
{0x3a1a, 0x37},
293+
{0x3a1c, 0x37},
294+
{0x3a1e, 0xf7},
295+
{0x3a20, 0x3f},
296+
{0x3a22, 0x6f},
297+
{0x3a24, 0x3f},
298+
{0x3a26, 0x5f},
299+
{0x3a28, 0x2f},
300+
};
301+
302+
static const s64 link_freq[] = {
303+
/* Corresponds to 1188Mbps data lane rate */
304+
IMX335_LINK_FREQ_594MHz,
305+
/* Corresponds to 891Mbps data lane rate */
306+
IMX335_LINK_FREQ_445MHz,
307+
};
308+
309+
static const struct imx335_reg_list link_freq_reglist[] = {
310+
{
311+
.num_of_regs = ARRAY_SIZE(mipi_data_rate_1188Mbps),
312+
.regs = mipi_data_rate_1188Mbps,
313+
},
314+
{
315+
.num_of_regs = ARRAY_SIZE(mipi_data_rate_891Mbps),
316+
.regs = mipi_data_rate_891Mbps,
317+
},
318+
};
319+
271320
static const u32 imx335_mbus_codes[] = {
272321
MEDIA_BUS_FMT_SRGGB12_1X12,
273322
MEDIA_BUS_FMT_SRGGB10_1X10,
@@ -282,7 +331,6 @@ static const struct imx335_mode supported_mode = {
282331
.vblank_min = 2560,
283332
.vblank_max = 133060,
284333
.pclk = 396000000,
285-
.link_freq_idx = 0,
286334
.reg_list = {
287335
.num_of_regs = ARRAY_SIZE(mode_2592x1940_regs),
288336
.regs = mode_2592x1940_regs,
@@ -765,6 +813,14 @@ static int imx335_start_streaming(struct imx335 *imx335)
765813
const struct imx335_reg_list *reg_list;
766814
int ret;
767815

816+
/* Setup PLL */
817+
reg_list = &link_freq_reglist[__ffs(imx335->link_freq_bitmap)];
818+
ret = imx335_write_regs(imx335, reg_list->regs, reg_list->num_of_regs);
819+
if (ret) {
820+
dev_err(imx335->dev, "%s failed to set plls\n", __func__);
821+
return ret;
822+
}
823+
768824
/* Write sensor mode registers */
769825
reg_list = &imx335->cur_mode->reg_list;
770826
ret = imx335_write_regs(imx335, reg_list->regs,

0 commit comments

Comments
 (0)