1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2
3/dts-v1/;
4#include <dt-bindings/input/linux-event-codes.h>
5#include "sun8i-v3s.dtsi"
6#include "sunxi-common-regulators.dtsi"
7
8/ {
9	model = "Anbernic RG Nano";
10	compatible = "anbernic,rg-nano", "allwinner,sun8i-v3s";
11
12	aliases {
13		rtc0 = &pcf8563;
14		rtc1 = &rtc;
15		serial0 = &uart0;
16	};
17
18	backlight: backlight {
19		compatible = "pwm-backlight";
20		brightness-levels = <0 1 2 3 8 14 21 32 46 60 80 100>;
21		default-brightness-level = <11>;
22		power-supply = <&reg_vcc5v0>;
23		pwms = <&pwm 0 40000 1>;
24	};
25
26	chosen {
27		stdout-path = "serial0:115200n8";
28	};
29
30	gpio_keys: gpio-keys {
31		compatible = "gpio-keys";
32
33		button-a {
34			gpios = <&gpio_expander 12 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
35			label = "BTN-A";
36			linux,code = <BTN_EAST>;
37		};
38
39		button-b {
40			gpios = <&gpio_expander 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
41			label = "BTN-B";
42			linux,code = <BTN_SOUTH>;
43		};
44
45		button-down {
46			gpios = <&gpio_expander 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
47			label = "DPAD-DOWN";
48			linux,code = <BTN_DPAD_DOWN>;
49		};
50
51		button-left {
52			gpios = <&gpio_expander 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
53			label = "DPAD-LEFT";
54			linux,code = <BTN_DPAD_LEFT>;
55		};
56
57		button-right {
58			gpios = <&gpio_expander 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
59			label = "DPAD-RIGHT";
60			linux,code = <BTN_DPAD_RIGHT>;
61		};
62
63		button-se {
64			gpios = <&gpio_expander 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
65			label = "BTN-SELECT";
66			linux,code = <BTN_SELECT>;
67		};
68
69		button-st {
70			gpios = <&gpio_expander 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
71			label = "BTN-START";
72			linux,code = <BTN_START>;
73		};
74
75		button-tl {
76			gpios = <&gpio_expander 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
77			label = "BTN-L";
78			linux,code = <BTN_TL>;
79		};
80
81		button-tr {
82			gpios = <&gpio_expander 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
83			label = "BTN-R";
84			linux,code = <BTN_TR>;
85		};
86
87		button-up {
88			gpios = <&gpio_expander 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
89			label = "DPAD-UP";
90			linux,code = <BTN_DPAD_UP>;
91		};
92
93		button-x {
94			gpios = <&gpio_expander 11 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
95			label = "BTN-X";
96			linux,code = <BTN_NORTH>;
97		};
98
99		button-y {
100			gpios = <&gpio_expander 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
101			label = "BTN-Y";
102			linux,code = <BTN_WEST>;
103		};
104	};
105};
106
107&codec {
108	allwinner,audio-routing = "Speaker", "HP",
109				  "MIC1", "Mic",
110				  "Mic", "HBIAS";
111	allwinner,pa-gpios = <&pio 5 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; /* PF6 */
112	status = "okay";
113};
114
115&ehci {
116	status = "okay";
117};
118
119&i2c0 {
120	status = "okay";
121
122	gpio_expander: gpio@20 {
123		compatible = "nxp,pcal6416";
124		reg = <0x20>;
125		gpio-controller;
126		#gpio-cells = <2>;
127		#interrupt-cells = <2>;
128		interrupt-controller;
129		interrupt-parent = <&pio>;
130		interrupts = <1 3 IRQ_TYPE_EDGE_BOTH>; /* PB3/EINT3 */
131		vcc-supply = <&reg_vcc3v3>;
132	};
133
134	axp209: pmic@34 {
135		reg = <0x34>;
136		interrupt-parent = <&pio>;
137		interrupts = <1 5 IRQ_TYPE_EDGE_FALLING>; /* PB5/EINT5 */
138	};
139
140	pcf8563: rtc@51 {
141		compatible = "nxp,pcf8563";
142		reg = <0x51>;
143	};
144};
145
146#include "axp209.dtsi"
147
148&battery_power_supply {
149	status = "okay";
150};
151
152&mmc0 {
153	broken-cd;
154	bus-width = <4>;
155	disable-wp;
156	vmmc-supply = <&reg_vcc3v3>;
157	vqmmc-supply = <&reg_vcc3v3>;
158	status = "okay";
159};
160
161&ohci {
162	status = "okay";
163};
164
165&pio {
166	vcc-pb-supply = <&reg_vcc3v3>;
167	vcc-pc-supply = <&reg_vcc3v3>;
168	vcc-pf-supply = <&reg_vcc3v3>;
169	vcc-pg-supply = <&reg_vcc3v3>;
170
171	spi0_no_miso_pins: spi0-no-miso-pins {
172		pins = "PC1", "PC2", "PC3";
173		function = "spi0";
174	};
175};
176
177&pwm {
178	pinctrl-0 = <&pwm0_pin>;
179	pinctrl-names = "default";
180	status = "okay";
181};
182
183/* DCDC2 wired into vdd-cpu, vdd-sys, and vdd-ephy. */
184&reg_dcdc2 {
185	regulator-always-on;
186	regulator-max-microvolt = <1250000>;
187	regulator-min-microvolt = <1250000>;
188	regulator-name = "vdd-cpu";
189};
190
191/* DCDC3 wired into every 3.3v input that isn't the RTC. */
192&reg_dcdc3 {
193	regulator-always-on;
194	regulator-max-microvolt = <3300000>;
195	regulator-min-microvolt = <3300000>;
196	regulator-name = "vcc-io";
197};
198
199/* LDO1 wired into RTC, voltage is hard-wired at 3.3v. */
200&reg_ldo1 {
201	regulator-always-on;
202	regulator-name = "vcc-rtc";
203};
204
205/* LDO2 wired into VCC-PLL and audio codec. */
206&reg_ldo2 {
207	regulator-always-on;
208	regulator-max-microvolt = <3000000>;
209	regulator-min-microvolt = <3000000>;
210	regulator-name = "vcc-pll";
211};
212
213/* LDO3, LDO4, and LDO5 unused. */
214&reg_ldo3 {
215	status = "disabled";
216};
217
218&reg_ldo4 {
219	status = "disabled";
220};
221
222/* RTC uses internal oscillator */
223&rtc {
224	/delete-property/ clocks;
225};
226
227&spi0 {
228	pinctrl-0 = <&spi0_no_miso_pins>;
229	pinctrl-names = "default";
230	status = "okay";
231
232	display@0 {
233		compatible = "saef,sftc154b", "panel-mipi-dbi-spi";
234		reg = <0>;
235		backlight = <&backlight>;
236		dc-gpios = <&pio 2 0 GPIO_ACTIVE_HIGH>; /* PC0 */
237		reset-gpios = <&pio 1 2 GPIO_ACTIVE_HIGH>; /* PB2 */
238		spi-max-frequency = <100000000>;
239
240		height-mm = <39>;
241		width-mm = <39>;
242
243		/* Set hb-porch to compensate for non-visible area */
244		panel-timing {
245			hactive = <240>;
246			vactive = <240>;
247			hback-porch = <80>;
248			vback-porch = <0>;
249			clock-frequency = <0>;
250			hfront-porch = <0>;
251			hsync-len = <0>;
252			vfront-porch = <0>;
253			vsync-len = <0>;
254		};
255	};
256};
257
258&uart0 {
259	pinctrl-0 = <&uart0_pb_pins>;
260	pinctrl-names = "default";
261	status = "okay";
262};
263
264&usb_otg {
265	dr_mode = "otg";
266	status = "okay";
267};
268
269&usb_power_supply {
270	status = "okay";
271};
272
273&usbphy {
274	usb0_id_det-gpios = <&pio 6 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* PG5 */
275	status = "okay";
276};
277