1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright 2020, Compass Electronics Group, LLC
4 */
5
6#include <dt-bindings/gpio/gpio.h>
7#include <dt-bindings/input/input.h>
8#include <dt-bindings/clk/versaclock.h>
9
10/ {
11	backlight_lvds: backlight-lvds {
12		compatible = "pwm-backlight";
13		power-supply = <&reg_lcd>;
14		enable-gpios = <&gpio_exp1 3 GPIO_ACTIVE_HIGH>;
15		pwms = <&pwm2 0 25000>;
16		brightness-levels = <0 4 8 16 32 64 128 255>;
17		default-brightness-level = <6>;
18	};
19
20	backlight_dpi: backlight-dpi {
21		compatible = "pwm-backlight";
22		power-supply = <&reg_lcd>;
23		enable-gpios = <&gpio_exp1 7 GPIO_ACTIVE_LOW>;
24		pwms = <&pwm0 0 25000>;
25		brightness-levels = <0 25 33 50 63 75 88 100>;
26		default-brightness-level = <6>;
27	};
28
29	hdmi0-out {
30		compatible = "hdmi-connector";
31		type = "a";
32
33		port {
34			hdmi0_con: endpoint {
35				remote-endpoint = <&rcar_dw_hdmi0_out>;
36			};
37		};
38	};
39
40	keys {
41		compatible = "gpio-keys";
42
43		key-1 { /* S19 */
44			gpios = <&gpio4 6 GPIO_ACTIVE_LOW>;
45			linux,code = <KEY_UP>;
46			label = "Up";
47			wakeup-source;
48			debounce-interval = <20>;
49		};
50		key-2 { /*S20 */
51			gpios = <&gpio3 13 GPIO_ACTIVE_LOW>;
52			linux,code = <KEY_LEFT>;
53			label = "Left";
54			wakeup-source;
55			debounce-interval = <20>;
56		};
57		key-3 { /* S21 */
58			gpios = <&gpio5 17 GPIO_ACTIVE_LOW>;
59			linux,code = <KEY_DOWN>;
60			label = "Down";
61			wakeup-source;
62			debounce-interval = <20>;
63		};
64		key-4 { /* S22 */
65			gpios = <&gpio5 20 GPIO_ACTIVE_LOW>;
66			linux,code = <KEY_RIGHT>;
67			label = "Right";
68			wakeup-source;
69			debounce-interval = <20>;
70		};
71		key-5 { /* S23 */
72			gpios = <&gpio5 22 GPIO_ACTIVE_LOW>;
73			linux,code = <KEY_ENTER>;
74			label = "Center";
75			wakeup-source;
76			debounce-interval = <20>;
77		};
78	};
79
80	leds {
81		compatible = "gpio-leds";
82		pinctrl-0 = <&led_pins>;
83		pinctrl-names = "default";
84
85		led0 {
86			gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
87			label = "LED0";
88			linux,default-trigger = "heartbeat";
89		};
90		led1 {
91			gpios = <&gpio7 0 GPIO_ACTIVE_HIGH>;
92			label = "LED1";
93		};
94		led2 {
95			gpios = <&gpio7 1 GPIO_ACTIVE_HIGH>;
96			label = "LED2";
97		};
98		led3 {
99			gpios = <&gpio7 3 GPIO_ACTIVE_HIGH>;
100			label = "LED3";
101		};
102	};
103
104	lvds {
105		compatible = "panel-lvds";
106		power-supply = <&reg_lcd_reset>;
107		width-mm = <223>;
108		height-mm = <125>;
109		backlight = <&backlight_lvds>;
110		data-mapping = "vesa-24";
111
112		panel-timing {
113			/* 800x480@60Hz */
114			clock-frequency = <30000000>;
115			hactive = <800>;
116			vactive = <480>;
117			hsync-len = <48>;
118			hfront-porch = <40>;
119			hback-porch = <40>;
120			vfront-porch = <13>;
121			vback-porch = <29>;
122			vsync-len = <1>;
123			hsync-active = <1>;
124			vsync-active = <3>;
125			de-active = <1>;
126			pixelclk-active = <0>;
127		};
128
129		port {
130			panel_in: endpoint {
131				remote-endpoint = <&lvds0_out>;
132			};
133		};
134	};
135
136	rgb {
137		/* Different LCD with compatible timings */
138		compatible = "rocktech,rk070er9427";
139		backlight = <&backlight_dpi>;
140		enable-gpios = <&gpio1 21 GPIO_ACTIVE_HIGH>;
141		power-supply = <&reg_lcd>;
142		port {
143			rgb_panel: endpoint {
144				remote-endpoint = <&du_out_rgb>;
145			};
146		};
147	};
148
149	reg_audio: regulator_audio {
150		compatible = "regulator-fixed";
151		regulator-name = "audio-1.8V";
152		regulator-min-microvolt = <1800000>;
153		regulator-max-microvolt = <1800000>;
154		gpio = <&gpio_exp4 1 GPIO_ACTIVE_HIGH>;
155		enable-active-high;
156	};
157
158	reg_lcd: regulator-lcd {
159		compatible = "regulator-fixed";
160		regulator-name = "lcd_panel_pwr";
161		regulator-min-microvolt = <3300000>;
162		regulator-max-microvolt = <3300000>;
163		gpio = <&gpio_exp1 1 GPIO_ACTIVE_HIGH>;
164		enable-active-high;
165	};
166
167	reg_lcd_reset: regulator-lcd-reset {
168		compatible = "regulator-fixed";
169		regulator-name = "nLCD_RESET";
170		regulator-min-microvolt = <3300000>;
171		regulator-max-microvolt = <3300000>;
172		gpio = <&gpio5 3 GPIO_ACTIVE_HIGH>;
173		enable-active-high;
174		vin-supply = <&reg_lcd>;
175	};
176
177	reg_cam0: regulator_camera {
178		compatible = "regulator-fixed";
179		regulator-name = "reg_cam0";
180		regulator-min-microvolt = <1800000>;
181		regulator-max-microvolt = <1800000>;
182		gpio = <&gpio_exp2 2 GPIO_ACTIVE_HIGH>;
183		enable-active-high;
184	};
185
186	reg_cam1: regulator_camera {
187		compatible = "regulator-fixed";
188		regulator-name = "reg_cam1";
189		regulator-min-microvolt = <1800000>;
190		regulator-max-microvolt = <1800000>;
191		gpio = <&gpio_exp2 5 GPIO_ACTIVE_HIGH>;
192		enable-active-high;
193		startup-delay-us = <100000>;
194	};
195
196	sound_card {
197		compatible = "audio-graph-card";
198		label = "rcar-sound";
199		dais = <&rsnd_port0>, <&rsnd_port1>;
200		widgets = "Microphone", "Mic Jack",
201			  "Line", "Line In Jack",
202			  "Headphone", "Headphone Jack";
203		mic-det-gpio = <&gpio0 2 GPIO_ACTIVE_LOW>;
204		routing = "Headphone Jack", "HPOUTL",
205			 "Headphone Jack", "HPOUTR",
206			 "IN3R", "MICBIAS",
207			 "Mic Jack", "IN3R";
208	};
209
210	vccq_sdhi0: regulator-vccq-sdhi0 {
211		compatible = "regulator-gpio";
212		regulator-name = "SDHI0 VccQ";
213		regulator-min-microvolt = <1800000>;
214		regulator-max-microvolt = <3300000>;
215		gpios = <&gpio6 30 GPIO_ACTIVE_HIGH>;
216		gpios-states = <1>;
217		states = <3300000 1>, <1800000 0>;
218	};
219
220	/* External DU dot clocks */
221	x302_clk: x302-clock {
222		compatible = "fixed-clock";
223		#clock-cells = <0>;
224		clock-frequency = <33000000>;
225	};
226
227	x304_clk: x304-clock {
228		compatible = "fixed-clock";
229		#clock-cells = <0>;
230		clock-frequency = <25000000>;
231	};
232
233	connector {
234		compatible = "usb-c-connector";
235		label = "USB-C";
236		data-role = "dual";
237
238		ports {
239			#address-cells = <1>;
240			#size-cells = <0>;
241			port@0 {
242				reg = <0>;
243				hs_ep: endpoint {
244					remote-endpoint = <&usb3_hs_ep>;
245				};
246			};
247			port@1 {
248				reg = <1>;
249				ss_ep: endpoint {
250					remote-endpoint = <&hd3ss3220_in_ep>;
251				};
252			};
253		};
254	};
255};
256
257&audio_clk_b {
258	clock-frequency = <22579200>;
259};
260
261&can0 {
262	pinctrl-0 = <&can0_pins>;
263	pinctrl-names = "default";
264	renesas,can-clock-select = <0x0>;
265	status = "okay";
266};
267
268&can1 {
269	pinctrl-0 = <&can1_pins>;
270	pinctrl-names = "default";
271	renesas,can-clock-select = <0x0>;
272	status = "okay";
273};
274
275&du_out_rgb {
276	remote-endpoint = <&rgb_panel>;
277};
278
279&ehci0 {
280	dr_mode = "otg";
281	status = "okay";
282	clocks = <&cpg CPG_MOD 703>, <&cpg CPG_MOD 704>, <&usb2_clksel>, <&versaclock5 3>;
283};
284
285&ehci1 {
286	status = "okay";
287	clocks = <&cpg CPG_MOD 703>, <&cpg CPG_MOD 704>, <&usb2_clksel>, <&versaclock5 3>;
288};
289
290&hdmi0 {
291	status = "okay";
292	ports {
293		#address-cells = <1>;
294		#size-cells = <0>;
295		port@0 {
296			reg = <0>;
297			dw_hdmi0_in: endpoint {
298				remote-endpoint = <&du_out_hdmi0>;
299			};
300		};
301		port@1 {
302			reg = <1>;
303			rcar_dw_hdmi0_out: endpoint {
304				remote-endpoint = <&hdmi0_con>;
305			};
306		};
307		port@2 {
308			reg = <2>;
309			dw_hdmi0_snd_in: endpoint {
310				remote-endpoint = <&rsnd_endpoint1>;
311			};
312		};
313	};
314};
315
316&hscif1 {
317	pinctrl-0 = <&hscif1_pins>;
318	pinctrl-names = "default";
319	uart-has-rtscts;
320	status = "okay";
321};
322
323&hsusb {
324	dr_mode = "otg";
325	status = "okay";
326};
327
328&i2c2 {
329	status = "okay";
330	clock-frequency = <400000>;
331	pinctrl-0 = <&i2c2_pins>;
332	pinctrl-names = "default";
333
334	gpio_exp2: gpio@21 {
335		compatible = "onnn,pca9654";
336		reg = <0x21>;
337		gpio-controller;
338		#gpio-cells = <2>;
339	};
340
341	gpio_exp3: gpio@22 {
342		compatible = "onnn,pca9654";
343		reg = <0x22>;
344		gpio-controller;
345		#gpio-cells = <2>;
346	};
347
348	gpio_exp4: gpio@23 {
349		compatible = "onnn,pca9654";
350		reg = <0x23>;
351		gpio-controller;
352		#gpio-cells = <2>;
353	};
354
355	versaclock6_bb: clock-controller@6a {
356		compatible = "idt,5p49v6965";
357		reg = <0x6a>;
358		#clock-cells = <1>;
359		clocks = <&x304_clk>;
360		clock-names = "xin";
361
362		assigned-clocks = <&versaclock6_bb 1>, <&versaclock6_bb 2>,
363				  <&versaclock6_bb 3>, <&versaclock6_bb 4>;
364		assigned-clock-rates = <24000000>, <24000000>, <24000000>,
365				       <24576000>;
366
367		OUT1 {
368			idt,mode = <VC5_CMOS>;
369			idt,voltage-microvolt = <1800000>;
370			idt,slew-percent = <100>;
371		};
372
373		OUT2 {
374			idt,mode = <VC5_CMOS>;
375			idt,voltage-microvolt = <1800000>;
376			idt,slew-percent = <100>;
377		};
378
379		OUT3 {
380			idt,mode = <VC5_CMOS>;
381			idt,voltage-microvolt = <3300000>;
382			idt,slew-percent = <100>;
383		};
384
385		OUT4 {
386			idt,mode = <VC5_CMOS>;
387			idt,voltage-microvolt = <3300000>;
388			idt,slew-percent = <100>;
389		};
390	};
391};
392
393&i2c0 {
394	status = "okay";
395	clock-frequency = <400000>;
396
397	pinctrl-0 = <&i2c0_pins>;
398	pinctrl-names = "default";
399};
400
401&i2c5 {
402	status = "okay";
403	clock-frequency = <400000>;
404	pinctrl-0 = <&i2c5_pins>;
405	pinctrl-names = "default";
406
407	codec: wm8962@1a {
408		compatible = "wlf,wm8962";
409		reg = <0x1a>;
410		clocks = <&versaclock6_bb 3>;
411		DCVDD-supply = <&reg_audio>;
412		DBVDD-supply = <&reg_audio>;
413		AVDD-supply = <&reg_audio>;
414		CPVDD-supply = <&reg_audio>;
415		MICVDD-supply = <&reg_audio>;
416		PLLVDD-supply = <&reg_audio>;
417		SPKVDD1-supply = <&reg_audio>;
418		SPKVDD2-supply = <&reg_audio>;
419		gpio-cfg = <
420			0x0000 /* 0:Default */
421			0x0000 /* 1:Default */
422			0x0000 /* 2:Default */
423			0x0000 /* 3:Default */
424			0x0000 /* 4:Default */
425			0x0000 /* 5:Default */
426		>;
427		port {
428			wm8962_endpoint: endpoint {
429				remote-endpoint = <&rsnd_endpoint0>;
430			};
431		};
432	};
433
434	/* 0 - lcd_reset */
435	/* 1 - lcd_pwr */
436	/* 2 - lcd_select */
437	/* 3 - backlight-enable */
438	/* 4 - Touch_shdwn */
439	/* 5 - LCD_H_pol */
440	/* 6 - lcd_V_pol */
441	gpio_exp1: gpio@20 {
442		compatible = "onnn,pca9654";
443		reg = <0x20>;
444		gpio-controller;
445		#gpio-cells = <2>;
446	};
447
448	touchscreen@26 {
449		compatible = "ilitek,ili2117";
450		reg = <0x26>;
451		interrupt-parent = <&gpio5>;
452		interrupts = <9 IRQ_TYPE_EDGE_RISING>;
453		wakeup-source;
454	};
455
456	hd3ss3220@47 {
457		compatible = "ti,hd3ss3220";
458		reg = <0x47>;
459		interrupt-parent = <&gpio6>;
460		interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
461
462		ports {
463			#address-cells = <1>;
464			#size-cells = <0>;
465			port@0 {
466				reg = <0>;
467				hd3ss3220_in_ep: endpoint {
468					remote-endpoint = <&ss_ep>;
469				};
470			};
471			port@1 {
472				reg = <1>;
473				hd3ss3220_out_ep: endpoint {
474					remote-endpoint = <&usb3_role_switch>;
475				};
476			};
477		};
478	};
479};
480
481&lvds0 {
482	status = "okay";
483
484	ports {
485		port@1 {
486			lvds0_out: endpoint {
487				remote-endpoint = <&panel_in>;
488			};
489		};
490	};
491};
492
493&msiof1 {
494	pinctrl-0 = <&msiof1_pins>;
495	pinctrl-names = "default";
496	status = "okay";
497	cs-gpios = <&gpio3 10 GPIO_ACTIVE_LOW>;
498};
499
500&ohci0 {
501	dr_mode = "otg";
502	status = "okay";
503};
504
505&ohci1 {
506	status = "okay";
507};
508
509&pciec0 {
510	status = "okay";
511};
512
513&pciec1 {
514	status = "okay";
515};
516
517&pcie_bus_clk {
518	clock-frequency = <100000000>;
519};
520
521&pfc {
522	can0_pins: can0 {
523		groups = "can0_data_a";
524		function = "can0";
525	};
526
527	can1_pins: can1 {
528		groups = "can1_data";
529		function = "can1";
530	};
531
532	du_pins: du {
533		groups = "du_rgb888", "du_sync", "du_clk_out_1", "du_disp";
534		function = "du";
535	};
536
537	i2c2_pins: i2c2 {
538		groups = "i2c2_a";
539		function = "i2c2";
540	};
541
542	i2c5_pins: i2c5 {
543		groups = "i2c5";
544		function = "i2c5";
545	};
546
547	led_pins: leds {
548		/* GP_0_4 , AVS1, AVS2, GP_7_3 */
549		pins = "GP_0_4", "GP_7_0", "GP_7_1", "GP_7_3";
550		bias-pull-down;
551	};
552
553	msiof1_pins: msiof1 {
554		groups = "msiof1_clk_g", "msiof1_rxd_g", "msiof1_txd_g";
555		function = "msiof1";
556	};
557
558	pwm0_pins: pwm0 {
559		groups = "pwm0";
560		function = "pwm0";
561	};
562
563	pwm2_pins: pwm2 {
564		groups = "pwm2_a";
565		function = "pwm2";
566	};
567
568	sdhi0_pins: sd0 {
569		groups = "sdhi0_data4", "sdhi0_ctrl";
570		function = "sdhi0";
571		power-source = <3300>;
572	};
573
574	sdhi0_pins_uhs: sd0_uhs {
575		groups = "sdhi0_data4", "sdhi0_ctrl";
576		function = "sdhi0";
577		power-source = <1800>;
578	};
579
580	sound_pins: sound {
581		groups = "ssi01239_ctrl", "ssi0_data", "ssi1_data_a";
582		function = "ssi";
583	};
584
585	sound_clk_pins: sound_clk {
586		groups = "audio_clk_a_a", "audio_clk_b_a";
587		function = "audio_clk";
588	};
589
590	usb0_pins: usb0 {
591		mux {
592			groups = "usb0";
593			function = "usb0";
594		};
595	};
596
597	usb1_pins: usb1 {
598		mux {
599			groups = "usb1";
600			function = "usb1";
601		};
602	};
603
604	usb30_pins: usb30 {
605		mux {
606			groups = "usb30";
607			function = "usb30";
608		};
609	};
610};
611
612&pwm0 {
613	pinctrl-0 = <&pwm0_pins>;
614	pinctrl-names = "default";
615	status = "okay";
616};
617
618&pwm2 {
619	pinctrl-0 = <&pwm2_pins>;
620	pinctrl-names = "default";
621	status = "okay";
622};
623
624&rcar_sound {
625	pinctrl-0 = <&sound_pins>, <&sound_clk_pins>;
626	pinctrl-names = "default";
627
628	/* Single DAI */
629	#sound-dai-cells = <0>;
630
631	/* audio_clkout0/1/2/3 */
632	#clock-cells = <1>;
633	clock-frequency = <11289600>;
634
635	status = "okay";
636
637	ports {
638		#address-cells = <1>;
639		#size-cells = <0>;
640		rsnd_port0: port@0 {
641			reg = <0>;
642			rsnd_endpoint0: endpoint {
643				remote-endpoint = <&wm8962_endpoint>;
644
645				dai-format = "i2s";
646				bitclock-master = <&rsnd_endpoint0>;
647				frame-master = <&rsnd_endpoint0>;
648
649				playback = <&ssi1>, <&dvc1>, <&src1>;
650				capture = <&ssi0>;
651			};
652		};
653		rsnd_port1: port@1 {
654		    reg = <0x01>;
655			rsnd_endpoint1: endpoint {
656				remote-endpoint = <&dw_hdmi0_snd_in>;
657
658				dai-format = "i2s";
659				bitclock-master = <&rsnd_endpoint1>;
660				frame-master = <&rsnd_endpoint1>;
661
662				playback = <&ssi2>;
663			};
664		};
665	};
666};
667
668&rwdt {
669	status = "okay";
670	timeout-sec = <60>;
671};
672
673&scif0 {
674	pinctrl-0 = <&scif0_pins>;
675	pinctrl-names = "default";
676	status = "okay";
677};
678
679&scif5 {
680	pinctrl-0 = <&scif5_pins>;
681	pinctrl-names = "default";
682	status = "okay";
683};
684
685&scif_clk {
686	clock-frequency = <14745600>;
687};
688
689&sdhi0 {
690	pinctrl-0 = <&sdhi0_pins>;
691	pinctrl-1 = <&sdhi0_pins_uhs>;
692	pinctrl-names = "default", "state_uhs";
693	vmmc-supply = <&reg_3p3v>;
694	vqmmc-supply = <&vccq_sdhi0>;
695	cd-gpios = <&gpio3 12 GPIO_ACTIVE_LOW>;
696	bus-width = <4>;
697	sd-uhs-sdr50;
698	sd-uhs-sdr104;
699	status = "okay";
700};
701
702&ssi1 {
703	shared-pin;
704};
705
706&tmu0 {
707	status = "okay";
708};
709
710&tmu1 {
711	status = "okay";
712};
713
714&tmu2 {
715	status = "okay";
716};
717
718&tmu3 {
719	status = "okay";
720};
721
722&tmu4 {
723	status = "okay";
724};
725
726&usb2_phy0 {
727	pinctrl-0 = <&usb0_pins>;
728	pinctrl-names = "default";
729	status = "okay";
730};
731
732&usb2_phy1 {
733	pinctrl-0 = <&usb1_pins>;
734	pinctrl-names = "default";
735	status = "okay";
736};
737
738&usb3_peri0 {
739	companion = <&xhci0>;
740	status = "okay";
741	usb-role-switch;
742
743	ports {
744		#address-cells = <1>;
745		#size-cells = <0>;
746		port@0 {
747			reg = <0>;
748			usb3_hs_ep: endpoint {
749				remote-endpoint = <&hs_ep>;
750			};
751		};
752		port@1 {
753			reg = <1>;
754			usb3_role_switch: endpoint {
755				remote-endpoint = <&hd3ss3220_out_ep>;
756			};
757		};
758	};
759};
760
761&usb3_phy0 {
762	status = "okay";
763};
764
765&vin0 {
766	status = "okay";
767};
768&vin1 {
769	status = "okay";
770};
771&vin2 {
772	status = "okay";
773};
774&vin3 {
775	status = "okay";
776};
777&vin4 {
778	status = "okay";
779};
780&vin5 {
781	status = "okay";
782};
783&vin6 {
784	status = "okay";
785};
786&vin7 {
787	status = "okay";
788};
789
790&xhci0
791{
792	pinctrl-0 = <&usb30_pins>;
793	pinctrl-names = "default";
794	status = "okay";
795};
796