From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 26 Jun 2026 00:00:00 +0800 Subject: [PATCH] uis7885: enable RTL8111HCG PCIe ethernet Enable the in-kernel r8169/Realtek PHY drivers, keep the RTL8111 3.3V enable GPIO high, extend the cold-boot PCIe REFCLK/PERST# delay to satisfy the RTL8111H power sequencing requirement, and bring eth0 up with DHCP during system network initialization. Add SELinux policy for ethernet debug tools so udhcpc, ping, and iperf3 can run in enforcing mode from local login shells. diff --git a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/sprd_uis7885_defconfig b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/sprd_uis7885_defconfig --- a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/sprd_uis7885_defconfig +++ b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/sprd_uis7885_defconfig @@ -1942,7 +1942,9 @@ CONFIG_VETH=y # # end of Distributed Switch Architecture drivers -# CONFIG_ETHERNET is not set +CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_REALTEK=y +CONFIG_R8169=y # CONFIG_FDDI is not set # CONFIG_HIPPI is not set CONFIG_MDIO_DEVICE=y @@ -1991,7 +1993,7 @@ CONFIG_FIXED_PHY=y # CONFIG_MICROSEMI_PHY is not set # CONFIG_NATIONAL_PHY is not set # CONFIG_QSEMI_PHY is not set -# CONFIG_REALTEK_PHY is not set +CONFIG_REALTEK_PHY=y # CONFIG_RENESAS_PHY is not set # CONFIG_ROCKCHIP_PHY is not set # CONFIG_SMSC_PHY is not set diff --git a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/recovery_uis7885_defconfig b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/recovery_uis7885_defconfig --- a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/recovery_uis7885_defconfig +++ b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/recovery_uis7885_defconfig @@ -1942,7 +1942,9 @@ CONFIG_VETH=y # # end of Distributed Switch Architecture drivers -# CONFIG_ETHERNET is not set +CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_REALTEK=y +CONFIG_R8169=y # CONFIG_FDDI is not set # CONFIG_HIPPI is not set CONFIG_MDIO_DEVICE=y @@ -1991,7 +1993,7 @@ CONFIG_FIXED_PHY=y # CONFIG_MICROSEMI_PHY is not set # CONFIG_NATIONAL_PHY is not set # CONFIG_QSEMI_PHY is not set -# CONFIG_REALTEK_PHY is not set +CONFIG_REALTEK_PHY=y # CONFIG_RENESAS_PHY is not set # CONFIG_ROCKCHIP_PHY is not set # CONFIG_SMSC_PHY is not set diff --git a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/product/wifionly/sprd_uis7885_defconfig b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/product/wifionly/sprd_uis7885_defconfig --- a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/product/wifionly/sprd_uis7885_defconfig +++ b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/product/wifionly/sprd_uis7885_defconfig @@ -1942,7 +1942,9 @@ CONFIG_VETH=y # # end of Distributed Switch Architecture drivers -# CONFIG_ETHERNET is not set +CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_REALTEK=y +CONFIG_R8169=y # CONFIG_FDDI is not set # CONFIG_HIPPI is not set CONFIG_MDIO_DEVICE=y @@ -1991,7 +1993,7 @@ CONFIG_FIXED_PHY=y # CONFIG_MICROSEMI_PHY is not set # CONFIG_NATIONAL_PHY is not set # CONFIG_QSEMI_PHY is not set -# CONFIG_REALTEK_PHY is not set +CONFIG_REALTEK_PHY=y # CONFIG_RENESAS_PHY is not set # CONFIG_ROCKCHIP_PHY is not set # CONFIG_SMSC_PHY is not set diff --git a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/uis7885-2h10-overlay.dts b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/uis7885-2h10-overlay.dts --- a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/uis7885-2h10-overlay.dts +++ b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/uis7885-2h10-overlay.dts @@ -476,6 +476,15 @@ &usb { status = "okay"; }; +&ap_gpio { + rtl8111_3v3_en { + gpio-hog; + gpios = <147 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "rtl8111-3v3-en"; + }; +}; + &ssphy { vdd-supply = <&vddusb33>; extcon = <&extcon_gpio>; diff --git a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/recovery-uis7885-2h10.dts b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/recovery-uis7885-2h10.dts --- a/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/recovery-uis7885-2h10.dts +++ b/source_sync_rls_25c/layers/meta-unisoc/recipes-kernel/linux/linux-unisoc-5.4/uis7885/recovery-uis7885-2h10.dts @@ -486,6 +486,15 @@ &usb { status = "okay"; }; +&ap_gpio { + rtl8111_3v3_en { + gpio-hog; + gpios = <147 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "rtl8111-3v3-en"; + }; +}; + &ion { #address-cells = <1>; #size-cells = <0>; diff --git a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/sprd_uis7885_defconfig b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/sprd_uis7885_defconfig --- a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/sprd_uis7885_defconfig +++ b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/sprd_uis7885_defconfig @@ -1942,7 +1942,9 @@ CONFIG_VETH=y # # end of Distributed Switch Architecture drivers -# CONFIG_ETHERNET is not set +CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_REALTEK=y +CONFIG_R8169=y # CONFIG_FDDI is not set # CONFIG_HIPPI is not set CONFIG_MDIO_DEVICE=y @@ -1991,7 +1993,7 @@ CONFIG_FIXED_PHY=y # CONFIG_MICROSEMI_PHY is not set # CONFIG_NATIONAL_PHY is not set # CONFIG_QSEMI_PHY is not set -# CONFIG_REALTEK_PHY is not set +CONFIG_REALTEK_PHY=y # CONFIG_RENESAS_PHY is not set # CONFIG_ROCKCHIP_PHY is not set # CONFIG_SMSC_PHY is not set diff --git a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/recovery_uis7885_defconfig b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/recovery_uis7885_defconfig --- a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/recovery_uis7885_defconfig +++ b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/recovery_uis7885_defconfig @@ -1942,7 +1942,9 @@ CONFIG_VETH=y # # end of Distributed Switch Architecture drivers -# CONFIG_ETHERNET is not set +CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_REALTEK=y +CONFIG_R8169=y # CONFIG_FDDI is not set # CONFIG_HIPPI is not set CONFIG_MDIO_DEVICE=y @@ -1991,7 +1993,7 @@ CONFIG_FIXED_PHY=y # CONFIG_MICROSEMI_PHY is not set # CONFIG_NATIONAL_PHY is not set # CONFIG_QSEMI_PHY is not set -# CONFIG_REALTEK_PHY is not set +CONFIG_REALTEK_PHY=y # CONFIG_RENESAS_PHY is not set # CONFIG_ROCKCHIP_PHY is not set # CONFIG_SMSC_PHY is not set diff --git a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/sprd_debian_defconfig b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/sprd_debian_defconfig --- a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/sprd_debian_defconfig +++ b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/configs/sprd_debian_defconfig @@ -1901,7 +1901,9 @@ CONFIG_VETH=y # # end of Distributed Switch Architecture drivers -# CONFIG_ETHERNET is not set +CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_REALTEK=y +CONFIG_R8169=y # CONFIG_FDDI is not set # CONFIG_HIPPI is not set CONFIG_MDIO_DEVICE=y @@ -1950,7 +1952,7 @@ CONFIG_FIXED_PHY=y # CONFIG_MICROSEMI_PHY is not set # CONFIG_NATIONAL_PHY is not set # CONFIG_QSEMI_PHY is not set -# CONFIG_REALTEK_PHY is not set +CONFIG_REALTEK_PHY=y # CONFIG_RENESAS_PHY is not set # CONFIG_ROCKCHIP_PHY is not set # CONFIG_SMSC_PHY is not set diff --git a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/uis7885-2h10-overlay.dts b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/uis7885-2h10-overlay.dts --- a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/uis7885-2h10-overlay.dts +++ b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/uis7885-2h10-overlay.dts @@ -476,6 +476,15 @@ &usb { status = "okay"; }; +&ap_gpio { + rtl8111_3v3_en { + gpio-hog; + gpios = <147 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "rtl8111-3v3-en"; + }; +}; + &ssphy { vdd-supply = <&vddusb33>; extcon = <&extcon_gpio>; diff --git a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/recovery-uis7885-2h10.dts b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/recovery-uis7885-2h10.dts --- a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/recovery-uis7885-2h10.dts +++ b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/recovery-uis7885-2h10.dts @@ -486,6 +486,15 @@ &usb { status = "okay"; }; +&ap_gpio { + rtl8111_3v3_en { + gpio-hog; + gpios = <147 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "rtl8111-3v3-en"; + }; +}; + &ion { #address-cells = <1>; #size-cells = <0>; diff --git a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/uis7885-mach.dtsi b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/uis7885-mach.dtsi --- a/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/uis7885-mach.dtsi +++ b/source_sync_rls_25c/source/kernel/kernel5.4/arch/arm64/boot/dts/sprd/uis7885-mach.dtsi @@ -1138,10 +1138,10 @@ &pcie1 { MASK_PMU_APB_PD_PCIE_STATE 0x0>, /* - * Remain 100M reference clock to active at least 200us to make - * sure that it's stable before pulling high perst#. + * Keep REFCLK and power stable before releasing PERST#. + * RTL8111H requires at least 100ms from 3.3V stable to PERST# inactive. */ - <&pmu_apb_regs 0 200 + <&pmu_apb_regs 0 100000 REG_PMU_APB_PCIEPLLV_REL_CFG MASK_PMU_APB_PCIEPLLV_FRC_ON 0x1>, @@ -1149,7 +1149,7 @@ &pcie1 { REG_AON_APB_IPA_ACCESS_CFG MASK_AON_APB_AON_ACCESS_PCIE_EN 0x2>, - /* perst assert */ + /* release PERST# */ <&pmu_apb_regs 0 2000 REG_PMU_APB_SNPS_PCIE3_SLP_CTRL MASK_PMU_APB_REG_PERST_N_ASSERT diff --git a/source_sync_rls_25c/layers/meta-unisoc/recipes-core/init-ifupdown/init-ifupdown/init_networking b/source_sync_rls_25c/layers/meta-unisoc/recipes-core/init-ifupdown/init-ifupdown/init_networking --- a/source_sync_rls_25c/layers/meta-unisoc/recipes-core/init-ifupdown/init-ifupdown/init_networking +++ b/source_sync_rls_25c/layers/meta-unisoc/recipes-core/init-ifupdown/init-ifupdown/init_networking @@ -55,11 +55,29 @@ check_network_swap() { exec 0<&9 9<&- } +start_eth0_dhcp() { + local retry=0 + + while [ ! -d /sys/class/net/eth0 ] && [ $retry -lt 10 ]; do + sleep 1 + retry=$((retry + 1)) + done + + [ -d /sys/class/net/eth0 ] || return 0 + + ip link set eth0 up 2>/dev/null || ifconfig eth0 up 2>/dev/null || true + + if command -v udhcpc >/dev/null 2>&1 && + ! ps | grep "[u]dhcpc .*eth0" >/dev/null 2>&1; then + udhcpc -i eth0 -b -R >/dev/null 2>&1 & + fi +} + case "$1" in start) echo -n "Configuring network interfaces... " sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1 - #ifup -a + start_eth0_dhcp echo "done." ;; diff --git a/source_sync_rls_25c/layers/meta-unisoc/recipes-connectivity/netcon/files/npd6.conf.backups b/source_sync_rls_25c/layers/meta-unisoc/recipes-connectivity/netcon/files/npd6.conf.backups new file mode 100644 --- /dev/null +++ b/source_sync_rls_25c/layers/meta-unisoc/recipes-connectivity/netcon/files/npd6.conf.backups @@ -0,0 +1,2 @@ +prefix = +interface = diff --git a/source_sync_rls_25c/layers/meta-unisoc/recipes-connectivity/netcon/netcon_0.0.1.bb b/source_sync_rls_25c/layers/meta-unisoc/recipes-connectivity/netcon/netcon_0.0.1.bb --- a/source_sync_rls_25c/layers/meta-unisoc/recipes-connectivity/netcon/netcon_0.0.1.bb +++ b/source_sync_rls_25c/layers/meta-unisoc/recipes-connectivity/netcon/netcon_0.0.1.bb @@ -26,6 +26,7 @@ SRC_URI = " \ file://netcon_dbus.conf \ file://hostapd.conf \ file://netcon.conf \ + file://npd6.conf.backups \ " require netcon.inc @@ -58,6 +59,9 @@ do_install () { install -d ${D}/etc/netcon/ install -m 0644 ${THISDIR}/files/netcon.conf ${D}/etc/netcon/ + + install -d ${D}/etc/netcon/npd6/ + install -m 0644 ${WORKDIR}/npd6.conf.backups ${D}/etc/netcon/npd6/ } TARGET_CC_ARCH += "${LDFLAGS}" diff --git a/source_sync_rls_25c/layers/meta-unisoc/recipes-core/busybox-initramfs/files/simple.script b/source_sync_rls_25c/layers/meta-unisoc/recipes-core/busybox-initramfs/files/simple.script --- a/source_sync_rls_25c/layers/meta-unisoc/recipes-core/busybox-initramfs/files/simple.script +++ b/source_sync_rls_25c/layers/meta-unisoc/recipes-core/busybox-initramfs/files/simple.script @@ -38,7 +38,7 @@ case "$1" in renew|bound) if [ $have_bin_ip -eq 1 ]; then - /SBIN_DIR/ip addr add dev $interface local $ip/$mask $BROADCAST + /SBIN_DIR/ip addr replace dev $interface local $ip/$mask $BROADCAST else /SBIN_DIR/ifconfig $interface $ip $BROADCAST $NETMASK fi @@ -59,7 +59,7 @@ case "$1" in metric=10 for i in $router ; do if [ $have_bin_ip -eq 1 ]; then - /SBIN_DIR/ip route add default via $i metric $metric dev $interface + /SBIN_DIR/ip route replace default via $i metric $metric dev $interface else /SBIN_DIR/route add default gw $i dev $interface metric $metric 2>/dev/null fi diff --git a/source_sync_rls_25c/source/unisoc/selinux/kirkstone/files/0097-Bug-rtl8111-ethernet-tools-selinux.patch b/source_sync_rls_25c/source/unisoc/selinux/kirkstone/files/0097-Bug-rtl8111-ethernet-tools-selinux.patch new file mode 100644 --- /dev/null +++ b/source_sync_rls_25c/source/unisoc/selinux/kirkstone/files/0097-Bug-rtl8111-ethernet-tools-selinux.patch @@ -0,0 +1,28 @@ +diff --git a/policy/modules/system/locallogin.te b/policy/modules/system/locallogin.te +index ef2716aac..3a7d4d2ab 100644 +--- a/policy/modules/system/locallogin.te ++++ b/policy/modules/system/locallogin.te +@@ -484,3 +484,23 @@ allow local_login_t tracefs_t:file { rw_file_perms getattr execute unlink map cr + allow local_login_t tracefs_t:filesystem { mount remount unmount getattr relabelfrom relabelto }; + allow local_login_t user_home_dir_t:dir { search_dir_perms create_dir_perms rw_dir_perms rmdir }; + allow local_login_t user_home_dir_t:file { rw_file_perms getattr execute unlink map create rename setattr execute_no_trans }; ++ ++gen_require(` ++ type node_t; ++ type ping_exec_t; ++ type unreserved_port_t; ++') ++ ++# Allow ethernet debug tools to run from local login shells in enforcing mode. ++allow local_login_t ping_exec_t:file { getattr open read execute execute_no_trans map }; ++ ++allow local_login_t self:tcp_socket { create ioctl read write getattr getopt setopt bind connect listen accept shutdown }; ++allow local_login_t unreserved_port_t:tcp_socket { name_connect name_bind }; ++allow local_login_t node_t:tcp_socket node_bind; ++ ++allow local_login_t self:udp_socket { create ioctl read write getattr getopt setopt bind connect }; ++allow local_login_t node_t:udp_socket node_bind; ++ ++allow local_login_t self:packet_socket { create ioctl read write getattr getopt setopt bind }; ++allow local_login_t self:rawip_socket { create ioctl read write getattr getopt setopt }; ++allow local_login_t self:netlink_route_socket { create ioctl read write getattr bind connect getopt setopt nlmsg_read nlmsg_write }; -- 2.34.1