1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2
3#include <dt-bindings/gpio/gpio.h>
4#include <dt-bindings/input/gpio-keys.h>
5#include <dt-bindings/input/input.h>
6#include <dt-bindings/leds/common.h>
7#include <dt-bindings/pinctrl/rockchip.h>
8
9#include "rk3566.dtsi"
10
11/ {
12	aliases {
13		mmc0 = &sdhci;
14	};
15
16	chosen {
17		stdout-path = "serial2:1500000n8";
18	};
19
20	adc-keys {
21		compatible = "adc-keys";
22		io-channels = <&saradc 0>;
23		io-channel-names = "buttons";
24		keyup-threshold-microvolt = <1750000>;
25
26		recovery {
27			label = "recovery";
28			linux,code = <KEY_VENDOR>;
29			press-threshold-microvolt = <0>;
30		};
31	};
32
33	spk_amp: audio-amplifier {
34		compatible = "simple-audio-amplifier";
35		enable-gpios = <&gpio3 RK_PC4 GPIO_ACTIVE_HIGH>;
36		pinctrl-0 = <&spk_amp_enable_h>;
37		pinctrl-names = "default";
38		sound-name-prefix = "Speaker Amp";
39	};
40
41	dmic_codec: dmic-codec {
42		compatible = "dmic-codec";
43		num-channels = <6>;
44		#sound-dai-cells = <0>;
45	};
46
47	gpio-keys {
48		compatible = "gpio-keys";
49		pinctrl-0 = <&hall_int_l>;
50		pinctrl-names = "default";
51
52		cover {
53			label = "cover";
54			gpios = <&gpio0 RK_PC7 GPIO_ACTIVE_LOW>;
55			linux,input-type = <EV_SW>;
56			linux,code = <SW_MACHINE_COVER>;
57			linux,can-disable;
58			wakeup-event-action = <EV_ACT_DEASSERTED>;
59			wakeup-source;
60		};
61	};
62
63	gpio-leds {
64		compatible = "gpio-leds";
65		pinctrl-0 = <&led_pin>;
66		pinctrl-names = "default";
67
68		led-0 {
69			color = <LED_COLOR_ID_WHITE>;
70			function = LED_FUNCTION_CHARGING;
71			gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_HIGH>;
72		};
73	};
74
75	sdio_pwrseq: sdio-pwrseq {
76		compatible = "mmc-pwrseq-simple";
77		clocks = <&rk817 1>;
78		clock-names = "ext_clock";
79		pinctrl-0 = <&wifi_enable_h>;
80		pinctrl-names = "default";
81		reset-gpios = <&gpio0 RK_PC6 GPIO_ACTIVE_LOW>;
82	};
83
84	sound {
85		compatible = "simple-audio-card";
86		simple-audio-card,name = "PineNote";
87		simple-audio-card,aux-devs = <&spk_amp>;
88		simple-audio-card,widgets = "Headphone", "Headphones",
89					    "Speaker", "Internal Speakers";
90		simple-audio-card,routing = "Headphones", "HPOL",
91					    "Headphones", "HPOR",
92					    "Internal Speakers", "Speaker Amp OUTL",
93					    "Internal Speakers", "Speaker Amp OUTR",
94					    "Speaker Amp INL", "HPOL",
95					    "Speaker Amp INR", "HPOR";
96		simple-audio-card,pin-switches = "Internal Speakers";
97		#address-cells = <1>;
98		#size-cells = <0>;
99
100		simple-audio-card,dai-link@0 {
101			reg = <0>;
102			bitclock-master = <&link0_cpu>;
103			format = "i2s";
104			frame-master = <&link0_cpu>;
105			mclk-fs = <256>;
106
107			link0_cpu: cpu {
108				sound-dai = <&i2s1_8ch>;
109			};
110
111			link0_codec: codec {
112				sound-dai = <&rk817>;
113			};
114		};
115
116		simple-audio-card,dai-link@1 {
117			reg = <1>;
118			bitclock-master = <&link1_cpu>;
119			format = "pdm";
120			frame-master = <&link1_cpu>;
121
122			link1_cpu: cpu {
123				sound-dai = <&pdm>;
124			};
125
126			link1_codec: codec {
127				sound-dai = <&dmic_codec>;
128			};
129		};
130	};
131
132	vbat_4g: vbat-4g {
133		compatible = "regulator-fixed";
134		regulator-name = "vbat_4g";
135		regulator-min-microvolt = <3800000>;
136		regulator-max-microvolt = <3800000>;
137		/* powered by vcc_bat, enabled by vbat_4g_en */
138		vin-supply = <&vbat_4g_en>;
139	};
140
141	vcc_1v8: vcc-1v8 {
142		compatible = "regulator-fixed";
143		regulator-name = "vcc_1v8";
144		regulator-always-on;
145		regulator-min-microvolt = <1800000>;
146		regulator-max-microvolt = <1800000>;
147		/* powered by vcc_sys, enabled by vcc_1v8_en */
148		vin-supply = <&vcc_1v8_en>;
149	};
150
151	vcc_bat: vcc-bat {
152		compatible = "regulator-fixed";
153		regulator-name = "vcc_bat";
154		regulator-always-on;
155		regulator-min-microvolt = <3800000>;
156		regulator-max-microvolt = <3800000>;
157	};
158
159	vcc_hall_3v3: vcc-hall-3v3 {
160		compatible = "regulator-fixed";
161		regulator-name = "vcc_hall_3v3";
162		regulator-always-on;
163		regulator-min-microvolt = <3300000>;
164		regulator-max-microvolt = <3300000>;
165		vin-supply = <&vcc_sys>;
166	};
167
168	vcc_sys: vcc-sys {
169		compatible = "regulator-fixed";
170		regulator-name = "vcc_sys";
171		regulator-always-on;
172		regulator-min-microvolt = <3800000>;
173		regulator-max-microvolt = <3800000>;
174		vin-supply = <&vcc_bat>;
175	};
176
177	vcc_wl: vcc-wl {
178		compatible = "regulator-fixed";
179		enable-active-high;
180		gpio = <&gpio0 RK_PA0 GPIO_ACTIVE_HIGH>;
181		pinctrl-0 = <&vcc_wl_pin>;
182		pinctrl-names = "default";
183		regulator-name = "vcc_wl";
184		regulator-min-microvolt = <3300000>;
185		regulator-max-microvolt = <3300000>;
186		vin-supply = <&vcc_bat>;
187	};
188
189	vdda_0v9: vdda-0v9 {
190		compatible = "regulator-fixed";
191		regulator-name = "vdda_0v9";
192		regulator-always-on;
193		regulator-min-microvolt = <900000>;
194		regulator-max-microvolt = <900000>;
195		/* powered by vcc_sys, enabled by vcc_1v8_en */
196		vin-supply = <&vcc_1v8_en>;
197	};
198};
199
200&cpu0 {
201	cpu-supply = <&vdd_cpu>;
202};
203
204&cpu1 {
205	cpu-supply = <&vdd_cpu>;
206};
207
208&cpu2 {
209	cpu-supply = <&vdd_cpu>;
210};
211
212&cpu3 {
213	cpu-supply = <&vdd_cpu>;
214};
215
216&i2c0 {
217	status = "okay";
218
219	vdd_cpu: regulator@1c {
220		compatible = "tcs,tcs4525";
221		reg = <0x1c>;
222		fcs,suspend-voltage-selector = <0>;
223		regulator-name = "vdd_cpu";
224		regulator-min-microvolt = <712500>;
225		regulator-max-microvolt = <1390000>;
226		regulator-ramp-delay = <2300>;
227		regulator-always-on;
228		vin-supply = <&vcc_sys>;
229
230		regulator-state-mem {
231			regulator-on-in-suspend;
232		};
233	};
234
235	rk817: pmic@20 {
236		compatible = "rockchip,rk817";
237		reg = <0x20>;
238		interrupt-parent = <&gpio0>;
239		interrupts = <RK_PA3 IRQ_TYPE_LEVEL_LOW>;
240		assigned-clocks = <&cru I2S1_MCLKOUT_TX>;
241		assigned-clock-parents = <&cru CLK_I2S1_8CH_TX>;
242		clocks = <&cru I2S1_MCLKOUT_TX>;
243		clock-names = "mclk";
244		#clock-cells = <1>;
245		pinctrl-0 = <&i2s1m0_mclk>, <&pmic_int_l>, <&pmic_sleep>;
246		pinctrl-names = "default";
247		rockchip,system-power-controller;
248		#sound-dai-cells = <0>;
249		wakeup-source;
250
251		vcc1-supply = <&vcc_sys>;
252		vcc2-supply = <&vcc_sys>;
253		vcc3-supply = <&vcc_sys>;
254		vcc4-supply = <&vcc_sys>;
255		vcc5-supply = <&vcc_sys>;
256		vcc6-supply = <&vcc_sys>;
257		vcc7-supply = <&vcc_sys>;
258		vcc8-supply = <&vcc_sys>;
259		vcc9-supply = <&dcdc_boost>;
260
261		regulators {
262			vdd_logic: DCDC_REG1 {
263				regulator-name = "vdd_logic";
264				regulator-always-on;
265				regulator-min-microvolt = <500000>;
266				regulator-max-microvolt = <1350000>;
267				regulator-init-microvolt = <900000>;
268				regulator-ramp-delay = <6001>;
269				regulator-initial-mode = <0x2>;
270
271				regulator-state-mem {
272					regulator-off-in-suspend;
273					regulator-suspend-microvolt = <900000>;
274				};
275			};
276
277			vdd_gpu_npu: DCDC_REG2 {
278				regulator-name = "vdd_gpu_npu";
279				regulator-min-microvolt = <500000>;
280				regulator-max-microvolt = <1350000>;
281				regulator-init-microvolt = <900000>;
282				regulator-ramp-delay = <6001>;
283				regulator-initial-mode = <0x2>;
284
285				regulator-state-mem {
286					regulator-off-in-suspend;
287				};
288			};
289
290			vcc_ddr: DCDC_REG3 {
291				regulator-name = "vcc_ddr";
292				regulator-always-on;
293				regulator-initial-mode = <0x2>;
294
295				regulator-state-mem {
296					regulator-on-in-suspend;
297				};
298			};
299
300			vcc_3v3: DCDC_REG4 {
301				regulator-name = "vcc_3v3";
302				regulator-always-on;
303				regulator-min-microvolt = <3300000>;
304				regulator-max-microvolt = <3300000>;
305				regulator-initial-mode = <0x2>;
306
307				regulator-state-mem {
308					regulator-off-in-suspend;
309				};
310			};
311
312			vcca_1v8_pmu: LDO_REG1 {
313				regulator-name = "vcca_1v8_pmu";
314				regulator-always-on;
315				regulator-min-microvolt = <1800000>;
316				regulator-max-microvolt = <1800000>;
317
318				regulator-state-mem {
319					regulator-on-in-suspend;
320				};
321			};
322
323			/* unused */
324			vdda_0v9_ldo: LDO_REG2 {
325				regulator-name = "vdda_0v9_ldo";
326				regulator-min-microvolt = <900000>;
327				regulator-max-microvolt = <900000>;
328
329				regulator-state-mem {
330					regulator-off-in-suspend;
331				};
332			};
333
334			vdda_0v9_pmu: LDO_REG3 {
335				regulator-name = "vdda_0v9_pmu";
336				regulator-always-on;
337				regulator-min-microvolt = <900000>;
338				regulator-max-microvolt = <900000>;
339
340				regulator-state-mem {
341					regulator-on-in-suspend;
342				};
343			};
344
345			vccio_acodec: LDO_REG4 {
346				regulator-name = "vccio_acodec";
347				regulator-always-on;
348				regulator-min-microvolt = <3300000>;
349				regulator-max-microvolt = <3300000>;
350
351				regulator-state-mem {
352					regulator-off-in-suspend;
353				};
354			};
355
356			/* unused */
357			vccio_sd: LDO_REG5 {
358				regulator-name = "vccio_sd";
359				regulator-min-microvolt = <1800000>;
360				regulator-max-microvolt = <3300000>;
361
362				regulator-state-mem {
363					regulator-off-in-suspend;
364				};
365			};
366
367			vcc_3v3_pmu: LDO_REG6 {
368				regulator-name = "vcc_3v3_pmu";
369				regulator-always-on;
370				regulator-min-microvolt = <3300000>;
371				regulator-max-microvolt = <3300000>;
372
373				regulator-state-mem {
374					regulator-on-in-suspend;
375				};
376			};
377
378			vcc_1v8_en: LDO_REG7 {
379				regulator-name = "vcc_1v8_en";
380				regulator-min-microvolt = <1800000>;
381				regulator-max-microvolt = <1800000>;
382
383				regulator-state-mem {
384					regulator-off-in-suspend;
385				};
386			};
387
388			vbat_4g_en: LDO_REG8 {
389				regulator-name = "vbat_4g_en";
390				regulator-min-microvolt = <1800000>;
391				regulator-max-microvolt = <1800000>;
392
393				regulator-state-mem {
394					regulator-off-in-suspend;
395				};
396			};
397
398			sleep_sta_ctl: LDO_REG9 {
399				regulator-name = "sleep_sta_ctl";
400				regulator-min-microvolt = <1800000>;
401				regulator-max-microvolt = <1800000>;
402
403				regulator-state-mem {
404					regulator-on-in-suspend;
405				};
406			};
407
408			dcdc_boost: BOOST {
409				regulator-name = "boost";
410				regulator-min-microvolt = <5000000>;
411				regulator-max-microvolt = <5000000>;
412
413				regulator-state-mem {
414					regulator-off-in-suspend;
415				};
416			};
417
418			otg_switch: OTG_SWITCH {
419				regulator-name = "otg_switch";
420
421				regulator-state-mem {
422					regulator-off-in-suspend;
423				};
424			};
425		};
426	};
427};
428
429&i2c1 {
430	status = "okay";
431
432	digitizer@9 {
433		compatible = "wacom,w9013", "hid-over-i2c";
434		reg = <0x09>;
435		interrupt-parent = <&gpio0>;
436		interrupts = <RK_PB6 IRQ_TYPE_LEVEL_LOW>;
437		hid-descr-addr = <0x1>;
438		pinctrl-0 = <&pen_fwe>, <&pen_irq_l>, <&pen_rst_l>;
439		pinctrl-names = "default";
440		vdd-supply = <&vcc_3v3_pmu>;
441	};
442};
443
444&i2c3 {
445	pinctrl-0 = <&i2c3m1_xfer>;
446	status = "okay";
447
448	led-controller@36 {
449		compatible = "ti,lm3630a";
450		reg = <0x36>;
451		enable-gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_HIGH>;
452		pinctrl-0 = <&backlight_hwen_h>;
453		pinctrl-names = "default";
454		#address-cells = <1>;
455		#size-cells = <0>;
456
457		led@0 {
458			reg = <0>;
459			label = "backlight_cool";
460			default-brightness = <0>;
461		};
462
463		led@1 {
464			reg = <1>;
465			label = "backlight_warm";
466			default-brightness = <0>;
467		};
468	};
469};
470
471&i2s1_8ch {
472	pinctrl-0 = <&i2s1m0_lrcktx>, <&i2s1m0_sclktx>, <&i2s1m0_sdi0>, <&i2s1m0_sdo0>;
473	rockchip,trcm-sync-tx-only;
474	status = "okay";
475};
476
477&pdm {
478	pinctrl-0 = <&pdmm0_clk1>, <&pdmm0_sdi1>, <&pdmm0_sdi2>;
479	/* microphones are on channels 1 and 2 */
480	rockchip,path-map = <1>, <2>, <0>, <3>;
481	status = "okay";
482};
483
484&pinctrl {
485	audio-amplifier {
486		spk_amp_enable_h: spk-amp-enable-h {
487			rockchip,pins = <3 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>;
488		};
489	};
490
491	backlight {
492		backlight_hwen_h: backlight-hwen-h {
493			rockchip,pins = <0 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>;
494		};
495	};
496
497	bt {
498		bt_enable_h: bt-enable-h {
499			rockchip,pins = <0 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>;
500		};
501
502		bt_host_wake_l: bt-host-wake-l {
503			rockchip,pins = <0 RK_PC3 RK_FUNC_GPIO &pcfg_pull_up>;
504		};
505
506		bt_wake_h: bt-wake-h {
507			rockchip,pins = <0 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
508		};
509	};
510
511	led {
512		led_pin: led-pin {
513			rockchip,pins = <3 RK_PC5 RK_FUNC_GPIO &pcfg_pull_none>;
514		};
515	};
516
517	hall {
518		hall_int_l: hall-int-l {
519			rockchip,pins = <0 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>;
520		};
521	};
522
523	pen {
524		pen_fwe: pen-fwe {
525			rockchip,pins = <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_down>;
526		};
527
528		pen_irq_l: pen-irq-l {
529			rockchip,pins = <0 RK_PB6 RK_FUNC_GPIO &pcfg_pull_none>;
530		};
531
532		pen_rst_l: pen-rst-l {
533			rockchip,pins = <0 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
534		};
535	};
536
537	pmic {
538		pmic_int_l: pmic-int-l {
539			rockchip,pins = <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
540		};
541
542		pmic_sleep: pmic-sleep {
543			rockchip,pins = <0 RK_PA2 1 &pcfg_pull_none>;
544		};
545	};
546
547	sdio-pwrseq {
548		wifi_enable_h: wifi-enable-h {
549			rockchip,pins = <0 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>;
550		};
551	};
552
553	vcc-wl {
554		vcc_wl_pin: vcc-wl-pin {
555			rockchip,pins = <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
556		};
557	};
558
559	wifi {
560		wifi_host_wake_l: wifi-host-wake-l {
561			rockchip,pins = <0 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>;
562		};
563	};
564};
565
566&pmu_io_domains {
567	pmuio1-supply = <&vcc_3v3_pmu>;
568	pmuio2-supply = <&vcc_3v3_pmu>;
569	vccio1-supply = <&vccio_acodec>;
570	vccio2-supply = <&vcc_1v8>;
571	vccio3-supply = <&vcc_3v3>;
572	vccio4-supply = <&vcca_1v8_pmu>;
573	vccio5-supply = <&vcc_3v3>;
574	vccio6-supply = <&vcc_3v3>;
575	status = "okay";
576};
577
578&saradc {
579	vref-supply = <&vcc_1v8>;
580	status = "okay";
581};
582
583&sdhci {
584	bus-width = <8>;
585	mmc-hs200-1_8v;
586	non-removable;
587	pinctrl-0 = <&emmc_bus8>, <&emmc_clk>, <&emmc_cmd>, <&emmc_datastrobe>, <&emmc_rstnout>;
588	pinctrl-names = "default";
589	vmmc-supply = <&vcc_3v3>;
590	vqmmc-supply = <&vcc_1v8>;
591	status = "okay";
592};
593
594&sdmmc1 {
595	bus-width = <4>;
596	cap-sd-highspeed;
597	cap-sdio-irq;
598	keep-power-in-suspend;
599	mmc-pwrseq = <&sdio_pwrseq>;
600	non-removable;
601	pinctrl-0 = <&sdmmc1_bus4>, <&sdmmc1_clk>, <&sdmmc1_cmd>;
602	pinctrl-names = "default";
603	sd-uhs-sdr104;
604	vmmc-supply = <&vcc_wl>;
605	vqmmc-supply = <&vcca_1v8_pmu>;
606	status = "okay";
607};
608
609&tsadc {
610	/* tshut mode 0:CRU 1:GPIO */
611	rockchip,hw-tshut-mode = <1>;
612	/* tshut polarity 0:LOW 1:HIGH */
613	rockchip,hw-tshut-polarity = <0>;
614	status = "okay";
615};
616
617&uart1 {
618	pinctrl-0 = <&uart1m0_ctsn>, <&uart1m0_rtsn>, <&uart1m0_xfer>;
619	pinctrl-names = "default";
620	uart-has-rtscts;
621	status = "okay";
622
623	bluetooth {
624		compatible = "brcm,bcm43438-bt";
625		clocks = <&rk817 1>;
626		clock-names = "lpo";
627		device-wake-gpios = <&gpio0 RK_PC2 GPIO_ACTIVE_HIGH>;
628		host-wake-gpios = <&gpio0 RK_PC3 GPIO_ACTIVE_HIGH>;
629		reset-gpios = <&gpio0 RK_PC4 GPIO_ACTIVE_LOW>;
630		pinctrl-0 = <&bt_enable_h>, <&bt_host_wake_l>, <&bt_wake_h>;
631		pinctrl-names = "default";
632		vbat-supply = <&vcc_wl>;
633		vddio-supply = <&vcca_1v8_pmu>;
634	};
635};
636
637&uart2 {
638	status = "okay";
639};
640