net: phy: add driver for the ZTE ZX279128S internal Gigabit PHY
Subsystems (3)
PATCH 1/1 net: phy: add driver for the ZTE ZX279128S internal Gigabit PHY
The ZTE ZX279128S is a dual Cortex-A9 xPON home-gateway SoC, used in the ZTE ZXHN H3600 router. It integrates four Gigabit copper PHYs, one per LAN port of its on-chip switch, on the SoC's MDIO bus at addresses 10..13. They identify as 0x84b95031 (the low nibble is the revision).
There is no public datasheet. The registers and values come from the PHY initialisation in the vendor's platform module shipped in the router firmware (no source available); the function names below are that module's symbols.
- Registers 0x10/0x11 give indirect access to extended registers:
address in 0x10, data in 0x11. The pair is done with the MDIO bus lock held. It is not a page select, so phy_*_paged() does not fit.
- Register 0x17 and extended register 0xb640: the PHY's LDO.
gephy_ldo_init() writes 0x17 = 0x2448, then 0xb640 = 0x001f, on
every PHY. The meaning of the 0x17 fields is unknown. - Extended registers 0xb667..0xb6c2: the copper TX DAC drive. gephy_tx_dac_drv_force_enable() has a "force" and a reduced pattern; the driver applies the force pattern. Without it the PHY links and receives but does not drive the line: the MAC counts the transmitted frames and the link partner sees none.
The LDO is only armed when 0xb640 does not already read 0x001f: arming it again power-cycles the PHY's analog domain, which the switch sees as a link bounce. When nothing has armed it before, the driver does.
The board's boot firmware leaves the PHYs with BMCR_PDOWN set, hence .resume = genphy_resume(). There is no .suspend: powering the analog domain down and up at runtime has not been tested.
Not implemented: interrupts, since the per-PHY lines have not been seen to fire on a cable change on this board, so phylib polls. Also not implemented are two runtime policies of the vendor module. One lowers the LDO setting (0xb640 = 0x001c) at or above 60 C die temperature and restores it at or below 50 C; it needs a driver for the SoC temperature sensor first. The other switches the TX DAC between the two patterns from the link state.
Tested on a ZTE ZXHN H3600 with net-next: the four PHYs bind, lan0 links at 1000, 100 and 10 Mb/s full duplex with traffic, link down/up, warm boots.
---
This is the first piece of mainline support for the ZTE ZX279128S (ZTE ZXHN H3600 router). The SoC's MDIO controller, its on-chip switch (DSA) and packet-processor drivers will be posted separately; this PHY driver is matched by PHY ID and does not depend on them.
No datasheet is available. Every vendor-specific value in the driver comes from the vendor's PHY initialisation (function names in the commit message), and its observed effect is described where known.
--- MAINTAINERS | 6 ++ drivers/net/phy/Kconfig | 11 ++++ drivers/net/phy/Makefile | 1 + drivers/net/phy/zte-zx279128s.c | 136 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+)
MAINTAINERS +6 -0
@@ -30906,6 +30906,12 @@ L: [email protected] S: Maintained F: drivers/net/ethernet/zte/ +ZTE ZX279128S ETHERNET PHY DRIVER +M: Agustin Santiago Isasmendi <[email protected]> +L: [email protected] +S: Maintained +F: drivers/net/phy/zte-zx279128s.c + THE REST M: Linus Torvalds <[email protected]> L: [email protected]
drivers/net/phy/Kconfig +11 -0
@@ -503,4 +503,15 @@ config XILINX_GMII2RGMII the Reduced Gigabit Media Independent Interface(RGMII) between Ethernet physical media devices and the Gigabit Ethernet controller. +config ZTE_ZX279128S_PHY + tristate "ZTE ZX279128S internal Gigabit PHY" + help + Support for the four Gigabit Ethernet PHYs integrated in the ZTE + ZX279128S SoC (PHY ID 0x84b95031), found in the ZTE ZXHN H3600 + router. The driver powers the PHY's LDO and enables the copper + TX DAC drive, without which the PHYs link but do not transmit. + + To compile this driver as a module, choose M here: the module + will be called zte-zx279128s. + endif # PHYLIB
drivers/net/phy/Makefile +1 -0
@@ -103,3 +103,4 @@ obj-$(CONFIG_TERANETICS_PHY) += teranetics.o obj-$(CONFIG_VITESSE_PHY) += vitesse.o obj-$(CONFIG_XPOWERS_ACX00_PHY) += xpowers/ obj-$(CONFIG_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o +obj-$(CONFIG_ZTE_ZX279128S_PHY) += zte-zx279128s.o
drivers/net/phy/zte-zx279128s.c new file +136 -0
136 lines not on this page · raw message
---
base-commit: 0822d2fe38262e8b55c5ea55c970022bca8dd2a9
change-id: 20261105-phy-submit-a3fa3cbe9eed
Best regards,
Signature · 1 line
Agustin Santiago Isasmendi <[email protected]>
Andrew Lunn
maintainerdrivers/net/phy/zte-zx279128s.c line 78
Quoted 3 lines
drivers/net/phy/zte-zx279128s.c new file +3
-0+static int zte_gephy_config_init (struct phy_device *phydev) +{ +int ret, i, ldo;
Given how minimal this driver is, there are some potential traps we could fall into later when we find out more about the device. To reduce the risk a bit, please could you add a test here:
if (phydev->interface != PHY_INTERFACE_MODE_INTERNAL)
return -EINVAL;drivers/net/phy/zte-zx279128s.c line 123
Quoted 11 lines
drivers/net/phy/zte-zx279128s.c new file +11
-0+static struct phy_driver zte_gephy_driver[] = { + { +PHY_ID_MATCH_MODEL (ZTE_GEPHY_PHY_ID ), + .name ="ZTE ZX279128S Gigabit PHY" , + .flags =PHY_IS_INTERNAL , + .config_init = zte_gephy_config_init, +/* The boot firmware hands over with BMCR_PDOWN set. No +* .suspend: powering the analog domain down and up at runtime +* has not been tested. +*/ + .resume = genphy_resume,
It looks odd with just resume, it makes it look like a workaround.
Why not have config_init() take it out of power down?
Andrew
Thanks for the review.
Before sending a v2 I went back to the bench, and the result changes the picture, with the generic PHY driver and only what the boot firmware sets up, the four LAN PHYs link and pass traffic at 1000, 100 and 10 Mb/s with no errors, across cold and warm boots and repeated renegotiation.
The TX DAC registers already hold the values this driver writes, and the PHY adjusts them itself with the link speed. It turned out to be a bug in our MAC driver (frames were sent to the wrong egress port), not anything in the PHY. That leaves only an LDO level and one undocumented register, with no measured benefit, so I'm withdrawing this patch. This is also consistent with Navid's ZX279128S series, which uses the generic driver for these PHYs. If I find a case where the vendor settings make a difference, I'll come back with data.
Sorry for the noise, and thanks again.
Quoted 26 lines · Andrew Lunn
drivers/net/phy/zte-zx279128s.c line 78
Quoted 3 lines
drivers/net/phy/zte-zx279128s.c new file +3
-0+static int zte_gephy_config_init (struct phy_device *phydev) +{ +int ret, i, ldo;Given how minimal this driver is, there are some potential traps we could fall into later when we find out more about the device. To reduce the risk a bit, please could you add a test here:
if (phydev->interface != PHY_INTERFACE_MODE_INTERNAL) return -EINVAL;drivers/net/phy/zte-zx279128s.c line 123
Quoted 11 lines
drivers/net/phy/zte-zx279128s.c new file +11
-0+static struct phy_driver zte_gephy_driver[] = { + { +PHY_ID_MATCH_MODEL (ZTE_GEPHY_PHY_ID ), + .name ="ZTE ZX279128S Gigabit PHY" , + .flags =PHY_IS_INTERNAL , + .config_init = zte_gephy_config_init, +/* The boot firmware hands over with BMCR_PDOWN set. No +* .suspend: powering the analog domain down and up at runtime +* has not been tested. +*/ + .resume = genphy_resume,It looks odd with just resume, it makes it look like a workaround.
Why not have
config_init()take it out of power down?Andrew