Mainline Linux, Radxa Rock Pi N10, and random TV boxes

| 7 min read

These are some patches that live in my arm64 Linux tree that haven't been mainlined for a reason or another.

Patches number 1 and 2 add the required DTS for booting Linux on some random TV boxes. To be sure, I'll post the images of the boards later. H96 Pro+ has working wi-fi on Mainline which is very handy, while the MXQ Pro 4K I have comes with a clone of Realtek wi-fi chips called SCI Inc. or SciInSX according to the Linux kernel. The history goes back in time with these ones - after using the aml_autoscript dummy file technique to execute an u-boot script in old Amlogic U-boot, I replaced the old U-boot in the MXQ Pro 4k box with an upstream one, which is really nasty to do, I believed I followed https://github.com/hexdump0815/u-boot-misc

In the H96 Pro+ case I left it without U-boot on the eMMC so it needs a SD-card to boot.

From a3c47d4818bf242447a8b2904921731e69c1e4da Mon Sep 17 00:00:00 2001
From: Geraldo Nascimento <[email protected]>
Date: Thu, 9 Feb 2023 12:34:44 -0300
Subject: [PATCH 01/10] Add DTS for MXQ Pro 4k and H96 Pro+

---
arch/arm64/boot/dts/amlogic/Makefile | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/amlogic/Makefile b/arch/arm64/boot/dts/amlogic/Makefile
index 97b42e2100e0..b975b3763365 100644
--- a/arch/arm64/boot/dts/amlogic/Makefile
+++ b/arch/arm64/boot/dts/amlogic/Makefile
@@ -46,6 +46,7 @@ dtb-$(CONFIG_ARCH_MESON) += meson-gxl-s905x-libretech-cc-v2.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxl-s905x-libretech-cc.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxl-s905x-nexbox-a95x.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxl-s905x-p212.dtb
+dtb-$(CONFIG_ARCH_MESON) += meson-mxq.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxm-gt1-ultimate.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxm-khadas-vim2.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxm-mecool-kiii-pro.dtb
@@ -53,6 +54,7 @@ dtb-$(CONFIG_ARCH_MESON) += meson-gxm-minix-neo-u9h.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxm-nexbox-a1.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxm-q200.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxm-q201.dtb
+dtb-$(CONFIG_ARCH_MESON) += meson-gxm-q202.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxm-rbox-pro.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxm-s912-libretech-pc.dtb
dtb-$(CONFIG_ARCH_MESON) += meson-gxm-vega-s96.dtb
--
2.45.2
From 2004addde09155677e75b3cee69a18b0b19dfcd5 Mon Sep 17 00:00:00 2001
From: Geraldo Nascimento <[email protected]>
Date: Thu, 9 Feb 2023 12:42:34 -0300
Subject: [PATCH 02/10] Change Rock Pi N10 USB3.0 port to host, activate GPU,
add DTS for MXQ Pro 4K and H96 Pro+

---
.../arm64/boot/dts/amlogic/meson-gxm-q202.dts | 96 +++++++++++++
arch/arm64/boot/dts/amlogic/meson-mxq.dts | 131 ++++++++++++++++++
arch/arm64/boot/dts/rockchip/rk3399.dtsi | 3 +-
.../dts/rockchip/rk3399pro-vmarc-som.dtsi | 4 +
4 files changed, 233 insertions(+), 1 deletion(-)
create mode 100644 arch/arm64/boot/dts/amlogic/meson-gxm-q202.dts
create mode 100644 arch/arm64/boot/dts/amlogic/meson-mxq.dts

diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-q202.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-q202.dts
new file mode 100644
index 000000000000..a0307c64953c
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-q202.dts
@@ -0,0 +1,96 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2016 Endless Computers, Inc.
+ * Author: Carlo Caione <[email protected]>
+ */

