xref: /linux/drivers/media/platform/qcom/camss/camss.c (revision 55a42f78ffd386e01a5404419f8c5ded7db70a21)
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_2290[] = {
519 	/* CSIPHY0 */
520 	{
521 		.regulators = { "vdd-csiphy-1p2", "vdd-csiphy-1p8" },
522 		.clock = { "top_ahb", "ahb", "csiphy0", "csiphy0_timer" },
523 		.clock_rate = { { 0 },
524 				{ 0 },
525 				{ 240000000, 341330000, 384000000 },
526 				{ 100000000, 200000000, 268800000 }  },
527 		.reg = { "csiphy0" },
528 		.interrupt = { "csiphy0" },
529 		.csiphy = {
530 			.id = 0,
531 			.hw_ops = &csiphy_ops_3ph_1_0,
532 			.formats = &csiphy_formats_sdm845
533 		}
534 	},
535 
536 	/* CSIPHY1 */
537 	{
538 		.regulators = { "vdd-csiphy-1p2", "vdd-csiphy-1p8" },
539 		.clock = { "top_ahb", "ahb", "csiphy1", "csiphy1_timer" },
540 		.clock_rate = { { 0 },
541 				{ 0 },
542 				{ 240000000, 341330000, 384000000 },
543 				{ 100000000, 200000000, 268800000 }  },
544 		.reg = { "csiphy1" },
545 		.interrupt = { "csiphy1" },
546 		.csiphy = {
547 			.id = 1,
548 			.hw_ops = &csiphy_ops_3ph_1_0,
549 			.formats = &csiphy_formats_sdm845
550 		}
551 	}
552 };
553 
554 static const struct camss_subdev_resources csid_res_2290[] = {
555 	/* CSID0 */
556 	{
557 		.regulators = {},
558 		.clock = { "top_ahb", "ahb", "csi0", "vfe0_cphy_rx", "vfe0" },
559 		.clock_rate = { { 0 },
560 				{ 0 },
561 				{ 192000000, 240000000, 384000000, 426400000 },
562 				{ 0 },
563 				{ 0 } },
564 		.reg = { "csid0" },
565 		.interrupt = { "csid0" },
566 		.csid = {
567 			.hw_ops = &csid_ops_340,
568 			.parent_dev_ops = &vfe_parent_dev_ops,
569 			.formats = &csid_formats_gen2
570 		}
571 	},
572 
573 	/* CSID1 */
574 	{
575 		.regulators = {},
576 		.clock = { "top_ahb", "ahb", "csi1", "vfe1_cphy_rx", "vfe1" },
577 		.clock_rate = { { 0 },
578 				{ 0 },
579 				{ 192000000, 240000000, 384000000, 426400000 },
580 				{ 0 },
581 				{ 0 } },
582 		.reg = { "csid1" },
583 		.interrupt = { "csid1" },
584 		.csid = {
585 			.hw_ops = &csid_ops_340,
586 			.parent_dev_ops = &vfe_parent_dev_ops,
587 			.formats = &csid_formats_gen2
588 		}
589 	}
590 };
591 
592 static const struct camss_subdev_resources vfe_res_2290[] = {
593 	/* VFE0 */
594 	{
595 		.regulators = {},
596 		.clock = { "top_ahb", "ahb", "axi", "vfe0", "camnoc_rt_axi", "camnoc_nrt_axi" },
597 		.clock_rate = { { 0 },
598 				{ 0 },
599 				{ 0 },
600 				{ 19200000, 153600000, 192000000, 256000000, 384000000, 460800000 },
601 				{ 0 },
602 				{ 0 }, },
603 		.reg = { "vfe0" },
604 		.interrupt = { "vfe0" },
605 		.vfe = {
606 			.line_num = 4,
607 			.hw_ops = &vfe_ops_340,
608 			.formats_rdi = &vfe_formats_rdi_845,
609 			.formats_pix = &vfe_formats_pix_845
610 		}
611 	},
612 
613 	/* VFE1 */
614 	{
615 		.regulators = {},
616 		.clock = { "top_ahb", "ahb", "axi", "vfe1", "camnoc_rt_axi", "camnoc_nrt_axi" },
617 		.clock_rate = { { 0 },
618 				{ 0 },
619 				{ 0 },
620 				{ 19200000, 153600000, 192000000, 256000000, 384000000, 460800000 },
621 				{ 0 },
622 				{ 0 }, },
623 		.reg = { "vfe1" },
624 		.interrupt = { "vfe1" },
625 		.vfe = {
626 			.line_num = 4,
627 			.hw_ops = &vfe_ops_340,
628 			.formats_rdi = &vfe_formats_rdi_845,
629 			.formats_pix = &vfe_formats_pix_845
630 		}
631 	},
632 };
633 
634 static const struct resources_icc icc_res_2290[] = {
635 	{
636 		.name = "ahb",
637 		.icc_bw_tbl.avg = 150000,
638 		.icc_bw_tbl.peak = 300000,
639 	},
640 	{
641 		.name = "hf_mnoc",
642 		.icc_bw_tbl.avg = 2097152,
643 		.icc_bw_tbl.peak = 3000000,
644 	},
645 	{
646 		.name = "sf_mnoc",
647 		.icc_bw_tbl.avg = 2097152,
648 		.icc_bw_tbl.peak = 3000000,
649 	},
650 };
651 
652 static const struct camss_subdev_resources csiphy_res_660[] = {
653 	/* CSIPHY0 */
654 	{
655 		.regulators = {},
656 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy0_timer",
657 			   "csi0_phy", "csiphy_ahb2crif" },
658 		.clock_rate = { { 0 },
659 				{ 0 },
660 				{ 0 },
661 				{ 100000000, 200000000, 269333333 },
662 				{ 0 } },
663 		.reg = { "csiphy0", "csiphy0_clk_mux" },
664 		.interrupt = { "csiphy0" },
665 		.csiphy = {
666 			.id = 0,
667 			.hw_ops = &csiphy_ops_3ph_1_0,
668 			.formats = &csiphy_formats_8x96
669 		}
670 	},
671 
672 	/* CSIPHY1 */
673 	{
674 		.regulators = {},
675 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy1_timer",
676 			   "csi1_phy", "csiphy_ahb2crif" },
677 		.clock_rate = { { 0 },
678 				{ 0 },
679 				{ 0 },
680 				{ 100000000, 200000000, 269333333 },
681 				{ 0 } },
682 		.reg = { "csiphy1", "csiphy1_clk_mux" },
683 		.interrupt = { "csiphy1" },
684 		.csiphy = {
685 			.id = 1,
686 			.hw_ops = &csiphy_ops_3ph_1_0,
687 			.formats = &csiphy_formats_8x96
688 		}
689 	},
690 
691 	/* CSIPHY2 */
692 	{
693 		.regulators = {},
694 		.clock = { "top_ahb", "ispif_ahb", "ahb", "csiphy2_timer",
695 			   "csi2_phy", "csiphy_ahb2crif" },
696 		.clock_rate = { { 0 },
697 				{ 0 },
698 				{ 0 },
699 				{ 100000000, 200000000, 269333333 },
700 				{ 0 } },
701 		.reg = { "csiphy2", "csiphy2_clk_mux" },
702 		.interrupt = { "csiphy2" },
703 		.csiphy = {
704 			.id = 2,
705 			.hw_ops = &csiphy_ops_3ph_1_0,
706 			.formats = &csiphy_formats_8x96
707 		}
708 	}
709 };
710 
711 static const struct camss_subdev_resources csid_res_660[] = {
712 	/* CSID0 */
713 	{
714 		.regulators = { "vdda", "vdd_sec" },
715 		.clock = { "top_ahb", "ispif_ahb", "csi0_ahb", "ahb",
716 			   "csi0", "csi0_phy", "csi0_pix", "csi0_rdi",
717 			   "cphy_csid0" },
718 		.clock_rate = { { 0 },
719 				{ 0 },
720 				{ 0 },
721 				{ 0 },
722 				{ 100000000, 200000000, 310000000,
723 				  404000000, 465000000 },
724 				{ 0 },
725 				{ 0 },
726 				{ 0 },
727 				{ 0 } },
728 		.reg = { "csid0" },
729 		.interrupt = { "csid0" },
730 		.csid = {
731 			.hw_ops = &csid_ops_4_7,
732 			.parent_dev_ops = &vfe_parent_dev_ops,
733 			.formats = &csid_formats_4_7
734 		}
735 	},
736 
737 	/* CSID1 */
738 	{
739 		.regulators = { "vdda", "vdd_sec" },
740 		.clock = { "top_ahb", "ispif_ahb", "csi1_ahb", "ahb",
741 			   "csi1", "csi1_phy", "csi1_pix", "csi1_rdi",
742 			   "cphy_csid1" },
743 		.clock_rate = { { 0 },
744 				{ 0 },
745 				{ 0 },
746 				{ 0 },
747 				{ 100000000, 200000000, 310000000,
748 				  404000000, 465000000 },
749 				{ 0 },
750 				{ 0 },
751 				{ 0 },
752 				{ 0 } },
753 		.reg = { "csid1" },
754 		.interrupt = { "csid1" },
755 		.csid = {
756 			.hw_ops = &csid_ops_4_7,
757 			.parent_dev_ops = &vfe_parent_dev_ops,
758 			.formats = &csid_formats_4_7
759 		}
760 	},
761 
762 	/* CSID2 */
763 	{
764 		.regulators = { "vdda", "vdd_sec" },
765 		.clock = { "top_ahb", "ispif_ahb", "csi2_ahb", "ahb",
766 			   "csi2", "csi2_phy", "csi2_pix", "csi2_rdi",
767 			   "cphy_csid2" },
768 		.clock_rate = { { 0 },
769 				{ 0 },
770 				{ 0 },
771 				{ 0 },
772 				{ 100000000, 200000000, 310000000,
773 				  404000000, 465000000 },
774 				{ 0 },
775 				{ 0 },
776 				{ 0 },
777 				{ 0 } },
778 		.reg = { "csid2" },
779 		.interrupt = { "csid2" },
780 		.csid = {
781 			.hw_ops = &csid_ops_4_7,
782 			.parent_dev_ops = &vfe_parent_dev_ops,
783 			.formats = &csid_formats_4_7
784 		}
785 	},
786 
787 	/* CSID3 */
788 	{
789 		.regulators = { "vdda", "vdd_sec" },
790 		.clock = { "top_ahb", "ispif_ahb", "csi3_ahb", "ahb",
791 			   "csi3", "csi3_phy", "csi3_pix", "csi3_rdi",
792 			   "cphy_csid3" },
793 		.clock_rate = { { 0 },
794 				{ 0 },
795 				{ 0 },
796 				{ 0 },
797 				{ 100000000, 200000000, 310000000,
798 				  404000000, 465000000 },
799 				{ 0 },
800 				{ 0 },
801 				{ 0 },
802 				{ 0 } },
803 		.reg = { "csid3" },
804 		.interrupt = { "csid3" },
805 		.csid = {
806 			.hw_ops = &csid_ops_4_7,
807 			.parent_dev_ops = &vfe_parent_dev_ops,
808 			.formats = &csid_formats_4_7
809 		}
810 	}
811 };
812 
813 static const struct camss_subdev_resources ispif_res_660 = {
814 	/* ISPIF */
815 	.clock = { "top_ahb", "ahb", "ispif_ahb",
816 		   "csi0", "csi0_pix", "csi0_rdi",
817 		   "csi1", "csi1_pix", "csi1_rdi",
818 		   "csi2", "csi2_pix", "csi2_rdi",
819 		   "csi3", "csi3_pix", "csi3_rdi" },
820 	.clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" },
821 	.reg = { "ispif", "csi_clk_mux" },
822 	.interrupt = { "ispif" },
823 };
824 
825 static const struct camss_subdev_resources vfe_res_660[] = {
826 	/* VFE0 */
827 	{
828 		.regulators = {},
829 		.clock = { "throttle_axi", "top_ahb", "ahb", "vfe0",
830 			   "csi_vfe0", "vfe_ahb", "vfe0_ahb", "vfe_axi",
831 			   "vfe0_stream"},
832 		.clock_rate = { { 0 },
833 				{ 0 },
834 				{ 0 },
835 				{ 120000000, 200000000, 256000000,
836 				  300000000, 404000000, 480000000,
837 				  540000000, 576000000 },
838 				{ 0 },
839 				{ 0 },
840 				{ 0 },
841 				{ 0 },
842 				{ 0 } },
843 		.reg = { "vfe0" },
844 		.interrupt = { "vfe0" },
845 		.vfe = {
846 			.line_num = 3,
847 			.has_pd = true,
848 			.hw_ops = &vfe_ops_4_8,
849 			.formats_rdi = &vfe_formats_rdi_8x96,
850 			.formats_pix = &vfe_formats_pix_8x96
851 		}
852 	},
853 
854 	/* VFE1 */
855 	{
856 		.regulators = {},
857 		.clock = { "throttle_axi", "top_ahb", "ahb", "vfe1",
858 			   "csi_vfe1", "vfe_ahb", "vfe1_ahb", "vfe_axi",
859 			   "vfe1_stream"},
860 		.clock_rate = { { 0 },
861 				{ 0 },
862 				{ 0 },
863 				{ 120000000, 200000000, 256000000,
864 				  300000000, 404000000, 480000000,
865 				  540000000, 576000000 },
866 				{ 0 },
867 				{ 0 },
868 				{ 0 },
869 				{ 0 },
870 				{ 0 } },
871 		.reg = { "vfe1" },
872 		.interrupt = { "vfe1" },
873 		.vfe = {
874 			.line_num = 3,
875 			.has_pd = true,
876 			.hw_ops = &vfe_ops_4_8,
877 			.formats_rdi = &vfe_formats_rdi_8x96,
878 			.formats_pix = &vfe_formats_pix_8x96
879 		}
880 	}
881 };
882 
883 static const struct camss_subdev_resources csiphy_res_670[] = {
884 	/* CSIPHY0 */
885 	{
886 		.regulators = { "vdda-phy", "vdda-pll" },
887 		.clock = { "soc_ahb", "cpas_ahb",
888 			   "csiphy0", "csiphy0_timer" },
889 		.clock_rate = { { 0 },
890 				{ 0 },
891 				{ 0 },
892 				{ 19200000, 240000000, 269333333 } },
893 		.reg = { "csiphy0" },
894 		.interrupt = { "csiphy0" },
895 		.csiphy = {
896 			.id = 0,
897 			.hw_ops = &csiphy_ops_3ph_1_0,
898 			.formats = &csiphy_formats_sdm845
899 		}
900 	},
901 
902 	/* CSIPHY1 */
903 	{
904 		.regulators = { "vdda-phy", "vdda-pll" },
905 		.clock = { "soc_ahb", "cpas_ahb",
906 			   "csiphy1", "csiphy1_timer" },
907 		.clock_rate = { { 0 },
908 				{ 0 },
909 				{ 0 },
910 				{ 19200000, 240000000, 269333333 } },
911 		.reg = { "csiphy1" },
912 		.interrupt = { "csiphy1" },
913 		.csiphy = {
914 			.id = 1,
915 			.hw_ops = &csiphy_ops_3ph_1_0,
916 			.formats = &csiphy_formats_sdm845
917 		}
918 	},
919 
920 	/* CSIPHY2 */
921 	{
922 		.regulators = { "vdda-phy", "vdda-pll" },
923 		.clock = { "soc_ahb", "cpas_ahb",
924 			   "csiphy2", "csiphy2_timer" },
925 		.clock_rate = { { 0 },
926 				{ 0 },
927 				{ 0 },
928 				{ 19200000, 240000000, 269333333 } },
929 		.reg = { "csiphy2" },
930 		.interrupt = { "csiphy2" },
931 		.csiphy = {
932 			.id = 2,
933 			.hw_ops = &csiphy_ops_3ph_1_0,
934 			.formats = &csiphy_formats_sdm845
935 		}
936 	}
937 };
938 
939 static const struct camss_subdev_resources csid_res_670[] = {
940 	/* CSID0 */
941 	{
942 		.regulators = {},
943 		.clock = { "cpas_ahb", "soc_ahb", "vfe0",
944 			   "vfe0_cphy_rx", "csi0" },
945 		.clock_rate = { { 0 },
946 				{ 0 },
947 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
948 				{ 384000000 },
949 				{ 19200000, 75000000, 384000000, 538666667 } },
950 		.reg = { "csid0" },
951 		.interrupt = { "csid0" },
952 		.csid = {
953 			.hw_ops = &csid_ops_gen2,
954 			.parent_dev_ops = &vfe_parent_dev_ops,
955 			.formats = &csid_formats_gen2
956 		}
957 	},
958 
959 	/* CSID1 */
960 	{
961 		.regulators = {},
962 		.clock = { "cpas_ahb", "soc_ahb", "vfe1",
963 			   "vfe1_cphy_rx", "csi1" },
964 		.clock_rate = { { 0 },
965 				{ 0 },
966 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
967 				{ 384000000 },
968 				{ 19200000, 75000000, 384000000, 538666667 } },
969 		.reg = { "csid1" },
970 		.interrupt = { "csid1" },
971 		.csid = {
972 			.hw_ops = &csid_ops_gen2,
973 			.parent_dev_ops = &vfe_parent_dev_ops,
974 			.formats = &csid_formats_gen2
975 		}
976 	},
977 
978 	/* CSID2 */
979 	{
980 		.regulators = {},
981 		.clock = { "cpas_ahb", "soc_ahb", "vfe_lite",
982 			   "vfe_lite_cphy_rx", "csi2" },
983 		.clock_rate = { { 0 },
984 				{ 0 },
985 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
986 				{ 384000000 },
987 				{ 19200000, 75000000, 384000000, 538666667 } },
988 		.reg = { "csid2" },
989 		.interrupt = { "csid2" },
990 		.csid = {
991 			.is_lite = true,
992 			.hw_ops = &csid_ops_gen2,
993 			.parent_dev_ops = &vfe_parent_dev_ops,
994 			.formats = &csid_formats_gen2
995 		}
996 	}
997 };
998 
999 static const struct camss_subdev_resources vfe_res_670[] = {
1000 	/* VFE0 */
1001 	{
1002 		.regulators = {},
1003 		.clock = { "camnoc_axi", "cpas_ahb", "soc_ahb",
1004 			   "vfe0", "vfe0_axi" },
1005 		.clock_rate = { { 0 },
1006 				{ 0 },
1007 				{ 0 },
1008 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
1009 				{ 0 } },
1010 		.reg = { "vfe0" },
1011 		.interrupt = { "vfe0" },
1012 		.vfe = {
1013 			.line_num = 4,
1014 			.has_pd = true,
1015 			.pd_name = "ife0",
1016 			.hw_ops = &vfe_ops_170,
1017 			.formats_rdi = &vfe_formats_rdi_845,
1018 			.formats_pix = &vfe_formats_pix_845
1019 		}
1020 	},
1021 
1022 	/* VFE1 */
1023 	{
1024 		.regulators = {},
1025 		.clock = { "camnoc_axi", "cpas_ahb", "soc_ahb",
1026 			   "vfe1", "vfe1_axi" },
1027 		.clock_rate = { { 0 },
1028 				{ 0 },
1029 				{ 0 },
1030 				{ 100000000, 320000000, 404000000, 480000000, 600000000 },
1031 				{ 0 } },
1032 		.reg = { "vfe1" },
1033 		.interrupt = { "vfe1" },
1034 		.vfe = {
1035 			.line_num = 4,
1036 			.has_pd = true,
1037 			.pd_name = "ife1",
1038 			.hw_ops = &vfe_ops_170,
1039 			.formats_rdi = &vfe_formats_rdi_845,
1040 			.formats_pix = &vfe_formats_pix_845
1041 		}
1042 	},
1043 
1044 	/* VFE-lite */
1045 	{
1046 		.regulators = {},
1047 		.clock = { "camnoc_axi", "cpas_ahb", "soc_ahb",
1048 			   "vfe_lite" },
1049 		.clock_rate = { { 0 },
1050 				{ 0 },
1051 				{ 0 },
1052 				{ 100000000, 320000000, 404000000, 480000000, 600000000 } },
1053 		.reg = { "vfe_lite" },
1054 		.interrupt = { "vfe_lite" },
1055 		.vfe = {
1056 			.is_lite = true,
1057 			.line_num = 4,
1058 			.hw_ops = &vfe_ops_170,
1059 			.formats_rdi = &vfe_formats_rdi_845,
1060 			.formats_pix = &vfe_formats_pix_845
1061 		}
1062 	}
1063 };
1064 
1065 static const struct camss_subdev_resources csiphy_res_845[] = {
1066 	/* CSIPHY0 */
1067 	{
1068 		.regulators = {},
1069 		.clock = { "camnoc_axi", "soc_ahb", "slow_ahb_src",
1070 				"cpas_ahb", "cphy_rx_src", "csiphy0",
1071 				"csiphy0_timer_src", "csiphy0_timer" },
1072 		.clock_rate = { { 0 },
1073 				{ 0 },
1074 				{ 0 },
1075 				{ 0 },
1076 				{ 0 },
1077 				{ 0 },
1078 				{ 0 },
1079 				{ 19200000, 240000000, 269333333 } },
1080 		.reg = { "csiphy0" },
1081 		.interrupt = { "csiphy0" },
1082 		.csiphy = {
1083 			.id = 0,
1084 			.hw_ops = &csiphy_ops_3ph_1_0,
1085 			.formats = &csiphy_formats_sdm845
1086 		}
1087 	},
1088 
1089 	/* CSIPHY1 */
1090 	{
1091 		.regulators = {},
1092 		.clock = { "camnoc_axi", "soc_ahb", "slow_ahb_src",
1093 				"cpas_ahb", "cphy_rx_src", "csiphy1",
1094 				"csiphy1_timer_src", "csiphy1_timer" },
1095 		.clock_rate = { { 0 },
1096 				{ 0 },
1097 				{ 0 },
1098 				{ 0 },
1099 				{ 0 },
1100 				{ 0 },
1101 				{ 0 },
1102 				{ 19200000, 240000000, 269333333 } },
1103 		.reg = { "csiphy1" },
1104 		.interrupt = { "csiphy1" },
1105 		.csiphy = {
1106 			.id = 1,
1107 			.hw_ops = &csiphy_ops_3ph_1_0,
1108 			.formats = &csiphy_formats_sdm845
1109 		}
1110 	},
1111 
1112 	/* CSIPHY2 */
1113 	{
1114 		.regulators = {},
1115 		.clock = { "camnoc_axi", "soc_ahb", "slow_ahb_src",
1116 				"cpas_ahb", "cphy_rx_src", "csiphy2",
1117 				"csiphy2_timer_src", "csiphy2_timer" },
1118 		.clock_rate = { { 0 },
1119 				{ 0 },
1120 				{ 0 },
1121 				{ 0 },
1122 				{ 0 },
1123 				{ 0 },
1124 				{ 0 },
1125 				{ 19200000, 240000000, 269333333 } },
1126 		.reg = { "csiphy2" },
1127 		.interrupt = { "csiphy2" },
1128 		.csiphy = {
1129 			.id = 2,
1130 			.hw_ops = &csiphy_ops_3ph_1_0,
1131 			.formats = &csiphy_formats_sdm845
1132 		}
1133 	},
1134 
1135 	/* CSIPHY3 */
1136 	{
1137 		.regulators = {},
1138 		.clock = { "camnoc_axi", "soc_ahb", "slow_ahb_src",
1139 				"cpas_ahb", "cphy_rx_src", "csiphy3",
1140 				"csiphy3_timer_src", "csiphy3_timer" },
1141 		.clock_rate = { { 0 },
1142 				{ 0 },
1143 				{ 0 },
1144 				{ 0 },
1145 				{ 0 },
1146 				{ 0 },
1147 				{ 0 },
1148 				{ 19200000, 240000000, 269333333 } },
1149 		.reg = { "csiphy3" },
1150 		.interrupt = { "csiphy3" },
1151 		.csiphy = {
1152 			.id = 3,
1153 			.hw_ops = &csiphy_ops_3ph_1_0,
1154 			.formats = &csiphy_formats_sdm845
1155 		}
1156 	}
1157 };
1158 
1159 static const struct camss_subdev_resources csid_res_845[] = {
1160 	/* CSID0 */
1161 	{
1162 		.regulators = { "vdda-phy", "vdda-pll" },
1163 		.clock = { "cpas_ahb", "cphy_rx_src", "slow_ahb_src",
1164 				"soc_ahb", "vfe0", "vfe0_src",
1165 				"vfe0_cphy_rx", "csi0",
1166 				"csi0_src" },
1167 		.clock_rate = { { 0 },
1168 				{ 384000000 },
1169 				{ 80000000 },
1170 				{ 0 },
1171 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1172 				{ 320000000 },
1173 				{ 0 },
1174 				{ 19200000, 75000000, 384000000, 538666667 },
1175 				{ 384000000 } },
1176 		.reg = { "csid0" },
1177 		.interrupt = { "csid0" },
1178 		.csid = {
1179 			.hw_ops = &csid_ops_gen2,
1180 			.parent_dev_ops = &vfe_parent_dev_ops,
1181 			.formats = &csid_formats_gen2
1182 		}
1183 	},
1184 
1185 	/* CSID1 */
1186 	{
1187 		.regulators = { "vdda-phy", "vdda-pll" },
1188 		.clock = { "cpas_ahb", "cphy_rx_src", "slow_ahb_src",
1189 				"soc_ahb", "vfe1", "vfe1_src",
1190 				"vfe1_cphy_rx", "csi1",
1191 				"csi1_src" },
1192 		.clock_rate = { { 0 },
1193 				{ 384000000 },
1194 				{ 80000000 },
1195 				{ 0 },
1196 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1197 				{ 320000000 },
1198 				{ 0 },
1199 				{ 19200000, 75000000, 384000000, 538666667 },
1200 				{ 384000000 } },
1201 		.reg = { "csid1" },
1202 		.interrupt = { "csid1" },
1203 		.csid = {
1204 			.hw_ops = &csid_ops_gen2,
1205 			.parent_dev_ops = &vfe_parent_dev_ops,
1206 			.formats = &csid_formats_gen2
1207 		}
1208 	},
1209 
1210 	/* CSID2 */
1211 	{
1212 		.regulators = { "vdda-phy", "vdda-pll" },
1213 		.clock = { "cpas_ahb", "cphy_rx_src", "slow_ahb_src",
1214 				"soc_ahb", "vfe_lite", "vfe_lite_src",
1215 				"vfe_lite_cphy_rx", "csi2",
1216 				"csi2_src" },
1217 		.clock_rate = { { 0 },
1218 				{ 384000000 },
1219 				{ 80000000 },
1220 				{ 0 },
1221 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1222 				{ 320000000 },
1223 				{ 0 },
1224 				{ 19200000, 75000000, 384000000, 538666667 },
1225 				{ 384000000 } },
1226 		.reg = { "csid2" },
1227 		.interrupt = { "csid2" },
1228 		.csid = {
1229 			.is_lite = true,
1230 			.hw_ops = &csid_ops_gen2,
1231 			.parent_dev_ops = &vfe_parent_dev_ops,
1232 			.formats = &csid_formats_gen2
1233 		}
1234 	}
1235 };
1236 
1237 static const struct camss_subdev_resources vfe_res_845[] = {
1238 	/* VFE0 */
1239 	{
1240 		.regulators = {},
1241 		.clock = { "camnoc_axi", "cpas_ahb", "slow_ahb_src",
1242 				"soc_ahb", "vfe0", "vfe0_axi",
1243 				"vfe0_src", "csi0",
1244 				"csi0_src"},
1245 		.clock_rate = { { 0 },
1246 				{ 0 },
1247 				{ 80000000 },
1248 				{ 0 },
1249 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1250 				{ 0 },
1251 				{ 320000000 },
1252 				{ 19200000, 75000000, 384000000, 538666667 },
1253 				{ 384000000 } },
1254 		.reg = { "vfe0" },
1255 		.interrupt = { "vfe0" },
1256 		.vfe = {
1257 			.line_num = 4,
1258 			.pd_name = "ife0",
1259 			.has_pd = true,
1260 			.hw_ops = &vfe_ops_170,
1261 			.formats_rdi = &vfe_formats_rdi_845,
1262 			.formats_pix = &vfe_formats_pix_845
1263 		}
1264 	},
1265 
1266 	/* VFE1 */
1267 	{
1268 		.regulators = {},
1269 		.clock = { "camnoc_axi", "cpas_ahb", "slow_ahb_src",
1270 				"soc_ahb", "vfe1", "vfe1_axi",
1271 				"vfe1_src", "csi1",
1272 				"csi1_src"},
1273 		.clock_rate = { { 0 },
1274 				{ 0 },
1275 				{ 80000000 },
1276 				{ 0 },
1277 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1278 				{ 0 },
1279 				{ 320000000 },
1280 				{ 19200000, 75000000, 384000000, 538666667 },
1281 				{ 384000000 } },
1282 		.reg = { "vfe1" },
1283 		.interrupt = { "vfe1" },
1284 		.vfe = {
1285 			.line_num = 4,
1286 			.pd_name = "ife1",
1287 			.has_pd = true,
1288 			.hw_ops = &vfe_ops_170,
1289 			.formats_rdi = &vfe_formats_rdi_845,
1290 			.formats_pix = &vfe_formats_pix_845
1291 		}
1292 	},
1293 
1294 	/* VFE-lite */
1295 	{
1296 		.regulators = {},
1297 		.clock = { "camnoc_axi", "cpas_ahb", "slow_ahb_src",
1298 				"soc_ahb", "vfe_lite",
1299 				"vfe_lite_src", "csi2",
1300 				"csi2_src"},
1301 		.clock_rate = { { 0 },
1302 				{ 0 },
1303 				{ 80000000 },
1304 				{ 0 },
1305 				{ 19200000, 100000000, 320000000, 404000000, 480000000, 600000000 },
1306 				{ 320000000 },
1307 				{ 19200000, 75000000, 384000000, 538666667 },
1308 				{ 384000000 } },
1309 		.reg = { "vfe_lite" },
1310 		.interrupt = { "vfe_lite" },
1311 		.vfe = {
1312 			.is_lite = true,
1313 			.line_num = 4,
1314 			.hw_ops = &vfe_ops_170,
1315 			.formats_rdi = &vfe_formats_rdi_845,
1316 			.formats_pix = &vfe_formats_pix_845
1317 		}
1318 	}
1319 };
1320 
1321 static const struct camss_subdev_resources csiphy_res_8250[] = {
1322 	/* CSIPHY0 */
1323 	{
1324 		.regulators = { "vdda-phy", "vdda-pll" },
1325 		.clock = { "csiphy0", "csiphy0_timer" },
1326 		.clock_rate = { { 400000000 },
1327 				{ 300000000 } },
1328 		.reg = { "csiphy0" },
1329 		.interrupt = { "csiphy0" },
1330 		.csiphy = {
1331 			.id = 0,
1332 			.hw_ops = &csiphy_ops_3ph_1_0,
1333 			.formats = &csiphy_formats_sdm845
1334 		}
1335 	},
1336 	/* CSIPHY1 */
1337 	{
1338 		.regulators = { "vdda-phy", "vdda-pll" },
1339 		.clock = { "csiphy1", "csiphy1_timer" },
1340 		.clock_rate = { { 400000000 },
1341 				{ 300000000 } },
1342 		.reg = { "csiphy1" },
1343 		.interrupt = { "csiphy1" },
1344 		.csiphy = {
1345 			.id = 1,
1346 			.hw_ops = &csiphy_ops_3ph_1_0,
1347 			.formats = &csiphy_formats_sdm845
1348 		}
1349 	},
1350 	/* CSIPHY2 */
1351 	{
1352 		.regulators = { "vdda-phy", "vdda-pll" },
1353 		.clock = { "csiphy2", "csiphy2_timer" },
1354 		.clock_rate = { { 400000000 },
1355 				{ 300000000 } },
1356 		.reg = { "csiphy2" },
1357 		.interrupt = { "csiphy2" },
1358 		.csiphy = {
1359 			.id = 2,
1360 			.hw_ops = &csiphy_ops_3ph_1_0,
1361 			.formats = &csiphy_formats_sdm845
1362 		}
1363 	},
1364 	/* CSIPHY3 */
1365 	{
1366 		.regulators = { "vdda-phy", "vdda-pll" },
1367 		.clock = { "csiphy3", "csiphy3_timer" },
1368 		.clock_rate = { { 400000000 },
1369 				{ 300000000 } },
1370 		.reg = { "csiphy3" },
1371 		.interrupt = { "csiphy3" },
1372 		.csiphy = {
1373 			.id = 3,
1374 			.hw_ops = &csiphy_ops_3ph_1_0,
1375 			.formats = &csiphy_formats_sdm845
1376 		}
1377 	},
1378 	/* CSIPHY4 */
1379 	{
1380 		.regulators = { "vdda-phy", "vdda-pll" },
1381 		.clock = { "csiphy4", "csiphy4_timer" },
1382 		.clock_rate = { { 400000000 },
1383 				{ 300000000 } },
1384 		.reg = { "csiphy4" },
1385 		.interrupt = { "csiphy4" },
1386 		.csiphy = {
1387 			.id = 4,
1388 			.hw_ops = &csiphy_ops_3ph_1_0,
1389 			.formats = &csiphy_formats_sdm845
1390 		}
1391 	},
1392 	/* CSIPHY5 */
1393 	{
1394 		.regulators = { "vdda-phy", "vdda-pll" },
1395 		.clock = { "csiphy5", "csiphy5_timer" },
1396 		.clock_rate = { { 400000000 },
1397 				{ 300000000 } },
1398 		.reg = { "csiphy5" },
1399 		.interrupt = { "csiphy5" },
1400 		.csiphy = {
1401 			.id = 5,
1402 			.hw_ops = &csiphy_ops_3ph_1_0,
1403 			.formats = &csiphy_formats_sdm845
1404 		}
1405 	}
1406 };
1407 
1408 static const struct camss_subdev_resources csid_res_8250[] = {
1409 	/* CSID0 */
1410 	{
1411 		.regulators = {},
1412 		.clock = { "vfe0_csid", "vfe0_cphy_rx", "vfe0", "vfe0_areg", "vfe0_ahb" },
1413 		.clock_rate = { { 400000000 },
1414 				{ 400000000 },
1415 				{ 350000000, 475000000, 576000000, 720000000 },
1416 				{ 100000000, 200000000, 300000000, 400000000 },
1417 				{ 0 } },
1418 		.reg = { "csid0" },
1419 		.interrupt = { "csid0" },
1420 		.csid = {
1421 			.hw_ops = &csid_ops_gen2,
1422 			.parent_dev_ops = &vfe_parent_dev_ops,
1423 			.formats = &csid_formats_gen2
1424 		}
1425 	},
1426 	/* CSID1 */
1427 	{
1428 		.regulators = {},
1429 		.clock = { "vfe1_csid", "vfe1_cphy_rx", "vfe1", "vfe1_areg", "vfe1_ahb" },
1430 		.clock_rate = { { 400000000 },
1431 				{ 400000000 },
1432 				{ 350000000, 475000000, 576000000, 720000000 },
1433 				{ 100000000, 200000000, 300000000, 400000000 },
1434 				{ 0 } },
1435 		.reg = { "csid1" },
1436 		.interrupt = { "csid1" },
1437 		.csid = {
1438 			.hw_ops = &csid_ops_gen2,
1439 			.parent_dev_ops = &vfe_parent_dev_ops,
1440 			.formats = &csid_formats_gen2
1441 		}
1442 	},
1443 	/* CSID2 */
1444 	{
1445 		.regulators = {},
1446 		.clock = { "vfe_lite_csid", "vfe_lite_cphy_rx", "vfe_lite",  "vfe_lite_ahb" },
1447 		.clock_rate = { { 400000000 },
1448 				{ 400000000 },
1449 				{ 400000000, 480000000 },
1450 				{ 0 } },
1451 		.reg = { "csid2" },
1452 		.interrupt = { "csid2" },
1453 		.csid = {
1454 			.is_lite = true,
1455 			.hw_ops = &csid_ops_gen2,
1456 			.parent_dev_ops = &vfe_parent_dev_ops,
1457 			.formats = &csid_formats_gen2
1458 		}
1459 	},
1460 	/* CSID3 */
1461 	{
1462 		.regulators = {},
1463 		.clock = { "vfe_lite_csid", "vfe_lite_cphy_rx", "vfe_lite",  "vfe_lite_ahb" },
1464 		.clock_rate = { { 400000000 },
1465 				{ 400000000 },
1466 				{ 400000000, 480000000 },
1467 				{ 0 } },
1468 		.reg = { "csid3" },
1469 		.interrupt = { "csid3" },
1470 		.csid = {
1471 			.is_lite = true,
1472 			.hw_ops = &csid_ops_gen2,
1473 			.parent_dev_ops = &vfe_parent_dev_ops,
1474 			.formats = &csid_formats_gen2
1475 		}
1476 	}
1477 };
1478 
1479 static const struct camss_subdev_resources vfe_res_8250[] = {
1480 	/* VFE0 */
1481 	{
1482 		.regulators = {},
1483 		.clock = { "camnoc_axi_src", "slow_ahb_src", "cpas_ahb",
1484 			   "camnoc_axi", "vfe0_ahb", "vfe0_areg", "vfe0",
1485 			   "vfe0_axi", "cam_hf_axi" },
1486 		.clock_rate = { { 19200000, 300000000, 400000000, 480000000 },
1487 				{ 19200000, 80000000 },
1488 				{ 19200000 },
1489 				{ 0 },
1490 				{ 0 },
1491 				{ 100000000, 200000000, 300000000, 400000000 },
1492 				{ 350000000, 475000000, 576000000, 720000000 },
1493 				{ 0 },
1494 				{ 0 } },
1495 		.reg = { "vfe0" },
1496 		.interrupt = { "vfe0" },
1497 		.vfe = {
1498 			.line_num = 3,
1499 			.has_pd = true,
1500 			.pd_name = "ife0",
1501 			.hw_ops = &vfe_ops_480,
1502 			.formats_rdi = &vfe_formats_rdi_845,
1503 			.formats_pix = &vfe_formats_pix_845
1504 		}
1505 	},
1506 	/* VFE1 */
1507 	{
1508 		.regulators = {},
1509 		.clock = { "camnoc_axi_src", "slow_ahb_src", "cpas_ahb",
1510 			   "camnoc_axi", "vfe1_ahb", "vfe1_areg", "vfe1",
1511 			   "vfe1_axi", "cam_hf_axi" },
1512 		.clock_rate = { { 19200000, 300000000, 400000000, 480000000 },
1513 				{ 19200000, 80000000 },
1514 				{ 19200000 },
1515 				{ 0 },
1516 				{ 0 },
1517 				{ 100000000, 200000000, 300000000, 400000000 },
1518 				{ 350000000, 475000000, 576000000, 720000000 },
1519 				{ 0 },
1520 				{ 0 } },
1521 		.reg = { "vfe1" },
1522 		.interrupt = { "vfe1" },
1523 		.vfe = {
1524 			.line_num = 3,
1525 			.has_pd = true,
1526 			.pd_name = "ife1",
1527 			.hw_ops = &vfe_ops_480,
1528 			.formats_rdi = &vfe_formats_rdi_845,
1529 			.formats_pix = &vfe_formats_pix_845
1530 		}
1531 	},
1532 	/* VFE2 (lite) */
1533 	{
1534 		.regulators = {},
1535 		.clock = { "camnoc_axi_src", "slow_ahb_src", "cpas_ahb",
1536 			   "camnoc_axi", "vfe_lite_ahb", "vfe_lite_axi",
1537 			   "vfe_lite", "cam_hf_axi" },
1538 		.clock_rate = { { 19200000, 300000000, 400000000, 480000000 },
1539 				{ 19200000, 80000000 },
1540 				{ 19200000 },
1541 				{ 0 },
1542 				{ 0 },
1543 				{ 0 },
1544 				{ 400000000, 480000000 },
1545 				{ 0 } },
1546 		.reg = { "vfe_lite0" },
1547 		.interrupt = { "vfe_lite0" },
1548 		.vfe = {
1549 			.is_lite = true,
1550 			.line_num = 4,
1551 			.hw_ops = &vfe_ops_480,
1552 			.formats_rdi = &vfe_formats_rdi_845,
1553 			.formats_pix = &vfe_formats_pix_845
1554 		}
1555 	},
1556 	/* VFE3 (lite) */
1557 	{
1558 		.regulators = {},
1559 		.clock = { "camnoc_axi_src", "slow_ahb_src", "cpas_ahb",
1560 			   "camnoc_axi", "vfe_lite_ahb", "vfe_lite_axi",
1561 			   "vfe_lite", "cam_hf_axi" },
1562 		.clock_rate = { { 19200000, 300000000, 400000000, 480000000 },
1563 				{ 19200000, 80000000 },
1564 				{ 19200000 },
1565 				{ 0 },
1566 				{ 0 },
1567 				{ 0 },
1568 				{ 400000000, 480000000 },
1569 				{ 0 } },
1570 		.reg = { "vfe_lite1" },
1571 		.interrupt = { "vfe_lite1" },
1572 		.vfe = {
1573 			.is_lite = true,
1574 			.line_num = 4,
1575 			.hw_ops = &vfe_ops_480,
1576 			.formats_rdi = &vfe_formats_rdi_845,
1577 			.formats_pix = &vfe_formats_pix_845
1578 		}
1579 	},
1580 };
1581 
1582 static const struct resources_icc icc_res_sm8250[] = {
1583 	{
1584 		.name = "cam_ahb",
1585 		.icc_bw_tbl.avg = 38400,
1586 		.icc_bw_tbl.peak = 76800,
1587 	},
1588 	{
1589 		.name = "cam_hf_0_mnoc",
1590 		.icc_bw_tbl.avg = 2097152,
1591 		.icc_bw_tbl.peak = 2097152,
1592 	},
1593 	{
1594 		.name = "cam_sf_0_mnoc",
1595 		.icc_bw_tbl.avg = 0,
1596 		.icc_bw_tbl.peak = 2097152,
1597 	},
1598 	{
1599 		.name = "cam_sf_icp_mnoc",
1600 		.icc_bw_tbl.avg = 2097152,
1601 		.icc_bw_tbl.peak = 2097152,
1602 	},
1603 };
1604 
1605 static const struct camss_subdev_resources csiphy_res_7280[] = {
1606 	/* CSIPHY0 */
1607 	{
1608 		.regulators = { "vdda-phy", "vdda-pll" },
1609 
1610 		.clock = { "csiphy0", "csiphy0_timer" },
1611 		.clock_rate = { { 300000000, 400000000 },
1612 				{ 300000000 } },
1613 		.reg = { "csiphy0" },
1614 		.interrupt = { "csiphy0" },
1615 		.csiphy = {
1616 			.id = 0,
1617 			.hw_ops = &csiphy_ops_3ph_1_0,
1618 			.formats = &csiphy_formats_sdm845,
1619 		}
1620 	},
1621 	/* CSIPHY1 */
1622 	{
1623 		.regulators = { "vdda-phy", "vdda-pll" },
1624 
1625 		.clock = { "csiphy1", "csiphy1_timer" },
1626 		.clock_rate = { { 300000000, 400000000 },
1627 				{ 300000000 } },
1628 		.reg = { "csiphy1" },
1629 		.interrupt = { "csiphy1" },
1630 		.csiphy = {
1631 			.id = 1,
1632 			.hw_ops = &csiphy_ops_3ph_1_0,
1633 			.formats = &csiphy_formats_sdm845,
1634 		}
1635 	},
1636 	/* CSIPHY2 */
1637 	{
1638 		.regulators = { "vdda-phy", "vdda-pll" },
1639 
1640 		.clock = { "csiphy2", "csiphy2_timer" },
1641 		.clock_rate = { { 300000000, 400000000 },
1642 				{ 300000000 } },
1643 		.reg = { "csiphy2" },
1644 		.interrupt = { "csiphy2" },
1645 		.csiphy = {
1646 			.id = 2,
1647 			.hw_ops = &csiphy_ops_3ph_1_0,
1648 			.formats = &csiphy_formats_sdm845,
1649 		}
1650 	},
1651 	/* CSIPHY3 */
1652 	{
1653 		.regulators = { "vdda-phy", "vdda-pll" },
1654 
1655 		.clock = { "csiphy3", "csiphy3_timer" },
1656 		.clock_rate = { { 300000000, 400000000 },
1657 				{ 300000000 } },
1658 		.reg = { "csiphy3" },
1659 		.interrupt = { "csiphy3" },
1660 		.csiphy = {
1661 			.id = 3,
1662 			.hw_ops = &csiphy_ops_3ph_1_0,
1663 			.formats = &csiphy_formats_sdm845,
1664 		}
1665 	},
1666 	/* CSIPHY4 */
1667 	{
1668 		.regulators = { "vdda-phy", "vdda-pll" },
1669 
1670 		.clock = { "csiphy4", "csiphy4_timer" },
1671 		.clock_rate = { { 300000000, 400000000 },
1672 				{ 300000000 } },
1673 		.reg = { "csiphy4" },
1674 		.interrupt = { "csiphy4" },
1675 		.csiphy = {
1676 			.id = 4,
1677 			.hw_ops = &csiphy_ops_3ph_1_0,
1678 			.formats = &csiphy_formats_sdm845,
1679 		}
1680 	},
1681 };
1682 
1683 static const struct camss_subdev_resources csid_res_7280[] = {
1684 	/* CSID0 */
1685 	{
1686 		.regulators = {},
1687 
1688 		.clock = { "vfe0_csid", "vfe0_cphy_rx", "vfe0" },
1689 		.clock_rate = { { 300000000, 400000000 },
1690 				{ 0 },
1691 				{ 380000000, 510000000, 637000000, 760000000 }
1692 		},
1693 
1694 		.reg = { "csid0" },
1695 		.interrupt = { "csid0" },
1696 		.csid = {
1697 			.is_lite = false,
1698 			.hw_ops = &csid_ops_gen2,
1699 			.parent_dev_ops = &vfe_parent_dev_ops,
1700 			.formats = &csid_formats_gen2
1701 		}
1702 	},
1703 	/* CSID1 */
1704 	{
1705 		.regulators = {},
1706 
1707 		.clock = { "vfe1_csid", "vfe1_cphy_rx", "vfe1" },
1708 		.clock_rate = { { 300000000, 400000000 },
1709 				{ 0 },
1710 				{ 380000000, 510000000, 637000000, 760000000 }
1711 		},
1712 
1713 		.reg = { "csid1" },
1714 		.interrupt = { "csid1" },
1715 		.csid = {
1716 			.is_lite = false,
1717 			.hw_ops = &csid_ops_gen2,
1718 			.parent_dev_ops = &vfe_parent_dev_ops,
1719 			.formats = &csid_formats_gen2
1720 		}
1721 	},
1722 	/* CSID2 */
1723 	{
1724 		.regulators = {},
1725 
1726 		.clock = { "vfe2_csid", "vfe2_cphy_rx", "vfe2" },
1727 		.clock_rate = { { 300000000, 400000000 },
1728 				{ 0 },
1729 				{ 380000000, 510000000, 637000000, 760000000 }
1730 		},
1731 
1732 		.reg = { "csid2" },
1733 		.interrupt = { "csid2" },
1734 		.csid = {
1735 			.is_lite = false,
1736 			.hw_ops = &csid_ops_gen2,
1737 			.parent_dev_ops = &vfe_parent_dev_ops,
1738 			.formats = &csid_formats_gen2
1739 		}
1740 	},
1741 	/* CSID3 */
1742 	{
1743 		.regulators = {},
1744 
1745 		.clock = { "vfe_lite0_csid", "vfe_lite0_cphy_rx", "vfe_lite0" },
1746 		.clock_rate = { { 300000000, 400000000 },
1747 				{ 0 },
1748 				{ 320000000, 400000000, 480000000, 600000000 }
1749 		},
1750 
1751 		.reg = { "csid_lite0" },
1752 		.interrupt = { "csid_lite0" },
1753 		.csid = {
1754 			.is_lite = true,
1755 			.hw_ops = &csid_ops_gen2,
1756 			.parent_dev_ops = &vfe_parent_dev_ops,
1757 			.formats = &csid_formats_gen2
1758 		}
1759 	},
1760 	/* CSID4 */
1761 	{
1762 		.regulators = {},
1763 
1764 		.clock = { "vfe_lite1_csid", "vfe_lite1_cphy_rx", "vfe_lite1" },
1765 		.clock_rate = { { 300000000, 400000000 },
1766 				{ 0 },
1767 				{ 320000000, 400000000, 480000000, 600000000 }
1768 		},
1769 
1770 		.reg = { "csid_lite1" },
1771 		.interrupt = { "csid_lite1" },
1772 		.csid = {
1773 			.is_lite = true,
1774 			.hw_ops = &csid_ops_gen2,
1775 			.parent_dev_ops = &vfe_parent_dev_ops,
1776 			.formats = &csid_formats_gen2
1777 		}
1778 	},
1779 };
1780 
1781 static const struct camss_subdev_resources vfe_res_7280[] = {
1782 	/* VFE0 */
1783 	{
1784 		.regulators = {},
1785 
1786 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb", "vfe0",
1787 			   "vfe0_axi", "gcc_axi_hf", "gcc_axi_sf" },
1788 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1789 				{ 80000000 },
1790 				{ 0 },
1791 				{ 380000000, 510000000, 637000000, 760000000 },
1792 				{ 0 },
1793 				{ 0 },
1794 				{ 0 } },
1795 
1796 		.reg = { "vfe0" },
1797 		.interrupt = { "vfe0" },
1798 		.vfe = {
1799 			.line_num = 3,
1800 			.is_lite = false,
1801 			.has_pd = true,
1802 			.pd_name = "ife0",
1803 			.hw_ops = &vfe_ops_170,
1804 			.formats_rdi = &vfe_formats_rdi_845,
1805 			.formats_pix = &vfe_formats_pix_845
1806 		}
1807 	},
1808 	/* VFE1 */
1809 	{
1810 		.regulators = {},
1811 
1812 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb", "vfe1",
1813 			   "vfe1_axi", "gcc_axi_hf", "gcc_axi_sf" },
1814 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1815 				{ 80000000 },
1816 				{ 0 },
1817 				{ 380000000, 510000000, 637000000, 760000000 },
1818 				{ 0 },
1819 				{ 0 },
1820 				{ 0 } },
1821 
1822 		.reg = { "vfe1" },
1823 		.interrupt = { "vfe1" },
1824 		.vfe = {
1825 			.line_num = 3,
1826 			.is_lite = false,
1827 			.has_pd = true,
1828 			.pd_name = "ife1",
1829 			.hw_ops = &vfe_ops_170,
1830 			.formats_rdi = &vfe_formats_rdi_845,
1831 			.formats_pix = &vfe_formats_pix_845
1832 		}
1833 	},
1834 	/* VFE2 */
1835 	{
1836 		.regulators = {},
1837 
1838 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb", "vfe2",
1839 			   "vfe2_axi", "gcc_axi_hf", "gcc_axi_sf" },
1840 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1841 				{ 80000000 },
1842 				{ 0 },
1843 				{ 380000000, 510000000, 637000000, 760000000 },
1844 				{ 0 },
1845 				{ 0 },
1846 				{ 0 } },
1847 
1848 		.reg = { "vfe2" },
1849 		.interrupt = { "vfe2" },
1850 		.vfe = {
1851 			.line_num = 3,
1852 			.is_lite = false,
1853 			.hw_ops = &vfe_ops_170,
1854 			.has_pd = true,
1855 			.pd_name = "ife2",
1856 			.formats_rdi = &vfe_formats_rdi_845,
1857 			.formats_pix = &vfe_formats_pix_845
1858 		}
1859 	},
1860 	/* VFE3 (lite) */
1861 	{
1862 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb",
1863 			   "vfe_lite0", "gcc_axi_hf", "gcc_axi_sf" },
1864 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1865 				{ 80000000 },
1866 				{ 0 },
1867 				{ 320000000, 400000000, 480000000, 600000000 },
1868 				{ 0 },
1869 				{ 0 } },
1870 
1871 		.regulators = {},
1872 		.reg = { "vfe_lite0" },
1873 		.interrupt = { "vfe_lite0" },
1874 		.vfe = {
1875 			.line_num = 4,
1876 			.is_lite = true,
1877 			.hw_ops = &vfe_ops_170,
1878 			.formats_rdi = &vfe_formats_rdi_845,
1879 			.formats_pix = &vfe_formats_pix_845
1880 		}
1881 	},
1882 	/* VFE4 (lite) */
1883 	{
1884 		.clock = { "camnoc_axi", "cpas_ahb", "icp_ahb",
1885 			   "vfe_lite1", "gcc_axi_hf", "gcc_axi_sf" },
1886 		.clock_rate = { { 150000000, 240000000, 320000000, 400000000, 480000000 },
1887 				{ 80000000 },
1888 				{ 0 },
1889 				{ 320000000, 400000000, 480000000, 600000000 },
1890 				{ 0 },
1891 				{ 0 } },
1892 
1893 		.regulators = {},
1894 		.reg = { "vfe_lite1" },
1895 		.interrupt = { "vfe_lite1" },
1896 		.vfe = {
1897 			.line_num = 4,
1898 			.is_lite = true,
1899 			.hw_ops = &vfe_ops_170,
1900 			.formats_rdi = &vfe_formats_rdi_845,
1901 			.formats_pix = &vfe_formats_pix_845
1902 		}
1903 	},
1904 };
1905 
1906 static const struct resources_icc icc_res_sc7280[] = {
1907 	{
1908 		.name = "ahb",
1909 		.icc_bw_tbl.avg = 38400,
1910 		.icc_bw_tbl.peak = 76800,
1911 	},
1912 	{
1913 		.name = "hf_0",
1914 		.icc_bw_tbl.avg = 2097152,
1915 		.icc_bw_tbl.peak = 2097152,
1916 	},
1917 };
1918 
1919 static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
1920 	/* CSIPHY0 */
1921 	{
1922 		.regulators = {},
1923 		.clock = { "csiphy0", "csiphy0_timer" },
1924 		.clock_rate = { { 400000000 },
1925 				{ 300000000 } },
1926 		.reg = { "csiphy0" },
1927 		.interrupt = { "csiphy0" },
1928 		.csiphy = {
1929 			.id = 0,
1930 			.hw_ops = &csiphy_ops_3ph_1_0,
1931 			.formats = &csiphy_formats_sdm845
1932 		}
1933 	},
1934 	/* CSIPHY1 */
1935 	{
1936 		.regulators = {},
1937 		.clock = { "csiphy1", "csiphy1_timer" },
1938 		.clock_rate = { { 400000000 },
1939 				{ 300000000 } },
1940 		.reg = { "csiphy1" },
1941 		.interrupt = { "csiphy1" },
1942 		.csiphy = {
1943 			.id = 1,
1944 			.hw_ops = &csiphy_ops_3ph_1_0,
1945 			.formats = &csiphy_formats_sdm845
1946 		}
1947 	},
1948 	/* CSIPHY2 */
1949 	{
1950 		.regulators = {},
1951 		.clock = { "csiphy2", "csiphy2_timer" },
1952 		.clock_rate = { { 400000000 },
1953 				{ 300000000 } },
1954 		.reg = { "csiphy2" },
1955 		.interrupt = { "csiphy2" },
1956 		.csiphy = {
1957 			.id = 2,
1958 			.hw_ops = &csiphy_ops_3ph_1_0,
1959 			.formats = &csiphy_formats_sdm845
1960 		}
1961 	},
1962 	/* CSIPHY3 */
1963 	{
1964 		.regulators = {},
1965 		.clock = { "csiphy3", "csiphy3_timer" },
1966 		.clock_rate = { { 400000000 },
1967 				{ 300000000 } },
1968 		.reg = { "csiphy3" },
1969 		.interrupt = { "csiphy3" },
1970 		.csiphy = {
1971 			.id = 3,
1972 			.hw_ops = &csiphy_ops_3ph_1_0,
1973 			.formats = &csiphy_formats_sdm845
1974 		}
1975 	},
1976 };
1977 
1978 static const struct camss_subdev_resources csid_res_sc8280xp[] = {
1979 	/* CSID0 */
1980 	{
1981 		.regulators = { "vdda-phy", "vdda-pll" },
1982 		.clock = { "vfe0_csid", "vfe0_cphy_rx", "vfe0", "vfe0_axi" },
1983 		.clock_rate = { { 400000000, 480000000, 600000000 },
1984 				{ 0 },
1985 				{ 0 },
1986 				{ 0 } },
1987 		.reg = { "csid0" },
1988 		.interrupt = { "csid0" },
1989 		.csid = {
1990 			.hw_ops = &csid_ops_gen2,
1991 			.parent_dev_ops = &vfe_parent_dev_ops,
1992 			.formats = &csid_formats_gen2
1993 		}
1994 	},
1995 	/* CSID1 */
1996 	{
1997 		.regulators = { "vdda-phy", "vdda-pll" },
1998 		.clock = { "vfe1_csid", "vfe1_cphy_rx", "vfe1", "vfe1_axi" },
1999 		.clock_rate = { { 400000000, 480000000, 600000000 },
2000 				{ 0 },
2001 				{ 0 },
2002 				{ 0 } },
2003 		.reg = { "csid1" },
2004 		.interrupt = { "csid1" },
2005 		.csid = {
2006 			.hw_ops = &csid_ops_gen2,
2007 			.parent_dev_ops = &vfe_parent_dev_ops,
2008 			.formats = &csid_formats_gen2
2009 		}
2010 	},
2011 	/* CSID2 */
2012 	{
2013 		.regulators = { "vdda-phy", "vdda-pll" },
2014 		.clock = { "vfe2_csid", "vfe2_cphy_rx", "vfe2", "vfe2_axi" },
2015 		.clock_rate = { { 400000000, 480000000, 600000000 },
2016 				{ 0 },
2017 				{ 0 },
2018 				{ 0 } },
2019 		.reg = { "csid2" },
2020 		.interrupt = { "csid2" },
2021 		.csid = {
2022 			.hw_ops = &csid_ops_gen2,
2023 			.parent_dev_ops = &vfe_parent_dev_ops,
2024 			.formats = &csid_formats_gen2
2025 		}
2026 	},
2027 	/* CSID3 */
2028 	{
2029 		.regulators = { "vdda-phy", "vdda-pll" },
2030 		.clock = { "vfe3_csid", "vfe3_cphy_rx", "vfe3", "vfe3_axi" },
2031 		.clock_rate = { { 400000000, 480000000, 600000000 },
2032 				{ 0 },
2033 				{ 0 },
2034 				{ 0 } },
2035 		.reg = { "csid3" },
2036 		.interrupt = { "csid3" },
2037 		.csid = {
2038 			.hw_ops = &csid_ops_gen2,
2039 			.parent_dev_ops = &vfe_parent_dev_ops,
2040 			.formats = &csid_formats_gen2
2041 		}
2042 	},
2043 	/* CSID_LITE0 */
2044 	{
2045 		.regulators = { "vdda-phy", "vdda-pll" },
2046 		.clock = { "vfe_lite0_csid", "vfe_lite0_cphy_rx", "vfe_lite0" },
2047 		.clock_rate = { { 400000000, 480000000, 600000000 },
2048 				{ 0 },
2049 				{ 0 }, },
2050 		.reg = { "csid0_lite" },
2051 		.interrupt = { "csid0_lite" },
2052 		.csid = {
2053 			.is_lite = true,
2054 			.hw_ops = &csid_ops_gen2,
2055 			.parent_dev_ops = &vfe_parent_dev_ops,
2056 			.formats = &csid_formats_gen2
2057 		}
2058 	},
2059 	/* CSID_LITE1 */
2060 	{
2061 		.regulators = { "vdda-phy", "vdda-pll" },
2062 		.clock = { "vfe_lite1_csid", "vfe_lite1_cphy_rx", "vfe_lite1" },
2063 		.clock_rate = { { 400000000, 480000000, 600000000 },
2064 				{ 0 },
2065 				{ 0 }, },
2066 		.reg = { "csid1_lite" },
2067 		.interrupt = { "csid1_lite" },
2068 		.csid = {
2069 			.is_lite = true,
2070 			.hw_ops = &csid_ops_gen2,
2071 			.parent_dev_ops = &vfe_parent_dev_ops,
2072 			.formats = &csid_formats_gen2
2073 		}
2074 	},
2075 	/* CSID_LITE2 */
2076 	{
2077 		.regulators = { "vdda-phy", "vdda-pll" },
2078 		.clock = { "vfe_lite2_csid", "vfe_lite2_cphy_rx", "vfe_lite2" },
2079 		.clock_rate = { { 400000000, 480000000, 600000000 },
2080 				{ 0 },
2081 				{ 0 }, },
2082 		.reg = { "csid2_lite" },
2083 		.interrupt = { "csid2_lite" },
2084 		.csid = {
2085 			.is_lite = true,
2086 			.hw_ops = &csid_ops_gen2,
2087 			.parent_dev_ops = &vfe_parent_dev_ops,
2088 			.formats = &csid_formats_gen2
2089 		}
2090 	},
2091 	/* CSID_LITE3 */
2092 	{
2093 		.regulators = { "vdda-phy", "vdda-pll" },
2094 		.clock = { "vfe_lite3_csid", "vfe_lite3_cphy_rx", "vfe_lite3" },
2095 		.clock_rate = { { 400000000, 480000000, 600000000 },
2096 				{ 0 },
2097 				{ 0 }, },
2098 		.reg = { "csid3_lite" },
2099 		.interrupt = { "csid3_lite" },
2100 		.csid = {
2101 			.is_lite = true,
2102 			.hw_ops = &csid_ops_gen2,
2103 			.parent_dev_ops = &vfe_parent_dev_ops,
2104 			.formats = &csid_formats_gen2
2105 		}
2106 	}
2107 };
2108 
2109 static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
2110 	/* VFE0 */
2111 	{
2112 		.regulators = {},
2113 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe0", "vfe0_axi" },
2114 		.clock_rate = { { 0 },
2115 				{ 0 },
2116 				{ 19200000, 80000000},
2117 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2118 				{ 400000000, 558000000, 637000000, 760000000 },
2119 				{ 0 }, },
2120 		.reg = { "vfe0" },
2121 		.interrupt = { "vfe0" },
2122 		.vfe = {
2123 			.line_num = 4,
2124 			.pd_name = "ife0",
2125 			.hw_ops = &vfe_ops_170,
2126 			.formats_rdi = &vfe_formats_rdi_845,
2127 			.formats_pix = &vfe_formats_pix_845
2128 		}
2129 	},
2130 	/* VFE1 */
2131 	{
2132 		.regulators = {},
2133 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe1", "vfe1_axi" },
2134 		.clock_rate = { { 0 },
2135 				{ 0 },
2136 				{ 19200000, 80000000},
2137 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2138 				{ 400000000, 558000000, 637000000, 760000000 },
2139 				{ 0 }, },
2140 		.reg = { "vfe1" },
2141 		.interrupt = { "vfe1" },
2142 		.vfe = {
2143 			.line_num = 4,
2144 			.pd_name = "ife1",
2145 			.hw_ops = &vfe_ops_170,
2146 			.formats_rdi = &vfe_formats_rdi_845,
2147 			.formats_pix = &vfe_formats_pix_845
2148 		}
2149 	},
2150 	/* VFE2 */
2151 	{
2152 		.regulators = {},
2153 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe2", "vfe2_axi" },
2154 		.clock_rate = { { 0 },
2155 				{ 0 },
2156 				{ 19200000, 80000000},
2157 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2158 				{ 400000000, 558000000, 637000000, 760000000 },
2159 				{ 0 }, },
2160 		.reg = { "vfe2" },
2161 		.interrupt = { "vfe2" },
2162 		.vfe = {
2163 			.line_num = 4,
2164 			.pd_name = "ife2",
2165 			.hw_ops = &vfe_ops_170,
2166 			.formats_rdi = &vfe_formats_rdi_845,
2167 			.formats_pix = &vfe_formats_pix_845
2168 		}
2169 	},
2170 	/* VFE3 */
2171 	{
2172 		.regulators = {},
2173 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe3", "vfe3_axi" },
2174 		.clock_rate = { { 0 },
2175 				{ 0 },
2176 				{ 19200000, 80000000},
2177 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2178 				{ 400000000, 558000000, 637000000, 760000000 },
2179 				{ 0 }, },
2180 		.reg = { "vfe3" },
2181 		.interrupt = { "vfe3" },
2182 		.vfe = {
2183 			.line_num = 4,
2184 			.pd_name = "ife3",
2185 			.hw_ops = &vfe_ops_170,
2186 			.formats_rdi = &vfe_formats_rdi_845,
2187 			.formats_pix = &vfe_formats_pix_845
2188 		}
2189 	},
2190 	/* VFE_LITE_0 */
2191 	{
2192 		.regulators = {},
2193 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe_lite0" },
2194 		.clock_rate = { { 0 },
2195 				{ 0 },
2196 				{ 19200000, 80000000},
2197 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2198 				{ 320000000, 400000000, 480000000, 600000000 }, },
2199 		.reg = { "vfe_lite0" },
2200 		.interrupt = { "vfe_lite0" },
2201 		.vfe = {
2202 			.is_lite = true,
2203 			.line_num = 4,
2204 			.hw_ops = &vfe_ops_170,
2205 			.formats_rdi = &vfe_formats_rdi_845,
2206 			.formats_pix = &vfe_formats_pix_845
2207 		}
2208 	},
2209 	/* VFE_LITE_1 */
2210 	{
2211 		.regulators = {},
2212 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe_lite1" },
2213 		.clock_rate = { { 0 },
2214 				{ 0 },
2215 				{ 19200000, 80000000},
2216 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2217 				{ 320000000, 400000000, 480000000, 600000000 }, },
2218 		.reg = { "vfe_lite1" },
2219 		.interrupt = { "vfe_lite1" },
2220 		.vfe = {
2221 			.is_lite = true,
2222 			.line_num = 4,
2223 			.hw_ops = &vfe_ops_170,
2224 			.formats_rdi = &vfe_formats_rdi_845,
2225 			.formats_pix = &vfe_formats_pix_845
2226 		}
2227 	},
2228 	/* VFE_LITE_2 */
2229 	{
2230 		.regulators = {},
2231 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe_lite2" },
2232 		.clock_rate = { { 0 },
2233 				{ 0 },
2234 				{ 19200000, 80000000},
2235 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2236 				{ 320000000, 400000000, 480000000, 600000000, }, },
2237 		.reg = { "vfe_lite2" },
2238 		.interrupt = { "vfe_lite2" },
2239 		.vfe = {
2240 			.is_lite = true,
2241 			.line_num = 4,
2242 			.hw_ops = &vfe_ops_170,
2243 			.formats_rdi = &vfe_formats_rdi_845,
2244 			.formats_pix = &vfe_formats_pix_845
2245 		}
2246 	},
2247 	/* VFE_LITE_3 */
2248 	{
2249 		.regulators = {},
2250 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", "camnoc_axi", "vfe_lite3" },
2251 		.clock_rate = { { 0 },
2252 				{ 0 },
2253 				{ 19200000, 80000000},
2254 				{ 19200000, 150000000, 266666667, 320000000, 400000000, 480000000 },
2255 				{ 320000000, 400000000, 480000000, 600000000 }, },
2256 		.reg = { "vfe_lite3" },
2257 		.interrupt = { "vfe_lite3" },
2258 		.vfe = {
2259 			.is_lite = true,
2260 			.line_num = 4,
2261 			.hw_ops = &vfe_ops_170,
2262 			.formats_rdi = &vfe_formats_rdi_845,
2263 			.formats_pix = &vfe_formats_pix_845
2264 		}
2265 	},
2266 };
2267 
2268 static const struct resources_icc icc_res_sc8280xp[] = {
2269 	{
2270 		.name = "cam_ahb",
2271 		.icc_bw_tbl.avg = 150000,
2272 		.icc_bw_tbl.peak = 300000,
2273 	},
2274 	{
2275 		.name = "cam_hf_mnoc",
2276 		.icc_bw_tbl.avg = 2097152,
2277 		.icc_bw_tbl.peak = 2097152,
2278 	},
2279 	{
2280 		.name = "cam_sf_mnoc",
2281 		.icc_bw_tbl.avg = 2097152,
2282 		.icc_bw_tbl.peak = 2097152,
2283 	},
2284 	{
2285 		.name = "cam_sf_icp_mnoc",
2286 		.icc_bw_tbl.avg = 2097152,
2287 		.icc_bw_tbl.peak = 2097152,
2288 	},
2289 };
2290 
2291 static const struct camss_subdev_resources csiphy_res_8550[] = {
2292 	/* CSIPHY0 */
2293 	{
2294 		.regulators = { "vdda-phy", "vdda-pll" },
2295 		.clock = { "csiphy0", "csiphy0_timer" },
2296 		.clock_rate = { { 400000000, 480000000 },
2297 				{ 400000000 } },
2298 		.reg = { "csiphy0" },
2299 		.interrupt = { "csiphy0" },
2300 		.csiphy = {
2301 			.id = 0,
2302 			.hw_ops = &csiphy_ops_3ph_1_0,
2303 			.formats = &csiphy_formats_sdm845
2304 		}
2305 	},
2306 	/* CSIPHY1 */
2307 	{
2308 		.regulators = { "vdda-phy", "vdda-pll" },
2309 		.clock = { "csiphy1", "csiphy1_timer" },
2310 		.clock_rate = { { 400000000, 480000000 },
2311 				{ 400000000 } },
2312 		.reg = { "csiphy1" },
2313 		.interrupt = { "csiphy1" },
2314 		.csiphy = {
2315 			.id = 1,
2316 			.hw_ops = &csiphy_ops_3ph_1_0,
2317 			.formats = &csiphy_formats_sdm845
2318 		}
2319 	},
2320 	/* CSIPHY2 */
2321 	{
2322 		.regulators = { "vdda-phy", "vdda-pll" },
2323 		.clock = { "csiphy2", "csiphy2_timer" },
2324 		.clock_rate = { { 400000000, 480000000 },
2325 				{ 400000000 } },
2326 		.reg = { "csiphy2" },
2327 		.interrupt = { "csiphy2" },
2328 		.csiphy = {
2329 			.id = 2,
2330 			.hw_ops = &csiphy_ops_3ph_1_0,
2331 			.formats = &csiphy_formats_sdm845
2332 		}
2333 	},
2334 	/* CSIPHY3 */
2335 	{
2336 		.regulators = { "vdda-phy", "vdda-pll" },
2337 		.clock = { "csiphy3", "csiphy3_timer" },
2338 		.clock_rate = { { 400000000, 480000000 },
2339 				{ 400000000 } },
2340 		.reg = { "csiphy3" },
2341 		.interrupt = { "csiphy3" },
2342 		.csiphy = {
2343 			.id = 3,
2344 			.hw_ops = &csiphy_ops_3ph_1_0,
2345 			.formats = &csiphy_formats_sdm845
2346 		}
2347 	},
2348 	/* CSIPHY4 */
2349 	{
2350 		.regulators = { "vdda-phy", "vdda-pll" },
2351 		.clock = { "csiphy4", "csiphy4_timer" },
2352 		.clock_rate = { { 400000000, 480000000 },
2353 				{ 400000000 } },
2354 		.reg = { "csiphy4" },
2355 		.interrupt = { "csiphy4" },
2356 		.csiphy = {
2357 			.id = 4,
2358 			.hw_ops = &csiphy_ops_3ph_1_0,
2359 			.formats = &csiphy_formats_sdm845
2360 		}
2361 	},
2362 	/* CSIPHY5 */
2363 	{
2364 		.regulators = { "vdda-phy", "vdda-pll" },
2365 		.clock = { "csiphy5", "csiphy5_timer" },
2366 		.clock_rate = { { 400000000, 480000000 },
2367 				{ 400000000 } },
2368 		.reg = { "csiphy5" },
2369 		.interrupt = { "csiphy5" },
2370 		.csiphy = {
2371 			.id = 5,
2372 			.hw_ops = &csiphy_ops_3ph_1_0,
2373 			.formats = &csiphy_formats_sdm845
2374 		}
2375 	},
2376 	/* CSIPHY6 */
2377 	{
2378 		.regulators = { "vdda-phy", "vdda-pll" },
2379 		.clock = { "csiphy6", "csiphy6_timer" },
2380 		.clock_rate = { { 400000000, 480000000 },
2381 				{ 400000000 } },
2382 		.reg = { "csiphy6" },
2383 		.interrupt = { "csiphy6" },
2384 		.csiphy = {
2385 			.id = 6,
2386 			.hw_ops = &csiphy_ops_3ph_1_0,
2387 			.formats = &csiphy_formats_sdm845
2388 		}
2389 	},
2390 	/* CSIPHY7 */
2391 	{
2392 		.regulators = { "vdda-phy", "vdda-pll" },
2393 		.clock = { "csiphy7", "csiphy7_timer" },
2394 		.clock_rate = { { 400000000, 480000000 },
2395 				{ 400000000 } },
2396 		.reg = { "csiphy7" },
2397 		.interrupt = { "csiphy7" },
2398 		.csiphy = {
2399 			.id = 7,
2400 			.hw_ops = &csiphy_ops_3ph_1_0,
2401 			.formats = &csiphy_formats_sdm845
2402 		}
2403 	}
2404 };
2405 
2406 static const struct resources_wrapper csid_wrapper_res_sm8550 = {
2407 	.reg = "csid_wrapper",
2408 };
2409 
2410 static const struct camss_subdev_resources csid_res_8550[] = {
2411 	/* CSID0 */
2412 	{
2413 		.regulators = {},
2414 		.clock = { "csid", "csiphy_rx" },
2415 		.clock_rate = { { 400000000, 480000000 },
2416 				{ 400000000, 480000000 } },
2417 		.reg = { "csid0" },
2418 		.interrupt = { "csid0" },
2419 		.csid = {
2420 			.is_lite = false,
2421 			.parent_dev_ops = &vfe_parent_dev_ops,
2422 			.hw_ops = &csid_ops_gen3,
2423 			.formats = &csid_formats_gen2
2424 		}
2425 	},
2426 	/* CSID1 */
2427 	{
2428 		.regulators = {},
2429 		.clock = { "csid", "csiphy_rx" },
2430 		.clock_rate = { { 400000000, 480000000 },
2431 				{ 400000000, 480000000 } },
2432 		.reg = { "csid1" },
2433 		.interrupt = { "csid1" },
2434 		.csid = {
2435 			.is_lite = false,
2436 			.parent_dev_ops = &vfe_parent_dev_ops,
2437 			.hw_ops = &csid_ops_gen3,
2438 			.formats = &csid_formats_gen2
2439 		}
2440 	},
2441 	/* CSID2 */
2442 	{
2443 		.regulators = {},
2444 		.clock = { "csid", "csiphy_rx" },
2445 		.clock_rate = { { 400000000, 480000000 },
2446 				{ 400000000, 480000000 } },
2447 		.reg = { "csid2" },
2448 		.interrupt = { "csid2" },
2449 		.csid = {
2450 			.is_lite = false,
2451 			.parent_dev_ops = &vfe_parent_dev_ops,
2452 			.hw_ops = &csid_ops_gen3,
2453 			.formats = &csid_formats_gen2
2454 		}
2455 	},
2456 	/* CSID3 */
2457 	{
2458 		.regulators = {},
2459 		.clock = { "vfe_lite_csid", "vfe_lite_cphy_rx" },
2460 		.clock_rate = { { 400000000, 480000000 },
2461 				{ 400000000, 480000000 } },
2462 		.reg = { "csid_lite0" },
2463 		.interrupt = { "csid_lite0" },
2464 		.csid = {
2465 			.is_lite = true,
2466 			.parent_dev_ops = &vfe_parent_dev_ops,
2467 			.hw_ops = &csid_ops_gen3,
2468 			.formats = &csid_formats_gen2
2469 		}
2470 	},
2471 	/* CSID4 */
2472 	{
2473 		.regulators = {},
2474 		.clock = { "vfe_lite_csid", "vfe_lite_cphy_rx" },
2475 		.clock_rate = { { 400000000, 480000000 },
2476 				{ 400000000, 480000000 } },
2477 		.reg = { "csid_lite1" },
2478 		.interrupt = { "csid_lite1" },
2479 		.csid = {
2480 			.is_lite = true,
2481 			.parent_dev_ops = &vfe_parent_dev_ops,
2482 			.hw_ops = &csid_ops_gen3,
2483 			.formats = &csid_formats_gen2
2484 		}
2485 	}
2486 };
2487 
2488 static const struct camss_subdev_resources vfe_res_8550[] = {
2489 	/* VFE0 */
2490 	{
2491 		.regulators = {},
2492 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe0_fast_ahb",
2493 			   "vfe0", "cpas_vfe0", "camnoc_axi" },
2494 		.clock_rate = { { 0 },
2495 				{ 80000000 },
2496 				{ 300000000, 400000000 },
2497 				{ 300000000, 400000000 },
2498 				{ 466000000, 594000000, 675000000, 785000000 },
2499 				{ 300000000, 400000000 },
2500 				{ 300000000, 400000000 } },
2501 		.reg = { "vfe0" },
2502 		.interrupt = { "vfe0" },
2503 		.vfe = {
2504 			.line_num = 3,
2505 			.is_lite = false,
2506 			.has_pd = true,
2507 			.pd_name = "ife0",
2508 			.hw_ops = &vfe_ops_gen3,
2509 			.formats_rdi = &vfe_formats_rdi_845,
2510 			.formats_pix = &vfe_formats_pix_845
2511 		}
2512 	},
2513 	/* VFE1 */
2514 	{
2515 		.regulators = {},
2516 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe1_fast_ahb",
2517 			   "vfe1", "cpas_vfe1", "camnoc_axi" },
2518 		.clock_rate = {	{ 0 },
2519 				{ 80000000 },
2520 				{ 300000000, 400000000 },
2521 				{ 300000000, 400000000 },
2522 				{ 466000000, 594000000, 675000000, 785000000 },
2523 				{ 300000000, 400000000 },
2524 				{ 300000000, 400000000 } },
2525 		.reg = { "vfe1" },
2526 		.interrupt = { "vfe1" },
2527 		.vfe = {
2528 			.line_num = 3,
2529 			.is_lite = false,
2530 			.has_pd = true,
2531 			.pd_name = "ife1",
2532 			.hw_ops = &vfe_ops_gen3,
2533 			.formats_rdi = &vfe_formats_rdi_845,
2534 			.formats_pix = &vfe_formats_pix_845
2535 		}
2536 	},
2537 	/* VFE2 */
2538 	{
2539 		.regulators = {},
2540 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe2_fast_ahb",
2541 			   "vfe2", "cpas_vfe2", "camnoc_axi" },
2542 		.clock_rate = {	{ 0 },
2543 				{ 80000000 },
2544 				{ 300000000, 400000000 },
2545 				{ 300000000, 400000000 },
2546 				{ 466000000, 594000000, 675000000, 785000000 },
2547 				{ 300000000, 400000000 },
2548 				{ 300000000, 400000000 } },
2549 		.reg = { "vfe2" },
2550 		.interrupt = { "vfe2" },
2551 		.vfe = {
2552 			.line_num = 3,
2553 			.is_lite = false,
2554 			.has_pd = true,
2555 			.pd_name = "ife2",
2556 			.hw_ops = &vfe_ops_gen3,
2557 			.formats_rdi = &vfe_formats_rdi_845,
2558 			.formats_pix = &vfe_formats_pix_845
2559 		}
2560 	},
2561 	/* VFE3 lite */
2562 	{
2563 		.regulators = {},
2564 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe_lite_ahb",
2565 			   "vfe_lite", "cpas_ife_lite", "camnoc_axi" },
2566 		.clock_rate = {	{ 0 },
2567 				{ 80000000 },
2568 				{ 300000000, 400000000 },
2569 				{ 300000000, 400000000 },
2570 				{ 400000000, 480000000 },
2571 				{ 300000000, 400000000 },
2572 				{ 300000000, 400000000 } },
2573 		.reg = { "vfe_lite0" },
2574 		.interrupt = { "vfe_lite0" },
2575 		.vfe = {
2576 			.line_num = 4,
2577 			.is_lite = true,
2578 			.hw_ops = &vfe_ops_gen3,
2579 			.formats_rdi = &vfe_formats_rdi_845,
2580 			.formats_pix = &vfe_formats_pix_845
2581 		}
2582 	},
2583 	/* VFE4 lite */
2584 	{
2585 		.regulators = {},
2586 		.clock = { "gcc_axi_hf", "cpas_ahb", "cpas_fast_ahb_clk", "vfe_lite_ahb",
2587 			   "vfe_lite", "cpas_ife_lite", "camnoc_axi" },
2588 		.clock_rate = {	{ 0 },
2589 				{ 80000000 },
2590 				{ 300000000, 400000000 },
2591 				{ 300000000, 400000000 },
2592 				{ 400000000, 480000000 },
2593 				{ 300000000, 400000000 },
2594 				{ 300000000, 400000000 } },
2595 		.reg = { "vfe_lite1" },
2596 		.interrupt = { "vfe_lite1" },
2597 		.vfe = {
2598 			.line_num = 4,
2599 			.is_lite = true,
2600 			.hw_ops = &vfe_ops_gen3,
2601 			.formats_rdi = &vfe_formats_rdi_845,
2602 			.formats_pix = &vfe_formats_pix_845
2603 		}
2604 	},
2605 };
2606 
2607 static const struct resources_icc icc_res_sm8550[] = {
2608 	{
2609 		.name = "ahb",
2610 		.icc_bw_tbl.avg = 2097152,
2611 		.icc_bw_tbl.peak = 2097152,
2612 	},
2613 	{
2614 		.name = "hf_0_mnoc",
2615 		.icc_bw_tbl.avg = 2097152,
2616 		.icc_bw_tbl.peak = 2097152,
2617 	},
2618 };
2619 
2620 static const struct camss_subdev_resources csiphy_res_8300[] = {
2621 	/* CSIPHY0 */
2622 	{
2623 		.regulators = { "vdda-phy", "vdda-pll" },
2624 
2625 		.clock = { "csiphy_rx", "csiphy0", "csiphy0_timer" },
2626 		.clock_rate = {
2627 			{ 400000000 },
2628 			{ 0 },
2629 			{ 400000000 },
2630 		},
2631 		.reg = { "csiphy0" },
2632 		.interrupt = { "csiphy0" },
2633 		.csiphy = {
2634 			.id = 0,
2635 			.hw_ops = &csiphy_ops_3ph_1_0,
2636 			.formats = &csiphy_formats_sdm845,
2637 		}
2638 	},
2639 	/* CSIPHY1 */
2640 	{
2641 		.regulators = { "vdda-phy", "vdda-pll" },
2642 
2643 		.clock = { "csiphy_rx", "csiphy1", "csiphy1_timer" },
2644 		.clock_rate = {
2645 			{ 400000000 },
2646 			{ 0 },
2647 			{ 400000000 },
2648 		},
2649 		.reg = { "csiphy1" },
2650 		.interrupt = { "csiphy1" },
2651 		.csiphy = {
2652 			.id = 1,
2653 			.hw_ops = &csiphy_ops_3ph_1_0,
2654 			.formats = &csiphy_formats_sdm845,
2655 		}
2656 	},
2657 	/* CSIPHY2 */
2658 	{
2659 		.regulators = { "vdda-phy", "vdda-pll" },
2660 
2661 		.clock = { "csiphy_rx", "csiphy2", "csiphy2_timer" },
2662 		.clock_rate = {
2663 			{ 400000000 },
2664 			{ 0 },
2665 			{ 400000000 },
2666 		},
2667 		.reg = { "csiphy2" },
2668 		.interrupt = { "csiphy2" },
2669 		.csiphy = {
2670 			.id = 2,
2671 			.hw_ops = &csiphy_ops_3ph_1_0,
2672 			.formats = &csiphy_formats_sdm845,
2673 		}
2674 	},
2675 };
2676 
2677 static const struct camss_subdev_resources csiphy_res_8775p[] = {
2678 	/* CSIPHY0 */
2679 	{
2680 		.regulators = { "vdda-phy", "vdda-pll" },
2681 		.clock = { "csiphy_rx", "csiphy0", "csiphy0_timer"},
2682 		.clock_rate = {
2683 			{ 400000000 },
2684 			{ 0 },
2685 			{ 400000000 },
2686 		},
2687 		.reg = { "csiphy0" },
2688 		.interrupt = { "csiphy0" },
2689 		.csiphy = {
2690 			.id = 0,
2691 			.hw_ops = &csiphy_ops_3ph_1_0,
2692 			.formats = &csiphy_formats_sdm845
2693 		}
2694 	},
2695 	/* CSIPHY1 */
2696 	{
2697 		.regulators = { "vdda-phy", "vdda-pll" },
2698 		.clock = { "csiphy_rx", "csiphy1", "csiphy1_timer"},
2699 		.clock_rate = {
2700 			{ 400000000 },
2701 			{ 0 },
2702 			{ 400000000 },
2703 		},
2704 		.reg = { "csiphy1" },
2705 		.interrupt = { "csiphy1" },
2706 		.csiphy = {
2707 			.id = 1,
2708 			.hw_ops = &csiphy_ops_3ph_1_0,
2709 			.formats = &csiphy_formats_sdm845
2710 		}
2711 	},
2712 	/* CSIPHY2 */
2713 	{
2714 		.regulators = { "vdda-phy", "vdda-pll" },
2715 		.clock = { "csiphy_rx", "csiphy2", "csiphy2_timer"},
2716 		.clock_rate = {
2717 			{ 400000000 },
2718 			{ 0 },
2719 			{ 400000000 },
2720 		},
2721 		.reg = { "csiphy2" },
2722 		.interrupt = { "csiphy2" },
2723 		.csiphy = {
2724 			.id = 2,
2725 			.hw_ops = &csiphy_ops_3ph_1_0,
2726 			.formats = &csiphy_formats_sdm845
2727 		}
2728 	},
2729 	/* CSIPHY3 */
2730 	{
2731 		.regulators = { "vdda-phy", "vdda-pll" },
2732 		.clock = { "csiphy_rx", "csiphy3", "csiphy3_timer"},
2733 		.clock_rate = {
2734 			{ 400000000 },
2735 			{ 0 },
2736 			{ 400000000 },
2737 		},
2738 		.reg = { "csiphy3" },
2739 		.interrupt = { "csiphy3" },
2740 		.csiphy = {
2741 			.id = 3,
2742 			.hw_ops = &csiphy_ops_3ph_1_0,
2743 			.formats = &csiphy_formats_sdm845
2744 		}
2745 	},
2746 };
2747 
2748 static const struct camss_subdev_resources csid_res_8775p[] = {
2749 	/* CSID0 */
2750 	{
2751 		.regulators = {},
2752 		.clock = { "csid", "csiphy_rx"},
2753 		.clock_rate = {
2754 			{ 400000000, 400000000},
2755 			{ 400000000, 400000000}
2756 		},
2757 		.reg = { "csid0" },
2758 		.interrupt = { "csid0" },
2759 		.csid = {
2760 			.is_lite = false,
2761 			.hw_ops = &csid_ops_gen3,
2762 			.parent_dev_ops = &vfe_parent_dev_ops,
2763 			.formats = &csid_formats_gen2
2764 		}
2765 	},
2766 	/* CSID1 */
2767 	{
2768 		.regulators = {},
2769 		.clock = { "csid", "csiphy_rx"},
2770 		.clock_rate = {
2771 			{ 400000000, 400000000},
2772 			{ 400000000, 400000000}
2773 		},
2774 		.reg = { "csid1" },
2775 		.interrupt = { "csid1" },
2776 		.csid = {
2777 			.is_lite = false,
2778 			.hw_ops = &csid_ops_gen3,
2779 			.parent_dev_ops = &vfe_parent_dev_ops,
2780 			.formats = &csid_formats_gen2
2781 		}
2782 	},
2783 
2784 	/* CSID2 (lite) */
2785 	{
2786 		.regulators = {},
2787 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
2788 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
2789 			   "vfe_lite"},
2790 		.clock_rate = {
2791 			{ 0, 0, 400000000, 400000000, 0},
2792 			{ 0, 0, 400000000, 480000000, 0}
2793 		},
2794 		.reg = { "csid_lite0" },
2795 		.interrupt = { "csid_lite0" },
2796 		.csid = {
2797 			.is_lite = true,
2798 			.hw_ops = &csid_ops_gen3,
2799 			.parent_dev_ops = &vfe_parent_dev_ops,
2800 			.formats = &csid_formats_gen2
2801 		}
2802 	},
2803 	/* CSID3 (lite) */
2804 	{
2805 		.regulators = {},
2806 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
2807 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
2808 			   "vfe_lite"},
2809 		.clock_rate = {
2810 			{ 0, 0, 400000000, 400000000, 0},
2811 			{ 0, 0, 400000000, 480000000, 0}
2812 		},
2813 		.reg = { "csid_lite1" },
2814 		.interrupt = { "csid_lite1" },
2815 		.csid = {
2816 			.is_lite = true,
2817 			.hw_ops = &csid_ops_gen3,
2818 			.parent_dev_ops = &vfe_parent_dev_ops,
2819 			.formats = &csid_formats_gen2
2820 		}
2821 	},
2822 	/* CSID4 (lite) */
2823 	{
2824 		.regulators = {},
2825 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
2826 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
2827 			   "vfe_lite"},
2828 		.clock_rate = {
2829 			{ 0, 0, 400000000, 400000000, 0},
2830 			{ 0, 0, 400000000, 480000000, 0}
2831 		},
2832 		.reg = { "csid_lite2" },
2833 		.interrupt = { "csid_lite2" },
2834 		.csid = {
2835 			.is_lite = true,
2836 			.hw_ops = &csid_ops_gen3,
2837 			.parent_dev_ops = &vfe_parent_dev_ops,
2838 			.formats = &csid_formats_gen2
2839 		}
2840 	},
2841 	/* CSID5 (lite) */
2842 	{
2843 		.regulators = {},
2844 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
2845 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
2846 			   "vfe_lite"},
2847 		.clock_rate = {
2848 			{ 0, 0, 400000000, 400000000, 0},
2849 			{ 0, 0, 400000000, 480000000, 0}
2850 		},
2851 		.reg = { "csid_lite3" },
2852 		.interrupt = { "csid_lite3" },
2853 		.csid = {
2854 			.is_lite = true,
2855 			.hw_ops = &csid_ops_gen3,
2856 			.parent_dev_ops = &vfe_parent_dev_ops,
2857 			.formats = &csid_formats_gen2
2858 		}
2859 	},
2860 	/* CSID6 (lite) */
2861 	{
2862 		.regulators = {},
2863 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
2864 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
2865 			   "vfe_lite"},
2866 		.clock_rate = {
2867 			{ 0, 0, 400000000, 400000000, 0},
2868 			{ 0, 0, 400000000, 480000000, 0}
2869 		},
2870 		.reg = { "csid_lite4" },
2871 		.interrupt = { "csid_lite4" },
2872 		.csid = {
2873 			.is_lite = true,
2874 			.hw_ops = &csid_ops_gen3,
2875 			.parent_dev_ops = &vfe_parent_dev_ops,
2876 			.formats = &csid_formats_gen2
2877 		}
2878 	},
2879 };
2880 
2881 static const struct camss_subdev_resources vfe_res_8775p[] = {
2882 	/* VFE0 */
2883 	{
2884 		.regulators = {},
2885 		.clock = { "cpas_vfe0", "vfe0", "vfe0_fast_ahb",
2886 			   "cpas_ahb", "gcc_axi_hf",
2887 			   "cpas_fast_ahb_clk",
2888 			   "camnoc_axi"},
2889 		.clock_rate = {
2890 			{ 0 },
2891 			{ 480000000 },
2892 			{ 300000000, 400000000 },
2893 			{ 300000000, 400000000 },
2894 			{ 0 },
2895 			{ 300000000, 400000000 },
2896 			{ 400000000 },
2897 		},
2898 		.reg = { "vfe0" },
2899 		.interrupt = { "vfe0" },
2900 		.vfe = {
2901 			.line_num = 3,
2902 			.is_lite = false,
2903 			.has_pd = false,
2904 			.pd_name = NULL,
2905 			.hw_ops = &vfe_ops_gen3,
2906 			.formats_rdi = &vfe_formats_rdi_845,
2907 			.formats_pix = &vfe_formats_pix_845
2908 		}
2909 	},
2910 	/* VFE1 */
2911 	{
2912 		.regulators = {},
2913 		.clock = { "cpas_vfe1", "vfe1", "vfe1_fast_ahb",
2914 			   "cpas_ahb", "gcc_axi_hf",
2915 			   "cpas_fast_ahb_clk",
2916 			   "camnoc_axi"},
2917 		.clock_rate = {
2918 			{ 0 },
2919 			{ 480000000 },
2920 			{ 300000000, 400000000 },
2921 			{ 300000000, 400000000 },
2922 			{ 0 },
2923 			{ 300000000, 400000000 },
2924 			{ 400000000 },
2925 		},
2926 		.reg = { "vfe1" },
2927 		.interrupt = { "vfe1" },
2928 		.vfe = {
2929 			.line_num = 3,
2930 			.is_lite = false,
2931 			.has_pd = false,
2932 			.pd_name = NULL,
2933 			.hw_ops = &vfe_ops_gen3,
2934 			.formats_rdi = &vfe_formats_rdi_845,
2935 			.formats_pix = &vfe_formats_pix_845
2936 		}
2937 	},
2938 	/* VFE2 (lite) */
2939 	{
2940 		.regulators = {},
2941 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
2942 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
2943 			   "vfe_lite"},
2944 		.clock_rate = {
2945 			{ 0, 0, 0, 0  },
2946 			{ 300000000, 400000000, 400000000, 400000000 },
2947 			{ 400000000, 400000000, 400000000, 400000000 },
2948 			{ 400000000, 400000000, 400000000, 400000000 },
2949 			{ 480000000, 600000000, 600000000, 600000000 },
2950 		},
2951 		.reg = { "vfe_lite0" },
2952 		.interrupt = { "vfe_lite0" },
2953 		.vfe = {
2954 			.line_num = 4,
2955 			.is_lite = true,
2956 			.hw_ops = &vfe_ops_gen3,
2957 			.formats_rdi = &vfe_formats_rdi_845,
2958 			.formats_pix = &vfe_formats_pix_845
2959 		}
2960 	},
2961 	/* VFE3 (lite) */
2962 	{
2963 		.regulators = {},
2964 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
2965 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
2966 			   "vfe_lite"},
2967 		.clock_rate = {
2968 			{ 0, 0, 0, 0  },
2969 			{ 300000000, 400000000, 400000000, 400000000 },
2970 			{ 400000000, 400000000, 400000000, 400000000 },
2971 			{ 400000000, 400000000, 400000000, 400000000 },
2972 			{ 480000000, 600000000, 600000000, 600000000 },
2973 		},
2974 		.reg = { "vfe_lite1" },
2975 		.interrupt = { "vfe_lite1" },
2976 		.vfe = {
2977 			.line_num = 4,
2978 			.is_lite = true,
2979 			.hw_ops = &vfe_ops_gen3,
2980 			.formats_rdi = &vfe_formats_rdi_845,
2981 			.formats_pix = &vfe_formats_pix_845
2982 		}
2983 	},
2984 	/* VFE4 (lite) */
2985 	{
2986 		.regulators = {},
2987 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
2988 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
2989 			   "vfe_lite"},
2990 		.clock_rate = {
2991 			{ 0, 0, 0, 0  },
2992 			{ 300000000, 400000000, 400000000, 400000000 },
2993 			{ 400000000, 400000000, 400000000, 400000000 },
2994 			{ 400000000, 400000000, 400000000, 400000000 },
2995 			{ 480000000, 600000000, 600000000, 600000000 },
2996 		},
2997 		.reg = { "vfe_lite2" },
2998 		.interrupt = { "vfe_lite2" },
2999 		.vfe = {
3000 			.line_num = 4,
3001 			.is_lite = true,
3002 			.hw_ops = &vfe_ops_gen3,
3003 			.formats_rdi = &vfe_formats_rdi_845,
3004 			.formats_pix = &vfe_formats_pix_845
3005 		}
3006 	},
3007 	/* VFE5 (lite) */
3008 	{
3009 		.regulators = {},
3010 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
3011 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
3012 			   "vfe_lite"},
3013 		.clock_rate = {
3014 			{ 0, 0, 0, 0  },
3015 			{ 300000000, 400000000, 400000000, 400000000 },
3016 			{ 400000000, 400000000, 400000000, 400000000 },
3017 			{ 400000000, 400000000, 400000000, 400000000 },
3018 			{ 480000000, 600000000, 600000000, 600000000 },
3019 		},
3020 		.reg = { "vfe_lite3" },
3021 		.interrupt = { "vfe_lite3" },
3022 		.vfe = {
3023 			.line_num = 4,
3024 			.is_lite = true,
3025 			.hw_ops = &vfe_ops_gen3,
3026 			.formats_rdi = &vfe_formats_rdi_845,
3027 			.formats_pix = &vfe_formats_pix_845
3028 		}
3029 	},
3030 	/* VFE6 (lite) */
3031 	{
3032 		.regulators = {},
3033 		.clock = { "cpas_vfe_lite", "vfe_lite_ahb",
3034 			   "vfe_lite_csid", "vfe_lite_cphy_rx",
3035 			   "vfe_lite"},
3036 		.clock_rate = {
3037 			{ 0, 0, 0, 0  },
3038 			{ 300000000, 400000000, 400000000, 400000000 },
3039 			{ 400000000, 400000000, 400000000, 400000000 },
3040 			{ 400000000, 400000000, 400000000, 400000000 },
3041 			{ 480000000, 600000000, 600000000, 600000000 },
3042 		},
3043 		.reg = { "vfe_lite4" },
3044 		.interrupt = { "vfe_lite4" },
3045 		.vfe = {
3046 			.line_num = 4,
3047 			.is_lite = true,
3048 			.hw_ops = &vfe_ops_gen3,
3049 			.formats_rdi = &vfe_formats_rdi_845,
3050 			.formats_pix = &vfe_formats_pix_845
3051 		}
3052 	},
3053 };
3054 
3055 static const struct resources_icc icc_res_qcs8300[] = {
3056 	{
3057 		.name = "ahb",
3058 		.icc_bw_tbl.avg = 38400,
3059 		.icc_bw_tbl.peak = 76800,
3060 	},
3061 	{
3062 		.name = "hf_0",
3063 		.icc_bw_tbl.avg = 2097152,
3064 		.icc_bw_tbl.peak = 2097152,
3065 	},
3066 };
3067 
3068 static const struct resources_icc icc_res_sa8775p[] = {
3069 	{
3070 		.name = "ahb",
3071 		.icc_bw_tbl.avg = 38400,
3072 		.icc_bw_tbl.peak = 76800,
3073 	},
3074 	{
3075 		.name = "hf_0",
3076 		.icc_bw_tbl.avg = 2097152,
3077 		.icc_bw_tbl.peak = 2097152,
3078 	},
3079 };
3080 
3081 static const struct camss_subdev_resources csiphy_res_x1e80100[] = {
3082 	/* CSIPHY0 */
3083 	{
3084 		.regulators = { "vdd-csiphy-0p8",
3085 				"vdd-csiphy-1p2" },
3086 		.clock = { "csiphy0", "csiphy0_timer" },
3087 		.clock_rate = { { 300000000, 400000000, 480000000 },
3088 				{ 266666667, 400000000 } },
3089 		.reg = { "csiphy0" },
3090 		.interrupt = { "csiphy0" },
3091 		.csiphy = {
3092 			.id = 0,
3093 			.hw_ops = &csiphy_ops_3ph_1_0,
3094 			.formats = &csiphy_formats_sdm845
3095 		},
3096 	},
3097 	/* CSIPHY1 */
3098 	{
3099 		.regulators = { "vdd-csiphy-0p8",
3100 				"vdd-csiphy-1p2" },
3101 		.clock = { "csiphy1", "csiphy1_timer" },
3102 		.clock_rate = { { 300000000, 400000000, 480000000 },
3103 				{ 266666667, 400000000 } },
3104 		.reg = { "csiphy1" },
3105 		.interrupt = { "csiphy1" },
3106 		.csiphy = {
3107 			.id = 1,
3108 			.hw_ops = &csiphy_ops_3ph_1_0,
3109 			.formats = &csiphy_formats_sdm845
3110 		},
3111 	},
3112 	/* CSIPHY2 */
3113 	{
3114 		.regulators = { "vdd-csiphy-0p8",
3115 				"vdd-csiphy-1p2" },
3116 		.clock = { "csiphy2", "csiphy2_timer" },
3117 		.clock_rate = { { 300000000, 400000000, 480000000 },
3118 				{ 266666667, 400000000 } },
3119 		.reg = { "csiphy2" },
3120 		.interrupt = { "csiphy2" },
3121 		.csiphy = {
3122 			.id = 2,
3123 			.hw_ops = &csiphy_ops_3ph_1_0,
3124 			.formats = &csiphy_formats_sdm845
3125 		},
3126 	},
3127 	/* CSIPHY4 */
3128 	{
3129 		.regulators = { "vdd-csiphy-0p8",
3130 				"vdd-csiphy-1p2" },
3131 		.clock = { "csiphy4", "csiphy4_timer" },
3132 		.clock_rate = { { 300000000, 400000000, 480000000 },
3133 				{ 266666667, 400000000 } },
3134 		.reg = { "csiphy4" },
3135 		.interrupt = { "csiphy4" },
3136 		.csiphy = {
3137 			.id = 4,
3138 			.hw_ops = &csiphy_ops_3ph_1_0,
3139 			.formats = &csiphy_formats_sdm845
3140 		},
3141 	},
3142 };
3143 
3144 static const struct camss_subdev_resources csid_res_x1e80100[] = {
3145 	/* CSID0 */
3146 	{
3147 		.regulators = {},
3148 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
3149 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
3150 		.clock_rate = { { 0 },
3151 				{ 0 },
3152 				{ 64000000, 80000000 },
3153 				{ 80000000,  100000000, 200000000,
3154 				  300000000, 400000000 },
3155 				{ 300000000, 400000000, 480000000 },
3156 				{ 300000000, 400000000, 480000000 }, },
3157 		.reg = { "csid0" },
3158 		.interrupt = { "csid0" },
3159 		.csid = {
3160 			.hw_ops = &csid_ops_680,
3161 			.parent_dev_ops = &vfe_parent_dev_ops,
3162 			.formats = &csid_formats_gen2
3163 		},
3164 	},
3165 	/* CSID1 */
3166 	{
3167 		.regulators = {},
3168 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
3169 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
3170 		.clock_rate = { { 0 },
3171 				{ 0 },
3172 				{ 64000000, 80000000 },
3173 				{ 80000000,  100000000, 200000000,
3174 				  300000000, 400000000 },
3175 				{ 300000000, 400000000, 480000000 },
3176 				{ 300000000, 400000000, 480000000 }, },
3177 		.reg = { "csid1" },
3178 		.interrupt = { "csid1" },
3179 		.csid = {
3180 			.hw_ops = &csid_ops_680,
3181 			.parent_dev_ops = &vfe_parent_dev_ops,
3182 			.formats = &csid_formats_gen2
3183 		},
3184 	},
3185 	/* CSID2 */
3186 	{
3187 		.regulators = {},
3188 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
3189 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
3190 		.clock_rate = { { 0 },
3191 				{ 0 },
3192 				{ 64000000, 80000000 },
3193 				{ 80000000,  100000000, 200000000,
3194 				  300000000, 400000000 },
3195 				{ 300000000, 400000000, 480000000 },
3196 				{ 300000000, 400000000, 480000000 }, },
3197 		.reg = { "csid2" },
3198 		.interrupt = { "csid2" },
3199 		.csid = {
3200 			.hw_ops = &csid_ops_680,
3201 			.parent_dev_ops = &vfe_parent_dev_ops,
3202 			.formats = &csid_formats_gen2
3203 		},
3204 	},
3205 	/* CSID_LITE0 */
3206 	{
3207 		.regulators = {},
3208 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
3209 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
3210 		.clock_rate = { { 0 },
3211 				{ 0 },
3212 				{ 64000000, 80000000 },
3213 				{ 80000000,  100000000, 200000000,
3214 				  300000000, 400000000 },
3215 				{ 300000000, 400000000, 480000000 },
3216 				{ 300000000, 400000000, 480000000 }, },
3217 		.reg = { "csid_lite0" },
3218 		.interrupt = { "csid_lite0" },
3219 		.csid = {
3220 			.is_lite = true,
3221 			.hw_ops = &csid_ops_680,
3222 			.parent_dev_ops = &vfe_parent_dev_ops,
3223 			.formats = &csid_formats_gen2
3224 		}
3225 	},
3226 	/* CSID_LITE1 */
3227 	{
3228 		.regulators = {},
3229 		.clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb",
3230 			   "cpas_fast_ahb", "csid", "csid_csiphy_rx" },
3231 		.clock_rate = { { 0 },
3232 				{ 0 },
3233 				{ 64000000, 80000000 },
3234 				{ 80000000,  100000000, 200000000,
3235 				  300000000, 400000000 },
3236 				{ 300000000, 400000000, 480000000 },
3237 				{ 300000000, 400000000, 480000000 }, },
3238 
3239 		.reg = { "csid_lite1" },
3240 		.interrupt = { "csid_lite1" },
3241 		.csid = {
3242 			.is_lite = true,
3243 			.hw_ops = &csid_ops_680,
3244 			.parent_dev_ops = &vfe_parent_dev_ops,
3245 			.formats = &csid_formats_gen2
3246 		}
3247 	},
3248 };
3249 
3250 static const struct camss_subdev_resources vfe_res_x1e80100[] = {
3251 	/* IFE0 */
3252 	{
3253 		.regulators = {},
3254 		.clock = {"camnoc_rt_axi", "camnoc_nrt_axi", "cpas_ahb",
3255 			  "cpas_fast_ahb", "cpas_vfe0", "vfe0_fast_ahb",
3256 			  "vfe0" },
3257 		.clock_rate = { { 0 },
3258 				{ 0 },
3259 				{ 0 },
3260 				{ 0 },
3261 				{ 0 },
3262 				{ 0 },
3263 				{ 345600000, 432000000, 594000000, 675000000,
3264 				  727000000 }, },
3265 		.reg = { "vfe0" },
3266 		.interrupt = { "vfe0" },
3267 		.vfe = {
3268 			.line_num = 4,
3269 			.pd_name = "ife0",
3270 			.hw_ops = &vfe_ops_680,
3271 			.formats_rdi = &vfe_formats_rdi_845,
3272 			.formats_pix = &vfe_formats_pix_845
3273 		},
3274 	},
3275 	/* IFE1 */
3276 	{
3277 		.regulators = {},
3278 		.clock = { "camnoc_rt_axi", "camnoc_nrt_axi", "cpas_ahb",
3279 			   "cpas_fast_ahb", "cpas_vfe1", "vfe1_fast_ahb",
3280 			   "vfe1"  },
3281 		.clock_rate = { { 0 },
3282 				{ 0 },
3283 				{ 0 },
3284 				{ 0 },
3285 				{ 0 },
3286 				{ 0 },
3287 				{ 345600000, 432000000, 594000000, 675000000,
3288 				  727000000 }, },
3289 		.reg = { "vfe1" },
3290 		.interrupt = { "vfe1" },
3291 		.vfe = {
3292 			.line_num = 4,
3293 			.pd_name = "ife1",
3294 			.hw_ops = &vfe_ops_680,
3295 			.formats_rdi = &vfe_formats_rdi_845,
3296 			.formats_pix = &vfe_formats_pix_845
3297 		},
3298 	},
3299 	/* IFE_LITE_0 */
3300 	{
3301 		.regulators = {},
3302 		.clock = { "camnoc_rt_axi", "camnoc_nrt_axi", "cpas_ahb",
3303 			   "vfe_lite_ahb", "cpas_vfe_lite", "vfe_lite",
3304 			   "vfe_lite_csid" },
3305 		.clock_rate = { { 0 },
3306 				{ 0 },
3307 				{ 0 },
3308 				{ 0 },
3309 				{ 0 },
3310 				{ 266666667, 400000000, 480000000 },
3311 				{ 266666667, 400000000, 480000000 }, },
3312 		.reg = { "vfe_lite0" },
3313 		.interrupt = { "vfe_lite0" },
3314 		.vfe = {
3315 			.is_lite = true,
3316 			.line_num = 4,
3317 			.hw_ops = &vfe_ops_680,
3318 			.formats_rdi = &vfe_formats_rdi_845,
3319 			.formats_pix = &vfe_formats_pix_845
3320 		},
3321 	},
3322 	/* IFE_LITE_1 */
3323 	{
3324 		.regulators = {},
3325 		.clock = { "camnoc_rt_axi", "camnoc_nrt_axi", "cpas_ahb",
3326 			   "vfe_lite_ahb", "cpas_vfe_lite", "vfe_lite",
3327 			   "vfe_lite_csid" },
3328 		.clock_rate = { { 0 },
3329 				{ 0 },
3330 				{ 0 },
3331 				{ 0 },
3332 				{ 0 },
3333 				{ 266666667, 400000000, 480000000 },
3334 				{ 266666667, 400000000, 480000000 }, },
3335 		.reg = { "vfe_lite1" },
3336 		.interrupt = { "vfe_lite1" },
3337 		.vfe = {
3338 			.is_lite = true,
3339 			.line_num = 4,
3340 			.hw_ops = &vfe_ops_680,
3341 			.formats_rdi = &vfe_formats_rdi_845,
3342 			.formats_pix = &vfe_formats_pix_845
3343 		},
3344 	},
3345 };
3346 
3347 static const struct resources_icc icc_res_x1e80100[] = {
3348 	{
3349 		.name = "ahb",
3350 		.icc_bw_tbl.avg = 150000,
3351 		.icc_bw_tbl.peak = 300000,
3352 	},
3353 	{
3354 		.name = "hf_mnoc",
3355 		.icc_bw_tbl.avg = 2097152,
3356 		.icc_bw_tbl.peak = 2097152,
3357 	},
3358 	{
3359 		.name = "sf_mnoc",
3360 		.icc_bw_tbl.avg = 2097152,
3361 		.icc_bw_tbl.peak = 2097152,
3362 	},
3363 	{
3364 		.name = "sf_icp_mnoc",
3365 		.icc_bw_tbl.avg = 2097152,
3366 		.icc_bw_tbl.peak = 2097152,
3367 	},
3368 };
3369 
3370 static const struct resources_wrapper csid_wrapper_res_x1e80100 = {
3371 	.reg = "csid_wrapper",
3372 };
3373 
3374 /*
3375  * camss_add_clock_margin - Add margin to clock frequency rate
3376  * @rate: Clock frequency rate
3377  *
3378  * When making calculations with physical clock frequency values
3379  * some safety margin must be added. Add it.
3380  */
3381 inline void camss_add_clock_margin(u64 *rate)
3382 {
3383 	*rate *= CAMSS_CLOCK_MARGIN_NUMERATOR;
3384 	*rate = div_u64(*rate, CAMSS_CLOCK_MARGIN_DENOMINATOR);
3385 }
3386 
3387 /*
3388  * camss_enable_clocks - Enable multiple clocks
3389  * @nclocks: Number of clocks in clock array
3390  * @clock: Clock array
3391  * @dev: Device
3392  *
3393  * Return 0 on success or a negative error code otherwise
3394  */
3395 int camss_enable_clocks(int nclocks, struct camss_clock *clock,
3396 			struct device *dev)
3397 {
3398 	int ret;
3399 	int i;
3400 
3401 	for (i = 0; i < nclocks; i++) {
3402 		ret = clk_prepare_enable(clock[i].clk);
3403 		if (ret) {
3404 			dev_err(dev, "clock enable failed: %d\n", ret);
3405 			goto error;
3406 		}
3407 	}
3408 
3409 	return 0;
3410 
3411 error:
3412 	for (i--; i >= 0; i--)
3413 		clk_disable_unprepare(clock[i].clk);
3414 
3415 	return ret;
3416 }
3417 
3418 /*
3419  * camss_disable_clocks - Disable multiple clocks
3420  * @nclocks: Number of clocks in clock array
3421  * @clock: Clock array
3422  */
3423 void camss_disable_clocks(int nclocks, struct camss_clock *clock)
3424 {
3425 	int i;
3426 
3427 	for (i = nclocks - 1; i >= 0; i--)
3428 		clk_disable_unprepare(clock[i].clk);
3429 }
3430 
3431 /*
3432  * camss_find_sensor_pad - Find the media pad via which the sensor is linked
3433  * @entity: Media entity to start searching from
3434  *
3435  * Return a pointer to sensor media pad or NULL if not found
3436  */
3437 struct media_pad *camss_find_sensor_pad(struct media_entity *entity)
3438 {
3439 	struct media_pad *pad;
3440 
3441 	while (1) {
3442 		pad = &entity->pads[0];
3443 		if (!(pad->flags & MEDIA_PAD_FL_SINK))
3444 			return NULL;
3445 
3446 		pad = media_pad_remote_pad_first(pad);
3447 		if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
3448 			return NULL;
3449 
3450 		entity = pad->entity;
3451 
3452 		if (entity->function == MEDIA_ENT_F_CAM_SENSOR)
3453 			return pad;
3454 	}
3455 }
3456 
3457 /**
3458  * camss_get_link_freq - Get link frequency from sensor
3459  * @entity: Media entity in the current pipeline
3460  * @bpp: Number of bits per pixel for the current format
3461  * @lanes: Number of lanes in the link to the sensor
3462  *
3463  * Return link frequency on success or a negative error code otherwise
3464  */
3465 s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp,
3466 			unsigned int lanes)
3467 {
3468 	struct media_pad *sensor_pad;
3469 
3470 	sensor_pad = camss_find_sensor_pad(entity);
3471 	if (!sensor_pad)
3472 		return -ENODEV;
3473 
3474 	return v4l2_get_link_freq(sensor_pad, bpp, 2 * lanes);
3475 }
3476 
3477 /*
3478  * camss_get_pixel_clock - Get pixel clock rate from sensor
3479  * @entity: Media entity in the current pipeline
3480  * @pixel_clock: Received pixel clock value
3481  *
3482  * Return 0 on success or a negative error code otherwise
3483  */
3484 int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock)
3485 {
3486 	struct media_pad *sensor_pad;
3487 	struct v4l2_subdev *subdev;
3488 	struct v4l2_ctrl *ctrl;
3489 
3490 	sensor_pad = camss_find_sensor_pad(entity);
3491 	if (!sensor_pad)
3492 		return -ENODEV;
3493 
3494 	subdev = media_entity_to_v4l2_subdev(sensor_pad->entity);
3495 
3496 	ctrl = v4l2_ctrl_find(subdev->ctrl_handler, V4L2_CID_PIXEL_RATE);
3497 
3498 	if (!ctrl)
3499 		return -EINVAL;
3500 
3501 	*pixel_clock = v4l2_ctrl_g_ctrl_int64(ctrl);
3502 
3503 	return 0;
3504 }
3505 
3506 int camss_pm_domain_on(struct camss *camss, int id)
3507 {
3508 	int ret = 0;
3509 
3510 	if (id < camss->res->vfe_num) {
3511 		struct vfe_device *vfe = &camss->vfe[id];
3512 
3513 		ret = vfe->res->hw_ops->pm_domain_on(vfe);
3514 	}
3515 
3516 	return ret;
3517 }
3518 
3519 void camss_pm_domain_off(struct camss *camss, int id)
3520 {
3521 	if (id < camss->res->vfe_num) {
3522 		struct vfe_device *vfe = &camss->vfe[id];
3523 
3524 		vfe->res->hw_ops->pm_domain_off(vfe);
3525 	}
3526 }
3527 
3528 static int vfe_parent_dev_ops_get(struct camss *camss, int id)
3529 {
3530 	int ret = -EINVAL;
3531 
3532 	if (id < camss->res->vfe_num) {
3533 		struct vfe_device *vfe = &camss->vfe[id];
3534 
3535 		ret = vfe_get(vfe);
3536 	}
3537 
3538 	return ret;
3539 }
3540 
3541 static int vfe_parent_dev_ops_put(struct camss *camss, int id)
3542 {
3543 	if (id < camss->res->vfe_num) {
3544 		struct vfe_device *vfe = &camss->vfe[id];
3545 
3546 		vfe_put(vfe);
3547 	}
3548 
3549 	return 0;
3550 }
3551 
3552 static void __iomem
3553 *vfe_parent_dev_ops_get_base_address(struct camss *camss, int id)
3554 {
3555 	if (id < camss->res->vfe_num) {
3556 		struct vfe_device *vfe = &camss->vfe[id];
3557 
3558 		return vfe->base;
3559 	}
3560 
3561 	return NULL;
3562 }
3563 
3564 static const struct parent_dev_ops vfe_parent_dev_ops = {
3565 	.get = vfe_parent_dev_ops_get,
3566 	.put = vfe_parent_dev_ops_put,
3567 	.get_base_address = vfe_parent_dev_ops_get_base_address
3568 };
3569 
3570 /*
3571  * camss_of_parse_endpoint_node - Parse port endpoint node
3572  * @dev: Device
3573  * @node: Device node to be parsed
3574  * @csd: Parsed data from port endpoint node
3575  *
3576  * Return 0 on success or a negative error code on failure
3577  */
3578 static int camss_of_parse_endpoint_node(struct device *dev,
3579 					struct device_node *node,
3580 					struct camss_async_subdev *csd)
3581 {
3582 	struct csiphy_lanes_cfg *lncfg = &csd->interface.csi2.lane_cfg;
3583 	struct v4l2_mbus_config_mipi_csi2 *mipi_csi2;
3584 	struct v4l2_fwnode_endpoint vep = { { 0 } };
3585 	unsigned int i;
3586 	int ret;
3587 
3588 	ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(node), &vep);
3589 	if (ret)
3590 		return ret;
3591 
3592 	/*
3593 	 * Most SoCs support both D-PHY and C-PHY standards, but currently only
3594 	 * D-PHY is supported in the driver.
3595 	 */
3596 	if (vep.bus_type != V4L2_MBUS_CSI2_DPHY) {
3597 		dev_err(dev, "Unsupported bus type %d\n", vep.bus_type);
3598 		return -EINVAL;
3599 	}
3600 
3601 	csd->interface.csiphy_id = vep.base.port;
3602 
3603 	mipi_csi2 = &vep.bus.mipi_csi2;
3604 	lncfg->clk.pos = mipi_csi2->clock_lane;
3605 	lncfg->clk.pol = mipi_csi2->lane_polarities[0];
3606 	lncfg->num_data = mipi_csi2->num_data_lanes;
3607 
3608 	lncfg->data = devm_kcalloc(dev,
3609 				   lncfg->num_data, sizeof(*lncfg->data),
3610 				   GFP_KERNEL);
3611 	if (!lncfg->data)
3612 		return -ENOMEM;
3613 
3614 	for (i = 0; i < lncfg->num_data; i++) {
3615 		lncfg->data[i].pos = mipi_csi2->data_lanes[i];
3616 		lncfg->data[i].pol = mipi_csi2->lane_polarities[i + 1];
3617 	}
3618 
3619 	return 0;
3620 }
3621 
3622 /*
3623  * camss_of_parse_ports - Parse ports node
3624  * @dev: Device
3625  * @notifier: v4l2_device notifier data
3626  *
3627  * Return number of "port" nodes found in "ports" node
3628  */
3629 static int camss_of_parse_ports(struct camss *camss)
3630 {
3631 	struct device *dev = camss->dev;
3632 	struct device_node *node = NULL;
3633 	struct device_node *remote = NULL;
3634 	int ret, num_subdevs = 0;
3635 
3636 	for_each_endpoint_of_node(dev->of_node, node) {
3637 		struct camss_async_subdev *csd;
3638 
3639 		remote = of_graph_get_remote_port_parent(node);
3640 		if (!remote) {
3641 			dev_err(dev, "Cannot get remote parent\n");
3642 			ret = -EINVAL;
3643 			goto err_cleanup;
3644 		}
3645 
3646 		csd = v4l2_async_nf_add_fwnode(&camss->notifier,
3647 					       of_fwnode_handle(remote),
3648 					       struct camss_async_subdev);
3649 		of_node_put(remote);
3650 		if (IS_ERR(csd)) {
3651 			ret = PTR_ERR(csd);
3652 			goto err_cleanup;
3653 		}
3654 
3655 		ret = camss_of_parse_endpoint_node(dev, node, csd);
3656 		if (ret < 0)
3657 			goto err_cleanup;
3658 
3659 		num_subdevs++;
3660 	}
3661 
3662 	return num_subdevs;
3663 
3664 err_cleanup:
3665 	of_node_put(node);
3666 	return ret;
3667 }
3668 
3669 /*
3670  * camss_init_subdevices - Initialize subdev structures and resources
3671  * @camss: CAMSS device
3672  *
3673  * Return 0 on success or a negative error code on failure
3674  */
3675 static int camss_init_subdevices(struct camss *camss)
3676 {
3677 	struct platform_device *pdev = to_platform_device(camss->dev);
3678 	const struct camss_resources *res = camss->res;
3679 	unsigned int i;
3680 	int ret;
3681 
3682 	for (i = 0; i < camss->res->csiphy_num; i++) {
3683 		ret = msm_csiphy_subdev_init(camss, &camss->csiphy[i],
3684 					     &res->csiphy_res[i],
3685 					     res->csiphy_res[i].csiphy.id);
3686 		if (ret < 0) {
3687 			dev_err(camss->dev,
3688 				"Failed to init csiphy%d sub-device: %d\n",
3689 				i, ret);
3690 			return ret;
3691 		}
3692 	}
3693 
3694 	/* note: SM8250 requires VFE to be initialized before CSID */
3695 	for (i = 0; i < camss->res->vfe_num; i++) {
3696 		ret = msm_vfe_subdev_init(camss, &camss->vfe[i],
3697 					  &res->vfe_res[i], i);
3698 		if (ret < 0) {
3699 			dev_err(camss->dev,
3700 				"Fail to init vfe%d sub-device: %d\n", i, ret);
3701 			return ret;
3702 		}
3703 	}
3704 
3705 	/* Get optional CSID wrapper regs shared between CSID devices */
3706 	if (res->csid_wrapper_res) {
3707 		char *reg = res->csid_wrapper_res->reg;
3708 		void __iomem *base;
3709 
3710 		base = devm_platform_ioremap_resource_byname(pdev, reg);
3711 		if (IS_ERR(base))
3712 			return PTR_ERR(base);
3713 		camss->csid_wrapper_base = base;
3714 	}
3715 
3716 	for (i = 0; i < camss->res->csid_num; i++) {
3717 		ret = msm_csid_subdev_init(camss, &camss->csid[i],
3718 					   &res->csid_res[i], i);
3719 		if (ret < 0) {
3720 			dev_err(camss->dev,
3721 				"Failed to init csid%d sub-device: %d\n",
3722 				i, ret);
3723 			return ret;
3724 		}
3725 	}
3726 
3727 	ret = msm_ispif_subdev_init(camss, res->ispif_res);
3728 	if (ret < 0) {
3729 		dev_err(camss->dev, "Failed to init ispif sub-device: %d\n",
3730 		ret);
3731 		return ret;
3732 	}
3733 
3734 	return 0;
3735 }
3736 
3737 /*
3738  * camss_link_err - print error in case link creation fails
3739  * @src_name: name for source of the link
3740  * @sink_name: name for sink of the link
3741  */
3742 inline void camss_link_err(struct camss *camss,
3743 			   const char *src_name,
3744 			   const char *sink_name,
3745 			   int ret)
3746 {
3747 	dev_err(camss->dev,
3748 		"Failed to link %s->%s entities: %d\n",
3749 		src_name,
3750 		sink_name,
3751 		ret);
3752 }
3753 
3754 /*
3755  * camss_link_entities - Register subdev nodes and create links
3756  * @camss: CAMSS device
3757  *
3758  * Return 0 on success or a negative error code on failure
3759  */
3760 static int camss_link_entities(struct camss *camss)
3761 {
3762 	int i, j, k;
3763 	int ret;
3764 
3765 	for (i = 0; i < camss->res->csiphy_num; i++) {
3766 		for (j = 0; j < camss->res->csid_num; j++) {
3767 			ret = media_create_pad_link(&camss->csiphy[i].subdev.entity,
3768 						    MSM_CSIPHY_PAD_SRC,
3769 						    &camss->csid[j].subdev.entity,
3770 						    MSM_CSID_PAD_SINK,
3771 						    0);
3772 			if (ret < 0) {
3773 				camss_link_err(camss,
3774 					       camss->csiphy[i].subdev.entity.name,
3775 					       camss->csid[j].subdev.entity.name,
3776 					       ret);
3777 				return ret;
3778 			}
3779 		}
3780 	}
3781 
3782 	if (camss->ispif) {
3783 		for (i = 0; i < camss->res->csid_num; i++) {
3784 			for (j = 0; j < camss->ispif->line_num; j++) {
3785 				ret = media_create_pad_link(&camss->csid[i].subdev.entity,
3786 							    MSM_CSID_PAD_SRC,
3787 							    &camss->ispif->line[j].subdev.entity,
3788 							    MSM_ISPIF_PAD_SINK,
3789 							    0);
3790 				if (ret < 0) {
3791 					camss_link_err(camss,
3792 						       camss->csid[i].subdev.entity.name,
3793 						       camss->ispif->line[j].subdev.entity.name,
3794 						       ret);
3795 					return ret;
3796 				}
3797 			}
3798 		}
3799 
3800 		for (i = 0; i < camss->ispif->line_num; i++)
3801 			for (k = 0; k < camss->res->vfe_num; k++)
3802 				for (j = 0; j < camss->vfe[k].res->line_num; j++) {
3803 					struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
3804 					struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
3805 
3806 					ret = media_create_pad_link(&ispif->entity,
3807 								    MSM_ISPIF_PAD_SRC,
3808 								    &vfe->entity,
3809 								    MSM_VFE_PAD_SINK,
3810 								    0);
3811 					if (ret < 0) {
3812 						camss_link_err(camss, ispif->entity.name,
3813 							       vfe->entity.name,
3814 							       ret);
3815 						return ret;
3816 					}
3817 				}
3818 	} else {
3819 		for (i = 0; i < camss->res->csid_num; i++)
3820 			for (k = 0; k < camss->res->vfe_num; k++)
3821 				for (j = 0; j < camss->vfe[k].res->line_num; j++) {
3822 					struct v4l2_subdev *csid = &camss->csid[i].subdev;
3823 					struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
3824 
3825 					ret = media_create_pad_link(&csid->entity,
3826 								    MSM_CSID_PAD_FIRST_SRC + j,
3827 								    &vfe->entity,
3828 								    MSM_VFE_PAD_SINK,
3829 								    0);
3830 					if (ret < 0) {
3831 						camss_link_err(camss, csid->entity.name,
3832 							       vfe->entity.name,
3833 							       ret);
3834 						return ret;
3835 					}
3836 				}
3837 	}
3838 
3839 	return 0;
3840 }
3841 
3842 void camss_reg_update(struct camss *camss, int hw_id, int port_id, bool is_clear)
3843 {
3844 	struct csid_device *csid;
3845 
3846 	if (hw_id < camss->res->csid_num) {
3847 		csid = &camss->csid[hw_id];
3848 
3849 		csid->res->hw_ops->reg_update(csid, port_id, is_clear);
3850 	}
3851 }
3852 
3853 void camss_buf_done(struct camss *camss, int hw_id, int port_id)
3854 {
3855 	struct vfe_device *vfe;
3856 
3857 	if (hw_id < camss->res->vfe_num) {
3858 		vfe = &camss->vfe[hw_id];
3859 
3860 		vfe->res->hw_ops->vfe_buf_done(vfe, port_id);
3861 	}
3862 }
3863 
3864 /*
3865  * camss_register_entities - Register subdev nodes and create links
3866  * @camss: CAMSS device
3867  *
3868  * Return 0 on success or a negative error code on failure
3869  */
3870 static int camss_register_entities(struct camss *camss)
3871 {
3872 	int i;
3873 	int ret;
3874 
3875 	for (i = 0; i < camss->res->csiphy_num; i++) {
3876 		ret = msm_csiphy_register_entity(&camss->csiphy[i],
3877 						 &camss->v4l2_dev);
3878 		if (ret < 0) {
3879 			dev_err(camss->dev,
3880 				"Failed to register csiphy%d entity: %d\n",
3881 				i, ret);
3882 			goto err_reg_csiphy;
3883 		}
3884 	}
3885 
3886 	for (i = 0; i < camss->res->csid_num; i++) {
3887 		ret = msm_csid_register_entity(&camss->csid[i],
3888 					       &camss->v4l2_dev);
3889 		if (ret < 0) {
3890 			dev_err(camss->dev,
3891 				"Failed to register csid%d entity: %d\n",
3892 				i, ret);
3893 			goto err_reg_csid;
3894 		}
3895 	}
3896 
3897 	ret = msm_ispif_register_entities(camss->ispif,
3898 					  &camss->v4l2_dev);
3899 	if (ret < 0) {
3900 		dev_err(camss->dev, "Failed to register ispif entities: %d\n", ret);
3901 		goto err_reg_ispif;
3902 	}
3903 
3904 	for (i = 0; i < camss->res->vfe_num; i++) {
3905 		ret = msm_vfe_register_entities(&camss->vfe[i],
3906 						&camss->v4l2_dev);
3907 		if (ret < 0) {
3908 			dev_err(camss->dev,
3909 				"Failed to register vfe%d entities: %d\n",
3910 				i, ret);
3911 			goto err_reg_vfe;
3912 		}
3913 	}
3914 
3915 	return 0;
3916 
3917 err_reg_vfe:
3918 	for (i--; i >= 0; i--)
3919 		msm_vfe_unregister_entities(&camss->vfe[i]);
3920 
3921 err_reg_ispif:
3922 	msm_ispif_unregister_entities(camss->ispif);
3923 
3924 	i = camss->res->csid_num;
3925 err_reg_csid:
3926 	for (i--; i >= 0; i--)
3927 		msm_csid_unregister_entity(&camss->csid[i]);
3928 
3929 	i = camss->res->csiphy_num;
3930 err_reg_csiphy:
3931 	for (i--; i >= 0; i--)
3932 		msm_csiphy_unregister_entity(&camss->csiphy[i]);
3933 
3934 	return ret;
3935 }
3936 
3937 /*
3938  * camss_unregister_entities - Unregister subdev nodes
3939  * @camss: CAMSS device
3940  *
3941  * Return 0 on success or a negative error code on failure
3942  */
3943 static void camss_unregister_entities(struct camss *camss)
3944 {
3945 	unsigned int i;
3946 
3947 	for (i = 0; i < camss->res->csiphy_num; i++)
3948 		msm_csiphy_unregister_entity(&camss->csiphy[i]);
3949 
3950 	for (i = 0; i < camss->res->csid_num; i++)
3951 		msm_csid_unregister_entity(&camss->csid[i]);
3952 
3953 	msm_ispif_unregister_entities(camss->ispif);
3954 
3955 	for (i = 0; i < camss->res->vfe_num; i++)
3956 		msm_vfe_unregister_entities(&camss->vfe[i]);
3957 }
3958 
3959 static int camss_subdev_notifier_bound(struct v4l2_async_notifier *async,
3960 				       struct v4l2_subdev *subdev,
3961 				       struct v4l2_async_connection *asd)
3962 {
3963 	struct camss *camss = container_of(async, struct camss, notifier);
3964 	struct camss_async_subdev *csd =
3965 		container_of(asd, struct camss_async_subdev, asd);
3966 	u8 id = csd->interface.csiphy_id;
3967 	struct csiphy_device *csiphy = &camss->csiphy[id];
3968 
3969 	csiphy->cfg.csi2 = &csd->interface.csi2;
3970 	subdev->host_priv = csiphy;
3971 
3972 	return 0;
3973 }
3974 
3975 static int camss_subdev_notifier_complete(struct v4l2_async_notifier *async)
3976 {
3977 	struct camss *camss = container_of(async, struct camss, notifier);
3978 	struct v4l2_device *v4l2_dev = &camss->v4l2_dev;
3979 	struct v4l2_subdev *sd;
3980 
3981 	list_for_each_entry(sd, &v4l2_dev->subdevs, list) {
3982 		struct csiphy_device *csiphy = sd->host_priv;
3983 		struct media_entity *input, *sensor;
3984 		unsigned int i;
3985 		int ret;
3986 
3987 		if (!csiphy)
3988 			continue;
3989 
3990 		input = &csiphy->subdev.entity;
3991 		sensor = &sd->entity;
3992 
3993 		for (i = 0; i < sensor->num_pads; i++) {
3994 			if (sensor->pads[i].flags & MEDIA_PAD_FL_SOURCE)
3995 				break;
3996 		}
3997 		if (i == sensor->num_pads) {
3998 			dev_err(camss->dev,
3999 				"No source pad in external entity\n");
4000 			return -EINVAL;
4001 		}
4002 
4003 		ret = media_create_pad_link(sensor, i, input,
4004 					    MSM_CSIPHY_PAD_SINK,
4005 					    MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED);
4006 		if (ret < 0) {
4007 			camss_link_err(camss, sensor->name, input->name, ret);
4008 			return ret;
4009 		}
4010 	}
4011 
4012 	return v4l2_device_register_subdev_nodes(&camss->v4l2_dev);
4013 }
4014 
4015 static const struct v4l2_async_notifier_operations camss_subdev_notifier_ops = {
4016 	.bound = camss_subdev_notifier_bound,
4017 	.complete = camss_subdev_notifier_complete,
4018 };
4019 
4020 static const struct media_device_ops camss_media_ops = {
4021 	.link_notify = v4l2_pipeline_link_notify,
4022 };
4023 
4024 static int camss_configure_pd(struct camss *camss)
4025 {
4026 	const struct camss_resources *res = camss->res;
4027 	struct device *dev = camss->dev;
4028 	int vfepd_num;
4029 	int i;
4030 	int ret;
4031 
4032 	camss->genpd_num = of_count_phandle_with_args(dev->of_node,
4033 						      "power-domains",
4034 						      "#power-domain-cells");
4035 	if (camss->genpd_num < 0) {
4036 		dev_err(dev, "Power domains are not defined for camss\n");
4037 		return camss->genpd_num;
4038 	}
4039 
4040 	/*
4041 	 * If a platform device has just one power domain, then it is attached
4042 	 * at platform_probe() level, thus there shall be no need and even no
4043 	 * option to attach it again, this is the case for CAMSS on MSM8916.
4044 	 */
4045 	if (camss->genpd_num == 1)
4046 		return 0;
4047 
4048 	/* count the # of VFEs which have flagged power-domain */
4049 	for (vfepd_num = i = 0; i < camss->res->vfe_num; i++) {
4050 		if (res->vfe_res[i].vfe.has_pd)
4051 			vfepd_num++;
4052 	}
4053 
4054 	/*
4055 	 * If the number of power-domains is greater than the number of VFEs
4056 	 * then the additional power-domain is for the entire CAMSS block.
4057 	 */
4058 	if (!(camss->genpd_num > vfepd_num))
4059 		return 0;
4060 
4061 	/*
4062 	 * If a power-domain name is defined try to use it.
4063 	 * It is possible we are running a new kernel with an old dtb so
4064 	 * fallback to indexes even if a pd_name is defined but not found.
4065 	 */
4066 	if (camss->res->pd_name) {
4067 		camss->genpd = dev_pm_domain_attach_by_name(camss->dev,
4068 							    camss->res->pd_name);
4069 		if (IS_ERR(camss->genpd))
4070 			return PTR_ERR(camss->genpd);
4071 	}
4072 
4073 	if (!camss->genpd) {
4074 		/*
4075 		 * Legacy magic index. TITAN_TOP GDSC must be the last
4076 		 * item in the power-domain list.
4077 		 */
4078 		camss->genpd = dev_pm_domain_attach_by_id(camss->dev,
4079 							  camss->genpd_num - 1);
4080 		if (IS_ERR(camss->genpd))
4081 			return PTR_ERR(camss->genpd);
4082 	}
4083 
4084 	if (!camss->genpd)
4085 		return -ENODEV;
4086 
4087 	camss->genpd_link = device_link_add(camss->dev, camss->genpd,
4088 					    DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME |
4089 					    DL_FLAG_RPM_ACTIVE);
4090 	if (!camss->genpd_link) {
4091 		ret = -EINVAL;
4092 		goto fail_pm;
4093 	}
4094 
4095 	return 0;
4096 
4097 fail_pm:
4098 	dev_pm_domain_detach(camss->genpd, true);
4099 
4100 	return ret;
4101 }
4102 
4103 static int camss_icc_get(struct camss *camss)
4104 {
4105 	const struct resources_icc *icc_res;
4106 	int i;
4107 
4108 	icc_res = camss->res->icc_res;
4109 
4110 	for (i = 0; i < camss->res->icc_path_num; i++) {
4111 		camss->icc_path[i] = devm_of_icc_get(camss->dev,
4112 						     icc_res[i].name);
4113 		if (IS_ERR(camss->icc_path[i]))
4114 			return PTR_ERR(camss->icc_path[i]);
4115 	}
4116 
4117 	return 0;
4118 }
4119 
4120 static void camss_genpd_subdevice_cleanup(struct camss *camss)
4121 {
4122 	int i;
4123 
4124 	for (i = 0; i < camss->res->vfe_num; i++)
4125 		msm_vfe_genpd_cleanup(&camss->vfe[i]);
4126 }
4127 
4128 static void camss_genpd_cleanup(struct camss *camss)
4129 {
4130 	if (camss->genpd_num == 1)
4131 		return;
4132 
4133 	camss_genpd_subdevice_cleanup(camss);
4134 
4135 	if (camss->genpd_link)
4136 		device_link_del(camss->genpd_link);
4137 
4138 	dev_pm_domain_detach(camss->genpd, true);
4139 }
4140 
4141 /*
4142  * camss_probe - Probe CAMSS platform device
4143  * @pdev: Pointer to CAMSS platform device
4144  *
4145  * Return 0 on success or a negative error code on failure
4146  */
4147 static int camss_probe(struct platform_device *pdev)
4148 {
4149 	struct device *dev = &pdev->dev;
4150 	struct camss *camss;
4151 	int ret;
4152 
4153 	camss = devm_kzalloc(dev, sizeof(*camss), GFP_KERNEL);
4154 	if (!camss)
4155 		return -ENOMEM;
4156 
4157 	camss->res = of_device_get_match_data(dev);
4158 
4159 	atomic_set(&camss->ref_count, 0);
4160 	camss->dev = dev;
4161 	platform_set_drvdata(pdev, camss);
4162 
4163 	camss->csiphy = devm_kcalloc(dev, camss->res->csiphy_num,
4164 				     sizeof(*camss->csiphy), GFP_KERNEL);
4165 	if (!camss->csiphy)
4166 		return -ENOMEM;
4167 
4168 	camss->csid = devm_kcalloc(dev, camss->res->csid_num, sizeof(*camss->csid),
4169 				   GFP_KERNEL);
4170 	if (!camss->csid)
4171 		return -ENOMEM;
4172 
4173 	if (camss->res->version == CAMSS_8x16 ||
4174 	    camss->res->version == CAMSS_8x53 ||
4175 	    camss->res->version == CAMSS_8x96) {
4176 		camss->ispif = devm_kcalloc(dev, 1, sizeof(*camss->ispif), GFP_KERNEL);
4177 		if (!camss->ispif)
4178 			return -ENOMEM;
4179 	}
4180 
4181 	camss->vfe = devm_kcalloc(dev, camss->res->vfe_num,
4182 				  sizeof(*camss->vfe), GFP_KERNEL);
4183 	if (!camss->vfe)
4184 		return -ENOMEM;
4185 
4186 	ret = camss_icc_get(camss);
4187 	if (ret < 0)
4188 		return ret;
4189 
4190 	ret = camss_configure_pd(camss);
4191 	if (ret < 0) {
4192 		dev_err(dev, "Failed to configure power domains: %d\n", ret);
4193 		return ret;
4194 	}
4195 
4196 	ret = camss_init_subdevices(camss);
4197 	if (ret < 0)
4198 		goto err_genpd_cleanup;
4199 
4200 	ret = dma_set_mask_and_coherent(dev, 0xffffffff);
4201 	if (ret)
4202 		goto err_genpd_cleanup;
4203 
4204 	camss->media_dev.dev = camss->dev;
4205 	strscpy(camss->media_dev.model, "Qualcomm Camera Subsystem",
4206 		sizeof(camss->media_dev.model));
4207 	camss->media_dev.ops = &camss_media_ops;
4208 	media_device_init(&camss->media_dev);
4209 
4210 	camss->v4l2_dev.mdev = &camss->media_dev;
4211 	ret = v4l2_device_register(camss->dev, &camss->v4l2_dev);
4212 	if (ret < 0) {
4213 		dev_err(dev, "Failed to register V4L2 device: %d\n", ret);
4214 		goto err_media_device_cleanup;
4215 	}
4216 
4217 	v4l2_async_nf_init(&camss->notifier, &camss->v4l2_dev);
4218 
4219 	pm_runtime_enable(dev);
4220 
4221 	ret = camss_of_parse_ports(camss);
4222 	if (ret < 0)
4223 		goto err_v4l2_device_unregister;
4224 
4225 	ret = camss_register_entities(camss);
4226 	if (ret < 0)
4227 		goto err_v4l2_device_unregister;
4228 
4229 	ret = camss_link_entities(camss);
4230 	if (ret < 0)
4231 		goto err_register_subdevs;
4232 
4233 	ret = media_device_register(&camss->media_dev);
4234 	if (ret < 0) {
4235 		dev_err(dev, "Failed to register media device: %d\n", ret);
4236 		goto err_register_subdevs;
4237 	}
4238 
4239 	camss->notifier.ops = &camss_subdev_notifier_ops;
4240 	ret = v4l2_async_nf_register(&camss->notifier);
4241 	if (ret) {
4242 		dev_err(dev,
4243 			"Failed to register async subdev nodes: %d\n", ret);
4244 		goto err_media_device_unregister;
4245 	}
4246 
4247 	return 0;
4248 
4249 err_media_device_unregister:
4250 	media_device_unregister(&camss->media_dev);
4251 err_register_subdevs:
4252 	camss_unregister_entities(camss);
4253 err_v4l2_device_unregister:
4254 	v4l2_device_unregister(&camss->v4l2_dev);
4255 	v4l2_async_nf_cleanup(&camss->notifier);
4256 	pm_runtime_disable(dev);
4257 err_media_device_cleanup:
4258 	media_device_cleanup(&camss->media_dev);
4259 err_genpd_cleanup:
4260 	camss_genpd_cleanup(camss);
4261 
4262 	return ret;
4263 }
4264 
4265 void camss_delete(struct camss *camss)
4266 {
4267 	v4l2_device_unregister(&camss->v4l2_dev);
4268 	media_device_unregister(&camss->media_dev);
4269 	media_device_cleanup(&camss->media_dev);
4270 
4271 	pm_runtime_disable(camss->dev);
4272 }
4273 
4274 /*
4275  * camss_remove - Remove CAMSS platform device
4276  * @pdev: Pointer to CAMSS platform device
4277  *
4278  * Always returns 0.
4279  */
4280 static void camss_remove(struct platform_device *pdev)
4281 {
4282 	struct camss *camss = platform_get_drvdata(pdev);
4283 
4284 	v4l2_async_nf_unregister(&camss->notifier);
4285 	v4l2_async_nf_cleanup(&camss->notifier);
4286 	camss_unregister_entities(camss);
4287 
4288 	if (atomic_read(&camss->ref_count) == 0)
4289 		camss_delete(camss);
4290 
4291 	camss_genpd_cleanup(camss);
4292 }
4293 
4294 static const struct camss_resources msm8916_resources = {
4295 	.version = CAMSS_8x16,
4296 	.csiphy_res = csiphy_res_8x16,
4297 	.csid_res = csid_res_8x16,
4298 	.ispif_res = &ispif_res_8x16,
4299 	.vfe_res = vfe_res_8x16,
4300 	.csiphy_num = ARRAY_SIZE(csiphy_res_8x16),
4301 	.csid_num = ARRAY_SIZE(csid_res_8x16),
4302 	.vfe_num = ARRAY_SIZE(vfe_res_8x16),
4303 };
4304 
4305 static const struct camss_resources msm8953_resources = {
4306 	.version = CAMSS_8x53,
4307 	.icc_res = icc_res_8x53,
4308 	.icc_path_num = ARRAY_SIZE(icc_res_8x53),
4309 	.csiphy_res = csiphy_res_8x96,
4310 	.csid_res = csid_res_8x53,
4311 	.ispif_res = &ispif_res_8x53,
4312 	.vfe_res = vfe_res_8x53,
4313 	.csiphy_num = ARRAY_SIZE(csiphy_res_8x96),
4314 	.csid_num = ARRAY_SIZE(csid_res_8x53),
4315 	.vfe_num = ARRAY_SIZE(vfe_res_8x53),
4316 };
4317 
4318 static const struct camss_resources msm8996_resources = {
4319 	.version = CAMSS_8x96,
4320 	.csiphy_res = csiphy_res_8x96,
4321 	.csid_res = csid_res_8x96,
4322 	.ispif_res = &ispif_res_8x96,
4323 	.vfe_res = vfe_res_8x96,
4324 	.csiphy_num = ARRAY_SIZE(csiphy_res_8x96),
4325 	.csid_num = ARRAY_SIZE(csid_res_8x96),
4326 	.vfe_num = ARRAY_SIZE(vfe_res_8x96),
4327 };
4328 
4329 static const struct camss_resources qcm2290_resources = {
4330 	.version = CAMSS_2290,
4331 	.csiphy_res = csiphy_res_2290,
4332 	.csid_res = csid_res_2290,
4333 	.vfe_res = vfe_res_2290,
4334 	.icc_res = icc_res_2290,
4335 	.icc_path_num = ARRAY_SIZE(icc_res_2290),
4336 	.csiphy_num = ARRAY_SIZE(csiphy_res_2290),
4337 	.csid_num = ARRAY_SIZE(csid_res_2290),
4338 	.vfe_num = ARRAY_SIZE(vfe_res_2290),
4339 };
4340 
4341 static const struct camss_resources qcs8300_resources = {
4342 	.version = CAMSS_8300,
4343 	.pd_name = "top",
4344 	.csiphy_res = csiphy_res_8300,
4345 	.csid_res = csid_res_8775p,
4346 	.csid_wrapper_res = &csid_wrapper_res_sm8550,
4347 	.vfe_res = vfe_res_8775p,
4348 	.icc_res = icc_res_qcs8300,
4349 	.csiphy_num = ARRAY_SIZE(csiphy_res_8300),
4350 	.csid_num = ARRAY_SIZE(csid_res_8775p),
4351 	.vfe_num = ARRAY_SIZE(vfe_res_8775p),
4352 	.icc_path_num = ARRAY_SIZE(icc_res_qcs8300),
4353 };
4354 
4355 static const struct camss_resources sa8775p_resources = {
4356 	.version = CAMSS_8775P,
4357 	.pd_name = "top",
4358 	.csiphy_res = csiphy_res_8775p,
4359 	.csid_res = csid_res_8775p,
4360 	.csid_wrapper_res = &csid_wrapper_res_sm8550,
4361 	.vfe_res = vfe_res_8775p,
4362 	.icc_res = icc_res_sa8775p,
4363 	.csiphy_num = ARRAY_SIZE(csiphy_res_8775p),
4364 	.csid_num = ARRAY_SIZE(csid_res_8775p),
4365 	.vfe_num = ARRAY_SIZE(vfe_res_8775p),
4366 	.icc_path_num = ARRAY_SIZE(icc_res_sa8775p),
4367 };
4368 
4369 static const struct camss_resources sdm660_resources = {
4370 	.version = CAMSS_660,
4371 	.csiphy_res = csiphy_res_660,
4372 	.csid_res = csid_res_660,
4373 	.ispif_res = &ispif_res_660,
4374 	.vfe_res = vfe_res_660,
4375 	.csiphy_num = ARRAY_SIZE(csiphy_res_660),
4376 	.csid_num = ARRAY_SIZE(csid_res_660),
4377 	.vfe_num = ARRAY_SIZE(vfe_res_660),
4378 };
4379 
4380 static const struct camss_resources sdm670_resources = {
4381 	.version = CAMSS_845,
4382 	.csiphy_res = csiphy_res_670,
4383 	.csid_res = csid_res_670,
4384 	.vfe_res = vfe_res_670,
4385 	.csiphy_num = ARRAY_SIZE(csiphy_res_670),
4386 	.csid_num = ARRAY_SIZE(csid_res_670),
4387 	.vfe_num = ARRAY_SIZE(vfe_res_670),
4388 };
4389 
4390 static const struct camss_resources sdm845_resources = {
4391 	.version = CAMSS_845,
4392 	.pd_name = "top",
4393 	.csiphy_res = csiphy_res_845,
4394 	.csid_res = csid_res_845,
4395 	.vfe_res = vfe_res_845,
4396 	.csiphy_num = ARRAY_SIZE(csiphy_res_845),
4397 	.csid_num = ARRAY_SIZE(csid_res_845),
4398 	.vfe_num = ARRAY_SIZE(vfe_res_845),
4399 };
4400 
4401 static const struct camss_resources sm8250_resources = {
4402 	.version = CAMSS_8250,
4403 	.pd_name = "top",
4404 	.csiphy_res = csiphy_res_8250,
4405 	.csid_res = csid_res_8250,
4406 	.vfe_res = vfe_res_8250,
4407 	.icc_res = icc_res_sm8250,
4408 	.icc_path_num = ARRAY_SIZE(icc_res_sm8250),
4409 	.csiphy_num = ARRAY_SIZE(csiphy_res_8250),
4410 	.csid_num = ARRAY_SIZE(csid_res_8250),
4411 	.vfe_num = ARRAY_SIZE(vfe_res_8250),
4412 };
4413 
4414 static const struct camss_resources sc8280xp_resources = {
4415 	.version = CAMSS_8280XP,
4416 	.pd_name = "top",
4417 	.csiphy_res = csiphy_res_sc8280xp,
4418 	.csid_res = csid_res_sc8280xp,
4419 	.ispif_res = NULL,
4420 	.vfe_res = vfe_res_sc8280xp,
4421 	.icc_res = icc_res_sc8280xp,
4422 	.icc_path_num = ARRAY_SIZE(icc_res_sc8280xp),
4423 	.csiphy_num = ARRAY_SIZE(csiphy_res_sc8280xp),
4424 	.csid_num = ARRAY_SIZE(csid_res_sc8280xp),
4425 	.vfe_num = ARRAY_SIZE(vfe_res_sc8280xp),
4426 };
4427 
4428 static const struct camss_resources sc7280_resources = {
4429 	.version = CAMSS_7280,
4430 	.pd_name = "top",
4431 	.csiphy_res = csiphy_res_7280,
4432 	.csid_res = csid_res_7280,
4433 	.vfe_res = vfe_res_7280,
4434 	.icc_res = icc_res_sc7280,
4435 	.icc_path_num = ARRAY_SIZE(icc_res_sc7280),
4436 	.csiphy_num = ARRAY_SIZE(csiphy_res_7280),
4437 	.csid_num = ARRAY_SIZE(csid_res_7280),
4438 	.vfe_num = ARRAY_SIZE(vfe_res_7280),
4439 };
4440 
4441 static const struct camss_resources sm8550_resources = {
4442 	.version = CAMSS_8550,
4443 	.pd_name = "top",
4444 	.csiphy_res = csiphy_res_8550,
4445 	.csid_res = csid_res_8550,
4446 	.vfe_res = vfe_res_8550,
4447 	.csid_wrapper_res = &csid_wrapper_res_sm8550,
4448 	.icc_res = icc_res_sm8550,
4449 	.icc_path_num = ARRAY_SIZE(icc_res_sm8550),
4450 	.csiphy_num = ARRAY_SIZE(csiphy_res_8550),
4451 	.csid_num = ARRAY_SIZE(csid_res_8550),
4452 	.vfe_num = ARRAY_SIZE(vfe_res_8550),
4453 };
4454 
4455 static const struct camss_resources x1e80100_resources = {
4456 	.version = CAMSS_X1E80100,
4457 	.pd_name = "top",
4458 	.csiphy_res = csiphy_res_x1e80100,
4459 	.csid_res = csid_res_x1e80100,
4460 	.vfe_res = vfe_res_x1e80100,
4461 	.csid_wrapper_res = &csid_wrapper_res_x1e80100,
4462 	.icc_res = icc_res_x1e80100,
4463 	.icc_path_num = ARRAY_SIZE(icc_res_x1e80100),
4464 	.csiphy_num = ARRAY_SIZE(csiphy_res_x1e80100),
4465 	.csid_num = ARRAY_SIZE(csid_res_x1e80100),
4466 	.vfe_num = ARRAY_SIZE(vfe_res_x1e80100),
4467 };
4468 
4469 static const struct of_device_id camss_dt_match[] = {
4470 	{ .compatible = "qcom,msm8916-camss", .data = &msm8916_resources },
4471 	{ .compatible = "qcom,msm8953-camss", .data = &msm8953_resources },
4472 	{ .compatible = "qcom,msm8996-camss", .data = &msm8996_resources },
4473 	{ .compatible = "qcom,qcm2290-camss", .data = &qcm2290_resources },
4474 	{ .compatible = "qcom,qcs8300-camss", .data = &qcs8300_resources },
4475 	{ .compatible = "qcom,sa8775p-camss", .data = &sa8775p_resources },
4476 	{ .compatible = "qcom,sc7280-camss", .data = &sc7280_resources },
4477 	{ .compatible = "qcom,sc8280xp-camss", .data = &sc8280xp_resources },
4478 	{ .compatible = "qcom,sdm660-camss", .data = &sdm660_resources },
4479 	{ .compatible = "qcom,sdm670-camss", .data = &sdm670_resources },
4480 	{ .compatible = "qcom,sdm845-camss", .data = &sdm845_resources },
4481 	{ .compatible = "qcom,sm8250-camss", .data = &sm8250_resources },
4482 	{ .compatible = "qcom,sm8550-camss", .data = &sm8550_resources },
4483 	{ .compatible = "qcom,x1e80100-camss", .data = &x1e80100_resources },
4484 	{ }
4485 };
4486 
4487 MODULE_DEVICE_TABLE(of, camss_dt_match);
4488 
4489 static int __maybe_unused camss_runtime_suspend(struct device *dev)
4490 {
4491 	struct camss *camss = dev_get_drvdata(dev);
4492 	int i;
4493 	int ret;
4494 
4495 	for (i = 0; i < camss->res->icc_path_num; i++) {
4496 		ret = icc_set_bw(camss->icc_path[i], 0, 0);
4497 		if (ret)
4498 			return ret;
4499 	}
4500 
4501 	return 0;
4502 }
4503 
4504 static int __maybe_unused camss_runtime_resume(struct device *dev)
4505 {
4506 	struct camss *camss = dev_get_drvdata(dev);
4507 	const struct resources_icc *icc_res = camss->res->icc_res;
4508 	int i;
4509 	int ret;
4510 
4511 	for (i = 0; i < camss->res->icc_path_num; i++) {
4512 		ret = icc_set_bw(camss->icc_path[i],
4513 				 icc_res[i].icc_bw_tbl.avg,
4514 				 icc_res[i].icc_bw_tbl.peak);
4515 		if (ret)
4516 			return ret;
4517 	}
4518 
4519 	return 0;
4520 }
4521 
4522 static const struct dev_pm_ops camss_pm_ops = {
4523 	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
4524 				pm_runtime_force_resume)
4525 	SET_RUNTIME_PM_OPS(camss_runtime_suspend, camss_runtime_resume, NULL)
4526 };
4527 
4528 static struct platform_driver qcom_camss_driver = {
4529 	.probe = camss_probe,
4530 	.remove = camss_remove,
4531 	.driver = {
4532 		.name = "qcom-camss",
4533 		.of_match_table = camss_dt_match,
4534 		.pm = &camss_pm_ops,
4535 	},
4536 };
4537 
4538 module_platform_driver(qcom_camss_driver);
4539 
4540 MODULE_ALIAS("platform:qcom-camss");
4541 MODULE_DESCRIPTION("Qualcomm Camera Subsystem driver");
4542 MODULE_AUTHOR("Todor Tomov <todor.tomov@linaro.org>");
4543 MODULE_LICENSE("GPL v2");
4544