From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: brentr <brent@mbari.org>
Date: Fri, 23 Dec 2022 21:57:53 +0100
Subject: [ARCHEOLOGY] Rockpis devtree mainlined (#4603)

> X-Git-Archeology: > recovered message: > * moved rockpro64 patch out of rockpis patch sequence
> X-Git-Archeology: > recovered message: > It had been misnamed
> X-Git-Archeology: > recovered message: > * patch new mainline devtree for Rock Pi-S instead of overwritting it.
> X-Git-Archeology: > recovered message: > Also restores lost bluetooth compatibility items on UART4
> X-Git-Archeology: - Revision 588c2ec17e709dec19304fa50522459702ebfadd: https://github.com/armbian/build/commit/588c2ec17e709dec19304fa50522459702ebfadd
> X-Git-Archeology:   Date: Fri, 23 Dec 2022 21:57:53 +0100
> X-Git-Archeology:   From: brentr <brent@mbari.org>
> X-Git-Archeology:   Subject: Rockpis devtree mainlined (#4603)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 34ae84fac5d0b66a1ab2d1e51534b7beb13ef245: https://github.com/armbian/build/commit/34ae84fac5d0b66a1ab2d1e51534b7beb13ef245
> X-Git-Archeology:   Date: Fri, 05 May 2023 14:22:00 +0200
> X-Git-Archeology:   From: amazingfate <liujianfeng1994@gmail.com>
> X-Git-Archeology:   Subject: bump rockchip64 edge to v6.3
> X-Git-Archeology:
---
 arch/arm64/boot/dts/rockchip/rk3308-rock-pi-s.dts | 240 +++++++---
 1 file changed, 164 insertions(+), 76 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3308-rock-pi-s.dts b/arch/arm64/boot/dts/rockchip/rk3308-rock-pi-s.dts
index e9810d2f0407..0d917658d24a 100644
--- a/arch/arm64/boot/dts/rockchip/rk3308-rock-pi-s.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3308-rock-pi-s.dts
@@ -2,6 +2,7 @@
 /*
  * Copyright (c) 2019 Akash Gajjar <akash@openedev.com>
  * Copyright (c) 2019 Jagan Teki <jagan@openedev.com>
+ * Revised: 2022 Brent Roman <brent@mbari.org>
  */
 
 /dts-v1/;
@@ -11,12 +12,6 @@ / {
 	model = "Radxa ROCK Pi S";
 	compatible = "radxa,rockpis", "rockchip,rk3308";
 
-	aliases {
-		ethernet0 = &gmac;
-		mmc0 = &emmc;
-		mmc1 = &sdmmc;
-	};
-
 	chosen {
 		stdout-path = "serial0:1500000n8";
 	};
@@ -27,44 +22,102 @@ leds {
 		pinctrl-0 = <&green_led_gio>, <&heartbeat_led_gpio>;
 
 		green-led {
-			default-state = "on";
-			gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_HIGH>;
 			label = "rockpis:green:power";
+			gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_HIGH>;
 			linux,default-trigger = "default-on";
+			default-state = "on";
 		};
 
 		blue-led {
-			default-state = "on";
-			gpios = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;
 			label = "rockpis:blue:user";
+			gpios = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;
 			linux,default-trigger = "heartbeat";
+			default-state = "on";
 		};
 	};
 
+	codec: acodec-sound {
+			compatible = "simple-audio-card";
+			simple-audio-card,format = "i2s";
+			simple-audio-card,name = "rockchip,rk3308-acodec";
+			simple-audio-card,mclk-fs = <256>;
+			simple-audio-card,codec-hp-det;
+			simple-audio-card,widgets =
+				"Headphone", "Headphones";
+			simple-audio-card,cpu {
+				sound-dai = <&i2s_8ch_2>;
+			};
+			simple-audio-card,codec {
+				sound-dai = <&acodec>;
+			};
+	};
+
+	sound {
+		compatible = "simple-audio-card";
+		simple-audio-card,format = "i2s";
+		simple-audio-card,mclk-fs = <256>;
+		simple-audio-card,name = "i2s_8ch_0";
+
+		simple-audio-card,dai-link@1 {
+			format = "i2s";
+			cpu {
+				sound-dai = <&i2s_8ch_0>;
+			};
+
+			codec {
+				sound-dai = <&pcm5102a>;
+			};
+		};
+	};
+
+	pcm5102a: pcm5102a {
+			#sound-dai-cells = <0>;
+			compatible = "ti,pcm5102a";
+			pcm510x,format = "i2s";
+	};
+
 	sdio_pwrseq: sdio-pwrseq {
 		compatible = "mmc-pwrseq-simple";
 		pinctrl-0 = <&wifi_enable_h>;
 		pinctrl-names = "default";
+		/*
+		 * On the module itself this is one of these (depending
+		 * on the actual card populated):
+		 * - SDIO_RESET_L_WL_REG_ON
+		 * - PDN (power down when low)
+		 */
 		reset-gpios = <&gpio0 RK_PA2 GPIO_ACTIVE_LOW>;
 	};
 
-	vcc_1v8: vcc-1v8 {
+	vcc5v0_sys: vcc5v0-sys {
 		compatible = "regulator-fixed";
-		regulator-name = "vcc_1v8";
+		regulator-name = "vcc5v0_sys";
 		regulator-always-on;
 		regulator-boot-on;
-		regulator-min-microvolt = <1800000>;
-		regulator-max-microvolt = <1800000>;
-		vin-supply = <&vcc_io>;
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
 	};
 
-	vcc_io: vcc-io {
+	vdd_core: vdd-core {
+		compatible = "pwm-regulator";
+		pwms = <&pwm0 0 5000 1>;
+		regulator-name = "vdd_core";
+		regulator-min-microvolt = <827000>;
+		regulator-max-microvolt = <1340000>;
+		regulator-init-microvolt = <1015000>;
+		regulator-settling-time-up-us = <250>;
+		regulator-always-on;
+		regulator-boot-on;
+		pwm-supply = <&vcc5v0_sys>;
+	};
+
+	vdd_log: vdd-log {
 		compatible = "regulator-fixed";
-		regulator-name = "vcc_io";
+		regulator-name = "vdd_log";
 		regulator-always-on;
 		regulator-boot-on;
-		regulator-min-microvolt = <3300000>;
-		regulator-max-microvolt = <3300000>;
+		regulator-min-microvolt = <1050000>;
+		regulator-max-microvolt = <1050000>;
 		vin-supply = <&vcc5v0_sys>;
 	};
 
@@ -78,49 +131,50 @@ vcc_ddr: vcc-ddr {
 		vin-supply = <&vcc5v0_sys>;
 	};
 
-	vcc5v0_otg: vcc5v0-otg {
+	vcc_1v8: vcc-1v8 {
 		compatible = "regulator-fixed";
-		enable-active-high;
-		gpio = <&gpio0 RK_PC5 GPIO_ACTIVE_HIGH>;
-		pinctrl-names = "default";
-		pinctrl-0 = <&otg_vbus_drv>;
-		regulator-name = "vcc5v0_otg";
+		regulator-name = "vcc_1v8";
 		regulator-always-on;
-		vin-supply = <&vcc5v0_sys>;
+		regulator-boot-on;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		vin-supply = <&vcc_io>;
 	};
 
-	vcc5v0_sys: vcc5v0-sys {
+	vcc_io: vcc-io {
 		compatible = "regulator-fixed";
-		regulator-name = "vcc5v0_sys";
+		regulator-name = "vcc_io";
 		regulator-always-on;
 		regulator-boot-on;
-		regulator-min-microvolt = <5000000>;
-		regulator-max-microvolt = <5000000>;
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		vin-supply = <&vcc5v0_sys>;
 	};
 
-	vdd_core: vdd-core {
-		compatible = "pwm-regulator";
-		pwms = <&pwm0 0 5000 1>;
-		pwm-supply = <&vcc5v0_sys>;
-		regulator-name = "vdd_core";
-		regulator-min-microvolt = <827000>;
-		regulator-max-microvolt = <1340000>;
-		regulator-settling-time-up-us = <250>;
+  vcc_phy: vcc-phy-regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc_phy";
 		regulator-always-on;
 		regulator-boot-on;
 	};
 
-	vdd_log: vdd-log {
+	vcc5v0_otg: vcc5v0-otg {
 		compatible = "regulator-fixed";
-		regulator-name = "vdd_log";
+		regulator-name = "vcc5v0_otg";
 		regulator-always-on;
-		regulator-boot-on;
-		regulator-min-microvolt = <1050000>;
-		regulator-max-microvolt = <1050000>;
+		gpio = <&gpio0 RK_PC5 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		pinctrl-names = "default";
+		pinctrl-0 = <&otg_vbus_drv>;
 		vin-supply = <&vcc5v0_sys>;
 	};
 };
 
+&acodec {
+	status = "okay";
+	#sound-dai-cells = <0>;
+};
+
 &cpu0 {
 	cpu-supply = <&vdd_core>;
 };
@@ -128,23 +182,60 @@ &cpu0 {
 &emmc {
 	bus-width = <4>;
 	cap-mmc-highspeed;
-	mmc-hs200-1_8v;
 	non-removable;
-	vmmc-supply = <&vcc_io>;
 	status = "okay";
 };
 
+&sdmmc {
+	cap-mmc-highspeed;
+	cap-sd-highspeed;
+	disable-wp;
+	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_det &sdmmc_bus4>;
+	card-detect-delay = <800>;
+	status = "okay";
+};
+
+&sdio {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	cap-sd-highspeed;
+	cap-sdio-irq;
+	keep-power-in-suspend;
+	mmc-pwrseq = <&sdio_pwrseq>;
+	non-removable;
+	no-mmc;
+	status = "okay";
+
+	rtl8723ds: wifi@1 {
+		interrupt-parent = <&gpio0>;
+		interrupts = <RK_PA3 GPIO_ACTIVE_HIGH>;
+		interrupt-names = "host-wake";
+		pinctrl-names = "default";
+		pinctrl-0 = <&wifi_host_wake>;
+	};
+};
+
 &gmac {
+	phy-supply = <&vcc_phy>;
 	clock_in_out = "output";
-	phy-supply = <&vcc_io>;
+	assigned-clocks = <&cru SCLK_MAC>;
+	assigned-clock-parents = <&cru SCLK_MAC_SRC>;
 	snps,reset-gpio = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>;
 	snps,reset-active-low;
 	snps,reset-delays-us = <0 50000 50000>;
 	status = "okay";
 };
 
-&i2c1 {
+&i2s_8ch_0 {
+	assigned-clocks = <&cru SCLK_I2S0_8CH_RX>;
+	assigned-clock-parents = <&cru SCLK_I2S0_8CH_TX_MUX>;
+	rockchip,clk-trcm = <1>;
+	#sound-dai-cells = <0>;
+};
+
+&i2s_8ch_2 {
 	status = "okay";
+	#sound-dai-cells = <0>;
 };
 
 &pinctrl {
@@ -171,7 +262,9 @@ sdio-pwrseq {
 		wifi_enable_h: wifi-enable-h {
 			rockchip,pins = <0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
 		};
+	};
 
+	wifi {
 		wifi_host_wake: wifi-host-wake {
 			rockchip,pins = <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_down>;
 		};
@@ -188,42 +281,29 @@ &saradc {
 	status = "okay";
 };
 
-&sdio {
-	#address-cells = <1>;
-	#size-cells = <0>;
-	cap-sd-highspeed;
-	cap-sdio-irq;
-	keep-power-in-suspend;
-	max-frequency = <1000000>;
-	mmc-pwrseq = <&sdio_pwrseq>;
-	non-removable;
-	sd-uhs-sdr104;
+&tsadc {
+	rockchip,hw-tshut-mode = <0>;		/* 0:CRU */
+	rockchip,hw-tshut-polarity = <1>;	/* 1:HIGH */
 	status = "okay";
 };
 
-&sdmmc {
-	cap-sd-highspeed;
+&i2c1 {
 	status = "okay";
 };
 
-&u2phy {
-	status = "okay";
-
-	u2phy_host: host-port {
-		phy-supply = <&vcc5v0_otg>;
-		status = "okay";
-	};
-
-	u2phy_otg: otg-port {
-		phy-supply = <&vcc5v0_otg>;
-		status = "okay";
-	};
+&spi2 {
+//	status = "okay";  //conflicts with UART2
+	max-freq = <10000000>;
 };
 
 &uart0 {
 	status = "okay";
 };
 
+&uart2 {
+	status = "okay";
+};
+
 &uart4 {
 	status = "okay";
 
@@ -234,19 +314,27 @@ bluetooth {
 	};
 };
 
-&usb_host_ehci {
+&u2phy {
 	status = "okay";
+
+	u2phy_host: host-port {
+		phy-supply = <&vcc5v0_otg>;
+		status = "okay";
+	};
+
+	u2phy_otg: otg-port {
+		status = "okay";
+	};
 };
 
-&usb_host_ohci {
+&usb20_otg {
 	status = "okay";
 };
 
-&usb20_otg {
-	dr_mode = "peripheral";
+&usb_host_ehci {
 	status = "okay";
 };
 
-&wdt {
+&usb_host_ohci{
 	status = "okay";
 };
-- 
Armbian

