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