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-cam0 {
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-cam1 {
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 {
276	ports {
277		port@0 {
278			du_out_rgb: endpoint {
279				remote-endpoint = <&rgb_panel>;
280			};
281		};
282	};
283};
284
285&ehci0 {
286	dr_mode = "otg";
287	status = "okay";
288	clocks = <&cpg CPG_MOD 703>, <&cpg CPG_MOD 704>, <&usb2_clksel>, <&versaclock5 3>;
289};
290
291&ehci1 {
292	status = "okay";
293	clocks = <&cpg CPG_MOD 703>, <&cpg CPG_MOD 704>, <&usb2_clksel>, <&versaclock5 3>;
294};
295
296&hdmi0 {
297	status = "okay";
298	ports {
299		#address-cells = <1>;
300		#size-cells = <0>;
301		port@0 {
302			reg = <0>;
303			dw_hdmi0_in: endpoint {
304				remote-endpoint = <&du_out_hdmi0>;
305			};
306		};
307		port@1 {
308			reg = <1>;
309			rcar_dw_hdmi0_out: endpoint {
310				remote-endpoint = <&hdmi0_con>;
311			};
312		};
313		port@2 {
314			reg = <2>;
315			dw_hdmi0_snd_in: endpoint {
316				remote-endpoint = <&rsnd_endpoint1>;
317			};
318		};
319	};
320};
321
322&hscif1 {
323	pinctrl-0 = <&hscif1_pins>;
324	pinctrl-names = "default";
325	uart-has-rtscts;
326	status = "okay";
327};
328
329&hsusb {
330	dr_mode = "otg";
331	status = "okay";
332};
333
334&i2c2 {
335	status = "okay";
336	clock-frequency = <400000>;
337	pinctrl-0 = <&i2c2_pins>;
338	pinctrl-names = "default";
339
340	gpio_exp2: gpio@21 {
341		compatible = "onnn,pca9654";
342		reg = <0x21>;
343		gpio-controller;
344		#gpio-cells = <2>;
345	};
346
347	gpio_exp3: gpio@22 {
348		compatible = "onnn,pca9654";
349		reg = <0x22>;
350		gpio-controller;
351		#gpio-cells = <2>;
352	};
353
354	gpio_exp4: gpio@23 {
355		compatible = "onnn,pca9654";
356		reg = <0x23>;
357		gpio-controller;
358		#gpio-cells = <2>;
359	};
360
361	versaclock6_bb: clock-controller@6a {
362		compatible = "idt,5p49v6965";
363		reg = <0x6a>;
364		#clock-cells = <1>;
365		clocks = <&x304_clk>;
366		clock-names = "xin";
367
368		assigned-clocks = <&versaclock6_bb 1>, <&versaclock6_bb 2>,
369				  <&versaclock6_bb 3>, <&versaclock6_bb 4>;
370		assigned-clock-rates = <24000000>, <24000000>, <24000000>,
371				       <24576000>;
372
373		OUT1 {
374			idt,mode = <VC5_CMOS>;
375			idt,voltage-microvolt = <1800000>;
376			idt,slew-percent = <100>;
377		};
378
379		OUT2 {
380			idt,mode = <VC5_CMOS>;
381			idt,voltage-microvolt = <1800000>;
382			idt,slew-percent = <100>;
383		};
384
385		OUT3 {
386			idt,mode = <VC5_CMOS>;
387			idt,voltage-microvolt = <3300000>;
388			idt,slew-percent = <100>;
389		};
390
391		OUT4 {
392			idt,mode = <VC5_CMOS>;
393			idt,voltage-microvolt = <3300000>;
394			idt,slew-percent = <100>;
395		};
396	};
397};
398
399&i2c0 {
400	status = "okay";
401	clock-frequency = <400000>;
402
403	pinctrl-0 = <&i2c0_pins>;
404	pinctrl-names = "default";
405};
406
407&i2c5 {
408	status = "okay";
409	clock-frequency = <400000>;
410	pinctrl-0 = <&i2c5_pins>;
411	pinctrl-names = "default";
412
413	codec: wm8962@1a {
414		compatible = "wlf,wm8962";
415		reg = <0x1a>;
416		clocks = <&versaclock6_bb 3>;
417		DCVDD-supply = <&reg_audio>;
418		DBVDD-supply = <&reg_audio>;
419		AVDD-supply = <&reg_audio>;
420		CPVDD-supply = <&reg_audio>;
421		MICVDD-supply = <&reg_audio>;
422		PLLVDD-supply = <&reg_audio>;
423		SPKVDD1-supply = <&reg_audio>;
424		SPKVDD2-supply = <&reg_audio>;
425		gpio-cfg = <
426			0x0000 /* 0:Default */
427			0x0000 /* 1:Default */
428			0x0000 /* 2:Default */
429			0x0000 /* 3:Default */
430			0x0000 /* 4:Default */
431			0x0000 /* 5:Default */
432		>;
433		port {
434			wm8962_endpoint: endpoint {
435				remote-endpoint = <&rsnd_endpoint0>;
436			};
437		};
438	};
439
440	/* 0 - lcd_reset */
441	/* 1 - lcd_pwr */
442	/* 2 - lcd_select */
443	/* 3 - backlight-enable */
444	/* 4 - Touch_shdwn */
445	/* 5 - LCD_H_pol */
446	/* 6 - lcd_V_pol */
447	gpio_exp1: gpio@20 {
448		compatible = "onnn,pca9654";
449		reg = <0x20>;
450		gpio-controller;
451		#gpio-cells = <2>;
452	};
453
454	touchscreen@26 {
455		compatible = "ilitek,ili2117";
456		reg = <0x26>;
457		interrupt-parent = <&gpio5>;
458		interrupts = <9 IRQ_TYPE_EDGE_RISING>;
459		wakeup-source;
460	};
461
462	hd3ss3220@47 {
463		compatible = "ti,hd3ss3220";
464		reg = <0x47>;
465		interrupt-parent = <&gpio6>;
466		interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
467
468		ports {
469			#address-cells = <1>;
470			#size-cells = <0>;
471			port@0 {
472				reg = <0>;
473				hd3ss3220_in_ep: endpoint {
474					remote-endpoint = <&ss_ep>;
475				};
476			};
477			port@1 {
478				reg = <1>;
479				hd3ss3220_out_ep: endpoint {
480					remote-endpoint = <&usb3_role_switch>;
481				};
482			};
483		};
484	};
485};
486
487&lvds0 {
488	status = "okay";
489
490	ports {
491		port@1 {
492			lvds0_out: endpoint {
493				remote-endpoint = <&panel_in>;
494			};
495		};
496	};
497};
498
499&msiof1 {
500	pinctrl-0 = <&msiof1_pins>;
501	pinctrl-names = "default";
502	status = "okay";
503	cs-gpios = <&gpio3 10 GPIO_ACTIVE_LOW>;
504};
505
506&ohci0 {
507	dr_mode = "otg";
508	status = "okay";
509};
510
511&ohci1 {
512	status = "okay";
513};
514
515&pciec0 {
516	status = "okay";
517};
518
519&pciec1 {
520	status = "okay";
521};
522
523&pcie_bus_clk {
524	clock-frequency = <100000000>;
525};
526
527&pfc {
528	can0_pins: can0 {
529		groups = "can0_data_a";
530		function = "can0";
531	};
532
533	can1_pins: can1 {
534		groups = "can1_data";
535		function = "can1";
536	};
537
538	du_pins: du {
539		groups = "du_rgb888", "du_sync", "du_clk_out_1", "du_disp";
540		function = "du";
541	};
542
543	i2c2_pins: i2c2 {
544		groups = "i2c2_a";
545		function = "i2c2";
546	};
547
548	i2c5_pins: i2c5 {
549		groups = "i2c5";
550		function = "i2c5";
551	};
552
553	led_pins: leds {
554		/* GP_0_4 , AVS1, AVS2, GP_7_3 */
555		pins = "GP_0_4", "GP_7_0", "GP_7_1", "GP_7_3";
556		bias-pull-down;
557	};
558
559	msiof1_pins: msiof1 {
560		groups = "msiof1_clk_g", "msiof1_rxd_g", "msiof1_txd_g";
561		function = "msiof1";
562	};
563
564	pwm0_pins: pwm0 {
565		groups = "pwm0";
566		function = "pwm0";
567	};
568
569	pwm2_pins: pwm2 {
570		groups = "pwm2_a";
571		function = "pwm2";
572	};
573
574	sdhi0_pins: sd0 {
575		groups = "sdhi0_data4", "sdhi0_ctrl";
576		function = "sdhi0";
577		power-source = <3300>;
578	};
579
580	sdhi0_pins_uhs: sd0_uhs {
581		groups = "sdhi0_data4", "sdhi0_ctrl";
582		function = "sdhi0";
583		power-source = <1800>;
584	};
585
586	sound_pins: sound {
587		groups = "ssi01239_ctrl", "ssi0_data", "ssi1_data_a";
588		function = "ssi";
589	};
590
591	sound_clk_pins: sound_clk {
592		groups = "audio_clk_a_a", "audio_clk_b_a";
593		function = "audio_clk";
594	};
595
596	usb0_pins: usb0 {
597		mux {
598			groups = "usb0";
599			function = "usb0";
600		};
601	};
602
603	usb1_pins: usb1 {
604		mux {
605			groups = "usb1";
606			function = "usb1";
607		};
608	};
609
610	usb30_pins: usb30 {
611		mux {
612			groups = "usb30";
613			function = "usb30";
614		};
615	};
616};
617
618&pwm0 {
619	pinctrl-0 = <&pwm0_pins>;
620	pinctrl-names = "default";
621	status = "okay";
622};
623
624&pwm2 {
625	pinctrl-0 = <&pwm2_pins>;
626	pinctrl-names = "default";
627	status = "okay";
628};
629
630&rcar_sound {
631	pinctrl-0 = <&sound_pins>, <&sound_clk_pins>;
632	pinctrl-names = "default";
633
634	/* Single DAI */
635	#sound-dai-cells = <0>;
636
637	/* audio_clkout0/1/2/3 */
638	#clock-cells = <1>;
639	clock-frequency = <11289600>;
640
641	status = "okay";
642
643	ports {
644		#address-cells = <1>;
645		#size-cells = <0>;
646		rsnd_port0: port@0 {
647			reg = <0>;
648			rsnd_endpoint0: endpoint {
649				remote-endpoint = <&wm8962_endpoint>;
650
651				dai-format = "i2s";
652				bitclock-master = <&rsnd_endpoint0>;
653				frame-master = <&rsnd_endpoint0>;
654
655				playback = <&ssi1>, <&dvc1>, <&src1>;
656				capture = <&ssi0>;
657			};
658		};
659		rsnd_port1: port@1 {
660		    reg = <0x01>;
661			rsnd_endpoint1: endpoint {
662				remote-endpoint = <&dw_hdmi0_snd_in>;
663
664				dai-format = "i2s";
665				bitclock-master = <&rsnd_endpoint1>;
666				frame-master = <&rsnd_endpoint1>;
667
668				playback = <&ssi2>;
669			};
670		};
671	};
672};
673
674&rwdt {
675	status = "okay";
676	timeout-sec = <60>;
677};
678
679&scif0 {
680	pinctrl-0 = <&scif0_pins>;
681	pinctrl-names = "default";
682	status = "okay";
683};
684
685&scif5 {
686	pinctrl-0 = <&scif5_pins>;
687	pinctrl-names = "default";
688	status = "okay";
689};
690
691&scif_clk {
692	clock-frequency = <14745600>;
693};
694
695&sdhi0 {
696	pinctrl-0 = <&sdhi0_pins>;
697	pinctrl-1 = <&sdhi0_pins_uhs>;
698	pinctrl-names = "default", "state_uhs";
699	vmmc-supply = <&reg_3p3v>;
700	vqmmc-supply = <&vccq_sdhi0>;
701	cd-gpios = <&gpio3 12 GPIO_ACTIVE_LOW>;
702	bus-width = <4>;
703	sd-uhs-sdr50;
704	sd-uhs-sdr104;
705	status = "okay";
706};
707
708&ssi1 {
709	shared-pin;
710};
711
712&tmu0 {
713	status = "okay";
714};
715
716&tmu1 {
717	status = "okay";
718};
719
720&tmu2 {
721	status = "okay";
722};
723
724&tmu3 {
725	status = "okay";
726};
727
728&tmu4 {
729	status = "okay";
730};
731
732&usb2_phy0 {
733	pinctrl-0 = <&usb0_pins>;
734	pinctrl-names = "default";
735	status = "okay";
736};
737
738&usb2_phy1 {
739	pinctrl-0 = <&usb1_pins>;
740	pinctrl-names = "default";
741	status = "okay";
742};
743
744&usb3_peri0 {
745	companion = <&xhci0>;
746	status = "okay";
747	usb-role-switch;
748
749	ports {
750		#address-cells = <1>;
751		#size-cells = <0>;
752		port@0 {
753			reg = <0>;
754			usb3_hs_ep: endpoint {
755				remote-endpoint = <&hs_ep>;
756			};
757		};
758		port@1 {
759			reg = <1>;
760			usb3_role_switch: endpoint {
761				remote-endpoint = <&hd3ss3220_out_ep>;
762			};
763		};
764	};
765};
766
767&usb3_phy0 {
768	status = "okay";
769};
770
771&vin0 {
772	status = "okay";
773};
774&vin1 {
775	status = "okay";
776};
777&vin2 {
778	status = "okay";
779};
780&vin3 {
781	status = "okay";
782};
783&vin4 {
784	status = "okay";
785};
786&vin5 {
787	status = "okay";
788};
789&vin6 {
790	status = "okay";
791};
792&vin7 {
793	status = "okay";
794};
795
796&xhci0
797{
798	pinctrl-0 = <&usb30_pins>;
799	pinctrl-names = "default";
800	status = "okay";
801};
802