Ok here is a little update @daniel
Given that we have the pin mapping from the zyxel script let me summarize what I understand from that code:
GPIO LIST (gpio base 411)
10 - 421 LOW FOR SFP, HIGH FOR 2.5 PHY
23 - 434 AE_RX_LOS_3V3
26 - 437 AE_TX_DIS_3V3
28 - 439 AE TX_FAULT_3V3
57 - 468 AE_MOD_ABS_1V8
When the SFP is not inserted the pins are configured this way:
421 = 1 GPIO_ACTIVE_LOW
434 = 1 GPIO_ACTIVE_LOW
437 = 0 GPIO_ACTIVE_HIGH
439 = 1 GPIO_ACTIVE_LOW
468 = 1 GPIO_ACTIVE_LOW
When the SFP is inserted:
421 = 0 GPIO_ACTIVE_HIGH
434 = 0 GPIO_ACTIVE_HIGH
437 = 0 GPIO_ACTIVE_HIGH
439 = 1 GPIO_ACTIVE_LOW
468 = 0 GPIO_ACTIVE_HIGH
I've been reading around some examples (bpi-r3 forum) of how SFP are wired into the DTS so this is my test:
Added the i2c bus and the pins taken directly from the zyxel oem DTS:
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c_pins>;
status = "okay";
};
&pio {
i2c_pins: i2c-pins-3-4 {
mux {
function = "i2c";
groups = "i2c";
};
};
Added the sfp definition with pins configured for no sfp present (is this correct?):
sfp: sfp {
compatible = "sff,sfp";
i2c-bus = <&i2c0>;
los-gpios = <&pio 23 GPIO_ACTIVE_LOW>;
mod-def0-gpios = <&pio 57 GPIO_ACTIVE_LOW>;
tx-disable-gpios = <&pio 26 GPIO_ACTIVE_HIGH>;
tx-fault-gpios = <&pio 28 GPIO_ACTIVE_LOW>;
maximum-power-milliwatt = <3000>;
};
Added into the ð > gmac1 the following (sfp=&sfp), is this the right spot?:
gmac1: mac@1 {
compatible = "mediatek,eth-mac";
reg = <1>;
phy-mode = "2500base-x";
phy = <&phy6>;
sfp = <&sfp>;
nvmem-cells = <&macaddr_factory_0024>;
nvmem-cell-names = "mac-address";
};
After compiling and booting here are my tests:
- Boot the router without SFP
- moving the wan port into the bridge (just to see if the phy is activated and works):
root@OpenWrt:/# [ 80.339117] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:06] driver [Maxlinear Ethernet GPY211B] (irq=POLL)
[ 80.349294] mtk_soc_eth 15100000.ethernet eth1: configuring for phy/2500base-x link mode
[ 80.359834] br-lan: port 5(eth1) entered blocking state
[ 80.365064] br-lan: port 5(eth1) entered disabled state
[ 80.370450] device eth1 entered promiscuous mode
This seems ok but the wan port is not working, if I plug the cable i see no traffic.
3. I decide to insert the sfp and see if any logs show anything:
root@OpenWrt:/# [ 217.427828] sfp sfp: please wait, module slow to respond
[ 262.818272] sfp sfp: module HUAWEI MA5671A rev 0000 sn 032VRJ10K6004724 dc 190514
[ 262.848193] hwmon hwmon2: temp1_input not attached to any thermal zone
Good, the sfp is recognized but no traffic is received:
root@OpenWrt:/# ethtool -m eth1
Identifier : 0x03 (SFP)
Extended identifier : 0x04 (GBIC/SFP defined by 2-wire interface ID)
Connector : 0x01 (SC)
Transceiver codes : 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00
Transceiver type : Ethernet: 1000BASE-LX
Encoding : 0x03 (NRZ)
BR, Nominal : 1200MBd
Rate identifier : 0x00 (unspecified)
Length (SMF,km) : 20km
Length (SMF) : 20000m
Length (50um) : 0m
Length (62.5um) : 0m
Length (Copper) : 0m
Length (OM3) : 0m
Laser wavelength : 1310nm
Vendor name : HUAWEI
Vendor OUI : 00:00:00
Vendor PN : MA5671A
Vendor rev : 0000
Option values : 0x00 0x1a
Option : RX_LOS implemented
Option : TX_FAULT implemented
Option : TX_DISABLE implemented
BR margin, max : 0%
BR margin, min : 0%
Vendor SN : 032VRJ10K6004724
Date code : 190514
Optical diagnostics support : Yes
Laser bias current : 6.332 mA
Laser output power : 0.0001 mW / -40.00 dBm
Receiver signal average optical power : 0.0001 mW / -40.00 dBm
Module temperature : 40.74 degrees C / 105.33 degrees F
Module voltage : 3.3671 V
Alarm/warning flags implemented : Yes
Laser bias current high alarm : Off
Laser bias current low alarm : Off
Laser bias current high warning : Off
Laser bias current low warning : Off
Laser output power high alarm : Off
Laser output power low alarm : On
Laser output power high warning : Off
Laser output power low warning : On
Module temperature high alarm : Off
Module temperature low alarm : Off
Module temperature high warning : Off
Module temperature low warning : Off
Module voltage high alarm : Off
Module voltage low alarm : Off
Module voltage high warning : Off
Module voltage low warning : Off
Laser rx power high alarm : Off
Laser rx power low alarm : On
Laser rx power high warning : Off
Laser rx power low warning : On
Laser bias current high alarm threshold : 90.000 mA
Laser bias current low alarm threshold : 0.000 mA
Laser bias current high warning threshold : 70.000 mA
Laser bias current low warning threshold : 0.000 mA
Laser output power high alarm threshold : 3.9810 mW / 6.00 dBm
Laser output power low alarm threshold : 0.8912 mW / -0.50 dBm
Laser output power high warning threshold : 3.1622 mW / 5.00 dBm
Laser output power low warning threshold : 1.1220 mW / 0.50 dBm
Module temperature high alarm threshold : 95.00 degrees C / 203.00 degrees F
Module temperature low alarm threshold : -50.00 degrees C / -58.00 degrees F
Module temperature high warning threshold : 90.00 degrees C / 194.00 degrees F
Module temperature low warning threshold : -45.00 degrees C / -49.00 degrees F
Module voltage high alarm threshold : 3.6000 V
Module voltage low alarm threshold : 3.0000 V
Module voltage high warning threshold : 3.5000 V
Module voltage low warning threshold : 3.1000 V
Laser rx power high alarm threshold : 0.2511 mW / -6.00 dBm
Laser rx power low alarm threshold : 0.0013 mW / -28.86 dBm
Laser rx power high warning threshold : 0.1995 mW / -7.00 dBm
Laser rx power low warning threshold : 0.0016 mW / -27.96 dBm
Second test:
- boot the router with the sfp inserted immediately:
During the bootlog i read the following:
33.378282] sfp sfp: module HUAWEI MA5671A rev 0000 sn 032VRJ10K6004724 dc 190514
[ 33.387598] mtk_soc_eth 15100000.ethernet eth1: switched to inband/2500base-x link mode
[ 33.408187] hwmon hwmon2: temp1_input not attached to any thermal zone
Ethtool shows same infos like previous test
2. Try to move the eth1 port into the bridge and see if there is any traffic:
root@OpenWrt:/# [ 77.456152] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:06] driver [Maxlinear Ethernet GPY211B] (irq=POLL)
[ 77.466341] mtk_soc_eth 15100000.ethernet eth1: configuring for inband/2500base-x link mode
[ 77.477152] br-lan: port 5(eth1) entered blocking state
[ 77.482403] br-lan: port 5(eth1) entered disabled state
[ 77.487777] device eth1 entered promiscuous mode
[ 77.527641] ------------[ cut here ]------------
[ 77.532259] called from state NOLINK
[ 77.535839] WARNING: CPU: 1 PID: 478 at phy_start+0x98/0xb0
[ 77.541403] Modules linked in: xt_connlimit pppoe ppp_async option nft_fib_inet nf_flow_table_ipv6 nf_flow_table_ipv4 nf_flow_table_inet nf_conncount xt_state xt_helper xt_conntrack xt_connmark xt_connbytes wireguard usb_wwan rndis_host qmi_wwan pppox ppp_generic nft_reject_ipv6 nft_reject_ipv4 nft_reject_inet nft_reject nft_redir nft_quota nft_objref nft_numgen nft_nat nft_masq nft_log nft_limit nft_hash nft_flow_offload nft_fib_ipv6 nft_fib_ipv4 nft_fib nft_ct nft_counter nft_chain_nat nf_tables nf_nat nf_flow_table nf_conntrack mt7915e mt76_connac_lib mt76 mac80211 libchacha20poly1305 iptable_mangle iptable_filter ipt_REJECT ip_tables chacha_neon cfg80211 cdc_ncm cdc_ether xt_time xt_tcpudp xt_recent xt_multiport xt_mark xt_mac xt_limit xt_comment xt_TCPMSS xt_LOG x_tables usbserial usbnet usblp spi_gpio spi_bitbang slhc sfp poly1305_neon nfnetlink nf_reject_ipv6 nf_reject_ipv4 nf_log_syslog nf_defrag_ipv6 nf_defrag_ipv4 mdio_netlink mdio_i2c libcurve25519_generic libcrc32c libchacha
[ 77.541550] hwmon hso crc_ccitt compat cdc_wdm cdc_acm crypto_safexcel i2c_mux_gpio i2c_mux ip6_gre ip_gre gre nat46 sit ip6_tunnel tunnel6 snd_rawmidi snd_seq_device snd_pcm_oss snd_mixer_oss snd_hwdep snd_compress ntfs br2684 atm sha1_generic md5 des_generic libdes usb_storage leds_gpio xhci_plat_hcd xhci_pci xhci_mtk_hcd xhci_hcd ohci_platform ohci_hcd fsl_mph_dr_of ehci_platform ehci_fsl ehci_hcd gpio_button_hotplug exfat gpio_cascade mux_gpio mux_core usbcore usb_common mii
[ 77.671196] CPU: 1 PID: 478 Comm: kworker/u8:4 Not tainted 5.15.107 #0
[ 77.677703] Hardware name: Zyxel EX5601-T0 (DT)
[ 77.682215] Workqueue: events_power_efficient 0xffffffc000b122a0
[ 77.688222] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 77.695162] pc : phy_start+0x98/0xb0
[ 77.698722] lr : phy_start+0x98/0xb0
[ 77.702281] sp : ffffffc00bd43d20
[ 77.705579] x29: ffffffc00bd43d20 x28: 0000000000000000 x27: ffffff8000fa0b40
[ 77.712694] x26: ffffff8003f27174 x25: ffffff8000007105 x24: ffffff8000008ab0
[ 77.719811] x23: 0000000000000000 x22: ffffff8000007100 x21: ffffff800000c000
[ 77.726927] x20: ffffff80009e7490 x19: ffffff80009e7000 x18: ffffffc00b1ea460
[ 77.734043] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000390
[ 77.741158] x14: 0000000000000130 x13: ffffffc00bd43a48 x12: ffffffc00b242460
[ 77.748274] x11: fffffffffffe4f68 x10: ffffffc00b242460 x9 : 0000000000000000
[ 77.755389] x8 : ffffffc00b1ea410 x7 : ffffffc00b1ea460 x6 : 0000000000000001
[ 77.762505] x5 : ffffff803fd936f8 x4 : 0000000000000000 x3 : 0000000000000027
[ 77.769620] x2 : 0000000000000027 x1 : 0000000000000023 x0 : 0000000000000018
[ 77.776736] Call trace:
[ 77.779167] phy_start+0x98/0xb0
[ 77.782381] phylink_sfp_module_start+0x44/0x4c
[ 77.786895] sfp_module_start+0x30/0x44
[ 77.790716] 0xffffffc000b10614
[ 77.793844] 0xffffffc000b122dc
[ 77.796972] process_one_work+0x210/0x3b0
[ 77.800967] worker_thread+0x170/0x4d0
[ 77.804699] kthread+0x11c/0x130
[ 77.807915] ret_from_fork+0x10/0x20
[ 77.811476] ---[ end trace 55e1587ab3afeed3 ]---
To mee it seems that the phy crashed...or some panic from the phy which doesn't know what to do
The big missing point here is pin 10 that should manage swapping between sfp and phy ethernet. I can't really find any examples on the internet on where to put that to allow swapping...
adding @bmork in case you have experience with this.
PS. when booting the zyxel firmware i see 2 additional pins that are not documented into /sys/class/gpio:
436 == ??? value 1
464 == ??? value 1
I don't know what they do and how they are exported given that are not preset into the script.
Thank you