From 18d939edfd0de05a511eba3ecb0331eaf2fb1b80 Mon Sep 17 00:00:00 2001 From: The-going <48602507+The-going@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:09:58 +0300 Subject: [PATCH] sunxi-6.16: add sun50i-h618-bananapi-m4-zero support --- .../sunxi-6.16/0000.patching_config.yaml | 38 ++ .../dt/sun50i-h618-bananapi-m4-zero.dts | 111 +++++ .../dt/sun50i-h618-bananapi-m4.dtsi | 296 +++++++++++++ .../sunxi-6.16/dt/sun50i-h618-kickpi-k2b.dts | 405 ++++++++++++++++++ 4 files changed, 850 insertions(+) create mode 100644 patch/kernel/archive/sunxi-6.16/0000.patching_config.yaml create mode 100644 patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-bananapi-m4-zero.dts create mode 100644 patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-bananapi-m4.dtsi create mode 100644 patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-kickpi-k2b.dts diff --git a/patch/kernel/archive/sunxi-6.16/0000.patching_config.yaml b/patch/kernel/archive/sunxi-6.16/0000.patching_config.yaml new file mode 100644 index 000000000..bdfda9444 --- /dev/null +++ b/patch/kernel/archive/sunxi-6.16/0000.patching_config.yaml @@ -0,0 +1,38 @@ +config: + + # Just some info stuff; not used by the patching scripts + name: sunxi-6.16 + kind: kernel + type: mainline # or: mainline + branch: linux-6.16.y + last-known-good-tag: v6.7.0 + maintainers: + - { github: pyavitz, name: Patrick Yavitz, email: pyavitz@gmail.com, armbian-forum: c0rnelius } + + # .dts files in these directories will be copied as-is to the build tree; later ones overwrite earlier ones. + # This is meant to provide a way to "add a board DTS" without having to null-patch them in. + dts-directories: + # will copy patch/kernel/archive/meson64-MAJOR.MINOR/dt-boards/*.dts to arch/arm64/boot/dts/allwinner + - { source: "dt", target: "arch/arm64/boot/dts/allwinner" } + + # every file in these directories will be copied as-is to the build tree; later ones overwrite earlier ones + # This is meant as a way to have overlays, bare, in a directory, without having to null-patch them in. + # @TODO need a solution to auto-Makefile the overlays as well +# overlay-directories: + # will copy patch/kernel/archive/meson64-MAJOR.MINOR/overlay/**/* to arch/arm64/boot/dts/allwinner/overlay +# - { source: "overlay", target: "arch/arm64/boot/dts/allwinner/overlay" } + + # the Makefile in each of these directories will be magically patched to include the dts files copied + # or patched-in; overlay subdir will be included "-y" if it exists. + # No more Makefile patching needed, yay! + auto-patch-dt-makefile: + - { directory: "arch/arm64/boot/dts/allwinner", config-var: "CONFIG_ARCH_SUNXI" } + + # configuration for when applying patches to git / auto-rewriting patches (development cycle helpers) + patches-to-git: + do-not-commit-files: + - "MAINTAINERS" # constant churn, drop them. sorry. + - "Documentation/devicetree/bindings/arm/allwinner.yaml" # constant churn, conflicts on every bump, drop it. sorry. + do-not-commit-regexes: # Python-style regexes + - "^arch/([a-zA-Z0-9]+)/boot/dts/([a-zA-Z0-9]+)/Makefile$" # ignore DT Makefile patches, we've an auto-patcher now + diff --git a/patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-bananapi-m4-zero.dts b/patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-bananapi-m4-zero.dts new file mode 100644 index 000000000..933c1336e --- /dev/null +++ b/patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-bananapi-m4-zero.dts @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2025 Patrick Yavitz + */ + +/dts-v1/; + +#include "sun50i-h618-bananapi-m4.dtsi" + +/ { + model = "BananaPi BPI-M4-Zero"; + compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h618"; + + aliases { + ethernet0 = &emac1; + i2c0 = &i2c0; + i2c1 = &i2c1; + i2c3 = &i2c3; + i2c4 = &i2c4; + serial4 = &uart4; + serial5 = &uart5; + spi1 = &spi1; + }; + + leds { + compatible = "gpio-leds"; + + led-0 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&pio 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */ + linux,default-trigger = "heartbeat"; + }; + }; +}; + +/* Connected to an on-board RTL8821CU USB WiFi chip. */ +&ehci1 { + status = "okay"; +}; + +&ehci2 { + status = "okay"; +}; + +&ehci3 { + status = "okay"; +}; + +&emac1 { + status = "disabled"; + pinctrl-names = "default"; + pinctrl-0 = <&rmii_pins>; + phy-mode = "rmii"; + phy-handle = <&rmii_phy>; + phy-supply = <®_dldo1>; + allwinner,rx-delay-ps = <3100>; + allwinner,tx-delay-ps = <700>; +}; + +&mdio1 { + rmii_phy: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; +}; + +/* SDIO */ +&mmc1 { + status = "disabled"; + bus-width = <4>; + max-frequency = <100000000>; + + non-removable; + disable-wp; + + /* WiFi firmware requires power to be kept while in suspend */ + keep-power-in-suspend; + + mmc-pwrseq = <&wifi_pwrseq>; + + cd-gpios = <&pio 6 15 GPIO_ACTIVE_HIGH>; /* PG15 */ + vmmc-supply = <®_vcc3v3>; + + sdio: wifi@1 { + reg = <1>; + compatible = "brcm,bcm4329-fmac"; + }; +}; + +&ohci1 { + status = "okay"; +}; + +&ohci2 { + status = "okay"; +}; + +&ohci3 { + status = "okay"; +}; + +&usbotg { + status = "okay"; + dr_mode = "peripheral"; +}; + +&usbphy { + status = "okay"; + usb1_vbus-supply = <®_usb_vbus>; +}; diff --git a/patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-bananapi-m4.dtsi b/patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-bananapi-m4.dtsi new file mode 100644 index 000000000..4b34a892a --- /dev/null +++ b/patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-bananapi-m4.dtsi @@ -0,0 +1,296 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2025 Patrick Yavitz + */ + +/dts-v1/; + +#include "sun50i-h616.dtsi" +#include "sun50i-h616-cpu-opp.dtsi" + +#include +#include +#include +#include + +/ { + aliases { + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + kaslr-seed = <0xfeedbeef 0xc0def00d>; + }; + + connector { + compatible = "hdmi-connector"; + type = "d"; + + port { + hdmi_con_in: endpoint { + remote-endpoint = <&hdmi_out_con>; + }; + }; + }; + + reg_usb_vbus: regulator-usb-vbus { + /* Separate discrete regulator for the USB ports */ + compatible = "regulator-fixed"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-name = "usb-vbus"; + vin-supply = <®_vcc5v>; + }; + + reg_vcc5v: regulator-vcc5v { + /* Board wide 5V supply directly from the USB-C socket */ + compatible = "regulator-fixed"; + regulator-always-on; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-name = "vcc-5v"; + }; + + reg_vcc3v3: regulator-vcc3v3 { + compatible = "regulator-fixed"; + regulator-always-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc-3v3"; + vin-supply = <®_vcc5v>; + }; + + reg_vcc1v8: regulator-vcc1v8 { + compatible = "regulator-fixed"; + regulator-always-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcc-1v8"; + vin-supply = <®_vcc3v3>; + }; + + wifi_pwrseq: wifi-pwrseq { + compatible = "mmc-pwrseq-simple"; + clocks = <&rtc CLK_OSC32K_FANOUT>; + clock-names = "ext_clock"; + pinctrl-0 = <&x32clk_fanout_pin>; + pinctrl-names = "default"; + post-power-on-delay-ms = <200>; + reset-gpios = <&pio 6 18 GPIO_ACTIVE_LOW>; /* PG18 */ + }; +}; + +&ahub_dam_plat { + status = "okay"; +}; + +&ahub1_plat { + status = "okay"; +}; + +&ahub1_mach { + status = "okay"; +}; + +&codec { + status = "disabled"; + allwinner,audio-routing = "Line Out", "LINEOUT"; +}; + +&cpu0 { + cpu-supply = <®_dcdc2>; +}; + +&de { + status = "okay"; +}; + +&gpu { + status = "disabled"; + mali-supply = <®_dcdc1>; +}; + +&hdmi { + status = "okay"; +}; + +&hdmi_out { + hdmi_out_con: endpoint { + remote-endpoint = <&hdmi_con_in>; + }; +}; + +&i2c0 { + status = "disabled"; + pinctrl-0 = <&i2c0_pins>; + pinctrl-names = "default"; +}; + +&i2c1 { + status = "disabled"; + pinctrl-0 = <&i2c1_pi_pins>; + pinctrl-names = "default"; +}; + +&i2c3 { + status = "disabled"; + pinctrl-0 = <&i2c3_pg_pins>; + pinctrl-names = "default"; +}; + +&i2c4 { + status = "disabled"; + pinctrl-0 = <&i2c4_pg_pins>; + pinctrl-names = "default"; +}; + +&ir { + status = "disabled"; + pinctrl-0 = <&ir_rx_pin>; + pinctrl-names = "default"; +}; + +/* SD card */ +&mmc0 { + status = "okay"; + bus-width = <4>; + max-frequency = <50000000>; + + disable-wp; + + cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */ + vmmc-supply = <®_vcc3v3>; +}; + +/* eMMC */ +&mmc2 { + status = "okay"; + bus-width = <8>; + cap-mmc-hw-reset; + mmc-hs200-1_8v; + + non-removable; + disable-wp; + + vmmc-supply = <®_vcc3v3>; + vqmmc-supply = <®_vcc1v8>; +}; + +&pio { + vcc-pc-supply = <®_aldo1>; + vcc-pf-supply = <®_dldo1>; + vcc-pg-supply = <®_dldo1>; + vcc-ph-supply = <®_dldo1>; + vcc-pi-supply = <®_dldo1>; + + /* PC0 required for spi0 */ + mmc2_pins: mmc2-pins { + pins = "PC1", "PC5", "PC6", + "PC8", "PC9", "PC10", "PC11", + "PC13", "PC14", "PC15", "PC16"; + function = "mmc2"; + drive-strength = <30>; + bias-pull-up; + }; +}; + +&r_i2c { + status = "okay"; + axp313: pmic@36 { + compatible = "x-powers,axp313a"; + reg = <0x36>; + #interrupt-cells = <1>; + interrupt-controller; + interrupt-parent = <&pio>; + + vin1-supply = <®_vcc5v>; + vin2-supply = <®_vcc5v>; + vin3-supply = <®_vcc5v>; + + regulators { + reg_aldo1: aldo1 { + regulator-always-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcc-1v8-pll"; + }; + + reg_dldo1: dldo1 { + regulator-always-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc-3v3-io"; + }; + + reg_dcdc1: dcdc1 { + regulator-always-on; + regulator-min-microvolt = <810000>; + regulator-max-microvolt = <990000>; + regulator-name = "vdd-gpu-sys"; + }; + + reg_dcdc2: dcdc2 { + regulator-always-on; + regulator-min-microvolt = <810000>; + regulator-max-microvolt = <1100000>; + regulator-name = "vdd-cpu"; + }; + + reg_dcdc3: dcdc3 { + regulator-always-on; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + regulator-name = "vdd-dram"; + }; + }; + }; +}; + +&spi0 { + status = "disabled"; + pinctrl-0 = <&spi0_pins>, <&spi1_cs0_pin>; + pinctrl-names = "default"; + + spidev@1 { + compatible = "rohm,dh2228fv"; + reg = <1>; + spi-max-frequency = <1000000>; + }; +}; + +&spi1 { + status = "disabled"; + pinctrl-0 = <&spi1_pins>, <&spi1_cs1_pin>; + pinctrl-names = "default"; + + spidev@1 { + compatible = "rohm,dh2228fv"; + reg = <1>; + spi-max-frequency = <1000000>; + }; +}; + +&uart0 { + status = "okay"; + pinctrl-0 = <&uart0_ph_pins>; + pinctrl-names = "default"; +}; + +&uart1 { + status = "disabled"; + pinctrl-0 = <&uart1_pins>; + pinctrl-names = "default"; +}; + +&uart4 { + status = "disabled"; + pinctrl-0 = <&uart4_pi_pins>; + pinctrl-names = "default"; +}; + +&uart5 { + status = "disabled"; + pinctrl-0 = <&uart5_pins>; + pinctrl-names = "default"; +}; diff --git a/patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-kickpi-k2b.dts b/patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-kickpi-k2b.dts new file mode 100644 index 000000000..3dc98ab94 --- /dev/null +++ b/patch/kernel/archive/sunxi-6.16/dt/sun50i-h618-kickpi-k2b.dts @@ -0,0 +1,405 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (C) 2025 Patrick Yavitz + */ + +/dts-v1/; + +#include "sun50i-h616.dtsi" +#include "sun50i-h616-cpu-opp.dtsi" + +#include +#include +#include +#include + +/ { + model = "KickPi K2B"; + compatible = "kickpi,k2b", "allwinner,sun50i-h618"; + + aliases { + ethernet0 = &emac0; + i2c1 = &i2c1; + i2c2 = &i2c2; + i2c3 = &i2c3; + i2c4 = &i2c4; + serial0 = &uart0; + serial1 = &uart1; + serial2 = &uart2; + serial5 = &uart5; + }; + + chosen { + stdout-path = "serial0:115200n8"; + kaslr-seed = <0xfeedbeef 0xc0def00d>; + }; + + connector { + compatible = "hdmi-connector"; + type = "d"; + + port { + hdmi_con_in: endpoint { + remote-endpoint = <&hdmi_out_con>; + }; + }; + }; + + gpio-keys-polled { + compatible = "gpio-keys-polled"; + poll-interval = <100>; + + button-power { + label = "power"; + linux,code = ; + gpios = <&pio 2 2 GPIO_ACTIVE_LOW>; /* PC2 */ + }; + }; + + leds { + compatible = "gpio-leds"; + + led-0 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&pio 8 16 GPIO_ACTIVE_HIGH>; /* PI16 */ + linux,default-trigger = "heartbeat"; + }; + }; + + reg_usb_vbus: regulator-usb-vbus { + /* Separate discrete regulator for the USB ports */ + compatible = "regulator-fixed"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-name = "usb-vbus"; + vin-supply = <®_vcc5v>; + }; + + reg_vcc5v: regulator-vcc5v { + /* Board wide 5V supply directly from the USB-C socket */ + compatible = "regulator-fixed"; + regulator-always-on; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-name = "vcc-5v"; + }; + + sdio_pwrseq: sdio-pwrseq { + compatible = "mmc-pwrseq-simple"; + clocks = <&rtc CLK_OSC32K_FANOUT>; + clock-names = "ext_clock"; + pinctrl-0 = <&x32clk_fanout_pin>; + pinctrl-names = "default"; + post-power-on-delay-ms = <100>; + power-off-delay-us = <5000000>; + reset-gpios = <&pio 6 18 GPIO_ACTIVE_LOW>, /* PG18 */ + <&pio 6 19 GPIO_ACTIVE_LOW>; /* PG19 */ + }; +}; + +&ahub_dam_plat { + status = "okay"; +}; + +&ahub1_plat { + status = "okay"; +}; + +&ahub1_mach { + status = "okay"; +}; + +&codec { + status = "okay"; + allwinner,audio-routing = "Line Out", "LINEOUT"; +}; + +&cpu0 { + cpu-supply = <®_dcdc2>; +}; + +&de { + status = "okay"; +}; + +&emac0 { + status = "okay"; + pinctrl-0 = <&ext_rgmii_pins>; + pinctrl-names = "default"; + phy-mode = "rgmii"; + phy-handle = <&ext_rgmii_phy>; + allwinner,tx-delay-ps = <700>; + allwinner,rx-delay-ps = <1700>; +}; + +&ehci0 { + status = "okay"; +}; + +&ehci1 { + status = "okay"; +}; + +&ehci2 { + status = "okay"; +}; + +&ehci3 { + status = "disabled"; +}; + +&gpu { + status = "okay"; + mali-supply = <®_dcdc1>; +}; + +&hdmi { + status = "okay"; +}; + +&hdmi_out { + hdmi_out_con: endpoint { + remote-endpoint = <&hdmi_con_in>; + }; +}; + +&i2c1 { + status = "disabled"; + pinctrl-0 = <&i2c1_ph_pins>; + pinctrl-names = "default"; +}; + +&i2c2 { + status = "disabled"; + pinctrl-0 = <&i2c2_ph_pins>; + pinctrl-names = "default"; +}; + +&i2c3 { + status = "disabled"; + pinctrl-0 = <&i2c3_ph_pins>; + pinctrl-names = "default"; +}; + +&i2c4 { + status = "disabled"; + pinctrl-0 = <&i2c4_ph_pins>; + pinctrl-names = "default"; +}; + +&ir { + status = "okay"; + pinctrl-0 = <&ir_rx_pin>; + pinctrl-names = "default"; +}; + +&mdio0 { + ext_rgmii_phy: ethernet-phy@1 { + compatible = "ethernet-phy-id001c.c916"; + reg = <1>; + reset-assert-us = <20000>; + reset-deassert-us = <100000>; + reset-gpios = <&pio 8 6 GPIO_ACTIVE_LOW>; /* PI6 */ + }; +}; + +/* SD card */ +&mmc0 { + status = "okay"; + bus-width = <4>; + cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */ + cd-inverted; + disable-wp; + max-frequency = <50000000>; + vmmc-supply = <®_dldo1>; +}; + +/* SDIO */ +&mmc1 { + status = "okay"; + bus-width = <4>; + keep-power-in-suspend; + max-frequency = <100000000>; + mmc-pwrseq = <&sdio_pwrseq>; + no-mmc; + no-sd; + non-removable; + vmmc-supply = <®_dldo1>; + vqmmc-supply = <®_aldo1>; + + sdio: wifi@1 { + reg = <1>; + }; +}; + +/* eMMC */ +&mmc2 { + status = "okay"; + bus-width = <8>; + cap-mmc-hw-reset; + mmc-hs200-1_8v; + non-removable; + vmmc-supply = <®_dldo1>; + vqmmc-supply = <®_aldo1>; +}; + +&ohci0 { + status = "okay"; +}; + +&ohci1 { + status = "okay"; +}; + +&ohci2 { + status = "okay"; +}; + +&ohci3 { + status = "disabled"; +}; + +&pio { + vcc-pc-supply = <®_dldo1>; + vcc-pf-supply = <®_dldo1>; + vcc-pg-supply = <®_aldo1>; + vcc-ph-supply = <®_dldo1>; + vcc-pi-supply = <®_dldo1>; + vcc-pl-supply = <®_aldo1>; + + /* PI16 required for sys_led */ + ext_rgmii_pins: rgmii-pins { + pins = "PI0", "PI1", "PI2", "PI3", "PI4", + "PI5", "PI7", "PI8", "PI9", "PI10", + "PI11", "PI12", "PI13", "PI14", "PI15"; + function = "emac0"; + drive-strength = <40>; + }; + + /* Add I2C PH Pins */ + i2c1_ph_pins: i2c1-ph-pins { + pins = "PH0", "PH1"; + function = "i2c1"; + }; + + i2c2_ph_pins: i2c2-ph-pins { + pins = "PH2", "PH3"; + function = "i2c2"; + }; + + i2c4_ph_pins: i2c4-ph-pins { + pins = "PH6", "PH7"; + function = "i2c4"; + }; + + /* PC0 required for spi0 */ + mmc2_pins: mmc2-pins { + pins = "PC1", "PC5", "PC6", + "PC8", "PC9", "PC10", "PC11", + "PC13", "PC14", "PC15", "PC16"; + function = "mmc2"; + drive-strength = <30>; + bias-pull-up; + }; +}; + +&r_i2c { + status = "okay"; + axp313: pmic@36 { + compatible = "x-powers,axp313a"; + reg = <0x36>; + #interrupt-cells = <1>; + interrupt-controller; + interrupt-parent = <&pio>; + + vin1-supply = <®_vcc5v>; + vin2-supply = <®_vcc5v>; + vin3-supply = <®_vcc5v>; + + regulators { + reg_aldo1: aldo1 { + regulator-always-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcc-1v8-pll"; + }; + + reg_dldo1: dldo1 { + regulator-always-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc-3v3-io"; + }; + + reg_dcdc1: dcdc1 { + regulator-always-on; + regulator-min-microvolt = <810000>; + regulator-max-microvolt = <990000>; + regulator-name = "vdd-gpu-sys"; + }; + + reg_dcdc2: dcdc2 { + regulator-always-on; + regulator-min-microvolt = <810000>; + regulator-max-microvolt = <1100000>; + regulator-name = "vdd-cpu"; + }; + + reg_dcdc3: dcdc3 { + regulator-always-on; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1500000>; + regulator-name = "vdd-dram"; + }; + }; + }; +}; + +&spi1 { + status = "disabled"; + pinctrl-0 = <&spi1_pins>, <&spi1_cs1_pin>; + pinctrl-names = "default"; + + spidev@1 { + compatible = "rohm,dh2228fv"; + reg = <1>; + spi-max-frequency = <1000000>; + }; +}; + +&uart0 { + status = "okay"; + pinctrl-0 = <&uart0_ph_pins>; + pinctrl-names = "default"; +}; + +/* Bluetooth */ +&uart1 { + status = "okay"; + pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>; + pinctrl-names = "default"; + uart-has-rtscts; +}; + +&uart2 { + status = "disabled"; + pinctrl-names = "default"; + pinctrl-0 = <&uart2_ph_pins>; +}; + +&uart5 { + status = "disabled"; + pinctrl-names = "default"; + pinctrl-0 = <&uart5_pins>; +}; + +&usbotg { + status = "okay"; + dr_mode = "peripheral"; +}; + +&usbphy { + status = "okay"; + usb1_vbus-supply = <®_usb_vbus>; +};