49
49
#define IMX335_INCLK_RATE 24000000
50
50
51
51
/* CSI2 HW configuration */
52
- #define IMX335_LINK_FREQ 594000000LL
52
+ #define IMX335_LINK_FREQ_594MHz 594000000LL
53
+ #define IMX335_LINK_FREQ_445MHz 445500000LL
54
+
53
55
#define IMX335_NUM_DATA_LANES 4
54
56
55
57
#define IMX335_REG_MIN 0x00
@@ -99,7 +101,6 @@ static const char * const imx335_supply_name[] = {
99
101
* @vblank_min: Minimum vertical blanking in lines
100
102
* @vblank_max: Maximum vertical blanking in lines
101
103
* @pclk: Sensor pixel clock
102
- * @link_freq_idx: Link frequency index
103
104
* @reg_list: Register list for sensor mode
104
105
*/
105
106
struct imx335_mode {
@@ -111,7 +112,6 @@ struct imx335_mode {
111
112
u32 vblank_min ;
112
113
u32 vblank_max ;
113
114
u64 pclk ;
114
- u32 link_freq_idx ;
115
115
struct imx335_reg_list reg_list ;
116
116
};
117
117
@@ -162,27 +162,17 @@ struct imx335 {
162
162
u32 cur_mbus_code ;
163
163
};
164
164
165
- static const s64 link_freq [] = {
166
- IMX335_LINK_FREQ ,
167
- };
168
-
169
165
/* Sensor mode registers */
170
166
static const struct imx335_reg mode_2592x1940_regs [] = {
171
167
{0x3000 , 0x01 },
172
168
{0x3002 , 0x00 },
173
- {0x300c , 0x3b },
174
- {0x300d , 0x2a },
175
169
{0x3018 , 0x04 },
176
170
{0x302c , 0x3c },
177
171
{0x302e , 0x20 },
178
172
{0x3056 , 0x94 },
179
173
{0x3074 , 0xc8 },
180
174
{0x3076 , 0x28 },
181
175
{0x304c , 0x00 },
182
- {0x314c , 0xc6 },
183
- {0x315a , 0x02 },
184
- {0x3168 , 0xa0 },
185
- {0x316a , 0x7e },
186
176
{0x31a1 , 0x00 },
187
177
{0x3288 , 0x21 },
188
178
{0x328a , 0x02 },
@@ -268,6 +258,65 @@ static const struct imx335_reg raw12_framefmt_regs[] = {
268
258
{0x341d , 0x00 },
269
259
};
270
260
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
+
271
320
static const u32 imx335_mbus_codes [] = {
272
321
MEDIA_BUS_FMT_SRGGB12_1X12 ,
273
322
MEDIA_BUS_FMT_SRGGB10_1X10 ,
@@ -282,7 +331,6 @@ static const struct imx335_mode supported_mode = {
282
331
.vblank_min = 2560 ,
283
332
.vblank_max = 133060 ,
284
333
.pclk = 396000000 ,
285
- .link_freq_idx = 0 ,
286
334
.reg_list = {
287
335
.num_of_regs = ARRAY_SIZE (mode_2592x1940_regs ),
288
336
.regs = mode_2592x1940_regs ,
@@ -765,6 +813,14 @@ static int imx335_start_streaming(struct imx335 *imx335)
765
813
const struct imx335_reg_list * reg_list ;
766
814
int ret ;
767
815
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
+
768
824
/* Write sensor mode registers */
769
825
reg_list = & imx335 -> cur_mode -> reg_list ;
770
826
ret = imx335_write_regs (imx335 , reg_list -> regs ,
0 commit comments