realtek: rtl838x: Switch GS1900 rtl8231 driver realtek/rtl8231-mfd
authorSander Vanheule <sander@svanheule.net>
Thu, 26 Dec 2024 21:26:33 +0000 (22:26 +0100)
committerSander Vanheule <sander@svanheule.net>
Fri, 27 Dec 2024 15:15:20 +0000 (16:15 +0100)
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 <sander@svanheule.net>
target/linux/realtek/dts/rtl8380_zyxel_gs1900-10hp.dts
target/linux/realtek/dts/rtl8380_zyxel_gs1900-8.dts
target/linux/realtek/dts/rtl8380_zyxel_gs1900.dtsi
target/linux/realtek/dts/rtl8382_zyxel_gs1900-16.dts
target/linux/realtek/dts/rtl8382_zyxel_gs1900-24-v1.dts
target/linux/realtek/dts/rtl8382_zyxel_gs1900-24e.dts
target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v1.dts
target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v2.dts

index 190a77b7ff7198742b89a671dbe3322f22990d28..8edc815df759ddb55f649a8bf75486f377b198ee 100644 (file)
@@ -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>;
        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>;
        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>;
        };
 };
 
index 548e83ba7308eb81f6f37adccc8e0c990f9efec6..6ae97041b1ff9b2cfb972976d835c26dd014dd92 100644 (file)
@@ -7,6 +7,6 @@
        model = "Zyxel GS1900-8v1/v2 Switch";
 };
 
-&gpio1 {
+&gpio_ext {
        /delete-node/ poe_enable;
 };
index b985c4bc8e499df79ff3cde0fe7a422b7242bfb4..a0e69eaf423ebe0cc8a0e56d2a9a98905e086171 100644 (file)
@@ -24,7 +24,7 @@
 
                reset {
                        label = "reset";
-                       gpios = <&gpio1 3 GPIO_ACTIVE_LOW>;
+                       gpios = <&gpio_ext 3 GPIO_ACTIVE_LOW>;
                        linux,code = <KEY_RESTART>;
                };
        };
                };
        };
 
-       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";
+               };
        };
 };
 
index 6010da2e26c3f5843c00a92911b867abdbd35bcf..495e96f5794f9dcaf9b5639e04e781014517590d 100644 (file)
@@ -31,6 +31,6 @@
        };
 };
 
-&gpio1 {
+&gpio_ext {
        /delete-node/ poe_enable;
 };
index 6d98e7fae1dcd443284b9dcf12deeac6297d591f..5c044fb10209af1953309fe3a6f37668489b0375 100644 (file)
@@ -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>;
        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>;
        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>;
        };
 };
 
        };
 };
 
-&gpio1 {
+&gpio_ext {
        /delete-node/ poe_enable;
 };
index b455ddf23a990dfef68d1fb41d178aa3a59bf19a..2ebef9ec51dfe50d11d711bc16f8c786ab868668 100644 (file)
@@ -58,6 +58,6 @@
        };
 };
 
-&gpio1 {
+&gpio_ext {
        /delete-node/ poe_enable;
 };
index fa9bef89d6ba7ff00f6d847f53a167370bbdff53..577d8af43813278b2ba29fb06cf515ebe7b9f583 100644 (file)
@@ -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>;
        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>;
        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>;
        };
 };
 
index 93011cbdaadfabf92253008fdc16623e194aa81b..e484a7641eeda2e32049e0662be87a4a21c56d95 100644 (file)
@@ -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>;
        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>;
        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>;
        };
 };