1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2
3/dts-v1/;
4
5#include <dt-bindings/gpio/gpio.h>
6#include <dt-bindings/input/linux-event-codes.h>
7#include <dt-bindings/pinctrl/rockchip.h>
8#include "rk3566-anbernic-rgxx3.dtsi"
9
10/ {
11	model = "RG503";
12	compatible = "anbernic,rg503", "rockchip,rk3566";
13
14	aliases {
15		mmc0 = &sdmmc0;
16		mmc1 = &sdmmc1;
17		mmc2 = &sdmmc2;
18	};
19
20	battery: battery {
21		compatible = "simple-battery";
22		charge-full-design-microamp-hours = <3472000>;
23		charge-term-current-microamp = <300000>;
24		constant-charge-current-max-microamp = <2000000>;
25		constant-charge-voltage-max-microvolt = <4200000>;
26		factory-internal-resistance-micro-ohms = <117000>;
27		voltage-max-design-microvolt = <4172000>;
28		voltage-min-design-microvolt = <3400000>;
29
30		ocv-capacity-celsius = <20>;
31		ocv-capacity-table-0 =	<4172000 100>, <4054000 95>, <3984000 90>, <3926000 85>,
32					<3874000 80>, <3826000 75>, <3783000 70>, <3746000 65>,
33					<3714000 60>, <3683000 55>, <3650000 50>, <3628000 45>,
34					<3612000 40>, <3600000 35>, <3587000 30>, <3571000 25>,
35					<3552000 20>, <3525000 15>, <3492000 10>, <3446000 5>,
36					<3400000 0>;
37	};
38
39	gpio_spi: spi {
40		compatible = "spi-gpio";
41		pinctrl-names = "default";
42		pinctrl-0 = <&spi_pins>;
43		#address-cells = <1>;
44		#size-cells = <0>;
45
46		sck-gpios = <&gpio4 RK_PB3 GPIO_ACTIVE_HIGH>;
47		mosi-gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_HIGH>;
48		cs-gpios = <&gpio4 RK_PA7 GPIO_ACTIVE_HIGH>;
49		num-chipselects = <0>;
50	};
51
52	/* Channels reversed for both headphones and speakers. */
53	sound {
54		compatible = "simple-audio-card";
55		simple-audio-card,name = "rk817_ext";
56		simple-audio-card,aux-devs = <&spk_amp>;
57		simple-audio-card,format = "i2s";
58		simple-audio-card,hp-det-gpio = <&gpio4 RK_PC6 GPIO_ACTIVE_HIGH>;
59		simple-audio-card,mclk-fs = <256>;
60		simple-audio-card,widgets =
61			"Microphone", "Mic Jack",
62			"Headphone", "Headphones",
63			"Speaker", "Internal Speakers";
64		simple-audio-card,routing =
65			"MICL", "Mic Jack",
66			"Headphones", "HPOL",
67			"Headphones", "HPOR",
68			"Internal Speakers", "Speaker Amp OUTL",
69			"Internal Speakers", "Speaker Amp OUTR",
70			"Speaker Amp INL", "HPOL",
71			"Speaker Amp INR", "HPOR";
72		simple-audio-card,pin-switches = "Internal Speakers";
73
74		simple-audio-card,codec {
75			sound-dai = <&rk817>;
76		};
77
78		simple-audio-card,cpu {
79			sound-dai = <&i2s1_8ch>;
80		};
81	};
82
83	spk_amp: audio-amplifier {
84		compatible = "simple-audio-amplifier";
85		enable-gpios = <&gpio4 RK_PC2 GPIO_ACTIVE_HIGH>;
86		pinctrl-0 = <&spk_amp_enable_h>;
87		pinctrl-names = "default";
88		sound-name-prefix = "Speaker Amp";
89	};
90};
91
92&cru {
93	assigned-clocks = <&cru PLL_GPLL>, <&pmucru PLL_PPLL>, <&cru PLL_VPLL>;
94	assigned-clock-rates = <1200000000>, <200000000>, <500000000>;
95};
96
97&gpio_keys_control {
98	button-a {
99		gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
100		label = "EAST";
101		linux,code = <BTN_EAST>;
102	};
103
104	button-left {
105		gpios = <&gpio3 RK_PA5 GPIO_ACTIVE_LOW>;
106		label = "DPAD-LEFT";
107		linux,code = <BTN_DPAD_LEFT>;
108	};
109
110	button-right {
111		gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
112		label = "DPAD-RIGHT";
113		linux,code = <BTN_DPAD_RIGHT>;
114	};
115
116	button-r1 {
117		gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
118		label = "TR";
119		linux,code = <BTN_TR>;
120	};
121
122	button-r2 {
123		gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
124		label = "TR2";
125		linux,code = <BTN_TR2>;
126	};
127
128	button-right {
129		gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
130		label = "DPAD-RIGHT";
131		linux,code = <BTN_DPAD_RIGHT>;
132	};
133
134	button-y {
135		gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
136		label = "WEST";
137		linux,code = <BTN_WEST>;
138	};
139};
140
141&pinctrl {
142	audio-amplifier {
143		spk_amp_enable_h: spk-amp-enable-h {
144			rockchip,pins =
145				<4 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
146		};
147	};
148
149	gpio-spi {
150		spi_pins: spi-pins {
151			rockchip,pins =
152				<4 RK_PA7 RK_FUNC_GPIO &pcfg_pull_none>,
153				<4 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>,
154				<4 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>;
155		};
156	};
157};
158
159&rk817 {
160	rk817_charger: charger {
161		monitored-battery = <&battery>;
162		rockchip,resistor-sense-micro-ohms = <10000>;
163		rockchip,sleep-enter-current-microamp = <300000>;
164		rockchip,sleep-filter-current-microamp = <100000>;
165	};
166};
167