Add support for PIC64-HPSC/HX MDIO controller
Subsystems (5)
Charles Perry
maintainerv5 cover Add support for PIC64-HPSC/HX MDIO controller
Hello,
This series adds a driver for the two MDIO controllers of PIC64-HPSC/HX. The hardware supports C22 and C45 but only C22 is implemented for now.
This MDIO hardware is based on a Microsemi design supported in Linux by mdio-mscc-miim.c. However, The register interface is completely different with pic64hpsc, hence the need for a separate driver.
The documentation recommends an input clock of 156.25MHz and a prescaler of 39, which yields an MDIO clock of 1.95MHz.
This was tested on Microchip HB1301 evalkit which has a VSC8574 and a VSC8541. I've tested with bus frequencies of 0.6, 1.95 and 2.5 MHz.
This series also adds a PHY write barrier when disabling PHY interrupts as discussed in [1].
Thanks,
Charles
[1]: https://lore.kernel.org/all/[email protected]/
Changes in v5:
- 1/3: Collect Conor's Acked-by
- 1/3: Remove the "|" in "description: |" (Rob)
- 1/3: Don't mention how many instances of the MDIO controller there are
(Rob)
- 1/3: Hex addresses are now in lowercase (Rob)
- 1/3: Drop the phy DT label in the example (Rob)
- 3/3: Support MDIO controllers that only support C45 (Russell, Andrew)
Changes in v4:
- 2/3: return FIELD_GET() directly instead of using "ret" (Russell)
- 3/3: Add the PHY barrier patch (Russell, Andrew)
Changes in v3:
- 2/2: Add a MAINTAINERS entry (Jakub)
Changes in v2:
- 1/2: Make "clocks" and "interrupts" required (Andrew)
- 1/2: Add a default value to "clock-frequency" (Andrew)
- 2/2: Remove #define for unused registers (Maxime)
- 2/2: Add "c22" to clause 22 read/write ops (Maxime)
- 2/2: Remove the call to platform_set_drvdata() (Andrew)
- 2/2: Make the clock mandatory (Andrew)
- 2/2: Use 2.5MHz if no clock-frequency was specified (Andrew)
- 2/2: Change the error message for bad clock-frequency (Andrew)
- 2/2: Fix a use without initialization on bus_freq (Andrew)
Charles Perry (3):
dt-bindings: net: document Microchip PIC64-HPSC/HX MDIO controller
net: mdio: add a driver for PIC64-HPSC/HX MDIO controller
net: phy: add a PHY write barrier when disabling interrupts
.../net/microchip,pic64hpsc-mdio.yaml | 68 +++++++ MAINTAINERS | 6 + drivers/net/mdio/Kconfig | 7 + drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mdio-pic64hpsc.c | 190 ++++++++++++++++++ drivers/net/phy/phy.c | 25 ++- 6 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/net/microchip,pic64hpsc-mdio.yaml create mode 100644 drivers/net/mdio/mdio-pic64hpsc.c
Signature · 1 line
2.47.3
Charles Perry
maintainerPATCH v5 1/3 dt-bindings: net: document Microchip PIC64-HPSC/HX MDIO controller
This MDIO hardware is based on a Microsemi design supported in Linux by mdio-mscc-miim.c. However, The register interface is completely different with pic64hpsc, hence the need for separate documentation.
The hardware supports C22 and C45.
The documentation recommends an input clock of 156.25MHz and a prescaler of 39, which yields an MDIO clock of 1.95MHz.
The hardware supports an interrupt pin to signal transaction completion which is not strictly needed as the software can also poll a "TRIGGER" bit for this.
---
Notes:
Changes in v5:
- Collect Conor's Acked-by
- Remove the "|" in "description: |" (Rob)
- Don't mention how many instances of the MDIO controller there are (Rob)
- Hex addresses are now in lowercase (Rob)
- Drop the phy DT label in the example (Rob)
Changes in v4: none
Changes in v3: none
Changes in v2:
- Make "clocks" and "interrupts" required (Andrew)
- Add a default value to "clock-frequency" (Andrew)
Changes in v5: none
Changes in v4: none
Changes in v3: none
Changes in v2:
- Make "clocks" and "interrupts" required (Andrew)
- Add a default value to "clock-frequency" (Andrew)
.../net/microchip,pic64hpsc-mdio.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/microchip,pic64hpsc-mdio.yaml
Documentation/devicetree/bindings/net/microchip,pic64hpsc-mdio.yaml new file +68 -0
@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/microchip,pic64hpsc-mdio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip PIC64-HPSC/HX MDIO controller + +maintainers: + - Charles Perry <[email protected]> + +description: + This is the MDIO bus controller present in Microchip PIC64-HPSC/HX SoCs. It + supports C22 and C45 register access and is named "MDIO Initiator" in the + documentation. + +allOf: + - $ref: mdio.yaml# + +properties: + compatible: + oneOf: + - const: microchip,pic64hpsc-mdio + - items: + - const: microchip,pic64hx-mdio + - const: microchip,pic64hpsc-mdio + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-frequency: + default: 2500000 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - clocks + - interrupts + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + bus { + #address-cells = <2>; + #size-cells = <2>; + + mdio@4000c21e000 { + compatible = "microchip,pic64hpsc-mdio"; + reg = <0x400 0x0c21e000 0x0 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&svc_clk>; + interrupt-parent = <&saplic0>; + interrupts = <168 IRQ_TYPE_LEVEL_HIGH>; + + ethernet-phy@0 { + reg = <0>; + }; + }; + };
Signature · 1 line
2.47.3
Charles Perry
maintainerPATCH v5 2/3 net: mdio: add a driver for PIC64-HPSC/HX MDIO controller
In reply to Charles PerryThis adds an MDIO driver for PIC64-HPSC/HX. The hardware supports C22 and C45 but only C22 is implemented in this commit.
This MDIO hardware is based on a Microsemi design supported in Linux by mdio-mscc-miim.c. However, The register interface is completely different with pic64hpsc, hence the need for a separate driver.
The documentation recommends an input clock of 156.25MHz and a prescaler of 39, which yields an MDIO clock of 1.95MHz.
The hardware supports an interrupt pin or a "TRIGGER" bit that can be polled to signal transaction completion. This commit uses polling.
This was tested on Microchip HB1301 evalkit with a VSC8574 and a VSC8541.
---
Notes:
Changes in v5: none
Changes in v4:
- read: return FIELD_GET() directly instead of using "ret" (Russell)
Changes in v3:
- Add a MAINTAINERS entry (Jakub)
Changes in v2:
- Remove #define for unused registers (Maxime)
- Add "c22" to clause 22 read/write ops (Maxime)
- Remove the call to platform_set_drvdata() (Andrew)
- Make the clock mandatory (Andrew)
- Use 2.5MHz if no clock-frequency was specified (Andrew)
- Change the error message for bad clock-frequency (Andrew)
- Fix a use without initialization on bus_freq (Andrew)
MAINTAINERS | 6 + drivers/net/mdio/Kconfig | 7 ++ drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mdio-pic64hpsc.c | 190 ++++++++++++++++++++++++++++++ 4 files changed, 204 insertions(+) create mode 100644 drivers/net/mdio/mdio-pic64hpsc.c
MAINTAINERS +6 -0
@@ -17216,6 +17216,12 @@ L: [email protected] S: Maintained F: drivers/tty/serial/8250/8250_pci1xxxx.c +MICROCHIP PIC64-HPSC/HX DRIVERS +M: Charles Perry <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/net/microchip,pic64hpsc-mdio.yaml +F: drivers/net/mdio/mdio-pic64hpsc.c + MICROCHIP POLARFIRE FPGA DRIVERS M: Conor Dooley <[email protected]> L: [email protected]
drivers/net/mdio/Kconfig +7 -0
@@ -146,6 +146,13 @@ config MDIO_OCTEON buses. It is required by the Octeon and ThunderX ethernet device drivers on some systems. +config MDIO_PIC64HPSC + tristate "PIC64-HPSC/HX MDIO interface support" + depends on HAS_IOMEM && OF_MDIO + help + This driver supports the MDIO interface found on the PIC64-HPSC/HX + SoCs. + config MDIO_IPQ4019 tristate "Qualcomm IPQ4019 MDIO interface support" depends on HAS_IOMEM && OF_MDIO
drivers/net/mdio/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_MDIO_MOXART) += mdio-moxart.o obj-$(CONFIG_MDIO_MSCC_MIIM) += mdio-mscc-miim.o obj-$(CONFIG_MDIO_MVUSB) += mdio-mvusb.o obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o +obj-$(CONFIG_MDIO_PIC64HPSC) += mdio-pic64hpsc.o obj-$(CONFIG_MDIO_REALTEK_RTL9300) += mdio-realtek-rtl9300.o obj-$(CONFIG_MDIO_REGMAP) += mdio-regmap.o obj-$(CONFIG_MDIO_SUN4I) += mdio-sun4i.o
drivers/net/mdio/mdio-pic64hpsc.c new file +190 -0
190 lines not on this page · raw message
Signature · 1 line
2.47.3
Charles Perry
maintainerPATCH v5 3/3 net: phy: add a PHY write barrier when disabling interrupts
In reply to Charles PerryMDIO bus controllers are not required to wait for write transactions to complete before returning as synchronization is often achieved by polling status bits.
This can cause issues when disabling interrupts since an interrupt could fire before the interrupt handler is unregistered and there's no status bit to poll.
Add a phy_write_barrier() function and use it in phy_disable_interrupts() to fix this issue. The write barrier just reads an MII register and discards the value, which is enough to guarantee that previous writes have completed.
---
Notes:
Changes in v5:
- Support the case where the MDIO controller only supports C45 (Russell, Andrew)
- Make the return type of phy_write_barrier() void
Changes in v4:
- Add this patch (Russell, Andrew)
drivers/net/phy/phy.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/net/phy/phy.c +24 -1
@@ -1368,14 +1368,37 @@ void phy_error(struct phy_device *phydev) }EXPORT_SYMBOL (phy_error); +/** +* phy_write_barrier - ensure the last write completed for this PHY device +* @phydev: target phy_device struct +* +* MDIO bus controllers are not required to wait for write transactions to +* complete before returning. Calling this function ensures that the previous +* write has completed. +*/ +static void phy_write_barrier (struct phy_device *phydev) +{ +if (mdiobus_read (phydev->mdio.bus, phydev->mdio.addr,MII_PHYSID1 ) == + -EOPNOTSUPP ) +mdiobus_c45_read (phydev->mdio.bus, phydev->mdio.addr, +MDIO_MMD_PMAPMD ,MII_PHYSID1 ); +} +/** * phy_disable_interrupts - Disable the PHY interrupts from the PHY side * @phydev: target phy_device struct */ int phy_disable_interrupts (struct phy_device *phydev) { +int err; +/* Disable PHY interrupts */ -return phy_config_interrupt (phydev,PHY_INTERRUPT_DISABLED ); + err =phy_config_interrupt (phydev,PHY_INTERRUPT_DISABLED ); +if (err) +return err; + +phy_write_barrier (phydev); +return 0 ; }/**
Signature · 1 line
2.47.3
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 8 Apr 2026 06:18:13 -0700 you wrote:
Hello,
This series adds a driver for the two MDIO controllers of PIC64-HPSC/HX. The hardware supports C22 and C45 but only C22 is implemented for now.
This MDIO hardware is based on a Microsemi design supported in Linux by
mdio-mscc-miim.c. However, The register interface is completely different with pic64hpsc, hence the need for a separate driver.[...]
Here is the summary with links:
- [net-next,v5,1/3] dt-bindings: net: document Microchip PIC64-HPSC/HX MDIO controller
https://git.kernel.org/netdev/net-next/c/268bb35d1a34 - [net-next,v5,2/3] net: mdio: add a driver for PIC64-HPSC/HX MDIO controller https://git.kernel.org/netdev/net-next/c/f76aef980206 - [net-next,v5,3/3] net: phy: add a PHY write barrier when disabling interrupts https://git.kernel.org/netdev/net-next/c/96aefe3afe0e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html