Skip to contentSkip to conversation

Add Cortina Systems CS7542 MDIO controller support

PATCH In review Fil Dunsky 2 participants 5 messages Nov 27 – Nov 28

Subsystems (4)
lore
Share & tools
lore

Fil Dunsky

author
#0 lore raw

v4 cover Add Cortina Systems CS7542 MDIO controller support

Add the CS7542 Clause 22 MDIO controller with bounded, sleepable polling. The driver is independent of the pending platform series and COMPILE_TEST. It retains the firmware MDC prescaler while enabling software-initiated transactions.

This revision acquires and enables the APB input required by the binding before the first register access. The managed clock remains enabled until the managed MDIO bus is unregistered. Clock lookup or enable failures, including probe deferral, return before touching registers. No clock-rate or MDC-divisor programming is added.

The APB source was established previously on Almond+ by changing APB from 150 to 100 MHz while AXI stayed at 150 MHz and comparing MDIO transaction timing. The binding describes that source and allows clock-frequency from mdio.yaml; the exact prescaler divisor encoding remains unestablished.

Validation for v4:
- The actual probe passes 10 allocation, map, clock, registration and cleanup-order cases with GCC/Clang ASan/UBSan. The pre-fix probe reproduces an MMIO access without an enabled clock under the same helpers.
- Native ARM driver=y object and exact Linux 6.18 driver=m module compile with W=1 and KCFLAGS=-Werror; existing configurations are unchanged.
- A read-only consumer probe on the running Almond+ obtained and enabled cs7542-apb at 150 MHz. MDIO CFG stayed 00200001; all references were dropped, the same OpenWrt boot continued and its watchdog/settings were preserved. This exercises the consumer/provider path, not a full live bus reprobe.

Earlier v2/v3 full independent builds, binding checks and RAM PHY read/write results remain recorded. The transaction logic and firmware prescaler are unchanged here; the old hardware matrix was not repeated.

---
Changes in v4:
- Enable the required APB input before accessing MDIO registers and keep it enabled through bus teardown.
- Clarify MANUAL transaction selection and preservation of the firmware
MDC prescaler.
- Link to v3: https://lore.kernel.org/all/[email protected]/

Changes in v3:
- Use sleepable polling in the MDIO bus callbacks.
- Describe the experimentally established APB input and allow the inherited optional clock-frequency property.
- Remove the unused private mii_bus pointer.
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Drop pending-frame state after Andrew Lunn's review.
- Sort Kconfig/Makefile entries and retain Andrew's Reviewed-by on the MAINTAINERS patch only.
- Link to v1: https://lore.kernel.org/all/[email protected]/

To: Fil Dunsky <[email protected]>
To: Andrew Lunn <[email protected]>
To: "David S. Miller" <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Andrew Lunn <[email protected]>
To: Heiner Kallweit <[email protected]>
To: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Fil Dunsky (3):
dt-bindings: net: Add Cortina CS7542 MDIO controller
net: mdio: Add Cortina CS7542 bus controller
MAINTAINERS: Add Cortina CS7542 MDIO controller entry

 .../bindings/net/cortina,cs7542-mdio.yaml          |  52 +++++++++
 MAINTAINERS                                        |   7 ++
 drivers/net/mdio/Kconfig                           |  12 ++
 drivers/net/mdio/Makefile                          |   1 +
 drivers/net/mdio/mdio-cs75xx.c                     | 126 +++++++++++++++++++++
 5 files changed, 198 insertions(+)

---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261123-b4-cs7542-mdio-ec44e757e824

Best regards,

Signature · 1 line
Fil Dunsky <[email protected]>
author
#1 lore raw

PATCH v4 1/3 dt-bindings: net: Add Cortina CS7542 MDIO controller

Describe the Clause 22 controller, its MDC prescaler and the devices on its management bus.

---
 .../bindings/net/cortina,cs7542-mdio.yaml          | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
Documentation/devicetree/bindings/net/cortina,cs7542-mdio.yaml new file +52 -0
new file mode 100644
index 000000000..66b5199c7
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/cortina,cs7542-mdio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cortina Systems CS7542 MDIO controller
+
+maintainers:
+  - Fil Dunsky <[email protected]>
+
+description:
+  Clause 22 MDIO controller with a programmable 16-bit MDC prescaler.
+
+allOf:
+  - $ref: mdio.yaml#
+
+properties:
+  compatible:
+    const: cortina,cs7542-mdio
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+    description: APB input clock
+
+  suppress-preamble: false
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - "#address-cells"
+  - "#size-cells"
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    mdio@f00700a0 {
+        compatible = "cortina,cs7542-mdio";
+        reg = <0xf00700a0 0x14>;
+        clocks = <&apb_clk>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ethernet-phy@0 {
+            reg = <0>;
+        };
+    };
Signature · 1 line
2.53.0
author
#2 lore raw

