From efc7aec5d5c235fe8f78539da9bc62ed5bde6de1 Mon Sep 17 00:00:00 2001 From: Sander Vanheule Date: Thu, 26 Dec 2024 22:26:33 +0100 Subject: [PATCH] realtek: rtl838x: Switch GS1900 rtl8231 driver Update the devicetree files to switch the GS1900 devices over to the new pinctrl and GPIO driver. This may fix issues caused by bad RMW behaviour on the GPIO data lines, or glitches due to setting the pin direction before the pin level. Although the driver support retaining GPIO state after a warm boot, the bootloader appears to apply a default configuration on boot, which may cause an interrupt in PoE-PSE support. Signed-off-by: Sander Vanheule --- .../realtek/dts/rtl8380_zyxel_gs1900-10hp.dts | 24 ++++++------- .../realtek/dts/rtl8380_zyxel_gs1900-8.dts | 2 +- .../realtek/dts/rtl8380_zyxel_gs1900.dtsi | 34 ++++++++++++++++--- .../realtek/dts/rtl8382_zyxel_gs1900-16.dts | 2 +- .../dts/rtl8382_zyxel_gs1900-24-v1.dts | 26 +++++++------- .../realtek/dts/rtl8382_zyxel_gs1900-24e.dts | 2 +- .../dts/rtl8382_zyxel_gs1900-24hp-v1.dts | 24 ++++++------- .../dts/rtl8382_zyxel_gs1900-24hp-v2.dts | 24 ++++++------- 8 files changed, 81 insertions(+), 57 deletions(-) diff --git a/target/linux/realtek/dts/rtl8380_zyxel_gs1900-10hp.dts b/target/linux/realtek/dts/rtl8380_zyxel_gs1900-10hp.dts index 190a77b7ff71..8edc815df759 100644 --- a/target/linux/realtek/dts/rtl8380_zyxel_gs1900-10hp.dts +++ b/target/linux/realtek/dts/rtl8380_zyxel_gs1900-10hp.dts @@ -9,8 +9,8 @@ /* i2c of the left SFP cage: port 9 */ i2c0: i2c-gpio-0 { compatible = "i2c-gpio"; - sda-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + sda-gpios = <&gpio_ext 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio_ext 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; #address-cells = <1>; #size-cells = <0>; @@ -19,17 +19,17 @@ sfp0: sfp-p9 { compatible = "sff,sfp"; i2c-bus = <&i2c0>; - los-gpio = <&gpio1 27 GPIO_ACTIVE_HIGH>; - tx-fault-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 26 GPIO_ACTIVE_LOW>; - tx-disable-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>; + los-gpio = <&gpio_ext 27 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpio_ext 22 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio_ext 26 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpio_ext 23 GPIO_ACTIVE_HIGH>; }; /* i2c of the right SFP cage: port 10 */ i2c1: i2c-gpio-1 { compatible = "i2c-gpio"; - sda-gpios = <&gpio1 30 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + sda-gpios = <&gpio_ext 30 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio_ext 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; #address-cells = <1>; #size-cells = <0>; @@ -38,10 +38,10 @@ sfp1: sfp-p10 { compatible = "sff,sfp"; i2c-bus = <&i2c1>; - los-gpio = <&gpio1 33 GPIO_ACTIVE_HIGH>; - tx-fault-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 32 GPIO_ACTIVE_LOW>; - tx-disable-gpio = <&gpio1 29 GPIO_ACTIVE_HIGH>; + los-gpio = <&gpio_ext 33 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpio_ext 28 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio_ext 32 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpio_ext 29 GPIO_ACTIVE_HIGH>; }; }; diff --git a/target/linux/realtek/dts/rtl8380_zyxel_gs1900-8.dts b/target/linux/realtek/dts/rtl8380_zyxel_gs1900-8.dts index 548e83ba7308..6ae97041b1ff 100644 --- a/target/linux/realtek/dts/rtl8380_zyxel_gs1900-8.dts +++ b/target/linux/realtek/dts/rtl8380_zyxel_gs1900-8.dts @@ -7,6 +7,6 @@ model = "Zyxel GS1900-8v1/v2 Switch"; }; -&gpio1 { +&gpio_ext { /delete-node/ poe_enable; }; diff --git a/target/linux/realtek/dts/rtl8380_zyxel_gs1900.dtsi b/target/linux/realtek/dts/rtl8380_zyxel_gs1900.dtsi index b985c4bc8e49..a0e69eaf423e 100644 --- a/target/linux/realtek/dts/rtl8380_zyxel_gs1900.dtsi +++ b/target/linux/realtek/dts/rtl8380_zyxel_gs1900.dtsi @@ -24,7 +24,7 @@ reset { label = "reset"; - gpios = <&gpio1 3 GPIO_ACTIVE_LOW>; + gpios = <&gpio_ext 3 GPIO_ACTIVE_LOW>; linux,code = ; }; }; @@ -40,17 +40,41 @@ }; }; - gpio1: rtl8231-gpio { - compatible = "realtek,rtl8231-gpio"; - #gpio-cells = <2>; + gpio-restart { + compatible = "gpio-restart"; + gpios = <&gpio_ext 5 GPIO_ACTIVE_LOW>; + priority = <192>; + open-source; + }; +}; + +&mdio_aux { + status = "okay"; + + // Reset GPIO is <&gpio0 1 GPIO_ACTIVE_LOW> + // Don't specify the reset info so the mdio subsystem doesn't reset the bus + //reset-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>; + //reset-delay-us = <1000>; + //reset-post-delay-us = <10000>; + + gpio_ext: expander@0 { + compatible = "realtek,rtl8231"; + reg = <0x0>; + gpio-controller; - indirect-access-bus-id = <0>; + #gpio-cells = <2>; + gpio-ranges = <&gpio_ext 0 0 37>; poe_enable { gpio-hog; gpios = <13 GPIO_ACTIVE_HIGH>; output-high; }; + + led-controller { + compatible = "realtek,rtl8231-leds"; + status = "disabled"; + }; }; }; diff --git a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-16.dts b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-16.dts index 6010da2e26c3..495e96f5794f 100644 --- a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-16.dts +++ b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-16.dts @@ -31,6 +31,6 @@ }; }; -&gpio1 { +&gpio_ext { /delete-node/ poe_enable; }; diff --git a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24-v1.dts b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24-v1.dts index 6d98e7fae1dc..5c044fb10209 100644 --- a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24-v1.dts +++ b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24-v1.dts @@ -13,8 +13,8 @@ /* i2c of the left SFP cage: port 25 */ i2c0: i2c-gpio-0 { compatible = "i2c-gpio"; - sda-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + sda-gpios = <&gpio_ext 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio_ext 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; #address-cells = <1>; #size-cells = <0>; @@ -23,17 +23,17 @@ sfp0: sfp-p25 { compatible = "sff,sfp"; i2c-bus = <&i2c0>; - los-gpio = <&gpio1 27 GPIO_ACTIVE_HIGH>; - tx-fault-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 26 GPIO_ACTIVE_LOW>; - tx-disable-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>; + los-gpio = <&gpio_ext 27 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpio_ext 22 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio_ext 26 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpio_ext 23 GPIO_ACTIVE_HIGH>; }; /* i2c of the right SFP cage: port 26 */ i2c1: i2c-gpio-1 { compatible = "i2c-gpio"; - sda-gpios = <&gpio1 30 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + sda-gpios = <&gpio_ext 30 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio_ext 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; #address-cells = <1>; #size-cells = <0>; @@ -42,10 +42,10 @@ sfp1: sfp-p26 { compatible = "sff,sfp"; i2c-bus = <&i2c1>; - los-gpio = <&gpio1 33 GPIO_ACTIVE_HIGH>; - tx-fault-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 32 GPIO_ACTIVE_LOW>; - tx-disable-gpio = <&gpio1 29 GPIO_ACTIVE_HIGH>; + los-gpio = <&gpio_ext 33 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpio_ext 28 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio_ext 32 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpio_ext 29 GPIO_ACTIVE_HIGH>; }; }; @@ -123,6 +123,6 @@ }; }; -&gpio1 { +&gpio_ext { /delete-node/ poe_enable; }; diff --git a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24e.dts b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24e.dts index b455ddf23a99..2ebef9ec51df 100644 --- a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24e.dts +++ b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24e.dts @@ -58,6 +58,6 @@ }; }; -&gpio1 { +&gpio_ext { /delete-node/ poe_enable; }; diff --git a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v1.dts b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v1.dts index fa9bef89d6ba..577d8af43813 100644 --- a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v1.dts +++ b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v1.dts @@ -13,8 +13,8 @@ /* i2c of the left SFP cage: port 25 */ i2c0: i2c-gpio-0 { compatible = "i2c-gpio"; - sda-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + sda-gpios = <&gpio_ext 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio_ext 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; #address-cells = <1>; #size-cells = <0>; @@ -23,17 +23,17 @@ sfp0: sfp-p25 { compatible = "sff,sfp"; i2c-bus = <&i2c0>; - los-gpio = <&gpio1 27 GPIO_ACTIVE_HIGH>; - tx-fault-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 26 GPIO_ACTIVE_LOW>; - tx-disable-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>; + los-gpio = <&gpio_ext 27 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpio_ext 22 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio_ext 26 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpio_ext 23 GPIO_ACTIVE_HIGH>; }; /* i2c of the right SFP cage: port 26 */ i2c1: i2c-gpio-1 { compatible = "i2c-gpio"; - sda-gpios = <&gpio1 30 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + sda-gpios = <&gpio_ext 30 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio_ext 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; #address-cells = <1>; #size-cells = <0>; @@ -42,10 +42,10 @@ sfp1: sfp-p26 { compatible = "sff,sfp"; i2c-bus = <&i2c1>; - los-gpio = <&gpio1 33 GPIO_ACTIVE_HIGH>; - tx-fault-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 32 GPIO_ACTIVE_LOW>; - tx-disable-gpio = <&gpio1 29 GPIO_ACTIVE_HIGH>; + los-gpio = <&gpio_ext 33 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpio_ext 28 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio_ext 32 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpio_ext 29 GPIO_ACTIVE_HIGH>; }; }; diff --git a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v2.dts b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v2.dts index 93011cbdaadf..e484a7641eed 100644 --- a/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v2.dts +++ b/target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v2.dts @@ -9,8 +9,8 @@ /* i2c of the left SFP cage: port 25 */ i2c0: i2c-gpio-0 { compatible = "i2c-gpio"; - sda-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + sda-gpios = <&gpio_ext 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio_ext 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; #address-cells = <1>; #size-cells = <0>; @@ -19,17 +19,17 @@ sfp0: sfp-p25 { compatible = "sff,sfp"; i2c-bus = <&i2c0>; - los-gpio = <&gpio1 27 GPIO_ACTIVE_HIGH>; - tx-fault-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 26 GPIO_ACTIVE_LOW>; - tx-disable-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>; + los-gpio = <&gpio_ext 27 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpio_ext 22 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio_ext 26 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpio_ext 23 GPIO_ACTIVE_HIGH>; }; /* i2c of the right SFP cage: port 26 */ i2c1: i2c-gpio-1 { compatible = "i2c-gpio"; - sda-gpios = <&gpio1 30 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&gpio1 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + sda-gpios = <&gpio_ext 30 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio_ext 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; #address-cells = <1>; #size-cells = <0>; @@ -38,10 +38,10 @@ sfp1: sfp-p26 { compatible = "sff,sfp"; i2c-bus = <&i2c1>; - los-gpio = <&gpio1 33 GPIO_ACTIVE_HIGH>; - tx-fault-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>; - mod-def0-gpio = <&gpio1 32 GPIO_ACTIVE_LOW>; - tx-disable-gpio = <&gpio1 29 GPIO_ACTIVE_HIGH>; + los-gpio = <&gpio_ext 33 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpio_ext 28 GPIO_ACTIVE_HIGH>; + mod-def0-gpio = <&gpio_ext 32 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpio_ext 29 GPIO_ACTIVE_HIGH>; }; };