Skip to content

Commit

Permalink
realtek: rtl838x: Switch GS1900 rtl8231 driver
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
svanheule committed Dec 27, 2024
1 parent 9dbd67a commit efc7aec
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 57 deletions.
24 changes: 12 additions & 12 deletions target/linux/realtek/dts/rtl8380_zyxel_gs1900-10hp.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand All @@ -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>;
Expand All @@ -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>;
};
};

Expand Down
2 changes: 1 addition & 1 deletion target/linux/realtek/dts/rtl8380_zyxel_gs1900-8.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
model = "Zyxel GS1900-8v1/v2 Switch";
};

&gpio1 {
&gpio_ext {
/delete-node/ poe_enable;
};
34 changes: 29 additions & 5 deletions target/linux/realtek/dts/rtl8380_zyxel_gs1900.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

reset {
label = "reset";
gpios = <&gpio1 3 GPIO_ACTIVE_LOW>;
gpios = <&gpio_ext 3 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
};
Expand All @@ -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";
};
};
};

Expand Down
2 changes: 1 addition & 1 deletion target/linux/realtek/dts/rtl8382_zyxel_gs1900-16.dts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
};
};

&gpio1 {
&gpio_ext {
/delete-node/ poe_enable;
};
26 changes: 13 additions & 13 deletions target/linux/realtek/dts/rtl8382_zyxel_gs1900-24-v1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand All @@ -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>;
Expand All @@ -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>;
};
};

Expand Down Expand Up @@ -123,6 +123,6 @@
};
};

&gpio1 {
&gpio_ext {
/delete-node/ poe_enable;
};
2 changes: 1 addition & 1 deletion target/linux/realtek/dts/rtl8382_zyxel_gs1900-24e.dts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
};
};

&gpio1 {
&gpio_ext {
/delete-node/ poe_enable;
};
24 changes: 12 additions & 12 deletions target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand All @@ -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>;
Expand All @@ -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>;
};
};

Expand Down
24 changes: 12 additions & 12 deletions target/linux/realtek/dts/rtl8382_zyxel_gs1900-24hp-v2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand All @@ -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>;
Expand All @@ -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>;
};
};

Expand Down

0 comments on commit efc7aec

Please sign in to comment.