1// SPDX-License-Identifier: GPL-2.0
2/dts-v1/;
3
4#include "jz4770.dtsi"
5#include <dt-bindings/clock/ingenic,tcu.h>
6
7#include <dt-bindings/gpio/gpio.h>
8#include <dt-bindings/iio/adc/ingenic,adc.h>
9#include <dt-bindings/input/input.h>
10
11/ {
12	compatible = "gcw,zero", "ingenic,jz4770";
13	model = "GCW Zero";
14
15	aliases {
16		serial0 = &uart0;
17		serial1 = &uart1;
18		serial2 = &uart2;
19		serial3 = &uart3;
20	};
21
22	memory: memory {
23		device_type = "memory";
24		reg = <0x0 0x10000000>,
25		      <0x30000000 0x10000000>;
26	};
27
28	chosen {
29		stdout-path = "serial2:57600n8";
30	};
31
32	vcc: regulator@0 {
33		compatible = "regulator-fixed";
34		regulator-name = "vcc";
35
36		regulator-min-microvolt = <3300000>;
37		regulator-max-microvolt = <3300000>;
38		regulator-always-on;
39	};
40
41	mmc1_power: regulator@1 {
42		compatible = "regulator-fixed";
43		regulator-name = "mmc1_vcc";
44		gpio = <&gpe 9 0>;
45
46		regulator-min-microvolt = <3300000>;
47		regulator-max-microvolt = <3300000>;
48		vin-supply = <&vcc>;
49	};
50
51	headphones_amp: analog-amplifier@0 {
52		compatible = "simple-audio-amplifier";
53		enable-gpios = <&gpf 3 GPIO_ACTIVE_LOW>;
54		enable-delay-ms = <50>;
55
56		VCC-supply = <&ldo5>;
57		sound-name-prefix = "Headphones Amp";
58	};
59
60	speaker_amp: analog-amplifier@1 {
61		compatible = "simple-audio-amplifier";
62		enable-gpios = <&gpf 20 GPIO_ACTIVE_HIGH>;
63
64		VCC-supply = <&ldo5>;
65		sound-name-prefix = "Speaker Amp";
66	};
67
68	sound {
69		compatible = "simple-audio-card";
70
71		simple-audio-card,name = "gcw0-audio";
72		simple-audio-card,format = "i2s";
73
74		simple-audio-card,widgets =
75			"Speaker", "Speaker",
76			"Headphone", "Headphones",
77			"Line", "FM Radio",
78			"Microphone", "Built-in Mic";
79		simple-audio-card,routing =
80			"Headphones Amp INL", "LHPOUT",
81			"Headphones Amp INR", "RHPOUT",
82			"Headphones", "Headphones Amp OUTL",
83			"Headphones", "Headphones Amp OUTR",
84			"Speaker Amp INL", "LOUT",
85			"Speaker Amp INR", "ROUT",
86			"Speaker", "Speaker Amp OUTL",
87			"Speaker", "Speaker Amp OUTR",
88			"LLINEIN", "FM Radio",
89			"RLINEIN", "FM Radio",
90			"Built-in Mic", "MICBIAS",
91			"MIC1P", "Built-in Mic",
92			"MIC1N", "Built-in Mic";
93		simple-audio-card,pin-switches = "Speaker", "Headphones";
94
95		simple-audio-card,hp-det-gpio = <&gpf 21 GPIO_ACTIVE_LOW>;
96		simple-audio-card,aux-devs = <&speaker_amp>, <&headphones_amp>;
97
98		simple-audio-card,bitclock-master = <&dai_codec>;
99		simple-audio-card,frame-master = <&dai_codec>;
100
101		dai_cpu: simple-audio-card,cpu {
102			sound-dai = <&aic>;
103		};
104
105		dai_codec: simple-audio-card,codec {
106			sound-dai = <&codec>;
107		};
108	};
109
110	rumble {
111		compatible = "pwm-vibrator";
112		pwms = <&pwm 4 2000000 0>;
113		pwm-names = "enable";
114
115		pinctrl-names = "default";
116		pinctrl-0 = <&pins_pwm4>;
117	};
118
119	backlight: backlight {
120		compatible = "pwm-backlight";
121		pwms = <&pwm 1 40000 0>;
122		power-supply = <&vcc>;
123
124		brightness-levels = <0 16 32 48 64 80 96 112 128
125				     144 160 176 192 208 224 240 255>;
126		default-brightness-level = <12>;
127
128		pinctrl-names = "default";
129		pinctrl-0 = <&pins_pwm1>;
130	};
131
132	gpio-keys {
133		compatible = "gpio-keys";
134		#address-cells = <1>;
135		#size-cells = <0>;
136
137		autorepeat;
138
139		button@0 {
140			label = "D-pad up";
141			linux,code = <KEY_UP>;
142			linux,can-disable;
143			gpios = <&gpe 21 GPIO_ACTIVE_LOW>;
144		};
145
146		button@1 {
147			label = "D-pad down";
148			linux,code = <KEY_DOWN>;
149			linux,can-disable;
150			gpios = <&gpe 25 GPIO_ACTIVE_LOW>;
151		};
152
153		button@2 {
154			label = "D-pad left";
155			linux,code = <KEY_LEFT>;
156			linux,can-disable;
157			gpios = <&gpe 23 GPIO_ACTIVE_LOW>;
158		};
159
160		button@3 {
161			label = "D-pad right";
162			linux,code = <KEY_RIGHT>;
163			linux,can-disable;
164			gpios = <&gpe 24 GPIO_ACTIVE_LOW>;
165		};
166
167		button@4 {
168			label = "Button A";
169			linux,code = <KEY_LEFTCTRL>;
170			linux,can-disable;
171			gpios = <&gpe 29 GPIO_ACTIVE_LOW>;
172		};
173
174		button@5 {
175			label = "Button B";
176			linux,code = <KEY_LEFTALT>;
177			linux,can-disable;
178			gpios = <&gpe 20 GPIO_ACTIVE_LOW>;
179		};
180
181		button@6 {
182			label = "Button Y";
183			linux,code = <KEY_SPACE>;
184			linux,can-disable;
185			gpios = <&gpe 27 GPIO_ACTIVE_LOW>;
186		};
187
188		button@7 {
189			label = "Button X";
190			linux,code = <KEY_LEFTSHIFT>;
191			linux,can-disable;
192			gpios = <&gpe 28 GPIO_ACTIVE_LOW>;
193		};
194
195		button@8 {
196			label = "Left shoulder button";
197			linux,code = <KEY_TAB>;
198			linux,can-disable;
199			gpios = <&gpb 20 GPIO_ACTIVE_LOW>;
200		};
201
202		button@9 {
203			label = "Right shoulder button";
204			linux,code = <KEY_BACKSPACE>;
205			linux,can-disable;
206			gpios = <&gpe 26 GPIO_ACTIVE_LOW>;
207		};
208
209		button@10 {
210			label = "Start button";
211			linux,code = <KEY_ENTER>;
212			linux,can-disable;
213			gpios = <&gpb 21 GPIO_ACTIVE_LOW>;
214		};
215
216		button@11 {
217			label = "Select button";
218			linux,code = <KEY_ESC>;
219			linux,can-disable;
220			/*
221			 * This is the only button that is active high,
222			 * since it doubles as BOOT_SEL1.
223			 */
224			gpios = <&gpd 18 GPIO_ACTIVE_HIGH>;
225		};
226
227		button@12 {
228			label = "Power slider";
229			linux,code = <KEY_POWER>;
230			linux,can-disable;
231			gpios = <&gpa 30 GPIO_ACTIVE_LOW>;
232			wakeup-source;
233		};
234
235		button@13 {
236			label = "Power hold";
237			linux,code = <KEY_PAUSE>;
238			linux,can-disable;
239			gpios = <&gpf 11 GPIO_ACTIVE_LOW>;
240		};
241	};
242
243	i2c3: i2c-controller@3 {
244		compatible = "i2c-gpio";
245		#address-cells = <1>;
246		#size-cells = <0>;
247
248		sda-gpios = <&gpd 5 GPIO_ACTIVE_HIGH>;
249		scl-gpios = <&gpd 4 GPIO_ACTIVE_HIGH>;
250		i2c-gpio,delay-us = <2>; /* 250 kHz */
251
252		act8600: pmic@5a {
253			compatible = "active-semi,act8600";
254			reg = <0x5a>;
255
256			regulators {
257				/* USB OTG */
258				otg_vbus: SUDCDC_REG4 {
259					/*
260					 * 5.3V instead of 5.0V to compensate
261					 * for the voltage drop of a diode
262					 * between the regulator and the
263					 * connector.
264					 */
265					regulator-min-microvolt = <5300000>;
266					regulator-max-microvolt = <5300000>;
267					inl-supply = <&vcc>;
268				};
269
270				/*
271				 * When this is off, there is no sound, but also
272				 * no USB networking.
273				 */
274				ldo5: LDO5 {
275					regulator-min-microvolt = <2500000>;
276					regulator-max-microvolt = <2500000>;
277					inl-supply = <&vcc>;
278				};
279
280				/* LCD panel and FM radio */
281				ldo6: LDO6 {
282					regulator-min-microvolt = <3300000>;
283					regulator-max-microvolt = <3300000>;
284					inl-supply = <&vcc>;
285				};
286
287				/* ??? */
288				LDO7 {
289					regulator-min-microvolt = <3300000>;
290					regulator-max-microvolt = <3300000>;
291					/*regulator-always-on;*/
292					inl-supply = <&vcc>;
293				};
294
295				/*
296				 * The colors on the LCD are wrong when this is
297				 * off. Which is strange, since the LCD panel
298				 * data sheet only mentions a 3.3V input.
299				 */
300				LDO8 {
301					regulator-min-microvolt = <1800000>;
302					regulator-max-microvolt = <1800000>;
303					regulator-always-on;
304					inl-supply = <&vcc>;
305				};
306
307				/* RTC fixed 3.3V */
308				LDO_REG9 {
309					regulator-min-microvolt = <3300000>;
310					regulator-max-microvolt = <3300000>;
311					regulator-always-on;
312					inl-supply = <&vcc>;
313				};
314
315				/* Unused fixed 1.2V */
316				LDO_REG10 {
317					inl-supply = <&vcc>;
318				};
319			};
320		};
321	};
322
323	leds {
324		compatible = "gpio-leds";
325
326		led {
327			gpios = <&gpb 30 GPIO_ACTIVE_LOW>;
328			default-state = "on";
329		};
330	};
331
332	spi {
333		compatible = "spi-gpio";
334		#address-cells = <1>;
335		#size-cells = <0>;
336
337		sck-gpios = <&gpe 15 GPIO_ACTIVE_HIGH>;
338		mosi-gpios = <&gpe 17 GPIO_ACTIVE_HIGH>;
339		cs-gpios = <&gpe 16 GPIO_ACTIVE_HIGH>;
340		num-chipselects = <1>;
341
342		nt39016@0 {
343			compatible = "kingdisplay,kd035g6-54nt";
344			reg = <0>;
345
346			spi-max-frequency = <3125000>;
347			spi-3wire;
348
349			reset-gpios = <&gpe 2 GPIO_ACTIVE_LOW>;
350
351			backlight = <&backlight>;
352			power-supply = <&ldo6>;
353
354			port {
355				panel_input: endpoint {
356					remote-endpoint = <&panel_output>;
357				};
358			};
359		};
360	};
361
362	connector {
363		compatible = "gpio-usb-b-connector", "usb-b-connector";
364		label = "mini-USB";
365		type = "mini";
366
367		/*
368		 * USB OTG is not yet working reliably, the ID detection
369		 * mechanism tends to fry easily for unknown reasons.
370		 * Until this is fixed, disable OTG by not providing the
371		 * ID GPIO to the driver.
372		 */
373		//id-gpios = <&gpf 18 GPIO_ACTIVE_LOW>;
374
375		vbus-gpios = <&gpb 5 GPIO_ACTIVE_HIGH>;
376		vbus-supply = <&otg_vbus>;
377
378		pinctrl-names = "default";
379		pinctrl-0 = <&pins_otg>;
380
381		port {
382			usb_ep: endpoint {
383				remote-endpoint = <&usb_otg_ep>;
384			};
385		};
386	};
387};
388
389&ext {
390	clock-frequency = <12000000>;
391};
392
393&pinctrl {
394	pins_lcd: lcd {
395		function = "lcd";
396		groups = "lcd-24bit";
397	};
398
399	pins_uart2: uart2 {
400		function = "uart2";
401		groups = "uart2-data";
402	};
403
404	pins_mmc0: mmc0 {
405		function = "mmc0";
406		groups = "mmc0-1bit-a", "mmc0-4bit-a";
407	};
408
409	pins_mmc1: mmc1 {
410		function = "mmc1";
411		groups = "mmc1-1bit-d", "mmc1-4bit-d";
412	};
413
414	pins_otg: otg {
415		otg-vbus-pin {
416			function = "otg";
417			groups = "otg-vbus";
418		};
419
420		vbus-pin {
421			pins = "PB5";
422			bias-disable;
423		};
424	};
425
426	pins_pwm1: pwm1 {
427		function = "pwm1";
428		groups = "pwm1";
429	};
430
431	pins_pwm4: pwm4 {
432		function = "pwm4";
433		groups = "pwm4";
434	};
435};
436
437&uart2 {
438	pinctrl-names = "default";
439	pinctrl-0 = <&pins_uart2>;
440
441	status = "okay";
442};
443
444&cgu {
445	/*
446	 * Put high-speed peripherals under PLL1, such that we can change the
447	 * PLL0 frequency on demand without having to suspend peripherals.
448	 * We use a rate of 432 MHz, which is the least common multiple of
449	 * 27 MHz (required by TV encoder) and 48 MHz (required by USB host).
450	 * Put the GPU under PLL0 since we want a higher frequency.
451	 * Use the 32 kHz oscillator as the parent of the RTC for a higher
452	 * precision.
453	 */
454	assigned-clocks =
455		<&cgu JZ4770_CLK_PLL1>,
456		<&cgu JZ4770_CLK_GPU>,
457		<&cgu JZ4770_CLK_RTC>,
458		<&cgu JZ4770_CLK_UHC>,
459		<&cgu JZ4770_CLK_LPCLK_MUX>,
460		<&cgu JZ4770_CLK_MMC0_MUX>,
461		<&cgu JZ4770_CLK_MMC1_MUX>;
462	assigned-clock-parents =
463		<0>,
464		<&cgu JZ4770_CLK_PLL0>,
465		<&cgu JZ4770_CLK_OSC32K>,
466		<&cgu JZ4770_CLK_PLL1>,
467		<&cgu JZ4770_CLK_PLL1>,
468		<&cgu JZ4770_CLK_PLL1>,
469		<&cgu JZ4770_CLK_PLL1>;
470	assigned-clock-rates =
471		<432000000>,
472		<600000000>;
473};
474
475&uhc {
476	/* The WiFi module is connected to the UHC. */
477	status = "okay";
478};
479
480&tcu {
481	/*
482	 * 750 kHz for the system timer and clocksource, 12 MHz for the OST,
483	 * and use RTC as the parent for the watchdog clock
484	 */
485	assigned-clocks = <&tcu TCU_CLK_TIMER0>, <&tcu TCU_CLK_TIMER2>,
486			  <&tcu TCU_CLK_OST>, <&tcu TCU_CLK_WDT>;
487	assigned-clock-parents = <0>, <0>, <0>, <&cgu JZ4770_CLK_RTC>;
488	assigned-clock-rates = <750000>, <750000>, <12000000>;
489
490	/* PWM1 is in use, so use channel #2 for the clocksource */
491	ingenic,pwm-channels-mask = <0xfa>;
492};
493
494&usb_otg {
495	port {
496		usb_otg_ep: endpoint {
497			remote-endpoint = <&usb_ep>;
498		};
499	};
500};
501
502&otg_phy {
503	vcc-supply = <&ldo5>;
504};
505
506&rtc {
507	clocks = <&cgu JZ4770_CLK_RTC>;
508	clock-names = "rtc";
509
510	system-power-controller;
511};
512
513&mmc0 {
514	status = "okay";
515
516	bus-width = <4>;
517	max-frequency = <48000000>;
518	vmmc-supply = <&vcc>;
519	non-removable;
520
521	pinctrl-names = "default";
522	pinctrl-0 = <&pins_mmc0>;
523};
524
525&mmc1 {
526	status = "okay";
527
528	bus-width = <4>;
529	max-frequency = <48000000>;
530	cd-gpios = <&gpb 2 GPIO_ACTIVE_LOW>;
531	vmmc-supply = <&mmc1_power>;
532
533	pinctrl-names = "default";
534	pinctrl-0 = <&pins_mmc1>;
535};
536
537&lcd {
538	pinctrl-names = "default";
539	pinctrl-0 = <&pins_lcd>;
540
541	port {
542		panel_output: endpoint {
543			remote-endpoint = <&panel_input>;
544		};
545	};
546};
547