net: ethernet: mtk_eth_soc: add paths and SerDes modes
Subsystems (5)
v2 cover net: ethernet: mtk_eth_soc: add paths and SerDes modes
The series brings support for SerDes interface modes up to 10 Gb/s for the MediaTek MT7988 SoC.
As the Ethernet driver now requires a few more phandles in device tree referencing various other parts of the SoC also add corresponding dt-binding changes.
It may be argued that instead of referencing those units as syscon and access them as regmap one may want to implement propper clk or reset drivers. However, only a single register write is require to the otherwise completely undocumented pextp_pll unit which will not make a nice clk driver...
The toprgu/watchdog reset controller is used to synchronously assert/deassert multiple resets as the same time which is not supported by Linux reset controller API which always asserts/deasserts resets sequentially. It is not known whether asserting/deasserting pextp, sgmii, xfi and usxgii resets simultanously is stricly required for the hardware to work reliably, however, it's what the vendor implementation is doing as well and there are no other drivers needing to access the toprgu reset controller.
This series has been tested with the MT7988 reference board as well as pre-mass-production BananaPi BPi-R4 board also featuring MT7988. Various SFP(+) modules have been successfully tested on both boards and also the on-board AQR133 10GE PHY found on the MT7988 reference board works nicely.
To make sure no existing older SoCs have been broken run-time tests have also been carried out on various MT7981, MT7986, MT7622 and MT7623 boards. The patch is also present in OpenWrt for some months now already and hence supposedly hundreds of users also on older MT7621 systems should have tested it while I didn't hear about any complaints so far.
For the interfaces modes covered by the existing LynxI PCS driver (Cisco SGMII, 1000Base-X, 2500Base-X) to work on MT7988 this series depends on commit 90308679c297f ("net: pcs: lynxi: implement pcs_disable op").
Changes since v1:
* add missing macro defines (v1 didn't build for that reason)
* add dt-bindings changes
Daniel Golle (2):
dt-bindings: net: mediatek,net: add phandles for SerDes on MT7988
net: ethernet: mtk_eth_soc: add paths and SerDes modes for MT7988
.../devicetree/bindings/net/mediatek,net.yaml | 28 + drivers/net/ethernet/mediatek/Kconfig | 16 + drivers/net/ethernet/mediatek/Makefile | 1 + drivers/net/ethernet/mediatek/mtk_eth_path.c | 123 ++- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 182 ++++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 237 +++++- drivers/net/ethernet/mediatek/mtk_usxgmii.c | 698 ++++++++++++++++++ 7 files changed, 1254 insertions(+), 31 deletions(-) create mode 100644 drivers/net/ethernet/mediatek/mtk_usxgmii.c
Signature · 1 line
2.42.0
PATCH v2 1/2 dt-bindings: net: mediatek,net: add phandles for SerDes on MT7988
Add several phandles needed for Ethernet SerDes interfaces on the MediaTek MT7988 SoC.
--- .../devicetree/bindings/net/mediatek,net.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)
Documentation/devicetree/bindings/net/mediatek,net.yaml +28 -0
@@ -385,6 +385,34 @@ allOf: minItems: 2 maxItems: 2 + mediatek,toprgu: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon representing the reset controller. + + mediatek,usxgmiisys: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 2 + maxItems: 2 + items: + maxItems: 1 + description: + A list of phandle to the syscon node referencing the USXGMII PCS. + + mediatek,xfi-pextp: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 2 + maxItems: 2 + items: + maxItems: 1 + description: + A list of phandle to the syscon node that handles the 10GE SerDes PHY. + + mediatek,xfi-pll: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon node handling the 10GE SerDes clock setup. + patternProperties: "^mac@[0-1]$": type: object
Signature · 1 line
2.42.0
Rob Herring
maintainerRe: [PATCH net-next v2 1/2] dt-bindings: net: mediatek,net: add phandles for SerDes on MT7988
Quoted 13 lines · Daniel Golle
Add several phandles needed for Ethernet SerDes interfaces on the MediaTek MT7988 SoC.
Signed-off-by Daniel Golle <[email protected]>--- .../devicetree/bindings/net/mediatek,net.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)Documentation/devicetree/bindings/net/mediatek,net.yaml +0
-0
Documentation/devicetree/bindings/net/mediatek,net.yaml allOf: · line 391
Quoted 7 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +4
-0@@ -385,6 +385,34 @@ allOf: minItems: 2 maxItems: 2 + mediatek,toprgu: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon representing the reset controller.
Use the reset binding
Documentation/devicetree/bindings/net/mediatek,net.yaml allOf: · line 400
Quoted 9 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +9
-0+ + mediatek,usxgmiisys: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 2 + maxItems: 2 + items: + maxItems: 1 + description: + A list of phandle to the syscon node referencing the USXGMII PCS.
Use the PCS binding
Documentation/devicetree/bindings/net/mediatek,net.yaml allOf: · line 409
Quoted 9 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +9
-0+ + mediatek,xfi-pextp: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 2 + maxItems: 2 + items: + maxItems: 1 + description: + A list of phandle to the syscon node that handles the 10GE SerDes PHY.
Use the phy binding (phys, not phy-handle for ethernet PHY).
Documentation/devicetree/bindings/net/mediatek,net.yaml allOf: · line 414
Quoted 5 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +5
-0+ + mediatek,xfi-pll: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon node handling the 10GE SerDes clock setup.
Use the clock binding
Quoted 6 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +1
-0+ patternProperties: "^mac@[0-1]$": type: objectSignature · 1 line
2.42.0
Re: [PATCH net-next v2 1/2] dt-bindings: net: mediatek,net: add phandles for SerDes on MT7988
Hi Rob,
thank you for the review!
Quoted 17 lines · Rob Herring
Quoted 16 lines · Daniel Golle
Add several phandles needed for Ethernet SerDes interfaces on the MediaTek MT7988 SoC.
Signed-off-by Daniel Golle <[email protected]>--- .../devicetree/bindings/net/mediatek,net.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)Documentation/devicetree/bindings/net/mediatek,net.yaml +0
-0@@ -385,6 +385,34 @@ allOf: minItems: 2 maxItems: 2
Quoted 6 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml allOf: · line 391
Quoted 4 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +4
-0+ mediatek,toprgu: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon representing the reset controller.Use the reset binding
I got an alternative implementation ready which implements an actual reset controller (by extending drivers/watchdog/mtk_wdt.c to cover also MT7988 and its addition sw-reset-enable bits) and uses single phandles for each reset bit assigned to the corresponding units instead of listing them all for the ethernet controller (maybe that's one step too far though...)
However, as mentioned in the cover letter, using the Linux reset controller API (which having to use is a consequence of having to use the reset bindings) doesn't allow to simultanously deassert the resets of pextp, usxgmii pcs and/or sgmii pcs which is how the vendor implementation is doing it as all reset bits are on the same 32-bit register and the Ethernet driver is the only driver needing to access that register.
Asserting the resets in sequence and subsequently deasserting in sequence works for me, but it will have to be confirmed to not create any problems because it's clearly a deviation from the behavior of the reference implementation.
Quoted 11 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml allOf: · line 400
Quoted 10 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +9
-0+ + mediatek,usxgmiisys: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 2 + maxItems: 2 + items: + maxItems: 1 + description: + A list of phandle to the syscon node referencing the USXGMII PCS.
Quoted 1 line
Use the PCS binding
Ack, I will ie. implement standalone PCS driver similar to eg. pcs-rzn1-miic.c.
Quoted 11 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml allOf: · line 409
Quoted 10 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +9
-0+ + mediatek,xfi-pextp: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 2 + maxItems: 2 + items: + maxItems: 1 + description: + A list of phandle to the syscon node that handles the 10GE SerDes PHY.
Quoted 1 line
Use the phy binding (phys, not phy-handle for ethernet PHY).
Ack, this can be implemented as a standalone PHY driver using PHY bindings. I will do that instead.
Quoted 8 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml allOf: · line 414
Quoted 6 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +5
-0+ + mediatek,xfi-pll: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon node handling the 10GE SerDes clock setup.Use the clock binding
Does that imply that I should implement a clock driver whith only a single clock offering only a single operation ('enable') which would then do the magic register writes?
While one part is actually identifyable as taking care of enabling a clock, I would not know how to meaningfully abstract the other (first) part, see vendor driver:
/* Register to control USXGMII XFI PLL digital */
#define XFI_PLL_DIG_GLB8 0x08
#define RG_XFI_PLL_EN BIT(31)
/* Register to control USXGMII XFI PLL analog */
#define XFI_PLL_ANA_GLB8 0x108
#define RG_XFI_PLL_ANA_SWWA 0x02283248
[...]
/* Add software workaround for USXGMII PLL TCL issue */ regmap_write(ss->pll, XFI_PLL_ANA_GLB8, RG_XFI_PLL_ANA_SWWA); // How would you represent the line above using the abstractions of the // common clk framework?
regmap_read(ss->pll, XFI_PLL_DIG_GLB8, &val); // that looks like it
val |= RG_XFI_PLL_EN; // <- could be a abstractedregmap_write(ss->pll, XFI_PLL_DIG_GLB8, val); // in a meaningful way in
clock driver.
... which is all we ever do on that regmap. Ever.
Thanks in advance to everybody sharing their ideas and advises.
Re: [PATCH net-next v2 1/2] dt-bindings: net: mediatek,net: add phandles for SerDes on MT7988
Quoted 36 lines · Daniel Golle
Hi Rob,
thank you for the review!
Quoted 17 lines · Rob Herring
Quoted 16 lines · Daniel Golle
Add several phandles needed for Ethernet SerDes interfaces on the MediaTek MT7988 SoC.
Signed-off-by Daniel Golle <[email protected]>--- .../devicetree/bindings/net/mediatek,net.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)Documentation/devicetree/bindings/net/mediatek,net.yaml +0
-0@@ -385,6 +385,34 @@ allOf: minItems: 2 maxItems: 2Quoted 6 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml allOf: · line 391
Quoted 4 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +4
-0+ mediatek,toprgu: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon representing the reset controller.Use the reset binding
I got an alternative implementation ready which implements an actual reset controller (by extending
drivers/watchdog/mtk_wdt.cto cover also MT7988 and its addition sw-reset-enable bits) and uses single phandles for each reset bit assigned to the corresponding units instead of listing them all for the ethernet controller (maybe that's one step too far though...)
Quoted 7 lines
However, as mentioned in the cover letter, using the Linux reset controller API (which having to use is a consequence of having to use the reset bindings) doesn't allow to simultanously deassert the resets of pextp, usxgmii pcs and/or sgmii pcs which is how the vendor implementation is doing it as all reset bits are on the same 32-bit register and the Ethernet driver is the only driver needing to access that register.
You can have reset for entire register, why not? And even if current Linux implementation had some troubles with this, you could fix it.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Documentation/devicetree/bindings/net/mediatek,net.yaml +5
-0+ + mediatek,xfi-pll: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon node handling the 10GE SerDes clock setup.
Quoted 5 lines
Quoted 1 line
Use the clock binding
Does that imply that I should implement a clock driver whith only a single clock offering only a single operation ('enable') which would then do the magic register writes?
Yes
Quoted 13 lines
While one part is actually identifyable as taking care of enabling a clock, I would not know how to meaningfully abstract the other (first) part, see vendor driver:
/* Register to control USXGMII XFI PLL digital */
#defineXFI_PLL_DIG_GLB80x08
#defineRG_XFI_PLL_ENBIT(31)/* Register to control USXGMII XFI PLL analog */
#defineXFI_PLL_ANA_GLB80x108
#defineRG_XFI_PLL_ANA_SWWA0x02283248
Quoted 6 lines
[...]
/* Add software workaround for USXGMII PLL TCL issue */
regmap_write(ss->pll, XFI_PLL_ANA_GLB8, RG_XFI_PLL_ANA_SWWA); // How would you represent the line above using the abstractions of the // common clk framework?
What is above line? Please do not ask us to decode your vendor code. You know, we also have nothing to do with it.
And anyway, why do you need to abstract it? Why not writing unconditionally?
Quoted 7 lines
regmap_read(ss->pll, XFI_PLL_DIG_GLB8, &val); // that looks like it
val |=RG_XFI_PLL_EN; // <- could be a abstractedregmap_write(ss->pll, XFI_PLL_DIG_GLB8, val); // in a meaningful way in
clock driver.... which is all we ever do on that regmap. Ever.
Not only. You will also get all Linux infrastructure associated with this clock, so proper devlinks, sysfs/debug entries, automatic gating of unused clocks etc.
Best regards,
Krzysztof
PATCH v2 2/2 net: ethernet: mtk_eth_soc: add paths and SerDes modes for MT7988
In reply to Daniel GolleMT7988 comes with a built-in 2.5G PHY as well as SerDes lanes to connect external PHYs or transceivers in USXGMII, 10GBase-R, 5GBase-R, 2500Base-X, 1000Base-X and Cisco SGMII interface modes.
Implement support for configuring for the new paths to SerDes interfaces and the internal 2.5G PHY.
Add USXGMII PCS driver for 10GBase-R, 5GBase-R and USXGMII mode, and setup the new PHYA on MT7988 to access the also still existing old LynxI PCS for 1000Base-X, 2500Base-X and Cisco SGMII PCS interface modes.
--- drivers/net/ethernet/mediatek/Kconfig | 16 + drivers/net/ethernet/mediatek/Makefile | 1 + drivers/net/ethernet/mediatek/mtk_eth_path.c | 123 +++- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 182 ++++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 237 ++++++- drivers/net/ethernet/mediatek/mtk_usxgmii.c | 698 +++++++++++++++++++ 6 files changed, 1226 insertions(+), 31 deletions(-) create mode 100644 drivers/net/ethernet/mediatek/mtk_usxgmii.c
drivers/net/ethernet/mediatek/Kconfig +16 -0
@@ -25,6 +25,22 @@ config NET_MEDIATEK_SOC This driver supports the gigabit ethernet MACs in the MediaTek SoC family. +config NET_MEDIATEK_SOC_USXGMII + bool "Support USXGMII SerDes on MT7988" + depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST + def_bool NET_MEDIATEK_SOC != n + help + Include support for 10GE SerDes which can be found on MT7988. + If this kernel should run on SoCs with 10 GBit/s Ethernet you + will need to select this option to use GMAC2 and GMAC3 with + external PHYs, SFP(+) cages in 10GBase-R, 5GBase-R or USXGMII + interface modes. + + Note that as the 2500Base-X/1000Base-X/Cisco SGMII SerDes PCS + unit (MediaTek LynxI) in MT7988 is connected via the new 10GE + SerDes, you will also need to select this option in case you + want to use any of those SerDes modes. + config NET_MEDIATEK_STAR_EMAC tristate "MediaTek STAR Ethernet MAC support" select PHYLIB
drivers/net/ethernet/mediatek/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o mtk_eth-y := mtk_eth_soc.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_USXGMII) += mtk_usxgmii.o mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o mtk_wed_wo.o ifdef CONFIG_DEBUG_FS mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o
drivers/net/ethernet/mediatek/mtk_eth_path.c +118 -4
172 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_eth_soc.c +158 -24
255 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_eth_soc.h +235 -2
379 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_usxgmii.c new file +698 -0
698 lines not on this page · raw message
Signature · 1 line
2.42.0