From edcc2833819f6750bf003b95a6ac856aced26274 Mon Sep 17 00:00:00 2001 From: aiamadeus <2789289348@qq.com> Date: Sat, 25 Mar 2023 23:05:16 +0800 Subject: [PATCH] r8169: add LED configuration from OF --- .../boot/dts/rockchip/rk3568-fastrhino.dtsi | 8 +-- ...-r8169-add-LED-configuration-from-OF.patch | 49 +++++++++++++++++++ ...-r8169-add-LED-configuration-from-OF.patch | 49 +++++++++++++++++++ 3 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 target/linux/rockchip/patches-5.15/101-net-realtek-r8169-add-LED-configuration-from-OF.patch create mode 100644 target/linux/rockchip/patches-6.1/101-net-realtek-r8169-add-LED-configuration-from-OF.patch diff --git a/target/linux/rockchip/files/arch/arm64/boot/dts/rockchip/rk3568-fastrhino.dtsi b/target/linux/rockchip/files/arch/arm64/boot/dts/rockchip/rk3568-fastrhino.dtsi index be08b25d9..3b3821da8 100644 --- a/target/linux/rockchip/files/arch/arm64/boot/dts/rockchip/rk3568-fastrhino.dtsi +++ b/target/linux/rockchip/files/arch/arm64/boot/dts/rockchip/rk3568-fastrhino.dtsi @@ -400,7 +400,7 @@ vpcie3v3-supply = <&vcc3v3_pcie>; status = "okay"; - pcie@10 { + pcie@0,0 { reg = <0x00100000 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; @@ -409,7 +409,7 @@ compatible = "pci10ec,8125"; reg = <0x000000 0 0 0 0>; - realtek,led-data = <0x4078>; + realtek,led-data = <0x238>; }; }; }; @@ -420,7 +420,7 @@ vpcie3v3-supply = <&vcc3v3_pcie>; status = "okay"; - pcie@20 { + pcie@0,0 { reg = <0x00200000 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; @@ -429,7 +429,7 @@ compatible = "pci10ec,8125"; reg = <0x000000 0 0 0 0>; - realtek,led-data = <0x4078>; + realtek,led-data = <0x238>; }; }; }; diff --git a/target/linux/rockchip/patches-5.15/101-net-realtek-r8169-add-LED-configuration-from-OF.patch b/target/linux/rockchip/patches-5.15/101-net-realtek-r8169-add-LED-configuration-from-OF.patch new file mode 100644 index 000000000..449e41568 --- /dev/null +++ b/target/linux/rockchip/patches-5.15/101-net-realtek-r8169-add-LED-configuration-from-OF.patch @@ -0,0 +1,49 @@ +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -183,6 +184,7 @@ enum rtl_registers { + MAR0 = 8, /* Multicast filter. */ + CounterAddrLow = 0x10, + CounterAddrHigh = 0x14, ++ CustomLED = 0x18, + TxDescStartAddrLow = 0x20, + TxDescStartAddrHigh = 0x24, + TxHDescStartAddrLow = 0x28, +@@ -5274,6 +5276,22 @@ done: + rtl_rar_set(tp, mac_addr); + } + ++static int rtl_led_configuration(struct rtl8169_private *tp) ++{ ++ u32 led_data; ++ int ret; ++ ++ ret = of_property_read_u32(tp->pci_dev->dev.of_node, ++ "realtek,led-data", &led_data); ++ ++ if (ret) ++ return ret; ++ ++ RTL_W16(tp, CustomLED, led_data); ++ ++ return 0; ++} ++ + static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) + { + struct rtl8169_private *tp; +@@ -5438,6 +5456,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct + if (!tp->counters) + return -ENOMEM; + ++ rtl_led_configuration(tp); + pci_set_drvdata(pdev, tp); + + rc = r8169_mdio_register(tp); diff --git a/target/linux/rockchip/patches-6.1/101-net-realtek-r8169-add-LED-configuration-from-OF.patch b/target/linux/rockchip/patches-6.1/101-net-realtek-r8169-add-LED-configuration-from-OF.patch new file mode 100644 index 000000000..f97af5280 --- /dev/null +++ b/target/linux/rockchip/patches-6.1/101-net-realtek-r8169-add-LED-configuration-from-OF.patch @@ -0,0 +1,49 @@ +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -183,6 +184,7 @@ enum rtl_registers { + MAR0 = 8, /* Multicast filter. */ + CounterAddrLow = 0x10, + CounterAddrHigh = 0x14, ++ CustomLED = 0x18, + TxDescStartAddrLow = 0x20, + TxDescStartAddrHigh = 0x24, + TxHDescStartAddrLow = 0x28, +@@ -5274,6 +5276,22 @@ done: + return false; + } + ++static int rtl_led_configuration(struct rtl8169_private *tp) ++{ ++ u32 led_data; ++ int ret; ++ ++ ret = of_property_read_u32(tp->pci_dev->dev.of_node, ++ "realtek,led-data", &led_data); ++ ++ if (ret) ++ return ret; ++ ++ RTL_W16(tp, CustomLED, led_data); ++ ++ return 0; ++} ++ + static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) + { + struct rtl8169_private *tp; +@@ -5438,6 +5456,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct + if (!tp->counters) + return -ENOMEM; + ++ rtl_led_configuration(tp); + pci_set_drvdata(pdev, tp); + + rc = r8169_mdio_register(tp);