1523adb55SChris Morgan// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2523adb55SChris Morgan
3523adb55SChris Morgan/dts-v1/;
4523adb55SChris Morgan
5523adb55SChris Morgan#include <dt-bindings/gpio/gpio.h>
6523adb55SChris Morgan#include <dt-bindings/input/linux-event-codes.h>
7523adb55SChris Morgan#include <dt-bindings/pinctrl/rockchip.h>
8523adb55SChris Morgan#include "rk3566-anbernic-rgxx3.dtsi"
9523adb55SChris Morgan
10523adb55SChris Morgan/ {
11523adb55SChris Morgan	model = "RG503";
12523adb55SChris Morgan	compatible = "anbernic,rg503", "rockchip,rk3566";
13523adb55SChris Morgan
14523adb55SChris Morgan	aliases {
15523adb55SChris Morgan		mmc0 = &sdmmc0;
16523adb55SChris Morgan		mmc1 = &sdmmc1;
17523adb55SChris Morgan		mmc2 = &sdmmc2;
18523adb55SChris Morgan	};
19523adb55SChris Morgan
2022a91b76SChris Morgan	battery: battery {
2122a91b76SChris Morgan		compatible = "simple-battery";
2222a91b76SChris Morgan		charge-full-design-microamp-hours = <3472000>;
2322a91b76SChris Morgan		charge-term-current-microamp = <300000>;
2422a91b76SChris Morgan		constant-charge-current-max-microamp = <2000000>;
2522a91b76SChris Morgan		constant-charge-voltage-max-microvolt = <4200000>;
2622a91b76SChris Morgan		factory-internal-resistance-micro-ohms = <117000>;
2722a91b76SChris Morgan		voltage-max-design-microvolt = <4172000>;
2822a91b76SChris Morgan		voltage-min-design-microvolt = <3400000>;
2922a91b76SChris Morgan
3022a91b76SChris Morgan		ocv-capacity-celsius = <20>;
3122a91b76SChris Morgan		ocv-capacity-table-0 =	<4172000 100>, <4054000 95>, <3984000 90>, <3926000 85>,
3222a91b76SChris Morgan					<3874000 80>, <3826000 75>, <3783000 70>, <3746000 65>,
3322a91b76SChris Morgan					<3714000 60>, <3683000 55>, <3650000 50>, <3628000 45>,
3422a91b76SChris Morgan					<3612000 40>, <3600000 35>, <3587000 30>, <3571000 25>,
3522a91b76SChris Morgan					<3552000 20>, <3525000 15>, <3492000 10>, <3446000 5>,
3622a91b76SChris Morgan					<3400000 0>;
3722a91b76SChris Morgan	};
3822a91b76SChris Morgan
39523adb55SChris Morgan	gpio_spi: spi {
40523adb55SChris Morgan		compatible = "spi-gpio";
41523adb55SChris Morgan		pinctrl-names = "default";
42523adb55SChris Morgan		pinctrl-0 = <&spi_pins>;
43523adb55SChris Morgan		#address-cells = <1>;
44523adb55SChris Morgan		#size-cells = <0>;
45523adb55SChris Morgan
46523adb55SChris Morgan		sck-gpios = <&gpio4 RK_PB3 GPIO_ACTIVE_HIGH>;
47523adb55SChris Morgan		mosi-gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_HIGH>;
48523adb55SChris Morgan		cs-gpios = <&gpio4 RK_PA7 GPIO_ACTIVE_HIGH>;
49523adb55SChris Morgan		num-chipselects = <0>;
5097ce9f36SChris Morgan
5197ce9f36SChris Morgan		panel@0 {
5297ce9f36SChris Morgan			compatible = "samsung,ams495qa01";
5397ce9f36SChris Morgan			reg = <0>;
5497ce9f36SChris Morgan			pinctrl-names = "default";
5597ce9f36SChris Morgan			pinctrl-0 = <&lcd_reset>;
5697ce9f36SChris Morgan			reset-gpios = <&gpio4 RK_PA0 GPIO_ACTIVE_LOW>;
5797ce9f36SChris Morgan			vdd-supply = <&vcc_3v3>;
5897ce9f36SChris Morgan
5997ce9f36SChris Morgan			port {
6097ce9f36SChris Morgan				mipi_in_panel: endpoint {
6197ce9f36SChris Morgan					remote-endpoint = <&mipi_out_panel>;
6297ce9f36SChris Morgan				};
6397ce9f36SChris Morgan			};
6497ce9f36SChris Morgan		};
65523adb55SChris Morgan	};
661e141cf1SChris Morgan
671e141cf1SChris Morgan	/* Channels reversed for both headphones and speakers. */
681e141cf1SChris Morgan	sound {
691e141cf1SChris Morgan		compatible = "simple-audio-card";
701e141cf1SChris Morgan		simple-audio-card,name = "rk817_ext";
711e141cf1SChris Morgan		simple-audio-card,aux-devs = <&spk_amp>;
721e141cf1SChris Morgan		simple-audio-card,format = "i2s";
731e141cf1SChris Morgan		simple-audio-card,hp-det-gpio = <&gpio4 RK_PC6 GPIO_ACTIVE_HIGH>;
741e141cf1SChris Morgan		simple-audio-card,mclk-fs = <256>;
751e141cf1SChris Morgan		simple-audio-card,widgets =
761e141cf1SChris Morgan			"Microphone", "Mic Jack",
771e141cf1SChris Morgan			"Headphone", "Headphones",
781e141cf1SChris Morgan			"Speaker", "Internal Speakers";
791e141cf1SChris Morgan		simple-audio-card,routing =
801e141cf1SChris Morgan			"MICL", "Mic Jack",
811e141cf1SChris Morgan			"Headphones", "HPOL",
821e141cf1SChris Morgan			"Headphones", "HPOR",
831e141cf1SChris Morgan			"Internal Speakers", "Speaker Amp OUTL",
841e141cf1SChris Morgan			"Internal Speakers", "Speaker Amp OUTR",
851e141cf1SChris Morgan			"Speaker Amp INL", "HPOL",
861e141cf1SChris Morgan			"Speaker Amp INR", "HPOR";
871e141cf1SChris Morgan		simple-audio-card,pin-switches = "Internal Speakers";
881e141cf1SChris Morgan
891e141cf1SChris Morgan		simple-audio-card,codec {
901e141cf1SChris Morgan			sound-dai = <&rk817>;
911e141cf1SChris Morgan		};
921e141cf1SChris Morgan
931e141cf1SChris Morgan		simple-audio-card,cpu {
941e141cf1SChris Morgan			sound-dai = <&i2s1_8ch>;
951e141cf1SChris Morgan		};
961e141cf1SChris Morgan	};
971e141cf1SChris Morgan
981e141cf1SChris Morgan	spk_amp: audio-amplifier {
991e141cf1SChris Morgan		compatible = "simple-audio-amplifier";
1001e141cf1SChris Morgan		enable-gpios = <&gpio4 RK_PC2 GPIO_ACTIVE_HIGH>;
1011e141cf1SChris Morgan		pinctrl-0 = <&spk_amp_enable_h>;
1021e141cf1SChris Morgan		pinctrl-names = "default";
1031e141cf1SChris Morgan		sound-name-prefix = "Speaker Amp";
1041e141cf1SChris Morgan	};
1051e141cf1SChris Morgan};
1061e141cf1SChris Morgan
1071e141cf1SChris Morgan&cru {
108*87891399SChris Morgan	assigned-clocks = <&pmucru CLK_RTC_32K>, <&cru PLL_GPLL>,
109*87891399SChris Morgan			  <&pmucru PLL_PPLL>, <&cru PLL_VPLL>;
110*87891399SChris Morgan	assigned-clock-rates = <32768>, <1200000000>,
111*87891399SChris Morgan			       <200000000>, <500000000>;
112523adb55SChris Morgan};
113523adb55SChris Morgan
11497ce9f36SChris Morgan&dsi_dphy0 {
11597ce9f36SChris Morgan	status = "okay";
11697ce9f36SChris Morgan};
11797ce9f36SChris Morgan
11897ce9f36SChris Morgan&dsi0 {
11997ce9f36SChris Morgan	status = "okay";
12097ce9f36SChris Morgan
12197ce9f36SChris Morgan	ports {
12297ce9f36SChris Morgan		dsi0_in: port@0 {
12397ce9f36SChris Morgan			reg = <0>;
12497ce9f36SChris Morgan
12597ce9f36SChris Morgan			dsi0_in_vp1: endpoint {
12697ce9f36SChris Morgan				remote-endpoint = <&vp1_out_dsi0>;
12797ce9f36SChris Morgan			};
12897ce9f36SChris Morgan		};
12997ce9f36SChris Morgan
13097ce9f36SChris Morgan		dsi0_out: port@1 {
13197ce9f36SChris Morgan			reg = <1>;
13297ce9f36SChris Morgan
13397ce9f36SChris Morgan			mipi_out_panel: endpoint {
13497ce9f36SChris Morgan				remote-endpoint = <&mipi_in_panel>;
13597ce9f36SChris Morgan			};
13697ce9f36SChris Morgan		};
13797ce9f36SChris Morgan	};
13897ce9f36SChris Morgan};
13997ce9f36SChris Morgan
140523adb55SChris Morgan&gpio_keys_control {
141523adb55SChris Morgan	button-a {
142523adb55SChris Morgan		gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
143523adb55SChris Morgan		label = "EAST";
144523adb55SChris Morgan		linux,code = <BTN_EAST>;
145523adb55SChris Morgan	};
146523adb55SChris Morgan
147523adb55SChris Morgan	button-left {
148523adb55SChris Morgan		gpios = <&gpio3 RK_PA5 GPIO_ACTIVE_LOW>;
149523adb55SChris Morgan		label = "DPAD-LEFT";
150523adb55SChris Morgan		linux,code = <BTN_DPAD_LEFT>;
151523adb55SChris Morgan	};
152523adb55SChris Morgan
153523adb55SChris Morgan	button-right {
154523adb55SChris Morgan		gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
155523adb55SChris Morgan		label = "DPAD-RIGHT";
156523adb55SChris Morgan		linux,code = <BTN_DPAD_RIGHT>;
157523adb55SChris Morgan	};
158523adb55SChris Morgan
159523adb55SChris Morgan	button-r1 {
160523adb55SChris Morgan		gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
161523adb55SChris Morgan		label = "TR";
162523adb55SChris Morgan		linux,code = <BTN_TR>;
163523adb55SChris Morgan	};
164523adb55SChris Morgan
165523adb55SChris Morgan	button-r2 {
166523adb55SChris Morgan		gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
167523adb55SChris Morgan		label = "TR2";
168523adb55SChris Morgan		linux,code = <BTN_TR2>;
169523adb55SChris Morgan	};
170523adb55SChris Morgan
171523adb55SChris Morgan	button-right {
172523adb55SChris Morgan		gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
173523adb55SChris Morgan		label = "DPAD-RIGHT";
174523adb55SChris Morgan		linux,code = <BTN_DPAD_RIGHT>;
175523adb55SChris Morgan	};
176523adb55SChris Morgan
177523adb55SChris Morgan	button-y {
178523adb55SChris Morgan		gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
179523adb55SChris Morgan		label = "WEST";
180523adb55SChris Morgan		linux,code = <BTN_WEST>;
181523adb55SChris Morgan	};
182523adb55SChris Morgan};
183523adb55SChris Morgan
184523adb55SChris Morgan&pinctrl {
1851e141cf1SChris Morgan	audio-amplifier {
1861e141cf1SChris Morgan		spk_amp_enable_h: spk-amp-enable-h {
1871e141cf1SChris Morgan			rockchip,pins =
1881e141cf1SChris Morgan				<4 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
1891e141cf1SChris Morgan		};
1901e141cf1SChris Morgan	};
1911e141cf1SChris Morgan
19297ce9f36SChris Morgan	gpio-lcd {
19397ce9f36SChris Morgan		lcd_reset: lcd-reset {
19497ce9f36SChris Morgan			rockchip,pins =
19597ce9f36SChris Morgan				<4 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
19697ce9f36SChris Morgan		};
19797ce9f36SChris Morgan	};
19897ce9f36SChris Morgan
199523adb55SChris Morgan	gpio-spi {
200523adb55SChris Morgan		spi_pins: spi-pins {
201523adb55SChris Morgan			rockchip,pins =
202523adb55SChris Morgan				<4 RK_PA7 RK_FUNC_GPIO &pcfg_pull_none>,
203523adb55SChris Morgan				<4 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>,
204523adb55SChris Morgan				<4 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>;
205523adb55SChris Morgan		};
206523adb55SChris Morgan	};
207523adb55SChris Morgan};
20822a91b76SChris Morgan
20922a91b76SChris Morgan&rk817 {
21022a91b76SChris Morgan	rk817_charger: charger {
21122a91b76SChris Morgan		monitored-battery = <&battery>;
21222a91b76SChris Morgan		rockchip,resistor-sense-micro-ohms = <10000>;
21322a91b76SChris Morgan		rockchip,sleep-enter-current-microamp = <300000>;
21422a91b76SChris Morgan		rockchip,sleep-filter-current-microamp = <100000>;
21522a91b76SChris Morgan	};
21622a91b76SChris Morgan};
21797ce9f36SChris Morgan
21897ce9f36SChris Morgan&vp1 {
21997ce9f36SChris Morgan	vp1_out_dsi0: endpoint@ROCKCHIP_VOP2_EP_MIPI0 {
22097ce9f36SChris Morgan		reg = <ROCKCHIP_VOP2_EP_MIPI0>;
22197ce9f36SChris Morgan		remote-endpoint = <&dsi0_in_vp1>;
22297ce9f36SChris Morgan	};
22397ce9f36SChris Morgan};
224