PATCH v4 2/3 net: mdio: Add Cortina CS7542 bus controller

In reply to Fil Dunsky

Support Clause 22 reads and writes through the CS7542 management interface. Retain the firmware-configured prescaler and unrelated configuration bits while enabling manual operation.

Use sleepable polling for the bounded wait in the MDIO bus callbacks. Report timeout errors directly without tracking a pending transaction. Use managed bus allocation and registration to cover probe failures and removal.

Acquire and enable the required APB input before accessing registers, and retain it for the lifetime of the registered bus. Managed bus teardown runs before the managed clock is disabled. The firmware MDC prescaler is preserved; no clock-rate or divisor programming is introduced.

---
 drivers/net/mdio/Kconfig       |  12 ++++
 drivers/net/mdio/Makefile      |   1 +
 drivers/net/mdio/mdio-cs75xx.c | 126 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 139 insertions(+)
drivers/net/mdio/Kconfig +12 -0
index d44278f26..6714c68ca 100644
@@ -87,6 +87,18 @@ config MDIO_BCM_UNIMAC
 config MDIO_CAVIUM
 	tristate
 
+config MDIO_CS75XX
+	tristate "Cortina Systems CS7542 MDIO controller"
+	depends on OF_MDIO && HAS_IOMEM
+	help
+	  Support Clause 22 PHY register access through the CS7542 MDIO
+	  controller, retaining the prescaler configured by platform firmware.
+	  Transactions use bounded polling.
+	  Device Tree describes the PHYs sharing this management bus.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called mdio-cs75xx.
+
 config MDIO_GPIO
 	tristate "GPIO lib-based bitbanged MDIO buses"
 	depends on MDIO_BITBANG
drivers/net/mdio/Makefile +1 -0
index 048586746..f0880c9f1 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_MDIO_BCM_IPROC)		+= mdio-bcm-iproc.o
 obj-$(CONFIG_MDIO_BCM_UNIMAC)		+= mdio-bcm-unimac.o
 obj-$(CONFIG_MDIO_BITBANG)		+= mdio-bitbang.o
 obj-$(CONFIG_MDIO_CAVIUM)		+= mdio-cavium.o
+obj-$(CONFIG_MDIO_CS75XX)		+= mdio-cs75xx.o
 obj-$(CONFIG_MDIO_GPIO)			+= mdio-gpio.o
 obj-$(CONFIG_MDIO_HISI_FEMAC)		+= mdio-hisi-femac.o
 obj-$(CONFIG_MDIO_I2C)			+= mdio-i2c.o
drivers/net/mdio/mdio-cs75xx.c new file +126 -0

126 lines not on this page · raw message

Signature · 1 line
2.53.0
maintainer Reviewed-by on v4 2/3
#3 lore raw

Re: [PATCH net-next v4 2/3] net: mdio: Add Cortina CS7542 bus controller

Quoted 11 lines · On Fri, Nov 27, 2026 at 01:14:23PM +0300, Fil Dunsky via B4 Relay wrote:

From: Fil Dunsky <[email protected]>

Support Clause 22 reads and writes through the CS7542 management interface. Retain the firmware-configured prescaler and unrelated configuration bits while enabling manual operation.

Use sleepable polling for the bounded wait in the MDIO bus callbacks. Report timeout errors directly without tracking a pending transaction. Use managed bus allocation and registration to cover probe failures and removal.

Quoted 6 lines

Acquire and enable the required APB input before accessing registers, and retain it for the lifetime of the registered bus. Managed bus teardown runs before the managed clock is disabled. The firmware MDC prescaler is preserved; no clock-rate or divisor programming is introduced.

Andrew

author
#4 lore raw

PATCH v4 3/3 MAINTAINERS: Add Cortina CS7542 MDIO controller entry

In reply to Fil Dunsky

List the binding and driver under the author maintaining the Almond+ platform support, together with the appropriate subsystem mailing list.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 44540a1eb..312d3b4af 100644
@@ -6918,6 +6918,13 @@ S:	Maintained
 F:	Documentation/hwmon/corsair-psu.rst
 F:	drivers/hwmon/corsair-psu.c
 
+CORTINA SYSTEMS CS7542 MDIO CONTROLLER
+M:	Fil Dunsky <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/net/cortina,cs7542-mdio.yaml
+F:	drivers/net/mdio/mdio-cs75xx.c
+
 COUNTER SUBSYSTEM
 M:	William Breathitt Gray <[email protected]>
 L:	[email protected]
Signature · 1 line
2.53.0