net: mdio: Add BCM6368 MDIO mux bus controller
Subsystems (4)
cover net: mdio: Add BCM6368 MDIO mux bus controller
This controller is present on BCM6318, BCM6328, BCM6362, BCM6368 and BCM63268 SoCs.
Álvaro Fernández Rojas (2):
dt-bindings: net: Add bcm6368-mdio-mux bindings
net: mdio: Add BCM6368 MDIO mux bus controller
.../bindings/net/brcm,bcm6368-mdio-mux.yaml | 79 ++++++++ drivers/net/mdio/Kconfig | 11 ++ drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mdio-mux-bcm6368.c | 179 ++++++++++++++++++ 4 files changed, 270 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/brcm,bcm6368-mdio-mux.yaml create mode 100644 drivers/net/mdio/mdio-mux-bcm6368.c
Signature · 1 line
2.20.1
PATCH 1/2 dt-bindings: net: Add bcm6368-mdio-mux bindings
Add documentations for bcm6368 mdio mux driver.
--- .../bindings/net/brcm,bcm6368-mdio-mux.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/brcm,bcm6368-mdio-mux.yaml
Documentation/devicetree/bindings/net/brcm,bcm6368-mdio-mux.yaml new file +79 -0
@@ -0,0 +1,79 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/brcm,bcm6368-mdio-mux.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom BCM6368 MDIO bus multiplexer + +maintainers: + - Álvaro Fernández Rojas <[email protected]> + +description: + This MDIO bus multiplexer defines buses that could be internal as well as + external to SoCs. When child bus is selected, one needs to select these two + properties as well to generate desired MDIO transaction on appropriate bus. + +allOf: + - $ref: "mdio.yaml#" + +properties: + compatible: + const: brcm,bcm6368-mdio-mux + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + +required: + - compatible + - reg + +patternProperties: + '^mdio@[0-1]$': + type: object + properties: + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + required: + - reg + - "#address-cells" + - "#size-cells" + +unevaluatedProperties: false + +examples: + - | + mdio0: mdio@10e000b0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "brcm,bcm6368-mdio-mux"; + reg = <0x10e000b0 0x6>; + + mdio_int: mdio@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + + mdio_ext: mdio@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + };
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRe: [PATCH 1/2] dt-bindings: net: Add bcm6368-mdio-mux bindings
Review
Quoted 2 lines · Álvaro Fernández Rojas
(quoted diff) +2
-0+ clocks: + maxItems: 1
Hi Álvaro
The driver does not make use of this clocks property. Is it really needed?
Andrew
Re: [PATCH 1/2] dt-bindings: net: Add bcm6368-mdio-mux bindings
Hi Andrew,
Quoted 10 lines · Andrew Lunn
Review
Quoted 2 lines · Álvaro Fernández Rojas
(quoted diff) +2
-0+ clocks: + maxItems: 1Hi Álvaro
The driver does not make use of this clocks property. Is it really needed?
Nice catch, this was copy & pasted from other driver. I will remove it on v2.
Quoted 2 lines
Andrew
Best regards,
Álvaro.
PATCH 2/2 net: mdio: Add BCM6368 MDIO mux bus controller
In reply to Álvaro Fernández RojasThis controller is present on BCM6318, BCM6328, BCM6362, BCM6368 and BCM63268 SoCs.
--- drivers/net/mdio/Kconfig | 11 ++ drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mdio-mux-bcm6368.c | 179 ++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 drivers/net/mdio/mdio-mux-bcm6368.c
drivers/net/mdio/Kconfig +11 -0
@@ -200,6 +200,17 @@ config MDIO_BUS_MUX_MESON_G12A the amlogic g12a SoC. The multiplexers connects either the external or the internal MDIO bus to the parent bus. +config MDIO_BUS_MUX_BCM6368 + tristate "Broadcom BCM6368 MDIO bus multiplexers" + depends on OF && OF_MDIO && (BMIPS_GENERIC || COMPILE_TEST) + select MDIO_BUS_MUX + default BMIPS_GENERIC + help + This module provides a driver for MDIO bus multiplexers found in + BCM6368 based Broadcom SoCs. This multiplexer connects one of several + child MDIO bus to a parent bus. Buses could be internal as well as + external and selection logic lies inside the same multiplexer. + config MDIO_BUS_MUX_BCM_IPROC tristate "Broadcom iProc based MDIO bus multiplexers" depends on OF && OF_MDIO && (ARCH_BCM_IPROC || COMPILE_TEST)
drivers/net/mdio/Makefile +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_MDIO_THUNDER) += mdio-thunder.o obj-$(CONFIG_MDIO_XGENE) += mdio-xgene.o obj-$(CONFIG_MDIO_BUS_MUX) += mdio-mux.o +obj-$(CONFIG_MDIO_BUS_MUX_BCM6368) += mdio-mux-bcm6368.o obj-$(CONFIG_MDIO_BUS_MUX_BCM_IPROC) += mdio-mux-bcm-iproc.o obj-$(CONFIG_MDIO_BUS_MUX_GPIO) += mdio-mux-gpio.o obj-$(CONFIG_MDIO_BUS_MUX_MESON_G12A) += mdio-mux-meson-g12a.o
drivers/net/mdio/mdio-mux-bcm6368.c new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
2.20.1
Jakub Kicinski
maintainerQuoted 4 lines · On Mon, 8 Mar 2021 19:41:02 +0100 Álvaro Fernández Rojas wrote:
This controller is present on BCM6318, BCM6328, BCM6362, BCM6368 and BCM63268 SoCs.
Signed-off-by Álvaro Fernández Rojas <[email protected]>
make[2]: *** Deleting file 'Module.symvers'
ERROR: modpost: missing MODULE_LICENSE() in drivers/net/mdio/mdio-mux-bcm6368.o make[2]: *** [Module.symvers] Error 1
make[1]: *** [modules] Error 2
make: *** [__sub-make] Error 2
make[2]: *** Deleting file 'Module.symvers'
Hi Jakub,
Quoted 6 lines · Jakub Kicinski
Quoted 3 lines · On Mon, 8 Mar 2021 19:41:02 +0100 Álvaro Fernández Rojas wrote:
This controller is present on BCM6318, BCM6328, BCM6362, BCM6368 and BCM63268 SoCs.
Quoted 8 lines
Quoted 1 line
Signed-off-by Álvaro Fernández Rojas <[email protected]>make[2]: *** Deleting file 'Module.symvers'
ERROR: modpost: missingMODULE_LICENSE()indrivers/net/mdio/mdio-mux-bcm6368.omake[2]: *** [Module.symvers] Error 1
make[1]: *** [modules] Error 2
make: *** [__sub-make] Error 2
make[2]: *** Deleting file 'Module.symvers’
Ok, I’ll add the following in v2:MODULE_AUTHOR("Álvaro Fernández Rojas <[email protected]>"); MODULE_DESCRIPTION("BCM6368 mdiomux bus controller driver"); MODULE_LICENSE("GPL v2");
Andrew Lunn
maintainerQuoted 36 lines
drivers/net/mdio/mdio-mux-bcm6368.c new file +36
-0+static int bcm6368_mdiomux_probe (struct platform_device *pdev) +{ +struct bcm6368_mdiomux_desc *md; +struct mii_bus *bus; +struct resource *res; +int rc; + + md =devm_kzalloc (&pdev->dev,sizeof (*md),GFP_KERNEL ); +if (!md) +return -ENOMEM ; + md->dev = &pdev->dev; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -EINVAL ; + +/* Just ioremap, as this MDIO block is usually integrated into an +* Ethernet MAC controller register range +*/ + md->base =devm_ioremap (&pdev->dev, res->start,resource_size (res)); +if (!md->base) { +dev_err (&pdev->dev,"failed to ioremap register\n" ); +return -ENOMEM ; + } + + md->mii_bus =devm_mdiobus_alloc (&pdev->dev); +if (!md->mii_bus) { +dev_err (&pdev->dev,"mdiomux bus alloc failed\n" ); +return ENOMEM ; + } + + bus = md->mii_bus; + bus->priv = md; + bus->name ="BCM6368 MDIO mux bus" ; +snprintf (bus->id,MII_BUS_ID_SIZE ,"%s-%d" , pdev->name, pdev->id); + bus->parent = &pdev->dev;
drivers/net/mdio/mdio-mux-bcm6368.c line 134
Quoted 10 lines
drivers/net/mdio/mdio-mux-bcm6368.c new file +10
-0+ bus->read = bcm6368_mdiomux_read; + bus->write = bcm6368_mdiomux_write; + bus->phy_mask =0x3f ; + bus->dev.of_node = pdev->dev.of_node; + + rc =mdiobus_register (bus); +if (rc) { +dev_err (&pdev->dev,"mdiomux registration failed\n" ); +return rc; + }
So this is different to all the other mux drivers. Normally there is an MDIO driver. And there is a mux driver. Two separate drivers. The mux driver uses a phandle to reference the MDIO driver. Here we have both in one driver.
Does this MDIO bus device exist as a standalone device? Without the mux? If silicon does exist like that, having two separate drivers would be better.
Andrew
Hi Andrew,
Quoted 54 lines · Andrew Lunn
Quoted 37 lines
drivers/net/mdio/mdio-mux-bcm6368.c new file +36
-0+static int bcm6368_mdiomux_probe (struct platform_device *pdev) +{ +struct bcm6368_mdiomux_desc *md; +struct mii_bus *bus; +struct resource *res; +int rc; + + md =devm_kzalloc (&pdev->dev,sizeof (*md),GFP_KERNEL ); +if (!md) +return -ENOMEM ; + md->dev = &pdev->dev; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -EINVAL ; + +/* Just ioremap, as this MDIO block is usually integrated into an +* Ethernet MAC controller register range +*/ + md->base =devm_ioremap (&pdev->dev, res->start,resource_size (res)); +if (!md->base) { +dev_err (&pdev->dev,"failed to ioremap register\n" ); +return -ENOMEM ; + } + + md->mii_bus =devm_mdiobus_alloc (&pdev->dev); +if (!md->mii_bus) { +dev_err (&pdev->dev,"mdiomux bus alloc failed\n" ); +return ENOMEM ; + } + + bus = md->mii_bus; + bus->priv = md; + bus->name ="BCM6368 MDIO mux bus" ; +snprintf (bus->id,MII_BUS_ID_SIZE ,"%s-%d" , pdev->name, pdev->id); + bus->parent = &pdev->dev;drivers/net/mdio/mdio-mux-bcm6368.c line 134
Quoted 10 lines
drivers/net/mdio/mdio-mux-bcm6368.c new file +10
-0+ bus->read = bcm6368_mdiomux_read; + bus->write = bcm6368_mdiomux_write; + bus->phy_mask =0x3f ; + bus->dev.of_node = pdev->dev.of_node; + + rc =mdiobus_register (bus); +if (rc) { +dev_err (&pdev->dev,"mdiomux registration failed\n" ); +return rc; + }So this is different to all the other mux drivers. Normally there is an MDIO driver. And there is a mux driver. Two separate drivers. The mux driver uses a phandle to reference the MDIO driver. Here we have both in one driver.
Quoted 3 lines
Does this MDIO bus device exist as a standalone device? Without the mux? If silicon does exist like that, having two separate drivers would be better.
BCM6368 (and newer) SoCs have an integrated ethernet switch controller with dedicated internal phys, but it also supports connecting to external phys not integrated in the internal switch.
Ports 0-3 are internal, ports 4-7 are external and can be connected to external switches or phys and port 8 is the CPU.
This MDIO bus device is integrated in the BCM63xx switch registers, which corresponds to the same registers present in drivers/net/dsa/b53/b53_regs.h.
As you can see in the source code, registers are the same for the internal and external bus. The only difference is that if MDIOC_EXT_MASK (bit 16) is set, the MDIO bus accessed will be the external, and on the contrary, if bit 16 isn’t set, the MDIO bus accessed will be the internal one.
I don’t know if this answers your question, but I think that adding it as mdiomux is the way to go.
Quoted 2 lines
Andrew
Best regards,
Álvaro.
Andrew Lunn
maintainerQuoted 6 lines
BCM6368 (and newer) SoCs have an integrated ethernet switch controller with dedicated internal phys, but it also supports connecting to external phys not integrated in the internal switch.
Ports 0-3 are internal, ports 4-7 are external and can be connected to external switches or phys and port 8 is the CPU.
This MDIO bus device is integrated in the BCM63xx switch registers, which corresponds to the same registers present indrivers/net/dsa/b53/b53_regs.h.
As you can see in the source code, registers are the same for the internal and external bus. The only difference is that ifMDIOC_EXT_MASK(bit 16) is set, the MDIO bus accessed will be the external, and on the contrary, if bit 16 isn’t set, the MDIO bus accessed will be the internal one.I don’t know if this answers your question, but I think that adding it as mdiomux is the way to go.
Hi Álvaro
The Marvell mv88e6390 family of switches has a very similar setup. An internal and an external MDIO bus, one bit difference in a register. When i wrote the code for that, i decided it was not a mux as such, but two MDIO busses. So i register two MDIO busses, and rely on a higher level switch register mutex to prevent parallel operations on the two busses.
The reason i decided it was not a mux, is that all the other mux drivers are separate drivers which rely on another MDIO bus driver. The mux driver gets a handle to the underlying MDIO bus driver, and and builds on it. Here you have it all combined in one, so it does not follow the pattern.
So if you want to use a max, please break this up into an MDIO driver, and a mux driver. Or have one driver which registers two mdio busses, no mux.
Andrew
Quoted 22 lines · Andrew Lunn
Quoted 6 lines
BCM6368 (and newer) SoCs have an integrated ethernet switch controller with dedicated internal phys, but it also supports connecting to external phys not integrated in the internal switch.
Ports 0-3 are internal, ports 4-7 are external and can be connected to external switches or phys and port 8 is the CPU.
This MDIO bus device is integrated in the BCM63xx switch registers, which corresponds to the same registers present indrivers/net/dsa/b53/b53_regs.h.
As you can see in the source code, registers are the same for the internal and external bus. The only difference is that ifMDIOC_EXT_MASK(bit 16) is set, the MDIO bus accessed will be the external, and on the contrary, if bit 16 isn’t set, the MDIO bus accessed will be the internal one.I don’t know if this answers your question, but I think that adding it as mdiomux is the way to go.
Hi Álvaro
The Marvell mv88e6390 family of switches has a very similar setup. An internal and an external MDIO bus, one bit difference in a register. When i wrote the code for that, i decided it was not a mux as such, but two MDIO busses. So i register two MDIO busses, and rely on a higher level switch register mutex to prevent parallel operations on the two busses.
The reason i decided it was not a mux, is that all the other mux drivers are separate drivers which rely on another MDIO bus driver. The mux driver gets a handle to the underlying MDIO bus driver, and and builds on it. Here you have it all combined in one, so it does not follow the pattern.
Quoted 3 lines
So if you want to use a max, please break this up into an MDIO driver, and a mux driver. Or have one driver which registers two mdio busses, no mux.
Also, if you were to support some dynamic power management in the future, it may be desirable to have the switch drivers and the MDIO mux controller be within the same driver, so you are in complete control of when the resources are needed and you can fully clock gate everything.
Signature · 1 line
Florian