xref: /linux/drivers/media/platform/qcom/camss/camss.c (revision ab93e0dd72c37d378dd936f031ffb83ff2bd87ce)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * camss.c
4  *
5  * Qualcomm MSM Camera Subsystem - Core
6  *
7  * Copyright (c) 2015, The Linux Foundation. All rights reserved.
8  * Copyright (C) 2015-2018 Linaro Ltd.
9  */
10 #include <linux/clk.h>
11 #include <linux/interconnect.h>
12 #include <linux/media-bus-format.h>
13 #include <linux/media.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/of.h>
17 #include <linux/of_device.h>
18 #include <linux/of_graph.h>
19 #include <linux/pm_runtime.h>
20 #include <linux/pm_domain.h>
21 #include <linux/slab.h>
22 #include <linux/videodev2.h>
23 
24 #include <media/media-device.h>
25 #include <media/v4l2-async.h>
26 #include <media/v4l2-device.h>
27 #include <media/v4l2-mc.h>
28 #include <media/v4l2-fwnode.h>
29 
30 #include "camss.h"
31 
32 #define CAMSS_CLOCK_MARGIN_NUMERATOR 105
33 #define CAMSS_CLOCK_MARGIN_DENOMINATOR 100
34 
35 static const struct parent_dev_ops vfe_parent_dev_ops;
36 
37 static const struct camss_subdev_resources csiphy_res_8x16[] = {
38 	/* CSIPHY0 */
39 	{
40 		.regulators = {},
41 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy0_timer" },
42 		.clock_rate = { { 0 },
43 				{ 0 },
44 				{ 0 },
45 				{ 100000000, 200000000 } },
46 		.reg = { "csiphy0", "csiphy0_clk_mux" },
47 		.interrupt = { "csiphy0" },
48 		.csiphy = {
49 			.id = 0,
50 			.hw_ops = &csiphy_ops_2ph_1_0,
51 			.formats = &csiphy_formats_8x16
52 		}
53 	},
54 
55 	/* CSIPHY1 */
56 	{
57 		.regulators = {},
58 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy1_timer" },
59 		.clock_rate = { { 0 },
60 				{ 0 },
61 				{ 0 },
62 				{ 100000000, 200000000 } },
63 		.reg = { "csiphy1", "csiphy1_clk_mux" },
64 		.interrupt = { "csiphy1" },
65 		.csiphy = {
66 			.id = 1,
67 			.hw_ops = &csiphy_ops_2ph_1_0,
68 			.formats = &csiphy_formats_8x16
69 		}
70 	}
71 };
72 
73 static const struct camss_subdev_resources csid_res_8x16[] = {
74 	/* CSID0 */
75 	{
76 		.regulators = { "vdda" },
77 		.clock = { "top_ahb", "ispif_ahb", "csi0_ahb", "ahb",
78 			   "csi0", "csi0_phy", "csi0_pix", "csi0_rdi" },
79 		.clock_rate = { { 0 },
80 				{ 0 },
81 				{ 0 },
82 				{ 0 },
83 				{ 100000000, 200000000 },
84 				{ 0 },
85 				{ 0 },
86 				{ 0 } },
87 		.reg = { "csid0" },
88 		.interrupt = { "csid0" },
89 		.csid = {
90 			.hw_ops = &csid_ops_4_1,
91 			.parent_dev_ops = &vfe_parent_dev_ops,
92 			.formats = &csid_formats_4_1
93 		}
94 	},
95 
96 	/* CSID1 */
97 	{
98 		.regulators = { "vdda" },
99 		.clock = { "top_ahb", "ispif_ahb", "csi1_ahb", "ahb",
100 			   "csi1", "csi1_phy", "csi1_pix", "csi1_rdi" },
101 		.clock_rate = { { 0 },
102 				{ 0 },
103 				{ 0 },
104 				{ 0 },
105 				{ 100000000, 200000000 },
106 				{ 0 },
107 				{ 0 },
108 				{ 0 } },
109 		.reg = { "csid1" },
110 		.interrupt = { "csid1" },
111 		.csid = {
112 			.hw_ops = &csid_ops_4_1,
113 			.parent_dev_ops = &vfe_parent_dev_ops,
114 			.formats = &csid_formats_4_1
115 		}
116 	},
117 };
118 
119 static const struct camss_subdev_resources ispif_res_8x16 = {
120 	/* ISPIF */
121 	.clock = { "top_ahb", "ahb", "ispif_ahb",
122 		   "csi0", "csi0_pix", "csi0_rdi",
123 		   "csi1", "csi1_pix", "csi1_rdi" },
124 	.clock_for_reset = { "vfe0", "csi_vfe0" },
125 	.reg = { "ispif", "csi_clk_mux" },
126 	.interrupt = { "ispif" },
127 };
128 
129 static const struct camss_subdev_resources vfe_res_8x16[] = {
130 	/* VFE0 */
131 	{
132 		.regulators = {},
133 		.clock = { "top_ahb", "vfe0", "csi_vfe0",
134 			   "vfe_ahb", "vfe_axi", "ahb" },
135 		.clock_rate = { { 0 },
136 				{ 50000000, 80000000, 100000000, 160000000,
137 				  177780000, 200000000, 266670000, 320000000,
138 				  400000000, 465000000 },
139 				{ 0 },
140 				{ 0 },
141 				{ 0 },
142 				{ 0 },
143 				{ 0 },
144 				{ 0 },
145 				{ 0 } },
146 		.reg = { "vfe0" },
147 		.interrupt = { "vfe0" },
148 		.vfe = {
149 			.line_num = 3,
150 			.hw_ops = &vfe_ops_4_1,
151 			.formats_rdi = &vfe_formats_rdi_8x16,
152 			.formats_pix = &vfe_formats_pix_8x16
153 		}
154 	}
155 };
156 
157 static const struct camss_subdev_resources csid_res_8x53[] = {
158 	/* CSID0 */
159 	{
160 		.regulators = { "vdda" },
161 		.clock = { "top_ahb", "ispif_ahb", "csi0_ahb", "ahb",
162 			   "csi0", "csi0_phy", "csi0_pix", "csi0_rdi" },
163 		.clock_rate = { { 0 },
164 				{ 0 },
165 				{ 0 },
166 				{ 0 },
167 				{ 100000000, 200000000, 310000000,
168 				  400000000, 465000000 },
169 				{ 0 },
170 				{ 0 },
171 				{ 0 } },
172 		.reg = { "csid0" },
173 		.interrupt = { "csid0" },
174 		.csid = {
175 			.hw_ops = &csid_ops_4_7,
176 			.parent_dev_ops = &vfe_parent_dev_ops,
177 			.formats = &csid_formats_4_7
178 		}
179 	},
180 
181 	/* CSID1 */
182 	{
183 		.regulators = { "vdda" },
184 		.clock = { "top_ahb", "ispif_ahb", "csi1_ahb", "ahb",
185 			   "csi1", "csi1_phy", "csi1_pix", "csi1_rdi" },
186 		.clock_rate = { { 0 },
187 				{ 0 },
188 				{ 0 },
189 				{ 0 },
190 				{ 100000000, 200000000, 310000000,
191 				  400000000, 465000000 },
192 				{ 0 },
193 				{ 0 },
194 				{ 0 } },
195 		.reg = { "csid1" },
196 		.interrupt = { "csid1" },
197 		.csid = {
198 			.hw_ops = &csid_ops_4_7,
199 			.parent_dev_ops = &vfe_parent_dev_ops,
200 			.formats = &csid_formats_4_7
201 		}
202 	},
203 
204 	/* CSID2 */
205 	{
206 		.regulators = { "vdda" },
207 		.clock = { "top_ahb", "ispif_ahb", "csi2_ahb", "ahb",
208 			   "csi2", "csi2_phy", "csi2_pix", "csi2_rdi" },
209 		.clock_rate = { { 0 },
210 				{ 0 },
211 				{ 0 },
212 				{ 0 },
213 				{ 100000000, 200000000, 310000000,
214 				  400000000, 465000000 },
215 				{ 0 },
216 				{ 0 },
217 				{ 0 } },
218 		.reg = { "csid2" },
219 		.interrupt = { "csid2" },
220 		.csid = {
221 			.hw_ops = &csid_ops_4_7,
222 			.parent_dev_ops = &vfe_parent_dev_ops,
223 			.formats = &csid_formats_4_7
224 		}
225 	},
226 };
227 
228 static const struct camss_subdev_resources ispif_res_8x53 = {
229 	/* ISPIF */
230 	.clock = { "top_ahb", "ahb", "ispif_ahb",
231 		   "csi0", "csi0_pix", "csi0_rdi",
232 		   "csi1", "csi1_pix", "csi1_rdi",
233 		   "csi2", "csi2_pix", "csi2_rdi" },
234 	.clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" },
235 	.reg = { "ispif", "csi_clk_mux" },
236 	.interrupt = { "ispif" },
237 };
238 
239 static const struct camss_subdev_resources vfe_res_8x53[] = {
240 	/* VFE0 */
241 	{
242 		.regulators = {},
243 		.clock = { "top_ahb", "ahb", "ispif_ahb",
244 			   "vfe0", "csi_vfe0", "vfe0_ahb", "vfe0_axi" },
245 		.clock_rate = { { 0 },
246 				{ 0 },
247 				{ 0 },
248 				{ 50000000, 100000000, 133330000,
249 				  160000000, 200000000, 266670000,
250 				  310000000, 400000000, 465000000 },
251 				{ 0 },
252 				{ 0 },
253 				{ 0 } },
254 		.reg = { "vfe0" },
255 		.interrupt = { "vfe0" },
256 		.vfe = {
257 			.line_num = 3,
258 			.has_pd = true,
259 			.pd_name = "vfe0",
260 			.hw_ops = &vfe_ops_4_1,
261 			.formats_rdi = &vfe_formats_rdi_8x16,
262 			.formats_pix = &vfe_formats_pix_8x16
263 		}
264 	},
265 
266 	/* VFE1 */
267 	{
268 		.regulators = {},
269 		.clock = { "top_ahb", "ahb", "ispif_ahb",
270 			   "vfe1", "csi_vfe1", "vfe1_ahb", "vfe1_axi" },
271 		.clock_rate = { { 0 },
272 				{ 0 },
273 				{ 0 },
274 				{ 50000000, 100000000, 133330000,
275 				  160000000, 200000000, 266670000,
276 				  310000000, 400000000, 465000000 },
277 				{ 0 },
278 				{ 0 },
279 				{ 0 } },
280 		.reg = { "vfe1" },
281 		.interrupt = { "vfe1" },
282 		.vfe = {
283 			.line_num = 3,
284 			.has_pd = true,
285 			.pd_name = "vfe1",
286 			.hw_ops = &vfe_ops_4_1,
287 			.formats_rdi = &vfe_formats_rdi_8x16,
288 			.formats_pix = &vfe_formats_pix_8x16
289 		}
290 	}
291 };
292 
293 static const struct resources_icc icc_res_8x53[] = {
294 	{
295 		.name = "cam_ahb",
296 		.icc_bw_tbl.avg = 38400,
297 		.icc_bw_tbl.peak = 76800,
298 	},
299 	{
300 		.name = "cam_vfe0_mem",
301 		.icc_bw_tbl.avg = 939524,
302 		.icc_bw_tbl.peak = 1342177,
303 	},
304 	{
305 		.name = "cam_vfe1_mem",
306 		.icc_bw_tbl.avg = 939524,
307 		.icc_bw_tbl.peak = 1342177,
308 	},
309 };
310 
311 static const struct camss_subdev_resources csiphy_res_8x96[] = {
312 	/* CSIPHY0 */
313 	{
314 		.regulators = {},
315 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy0_timer" },
316 		.clock_rate = { { 0 },
317 				{ 0 },
318 				{ 0 },
319 				{ 100000000, 200000000, 266666667 } },
320 		.reg = { "csiphy0", "csiphy0_clk_mux" },
321 		.interrupt = { "csiphy0" },
322 		.csiphy = {
323 			.id = 0,
324 			.hw_ops = &csiphy_ops_3ph_1_0,
325 			.formats = &csiphy_formats_8x96
326 		}
327 	},
328 
329 	/* CSIPHY1 */
330 	{
331 		.regulators = {},
332 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy1_timer" },
333 		.clock_rate = { { 0 },
334 				{ 0 },
335 				{ 0 },
336 				{ 100000000, 200000000, 266666667 } },
337 		.reg = { "csiphy1", "csiphy1_clk_mux" },
338 		.interrupt = { "csiphy1" },
339 		.csiphy = {
340 			.id = 1,
341 			.hw_ops = &csiphy_ops_3ph_1_0,
342 			.formats = &csiphy_formats_8x96
343 		}
344 	},
345 
346 	/* CSIPHY2 */
347 	{
348 		.regulators = {},
349 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy2_timer" },
350 		.clock_rate = { { 0 },
351 				{ 0 },
352 				{ 0 },
353 				{ 100000000, 200000000, 266666667 } },
354 		.reg = { "csiphy2", "csiphy2_clk_mux" },
355 		.interrupt = { "csiphy2" },
356 		.csiphy = {
357 			.id = 2,
358 			.hw_ops = &csiphy_ops_3ph_1_0,
359 			.formats = &csiphy_formats_8x96
360 		}
361 	}
362 };
363 
364 static const struct camss_subdev_resources csid_res_8x96[] = {
365 	/* CSID0 */
366 	{
367 		.regulators = { "vdda" },
368 		.clock = { "top_ahb", "ispif_ahb", "csi0_ahb", "ahb",
369 			   "csi0", "csi0_phy", "csi0_pix", "csi0_rdi" },
370 		.clock_rate = { { 0 },
371 				{ 0 },
372 				{ 0 },
373 				{ 0 },
374 				{ 100000000, 200000000, 266666667 },
375 				{ 0 },
376 				{ 0 },
377 				{ 0 } },
378 		.reg = { "csid0" },
379 		.interrupt = { "csid0" },
380 		.csid = {
381 			.hw_ops = &csid_ops_4_7,
382 			.parent_dev_ops = &vfe_parent_dev_ops,
383 			.formats = &csid_formats_4_7
384 		}
385 	},
386 
387 	/* CSID1 */
388 	{
389 		.regulators = { "vdda" },
390 		.clock = { "top_ahb", "ispif_ahb", "csi1_ahb", "ahb",
391 			   "csi1", "csi1_phy", "csi1_pix", "csi1_rdi" },
392 		.clock_rate = { { 0 },
393 				{ 0 },
394 				{ 0 },
395 				{ 0 },
396 				{ 100000000, 200000000, 266666667 },
397 				{ 0 },
398 				{ 0 },
399 				{ 0 } },
400 		.reg = { "csid1" },
401 		.interrupt = { "csid1" },
402 		.csid = {
403 			.hw_ops = &csid_ops_4_7,
404 			.parent_dev_ops = &vfe_parent_dev_ops,
405 			.formats = &csid_formats_4_7
406 		}
407 	},
408 
409 	/* CSID2 */
410 	{
411 		.regulators = { "vdda" },
412 		.clock = { "top_ahb", "ispif_ahb", "csi2_ahb", "ahb",
413 			   "csi2", "csi2_phy", "csi2_pix", "csi2_rdi" },
414 		.clock_rate = { { 0 },
415 				{ 0 },
416 				{ 0 },
417 				{ 0 },
418 				{ 100000000, 200000000, 266666667 },
419 				{ 0 },
420 				{ 0 },
421 				{ 0 } },
422 		.reg = { "csid2" },
423 		.interrupt = { "csid2" },
424 		.csid = {
425 			.hw_ops = &csid_ops_4_7,
426 			.parent_dev_ops = &vfe_parent_dev_ops,
427 			.formats = &csid_formats_4_7
428 		}
429 	},
430 
431 	/* CSID3 */
432 	{
433 		.regulators = { "vdda" },
434 		.clock = { "top_ahb", "ispif_ahb", "csi3_ahb", "ahb",
435 			   "csi3", "csi3_phy", "csi3_pix", "csi3_rdi" },
436 		.clock_rate = { { 0 },
437 				{ 0 },
438 				{ 0 },
439 				{ 0 },
440 				{ 100000000, 200000000, 266666667 },
441 				{ 0 },
442 				{ 0 },
443 				{ 0 } },
444 		.reg = { "csid3" },
445 		.interrupt = { "csid3" },
446 		.csid = {
447 			.hw_ops = &csid_ops_4_7,
448 			.parent_dev_ops = &vfe_parent_dev_ops,
449 			.formats = &csid_formats_4_7
450 		}
451 	}
452 };
453 
454 static const struct camss_subdev_resources ispif_res_8x96 = {
455 	/* ISPIF */
456 	.clock = { "top_ahb", "ahb", "ispif_ahb",
457 		   "csi0", "csi0_pix", "csi0_rdi",
458 		   "csi1", "csi1_pix", "csi1_rdi",
459 		   "csi2", "csi2_pix", "csi2_rdi",
460 		   "csi3", "csi3_pix", "csi3_rdi" },
461 	.clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" },
462 	.reg = { "ispif", "csi_clk_mux" },
463 	.interrupt = { "ispif" },
464 };
465 
466 static const struct camss_subdev_resources vfe_res_8x96[] = {
467 	/* VFE0 */
468 	{
469 		.regulators = {},
470 		.clock = { "top_ahb", "ahb", "vfe0", "csi_vfe0", "vfe_ahb",
471 			   "vfe0_ahb", "vfe_axi", "vfe0_stream"},
472 		.clock_rate = { { 0 },
473 				{ 0 },
474 				{ 75000000, 100000000, 300000000,
475 				  320000000, 480000000, 600000000 },
476 				{ 0 },
477 				{ 0 },
478 				{ 0 },
479 				{ 0 },
480 				{ 0 } },
481 		.reg = { "vfe0" },
482 		.interrupt = { "vfe0" },
483 		.vfe = {
484 			.line_num = 3,
485 			.has_pd = true,
486 			.hw_ops = &vfe_ops_4_7,
487 			.formats_rdi = &vfe_formats_rdi_8x96,
488 			.formats_pix = &vfe_formats_pix_8x96
489 		}
490 	},
491 
492 	/* VFE1 */
493 	{
494 		.regulators = {},
495 		.clock = { "top_ahb", "ahb", "vfe1", "csi_vfe1", "vfe_ahb",
496 			   "vfe1_ahb", "vfe_axi", "vfe1_stream"},
497 		.clock_rate = { { 0 },
498 				{ 0 },
499 				{ 75000000, 100000000, 300000000,
500 				  320000000, 480000000, 600000000 },
501 				{ 0 },
502 				{ 0 },
503 				{ 0 },
504 				{ 0 },
505 				{ 0 } },
506 		.reg = { "vfe1" },
507 		.interrupt = { "vfe1" },
508 		.vfe = {
509 			.line_num = 3,
510 			.has_pd = true,
511 			.hw_ops = &vfe_ops_4_7,
512 			.formats_rdi = &vfe_formats_rdi_8x96,
513 			.formats_pix = &vfe_formats_pix_8x96
514 		}
515 	}
516 };
517 
518 static const struct camss_subdev_resources csiphy_res_660[] = {
519 	/* CSIPHY0 */
520 	{
521 		.regulators = {},
522 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy0_timer",
523 			   "csi0_phy", "csiphy_ahb2crif" },
524 		.clock_rate = { { 0 },
525 				{ 0 },
526 				{ 0 },
527 				{ 100000000, 200000000, 269333333 },
528 				{ 0 } },
529 		.reg = { "csiphy0", "csiphy0_clk_mux" },
530 		.interrupt = { "csiphy0" },
531 		.csiphy = {
532 			.id = 0,
533 			.hw_ops = &csiphy_ops_3ph_1_0,
534 			.formats = &csiphy_formats_8x96
535 		}
536 	},
537 
538 	/* CSIPHY1 */
539 	{
540 		.regulators = {},
541 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy1_timer",
542 			   "csi1_phy", "csiphy_ahb2crif" },
543 		.clock_rate = { { 0 },
544 				{ 0 },
545 				{ 0 },
546 				{ 100000000, 200000000, 269333333 },
547 				{ 0 } },
548 		.reg = { "csiphy1", "csiphy1_clk_mux" },
549 		.interrupt = { "csiphy1" },
550 		.csiphy = {
551 			.id = 1,
552 			.hw_ops = &csiphy_ops_3ph_1_0,
553 			.formats = &csiphy_formats_8x96
554 		}
555 	},
556 
557 	/* CSIPHY2 */
558 	{
559 		.regulators = {},
560 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy2_timer",
561 			   "csi2_phy", "csiphy_ahb2crif" },
562 		.clock_rate = { { 0 },
563 				{ 0 },
564 				{ 0 },
565 				{ 100000000, 200000000, 269333333 },
566 				{ 0 } },
567 		.reg = { "csiphy2", "csiphy2_clk_mux" },
568 		.interrupt = { "csiphy2" },
569 		.csiphy = {
570 			.id = 2,
571 			.hw_ops = &csiphy_ops_3ph_1_0,
572 			.formats = &csiphy_formats_8x96
573 		}
574 	}
575 };
576 
577 static const struct camss_subdev_resources csid_res_660[] = {
578 	/* CSID0 */
579 	{
580 		.regulators = { "vdda", "vdd_sec" },
581 		.clock = { "top_ahb", "ispif_ahb", "csi0_ahb", "ahb",
582 			   "csi0", "csi0_phy", "csi0_pix", "csi0_rdi",
583 			   "cphy_csid0" },
584 		.clock_rate = { { 0 },
585 				{ 0 },
586 				{ 0 },
587 				{ 0 },
588 				{ 100000000, 200000000, 310000000,
589 				  404000000, 465000000 },
590 				{ 0 },
591 				{ 0 },
592 				{ 0 },
593 				{ 0 } },
594 		.reg = { "csid0" },
595 		.interrupt = { "csid0" },
596 		.csid = {
597 			.hw_ops = &csid_ops_4_7,
598 			.parent_dev_ops = &vfe_parent_dev_ops,
599 			.formats = &csid_formats_4_7
600 		}
601 	},
602 
603 	/* CSID1 */
604 	{
605 		.regulators = { "vdda", "vdd_sec" },
606 		.clock = { "top_ahb", "ispif_ahb", "csi1_ahb", "ahb",
607 			   "csi1", "csi1_phy", "csi1_pix", "csi1_rdi",
608 			   "cphy_csid1" },
609 		.clock_rate = { { 0 },
610 				{ 0 },
611 				{ 0 },
612 				{ 0 },
613 				{ 100000000, 200000000, 310000000,
614 				  404000000, 465000000 },
615 				{ 0 },
616 				{ 0 },
617 				{ 0 },
618 				{ 0 } },
619 		.reg = { "csid1" },
620 		.interrupt = { "csid1" },
621 		.csid = {
622 			.hw_ops = &csid_ops_4_7,
623 			.parent_dev_ops = &vfe_parent_dev_ops,
624 			.formats = &csid_formats_4_7
625 		}
626 	},
627 
628 	/* CSID2 */
629 	{
630 		.regulators = { "vdda", "vdd_sec" },
631 		.clock = { "top_ahb", "ispif_ahb", "csi2_ahb", "ahb",
632 			   "csi2", "csi2_phy", "csi2_pix", "csi2_rdi",
633 			   "cphy_csid2" },
634 		.clock_rate = { { 0 },
635 				{ 0 },
636 				{ 0 },
637 				{ 0 },
638 				{ 100000000, 200000000, 310000000,
639 				  404000000, 465000000 },
640 				{ 0 },
641 				{ 0 },
642 				{ 0 },
643 				{ 0 } },
644 		.reg = { "csid2" },
645 		.interrupt = { "csid2" },
646 		.csid = {
647 			.hw_ops = &csid_ops_4_7,
648 			.parent_dev_ops = &vfe_parent_dev_ops,
649 			.formats = &csid_formats_4_7
650 		}
651 	},
652 
653 	/* CSID3 */
654 	{
655 		.regulators = { "vdda", "vdd_sec" },
656 		.clock = { "top_ahb", "ispif_ahb", "csi3_ahb", "ahb",
657 			   "csi3", "csi3_phy", "csi3_pix", "csi3_rdi",
658 			   "cphy_csid3" },
659 		.clock_rate = { { 0 },
660 				{ 0 },
661 				{ 0 },
662 				{ 0 },
663 				{ 100000000, 200000000, 310000000,
664 				  404000000, 465000000 },
665 				{ 0 },
666 				{ 0 },
667 				{ 0 },
668 				{ 0 } },
669 		.reg = { "csid3" },
670 		.interrupt = { "csid3" },
671 		.csid = {
672 			.hw_ops = &csid_ops_4_7,
673 			.parent_dev_ops = &vfe_parent_dev_ops,
674 			.formats = &csid_formats_4_7
675 		}
676 	}
677 };
678 
679 static const struct camss_subdev_resources ispif_res_660 = {
680 	/* ISPIF */
681 	.clock = { "top_ahb", "ahb", "ispif_ahb",
682 		   "csi0", "csi0_pix", "csi0_rdi",
683 		   "csi1", "csi1_pix", "csi1_rdi",
684 		   "csi2", "csi2_pix", "csi2_rdi",
685 		   "csi3", "csi3_pix", "csi3_rdi" },
686 	.clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" },
687 	.reg = { "ispif", "csi_clk_mux" },
688 	.interrupt = { "ispif" },
689 };
690 
691 static const struct camss_subdev_resources vfe_res_660[] = {
692 	/* VFE0 */
693 	{
694 		.regulators = {},
695 		.clock = { "throttle_axi", "top_ahb", "ahb", "vfe0",
696 			   "csi_vfe0", "vfe_ahb", "vfe0_ahb", "vfe_axi",
697 			   "vfe0_stream"},
698 		.clock_rate = { { 0 },
699 				{ 0 },
700 				{ 0 },
701 				{ 120000000, 200000000, 256000000,
702 				  300000000, 404000000, 480000000,
703 				  540000000, 576000000 },
704 				{ 0 },
705 				{ 0 },
706 				{ 0 },
707 				{ 0 },
708 				{ 0 } },
709 		.reg = { "vfe0" },
710 		.interrupt = { "vfe0" },
711 		.vfe = {
712 			.line_num = 3,
713 			.has_pd = true,
714 			.hw_ops = &vfe_ops_4_8,
715 			.formats_rdi = &vfe_formats_rdi_8x96,
716 			.formats_pix = &vfe_formats_pix_8x96
717 		}
718 	},
719 
720 	/* VFE1 */
721 	{
722 		.regulators = {},
723 		.clock = { "throttle_axi", "top_ahb", "ahb", "vfe1",
724 			   "csi_vfe1", "vfe_ahb", "vfe1_ahb", "vfe_axi",
725 			   "vfe1_stream"},
726 		.clock_rate = { { 0 },
727 				{ 0 },
728 				{ 0 },
729 				{ 120000000, 200000000, 256000000,
730 				  300000000, 404000000, 480000000,
731 				  540000000, 576000000 },
732 				{ 0 },
733 				{ 0 },
734 				{ 0 },
735 				{ 0 },
736 				{ 0 } },
737 		.reg = { "vfe1" },
738 		.interrupt = { "vfe1" },
739 		.vfe = {
740 			.line_num = 3,
741 			.has_pd = true,
742 			.hw_ops = &vfe_ops_4_8,
743 			.formats_rdi = &vfe_formats_rdi_8x96,
744 			.formats_pix = &vfe_formats_pix_8x96
745 		}
746 	}
747 };
748 
749 static const struct camss_subdev_resources csiphy_res_670[] = {
750 	/* CSIPHY0 */
751 	{
752 		.regulators = { "vdda-phy", "vdda-pll" },
753 		.clock = { "soc_ahb", "cpas_ahb",
754 			   "csiphy0", "csiphy0_timer" },
755 		.clock_rate = { { 0 },
756 				{ 0 },
757 				{ 0 },
758 				{ 19200000, 240000000, 269333333 } },
759 		.reg = { "csiphy0" },
760 		.interrupt = { "csiphy0" },
761 		.csiphy = {
762 			.id = 0,
763 			.hw_ops = &csiphy_ops_3ph_1_0,
764 			.formats = &csiphy_formats_sdm845
765 		}
766 	},
767 
768 	/* CSIPHY1 */
769 	{
770 		.regulators = { "vdda-phy", "vdda-pll" },
771 		.clock = { "soc_ahb", "cpas_ahb",
772 			   "csiphy1", "csiphy1_timer" },
773 		.clock_rate = { { 0 },
774 				{ 0 },
775 				{ 0 },
776 				{ 19200000, 240000000, 269333333 } },
777 		.reg = { "csiphy1" },
778 		.interrupt = { "csiphy1" },
779 		.csiphy = {
780 			.id = 1,
781 			.hw_ops = &csiphy_ops_3ph_1_0,
782 			.formats = &csiphy_formats_sdm845
783 		}
784 	},
785 
786 	/* CSIPHY2 */
787 	{
788 		.regulators = { "vdda-phy", "vdda-pll" },
789 		.clock = { "soc_ahb", "cpas_ahb",
790 			   "csiphy2", "csiphy2_timer" },
791 		.clock_rate = { { 0 },
792 				{ 0 },
793 				{ 0 },
794 				{ 19200000, 240000000, 269333333 } },
795 		.reg = { "csiphy2" },
796 		.interrupt = { "csiphy2" },
797 		.csiphy = {
798 			.id = 2,
799 			.hw_ops = &csiphy_ops_3ph_1_0,
800 			.formats = &csiphy_formats_sdm845
801 		}
802 	}
803 };
804 
805 static const struct camss_subdev_resources csid_res_670[] = {
806 	/* CSID0 */
807 	{
808 		.regulators = {},
809 		.clock = { "cpas_ahb", "soc_ahb", "vfe0",
810 			   "vfe0_cphy_rx", "csi0" },
811 		.clock_rate = { { 0 },
812 				{ 0 },
813 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
814 				{ 384000000 },
815 				{ 19200000, 75000000, 384000000, 538666667 } },
816 		.reg = { "csid0" },
817 		.interrupt = { "csid0" },
818 		.csid = {
819 			.hw_ops = &csid_ops_gen2,
820 			.parent_dev_ops = &vfe_parent_dev_ops,
821 			.formats = &csid_formats_gen2
822 		}
823 	},
824 
825 	/* CSID1 */
826 	{
827 		.regulators = {},
828 		.clock = { "cpas_ahb", "soc_ahb", "vfe1",
829 			   "vfe1_cphy_rx", "csi1" },
830 		.clock_rate = { { 0 },
831 				{ 0 },
832 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
833 				{ 384000000 },
834 				{ 19200000, 75000000, 384000000, 538666667 } },
835 		.reg = { "csid1" },
836 		.interrupt = { "csid1" },
837 		.csid = {
838 			.hw_ops = &csid_ops_gen2,
839 			.parent_dev_ops = &vfe_parent_dev_ops,
840 			.formats = &csid_formats_gen2
841 		}
842 	},
843 
844 	/* CSID2 */
845 	{
846 		.regulators = {},
847 		.clock = { "cpas_ahb", "soc_ahb", "vfe_lite",
848 			   "vfe_lite_cphy_rx", "csi2" },
849 		.clock_rate = { { 0 },
850 				{ 0 },
851 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
852 				{ 384000000 },
853 				{ 19200000, 75000000, 384000000, 538666667 } },
854 		.reg = { "csid2" },
855 		.interrupt = { "csid2" },
856 		.csid = {
857 			.is_lite = true,
858 			.hw_ops = &csid_ops_gen2,
859 			.parent_dev_ops = &vfe_parent_dev_ops,
860 			.formats = &csid_formats_gen2
861 		}
862 	}
863 };
864 
865 static const struct camss_subdev_resources vfe_res_670[] = {
866 	/* VFE0 */
867 	{
868 		.regulators = {},
869 		.clock = { "camnoc_axi", "cpas_ahb", "soc_ahb",
870 			   "vfe0", "vfe0_axi" },
871 		.clock_rate = { { 0 },
872 				{ 0 },
873 				{ 0 },
874 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
875 				{ 0 } },
876 		.reg = { "vfe0" },
877 		.interrupt = { "vfe0" },
878 		.vfe = {
879 			.line_num = 4,
880 			.has_pd = true,
881 			.pd_name = "ife0",
882 			.hw_ops = &vfe_ops_170,
883 			.formats_rdi = &vfe_formats_rdi_845,
884 			.formats_pix = &vfe_formats_pix_845
885 		}
886 	},
887 
888 	/* VFE1 */
889 	{
890 		.regulators = {},
891 		.clock = { "camnoc_axi", "cpas_ahb", "soc_ahb",
892 			   "vfe1", "vfe1_axi" },
893 		.clock_rate = { { 0 },
894 				{ 0 },
895 				{ 0 },
896 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
897 				{ 0 } },
898 		.reg = { "vfe1" },
899 		.interrupt = { "vfe1" },
900 		.vfe = {
901 			.line_num = 4,
902 			.has_pd = true,
903 			.pd_name = "ife1",
904 			.hw_ops = &vfe_ops_170,
905 			.formats_rdi = &vfe_formats_rdi_845,
906 			.formats_pix = &vfe_formats_pix_845
907 		}
908 	},
909 
910 	/* VFE-lite */
911 	{
912 		.regulators = {},
913 		.clock = { "camnoc_axi", "cpas_ahb", "soc_ahb",
914 			   "vfe_lite" },
915 		.clock_rate = { { 0 },
916 				{ 0 },
917 				{ 0 },
918 				{ 100000000, 320000000, 404000000, 480000000, 600000000 } },
919 		.reg = { "vfe_lite" },
920 		.interrupt = { "vfe_lite" },
921 		.vfe = {
922 			.is_lite = true,
923 			.line_num = 4,
924 			.hw_ops = &vfe_ops_170,
925 			.formats_rdi = &vfe_formats_rdi_845,
926 			.formats_pix = &vfe_formats_pix_845
927 		}
928 	}
929 };
930 
931 static const struct camss_subdev_resources csiphy_res_845[] = {
932 	/* CSIPHY0 */
933 	{
934 		.regulators = {},
935 		.clock = { "camnoc_axi", "soc_ahb", "slow_ahb_src",
936 				"cpas_ahb", "cphy_rx_src", "csiphy0",
937 				"csiphy0_timer_src", "csiphy0_timer" },
938 		.clock_rate = { { 0 },
939 				{ 0 },
940 				{ 0 },
941 				{ 0 },
942 				{ 0 },
943 				{ 0 },
944 				{ 0 },
945 				{ 19200000, 240000000, 269333333 } },
946 		.reg = { "csiphy0" },
947 		.interrupt = { "csiphy0" },
948 		.csiphy = {
949 			.id = 0,
950 			.hw_ops = &csiphy_ops_3ph_1_0,
951 			.formats = &csiphy_formats_sdm845
952 		}
953 	},
954 
955 	/* CSIPHY1 */
956 	{
957 		.regulators = {},
958 		.clock = { "camnoc_axi", "soc_ahb", "slow_ahb_src",
959 				"cpas_ahb", "cphy_rx_src", "csiphy1",
960 				"csiphy1_timer_src", "csiphy1_timer" },
961 		.clock_rate = { { 0 },
962 				{ 0 },
963 				{ 0 },
964 				{ 0 },
965 				{ 0 },
966 				{ 0 },
967 				{ 0 },
968 				{ 19200000, 240000000, 269333333 } },
969 		.reg = { "csiphy1" },
970 		.interrupt = { "csiphy1" },
971 		.csiphy = {
972 			.id = 1,
973 			.hw_ops = &csiphy_ops_3ph_1_0,
974 			.formats = &csiphy_formats_sdm845
975 		}
976 	},
977 
978 	/* CSIPHY2 */
979 	{
980 		.regulators = {},
981 		.clock = { "camnoc_axi", "soc_ahb", "slow_ahb_src",
982 				"cpas_ahb", "cphy_rx_src", "csiphy2",
983 				"csiphy2_timer_src", "csiphy2_timer" },
984 		.clock_rate = { { 0 },
985 				{ 0 },
986 				{ 0 },
987 				{ 0 },
988 				{ 0 },
989 				{ 0 },
990 				{ 0 },
991 				{ 19200000, 240000000, 269333333 } },
992 		.reg = { "csiphy2" },
993 		.interrupt = { "csiphy2" },
994 		.csiphy = {
995 			.id = 2,
996 			.hw_ops = &csiphy_ops_3ph_1_0,
997 			.formats = &csiphy_formats_sdm845
998 		}
999 	},
1000 
1001 	/* CSIPHY3 */
1002 	{
1003 		.regulators = {},
1004 		.clock = { "camnoc_axi", "soc_ahb", "slow_ahb_src",
1005 				"cpas_ahb", "cphy_rx_src", "csiphy3",
1006 				"csiphy3_timer_src", "csiphy3_timer" },
1007 		.clock_rate = { { 0 },
1008 				{ 0 },
1009 				{ 0 },
1010 				{ 0 },
1011 				{ 0 },
1012 				{ 0 },
1013 				{ 0 },
1014 				{ 19200000, 240000000, 269333333 } },
1015 		.reg = { "csiphy3" },
1016 		.interrupt = { "csiphy3" },
1017 		.csiphy = {
1018 			.id = 3,
1019 			.hw_ops = &csiphy_ops_3ph_1_0,
1020 			.formats = &csiphy_formats_sdm845
1021 		}
1022 	}
1023 };
1024 
1025 static const struct camss_subdev_resources csid_res_845[] = {
1026 	/* CSID0 */
1027 	{
1028 		.regulators = { "vdda-phy", "vdda-pll" },
1029 		.clock = { "cpas_ahb", "cphy_rx_src", "slow_ahb_src",
1030 				"soc_ahb", "vfe0", "vfe0_src",
1031 				"vfe0_cphy_rx", "csi0",
1032 				"csi0_src" },
1033 		.clock_rate = { { 0 },
1034 				{ 384000000 },
1035 				{ 80000000 },
1036 				{ 0 },
1037 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1038 				{ 320000000 },
1039 				{ 0 },
1040 				{ 19200000, 75000000, 384000000, 538666667 },
1041 				{ 384000000 } },
1042 		.reg = { "csid0" },
1043 		.interrupt = { "csid0" },
1044 		.csid = {
1045 			.hw_ops = &csid_ops_gen2,
1046 			.parent_dev_ops = &vfe_parent_dev_ops,
1047 			.formats = &csid_formats_gen2
1048 		}
1049 	},
1050 
1051 	/* CSID1 */
1052 	{
1053 		.regulators = { "vdda-phy", "vdda-pll" },
1054 		.clock = { "cpas_ahb", "cphy_rx_src", "slow_ahb_src",
1055 				"soc_ahb", "vfe1", "vfe1_src",
1056 				"vfe1_cphy_rx", "csi1",
1057 				"csi1_src" },
1058 		.clock_rate = { { 0 },
1059 				{ 384000000 },
1060 				{ 80000000 },
1061 				{ 0 },
1062 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1063 				{ 320000000 },
1064 				{ 0 },
1065 				{ 19200000, 75000000, 384000000, 538666667 },
1066 				{ 384000000 } },
1067 		.reg = { "csid1" },
1068 		.interrupt = { "csid1" },
1069 		.csid = {
1070 			.hw_ops = &csid_ops_gen2,
1071 			.parent_dev_ops = &vfe_parent_dev_ops,
1072 			.formats = &csid_formats_gen2
1073 		}
1074 	},
1075 
1076 	/* CSID2 */
1077 	{
1078 		.regulators = { "vdda-phy", "vdda-pll" },
1079 		.clock = { "cpas_ahb", "cphy_rx_src", "slow_ahb_src",
1080 				"soc_ahb", "vfe_lite", "vfe_lite_src",
1081 				"vfe_lite_cphy_rx", "csi2",
1082 				"csi2_src" },
1083 		.clock_rate = { { 0 },
1084 				{ 384000000 },
1085 				{ 80000000 },
1086 				{ 0 },
1087 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1088 				{ 320000000 },
1089 				{ 0 },
1090 				{ 19200000, 75000000, 384000000, 538666667 },
1091 				{ 384000000 } },
1092 		.reg = { "csid2" },
1093 		.interrupt = { "csid2" },
1094 		.csid = {
1095 			.is_lite = true,
1096 			.hw_ops = &csid_ops_gen2,
1097 			.parent_dev_ops = &vfe_parent_dev_ops,
1098 			.formats = &csid_formats_gen2
1099 		}
1100 	}
1101 };
1102 
1103 static const struct camss_subdev_resources vfe_res_845[] = {
1104 	/* VFE0 */
1105 	{
1106 		.regulators = {},
1107 		.clock = { "camnoc_axi", "cpas_ahb", "slow_ahb_src",
1108 				"soc_ahb", "vfe0", "vfe0_axi",
1109 				"vfe0_src", "csi0",
1110 				"csi0_src"},
1111 		.clock_rate = { { 0 },
1112 				{ 0 },
1113 				{ 80000000 },
1114 				{ 0 },
1115 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1116 				{ 0 },
1117 				{ 320000000 },
1118 				{ 19200000, 75000000, 384000000, 538666667 },
1119 				{ 384000000 } },
1120 		.reg = { "vfe0" },
1121 		.interrupt = { "vfe0" },
1122 		.vfe = {
1123 			.line_num = 4,
1124 			.pd_name = "ife0",
1125 			.has_pd = true,
1126 			.hw_ops = &vfe_ops_170,
1127 			.formats_rdi = &vfe_formats_rdi_845,
1128 			.formats_pix = &vfe_formats_pix_845
1129 		}
1130 	},
1131 
1132 	/* VFE1 */
1133 	{
1134 		.regulators = {},
1135 		.clock = { "camnoc_axi", "cpas_ahb", "slow_ahb_src",
1136 				"soc_ahb", "vfe1", "vfe1_axi",
1137 				"vfe1_src", "csi1",
1138 				"csi1_src"},
1139 		.clock_rate = { { 0 },
1140 				{ 0 },
1141 				{ 80000000 },
1142 				{ 0 },
1143 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1144 				{ 0 },
1145 				{ 320000000 },
1146 				{ 19200000, 75000000, 384000000, 538666667 },
1147 				{ 384000000 } },
1148 		.reg = { "vfe1" },
1149 		.interrupt = { "vfe1" },
1150 		.vfe = {
1151 			.line_num = 4,
1152 			.pd_name = "ife1",
1153 			.has_pd = true,
1154 			.hw_ops = &vfe_ops_170,
1155 			.formats_rdi = &vfe_formats_rdi_845,
1156 			.formats_pix = &vfe_formats_pix_845
1157 		}
1158 	},
1159 
1160 	/* VFE-lite */
1161 	{
1162 		.regulators = {},
1163 		.clock = { "camnoc_axi", "cpas_ahb", "slow_ahb_src",
1164 				"soc_ahb", "vfe_lite",
1165 				"vfe_lite_src", "csi2",
1166 				"csi2_src"},
1167 		.clock_rate = { { 0 },
1168 				{ 0 },
1169 				{ 80000000 },
1170 				{ 0 },
1171 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1172 				{ 320000000 },
1173 				{ 19200000, 75000000, 384000000, 538666667 },
1174 				{ 384000000 } },
1175 		.reg = { "vfe_lite" },
1176 		.interrupt = { "vfe_lite" },
1177 		.vfe = {
1178 			.is_lite = true,
1179 			.line_num = 4,
1180 			.hw_ops = &vfe_ops_170,
1181 			.formats_rdi = &vfe_formats_rdi_845,
1182 			.formats_pix = &vfe_formats_pix_845
1183 		}
1184 	}
1185 };
1186 
1187 static const struct camss_subdev_resources csiphy_res_8250[] = {
1188 	/* CSIPHY0 */
1189 	{
1190 		.regulators = { "vdda-phy", "vdda-pll" },
1191 		.clock = { "csiphy0", "csiphy0_timer" },
1192 		.clock_rate = { { 400000000 },
1193 				{ 300000000 } },
1194 		.reg = { "csiphy0" },
1195 		.interrupt = { "csiphy0" },
1196 		.csiphy = {
1197 			.id = 0,
1198 			.hw_ops = &csiphy_ops_3ph_1_0,
1199 			.formats = &csiphy_formats_sdm845
1200 		}
1201 	},
1202 	/* CSIPHY1 */
1203 	{
1204 		.regulators = { "vdda-phy", "vdda-pll" },
1205 		.clock = { "csiphy1", "csiphy1_timer" },
1206 		.clock_rate = { { 400000000 },
1207 				{ 300000000 } },
1208 		.reg = { "csiphy1" },
1209 		.interrupt = { "csiphy1" },
1210 		.csiphy = {
1211 			.id = 1,
1212 			.hw_ops = &csiphy_ops_3ph_1_0,
1213 			.formats = &csiphy_formats_sdm845
1214 		}
1215 	},
1216 	/* CSIPHY2 */
1217 	{
1218 		.regulators = { "vdda-phy", "vdda-pll" },
1219 		.clock = { "csiphy2", "csiphy2_timer" },
1220 		.clock_rate = { { 400000000 },
1221 				{ 300000000 } },
1222 		.reg = { "csiphy2" },
1223 		.interrupt = { "csiphy2" },
1224 		.csiphy = {
1225 			.id = 2,
1226 			.hw_ops = &csiphy_ops_3ph_1_0,
1227 			.formats = &csiphy_formats_sdm845
1228 		}
1229 	},
1230 	/* CSIPHY3 */
1231 	{
1232 		.regulators = { "vdda-phy", "vdda-pll" },
1233 		.clock = { "csiphy3", "csiphy3_timer" },
1234 		.clock_rate = { { 400000000 },
1235 				{ 300000000 } },
1236 		.reg = { "csiphy3" },
1237 		.interrupt = { "csiphy3" },
1238 		.csiphy = {
1239 			.id = 3,
1240 			.hw_ops = &csiphy_ops_3ph_1_0,
1241 			.formats = &csiphy_formats_sdm845
1242 		}
1243 	},
1244 	/* CSIPHY4 */
1245 	{
1246 		.regulators = { "vdda-phy", "vdda-pll" },
1247 		.clock = { "csiphy4", "csiphy4_timer" },
1248 		.clock_rate = { { 400000000 },
1249 				{ 300000000 } },
1250 		.reg = { "csiphy4" },
1251 		.interrupt = { "csiphy4" },
1252 		.csiphy = {
1253 			.id = 4,
1254 			.hw_ops = &csiphy_ops_3ph_1_0,
1255 			.formats = &csiphy_formats_sdm845
1256 		}
1257 	},
1258 	/* CSIPHY5 */
1259 	{
1260 		.regulators = { "vdda-phy", "vdda-pll" },
1261 		.clock = { "csiphy5", "csiphy5_timer" },
1262 		.clock_rate = { { 400000000 },
1263 				{ 300000000 } },
1264 		.reg = { "csiphy5" },
1265 		.interrupt = { "csiphy5" },
1266 		.csiphy = {
1267 			.id = 5,
1268 			.hw_ops = &csiphy_ops_3ph_1_0,
1269 			.formats = &csiphy_formats_sdm845
1270 		}
1271 	}
1272 };
1273 
1274 static const struct camss_subdev_resources csid_res_8250[] = {
1275 	/* CSID0 */
1276 	{
1277 		.regulators = {},
1278 		.clock = { "vfe0_csid", "vfe0_cphy_rx", "vfe0", "vfe0_areg", "vfe0_ahb" },
1279 		.clock_rate = { { 400000000 },
1280 				{ 400000000 },
1281 				{ 350000000, 475000000, 576000000, 720000000 },
1282 				{ 100000000, 200000000, 300000000, 400000000 },
1283 				{ 0 } },
1284 		.reg = { "csid0" },
1285 		.interrupt = { "csid0" },
1286 		.csid = {
1287 			.hw_ops = &csid_ops_gen2,
1288 			.parent_dev_ops = &vfe_parent_dev_ops,
1289 			.formats = &csid_formats_gen2
1290 		}
1291 	},
1292 	/* CSID1 */
1293 	{
1294 		.regulators = {},
1295 		.clock = { "vfe1_csid", "vfe1_cphy_rx", "vfe1", "vfe1_areg", "vfe1_ahb" },
1296 		.clock_rate = { { 400000000 },
1297 				{ 400000000 },
1298 				{ 350000000, 475000000, 576000000, 720000000 },
1299 				{ 100000000, 200000000, 300000000, 400000000 },
1300 				{ 0 } },
1301 		.reg = { "csid1" },
1302 		.interrupt = { "csid1" },
1303 		.csid = {
1304 			.hw_ops = &csid_ops_gen2,
1305 			.parent_dev_ops = &vfe_parent_dev_ops,
1306 			.formats = &csid_formats_gen2
1307 		}
1308 	},
1309 	/* CSID2 */
1310 	{
1311 		.regulators = {},
1312 		.clock = { "vfe_lite_csid", "vfe_lite_cphy_rx", "vfe_lite",  "vfe_lite_ahb" },
1313 		.clock_rate = { { 400000000 },
1314 				{ 400000000 },
1315 				{ 400000000, 480000000 },
1316 				{ 0 } },
1317 		.reg = { "csid2" },
1318 		.interrupt = { "csid2" },
1319 		.csid = {
1320 			.is_lite = true,
1321 			.hw_ops = &csid_ops_gen2,
1322 			.parent_dev_ops = &vfe_parent_dev_ops,
1323 			.formats = &csid_formats_gen2
1324 		}
1325 	},
1326 	/* CSID3 */
1327 	{
1328 		.regulators = {},
1329 		.clock = { "vfe_lite_csid", "vfe_lite_cphy_rx", "vfe_lite",  "vfe_lite_ahb" },
1330 		.clock_rate = { { 400000000 },
1331 				{ 400000000 },
1332 				{ 400000000, 480000000 },
1333 				{ 0 } },
1334 		.reg = { "csid3" },
1335 		.interrupt = { "csid3" },
1336 		.csid = {
1337 			.is_lite = true,
1338 			.hw_ops = &csid_ops_gen2,
1339 			.parent_dev_ops = &vfe_parent_dev_ops,
1340 			.formats = &csid_formats_gen2
1341 		}
1342 	}
1343 };
1344 
1345 static const struct camss_subdev_resources vfe_res_8250[] = {
1346 	/* VFE0 */
1347 	{
1348 		.regulators = {},
1349 		.clock = { "camnoc_axi_src", "slow_ahb_src", "cpas_ahb",
1350 			   "camnoc_axi", "vfe0_ahb", "vfe0_areg", "vfe0",
1351 			   "vfe0_axi", "cam_hf_axi" },
1352 		.clock_rate = { { 19200000, 300000000, 400000000, 480000000 },
1353 				{ 19200000, 80000000 },
1354 				{ 19200000 },
1355 				{ 0 },
1356 				{ 0 },
1357 				{ 100000000, 200000000, 300000000, 400000000 },
1358 				{ 350000000, 475000000, 576000000, 720000000 },
1359 				{ 0 },
1360 				{ 0 } },
1361 		.reg = { "vfe0" },
1362 		.interrupt = { "vfe0" },
1363 		.vfe = {
1364 			.line_num = 3,
1365 			.has_pd = true,
1366 			.pd_name = "ife0",
1367 			.hw_ops = &vfe_ops_480,
1368 			.formats_rdi = &vfe_formats_rdi_845,
1369 			.formats_pix = &vfe_formats_pix_845
1370 		}
1371 	},
1372 	/* VFE1 */
1373 	{
1374 		.regulators = {},
1375 		.clock = { "camnoc_axi_src", "slow_ahb_src", "cpas_ahb",
1376 			   "camnoc_axi", "vfe1_ahb", "vfe1_areg", "vfe1",
1377 			   "vfe1_axi", "cam_hf_axi" },
1378 		.clock_rate = { { 19200000, 300000000, 400000000, 480000000 },
1379 				{ 19200000, 80000000 },
1380 				{ 19200000 },
1381 				{ 0 },
1382 				{ 0 },
1383 				{ 100000000, 200000000, 300000000, 400000000 },
1384 				{ 350000000, 475000000, 576000000, 720000000 },
1385 				{ 0 },
1386 				{ 0 } },
1387 		.reg = { "vfe1" },
1388 		.interrupt = { "vfe1" },
1389 		.vfe = {
1390 			.line_num = 3,
1391 			.has_pd = true,
1392 			.pd_name = "ife1",
1393 			.hw_ops = &vfe_ops_480,
1394 			.formats_rdi = &vfe_formats_rdi_845,
1395 			.formats_pix = &vfe_formats_pix_845
1396 		}
1397 	},
1398 	/* VFE2 (lite) */
1399 	{
1400 		.regulators = {},
1401 		.clock = { "camnoc_axi_src", "slow_ahb_src", "cpas_ahb",
1402 			   "camnoc_axi", "vfe_lite_ahb", "vfe_lite_axi",
1403 			   "vfe_lite", "cam_hf_axi" },
1404 		.clock_rate = { { 19200000, 300000000, 400000000, 480000000 },
1405 				{ 19200000, 80000000 },
1406 				{ 19200000 },
1407 				{ 0 },
1408 				{ 0 },
1409 				{ 0 },
1410 				{ 400000000, 480000000 },
1411 				{ 0 } },
1412 		.reg = { "vfe_lite0" },
1413 		.interrupt = { "vfe_lite0" },
1414 		.vfe = {
1415 			.is_lite = true,
1416 			.line_num = 4,
1417 			.hw_ops = &vfe_ops_480,
1418 			.formats_rdi = &vfe_formats_rdi_845,
1419 			.formats_pix = &vfe_formats_pix_845
1420 		}
1421 	},
1422 	/* VFE3 (lite) */
1423 	{
1424 		.regulators = {},
1425 		.clock = { "camnoc_axi_src", "slow_ahb_src", "cpas_ahb",
1426 			   "camnoc_axi", "vfe_lite_ahb", "vfe_lite_axi",
1427 			   "vfe_lite", "cam_hf_axi" },
1428 		.clock_rate = { { 19200000, 300000000, 400000000, 480000000 },
1429 				{ 19200000, 80000000 },
1430 				{ 19200000 },
1431 				{ 0 },
1432 				{ 0 },
1433 				{ 0 },
1434 				{ 400000000, 480000000 },
1435 				{ 0 } },
1436 		.reg = { "vfe_lite1" },
1437 		.interrupt = { "vfe_lite1" },
1438 		.vfe = {
1439 			.is_lite = true,
1440 			.line_num = 4,
1441 			.hw_ops = &vfe_ops_480,
1442 			.formats_rdi = &vfe_formats_rdi_845,
1443 			.formats_pix = &vfe_formats_pix_845
1444 		}
1445 	},
1446 };
1447 
1448 static const struct resources_icc icc_res_sm8250[] = {
1449 	{
1450 		.name = "cam_ahb",
1451 		.icc_bw_tbl.avg = 38400,
1452 		.icc_bw_tbl.peak = 76800,
1453 	},
1454 	{
1455 		.name = "cam_hf_0_mnoc",
1456 		.icc_bw_tbl.avg = 2097152,
1457 		.icc_bw_tbl.peak = 2097152,
1458 	},
1459 	{
1460 		.name = "cam_sf_0_mnoc",
1461 		.icc_bw_tbl.avg = 0,
1462 		.icc_bw_tbl.peak = 2097152,
1463 	},
1464 	{
1465 		.name = "cam_sf_icp_mnoc",
1466 		.icc_bw_tbl.avg = 2097152,
1467 		.icc_bw_tbl.peak = 2097152,
1468 	},
1469 };
1470 
1471 static const struct camss_subdev_resources csiphy_res_7280[] = {
1472 	/* CSIPHY0 */
1473 	{
1474 		.regulators = { "vdda-phy", "vdda-pll" },
1475 
1476 		.clock = { "csiphy0", "csiphy0_timer" },
1477 		.clock_rate = { { 300000000, 400000000 },
1478 				{ 300000000 } },
1479 		.reg = { "csiphy0" },
1480 		.interrupt = { "csiphy0" },
1481 		.csiphy = {
1482 			.id = 0,
1483 			.hw_ops = &csiphy_ops_3ph_1_0,
1484 			.formats = &csiphy_formats_sdm845,
1485 		}
1486 	},
1487 	/* CSIPHY1 */
1488 	{
1489 		.regulators = { "vdda-phy", "vdda-pll" },
1490 
1491 		.clock = { "csiphy1", "csiphy1_timer" },
1492 		.clock_rate = { { 300000000, 400000000 },
1493 				{ 300000000 } },
1494 		.reg = { "csiphy1" },
1495 		.interrupt = { "csiphy1" },
1496 		.csiphy = {
1497 			.id = 1,
1498 			.hw_ops = &csiphy_ops_3ph_1_0,
1499 			.formats = &csiphy_formats_sdm845,
1500 		}
1501 	},
1502 	/* CSIPHY2 */
1503 	{
1504 		.regulators = { "vdda-phy", "vdda-pll" },
1505 
1506 		.clock = { "csiphy2", "csiphy2_timer" },
1507 		.clock_rate = { { 300000000, 400000000 },
1508 				{ 300000000 } },
1509 		.reg = { "csiphy2" },
1510 		.interrupt = { "csiphy2" },
1511 		.csiphy = {
1512 			.id = 2,
1513 			.hw_ops = &csiphy_ops_3ph_1_0,
1514 			.formats = &csiphy_formats_sdm845,
1515 		}
1516 	},
1517 	/* CSIPHY3 */
1518 	{
1519 		.regulators = { "vdda-phy", "vdda-pll" },
1520 
1521 		.clock = { "csiphy3", "csiphy3_timer" },
1522 		.clock_rate = { { 300000000, 400000000 },
1523 				{ 300000000 } },
1524 		.reg = { "csiphy3" },
1525 		.interrupt = { "csiphy3" },
1526 		.csiphy = {
1527 			.id = 3,
1528 			.hw_ops = &csiphy_ops_3ph_1_0,
1529 			.formats = &csiphy_formats_sdm845,
1530 		}
1531 	},
1532 	/* CSIPHY4 */
1533 	{
1534 		.regulators = { "vdda-phy", "vdda-pll" },
1535 
1536 		.clock = { "csiphy4", "csiphy4_timer" },
1537 		.clock_rate = { { 300000000, 400000000 },
1538 				{ 300000000 } },
1539 		.reg = { "csiphy4" },
1540 		.interrupt = { "csiphy4" },
1541 		.csiphy = {
1542 			.id = 4,
1543 			.hw_ops = &csiphy_ops_3ph_1_0,
1544 			.formats = &csiphy_formats_sdm845,
1545 		}
1546 	},
1547 };
1548 
1549 static const struct camss_subdev_resources csid_res_7280[] = {
1550 	/* CSID0 */
1551 	{
1552 		.regulators = {},
1553 
1554 		.clock = { "vfe0_csid", "vfe0_cphy_rx", "vfe0" },
1555 		.clock_rate = { { 300000000, 400000000 },
1556 				{ 0 },
1557 				{ 380000000, 510000000, 637000000, 760000000 }
1558 		},
1559 
1560 		.reg = { "csid0" },
1561 		.interrupt = { "csid0" },
1562 		.csid = {
1563 			.is_lite = false,
1564 			.hw_ops = &csid_ops_gen2,
1565 			.parent_dev_ops = &vfe_parent_dev_ops,
1566 			.formats = &csid_formats_gen2
1567 		}
1568 	},
1569 	/* CSID1 */
1570 	{
1571 		.regulators = {},
1572 
1573 		.clock = { "vfe1_csid", "vfe1_cphy_rx", "vfe1" },
1574 		.clock_rate = { { 300000000, 400000000 },
1575 				{ 0 },
1576 				{ 380000000, 510000000, 637000000, 760000000 }
1577 		},
1578 
1579 		.reg = { "csid1" },
1580 		.interrupt = { "csid1" },
1581 		.csid = {
1582 			.is_lite = false,
1583 			.hw_ops = &csid_ops_gen2,
1584 			.parent_dev_ops = &vfe_parent_dev_ops,
1585 			.formats = &csid_formats_gen2
1586 		}
1587 	},
1588 	/* CSID2 */
1589 	{
1590 		.regulators = {},
1591 
1592 		.clock = { "vfe2_csid", "vfe2_cphy_rx", "vfe2" },
1593 		.clock_rate = { { 300000000, 400000000 },
1594 				{ 0 },
1595 				{ 380000000, 510000000, 637000000, 760000000 }
1596 		},
1597 
1598 		.reg = { "csid2" },
1599 		.interrupt = { "csid2" },
1600 		.csid = {
1601 			.is_lite = false,
1602 			.hw_ops = &csid_ops_gen2,
1603 			.parent_dev_ops = &vfe_parent_dev_ops,
1604 			.formats = &csid_formats_gen2
1605 		}
1606 	},
1607 	/* CSID3 */
1608 	{
1609 		.regulators = {},
1610 
1611 		.clock = { "vfe_lite0_csid", "vfe_lite0_cphy_rx", "vfe_lite0" },
1612 		.clock_rate = { { 300000000, 400000000 },
1613 				{ 0 },
1614 				{ 320000000, 400000000, 480000000, 600000000 }
1615 		},
1616 
1617 		.reg = { "csid_lite0" },
1618 		.interrupt = { "csid_lite0" },
1619 		.csid = {
1620 			.is_lite = true,
1621 			.hw_ops = &csid_ops_gen2,
1622 			.parent_dev_ops = &vfe_parent_dev_ops,
1623 			.formats = &csid_formats_gen2
1624 		}
1625 	},
1626 	/* CSID4 */
1627 	{
1628 		.regulators = {},
1629 
1630 		.clock = { "vfe_lite1_csid", "vfe_lite1_cphy_rx", "vfe_lite1" },
1631 		.clock_rate = { { 300000000, 400000000 },
1632 				{ 0 },
1633 				{ 320000000, 400000000, 480000000, 600000000 }
1634 		},
1635 
1636 		.reg = { "csid_lite1" },
1637 		.interrupt = { "csid_lite1" },
1638 		.csid = {
1639 			.is_lite = true,
1640 			.hw_ops = &csid_ops_gen2,
1641 			.parent_dev_ops = &vfe_parent_dev_ops,
1642 			.formats = &csid_formats_gen2
1643 		}
1644 	},
1645 };
1646 
1647 static const struct camss_subdev_resources vfe_res_7280[] = {
1648 	/* VFE0 */
1649 	{
1650 		.regulators = {},
1651 
1652 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb", "vfe0",
1653 			   "vfe0_axi", "gcc_axi_hf", "gcc_axi_sf" },
1654 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1655 				{ 80000000 },
1656 				{ 0 },
1657 				{ 380000000, 510000000, 637000000, 760000000 },
1658 				{ 0 },
1659 				{ 0 },
1660 				{ 0 } },
1661 
1662 		.reg = { "vfe0" },
1663 		.interrupt = { "vfe0" },
1664 		.vfe = {
1665 			.line_num = 3,
1666 			.is_lite = false,
1667 			.has_pd = true,
1668 			.pd_name = "ife0",
1669 			.hw_ops = &vfe_ops_170,
1670 			.formats_rdi = &vfe_formats_rdi_845,
1671 			.formats_pix = &vfe_formats_pix_845
1672 		}
1673 	},
1674 	/* VFE1 */
1675 	{
1676 		.regulators = {},
1677 
1678 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb", "vfe1",
1679 			   "vfe1_axi", "gcc_axi_hf", "gcc_axi_sf" },
1680 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1681 				{ 80000000 },
1682 				{ 0 },
1683 				{ 380000000, 510000000, 637000000, 760000000 },
1684 				{ 0 },
1685 				{ 0 },
1686 				{ 0 } },
1687 
1688 		.reg = { "vfe1" },
1689 		.interrupt = { "vfe1" },
1690 		.vfe = {
1691 			.line_num = 3,
1692 			.is_lite = false,
1693 			.has_pd = true,
1694 			.pd_name = "ife1",
1695 			.hw_ops = &vfe_ops_170,
1696 			.formats_rdi = &vfe_formats_rdi_845,
1697 			.formats_pix = &vfe_formats_pix_845
1698 		}
1699 	},
1700 	/* VFE2 */
1701 	{
1702 		.regulators = {},
1703 
1704 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb", "vfe2",
1705 			   "vfe2_axi", "gcc_axi_hf", "gcc_axi_sf" },
1706 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1707 				{ 80000000 },
1708 				{ 0 },
1709 				{ 380000000, 510000000, 637000000, 760000000 },
1710 				{ 0 },
1711 				{ 0 },
1712 				{ 0 } },
1713 
1714 		.reg = { "vfe2" },
1715 		.interrupt = { "vfe2" },
1716 		.vfe = {
1717 			.line_num = 3,
1718 			.is_lite = false,
1719 			.hw_ops = &vfe_ops_170,
1720 			.has_pd = true,
1721 			.pd_name = "ife2",
1722 			.formats_rdi = &vfe_formats_rdi_845,
1723 			.formats_pix = &vfe_formats_pix_845
1724 		}
1725 	},
1726 	/* VFE3 (lite) */
1727 	{
1728 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb",
1729 			   "vfe_lite0", "gcc_axi_hf", "gcc_axi_sf" },
1730 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1731 				{ 80000000 },
1732 				{ 0 },
1733 				{ 320000000, 400000000, 480000000, 600000000 },
1734 				{ 0 },
1735 				{ 0 } },
1736 
1737 		.regulators = {},
1738 		.reg = { "vfe_lite0" },
1739 		.interrupt = { "vfe_lite0" },
1740 		.vfe = {
1741 			.line_num = 4,
1742 			.is_lite = true,
1743 			.hw_ops = &vfe_ops_170,
1744 			.formats_rdi = &vfe_formats_rdi_845,
1745 			.formats_pix = &vfe_formats_pix_845
1746 		}
1747 	},
1748 	/* VFE4 (lite) */
1749 	{
1750 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb",
1751 			   "vfe_lite1", "gcc_axi_hf", "gcc_axi_sf" },
1752 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1753 				{ 80000000 },
1754 				{ 0 },
1755 				{ 320000000, 400000000, 480000000, 600000000 },
1756 				{ 0 },
1757 				{ 0 } },
1758 
1759 		.regulators = {},
1760 		.reg = { "vfe_lite1" },
1761 		.interrupt = { "vfe_lite1" },
1762 		.vfe = {
1763 			.line_num = 4,
1764 			.is_lite = true,
1765 			.hw_ops = &vfe_ops_170,
1766 			.formats_rdi = &vfe_formats_rdi_845,
1767 			.formats_pix = &vfe_formats_pix_845
1768 		}
1769 	},
1770 };
1771 
1772 static const struct resources_icc icc_res_sc7280[] = {
1773 	{
1774 		.name = "ahb",
1775 		.icc_bw_tbl.avg = 38400,
1776 		.icc_bw_tbl.peak = 76800,
1777 	},
1778 	{
1779 		.name = "hf_0",
1780 		.icc_bw_tbl.avg = 2097152,
1781 		.icc_bw_tbl.peak = 2097152,
1782 	},
1783 };
1784 
1785 static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
1786 	/* CSIPHY0 */
1787 	{
1788 		.regulators = {},
1789 		.clock = { "csiphy0", "csiphy0_timer" },
1790 		.clock_rate = { { 400000000 },
1791 				{ 300000000 } },
1792 		.reg = { "csiphy0" },
1793 		.interrupt = { "csiphy0" },
1794 		.csiphy = {
1795 			.id = 0,
1796 			.hw_ops = &csiphy_ops_3ph_1_0,
1797 			.formats = &csiphy_formats_sdm845
1798 		}
1799 	},
1800 	/* CSIPHY1 */
1801 	{
1802 		.regulators = {},
1803 		.clock = { "csiphy1", "csiphy1_timer" },
1804 		.clock_rate = { { 400000000 },
1805 				{ 300000000 } },
1806 		.reg = { "csiphy1" },
1807 		.interrupt = { "csiphy1" },
1808 		.csiphy = {
1809 			.id = 1,
1810 			.hw_ops = &csiphy_ops_3ph_1_0,
1811 			.formats = &csiphy_formats_sdm845
1812 		}
1813 	},
1814 	/* CSIPHY2 */
1815 	{
1816 		.regulators = {},
1817 		.clock = { "csiphy2", "csiphy2_timer" },
1818 		.clock_rate = { { 400000000 },
1819 				{ 300000000 } },
1820 		.reg = { "csiphy2" },
1821 		.interrupt = { "csiphy2" },
1822 		.csiphy = {
1823 			.id = 2,
1824 			.hw_ops = &csiphy_ops_3ph_1_0,
1825 			.formats = &csiphy_formats_sdm845
1826 		}
1827 	},
1828 	/* CSIPHY3 */
1829 	{
1830 		.regulators = {},
1831 		.clock = { "csiphy3", "csiphy3_timer" },
1832 		.clock_rate = { { 400000000 },
1833 				{ 300000000 } },
1834 		.reg = { "csiphy3" },
1835 		.interrupt = { "csiphy3" },
1836 		.csiphy = {
1837 			.id = 3,
1838 			.hw_ops = &csiphy_ops_3ph_1_0,
1839 			.formats = &csiphy_formats_sdm845
1840 		}
1841 	},
1842 };
1843 
1844 static const struct camss_subdev_resources csid_res_sc8280xp[] = {
1845 	/* CSID0 */
1846 	{
1847 		.regulators = { "vdda-phy", "vdda-pll" },
1848 		.clock = { "vfe0_csid", "vfe0_cphy_rx", "vfe0", "vfe0_axi" },
1849 		.clock_rate = { { 400000000, 480000000, 600000000 },
1850 				{ 0 },
1851 				{ 0 },
1852 				{ 0 } },
1853 		.reg = { "csid0" },
1854 		.interrupt = { "csid0" },
1855 		.csid = {
1856 			.hw_ops = &csid_ops_gen2,
1857 			.parent_dev_ops = &vfe_parent_dev_ops,
1858 			.formats = &csid_formats_gen2
1859 		}
1860 	},
1861 	/* CSID1 */
1862 	{
1863 		.regulators = { "vdda-phy", "vdda-pll" },
1864 		.clock = { "vfe1_csid", "vfe1_cphy_rx", "vfe1", "vfe1_axi" },
1865 		.clock_rate = { { 400000000, 480000000, 600000000 },
1866 				{ 0 },
1867 				{ 0 },
1868 				{ 0 } },
1869 		.reg = { "csid1" },
1870 		.interrupt = { "csid1" },
1871 		.csid = {
1872 			.hw_ops = &csid_ops_gen2,
1873 			.parent_dev_ops = &vfe_parent_dev_ops,
1874 			.formats = &csid_formats_gen2
1875 		}
1876 	},
1877 	/* CSID2 */
1878 	{
1879 		.regulators = { "vdda-phy", "vdda-pll" },
1880 		.clock = { "vfe2_csid", "vfe2_cphy_rx", "vfe2", "vfe2_axi" },
1881 		.clock_rate = { { 400000000, 480000000, 600000000 },
1882 				{ 0 },
1883 				{ 0 },
1884 				{ 0 } },
1885 		.reg = { "csid2" },
1886 		.interrupt = { "csid2" },
1887 		.csid = {
1888 			.hw_ops = &csid_ops_gen2,
1889 			.parent_dev_ops = &vfe_parent_dev_ops,
1890 			.formats = &csid_formats_gen2
1891 		}
1892 	},
1893 	/* CSID3 */
1894 	{
1895 		.regulators = { "vdda-phy", "vdda-pll" },
1896 		.clock = { "vfe3_csid", "vfe3_cphy_rx", "vfe3", "vfe3_axi" },
1897 		.clock_rate = { { 400000000, 480000000, 600000000 },
1898 				{ 0 },
1899 				{ 0 },
1900 				{ 0 } },
1901 		.reg = { "csid3" },
1902 		.interrupt = { "csid3" },
1903 		.csid = {
1904 			.hw_ops = &csid_ops_gen2,
1905 			.parent_dev_ops = &vfe_parent_dev_ops,
1906 			.formats = &csid_formats_gen2
1907 		}
1908 	},
1909 	/* CSID_LITE0 */
1910 	{
1911 		.regulators = { "vdda-phy", "vdda-pll" },
1912 		.clock = { "vfe_lite0_csid", "vfe_lite0_cphy_rx", "vfe_lite0" },
1913 		.clock_rate = { { 400000000, 480000000, 600000000 },
1914 				{ 0 },
1915 				{ 0 }, },
1916 		.reg = { "csid0_lite" },
1917 		.interrupt = { "csid0_lite" },
1918 		.csid = {
1919 			.is_lite = true,
1920 			.hw_ops = &csid_ops_gen2,
1921 			.parent_dev_ops = &vfe_parent_dev_ops,
1922 			.formats = &csid_formats_gen2
1923 		}
1924 	},
1925 	/* CSID_LITE1 */
1926 	{
1927 		.regulators = { "vdda-phy", "vdda-pll" },
1928 		.clock = { "vfe_lite1_csid", "vfe_lite1_cphy_rx", "vfe_lite1" },
1929 		.clock_rate = { { 400000000, 480000000, 600000000 },
1930 				{ 0 },
1931 				{ 0 }, },
1932 		.reg = { "csid1_lite" },
1933 		.interrupt = { "csid1_lite" },
1934 		.csid = {
1935 			.is_lite = true,
1936 			.hw_ops = &csid_ops_gen2,
1937 			.parent_dev_ops = &vfe_parent_dev_ops,
1938 			.formats = &csid_formats_gen2
1939 		}
1940 	},
1941 	/* CSID_LITE2 */
1942 	{
1943 		.regulators = { "vdda-phy", "vdda-pll" },
1944 		.clock = { "vfe_lite2_csid", "vfe_lite2_cphy_rx", "vfe_lite2" },
1945 		.clock_rate = { { 400000000, 480000000, 600000000 },
1946 				{ 0 },
1947 				{ 0 }, },
1948 		.reg = { "csid2_lite" },
1949 		.interrupt = { "csid2_lite" },
1950 		.csid = {
1951 			.is_lite = true,
1952 			.hw_ops = &csid_ops_gen2,
1953 			.parent_dev_ops = &vfe_parent_dev_ops,
1954 			.formats = &csid_formats_gen2
1955 		}
1956 	},
1957 	/* CSID_LITE3 */
1958 	{
1959 		.regulators = { "vdda-phy", "vdda-pll" },
1960 		.clock = { "vfe_lite3_csid", "vfe_lite3_cphy_rx", "vfe_lite3" },
1961 		.clock_rate = { { 400000000, 480000000, 600000000 },
1962 				{ 0 },
1963 				{ 0 }, },
1964 		.reg = { "csid3_lite" },
1965 		.interrupt = { "csid3_lite" },
1966 		.csid = {
1967 			.is_lite = true,
1968 			.hw_ops = &csid_ops_gen2,
1969 			.parent_dev_ops = &vfe_parent_dev_ops,
1970 			.formats = &csid_formats_gen2
1971 		}
1972 	}
1973 };
1974 
1975 static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
1976 	/* VFE0 */
1977 	{
1978 		.regulators = {},
1979 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe0", "vfe0_axi" },
1980 		.clock_rate = { { 0 },
1981 				{ 0 },
1982 				{ 19200000, 80000000},
1983 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
1984 				{ 400000000, 558000000, 637000000, 760000000 },
1985 				{ 0 }, },
1986 		.reg = { "vfe0" },
1987 		.interrupt = { "vfe0" },
1988 		.vfe = {
1989 			.line_num = 4,
1990 			.pd_name = "ife0",
1991 			.hw_ops = &vfe_ops_170,
1992 			.formats_rdi = &vfe_formats_rdi_845,
1993 			.formats_pix = &vfe_formats_pix_845
1994 		}
1995 	},
1996 	/* VFE1 */
1997 	{
1998 		.regulators = {},
1999 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe1", "vfe1_axi" },
2000 		.clock_rate = { { 0 },
2001 				{ 0 },
2002 				{ 19200000, 80000000},
2003 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2004 				{ 400000000, 558000000, 637000000, 760000000 },
2005 				{ 0 }, },
2006 		.reg = { "vfe1" },
2007 		.interrupt = { "vfe1" },
2008 		.vfe = {
2009 			.line_num = 4,
2010 			.pd_name = "ife1",
2011 			.hw_ops = &vfe_ops_170,
2012 			.formats_rdi = &vfe_formats_rdi_845,
2013 			.formats_pix = &vfe_formats_pix_845
2014 		}
2015 	},
2016 	/* VFE2 */
2017 	{
2018 		.regulators = {},
2019 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe2", "vfe2_axi" },
2020 		.clock_rate = { { 0 },
2021 				{ 0 },
2022 				{ 19200000, 80000000},
2023 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2024 				{ 400000000, 558000000, 637000000, 760000000 },
2025 				{ 0 }, },
2026 		.reg = { "vfe2" },
2027 		.interrupt = { "vfe2" },
2028 		.vfe = {
2029 			.line_num = 4,
2030 			.pd_name = "ife2",
2031 			.hw_ops = &vfe_ops_170,
2032 			.formats_rdi = &vfe_formats_rdi_845,
2033 			.formats_pix = &vfe_formats_pix_845
2034 		}
2035 	},
2036 	/* VFE3 */
2037 	{
2038 		.regulators = {},
2039 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe3", "vfe3_axi" },
2040 		.clock_rate = { { 0 },
2041 				{ 0 },
2042 				{ 19200000, 80000000},
2043 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2044 				{ 400000000, 558000000, 637000000, 760000000 },
2045 				{ 0 }, },
2046 		.reg = { "vfe3" },
2047 		.interrupt = { "vfe3" },
2048 		.vfe = {
2049 			.line_num = 4,
2050 			.pd_name = "ife3",
2051 			.hw_ops = &vfe_ops_170,
2052 			.formats_rdi = &vfe_formats_rdi_845,
2053 			.formats_pix = &vfe_formats_pix_845
2054 		}
2055 	},
2056 	/* VFE_LITE_0 */
2057 	{
2058 		.regulators = {},
2059 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe_lite0" },
2060 		.clock_rate = { { 0 },
2061 				{ 0 },
2062 				{ 19200000, 80000000},
2063 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2064 				{ 320000000, 400000000, 480000000, 600000000 }, },
2065 		.reg = { "vfe_lite0" },
2066 		.interrupt = { "vfe_lite0" },
2067 		.vfe = {
2068 			.is_lite = true,
2069 			.line_num = 4,
2070 			.hw_ops = &vfe_ops_170,
2071 			.formats_rdi = &vfe_formats_rdi_845,
2072 			.formats_pix = &vfe_formats_pix_845
2073 		}
2074 	},
2075 	/* VFE_LITE_1 */
2076 	{
2077 		.regulators = {},
2078 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe_lite1" },
2079 		.clock_rate = { { 0 },
2080 				{ 0 },
2081 				{ 19200000, 80000000},
2082 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2083 				{ 320000000, 400000000, 480000000, 600000000 }, },
2084 		.reg = { "vfe_lite1" },
2085 		.interrupt = { "vfe_lite1" },
2086 		.vfe = {
2087 			.is_lite = true,
2088 			.line_num = 4,
2089 			.hw_ops = &vfe_ops_170,
2090 			.formats_rdi = &vfe_formats_rdi_845,
2091 			.formats_pix = &vfe_formats_pix_845
2092 		}
2093 	},
2094 	/* VFE_LITE_2 */
2095 	{
2096 		.regulators = {},
2097 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe_lite2" },
2098 		.clock_rate = { { 0 },
2099 				{ 0 },
2100 				{ 19200000, 80000000},
2101 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2102 				{ 320000000, 400000000, 480000000, 600000000, }, },
2103 		.reg = { "vfe_lite2" },
2104 		.interrupt = { "vfe_lite2" },
2105 		.vfe = {
2106 			.is_lite = true,
2107 			.line_num = 4,
2108 			.hw_ops = &vfe_ops_170,
2109 			.formats_rdi = &vfe_formats_rdi_845,
2110 			.formats_pix = &vfe_formats_pix_845
2111 		}
2112 	},
2113 	/* VFE_LITE_3 */
2114 	{
2115 		.regulators = {},
2116 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe_lite3" },
2117 		.clock_rate = { { 0 },
2118 				{ 0 },
2119 				{ 19200000, 80000000},
2120 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2121 				{ 320000000, 400000000, 480000000, 600000000 }, },
2122 		.reg = { "vfe_lite3" },
2123 		.interrupt = { "vfe_lite3" },
2124 		.vfe = {
2125 			.is_lite = true,
2126 			.line_num = 4,
2127 			.hw_ops = &vfe_ops_170,
2128 			.formats_rdi = &vfe_formats_rdi_845,
2129 			.formats_pix = &vfe_formats_pix_845
2130 		}
2131 	},
2132 };
2133 
2134 static const struct resources_icc icc_res_sc8280xp[] = {
2135 	{
2136 		.name = "cam_ahb",
2137 		.icc_bw_tbl.avg = 150000,
2138 		.icc_bw_tbl.peak = 300000,
2139 	},
2140 	{
2141 		.name = "cam_hf_mnoc",
2142 		.icc_bw_tbl.avg = 2097152,
2143 		.icc_bw_tbl.peak = 2097152,
2144 	},
2145 	{
2146 		.name = "cam_sf_mnoc",
2147 		.icc_bw_tbl.avg = 2097152,
2148 		.icc_bw_tbl.peak = 2097152,
2149 	},
2150 	{
2151 		.name = "cam_sf_icp_mnoc",
2152 		.icc_bw_tbl.avg = 2097152,
2153 		.icc_bw_tbl.peak = 2097152,
2154 	},
2155 };
2156 
2157 static const struct camss_subdev_resources csiphy_res_8550[] = {
2158 	/* CSIPHY0 */
2159 	{
2160 		.regulators = { "vdda-phy", "vdda-pll" },
2161 		.clock = { "csiphy0", "csiphy0_timer" },
2162 		.clock_rate = { { 400000000, 480000000 },
2163 				{ 400000000 } },
2164 		.reg = { "csiphy0" },
2165 		.interrupt = { "csiphy0" },
2166 		.csiphy = {
2167 			.id = 0,
2168 			.hw_ops = &csiphy_ops_3ph_1_0,
2169 			.formats = &csiphy_formats_sdm845
2170 		}
2171 	},
2172 	/* CSIPHY1 */
2173 	{
2174 		.regulators = { "vdda-phy", "vdda-pll" },
2175 		.clock = { "csiphy1", "csiphy1_timer" },
2176 		.clock_rate = { { 400000000, 480000000 },
2177 				{ 400000000 } },
2178 		.reg = { "csiphy1" },
2179 		.interrupt = { "csiphy1" },
2180 		.csiphy = {
2181 			.id = 1,
2182 			.hw_ops = &csiphy_ops_3ph_1_0,
2183 			.formats = &csiphy_formats_sdm845
2184 		}
2185 	},
2186 	/* CSIPHY2 */
2187 	{
2188 		.regulators = { "vdda-phy", "vdda-pll" },
2189 		.clock = { "csiphy2", "csiphy2_timer" },
2190 		.clock_rate = { { 400000000, 480000000 },
2191 				{ 400000000 } },
2192 		.reg = { "csiphy2" },
2193 		.interrupt = { "csiphy2" },
2194 		.csiphy = {
2195 			.id = 2,
2196 			.hw_ops = &csiphy_ops_3ph_1_0,
2197 			.formats = &csiphy_formats_sdm845
2198 		}
2199 	},
2200 	/* CSIPHY3 */
2201 	{
2202 		.regulators = { "vdda-phy", "vdda-pll" },
2203 		.clock = { "csiphy3", "csiphy3_timer" },
2204 		.clock_rate = { { 400000000, 480000000 },
2205 				{ 400000000 } },
2206 		.reg = { "csiphy3" },
2207 		.interrupt = { "csiphy3" },
2208 		.csiphy = {
2209 			.id = 3,
2210 			.hw_ops = &csiphy_ops_3ph_1_0,
2211 			.formats = &csiphy_formats_sdm845
2212 		}
2213 	},
2214 	/* CSIPHY4 */
2215 	{
2216 		.regulators = { "vdda-phy", "vdda-pll" },
2217 		.clock = { "csiphy4", "csiphy4_timer" },
2218 		.clock_rate = { { 400000000, 480000000 },
2219 				{ 400000000 } },
2220 		.reg = { "csiphy4" },
2221 		.interrupt = { "csiphy4" },
2222 		.csiphy = {
2223 			.id = 4,
2224 			.hw_ops = &csiphy_ops_3ph_1_0,
2225 			.formats = &csiphy_formats_sdm845
2226 		}
2227 	},
2228 	/* CSIPHY5 */
2229 	{
2230 		.regulators = { "vdda-phy", "vdda-pll" },
2231 		.clock = { "csiphy5", "csiphy5_timer" },
2232 		.clock_rate = { { 400000000, 480000000 },
2233 				{ 400000000 } },
2234 		.reg = { "csiphy5" },
2235 		.interrupt = { "csiphy5" },
2236 		.csiphy = {
2237 			.id = 5,
2238 			.hw_ops = &csiphy_ops_3ph_1_0,
2239 			.formats = &csiphy_formats_sdm845
2240 		}
2241 	},
2242 	/* CSIPHY6 */
2243 	{
2244 		.regulators = { "vdda-phy", "vdda-pll" },
2245 		.clock = { "csiphy6", "csiphy6_timer" },
2246 		.clock_rate = { { 400000000, 480000000 },
2247 				{ 400000000 } },
2248 		.reg = { "csiphy6" },
2249 		.interrupt = { "csiphy6" },
2250 		.csiphy = {
2251 			.id = 6,
2252 			.hw_ops = &csiphy_ops_3ph_1_0,
2253 			.formats = &csiphy_formats_sdm845
2254 		}
2255 	},
2256 	/* CSIPHY7 */
2257 	{
2258 		.regulators = { "vdda-phy", "vdda-pll" },
2259 		.clock = { "csiphy7", "csiphy7_timer" },
2260 		.clock_rate = { { 400000000, 480000000 },
2261 				{ 400000000 } },
2262 		.reg = { "csiphy7" },
2263 		.interrupt = { "csiphy7" },
2264 		.csiphy = {
2265 			.id = 7,
2266 			.hw_ops = &csiphy_ops_3ph_1_0,
2267 			.formats = &csiphy_formats_sdm845
2268 		}
2269 	}
2270 };
2271 
2272 static const struct resources_wrapper csid_wrapper_res_sm8550 = {
2273 	.reg = "csid_wrapper",
2274 };
2275 
2276 static const struct camss_subdev_resources csid_res_8550[] = {
2277 	/* CSID0 */
2278 	{
2279 		.regulators = {},
2280 		.clock = { "csid", "csiphy_rx" },
2281 		.clock_rate = { { 400000000, 480000000 },
2282 				{ 400000000, 480000000 } },
2283 		.reg = { "csid0" },
2284 		.interrupt = { "csid0" },
2285 		.csid = {
2286 			.is_lite = false,
2287 			.parent_dev_ops = &vfe_parent_dev_ops,
2288 			.hw_ops = &csid_ops_780,
2289 			.formats = &csid_formats_gen2
2290 		}
2291 	},
2292 	/* CSID1 */
2293 	{
2294 		.regulators = {},
2295 		.clock = { "csid", "csiphy_rx" },
2296 		.clock_rate = { { 400000000, 480000000 },
2297 				{ 400000000, 480000000 } },
2298 		.reg = { "csid1" },
2299 		.interrupt = { "csid1" },
2300 		.csid = {
2301 			.is_lite = false,
2302 			.parent_dev_ops = &vfe_parent_dev_ops,
2303 			.hw_ops = &csid_ops_780,
2304 			.formats = &csid_formats_gen2
2305 		}
2306 	},
2307 	/* CSID2 */
2308 	{
2309 		.regulators = {},
2310 		.clock = { "csid", "csiphy_rx" },
2311 		.clock_rate = { { 400000000, 480000000 },
2312 				{ 400000000, 480000000 } },
2313 		.reg = { "csid2" },
2314 		.interrupt = { "csid2" },
2315 		.csid = {
2316 			.is_lite = false,
2317 			.parent_dev_ops = &vfe_parent_dev_ops,
2318 			.hw_ops = &csid_ops_780,
2319 			.formats = &csid_formats_gen2
2320 		}
2321 	},
2322 	/* CSID3 */
2323 	{
2324 		.regulators = {},
2325 		.clock = { "vfe_lite_csid", "vfe_lite_cphy_rx" },
2326 		.clock_rate = { { 400000000, 480000000 },
2327 				{ 400000000, 480000000 } },
2328 		.reg = { "csid_lite0" },
2329 		.interrupt = { "csid_lite0" },
2330 		.csid = {
2331 			.is_lite = true,
2332 			.parent_dev_ops = &vfe_parent_dev_ops,
2333 			.hw_ops = &csid_ops_780,
2334 			.formats = &csid_formats_gen2
2335 		}
2336 	},
2337 	/* CSID4 */
2338 	{
2339 		.regulators = {},
2340 		.clock = { "vfe_lite_csid", "vfe_lite_cphy_rx" },
2341 		.clock_rate = { { 400000000, 480000000 },
2342 				{ 400000000, 480000000 } },
2343 		.reg = { "csid_lite1" },
2344 		.interrupt = { "csid_lite1" },
2345 		.csid = {
2346 			.is_lite = true,
2347 			.parent_dev_ops = &vfe_parent_dev_ops,
2348 			.hw_ops = &csid_ops_780,
2349 			.formats = &csid_formats_gen2
2350 		}
2351 	}
2352 };
2353 
2354 static const struct camss_subdev_resources vfe_res_8550[] = {
2355 	/* VFE0 */
2356 	{
2357 		.regulators = {},
2358 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe0_fast_ahb",
2359 			   "vfe0", "cpas_vfe0", "camnoc_axi" },
2360 		.clock_rate = { { 0 },
2361 				{ 80000000 },
2362 				{ 300000000, 400000000 },
2363 				{ 300000000, 400000000 },
2364 				{ 466000000, 594000000, 675000000, 785000000 },
2365 				{ 300000000, 400000000 },
2366 				{ 300000000, 400000000 } },
2367 		.reg = { "vfe0" },
2368 		.interrupt = { "vfe0" },
2369 		.vfe = {
2370 			.line_num = 3,
2371 			.is_lite = false,
2372 			.has_pd = true,
2373 			.pd_name = "ife0",
2374 			.hw_ops = &vfe_ops_780,
2375 			.formats_rdi = &vfe_formats_rdi_845,
2376 			.formats_pix = &vfe_formats_pix_845
2377 		}
2378 	},
2379 	/* VFE1 */
2380 	{
2381 		.regulators = {},
2382 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe1_fast_ahb",
2383 			   "vfe1", "cpas_vfe1", "camnoc_axi" },
2384 		.clock_rate = {	{ 0 },
2385 				{ 80000000 },
2386 				{ 300000000, 400000000 },
2387 				{ 300000000, 400000000 },
2388 				{ 466000000, 594000000, 675000000, 785000000 },
2389 				{ 300000000, 400000000 },
2390 				{ 300000000, 400000000 } },
2391 		.reg = { "vfe1" },
2392 		.interrupt = { "vfe1" },
2393 		.vfe = {
2394 			.line_num = 3,
2395 			.is_lite = false,
2396 			.has_pd = true,
2397 			.pd_name = "ife1",
2398 			.hw_ops = &vfe_ops_780,
2399 			.formats_rdi = &vfe_formats_rdi_845,
2400 			.formats_pix = &vfe_formats_pix_845
2401 		}
2402 	},
2403 	/* VFE2 */
2404 	{
2405 		.regulators = {},
2406 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe2_fast_ahb",
2407 			   "vfe2", "cpas_vfe2", "camnoc_axi" },
2408 		.clock_rate = {	{ 0 },
2409 				{ 80000000 },
2410 				{ 300000000, 400000000 },
2411 				{ 300000000, 400000000 },
2412 				{ 466000000, 594000000, 675000000, 785000000 },
2413 				{ 300000000, 400000000 },
2414 				{ 300000000, 400000000 } },
2415 		.reg = { "vfe2" },
2416 		.interrupt = { "vfe2" },
2417 		.vfe = {
2418 			.line_num = 3,
2419 			.is_lite = false,
2420 			.has_pd = true,
2421 			.pd_name = "ife2",
2422 			.hw_ops = &vfe_ops_780,
2423 			.formats_rdi = &vfe_formats_rdi_845,
2424 			.formats_pix = &vfe_formats_pix_845
2425 		}
2426 	},
2427 	/* VFE3 lite */
2428 	{
2429 		.regulators = {},
2430 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe_lite_ahb",
2431 			   "vfe_lite", "cpas_ife_lite", "camnoc_axi" },
2432 		.clock_rate = {	{ 0 },
2433 				{ 80000000 },
2434 				{ 300000000, 400000000 },
2435 				{ 300000000, 400000000 },
2436 				{ 400000000, 480000000 },
2437 				{ 300000000, 400000000 },
2438 				{ 300000000, 400000000 } },
2439 		.reg = { "vfe_lite0" },
2440 		.interrupt = { "vfe_lite0" },
2441 		.vfe = {
2442 			.line_num = 4,
2443 			.is_lite = true,
2444 			.hw_ops = &vfe_ops_780,
2445 			.formats_rdi = &vfe_formats_rdi_845,
2446 			.formats_pix = &vfe_formats_pix_845
2447 		}
2448 	},
2449 	/* VFE4 lite */
2450 	{
2451 		.regulators = {},
2452 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe_lite_ahb",
2453 			   "vfe_lite", "cpas_ife_lite", "camnoc_axi" },
2454 		.clock_rate = {	{ 0 },
2455 				{ 80000000 },
2456 				{ 300000000, 400000000 },
2457 				{ 300000000, 400000000 },
2458 				{ 400000000, 480000000 },
2459 				{ 300000000, 400000000 },
2460 				{ 300000000, 400000000 } },
2461 		.reg = { "vfe_lite1" },
2462 		.interrupt = { "vfe_lite1" },
2463 		.vfe = {
2464 			.line_num = 4,
2465 			.is_lite = true,
2466 			.hw_ops = &vfe_ops_780,
2467 			.formats_rdi = &vfe_formats_rdi_845,
2468 			.formats_pix = &vfe_formats_pix_845
2469 		}
2470 	},
2471 };
2472 
2473 static const struct resources_icc icc_res_sm8550[] = {
2474 	{
2475 		.name = "ahb",
2476 		.icc_bw_tbl.avg = 2097152,
2477 		.icc_bw_tbl.peak = 2097152,
2478 	},
2479 	{
2480 		.name = "hf_0_mnoc",
2481 		.icc_bw_tbl.avg = 2097152,
2482 		.icc_bw_tbl.peak = 2097152,
2483 	},
2484 };
2485 
2486 static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
2487 	/* CSIPHY0 */
2488 	{
2489 		.regulators = { "vdd-csiphy-0p8",
2490 				"vdd-csiphy-1p2" },
2491 		.clock = { "csiphy0", "csiphy0_timer" },
2492 		.clock_rate = { { 300000000, 400000000, 480000000 },
2493 				{ 266666667, 400000000 } },
2494 		.reg = { "csiphy0" },
2495 		.interrupt = { "csiphy0" },
2496 		.csiphy = {
2497 			.id = 0,
2498 			.hw_ops = &csiphy_ops_3ph_1_0,
2499 			.formats = &csiphy_formats_sdm845
2500 		},
2501 	},
2502 	/* CSIPHY1 */
2503 	{
2504 		.regulators = { "vdd-csiphy-0p8",
2505 				"vdd-csiphy-1p2" },
2506 		.clock = { "csiphy1", "csiphy1_timer" },
2507 		.clock_rate = { { 300000000, 400000000, 480000000 },
2508 				{ 266666667, 400000000 } },
2509 		.reg = { "csiphy1" },
2510 		.interrupt = { "csiphy1" },
2511 		.csiphy = {
2512 			.id = 1,
2513 			.hw_ops = &csiphy_ops_3ph_1_0,
2514 			.formats = &csiphy_formats_sdm845
2515 		},
2516 	},
2517 	/* CSIPHY2 */
2518 	{
2519 		.regulators = { "vdd-csiphy-0p8",
2520 				"vdd-csiphy-1p2" },
2521 		.clock = { "csiphy2", "csiphy2_timer" },
2522 		.clock_rate = { { 300000000, 400000000, 480000000 },
2523 				{ 266666667, 400000000 } },
2524 		.reg = { "csiphy2" },
2525 		.interrupt = { "csiphy2" },
2526 		.csiphy = {
2527 			.id = 2,
2528 			.hw_ops = &csiphy_ops_3ph_1_0,
2529 			.formats = &csiphy_formats_sdm845
2530 		},
2531 	},
2532 	/* CSIPHY4 */
2533 	{
2534 		.regulators = { "vdd-csiphy-0p8",
2535 				"vdd-csiphy-1p2" },
2536 		.clock = { "csiphy4", "csiphy4_timer" },
2537 		.clock_rate = { { 300000000, 400000000, 480000000 },
2538 				{ 266666667, 400000000 } },
2539 		.reg = { "csiphy4" },
2540 		.interrupt = { "csiphy4" },
2541 		.csiphy = {
2542 			.id = 4,
2543 			.hw_ops = &csiphy_ops_3ph_1_0,
2544 			.formats = &csiphy_formats_sdm845
2545 		},
2546 	},
2547 };
2548 
2549 static const struct camss_subdev_resources csid_res_x1e80100[] = {
2550 	/* CSID0 */
2551 	{
2552 		.regulators = {},
2553 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
2554 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
2555 		.clock_rate = { { 0 },
2556 				{ 0 },
2557 				{ 64000000, 80000000 },
2558 				{ 80000000,  100000000, 200000000,
2559 				  300000000, 400000000 },
2560 				{ 300000000, 400000000, 480000000 },
2561 				{ 300000000, 400000000, 480000000 }, },
2562 		.reg = { "csid0" },
2563 		.interrupt = { "csid0" },
2564 		.csid = {
2565 			.hw_ops = &csid_ops_680,
2566 			.parent_dev_ops = &vfe_parent_dev_ops,
2567 			.formats = &csid_formats_gen2
2568 		},
2569 	},
2570 	/* CSID1 */
2571 	{
2572 		.regulators = {},
2573 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
2574 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
2575 		.clock_rate = { { 0 },
2576 				{ 0 },
2577 				{ 64000000, 80000000 },
2578 				{ 80000000,  100000000, 200000000,
2579 				  300000000, 400000000 },
2580 				{ 300000000, 400000000, 480000000 },
2581 				{ 300000000, 400000000, 480000000 }, },
2582 		.reg = { "csid1" },
2583 		.interrupt = { "csid1" },
2584 		.csid = {
2585 			.hw_ops = &csid_ops_680,
2586 			.parent_dev_ops = &vfe_parent_dev_ops,
2587 			.formats = &csid_formats_gen2
2588 		},
2589 	},
2590 	/* CSID2 */
2591 	{
2592 		.regulators = {},
2593 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
2594 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
2595 		.clock_rate = { { 0 },
2596 				{ 0 },
2597 				{ 64000000, 80000000 },
2598 				{ 80000000,  100000000, 200000000,
2599 				  300000000, 400000000 },
2600 				{ 300000000, 400000000, 480000000 },
2601 				{ 300000000, 400000000, 480000000 }, },
2602 		.reg = { "csid2" },
2603 		.interrupt = { "csid2" },
2604 		.csid = {
2605 			.hw_ops = &csid_ops_680,
2606 			.parent_dev_ops = &vfe_parent_dev_ops,
2607 			.formats = &csid_formats_gen2
2608 		},
2609 	},
2610 	/* CSID_LITE0 */
2611 	{
2612 		.regulators = {},
2613 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
2614 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
2615 		.clock_rate = { { 0 },
2616 				{ 0 },
2617 				{ 64000000, 80000000 },
2618 				{ 80000000,  100000000, 200000000,
2619 				  300000000, 400000000 },
2620 				{ 300000000, 400000000, 480000000 },
2621 				{ 300000000, 400000000, 480000000 }, },
2622 		.reg = { "csid_lite0" },
2623 		.interrupt = { "csid_lite0" },
2624 		.csid = {
2625 			.is_lite = true,
2626 			.hw_ops = &csid_ops_680,
2627 			.parent_dev_ops = &vfe_parent_dev_ops,
2628 			.formats = &csid_formats_gen2
2629 		}
2630 	},
2631 	/* CSID_LITE1 */
2632 	{
2633 		.regulators = {},
2634 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
2635 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
2636 		.clock_rate = { { 0 },
2637 				{ 0 },
2638 				{ 64000000, 80000000 },
2639 				{ 80000000,  100000000, 200000000,
2640 				  300000000, 400000000 },
2641 				{ 300000000, 400000000, 480000000 },
2642 				{ 300000000, 400000000, 480000000 }, },
2643 
2644 		.reg = { "csid_lite1" },
2645 		.interrupt = { "csid_lite1" },
2646 		.csid = {
2647 			.is_lite = true,
2648 			.hw_ops = &csid_ops_680,
2649 			.parent_dev_ops = &vfe_parent_dev_ops,
2650 			.formats = &csid_formats_gen2
2651 		}
2652 	},
2653 };
2654 
2655 static const struct camss_subdev_resources vfe_res_x1e80100[] = {
2656 	/* IFE0 */
2657 	{
2658 		.regulators = {},
2659 		.clock = {"camnoc_rt_axi", "camnoc_nrt_axi", "cpas_ahb",
2660 			  "cpas_fast_ahb", "cpas_vfe0", "vfe0_fast_ahb",
2661 			  "vfe0" },
2662 		.clock_rate = { { 0 },
2663 				{ 0 },
2664 				{ 0 },
2665 				{ 0 },
2666 				{ 0 },
2667 				{ 0 },
2668 				{ 345600000, 432000000, 594000000, 675000000,
2669 				  727000000 }, },
2670 		.reg = { "vfe0" },
2671 		.interrupt = { "vfe0" },
2672 		.vfe = {
2673 			.line_num = 4,
2674 			.pd_name = "ife0",
2675 			.hw_ops = &vfe_ops_680,
2676 			.formats_rdi = &vfe_formats_rdi_845,
2677 			.formats_pix = &vfe_formats_pix_845
2678 		},
2679 	},
2680 	/* IFE1 */
2681 	{
2682 		.regulators = {},
2683 		.clock = { "camnoc_rt_axi", "camnoc_nrt_axi", "cpas_ahb",
2684 			   "cpas_fast_ahb", "cpas_vfe1", "vfe1_fast_ahb",
2685 			   "vfe1"  },
2686 		.clock_rate = { { 0 },
2687 				{ 0 },
2688 				{ 0 },
2689 				{ 0 },
2690 				{ 0 },
2691 				{ 0 },
2692 				{ 345600000, 432000000, 594000000, 675000000,
2693 				  727000000 }, },
2694 		.reg = { "vfe1" },
2695 		.interrupt = { "vfe1" },
2696 		.vfe = {
2697 			.line_num = 4,
2698 			.pd_name = "ife1",
2699 			.hw_ops = &vfe_ops_680,
2700 			.formats_rdi = &vfe_formats_rdi_845,
2701 			.formats_pix = &vfe_formats_pix_845
2702 		},
2703 	},
2704 	/* IFE_LITE_0 */
2705 	{
2706 		.regulators = {},
2707 		.clock = { "camnoc_rt_axi", "camnoc_nrt_axi", "cpas_ahb",
2708 			   "vfe_lite_ahb", "cpas_vfe_lite", "vfe_lite",
2709 			   "vfe_lite_csid" },
2710 		.clock_rate = { { 0 },
2711 				{ 0 },
2712 				{ 0 },
2713 				{ 0 },
2714 				{ 0 },
2715 				{ 266666667, 400000000, 480000000 },
2716 				{ 266666667, 400000000, 480000000 }, },
2717 		.reg = { "vfe_lite0" },
2718 		.interrupt = { "vfe_lite0" },
2719 		.vfe = {
2720 			.is_lite = true,
2721 			.line_num = 4,
2722 			.hw_ops = &vfe_ops_680,
2723 			.formats_rdi = &vfe_formats_rdi_845,
2724 			.formats_pix = &vfe_formats_pix_845
2725 		},
2726 	},
2727 	/* IFE_LITE_1 */
2728 	{
2729 		.regulators = {},
2730 		.clock = { "camnoc_rt_axi", "camnoc_nrt_axi", "cpas_ahb",
2731 			   "vfe_lite_ahb", "cpas_vfe_lite", "vfe_lite",
2732 			   "vfe_lite_csid" },
2733 		.clock_rate = { { 0 },
2734 				{ 0 },
2735 				{ 0 },
2736 				{ 0 },
2737 				{ 0 },
2738 				{ 266666667, 400000000, 480000000 },
2739 				{ 266666667, 400000000, 480000000 }, },
2740 		.reg = { "vfe_lite1" },
2741 		.interrupt = { "vfe_lite1" },
2742 		.vfe = {
2743 			.is_lite = true,
2744 			.line_num = 4,
2745 			.hw_ops = &vfe_ops_680,
2746 			.formats_rdi = &vfe_formats_rdi_845,
2747 			.formats_pix = &vfe_formats_pix_845
2748 		},
2749 	},
2750 };
2751 
2752 static const struct resources_icc icc_res_x1e80100[] = {
2753 	{
2754 		.name = "ahb",
2755 		.icc_bw_tbl.avg = 150000,
2756 		.icc_bw_tbl.peak = 300000,
2757 	},
2758 	{
2759 		.name = "hf_mnoc",
2760 		.icc_bw_tbl.avg = 2097152,
2761 		.icc_bw_tbl.peak = 2097152,
2762 	},
2763 	{
2764 		.name = "sf_mnoc",
2765 		.icc_bw_tbl.avg = 2097152,
2766 		.icc_bw_tbl.peak = 2097152,
2767 	},
2768 	{
2769 		.name = "sf_icp_mnoc",
2770 		.icc_bw_tbl.avg = 2097152,
2771 		.icc_bw_tbl.peak = 2097152,
2772 	},
2773 };
2774 
2775 static const struct resources_wrapper csid_wrapper_res_x1e80100 = {
2776 	.reg = "csid_wrapper",
2777 };
2778 
2779 /*
2780  * camss_add_clock_margin - Add margin to clock frequency rate
2781  * @rate: Clock frequency rate
2782  *
2783  * When making calculations with physical clock frequency values
2784  * some safety margin must be added. Add it.
2785  */
camss_add_clock_margin(u64 * rate)2786 inline void camss_add_clock_margin(u64 *rate)
2787 {
2788 	*rate *= CAMSS_CLOCK_MARGIN_NUMERATOR;
2789 	*rate = div_u64(*rate, CAMSS_CLOCK_MARGIN_DENOMINATOR);
2790 }
2791 
2792 /*
2793  * camss_enable_clocks - Enable multiple clocks
2794  * @nclocks: Number of clocks in clock array
2795  * @clock: Clock array
2796  * @dev: Device
2797  *
2798  * Return 0 on success or a negative error code otherwise
2799  */
camss_enable_clocks(int nclocks,struct camss_clock * clock,struct device * dev)2800 int camss_enable_clocks(int nclocks, struct camss_clock *clock,
2801 			struct device *dev)
2802 {
2803 	int ret;
2804 	int i;
2805 
2806 	for (i = 0; i < nclocks; i++) {
2807 		ret = clk_prepare_enable(clock[i].clk);
2808 		if (ret) {
2809 			dev_err(dev, "clock enable failed: %d\n", ret);
2810 			goto error;
2811 		}
2812 	}
2813 
2814 	return 0;
2815 
2816 error:
2817 	for (i--; i >= 0; i--)
2818 		clk_disable_unprepare(clock[i].clk);
2819 
2820 	return ret;
2821 }
2822 
2823 /*
2824  * camss_disable_clocks - Disable multiple clocks
2825  * @nclocks: Number of clocks in clock array
2826  * @clock: Clock array
2827  */
camss_disable_clocks(int nclocks,struct camss_clock * clock)2828 void camss_disable_clocks(int nclocks, struct camss_clock *clock)
2829 {
2830 	int i;
2831 
2832 	for (i = nclocks - 1; i >= 0; i--)
2833 		clk_disable_unprepare(clock[i].clk);
2834 }
2835 
2836 /*
2837  * camss_find_sensor_pad - Find the media pad via which the sensor is linked
2838  * @entity: Media entity to start searching from
2839  *
2840  * Return a pointer to sensor media pad or NULL if not found
2841  */
camss_find_sensor_pad(struct media_entity * entity)2842 struct media_pad *camss_find_sensor_pad(struct media_entity *entity)
2843 {
2844 	struct media_pad *pad;
2845 
2846 	while (1) {
2847 		pad = &entity->pads[0];
2848 		if (!(pad->flags & MEDIA_PAD_FL_SINK))
2849 			return NULL;
2850 
2851 		pad = media_pad_remote_pad_first(pad);
2852 		if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
2853 			return NULL;
2854 
2855 		entity = pad->entity;
2856 
2857 		if (entity->function == MEDIA_ENT_F_CAM_SENSOR)
2858 			return pad;
2859 	}
2860 }
2861 
2862 /**
2863  * camss_get_link_freq - Get link frequency from sensor
2864  * @entity: Media entity in the current pipeline
2865  * @bpp: Number of bits per pixel for the current format
2866  * @lanes: Number of lanes in the link to the sensor
2867  *
2868  * Return link frequency on success or a negative error code otherwise
2869  */
camss_get_link_freq(struct media_entity * entity,unsigned int bpp,unsigned int lanes)2870 s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp,
2871 			unsigned int lanes)
2872 {
2873 	struct media_pad *sensor_pad;
2874 
2875 	sensor_pad = camss_find_sensor_pad(entity);
2876 	if (!sensor_pad)
2877 		return -ENODEV;
2878 
2879 	return v4l2_get_link_freq(sensor_pad, bpp, 2 * lanes);
2880 }
2881 
2882 /*
2883  * camss_get_pixel_clock - Get pixel clock rate from sensor
2884  * @entity: Media entity in the current pipeline
2885  * @pixel_clock: Received pixel clock value
2886  *
2887  * Return 0 on success or a negative error code otherwise
2888  */
camss_get_pixel_clock(struct media_entity * entity,u64 * pixel_clock)2889 int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock)
2890 {
2891 	struct media_pad *sensor_pad;
2892 	struct v4l2_subdev *subdev;
2893 	struct v4l2_ctrl *ctrl;
2894 
2895 	sensor_pad = camss_find_sensor_pad(entity);
2896 	if (!sensor_pad)
2897 		return -ENODEV;
2898 
2899 	subdev = media_entity_to_v4l2_subdev(sensor_pad->entity);
2900 
2901 	ctrl = v4l2_ctrl_find(subdev->ctrl_handler, V4L2_CID_PIXEL_RATE);
2902 
2903 	if (!ctrl)
2904 		return -EINVAL;
2905 
2906 	*pixel_clock = v4l2_ctrl_g_ctrl_int64(ctrl);
2907 
2908 	return 0;
2909 }
2910 
camss_pm_domain_on(struct camss * camss,int id)2911 int camss_pm_domain_on(struct camss *camss, int id)
2912 {
2913 	int ret = 0;
2914 
2915 	if (id < camss->res->vfe_num) {
2916 		struct vfe_device *vfe = &camss->vfe[id];
2917 
2918 		ret = vfe->res->hw_ops->pm_domain_on(vfe);
2919 	}
2920 
2921 	return ret;
2922 }
2923 
camss_pm_domain_off(struct camss * camss,int id)2924 void camss_pm_domain_off(struct camss *camss, int id)
2925 {
2926 	if (id < camss->res->vfe_num) {
2927 		struct vfe_device *vfe = &camss->vfe[id];
2928 
2929 		vfe->res->hw_ops->pm_domain_off(vfe);
2930 	}
2931 }
2932 
vfe_parent_dev_ops_get(struct camss * camss,int id)2933 static int vfe_parent_dev_ops_get(struct camss *camss, int id)
2934 {
2935 	int ret = -EINVAL;
2936 
2937 	if (id < camss->res->vfe_num) {
2938 		struct vfe_device *vfe = &camss->vfe[id];
2939 
2940 		ret = vfe_get(vfe);
2941 	}
2942 
2943 	return ret;
2944 }
2945 
vfe_parent_dev_ops_put(struct camss * camss,int id)2946 static int vfe_parent_dev_ops_put(struct camss *camss, int id)
2947 {
2948 	if (id < camss->res->vfe_num) {
2949 		struct vfe_device *vfe = &camss->vfe[id];
2950 
2951 		vfe_put(vfe);
2952 	}
2953 
2954 	return 0;
2955 }
2956 
2957 static void __iomem
vfe_parent_dev_ops_get_base_address(struct camss * camss,int id)2958 *vfe_parent_dev_ops_get_base_address(struct camss *camss, int id)
2959 {
2960 	if (id < camss->res->vfe_num) {
2961 		struct vfe_device *vfe = &camss->vfe[id];
2962 
2963 		return vfe->base;
2964 	}
2965 
2966 	return NULL;
2967 }
2968 
2969 static const struct parent_dev_ops vfe_parent_dev_ops = {
2970 	.get = vfe_parent_dev_ops_get,
2971 	.put = vfe_parent_dev_ops_put,
2972 	.get_base_address = vfe_parent_dev_ops_get_base_address
2973 };
2974 
2975 /*
2976  * camss_of_parse_endpoint_node - Parse port endpoint node
2977  * @dev: Device
2978  * @node: Device node to be parsed
2979  * @csd: Parsed data from port endpoint node
2980  *
2981  * Return 0 on success or a negative error code on failure
2982  */
camss_of_parse_endpoint_node(struct device * dev,struct device_node * node,struct camss_async_subdev * csd)2983 static int camss_of_parse_endpoint_node(struct device *dev,
2984 					struct device_node *node,
2985 					struct camss_async_subdev *csd)
2986 {
2987 	struct csiphy_lanes_cfg *lncfg = &csd->interface.csi2.lane_cfg;
2988 	struct v4l2_mbus_config_mipi_csi2 *mipi_csi2;
2989 	struct v4l2_fwnode_endpoint vep = { { 0 } };
2990 	unsigned int i;
2991 	int ret;
2992 
2993 	ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(node), &vep);
2994 	if (ret)
2995 		return ret;
2996 
2997 	/*
2998 	 * Most SoCs support both D-PHY and C-PHY standards, but currently only
2999 	 * D-PHY is supported in the driver.
3000 	 */
3001 	if (vep.bus_type != V4L2_MBUS_CSI2_DPHY) {
3002 		dev_err(dev, "Unsupported bus type %d\n", vep.bus_type);
3003 		return -EINVAL;
3004 	}
3005 
3006 	csd->interface.csiphy_id = vep.base.port;
3007 
3008 	mipi_csi2 = &vep.bus.mipi_csi2;
3009 	lncfg->clk.pos = mipi_csi2->clock_lane;
3010 	lncfg->clk.pol = mipi_csi2->lane_polarities[0];
3011 	lncfg->num_data = mipi_csi2->num_data_lanes;
3012 
3013 	lncfg->data = devm_kcalloc(dev,
3014 				   lncfg->num_data, sizeof(*lncfg->data),
3015 				   GFP_KERNEL);
3016 	if (!lncfg->data)
3017 		return -ENOMEM;
3018 
3019 	for (i = 0; i < lncfg->num_data; i++) {
3020 		lncfg->data[i].pos = mipi_csi2->data_lanes[i];
3021 		lncfg->data[i].pol = mipi_csi2->lane_polarities[i + 1];
3022 	}
3023 
3024 	return 0;
3025 }
3026 
3027 /*
3028  * camss_of_parse_ports - Parse ports node
3029  * @dev: Device
3030  * @notifier: v4l2_device notifier data
3031  *
3032  * Return number of "port" nodes found in "ports" node
3033  */
camss_of_parse_ports(struct camss * camss)3034 static int camss_of_parse_ports(struct camss *camss)
3035 {
3036 	struct device *dev = camss->dev;
3037 	struct device_node *node = NULL;
3038 	struct device_node *remote = NULL;
3039 	int ret, num_subdevs = 0;
3040 
3041 	for_each_endpoint_of_node(dev->of_node, node) {
3042 		struct camss_async_subdev *csd;
3043 
3044 		if (!of_device_is_available(node))
3045 			continue;
3046 
3047 		remote = of_graph_get_remote_port_parent(node);
3048 		if (!remote) {
3049 			dev_err(dev, "Cannot get remote parent\n");
3050 			ret = -EINVAL;
3051 			goto err_cleanup;
3052 		}
3053 
3054 		csd = v4l2_async_nf_add_fwnode(&camss->notifier,
3055 					       of_fwnode_handle(remote),
3056 					       struct camss_async_subdev);
3057 		of_node_put(remote);
3058 		if (IS_ERR(csd)) {
3059 			ret = PTR_ERR(csd);
3060 			goto err_cleanup;
3061 		}
3062 
3063 		ret = camss_of_parse_endpoint_node(dev, node, csd);
3064 		if (ret < 0)
3065 			goto err_cleanup;
3066 
3067 		num_subdevs++;
3068 	}
3069 
3070 	return num_subdevs;
3071 
3072 err_cleanup:
3073 	of_node_put(node);
3074 	return ret;
3075 }
3076 
3077 /*
3078  * camss_init_subdevices - Initialize subdev structures and resources
3079  * @camss: CAMSS device
3080  *
3081  * Return 0 on success or a negative error code on failure
3082  */
camss_init_subdevices(struct camss * camss)3083 static int camss_init_subdevices(struct camss *camss)
3084 {
3085 	struct platform_device *pdev = to_platform_device(camss->dev);
3086 	const struct camss_resources *res = camss->res;
3087 	unsigned int i;
3088 	int ret;
3089 
3090 	for (i = 0; i < camss->res->csiphy_num; i++) {
3091 		ret = msm_csiphy_subdev_init(camss, &camss->csiphy[i],
3092 					     &res->csiphy_res[i],
3093 					     res->csiphy_res[i].csiphy.id);
3094 		if (ret < 0) {
3095 			dev_err(camss->dev,
3096 				"Failed to init csiphy%d sub-device: %d\n",
3097 				i, ret);
3098 			return ret;
3099 		}
3100 	}
3101 
3102 	/* note: SM8250 requires VFE to be initialized before CSID */
3103 	for (i = 0; i < camss->res->vfe_num; i++) {
3104 		ret = msm_vfe_subdev_init(camss, &camss->vfe[i],
3105 					  &res->vfe_res[i], i);
3106 		if (ret < 0) {
3107 			dev_err(camss->dev,
3108 				"Fail to init vfe%d sub-device: %d\n", i, ret);
3109 			return ret;
3110 		}
3111 	}
3112 
3113 	/* Get optional CSID wrapper regs shared between CSID devices */
3114 	if (res->csid_wrapper_res) {
3115 		char *reg = res->csid_wrapper_res->reg;
3116 		void __iomem *base;
3117 
3118 		base = devm_platform_ioremap_resource_byname(pdev, reg);
3119 		if (IS_ERR(base))
3120 			return PTR_ERR(base);
3121 		camss->csid_wrapper_base = base;
3122 	}
3123 
3124 	for (i = 0; i < camss->res->csid_num; i++) {
3125 		ret = msm_csid_subdev_init(camss, &camss->csid[i],
3126 					   &res->csid_res[i], i);
3127 		if (ret < 0) {
3128 			dev_err(camss->dev,
3129 				"Failed to init csid%d sub-device: %d\n",
3130 				i, ret);
3131 			return ret;
3132 		}
3133 	}
3134 
3135 	ret = msm_ispif_subdev_init(camss, res->ispif_res);
3136 	if (ret < 0) {
3137 		dev_err(camss->dev, "Failed to init ispif sub-device: %d\n",
3138 		ret);
3139 		return ret;
3140 	}
3141 
3142 	return 0;
3143 }
3144 
3145 /*
3146  * camss_link_entities - Register subdev nodes and create links
3147  * camss_link_err - print error in case link creation fails
3148  * @src_name: name for source of the link
3149  * @sink_name: name for sink of the link
3150  */
camss_link_err(struct camss * camss,const char * src_name,const char * sink_name,int ret)3151 inline void camss_link_err(struct camss *camss,
3152 			   const char *src_name,
3153 			   const char *sink_name,
3154 			   int ret)
3155 {
3156 	dev_err(camss->dev,
3157 		"Failed to link %s->%s entities: %d\n",
3158 		src_name,
3159 		sink_name,
3160 		ret);
3161 }
3162 
3163 /*
3164  * camss_link_entities - Register subdev nodes and create links
3165  * @camss: CAMSS device
3166  *
3167  * Return 0 on success or a negative error code on failure
3168  */
camss_link_entities(struct camss * camss)3169 static int camss_link_entities(struct camss *camss)
3170 {
3171 	int i, j, k;
3172 	int ret;
3173 
3174 	for (i = 0; i < camss->res->csiphy_num; i++) {
3175 		for (j = 0; j < camss->res->csid_num; j++) {
3176 			ret = media_create_pad_link(&camss->csiphy[i].subdev.entity,
3177 						    MSM_CSIPHY_PAD_SRC,
3178 						    &camss->csid[j].subdev.entity,
3179 						    MSM_CSID_PAD_SINK,
3180 						    0);
3181 			if (ret < 0) {
3182 				camss_link_err(camss,
3183 					       camss->csiphy[i].subdev.entity.name,
3184 					       camss->csid[j].subdev.entity.name,
3185 					       ret);
3186 				return ret;
3187 			}
3188 		}
3189 	}
3190 
3191 	if (camss->ispif) {
3192 		for (i = 0; i < camss->res->csid_num; i++) {
3193 			for (j = 0; j < camss->ispif->line_num; j++) {
3194 				ret = media_create_pad_link(&camss->csid[i].subdev.entity,
3195 							    MSM_CSID_PAD_SRC,
3196 							    &camss->ispif->line[j].subdev.entity,
3197 							    MSM_ISPIF_PAD_SINK,
3198 							    0);
3199 				if (ret < 0) {
3200 					camss_link_err(camss,
3201 						       camss->csid[i].subdev.entity.name,
3202 						       camss->ispif->line[j].subdev.entity.name,
3203 						       ret);
3204 					return ret;
3205 				}
3206 			}
3207 		}
3208 
3209 		for (i = 0; i < camss->ispif->line_num; i++)
3210 			for (k = 0; k < camss->res->vfe_num; k++)
3211 				for (j = 0; j < camss->vfe[k].res->line_num; j++) {
3212 					struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
3213 					struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
3214 
3215 					ret = media_create_pad_link(&ispif->entity,
3216 								    MSM_ISPIF_PAD_SRC,
3217 								    &vfe->entity,
3218 								    MSM_VFE_PAD_SINK,
3219 								    0);
3220 					if (ret < 0) {
3221 						camss_link_err(camss, ispif->entity.name,
3222 							       vfe->entity.name,
3223 							       ret);
3224 						return ret;
3225 					}
3226 				}
3227 	} else {
3228 		for (i = 0; i < camss->res->csid_num; i++)
3229 			for (k = 0; k < camss->res->vfe_num; k++)
3230 				for (j = 0; j < camss->vfe[k].res->line_num; j++) {
3231 					struct v4l2_subdev *csid = &camss->csid[i].subdev;
3232 					struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
3233 
3234 					ret = media_create_pad_link(&csid->entity,
3235 								    MSM_CSID_PAD_FIRST_SRC + j,
3236 								    &vfe->entity,
3237 								    MSM_VFE_PAD_SINK,
3238 								    0);
3239 					if (ret < 0) {
3240 						camss_link_err(camss, csid->entity.name,
3241 							       vfe->entity.name,
3242 							       ret);
3243 						return ret;
3244 					}
3245 				}
3246 	}
3247 
3248 	return 0;
3249 }
3250 
camss_reg_update(struct camss * camss,int hw_id,int port_id,bool is_clear)3251 void camss_reg_update(struct camss *camss, int hw_id, int port_id, bool is_clear)
3252 {
3253 	struct csid_device *csid;
3254 
3255 	if (hw_id < camss->res->csid_num) {
3256 		csid = &camss->csid[hw_id];
3257 
3258 		csid->res->hw_ops->reg_update(csid, port_id, is_clear);
3259 	}
3260 }
3261 
camss_buf_done(struct camss * camss,int hw_id,int port_id)3262 void camss_buf_done(struct camss *camss, int hw_id, int port_id)
3263 {
3264 	struct vfe_device *vfe;
3265 
3266 	if (hw_id < camss->res->vfe_num) {
3267 		vfe = &camss->vfe[hw_id];
3268 
3269 		vfe->res->hw_ops->vfe_buf_done(vfe, port_id);
3270 	}
3271 }
3272 
3273 /*
3274  * camss_register_entities - Register subdev nodes and create links
3275  * @camss: CAMSS device
3276  *
3277  * Return 0 on success or a negative error code on failure
3278  */
camss_register_entities(struct camss * camss)3279 static int camss_register_entities(struct camss *camss)
3280 {
3281 	int i;
3282 	int ret;
3283 
3284 	for (i = 0; i < camss->res->csiphy_num; i++) {
3285 		ret = msm_csiphy_register_entity(&camss->csiphy[i],
3286 						 &camss->v4l2_dev);
3287 		if (ret < 0) {
3288 			dev_err(camss->dev,
3289 				"Failed to register csiphy%d entity: %d\n",
3290 				i, ret);
3291 			goto err_reg_csiphy;
3292 		}
3293 	}
3294 
3295 	for (i = 0; i < camss->res->csid_num; i++) {
3296 		ret = msm_csid_register_entity(&camss->csid[i],
3297 					       &camss->v4l2_dev);
3298 		if (ret < 0) {
3299 			dev_err(camss->dev,
3300 				"Failed to register csid%d entity: %d\n",
3301 				i, ret);
3302 			goto err_reg_csid;
3303 		}
3304 	}
3305 
3306 	ret = msm_ispif_register_entities(camss->ispif,
3307 					  &camss->v4l2_dev);
3308 	if (ret < 0) {
3309 		dev_err(camss->dev, "Failed to register ispif entities: %d\n", ret);
3310 		goto err_reg_ispif;
3311 	}
3312 
3313 	for (i = 0; i < camss->res->vfe_num; i++) {
3314 		ret = msm_vfe_register_entities(&camss->vfe[i],
3315 						&camss->v4l2_dev);
3316 		if (ret < 0) {
3317 			dev_err(camss->dev,
3318 				"Failed to register vfe%d entities: %d\n",
3319 				i, ret);
3320 			goto err_reg_vfe;
3321 		}
3322 	}
3323 
3324 	return 0;
3325 
3326 err_reg_vfe:
3327 	for (i--; i >= 0; i--)
3328 		msm_vfe_unregister_entities(&camss->vfe[i]);
3329 
3330 err_reg_ispif:
3331 	msm_ispif_unregister_entities(camss->ispif);
3332 
3333 	i = camss->res->csid_num;
3334 err_reg_csid:
3335 	for (i--; i >= 0; i--)
3336 		msm_csid_unregister_entity(&camss->csid[i]);
3337 
3338 	i = camss->res->csiphy_num;
3339 err_reg_csiphy:
3340 	for (i--; i >= 0; i--)
3341 		msm_csiphy_unregister_entity(&camss->csiphy[i]);
3342 
3343 	return ret;
3344 }
3345 
3346 /*
3347  * camss_unregister_entities - Unregister subdev nodes
3348  * @camss: CAMSS device
3349  *
3350  * Return 0 on success or a negative error code on failure
3351  */
camss_unregister_entities(struct camss * camss)3352 static void camss_unregister_entities(struct camss *camss)
3353 {
3354 	unsigned int i;
3355 
3356 	for (i = 0; i < camss->res->csiphy_num; i++)
3357 		msm_csiphy_unregister_entity(&camss->csiphy[i]);
3358 
3359 	for (i = 0; i < camss->res->csid_num; i++)
3360 		msm_csid_unregister_entity(&camss->csid[i]);
3361 
3362 	msm_ispif_unregister_entities(camss->ispif);
3363 
3364 	for (i = 0; i < camss->res->vfe_num; i++)
3365 		msm_vfe_unregister_entities(&camss->vfe[i]);
3366 }
3367 
camss_subdev_notifier_bound(struct v4l2_async_notifier * async,struct v4l2_subdev * subdev,struct v4l2_async_connection * asd)3368 static int camss_subdev_notifier_bound(struct v4l2_async_notifier *async,
3369 				       struct v4l2_subdev *subdev,
3370 				       struct v4l2_async_connection *asd)
3371 {
3372 	struct camss *camss = container_of(async, struct camss, notifier);
3373 	struct camss_async_subdev *csd =
3374 		container_of(asd, struct camss_async_subdev, asd);
3375 	u8 id = csd->interface.csiphy_id;
3376 	struct csiphy_device *csiphy = &camss->csiphy[id];
3377 
3378 	csiphy->cfg.csi2 = &csd->interface.csi2;
3379 	subdev->host_priv = csiphy;
3380 
3381 	return 0;
3382 }
3383 
camss_subdev_notifier_complete(struct v4l2_async_notifier * async)3384 static int camss_subdev_notifier_complete(struct v4l2_async_notifier *async)
3385 {
3386 	struct camss *camss = container_of(async, struct camss, notifier);
3387 	struct v4l2_device *v4l2_dev = &camss->v4l2_dev;
3388 	struct v4l2_subdev *sd;
3389 
3390 	list_for_each_entry(sd, &v4l2_dev->subdevs, list) {
3391 		struct csiphy_device *csiphy = sd->host_priv;
3392 		struct media_entity *input, *sensor;
3393 		unsigned int i;
3394 		int ret;
3395 
3396 		if (!csiphy)
3397 			continue;
3398 
3399 		input = &csiphy->subdev.entity;
3400 		sensor = &sd->entity;
3401 
3402 		for (i = 0; i < sensor->num_pads; i++) {
3403 			if (sensor->pads[i].flags & MEDIA_PAD_FL_SOURCE)
3404 				break;
3405 		}
3406 		if (i == sensor->num_pads) {
3407 			dev_err(camss->dev,
3408 				"No source pad in external entity\n");
3409 			return -EINVAL;
3410 		}
3411 
3412 		ret = media_create_pad_link(sensor, i, input,
3413 					    MSM_CSIPHY_PAD_SINK,
3414 					    MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED);
3415 		if (ret < 0) {
3416 			camss_link_err(camss, sensor->name, input->name, ret);
3417 			return ret;
3418 		}
3419 	}
3420 
3421 	return v4l2_device_register_subdev_nodes(&camss->v4l2_dev);
3422 }
3423 
3424 static const struct v4l2_async_notifier_operations camss_subdev_notifier_ops = {
3425 	.bound = camss_subdev_notifier_bound,
3426 	.complete = camss_subdev_notifier_complete,
3427 };
3428 
3429 static const struct media_device_ops camss_media_ops = {
3430 	.link_notify = v4l2_pipeline_link_notify,
3431 };
3432 
camss_configure_pd(struct camss * camss)3433 static int camss_configure_pd(struct camss *camss)
3434 {
3435 	const struct camss_resources *res = camss->res;
3436 	struct device *dev = camss->dev;
3437 	int vfepd_num;
3438 	int i;
3439 	int ret;
3440 
3441 	camss->genpd_num = of_count_phandle_with_args(dev->of_node,
3442 						      "power-domains",
3443 						      "#power-domain-cells");
3444 	if (camss->genpd_num < 0) {
3445 		dev_err(dev, "Power domains are not defined for camss\n");
3446 		return camss->genpd_num;
3447 	}
3448 
3449 	/*
3450 	 * If a platform device has just one power domain, then it is attached
3451 	 * at platform_probe() level, thus there shall be no need and even no
3452 	 * option to attach it again, this is the case for CAMSS on MSM8916.
3453 	 */
3454 	if (camss->genpd_num == 1)
3455 		return 0;
3456 
3457 	/* count the # of VFEs which have flagged power-domain */
3458 	for (vfepd_num = i = 0; i < camss->res->vfe_num; i++) {
3459 		if (res->vfe_res[i].vfe.has_pd)
3460 			vfepd_num++;
3461 	}
3462 
3463 	/*
3464 	 * If the number of power-domains is greater than the number of VFEs
3465 	 * then the additional power-domain is for the entire CAMSS block.
3466 	 */
3467 	if (!(camss->genpd_num > vfepd_num))
3468 		return 0;
3469 
3470 	/*
3471 	 * If a power-domain name is defined try to use it.
3472 	 * It is possible we are running a new kernel with an old dtb so
3473 	 * fallback to indexes even if a pd_name is defined but not found.
3474 	 */
3475 	if (camss->res->pd_name) {
3476 		camss->genpd = dev_pm_domain_attach_by_name(camss->dev,
3477 							    camss->res->pd_name);
3478 		if (IS_ERR(camss->genpd))
3479 			return PTR_ERR(camss->genpd);
3480 	}
3481 
3482 	if (!camss->genpd) {
3483 		/*
3484 		 * Legacy magic index. TITAN_TOP GDSC must be the last
3485 		 * item in the power-domain list.
3486 		 */
3487 		camss->genpd = dev_pm_domain_attach_by_id(camss->dev,
3488 							  camss->genpd_num - 1);
3489 		if (IS_ERR(camss->genpd))
3490 			return PTR_ERR(camss->genpd);
3491 	}
3492 
3493 	if (!camss->genpd)
3494 		return -ENODEV;
3495 
3496 	camss->genpd_link = device_link_add(camss->dev, camss->genpd,
3497 					    DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME |
3498 					    DL_FLAG_RPM_ACTIVE);
3499 	if (!camss->genpd_link) {
3500 		ret = -EINVAL;
3501 		goto fail_pm;
3502 	}
3503 
3504 	return 0;
3505 
3506 fail_pm:
3507 	dev_pm_domain_detach(camss->genpd, true);
3508 
3509 	return ret;
3510 }
3511 
camss_icc_get(struct camss * camss)3512 static int camss_icc_get(struct camss *camss)
3513 {
3514 	const struct resources_icc *icc_res;
3515 	int i;
3516 
3517 	icc_res = camss->res->icc_res;
3518 
3519 	for (i = 0; i < camss->res->icc_path_num; i++) {
3520 		camss->icc_path[i] = devm_of_icc_get(camss->dev,
3521 						     icc_res[i].name);
3522 		if (IS_ERR(camss->icc_path[i]))
3523 			return PTR_ERR(camss->icc_path[i]);
3524 	}
3525 
3526 	return 0;
3527 }
3528 
camss_genpd_subdevice_cleanup(struct camss * camss)3529 static void camss_genpd_subdevice_cleanup(struct camss *camss)
3530 {
3531 	int i;
3532 
3533 	for (i = 0; i < camss->res->vfe_num; i++)
3534 		msm_vfe_genpd_cleanup(&camss->vfe[i]);
3535 }
3536 
camss_genpd_cleanup(struct camss * camss)3537 static void camss_genpd_cleanup(struct camss *camss)
3538 {
3539 	if (camss->genpd_num == 1)
3540 		return;
3541 
3542 	camss_genpd_subdevice_cleanup(camss);
3543 
3544 	if (camss->genpd_link)
3545 		device_link_del(camss->genpd_link);
3546 
3547 	dev_pm_domain_detach(camss->genpd, true);
3548 }
3549 
3550 /*
3551  * camss_probe - Probe CAMSS platform device
3552  * @pdev: Pointer to CAMSS platform device
3553  *
3554  * Return 0 on success or a negative error code on failure
3555  */
camss_probe(struct platform_device * pdev)3556 static int camss_probe(struct platform_device *pdev)
3557 {
3558 	struct device *dev = &pdev->dev;
3559 	struct camss *camss;
3560 	int num_subdevs;
3561 	int ret;
3562 
3563 	camss = devm_kzalloc(dev, sizeof(*camss), GFP_KERNEL);
3564 	if (!camss)
3565 		return -ENOMEM;
3566 
3567 	camss->res = of_device_get_match_data(dev);
3568 
3569 	atomic_set(&camss->ref_count, 0);
3570 	camss->dev = dev;
3571 	platform_set_drvdata(pdev, camss);
3572 
3573 	camss->csiphy = devm_kcalloc(dev, camss->res->csiphy_num,
3574 				     sizeof(*camss->csiphy), GFP_KERNEL);
3575 	if (!camss->csiphy)
3576 		return -ENOMEM;
3577 
3578 	camss->csid = devm_kcalloc(dev, camss->res->csid_num, sizeof(*camss->csid),
3579 				   GFP_KERNEL);
3580 	if (!camss->csid)
3581 		return -ENOMEM;
3582 
3583 	if (camss->res->version == CAMSS_8x16 ||
3584 	    camss->res->version == CAMSS_8x53 ||
3585 	    camss->res->version == CAMSS_8x96) {
3586 		camss->ispif = devm_kcalloc(dev, 1, sizeof(*camss->ispif), GFP_KERNEL);
3587 		if (!camss->ispif)
3588 			return -ENOMEM;
3589 	}
3590 
3591 	camss->vfe = devm_kcalloc(dev, camss->res->vfe_num,
3592 				  sizeof(*camss->vfe), GFP_KERNEL);
3593 	if (!camss->vfe)
3594 		return -ENOMEM;
3595 
3596 	ret = camss_icc_get(camss);
3597 	if (ret < 0)
3598 		return ret;
3599 
3600 	ret = camss_configure_pd(camss);
3601 	if (ret < 0) {
3602 		dev_err(dev, "Failed to configure power domains: %d\n", ret);
3603 		return ret;
3604 	}
3605 
3606 	ret = camss_init_subdevices(camss);
3607 	if (ret < 0)
3608 		goto err_genpd_cleanup;
3609 
3610 	ret = dma_set_mask_and_coherent(dev, 0xffffffff);
3611 	if (ret)
3612 		goto err_genpd_cleanup;
3613 
3614 	camss->media_dev.dev = camss->dev;
3615 	strscpy(camss->media_dev.model, "Qualcomm Camera Subsystem",
3616 		sizeof(camss->media_dev.model));
3617 	camss->media_dev.ops = &camss_media_ops;
3618 	media_device_init(&camss->media_dev);
3619 
3620 	camss->v4l2_dev.mdev = &camss->media_dev;
3621 	ret = v4l2_device_register(camss->dev, &camss->v4l2_dev);
3622 	if (ret < 0) {
3623 		dev_err(dev, "Failed to register V4L2 device: %d\n", ret);
3624 		goto err_media_device_cleanup;
3625 	}
3626 
3627 	v4l2_async_nf_init(&camss->notifier, &camss->v4l2_dev);
3628 
3629 	pm_runtime_enable(dev);
3630 
3631 	num_subdevs = camss_of_parse_ports(camss);
3632 	if (num_subdevs < 0) {
3633 		ret = num_subdevs;
3634 		goto err_v4l2_device_unregister;
3635 	}
3636 
3637 	ret = camss_register_entities(camss);
3638 	if (ret < 0)
3639 		goto err_v4l2_device_unregister;
3640 
3641 	ret = camss->res->link_entities(camss);
3642 	if (ret < 0)
3643 		goto err_register_subdevs;
3644 
3645 	ret = media_device_register(&camss->media_dev);
3646 	if (ret < 0) {
3647 		dev_err(dev, "Failed to register media device: %d\n", ret);
3648 		goto err_register_subdevs;
3649 	}
3650 
3651 	if (num_subdevs) {
3652 		camss->notifier.ops = &camss_subdev_notifier_ops;
3653 
3654 		ret = v4l2_async_nf_register(&camss->notifier);
3655 		if (ret) {
3656 			dev_err(dev,
3657 				"Failed to register async subdev nodes: %d\n",
3658 				ret);
3659 			goto err_media_device_unregister;
3660 		}
3661 	} else {
3662 		ret = v4l2_device_register_subdev_nodes(&camss->v4l2_dev);
3663 		if (ret < 0) {
3664 			dev_err(dev, "Failed to register subdev nodes: %d\n",
3665 				ret);
3666 			goto err_media_device_unregister;
3667 		}
3668 	}
3669 
3670 	return 0;
3671 
3672 err_media_device_unregister:
3673 	media_device_unregister(&camss->media_dev);
3674 err_register_subdevs:
3675 	camss_unregister_entities(camss);
3676 err_v4l2_device_unregister:
3677 	v4l2_device_unregister(&camss->v4l2_dev);
3678 	v4l2_async_nf_cleanup(&camss->notifier);
3679 	pm_runtime_disable(dev);
3680 err_media_device_cleanup:
3681 	media_device_cleanup(&camss->media_dev);
3682 err_genpd_cleanup:
3683 	camss_genpd_cleanup(camss);
3684 
3685 	return ret;
3686 }
3687 
camss_delete(struct camss * camss)3688 void camss_delete(struct camss *camss)
3689 {
3690 	v4l2_device_unregister(&camss->v4l2_dev);
3691 	media_device_unregister(&camss->media_dev);
3692 	media_device_cleanup(&camss->media_dev);
3693 
3694 	pm_runtime_disable(camss->dev);
3695 }
3696 
3697 /*
3698  * camss_remove - Remove CAMSS platform device
3699  * @pdev: Pointer to CAMSS platform device
3700  *
3701  * Always returns 0.
3702  */
camss_remove(struct platform_device * pdev)3703 static void camss_remove(struct platform_device *pdev)
3704 {
3705 	struct camss *camss = platform_get_drvdata(pdev);
3706 
3707 	v4l2_async_nf_unregister(&camss->notifier);
3708 	v4l2_async_nf_cleanup(&camss->notifier);
3709 	camss_unregister_entities(camss);
3710 
3711 	if (atomic_read(&camss->ref_count) == 0)
3712 		camss_delete(camss);
3713 
3714 	camss_genpd_cleanup(camss);
3715 }
3716 
3717 static const struct camss_resources msm8916_resources = {
3718 	.version = CAMSS_8x16,
3719 	.csiphy_res = csiphy_res_8x16,
3720 	.csid_res = csid_res_8x16,
3721 	.ispif_res = &ispif_res_8x16,
3722 	.vfe_res = vfe_res_8x16,
3723 	.csiphy_num = ARRAY_SIZE(csiphy_res_8x16),
3724 	.csid_num = ARRAY_SIZE(csid_res_8x16),
3725 	.vfe_num = ARRAY_SIZE(vfe_res_8x16),
3726 	.link_entities = camss_link_entities
3727 };
3728 
3729 static const struct camss_resources msm8953_resources = {
3730 	.version = CAMSS_8x53,
3731 	.icc_res = icc_res_8x53,
3732 	.icc_path_num = ARRAY_SIZE(icc_res_8x53),
3733 	.csiphy_res = csiphy_res_8x96,
3734 	.csid_res = csid_res_8x53,
3735 	.ispif_res = &ispif_res_8x53,
3736 	.vfe_res = vfe_res_8x53,
3737 	.csiphy_num = ARRAY_SIZE(csiphy_res_8x96),
3738 	.csid_num = ARRAY_SIZE(csid_res_8x53),
3739 	.vfe_num = ARRAY_SIZE(vfe_res_8x53),
3740 	.link_entities = camss_link_entities
3741 };
3742 
3743 static const struct camss_resources msm8996_resources = {
3744 	.version = CAMSS_8x96,
3745 	.csiphy_res = csiphy_res_8x96,
3746 	.csid_res = csid_res_8x96,
3747 	.ispif_res = &ispif_res_8x96,
3748 	.vfe_res = vfe_res_8x96,
3749 	.csiphy_num = ARRAY_SIZE(csiphy_res_8x96),
3750 	.csid_num = ARRAY_SIZE(csid_res_8x96),
3751 	.vfe_num = ARRAY_SIZE(vfe_res_8x96),
3752 	.link_entities = camss_link_entities
3753 };
3754 
3755 static const struct camss_resources sdm660_resources = {
3756 	.version = CAMSS_660,
3757 	.csiphy_res = csiphy_res_660,
3758 	.csid_res = csid_res_660,
3759 	.ispif_res = &ispif_res_660,
3760 	.vfe_res = vfe_res_660,
3761 	.csiphy_num = ARRAY_SIZE(csiphy_res_660),
3762 	.csid_num = ARRAY_SIZE(csid_res_660),
3763 	.vfe_num = ARRAY_SIZE(vfe_res_660),
3764 	.link_entities = camss_link_entities
3765 };
3766 
3767 static const struct camss_resources sdm670_resources = {
3768 	.version = CAMSS_845,
3769 	.csiphy_res = csiphy_res_670,
3770 	.csid_res = csid_res_670,
3771 	.vfe_res = vfe_res_670,
3772 	.csiphy_num = ARRAY_SIZE(csiphy_res_670),
3773 	.csid_num = ARRAY_SIZE(csid_res_670),
3774 	.vfe_num = ARRAY_SIZE(vfe_res_670),
3775 	.link_entities = camss_link_entities
3776 };
3777 
3778 static const struct camss_resources sdm845_resources = {
3779 	.version = CAMSS_845,
3780 	.pd_name = "top",
3781 	.csiphy_res = csiphy_res_845,
3782 	.csid_res = csid_res_845,
3783 	.vfe_res = vfe_res_845,
3784 	.csiphy_num = ARRAY_SIZE(csiphy_res_845),
3785 	.csid_num = ARRAY_SIZE(csid_res_845),
3786 	.vfe_num = ARRAY_SIZE(vfe_res_845),
3787 	.link_entities = camss_link_entities
3788 };
3789 
3790 static const struct camss_resources sm8250_resources = {
3791 	.version = CAMSS_8250,
3792 	.pd_name = "top",
3793 	.csiphy_res = csiphy_res_8250,
3794 	.csid_res = csid_res_8250,
3795 	.vfe_res = vfe_res_8250,
3796 	.icc_res = icc_res_sm8250,
3797 	.icc_path_num = ARRAY_SIZE(icc_res_sm8250),
3798 	.csiphy_num = ARRAY_SIZE(csiphy_res_8250),
3799 	.csid_num = ARRAY_SIZE(csid_res_8250),
3800 	.vfe_num = ARRAY_SIZE(vfe_res_8250),
3801 	.link_entities = camss_link_entities
3802 };
3803 
3804 static const struct camss_resources sc8280xp_resources = {
3805 	.version = CAMSS_8280XP,
3806 	.pd_name = "top",
3807 	.csiphy_res = csiphy_res_sc8280xp,
3808 	.csid_res = csid_res_sc8280xp,
3809 	.ispif_res = NULL,
3810 	.vfe_res = vfe_res_sc8280xp,
3811 	.icc_res = icc_res_sc8280xp,
3812 	.icc_path_num = ARRAY_SIZE(icc_res_sc8280xp),
3813 	.csiphy_num = ARRAY_SIZE(csiphy_res_sc8280xp),
3814 	.csid_num = ARRAY_SIZE(csid_res_sc8280xp),
3815 	.vfe_num = ARRAY_SIZE(vfe_res_sc8280xp),
3816 	.link_entities = camss_link_entities
3817 };
3818 
3819 static const struct camss_resources sc7280_resources = {
3820 	.version = CAMSS_7280,
3821 	.pd_name = "top",
3822 	.csiphy_res = csiphy_res_7280,
3823 	.csid_res = csid_res_7280,
3824 	.vfe_res = vfe_res_7280,
3825 	.icc_res = icc_res_sc7280,
3826 	.icc_path_num = ARRAY_SIZE(icc_res_sc7280),
3827 	.csiphy_num = ARRAY_SIZE(csiphy_res_7280),
3828 	.csid_num = ARRAY_SIZE(csid_res_7280),
3829 	.vfe_num = ARRAY_SIZE(vfe_res_7280),
3830 	.link_entities = camss_link_entities
3831 };
3832 
3833 static const struct camss_resources sm8550_resources = {
3834 	.version = CAMSS_8550,
3835 	.pd_name = "top",
3836 	.csiphy_res = csiphy_res_8550,
3837 	.csid_res = csid_res_8550,
3838 	.vfe_res = vfe_res_8550,
3839 	.csid_wrapper_res = &csid_wrapper_res_sm8550,
3840 	.icc_res = icc_res_sm8550,
3841 	.icc_path_num = ARRAY_SIZE(icc_res_sm8550),
3842 	.csiphy_num = ARRAY_SIZE(csiphy_res_8550),
3843 	.csid_num = ARRAY_SIZE(csid_res_8550),
3844 	.vfe_num = ARRAY_SIZE(vfe_res_8550),
3845 	.link_entities = camss_link_entities
3846 };
3847 
3848 static const struct camss_resources x1e80100_resources = {
3849 	.version = CAMSS_X1E80100,
3850 	.pd_name = "top",
3851 	.csiphy_res = csiphy_res_x1e80100,
3852 	.csid_res = csid_res_x1e80100,
3853 	.vfe_res = vfe_res_x1e80100,
3854 	.csid_wrapper_res = &csid_wrapper_res_x1e80100,
3855 	.icc_res = icc_res_x1e80100,
3856 	.icc_path_num = ARRAY_SIZE(icc_res_x1e80100),
3857 	.csiphy_num = ARRAY_SIZE(csiphy_res_x1e80100),
3858 	.csid_num = ARRAY_SIZE(csid_res_x1e80100),
3859 	.vfe_num = ARRAY_SIZE(vfe_res_x1e80100),
3860 	.link_entities = camss_link_entities
3861 };
3862 
3863 static const struct of_device_id camss_dt_match[] = {
3864 	{ .compatible = "qcom,msm8916-camss", .data = &msm8916_resources },
3865 	{ .compatible = "qcom,msm8953-camss", .data = &msm8953_resources },
3866 	{ .compatible = "qcom,msm8996-camss", .data = &msm8996_resources },
3867 	{ .compatible = "qcom,sc7280-camss", .data = &sc7280_resources },
3868 	{ .compatible = "qcom,sc8280xp-camss", .data = &sc8280xp_resources },
3869 	{ .compatible = "qcom,sdm660-camss", .data = &sdm660_resources },
3870 	{ .compatible = "qcom,sdm670-camss", .data = &sdm670_resources },
3871 	{ .compatible = "qcom,sdm845-camss", .data = &sdm845_resources },
3872 	{ .compatible = "qcom,sm8250-camss", .data = &sm8250_resources },
3873 	{ .compatible = "qcom,sm8550-camss", .data = &sm8550_resources },
3874 	{ .compatible = "qcom,x1e80100-camss", .data = &x1e80100_resources },
3875 	{ }
3876 };
3877 
3878 MODULE_DEVICE_TABLE(of, camss_dt_match);
3879 
camss_runtime_suspend(struct device * dev)3880 static int __maybe_unused camss_runtime_suspend(struct device *dev)
3881 {
3882 	struct camss *camss = dev_get_drvdata(dev);
3883 	int i;
3884 	int ret;
3885 
3886 	for (i = 0; i < camss->res->icc_path_num; i++) {
3887 		ret = icc_set_bw(camss->icc_path[i], 0, 0);
3888 		if (ret)
3889 			return ret;
3890 	}
3891 
3892 	return 0;
3893 }
3894 
camss_runtime_resume(struct device * dev)3895 static int __maybe_unused camss_runtime_resume(struct device *dev)
3896 {
3897 	struct camss *camss = dev_get_drvdata(dev);
3898 	const struct resources_icc *icc_res = camss->res->icc_res;
3899 	int i;
3900 	int ret;
3901 
3902 	for (i = 0; i < camss->res->icc_path_num; i++) {
3903 		ret = icc_set_bw(camss->icc_path[i],
3904 				 icc_res[i].icc_bw_tbl.avg,
3905 				 icc_res[i].icc_bw_tbl.peak);
3906 		if (ret)
3907 			return ret;
3908 	}
3909 
3910 	return 0;
3911 }
3912 
3913 static const struct dev_pm_ops camss_pm_ops = {
3914 	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
3915 				pm_runtime_force_resume)
3916 	SET_RUNTIME_PM_OPS(camss_runtime_suspend, camss_runtime_resume, NULL)
3917 };
3918 
3919 static struct platform_driver qcom_camss_driver = {
3920 	.probe = camss_probe,
3921 	.remove = camss_remove,
3922 	.driver = {
3923 		.name = "qcom-camss",
3924 		.of_match_table = camss_dt_match,
3925 		.pm = &camss_pm_ops,
3926 	},
3927 };
3928 
3929 module_platform_driver(qcom_camss_driver);
3930 
3931 MODULE_ALIAS("platform:qcom-camss");
3932 MODULE_DESCRIPTION("Qualcomm Camera Subsystem driver");
3933 MODULE_AUTHOR("Todor Tomov <todor.tomov@linaro.org>");
3934 MODULE_LICENSE("GPL v2");
3935