From aba9592e4145e57ca25bfae7877f2979f38bc823 Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Sat, 17 Oct 2020 16:16:17 +0000 Subject: [PATCH] sunxi: rework nanopi r1s (h5) compilation for kernel 4.14 Known issues: - Wireless not working Signed-off-by: CN_SZTL --- package/boot/uboot-sunxi/Makefile | 4 +- .../uboot-sunxi/patches/401-add-r1s-h5.patch | 3 +- target/linux/sunxi/image/cortex-a53.mk | 3 +- ...et-usb-r8152-init-LED-for-RTL_VER_09.patch | 33 +++++++ ...0-ARM-dts-friendlyelec-nanopi-r1s-h5.patch | 98 ++++++++++++------- 5 files changed, 99 insertions(+), 42 deletions(-) create mode 100644 target/linux/sunxi/patches-4.14/010-net-usb-r8152-init-LED-for-RTL_VER_09.patch diff --git a/package/boot/uboot-sunxi/Makefile b/package/boot/uboot-sunxi/Makefile index e6478dc73c..631a15ce50 100644 --- a/package/boot/uboot-sunxi/Makefile +++ b/package/boot/uboot-sunxi/Makefile @@ -159,13 +159,13 @@ endef define U-Boot/nanopi_r1 BUILD_SUBTARGET:=cortexa7 NAME:=U-Boot for NanoPi R1 (H3) - BUILD_DEVICES:=friendyarm-h3-nanopi-r1 + BUILD_DEVICES:=friendlyarm_nanopi-r1 endef define U-Boot/nanopi_r1s BUILD_SUBTARGET:=cortexa53 NAME:=NanoPi R1S (H5) - BUILD_DEVICES:=friendlyarm-h5-nanopi-r1s + BUILD_DEVICES:=friendlyarm_nanopi-r1s DEPENDS:=+PACKAGE_u-boot-nanopi_r1s:arm-trusted-firmware-sunxi UENV:=a64 endef diff --git a/package/boot/uboot-sunxi/patches/401-add-r1s-h5.patch b/package/boot/uboot-sunxi/patches/401-add-r1s-h5.patch index c618cb72aa..4b1812f1e9 100644 --- a/package/boot/uboot-sunxi/patches/401-add-r1s-h5.patch +++ b/package/boot/uboot-sunxi/patches/401-add-r1s-h5.patch @@ -28,7 +28,7 @@ new file mode 100644 index 0000000..4992ef5 --- /dev/null +++ b/arch/arm/dts/sun50i-h5-nanopi-r1s.dts -@@ -0,0 +1,86 @@ +@@ -0,0 +1,85 @@ +/* + * Copyright (C) 2017 Icenowy Zheng + * Copyright (C) 2017 Jagan Teki @@ -103,7 +103,6 @@ index 0000000..4992ef5 + "allwinner,sun50i-a64-mmc", + "allwinner,sun5i-a13-mmc"; + pinctrl-names = "default"; -+ pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>; + vmmc-supply = <®_vcc3v3>; + bus-width = <4>; + cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */ diff --git a/target/linux/sunxi/image/cortex-a53.mk b/target/linux/sunxi/image/cortex-a53.mk index ee4e9195cf..eca4761220 100644 --- a/target/linux/sunxi/image/cortex-a53.mk +++ b/target/linux/sunxi/image/cortex-a53.mk @@ -31,8 +31,7 @@ TARGET_DEVICES += friendlyarm_nanopi-neo2 define Device/friendlyarm_nanopi-r1s DEVICE_VENDOR := FriendlyARM DEVICE_MODEL:=Nanopi R1S (H5) - DEVICE_PACKAGES:=kmod-rtc-sunxi \ - kmod-leds-gpio kmod-ledtrig-heartbeat \ + DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-leds-gpio kmod-ledtrig-heartbeat \ kmod-brcmfmac brcmfmac-firmware-43430-sdio wpad-basic \ kmod-usb-net kmod-usb-net-rtl8152 SUPPORTED_DEVICES:=nanopi-r1s diff --git a/target/linux/sunxi/patches-4.14/010-net-usb-r8152-init-LED-for-RTL_VER_09.patch b/target/linux/sunxi/patches-4.14/010-net-usb-r8152-init-LED-for-RTL_VER_09.patch new file mode 100644 index 0000000000..2a2476f8a5 --- /dev/null +++ b/target/linux/sunxi/patches-4.14/010-net-usb-r8152-init-LED-for-RTL_VER_09.patch @@ -0,0 +1,33 @@ +From a8ec9a8d2247076290e6c8b8f353c948c2a84a62 Mon Sep 17 00:00:00 2001 +From: wuweidong <625769020@qq.com> +Date: Wed, 18 Sep 2019 14:32:26 +0800 +Subject: [PATCH] r8152: init LED for RTL_VER_09 + +--- + drivers/net/usb/r8152.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c +index 8ccb22b098a6b..a22e113fe17dd 100644 +--- a/drivers/net/usb/r8152.c ++++ b/drivers/net/usb/r8152.c +@@ -4217,6 +4217,10 @@ static void r8153b_init(struct r8152 *tp) + rtl_tally_reset(tp); + + tp->coalesce = 15000; /* 15 us */ ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LEDSEL); ++ ocp_data = 0x78; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, ocp_data); + } + + static int rtl8152_pre_reset(struct usb_interface *intf) +@@ -5141,7 +5145,7 @@ static u8 rtl_get_version(struct usb_interface *intf) + break; + } + +- dev_dbg(&intf->dev, "Detected version 0x%04x\n", version); ++ dev_info(&intf->dev, "Detected version 0x%04x\n", version); + + return version; + } diff --git a/target/linux/sunxi/patches-4.14/230-ARM-dts-friendlyelec-nanopi-r1s-h5.patch b/target/linux/sunxi/patches-4.14/230-ARM-dts-friendlyelec-nanopi-r1s-h5.patch index 2997286f7d..61100c787b 100644 --- a/target/linux/sunxi/patches-4.14/230-ARM-dts-friendlyelec-nanopi-r1s-h5.patch +++ b/target/linux/sunxi/patches-4.14/230-ARM-dts-friendlyelec-nanopi-r1s-h5.patch @@ -10,7 +10,7 @@ subdir-y := $(dts-dirs) --- /dev/null +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-r1s.dts -@@ -0,0 +1,232 @@ +@@ -0,0 +1,258 @@ +/* + * Copyright (C) 2017 Icenowy Zheng + * @@ -61,36 +61,19 @@ +#include +#include +/ { -+ model = "FriendlyElec NanoPi-R1S-H5"; ++ model = "FriendlyElec NanoPi R1S (H5)"; + compatible = "friendlyelec,nanopi-r1s-h5", "allwinner,sun50i-h5"; + + aliases { + ethernet0 = &emac; ++ ethernet1 = &emac; ++ ethernet2 = &sdio_wifi; + serial0 = &uart0; + }; + -+ + chosen { + stdout-path = "serial0:115200n8"; + }; -+ -+ wifi_pwrseq: wifi_pwrseq { -+ compatible = "mmc-pwrseq-simple"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&wifi_en_npi>; -+ reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>; /* PL7 */ -+ post-power-on-delay-ms = <200>; -+ }; -+ -+ r-gpio-keys { -+ compatible = "gpio-keys"; -+ -+ k1@0 { -+ label = "k1"; -+ linux,code = ; -+ gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>; -+ }; -+ }; + + leds { + compatible = "gpio-leds"; @@ -142,11 +125,26 @@ + gpio = <&r_pio 0 2 GPIO_ACTIVE_HIGH>; /* PL2 */ + status = "okay"; + }; ++ ++ r-gpio-keys { ++ compatible = "gpio-keys"; ++ ++ k1@0 { ++ label = "k1"; ++ linux,code = ; ++ gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ wifi_pwrseq: wifi_pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&wifi_en_npi>; ++ reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>; /* PL7 */ ++ post-power-on-delay-ms = <200>; ++ }; +}; + -+ -+ -+ +&ehci0 { + status = "okay"; +}; @@ -185,13 +183,14 @@ + phy-supply = <®_gmac_3v3>; + phy-handle = <&ext_rgmii_phy>; + phy-mode = "rgmii"; ++ + status = "okay"; +}; + -+&external_mdio { -+ ext_rgmii_phy: ethernet-phy@7 { ++&mdio { ++ ext_rgmii_phy: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; -+ reg = <7>; ++ reg = <0>; + }; +}; + @@ -213,12 +212,32 @@ + bus-width = <4>; + non-removable; + status = "okay"; ++ ++ sdio_wifi: sdio_wifi@1 { ++ reg = <1>; ++ compatible = "brcm,bcm4329-fmac"; ++ interrupt-parent = <&pio>; ++ interrupts = <6 10 IRQ_TYPE_LEVEL_LOW>; /* PG10 / EINT10 */ ++ interrupt-names = "host-wake"; ++ }; +}; -+&r_pio { -+ wifi_en_npi: wifi_en_pin { -+ pins = "PL7"; -+ function = "gpio_out"; -+ }; ++ ++&mmc2 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc2_8bit_pins>; ++ vmmc-supply = <®_vcc3v3>; ++ vqmmc-supply = <®_vcc3v3>; ++ bus-width = <8>; ++ non-removable; ++ status = "okay"; ++}; ++ ++&ohci0 { ++ status = "okay"; ++}; ++ ++&ohci1 { ++ status = "okay"; +}; + +&uart0 { @@ -231,10 +250,6 @@ + dr_mode = "peripheral"; + status = "okay"; +}; -+®_usb0_vbus { -+ gpio = <&r_pio 0 2 GPIO_ACTIVE_HIGH>; /* PL2 */ -+ status = "okay"; -+}; + +&usbphy { + /* USB Type-A port's VBUS is always on */ @@ -243,3 +258,14 @@ + status = "okay"; +}; + ++&r_pio { ++ wifi_en_npi: wifi_en_pin { ++ pins = "PL7"; ++ function = "gpio_out"; ++ }; ++}; ++ ++®_usb0_vbus { ++ gpio = <&r_pio 0 2 GPIO_ACTIVE_HIGH>; /* PL2 */ ++ status = "okay"; ++};