ramips: enable SFP port for Ubiquiti ER-X-SFP
authorRené van Dorst <opensource@vdorst.com>
Tue, 10 Mar 2020 17:34:33 +0000 (01:34 +0800)
committerAlexander Couzens <lynxis@fe80.eu>
Sat, 25 Apr 2020 21:48:45 +0000 (23:48 +0200)
SFP cage of this device is connected via a AT8031 phy to port 5 of the switch.
This phy act as a RGMII-to-SerDes converter.

Also a I2C clock gate needs to be enabled in order to access the SFP module via I2C bus.
SFP cage also has module detect pin which is connected to I2C gpio expander.

With this patch the kernel/PHYLINK now can detect, readout and use the SFP module/port.

NOTE: SFP cage / AT8033 PHY only support 1000base-X encoding!
This means that some SGMII modules can work and only at forced 1GBit/full-duplex!

Signed-off-by: René van Dorst <opensource@vdorst.com>
target/linux/ramips/dts/mt7621_ubnt_edgerouter-x-sfp.dts
target/linux/ramips/mt7621/base-files/etc/board.d/02_network
target/linux/ramips/mt7621/config-5.4

index 9515f1d8b5b5b40c16bc35fb7bcd29649725ec41..0b58a78a5080e7407d116c533d07e647079eab00 100644 (file)
@@ -5,13 +5,71 @@
 / {
        model = "Ubiquiti EdgeRouter X SFP";
        compatible = "ubnt,edgerouter-x-sfp", "mediatek,mt7621-soc";
+
+       sfp_eth5: sfp_eth5 {
+               compatible = "sff,sfp";
+               i2c-bus = <&i2c>;
+               mod-def0-gpio = <&expander0 5 GPIO_ACTIVE_LOW>;
+               maximum-power-milliwatt = <1000>;
+       };
 };
 
 &i2c {
        status = "okay";
 
-       pca9555@25 {
+       /*
+        * PCA9655 GPIO expander
+        *  0-POE power port eth0
+        *  1-POE power port eth1
+        *  2-POE power port eth2
+        *  3-POE power port eth3
+        *  4-POE power port eth4
+        *  5-SFP_MOD_DEF0#
+        *  6-
+        *  7-
+        *  8-Pull up to VCC
+        *  9-Pull down to GND
+        * 10-Pull down to GND
+        * 11-Pull down to GND
+        * 12-Pull down to GND
+        * 13-Pull down to GND
+        * 14-Pull down to GND
+        * 15-Pull down to GND
+        */
+       expander0: pca9555@25 {
                compatible = "nxp,pca9555";
+               interrupt-parent = <&gpio>;
+               interrupts = <8 IRQ_TYPE_EDGE_FALLING>;
+               gpio-controller;
+               #gpio-cells = <2>;
                reg = <0x25>;
        };
 };
+
+&gpio {
+       sfp_i2c_clk_gate {
+               gpio-hog;
+               gpios = <7 GPIO_ACTIVE_LOW>;
+               output-high;
+       };
+};
+
+&mdio {
+       ephy7: ethernet-phy@7 {
+               reg = <7>;
+               sfp = <&sfp_eth5>;
+       };
+};
+
+&switch0 {
+       ports {
+               port@5 {
+                       reg = <5>;
+                       label = "eth5";
+                       phy-handle = <&ephy7>;
+                       phy-mode = "rgmii-rxid";
+                       mtd-mac-address = <&factory 0x22>;
+                       mtd-mac-address-increment = <5>;
+               };
+       };
+};
index 252f9f1dda6c426007d5e411991f8a51f4e4c481..952146478cce8b682f55400252e3ffadf632fd3a 100755 (executable)
@@ -42,10 +42,12 @@ ramips_setup_interfaces()
        mikrotik,routerboard-750gr3)
                ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan"
                ;;
-       ubnt,edgerouter-x|\
-       ubnt,edgerouter-x-sfp)
+       ubnt,edgerouter-x)
                ucidef_set_interface_lan "eth0 eth1 eth2 eth3 eth4"
                ;;
+       ubnt,edgerouter-x-sfp)
+               ucidef_set_interface_lan "eth0 eth1 eth2 eth3 eth4 eth5"
+               ;;
        *)
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
                ;;
index e91003d8d28199216e6ca27f10bdb3bb162e5093..fda295a93f35dd48e2be5e8ddcbd377d27d628d0 100644 (file)
@@ -19,6 +19,7 @@ CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
 CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
 CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT=y
 CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
+CONFIG_AT803X_PHY=y
 CONFIG_BLK_MQ_PCI=y
 CONFIG_BOARD_SCACHE=y
 CONFIG_BOUNCE=y