+
+/dts-v1/;
+
+#include <dt-bindings/input/input.h>
+
+#include "meson-gxm.dtsi"
+#include "meson-gx-p23x-q20x.dtsi"
+
+/ {
+ compatible = "amlogic,q200", "amlogic,s912", "amlogic,meson-gxm";
+ model = "Amlogic Meson GXM (S912) Q200 Development Board";
+
+ adc-keys {
+ compatible = "adc-keys";
+ io-channels = <&saradc 0>;
+ io-channel-names = "buttons";
+ keyup-threshold-microvolt = <1710000>;
+
+ button-function {
+ label = "Update";
+ linux,code = <KEY_VENDOR>;
+ press-threshold-microvolt = <10000>;
+ };
+ };
+
+ gpio-keys-polled {
+ compatible = "gpio-keys-polled";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ poll-interval = <100>;
+
+ button@0 {
+ label = "power";
+ linux,code = <KEY_POWER>;
+ gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_LOW>;
+ };
+ };
+};
+
+/* Q200 has exclusive choice between internal or external PHY */
+&ethmac {
+ pinctrl-0 = <&eth_pins>;
+ pinctrl-names = "default";
+
+ /* Select external PHY by default */
+ phy-handle = <&external_phy>;
+
+ amlogic,tx-delay-ns = <2>;
+
+ /* External PHY is in RGMII */
+ phy-mode = "rgmii";
+};
+
+&external_mdio {
+ external_phy: ethernet-phy@0 {
+ /* Realtek RTL8211F (0x001cc916) */
+ reg = <0>;
+ max-speed = <1000>;
+
+ /* Occasional disconnections probably caused by broken
+ Energy Efficient Ethernet */

+ eee-broken-100tx;
+ eee-broken-1000t;
+
+ /* External PHY reset is shared with internal PHY Led signal */
+ reset-assert-us = <10000>;
+ reset-deassert-us = <80000>;
+ reset-gpios = <&gpio GPIOZ_14 GPIO_ACTIVE_LOW>;
+
+ interrupt-parent = <&gpio_intc>;
+ /* MAC_INTR on GPIOZ_15 */
+ interrupts = <25 IRQ_TYPE_LEVEL_LOW>;
+ };
+};
+
+&uart_A {
+ status = "okay";
+ pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
+ pinctrl-names = "default";
+ uart-has-rtscts;
+
+ bluetooth {
+ compatible = "qcom,qca9377-bt";
+ enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
+ max-speed = <2000000>;
+ clocks = <&wifi32k>;
+ clock-names = "lpo";
+
+ };
+
+};
diff --git a/arch/arm64/boot/dts/amlogic/meson-mxq.dts b/arch/arm64/boot/dts/amlogic/meson-mxq.dts
new file mode 100644
index 000000000000..b12871f9c826
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/meson-mxq.dts
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2016 Endless Computers, Inc.
+ * Author: Carlo Caione <[email protected]>
+ */

