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