realtek: EnGenius EWS2910P: add support for SFP ports
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Mon, 16 May 2022 02:54:47 +0000 (21:54 -0500)
committerSander Vanheule <sander@svanheule.net>
Sat, 25 Jun 2022 13:45:30 +0000 (15:45 +0200)
The SFP cages 9F and 10F share the same SCL line. Currently, there
isn't a good way to model this. Thus, only one SFP port can be fully
supported.

Cage 10F is fully supported with an I2C bus and sfp handle. Linux
automatically handles enabling or disabling the TX laser.

Cage 9F is only parially supported, without the sfp handle. The SDA
line is hogged as an input, so that it remains high. SCL transitions
sould not affect modules connected to this cage. The default value of
the tx-disable line is high (active). It is exported as a gpio, but
the laser is off by default. To enable the laser:

    echo 0 > /sys/class/gpio/sff-p9-tx-disable/value

Thus, both modules can be used for networking, but only 10F will be
able to detect and identify a plugged in SFP module.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
target/linux/realtek/dts-5.10/rtl8380_engenius_ews2910p.dts

index feb57fecffc93debfc8909b1463043b28f087f48..f87c9585f9d30384508044c1f3c4dc4a2cb3b9ea 100644 (file)
                #gpio-cells = <2>;
                gpio-controller;
                indirect-access-bus-id = <0>;
+
+               sff_p9_gpios {
+                       gpio-hog;
+                       gpios = < 6 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>,
+                               < 11 GPIO_ACTIVE_HIGH>, /* los-gpio */
+                               < 12 GPIO_ACTIVE_LOW>;   /* mod-def0-gpio */
+                       input;
+                       line-name = "sff-p9-gpios";
+               };
+       };
+
+       gpio-export {
+               compatible = "gpio-export";
+
+               sff-p9-tx-disable {
+                       gpio-export,name = "sff-p9-tx-disable";
+                       gpio-export,output = <1>;
+                       gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
+               };
        };
 
        gpio-restart {
                        gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
                };
        };
+
+       i2c1: i2c-gpio-1 {
+               compatible = "i2c-gpio";
+               sda-gpios = <&gpio1 7 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+               scl-gpios = <&gpio1 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>;
+               tx-disable-gpio = <&gpio1 13 GPIO_ACTIVE_HIGH>;
+               los-gpio = <&gpio1 14 GPIO_ACTIVE_HIGH>;
+               mod-def0-gpio = <&gpio1 21 GPIO_ACTIVE_LOW>;
+       };
 };
 
 &spi0 {
                INTERNAL_PHY(13)
                INTERNAL_PHY(14)
                INTERNAL_PHY(15)
+
+               INTERNAL_PHY(24)
+               INTERNAL_PHY(26)
        };
 };
 
                SWITCH_PORT(14, 7, internal)
                SWITCH_PORT(15, 8, internal)
 
+               SWITCH_SFP_PORT(24, 9, 1000base-x)
+
+               port@26 {
+                       reg = <26>;
+                       label = "lan10";
+                       phy-mode = "1000base-x";
+                       phy-handle = <&phy26>;
+                       managed = "in-band-status";
+                       sfp = <&sfp1>;
+               };
+
                port@28 {
                        ethernet = <&ethernet0>;
                        reg = <28>;