+
+/dts-v1/;
+
+#include "meson-gxl-s905x-p212.dtsi"
+#include <dt-bindings/sound/meson-aiu.h>
+#include <dt-bindings/leds/common.h>
+
+/ {
+ compatible = "amlogic,p212", "amlogic,s905x", "amlogic,meson-gxl";
+ model = "Amlogic Meson GXL (S905X) P212 MXQ PRO 4K";
+
+ leds {
+ compatible = "gpio-leds";
+
+ led-red {
+ color = <LED_COLOR_ID_RED>;
+ function = LED_FUNCTION_POWER;
+ gpios = <&gpio GPIODV_24 GPIO_ACTIVE_LOW>;
+ panic-indicator;
+ };
+
+ led-blue {
+ color = <LED_COLOR_ID_BLUE>;
+ function = LED_FUNCTION_POWER;
+ gpios = <&gpio GPIODV_26 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ sound {
+ compatible = "amlogic,gx-sound-card";
+ model = "Amlogic Meson GXL (S905X) P212 sound";
+ assigned-clocks = <&clkc CLKID_MPLL0>,
+ <&clkc CLKID_MPLL1>,
+ <&clkc CLKID_MPLL2>;
+ assigned-clock-parents = <0>, <0>, <0>;
+ assigned-clock-rates = <294912000>,
+ <270950400>,
+ <393216000>;
+ status = "okay";
+
+ dai-link-0 {
+ sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>;
+ };
+
+ dai-link-1 {
+ sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>;
+ dai-format = "i2s";
+ mclk-fs = <256>;
+
+ codec-0 {
+ sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
+ };
+ };
+
+ dai-link-2 {
+ sound-dai = <&aiu AIU_HDMI CTRL_OUT>;
+
+ codec-0 {
+ sound-dai = <&hdmi_tx>;
+ };
+ };
+ };
+
+ cvbs-connector {
+ compatible = "composite-video-connector";
+
+ port {
+ cvbs_connector_in: endpoint {
+ remote-endpoint = <&cvbs_vdac_out>;
+ };
+ };
+ };
+
+ hdmi-connector {
+ compatible = "hdmi-connector";
+ type = "a";
+
+ port {
+ hdmi_connector_in: endpoint {
+ remote-endpoint = <&hdmi_tx_tmds_out>;
+ };
+ };
+ };
+};
+
+&usb2_phy1 {
+ /*
+ * HDMI_5V is also used as supply for the USB VBUS.
+ */

+ phy-supply = <&hdmi_5v>;
+};
+
+&aiu {
+ status = "okay";
+};
+
+&cec_AO {
+ status = "okay";
+ pinctrl-0 = <&ao_cec_pins>;
+ pinctrl-names = "default";
+ hdmi-phandle = <&hdmi_tx>;
+};
+
+&cvbs_vdac_port {
+ cvbs_vdac_out: endpoint {
+ remote-endpoint = <&cvbs_connector_in>;
+ };
+};
+
+&hdmi_tx {
+ status = "okay";
+ pinctrl-0 = <&hdmi_hpd_pins>, <&hdmi_i2c_pins>;
+ pinctrl-names = "default";
+ hdmi-supply = <&hdmi_5v>;
+};
+
+&hdmi_tx_tmds_port {
+ hdmi_tx_tmds_out: endpoint {
+ remote-endpoint = <&hdmi_connector_in>;
+ };
+};
+
+/* This UART is brought out to the DB9 connector */
+&uart_AO {
+ status = "okay";
+};
diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 4391aea25984..ce2a5a990a7a 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -452,7 +452,7 @@ usbdrd_dwc3_0: usb@fe800000 {
clocks = <&cru SCLK_USB3OTG0_REF>, <&cru ACLK_USB3OTG0>,
<&cru SCLK_USB3OTG0_SUSPEND>;
clock-names = "ref", "bus_early", "suspend";
- dr_mode = "otg";
+ dr_mode = "host";
phys = <&u2phy0_otg>, <&tcphy0_usb3>;
phy-names = "usb2-phy", "usb3-phy";
phy_type = "utmi_wide";
@@ -461,6 +461,7 @@ usbdrd_dwc3_0: usb@fe800000 {
snps,dis_u2_susphy_quirk;
snps,dis-del-phy-power-chg-quirk;
snps,dis-tx-ipgap-linecheck-quirk;
+ snps,parkmode-disable-ss-quirk;
power-domains = <&power RK3399_PD_USB3>;
status = "disabled";
};
diff --git a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
index bf9eb0405b62..e0242044a897 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
@@ -461,6 +461,10 @@ &usbdrd_dwc3_0 {
status = "okay";
};

+&gpu {
+ status = "okay";
+};
+
&vbus_host {
enable-active-high;
gpio = <&gpio4 RK_PD1 GPIO_ACTIVE_HIGH>; /* USB1_EN_OC# */
--
2.45.2
From 179a2b5b960ab414b7feccb32c1308e68279907c Mon Sep 17 00:00:00 2001
From: Geraldo Nascimento <[email protected]>
Date: Thu, 9 Feb 2023 13:04:44 -0300
Subject: [PATCH 03/10] Activate sound for Rock Pi N10

---
.../dts/rockchip-radxa-dalang-carrier.dtsi | 2 +-
arch/arm64/boot/dts/rockchip/rk3399.dtsi | 6 +-
.../dts/rockchip/rk3399pro-vmarc-som.dtsi | 56 ++++++++++++++++++-
.../drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 12 ++++
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 5 ++
5 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/rockchip-radxa-dalang-carrier.dtsi b/arch/arm/boot/dts/rockchip-radxa-dalang-carrier.dtsi
index da1d548b7330..eb0408c06999 100644
--- a/arch/arm/boot/dts/rockchip-radxa-dalang-carrier.dtsi
+++ b/arch/arm/boot/dts/rockchip-radxa-dalang-carrier.dtsi
@@ -117,7 +117,7 @@ &uart0 {
};

&uart2 {
- status = "okay";
+ status = "disabled";
};

&vopb {
diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index ce2a5a990a7a..34a5164185e3 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -641,8 +641,8 @@ i2c3: i2c@ff130000 {
clocks = <&cru SCLK_I2C3>, <&cru PCLK_I2C3>;
clock-names = "i2c", "pclk";
interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH 0>;
- pinctrl-names = "default";
- pinctrl-0 = <&i2c3_xfer>;
+ //pinctrl-names = "default";
+ //pinctrl-0 = <&i2c3_xfer>;
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
@@ -1714,6 +1714,8 @@ i2s2: i2s@ff8a0000 {
interrupts = <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH 0>;
dmas = <&dmac_bus 4>, <&dmac_bus 5>;
dma-names = "tx", "rx";
+ reset-names = "reset-m", "reset-h";
+ resets = <&cru SRST_I2S2_8CH>, <&cru SRST_H_I2S2_8CH>;
clock-names = "i2s_clk", "i2s_hclk";
clocks = <&cru SCLK_I2S2_8CH>, <&cru HCLK_I2S2_8CH>;
power-domains = <&power RK3399_PD_SDIOAUDIO>;
diff --git a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
index e0242044a897..f40cde7f2fc2 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
@@ -30,6 +30,29 @@ vcc3v3_pcie: vcc-pcie-regulator {
};
};

+
+ es8316-sound {
+ status = "okay";
+ compatible = "simple-audio-card";
+ simple-audio-card,format = "i2s";
+ simple-audio-card,name = "rockchip,es8316-codec";
+ simple-audio-card,mclk-fs = <256>;
+ simple-audio-card,widgets =
+ "Microphone", "Mic Jack",
+ "Headphone", "Headphone Jack";
+ simple-audio-card,routing =
+ "Headphone Jack", "HPOL",
+ "Headphone Jack", "HPOR";
+
+ simple-audio-card,cpu {
+ sound-dai = <&i2s0>;
+ };
+
+ simple-audio-card,codec {
+ sound-dai = <&es8316>;
+ };
+ };
+
&cpu_l0 {
cpu-supply = <&vdd_cpu_l>;
};
@@ -59,7 +82,7 @@ &gmac {
&hdmi {
ddc-i2c-bus = <&i2c3>;
pinctrl-names = "default";
- pinctrl-0 = <&hdmi_cec>;
+ pinctrl-0 = <&hdmi_cec &hdmi_i2c_xfer>;
};

&i2c0 {
@@ -312,12 +335,39 @@ hym8563: rtc@51 {
&i2c3 {
i2c-scl-rising-time-ns = <450>;
i2c-scl-falling-time-ns = <15>;
+ assigned-clock-rates = <100000000>;
+ status = "okay";
+};
+
+&i2c4 {
+ i2c-scl-rising-time-ns = <300>;
+ i2c-scl-falling-time-ns = <15>;
+ status = "okay";
+
+ es8316: codec@11 {
+ compatible = "everest,es8316";
+ reg = <0x11>;
+ clocks = <&cru SCLK_I2S_8CH_OUT>;
+ clock-names = "mclk";
+ #sound-dai-cells = <0>;
+ };
+};
+
+&i2s0 {
+ pinctrl-0 = <&i2s0_8ch_bus>;
+ status = "okay";
+};
+
+
+&i2s2 {
+ assigned-clocks = <&cru SCLK_I2S2_DIV>;
status = "okay";
};

&io_domains {
status = "okay";
bt656-supply = <&vcca_1v8>;
+ audio-supply = <&vcca_1v8>;
gpio1830-supply = <&vccio_3v0>;
sdmmc-supply = <&vccio_sd>;
};
@@ -465,6 +515,10 @@ &gpu {
status = "okay";
};

+&hdmi_sound {
+ status = "okay";
+};
+
&vbus_host {
enable-active-high;
gpio = <&gpio4 RK_PD1 GPIO_ACTIVE_HIGH>; /* USB1_EN_OC# */
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
index d751820c6da6..a6b63fc4aeec 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
@@ -42,6 +42,7 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,
struct dw_hdmi *hdmi = audio->hdmi;
u8 conf0 = 0;
u8 conf1 = 0;
+ u8 conf2 = 0;
u8 inputclkfs = 0;

/* it cares I2S only */
@@ -101,6 +102,16 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,
return -EINVAL;
}

+ /*
+ * dw-hdmi introduced insert_pcuv bit in version 2.10a.
+ * When set (1'b1), this bit enables the insertion of the PCUV
+ * (Parity, Channel Status, User bit and Validity) bits on the
+ * incoming audio stream (support limited to Linear PCM audio)
+ */

+ if (hdmi_read(audio, HDMI_DESIGN_ID) >= 0x21 &&
+ !(hparms->iec.status[0] & IEC958_AES0_NONAUDIO))
+ conf2 = HDMI_AUD_CONF2_INSERT_PCUV;
+
dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate);
dw_hdmi_set_channel_status(hdmi, hparms->iec.status);
dw_hdmi_set_channel_count(hdmi, hparms->channels);
@@ -109,6 +120,7 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,
hdmi_write(audio, inputclkfs, HDMI_AUD_INPUTCLKFS);
hdmi_write(audio, conf0, HDMI_AUD_CONF0);
hdmi_write(audio, conf1, HDMI_AUD_CONF1);
+ hdmi_write(audio, conf2, HDMI_AUD_CONF2);

return 0;
}
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h
index af43a0414b78..d7cbdc42d501 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h
@@ -931,6 +931,11 @@ enum {
HDMI_AUD_CONF1_WIDTH_16 = 0x10,
HDMI_AUD_CONF1_WIDTH_24 = 0x18,

+/* AUD_CONF2 field values */
+ HDMI_AUD_CONF2_HBR = 0x1,
+ HDMI_AUD_CONF2_NLPCM = 0x2,
+ HDMI_AUD_CONF2_INSERT_PCUV = 0x04,
+
/* AUD_CTS3 field values */
HDMI_AUD_CTS3_N_SHIFT_OFFSET = 5,
HDMI_AUD_CTS3_N_SHIFT_MASK = 0xe0,
--
2.45.2
From 731c9389a2400d7c362579c706f1bf1cb55ec7c9 Mon Sep 17 00:00:00 2001
From: Geraldo Nascimento <[email protected]>
Date: Thu, 9 Feb 2023 13:14:37 -0300
Subject: [PATCH 04/10] Add I2S CLK DIV for RK3399

---
arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi | 3 +--
include/dt-bindings/clock/rk3399-cru.h | 3 +++
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
index f40cde7f2fc2..aa0994bef700 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
@@ -28,8 +28,6 @@ vcc3v3_pcie: vcc-pcie-regulator {
regulator-boot-on;
vin-supply = <&vcc5v0_sys>;
};
-};
-

es8316-sound {
status = "okay";
@@ -52,6 +50,7 @@ simple-audio-card,codec {
sound-dai = <&es8316>;
};
};
+};

&cpu_l0 {
cpu-supply = <&vdd_cpu_l>;
diff --git a/include/dt-bindings/clock/rk3399-cru.h b/include/dt-bindings/clock/rk3399-cru.h
index 39169d94a44e..4cc0dcd5bfb9 100644
--- a/include/dt-bindings/clock/rk3399-cru.h
+++ b/include/dt-bindings/clock/rk3399-cru.h
@@ -125,6 +125,9 @@
#define SCLK_DDRC 168
#define SCLK_TESTCLKOUT1 169
#define SCLK_TESTCLKOUT2 170
+#define SCLK_I2S0_DIV 174
+#define SCLK_I2S1_DIV 175
+#define SCLK_I2S2_DIV 176

#define DCLK_VOP0 180
#define DCLK_VOP1 181
--
2.45.2
From 09017ffad00a76b363de81730d947e51324bb9d3 Mon Sep 17 00:00:00 2001
From: Geraldo Nascimento <[email protected]>
Date: Fri, 10 Feb 2023 04:21:19 -0300
Subject: [PATCH 05/10] I2C3 xfer on the RK3399pro belongs on the i2c3 node
unlike in the downstream kernel. Do that or get no EDID

---
arch/arm64/boot/dts/rockchip/rk3399.dtsi | 4 ++--
arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 34a5164185e3..940752dce7b4 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -641,8 +641,8 @@ i2c3: i2c@ff130000 {
clocks = <&cru SCLK_I2C3>, <&cru PCLK_I2C3>;
clock-names = "i2c", "pclk";
interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH 0>;
- //pinctrl-names = "default";
- //pinctrl-0 = <&i2c3_xfer>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c3_xfer>;
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
diff --git a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
index aa0994bef700..ddcf4377064f 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
@@ -81,7 +81,7 @@ &gmac {
&hdmi {
ddc-i2c-bus = <&i2c3>;
pinctrl-names = "default";
- pinctrl-0 = <&hdmi_cec &hdmi_i2c_xfer>;
+ pinctrl-0 = <&hdmi_cec>;
};

&i2c0 {
--
2.45.2
From 60a826350a9293c723f7bbce1d5c7e2b23421eb2 Mon Sep 17 00:00:00 2001
From: Geraldo Nascimento <[email protected]>
Date: Sun, 16 Jul 2023 20:58:38 -0300
Subject: [PATCH 08/10] Add analog sound to MXQ Pro 4K TV Box, IR capabilities
to RK3399Pro and set cap-sdio-irq for H96 Pro+ TV Box

---
.../boot/dts/amlogic/meson-gx-p23x-q20x.dtsi | 1 +
arch/arm64/boot/dts/amlogic/meson-mxq.dts | 18 ++++++++++++++++++
.../boot/dts/rockchip/rk3399pro-vmarc-som.dtsi | 17 +++++++++++++++--
3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi
index dafc841f7c16..a8085c1dd2f2 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi
@@ -300,6 +300,7 @@ &sd_emmc_c {

bus-width = <8>;
cap-mmc-highspeed;
+ cap-sdio-irq;
max-frequency = <200000000>;
non-removable;
disable-wp;
diff --git a/arch/arm64/boot/dts/amlogic/meson-mxq.dts b/arch/arm64/boot/dts/amlogic/meson-mxq.dts
index b12871f9c826..1b976891de5d 100644
--- a/arch/arm64/boot/dts/amlogic/meson-mxq.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-mxq.dts
@@ -55,6 +55,10 @@ dai-link-1 {
codec-0 {
sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
};
+
+ codec-1 {
+ sound-dai = <&aiu AIU_ACODEC CTRL_I2S>;
+ };
};

dai-link-2 {
@@ -64,6 +68,14 @@ codec-0 {
sound-dai = <&hdmi_tx>;
};
};
+
+ dai-link-3 {
+ sound-dai = <&aiu AIU_ACODEC CTRL_OUT>;
+
+ codec-0 {
+ sound-dai = <&acodec>;
+ };
+ };
};

cvbs-connector {
@@ -88,6 +100,12 @@ hdmi_connector_in: endpoint {
};
};

+&acodec {
+ AVDD-supply = <&vddio_ao18>;
+ status = "okay";
+};
+
+
&usb2_phy1 {
/*
* HDMI_5V is also used as supply for the USB VBUS.
diff --git a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
index ddcf4377064f..efc19c0f2cd7 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399pro-vmarc-som.dtsi
@@ -50,6 +50,13 @@ simple-audio-card,codec {
sound-dai = <&es8316>;
};
};
+
+ ir-receiver {
+ compatible = "gpio-ir-receiver";
+ gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_LOW>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&ir_int>;
+ };
};

&cpu_l0 {
@@ -334,8 +341,8 @@ hym8563: rtc@51 {
&i2c3 {
i2c-scl-rising-time-ns = <450>;
i2c-scl-falling-time-ns = <15>;
- assigned-clock-rates = <100000000>;
- status = "okay";
+ assigned-clock-rates = <100000000>;
+ status = "okay";
};

&i2c4 {
@@ -393,6 +400,12 @@ hym8563_int: hym8563-int {
};
};

+ ir {
+ ir_int: ir-int {
+ rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
+ };
+ };
+
pcie {
pcie_pwr: pcie-pwr {
rockchip,pins = <4 RK_PD4 RK_FUNC_GPIO &pcfg_pull_up>;
--
2.45.2
From 8c5aeb3c1880ef870797cc96518db24d6168f51a Mon Sep 17 00:00:00 2001
From: Geraldo Nascimento <[email protected]>
Date: Tue, 18 Jun 2024 00:55:30 -0300
Subject: [PATCH 10/10] dts/rockchip: Enforce lower clock on Rock Pi N10

It seems some cuts of the RK3399Pro present on the
Rock Pi N10 will cause system instability with default
operating points.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212917
Signed-off-by: Geraldo Nascimento <[email protected]>
---
arch/arm64/boot/dts/rockchip/rk3399pro-rock-pi-n10.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399pro-rock-pi-n10.dts b/arch/arm64/boot/dts/rockchip/rk3399pro-rock-pi-n10.dts
index c58fb7658d7a..1aa5e964f741 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399pro-rock-pi-n10.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399pro-rock-pi-n10.dts
@@ -7,7 +7,7 @@

/dts-v1/;
#include "rk3399.dtsi"
-#include "rk3399-opp.dtsi"
+#include "rk3399-t-opp.dtsi"
#include <arm/rockchip/rockchip-radxa-dalang-carrier.dtsi>
#include "rk3399pro-vmarc-som.dtsi"

--
2.45.2