dtoverlays: Add option for cam0 to camera-mux-Nport overlays
[platform/kernel/linux-rpi.git] / arch / arm / boot / dts / overlays / camera-mux-2port-overlay.dts
1 // SPDX-License-Identifier: GPL-2.0-only
2 // Overlay to configure a 2 port camera multiplexer
3 //
4 // Configuration is based on the Arducam Doubleplexer
5 // which uses a PCA9543 I2C multiplexer to handle the
6 // I2C, and GPIO 4 to control the MIPI mux, and GPIO 17
7 // to enable the CSI-2 mux output (gpio-hog).
8
9 /dts-v1/;
10 /plugin/;
11
12 #include <dt-bindings/gpio/gpio.h>
13
14 /{
15         compatible = "brcm,bcm2835";
16
17         /* Fragments that complete the individual sensor fragments */
18         /* IMX290 */
19         fragment@0 {
20                 target = <&imx290_0_ep>;
21                 __overlay__ {
22                         data-lanes = <1 2>;
23                         link-frequencies =
24                                 /bits/ 64 <445500000 297000000>;
25                 };
26         };
27
28         fragment@1 {
29                 target = <&imx290_1_ep>;
30                 __overlay__ {
31                         data-lanes = <1 2>;
32                         link-frequencies =
33                                 /bits/ 64 <445500000 297000000>;
34                 };
35         };
36
37         /* IMX477 */
38         fragment@10 {
39                 target = <&imx477_0>;
40                 __overlay__ {
41                         compatible = "sony,imx477";
42                 };
43         };
44
45         fragment@11 {
46                 target = <&imx477_1>;
47                 __overlay__ {
48                         compatible = "sony,imx477";
49                 };
50         };
51
52         /* Additional fragments affecting the mux nodes */
53         fragment@100 {
54                 target = <&mux_in0>;
55                 __dormant__ {
56                         data-lanes = <1>;
57                 };
58         };
59         fragment@101 {
60                 target = <&mux_in0>;
61                 __overlay__ {
62                         data-lanes = <1 2>;
63                 };
64         };
65
66         fragment@102 {
67                 target = <&mux_in1>;
68                 __dormant__ {
69                         data-lanes = <1>;
70                 };
71         };
72         fragment@103 {
73                 target = <&mux_in1>;
74                 __overlay__ {
75                         data-lanes = <1 2>;
76                 };
77         };
78
79         /* Mux define */
80         i2c_frag: fragment@200 {
81                 target = <&i2c_csi_dsi>;
82                 __overlay__ {
83                         #address-cells = <1>;
84                         #size-cells = <0>;
85                         status = "okay";
86
87                         pca@70 {
88                                 reg = <0x70>;
89                                 compatible = "nxp,pca9543";
90
91                                 #address-cells = <1>;
92                                 #size-cells = <0>;
93
94                                 i2c@0 {
95                                         reg = <0>;
96                                         #address-cells = <1>;
97                                         #size-cells = <0>;
98
99                                         #define cam_node arducam_64mp_0
100                                         #define cam_endpoint arducam_64mp_0_ep
101                                         #define vcm_node arducam_64mp_0_vcm
102                                         #define cam1_clk clk_24mhz
103                                         #include "arducam-64mp.dtsi"
104                                         #undef cam_node
105                                         #undef cam_endpoint
106                                         #undef vcm_node
107                                         #undef cam1_clk
108
109                                         #define cam_node imx219_0
110                                         #define cam_endpoint imx219_0_ep
111                                         #define cam1_clk clk_24mhz
112                                         #include "imx219.dtsi"
113                                         #undef cam_node
114                                         #undef cam_endpoint
115                                         #undef cam1_clk
116
117                                         #define cam_node imx477_0
118                                         #define cam_endpoint imx477_0_ep
119                                         #define cam1_clk clk_24mhz
120                                         #include "imx477_378.dtsi"
121                                         #undef cam_node
122                                         #undef cam_endpoint
123                                         #undef cam1_clk
124
125                                         #define cam_node imx519_0
126                                         #define cam_endpoint imx519_0_ep
127                                         #define vcm_node imx519_0_vcm
128                                         #define cam1_clk clk_24mhz
129                                         #include "imx519.dtsi"
130                                         #undef cam_node
131                                         #undef cam_endpoint
132                                         #undef vcm_node
133                                         #undef cam1_clk
134
135                                         #define cam_node imx708_0
136                                         #define cam_endpoint imx708_0_ep
137                                         #define vcm_node imx708_0_vcm
138                                         #define cam1_clk clk_24mhz
139                                         #include "imx708.dtsi"
140                                         #undef cam_node
141                                         #undef cam_endpoint
142                                         #undef vcm_node
143                                         #undef cam1_clk
144
145                                         #define cam_node ov5647_0
146                                         #define cam_endpoint ov5647_0_ep
147                                         #define cam1_clk clk_25mhz
148                                         #include "ov5647.dtsi"
149                                         #undef cam_node
150                                         #undef cam_endpoint
151                                         #undef cam1_clk
152
153                                         #define cam_node ov7251_0
154                                         #define cam_endpoint ov7251_0_ep
155                                         #define cam1_clk clk_24mhz
156                                         #include "ov7251.dtsi"
157                                         #undef cam_node
158                                         #undef cam_endpoint
159                                         #undef cam1_clk
160
161                                         #define cam_node ov9281_0
162                                         #define cam_endpoint ov9281_0_ep
163                                         #define cam1_clk clk_24mhz
164                                         #include "ov9281.dtsi"
165                                         #undef cam_node
166                                         #undef cam_endpoint
167                                         #undef cam1_clk
168
169                                         #define cam_node imx258_0
170                                         #define cam_endpoint imx258_0_ep
171                                         #define cam1_clk clk_24mhz
172                                         #include "imx258.dtsi"
173                                         #undef cam_node
174                                         #undef cam_endpoint
175                                         #undef cam1_clk
176
177                                         #define cam_node imx290_0
178                                         #define cam_endpoint imx290_0_ep
179                                         #define cam1_clk clk_imx290
180                                         #include "imx290_327.dtsi"
181                                         #undef cam_node
182                                         #undef cam_endpoint
183                                         #undef cam1_clk
184
185                                         #define cam_node ov2311_0
186                                         #define cam_endpoint ov2311_0_ep
187                                         #define cam1_clk clk_24mhz
188                                         #include "ov2311.dtsi"
189                                         #undef cam_node
190                                         #undef cam_endpoint
191                                         #undef cam1_clk
192                                 };
193
194                                 i2c@1 {
195                                         reg = <1>;
196                                         #address-cells = <1>;
197                                         #size-cells = <0>;
198
199                                         #define cam_node arducam_64mp_1
200                                         #define cam_endpoint arducam_64mp_1_ep
201                                         #define vcm_node arducam_64mp_1_vcm
202                                         #define cam1_clk clk_24mhz
203                                         #include "arducam-64mp.dtsi"
204                                         #undef cam_node
205                                         #undef cam_endpoint
206                                         #undef vcm_node
207                                         #undef cam1_clk
208
209                                         #define cam_node imx219_1
210                                         #define cam_endpoint imx219_1_ep
211                                         #define cam1_clk clk_24mhz
212                                         #include "imx219.dtsi"
213                                         #undef cam_node
214                                         #undef cam_endpoint
215                                         #undef cam1_clk
216
217                                         #define cam_node imx477_1
218                                         #define cam_endpoint imx477_1_ep
219                                         #define cam1_clk clk_24mhz
220                                         #include "imx477_378.dtsi"
221                                         #undef cam_node
222                                         #undef cam_endpoint
223                                         #undef cam1_clk
224
225                                         #define cam_node imx519_1
226                                         #define cam_endpoint imx519_1_ep
227                                         #define vcm_node imx519_1_vcm
228                                         #define cam1_clk clk_24mhz
229                                         #include "imx519.dtsi"
230                                         #undef cam_node
231                                         #undef cam_endpoint
232                                         #undef vcm_node
233                                         #undef cam1_clk
234
235                                         #define cam_node imx708_1
236                                         #define cam_endpoint imx708_1_ep
237                                         #define vcm_node imx708_1_vcm
238                                         #define cam1_clk clk_24mhz
239                                         #include "imx708.dtsi"
240                                         #undef cam_node
241                                         #undef cam_endpoint
242                                         #undef vcm_node
243                                         #undef cam1_clk
244
245                                         #define cam_node ov5647_1
246                                         #define cam_endpoint ov5647_1_ep
247                                         #define cam1_clk clk_25mhz
248                                         #include "ov5647.dtsi"
249                                         #undef cam_node
250                                         #undef cam_endpoint
251                                         #undef cam1_clk
252
253                                         #define cam_node ov7251_1
254                                         #define cam_endpoint ov7251_1_ep
255                                         #define cam1_clk clk_24mhz
256                                         #include "ov7251.dtsi"
257                                         #undef cam_node
258                                         #undef cam_endpoint
259                                         #undef cam1_clk
260
261                                         #define cam_node ov9281_1
262                                         #define cam_endpoint ov9281_1_ep
263                                         #define cam1_clk clk_24mhz
264                                         #include "ov9281.dtsi"
265                                         #undef cam_node
266                                         #undef cam_endpoint
267                                         #undef cam1_clk
268
269                                         #define cam_node imx258_1
270                                         #define cam_endpoint imx258_1_ep
271                                         #define cam1_clk clk_24mhz
272                                         #include "imx258.dtsi"
273                                         #undef cam_node
274                                         #undef cam_endpoint
275                                         #undef cam1_clk
276
277                                         #define cam_node imx290_1
278                                         #define cam_endpoint imx290_1_ep
279                                         #define cam1_clk clk_imx290
280                                         #include "imx290_327.dtsi"
281                                         #undef cam_node
282                                         #undef cam_endpoint
283                                         #undef cam1_clk
284
285                                         #define cam_node ov2311_1
286                                         #define cam_endpoint ov2311_1_ep
287                                         #define cam1_clk clk_24mhz
288                                         #include "ov2311.dtsi"
289                                         #undef cam_node
290                                         #undef cam_endpoint
291                                         #undef cam1_clk
292                                 };
293                         };
294                 };
295         };
296
297         csi_frag: fragment@201 {
298                 target = <&csi1>;
299                 __overlay__ {
300                         status = "okay";
301
302                         brcm,media-controller;
303
304                         port {
305                                 csi1_ep: endpoint {
306                                         remote-endpoint = <&mux_out>;
307                                         clock-lanes = <0>;
308                                         data-lanes = <1 2>;
309                                 };
310                         };
311                 };
312         };
313
314         fragment@202 {
315                 target = <&i2c0if>;
316                 __overlay__ {
317                         status = "okay";
318                 };
319         };
320
321         fragment@203 {
322                 target-path="/";
323                 __overlay__ {
324                         mux: mux-controller {
325                                 compatible = "gpio-mux";
326                                 #mux-control-cells = <0>;
327
328                                 mux-gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
329                         };
330
331                         video-mux {
332                                 compatible = "video-mux";
333                                 mux-controls = <&mux>;
334                                 #address-cells = <1>;
335                                 #size-cells = <0>;
336
337                                 port@0 {
338                                         reg = <0>;
339
340                                         mux_in0: endpoint {
341                                                 clock-lanes = <0>;
342                                         };
343                                 };
344
345                                 port@1 {
346                                         reg = <1>;
347
348                                         mux_in1: endpoint {
349                                                 clock-lanes = <0>;
350                                         };
351                                 };
352
353                                 port@2 {
354                                         reg = <2>;
355
356                                         mux_out: endpoint {
357                                                 remote-endpoint = <&csi1_ep>;
358                                                 clock-lanes = <0>;
359                                         };
360                                 };
361                         };
362
363                         clk_24mhz: clk_24mhz {
364                                 compatible = "fixed-clock";
365                                 #clock-cells = <0>;
366
367                                 clock-frequency = <24000000>;
368                                 status = "okay";
369                         };
370
371                         clk_25mhz: clk_25mhz {
372                                 compatible = "fixed-clock";
373                                 #clock-cells = <0>;
374
375                                 clock-frequency = <25000000>;
376                                 status = "okay";
377                         };
378
379                         clk_imx290: clk_imx290 {
380                                 compatible = "fixed-clock";
381                                 #clock-cells = <0>;
382
383                                 clock-frequency = <37125000>;
384                                 status = "okay";
385                         };
386                 };
387         };
388
389         fragment@204 {
390                 target = <&i2c0mux>;
391                 __overlay__ {
392                         status = "okay";
393                 };
394         };
395
396         fragment@205 {
397                 target = <&gpio>;
398                 __overlay__ {
399                         mipi_sw_oe_hog {
400                                 gpio-hog;
401                                 gpios = <17 GPIO_ACTIVE_LOW>;
402                                 output-high;
403                         };
404                 };
405         };
406
407         __overrides__ {
408                 cam0-arducam-64mp = <&mux_in0>, "remote-endpoint:0=",<&arducam_64mp_0_ep>,
409                                     <&arducam_64mp_0_ep>, "remote-endpoint:0=",<&mux_in0>,
410                                     <&mux_in0>, "clock-noncontinuous?",
411                                     <&arducam_64mp_0>, "status=okay",
412                                     <&arducam_64mp_0_vcm>, "status=okay",
413                                     <&arducam_64mp_0>,"lens-focus:0=", <&arducam_64mp_0_vcm>;
414                 cam0-imx219 = <&mux_in0>, "remote-endpoint:0=",<&imx219_0_ep>,
415                               <&imx219_0_ep>, "remote-endpoint:0=",<&mux_in0>,
416                               <&mux_in0>, "clock-noncontinuous?",
417                               <&imx219_0>, "status=okay";
418                 cam0-imx477 = <&mux_in0>, "remote-endpoint:0=",<&imx477_0_ep>,
419                               <&imx477_0_ep>, "remote-endpoint:0=",<&mux_in0>,
420                               <&mux_in0>, "clock-noncontinuous?",
421                               <&imx477_0>, "status=okay";
422                 cam0-imx519 = <&mux_in0>, "remote-endpoint:0=",<&imx519_0_ep>,
423                               <&imx519_0_ep>, "remote-endpoint:0=",<&mux_in0>,
424                               <&mux_in0>, "clock-noncontinuous?",
425                               <&imx519_0>, "status=okay",
426                                   <&imx519_0_vcm>, "status=okay",
427                               <&imx519_0>,"lens-focus:0=", <&imx519_0_vcm>;
428                 cam0-imx708 = <&mux_in0>, "remote-endpoint:0=",<&imx708_0_ep>,
429                               <&imx708_0_ep>, "remote-endpoint:0=",<&mux_in0>,
430                               <&mux_in0>, "clock-noncontinuous?",
431                               <&imx708_0>, "status=okay",
432                               <&imx708_0_vcm>, "status=okay",
433                               <&imx708_0>,"lens-focus:0=", <&imx708_0_vcm>;
434                 cam0-ov5647 = <&mux_in0>, "remote-endpoint:0=",<&ov5647_0_ep>,
435                               <&ov5647_0_ep>, "remote-endpoint:0=",<&mux_in0>,
436                               <&ov5647_0>, "status=okay";
437                 cam0-ov7251 = <&mux_in0>, "remote-endpoint:0=",<&ov7251_0_ep>,
438                               <&ov7251_0_ep>, "remote-endpoint:0=",<&mux_in0>,
439                               <&ov7251_0>, "status=okay",
440                               <0>,"+100-101";
441                 cam0-ov9281 = <&mux_in0>, "remote-endpoint:0=",<&ov9281_0_ep>,
442                               <&ov9281_0_ep>, "remote-endpoint:0=",<&mux_in0>,
443                               <&ov9281_0>, "status=okay";
444                 cam0-imx258 = <&mux_in0>, "remote-endpoint:0=",<&imx258_0_ep>,
445                               <&imx258_0_ep>, "remote-endpoint:0=",<&mux_in0>,
446                               <&imx258_0>, "status=okay";
447                 cam0-imx290 = <&mux_in0>, "remote-endpoint:0=",<&imx290_0_ep>,
448                               <&imx290_0_ep>, "remote-endpoint:0=",<&mux_in0>,
449                               <&imx290_0>, "status=okay";
450                 cam0-ov2311 = <&mux_in0>, "remote-endpoint:0=",<&ov2311_0_ep>,
451                               <&ov2311_0_ep>, "remote-endpoint:0=",<&mux_in0>,
452                               <&ov2311_0>, "status=okay";
453
454                 cam1-arducam-64mp = <&mux_in1>, "remote-endpoint:0=",<&arducam_64mp_1_ep>,
455                                     <&arducam_64mp_1_ep>, "remote-endpoint:0=",<&mux_in1>,
456                                     <&mux_in1>, "clock-noncontinuous?",
457                                     <&arducam_64mp_1>, "status=okay",
458                                     <&arducam_64mp_1_vcm>, "status=okay",
459                                     <&arducam_64mp_1>,"lens-focus:0=", <&arducam_64mp_1_vcm>;
460                 cam1-imx219 = <&mux_in1>, "remote-endpoint:0=",<&imx219_1_ep>,
461                               <&imx219_1_ep>, "remote-endpoint:0=",<&mux_in1>,
462                               <&mux_in1>, "clock-noncontinuous?",
463                               <&imx219_1>, "status=okay";
464                 cam1-imx477 = <&mux_in1>, "remote-endpoint:0=",<&imx477_1_ep>,
465                               <&imx477_1_ep>, "remote-endpoint:0=",<&mux_in1>,
466                               <&mux_in1>, "clock-noncontinuous?",
467                               <&imx477_1>, "status=okay";
468                 cam1-imx519 = <&mux_in1>, "remote-endpoint:0=",<&imx519_1_ep>,
469                               <&imx519_1_ep>, "remote-endpoint:0=",<&mux_in1>,
470                               <&mux_in1>, "clock-noncontinuous?",
471                               <&imx519_1>, "status=okay",
472                               <&imx519_1_vcm>, "status=okay",
473                               <&imx519_1>,"lens-focus:0=", <&imx519_1_vcm>;
474                 cam1-imx708 = <&mux_in1>, "remote-endpoint:0=",<&imx708_1_ep>,
475                               <&imx708_1_ep>, "remote-endpoint:0=",<&mux_in1>,
476                               <&mux_in1>, "clock-noncontinuous?",
477                               <&imx708_1>, "status=okay",
478                               <&imx708_1_vcm>, "status=okay",
479                               <&imx708_1>,"lens-focus:0=", <&imx708_1_vcm>;
480                 cam1-ov5647 = <&mux_in1>, "remote-endpoint:0=",<&ov5647_1_ep>,
481                               <&ov5647_1_ep>, "remote-endpoint:0=",<&mux_in1>,
482                               <&ov5647_1>, "status=okay";
483                 cam1-ov7251 = <&mux_in1>, "remote-endpoint:0=",<&ov7251_1_ep>,
484                               <&ov7251_1_ep>, "remote-endpoint:0=",<&mux_in1>,
485                               <&ov7251_1>, "status=okay",
486                               <0>,"+102-103";
487                 cam1-ov9281 = <&mux_in1>, "remote-endpoint:0=",<&ov9281_1_ep>,
488                               <&ov9281_1_ep>, "remote-endpoint:0=",<&mux_in1>,
489                               <&ov9281_1>, "status=okay";
490                 cam1-imx258 = <&mux_in1>, "remote-endpoint:0=",<&imx258_1_ep>,
491                               <&imx258_1_ep>, "remote-endpoint:0=",<&mux_in1>,
492                               <&imx258_1>, "status=okay";
493                 cam1-imx290 = <&mux_in1>, "remote-endpoint:0=",<&imx290_1_ep>,
494                               <&imx290_1_ep>, "remote-endpoint:0=",<&mux_in1>,
495                               <&imx290_1>, "status=okay";
496                 cam1-ov2311 = <&mux_in1>, "remote-endpoint:0=",<&ov2311_1_ep>,
497                               <&ov2311_1_ep>, "remote-endpoint:0=",<&mux_in1>,
498                               <&ov2311_1>, "status=okay";
499
500                 cam0-imx290-clk-freq = <&clk_imx290>,"clock-frequency:0",
501                                        <&imx290_0>,"clock-frequency:0";
502                 cam1-imx290-clk-freq = <&clk_imx290>,"clock-frequency:0",
503                                        <&imx290_1>,"clock-frequency:0";
504
505                 cam0 = <&i2c_frag>, "target:0=",<&i2c_csi_dsi0>,
506                        <&csi_frag>, "target:0=",<&csi0>;
507         };
508 };