Skip to contentSkip to conversation

Add Shared MDIO framework for iProc based SoCs

PATCH In review Pramod Kumar 7 participants 27 messages Apr 21, 2016 – Apr 27, 2016

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover Add Shared MDIO framework for iProc based SoCs

Broadcom iProc based SoCs uses MDIO bus for programming PHYs belonging to different I/O subsystem like USB, SATA, PCIe, ETHERNET etc. Every subsystem is referred as "Master" When a master is selected, all PHYs belonging to this subsystem get active on the MDIO bus and responds to MDIO transaction. In this way one MDIO controller is shared among all masters hence named as "Shared MDIO controller".

We have two important entities in "Shared MDIO Bus" framework:
1) shared_mdio_master and
2) shared_mdio_driver.

The shared MDIO controller driver is registered as platform driver and it creates shared_mdio_master instances and adds them to "Shared MDIO Bus" framework. The "Shared MDIO Bus" framework will try to match-n-probe each shared_mdio_master instance with all available shared_mdio_driver based on DT matching. The shared_mdio_driver will acts as phy provider for respective PHY frameworks and it will access PHY registers only using "Shared MDIO Bus" framework APIs. All PHY read/write from shared_mdio_driver will eventually reach shared MDIO controller driver (who originally created shared_mdio_master instances) and shared MDIO controller driver will serialized these PHY read/write as required.

This patch set includes Shared MDIO Bus framework, Shared MDIO block driver and one Shared MDIO driver, ETHERNET PHY provider driver.

shared_mdio.c: This is the bus framework where all masters are registered via shared MDIO block driver.

iproc_shared_mdio.c: Represent the shared MDIO block driver. The driver registers all masters to shared mdio bus framework.

mdio-bcm-iproc-shared.c: Master driver which registers ETHERNET phy to legacy MII framework.

In future there will be more driver for SATA, USB, PCIe masters which will register phys for their subsystem.

Patch series is developed based on Linux v4.6-rc1 and available at:
repo: https://github.com/Broadcom/arm64-linux.git
branch: shared_mdio_v0

Pramod Kumar (6):
bus: Add shared MDIO bus framework
Documentation: DT binding doc for iProc Shared MDIO Controller.
bus: Add platform driver for iProc shared MDIO Controller
dt: Add Shared MDIO Controller node for NS2
Documentation: Binding doc for ethernet master in NS2 net:phy: Add Ethernet Master for iProc Shared MDIO Controller

 .../bindings/bus/brcm,iproc-shared-mdio.txt        |  76 ++++++
 .../bindings/net/brcm,iproc-mdio-shared.txt        |  32 +++
 arch/arm64/boot/dts/broadcom/ns2-svk.dts           |  15 ++
 arch/arm64/boot/dts/broadcom/ns2.dtsi              |   8 +
 drivers/bus/Kconfig                                |  22 ++
 drivers/bus/Makefile                               |   2 +
 drivers/bus/iproc_shared_mdio.c                    | 287 +++++++++++++++++++++
 drivers/bus/shared_mdio.c                          | 179 +++++++++++++
 drivers/net/phy/Kconfig                            |  11 +
 drivers/net/phy/Makefile                           |   1 +
 drivers/net/phy/mdio-bcm-iproc-shared.c            | 116 +++++++++
 include/linux/shared_mdio.h                        | 123 +++++++++
 12 files changed, 872 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt
 create mode 100644 Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt
 create mode 100644 drivers/bus/iproc_shared_mdio.c
 create mode 100644 drivers/bus/shared_mdio.c
 create mode 100644 drivers/net/phy/mdio-bcm-iproc-shared.c
 create mode 100644 include/linux/shared_mdio.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/6 bus: Add shared MDIO bus framework

Add a common shared MDIO bus framework for sharing single (or few) MDIO bus across IO subsystems such as SATA, PCIe, USB, and Ethernet.

The IO specific PHY drivers will register to common shared MDIO bus as shared MDIO drivers and access the MDIO bus only using shared MDIO APIs.

---
 drivers/bus/Kconfig         |  11 +++
 drivers/bus/Makefile        |   1 +
 drivers/bus/shared_mdio.c   | 179 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/shared_mdio.h | 123 ++++++++++++++++++++++++++++++
 4 files changed, 314 insertions(+)
 create mode 100644 drivers/bus/shared_mdio.c
 create mode 100644 include/linux/shared_mdio.h
drivers/bus/Kconfig +11 -0
index d4a3a31..1b51b1a 100644
@@ -107,6 +107,17 @@ config OMAP_OCP2SCP
 	  OCP2SCP and in OMAP5, both USB PHY and SATA PHY is connected via
 	  OCP2SCP.
 
+config SHARED_MDIO
+	bool "Shared MDIO bus"
+	depends on OF
+
+	help
+	  Shared MDIO bus implementation for SoCs having common MDIO bus
+	  for different IO subsystems. All masters should be registered to
+	  this bus via a platform driver using shared framework API.
+	  Respective drivers would be called matching a compatible string
+	  provided in master node.
+
 config SIMPLE_PM_BUS
 	bool "Simple Power-Managed Bus Driver"
 	depends on OF && PM
drivers/bus/Makefile +1 -0
index ccff007..2b6d6e9 100644
@@ -19,3 +19,4 @@ obj-$(CONFIG_SUNXI_RSB)		+= sunxi-rsb.o
 obj-$(CONFIG_SIMPLE_PM_BUS)	+= simple-pm-bus.o
 obj-$(CONFIG_UNIPHIER_SYSTEM_BUS)	+= uniphier-system-bus.o
 obj-$(CONFIG_VEXPRESS_CONFIG)	+= vexpress-config.o
+obj-$(CONFIG_SHARED_MDIO)	+= shared_mdio.o
drivers/bus/shared_mdio.c new file +179 -0

179 lines not on this page · raw message

include/linux/shared_mdio.h new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

From: Pramod Kumar <[email protected]>
Date: Thu, 21 Apr 2016 14:48:38 +0530

drivers/bus/shared_mdio.c line 40

Quoted 5 lines
drivers/bus/shared_mdio.c new file +5 -0
+struct shared_mdio_master *shared_mdio_alloc_master(struct device *parent,
+						    struct device_node *node)
+{
+	int ret = 0;
+	struct shared_mdio_master *master;

Always order local variable declarations in reverse christmas tree (longest to shortest line) order.

drivers/bus/shared_mdio.c line 86

Quoted 5 lines
drivers/bus/shared_mdio.c new file +5 -0
+static int shared_mdio_driver_probe(struct device *dev)
+{
+	int rc;
+	struct shared_mdio_master *master = to_shared_mdio_master(dev);
+	struct shared_mdio_driver *drv = to_shared_mdio_driver(dev->driver);

Likewise.

Please audit your entire submission for this issue.

#3 lore raw

RE: [PATCH 1/6] bus: Add shared MDIO bus framework

Hi David,

Thanks for providing input over the patch. Will address the comment as described below.

Quoted 12 lines

-----Original Message-----
From: David Miller [mailto:davem at davemloft.net]
Sent: 24 April 2016 23:48
To: pramod.kumar at broadcom.com
Cc: robh+dt at kernel.org; catalin.marinas at arm.com; will.deacon at arm.com; yamada.masahiro at socionext.com; wens at csie.org; bcm-kernel-feedback- list at broadcom.com; pawel.moll at arm.com; mark.rutland at arm.com; arnd at arndb.de; suzuki.poulose at arm.com; punit.agrawal at arm.com; devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux- kernel at vger.kernel.org; netdev at vger.kernel.org; anup.patel at broadcom.com
Subject: Re: [PATCH 1/6] bus: Add shared MDIO bus framework

Quoted 6 lines

From: Pramod Kumar <[email protected]>
Date: Thu, 21 Apr 2016 14:48:38 +0530

Quoted 1 line

+struct shared_mdio_master *shared_mdio_alloc_master(struct device

*parent,

Review

Quoted 1 line
(quoted diff) +1 -0
+						    struct device_node

*node)

Quoted 5 lines

drivers/bus/shared_mdio.c line 40

Quoted 3 lines
drivers/bus/shared_mdio.c new file +3 -0
+{
+	int ret = 0;
+	struct shared_mdio_master *master;

Always order local variable declarations in reverse christmas tree

(longest to

Quoted 2 lines

shortest line) order.

Sure. Next patch will address this.

Quoted 4 lines

drivers/bus/shared_mdio.c

Quoted 4 lines
drivers/bus/shared_mdio.c new file +4 -0
+static int shared_mdio_driver_probe(struct device *dev) {
+	int rc;
+	struct shared_mdio_master *master = to_shared_mdio_master(dev);
+	struct shared_mdio_driver *drv =

to_shared_mdio_driver(dev->driver);

Quoted 2 lines

Likewise.

Sure.

Quoted 1 line

Please audit your entire submission for this issue.

Sure. I'll audit the entire patch set for above issue.

Regards,
Pramod

maintainer
#4 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

In reply to Pramod Kumar

Hi Pramod

I took a closer look. I don't see why the current MDIO code should not be used, rather than adding a new framework.

What you need for your Non Ethernet PHYs is that they are somehow probed. The current MDIO code will do that, based on the compatible string. An mdio device gets passed a struct mdio_device * to its probe function, giving you the bus and address on the bus for the device. Your PHY driver can then register itself using devm_of_phy_provider_register(). The user of the PHY then needs to use devm_phy_get() to get a handle on the phy, and can then use phy_power_on()/phy_power_off().

There is a very simple example here for an MDIO device driver:

http://thread.gmane.org/gmane.linux.network/393532

The muxing of the MDIO busses looks a little tricky. At the moment you have:

    writel(cmd, base + MDIO_PARAM_OFFSET);

which mixes together the muxing parameters and the write value. Can this register be accessed as two 16 bit registers? If it can be, you can cleanly separate out the muxing.

Take a look at mdio-mux-gpio.c and mdio-mux-mmioreg.c for examples of MDIO muxes.

Andrew

#5 lore raw

RE: [PATCH 1/6] bus: Add shared MDIO bus framework

Hi Andrew,

Thanks for reviewing. I really appreciate your effort it.

I am already aware of MDIO mux framework but did not see it fit for our use case due to below limitations:

1. Current MDIO mux framework is Ethernet centric and it is only meant to mux multiple MII buses using same MDIO controller. This means it is only meant for MII-compliant PHY devices (i.e. PHY devices having registers as-per MII specs). This is not the case with Broadcom SATA PHYs, PCIe PHYs, and USB PHYs even if we are sharing same MDIO controller for accessing these PHYs.

2. The MDIO mux framework registers each child bus as MII bus. The Linux Ethernet MDIO framework will scan for all attached PHY devices on given MII bus and try to read MII PHY_ID register which is not present in all Broadcom non-ethernet PHYs.

3. Let's say we ignore point1 and point2 above and go ahead and use MDIO mux framework then we will still have to emulated MII PHY_ID read for non-ethernet PHYs. Let's say we also emulate MII PHY_ID read in non-ethernet PHYs then next thing is non-ethernet PHYs don't follow MII state machine so all other MII PHY register read/write will not work.

4. Apart from these, by using MDIO mux framework we are making our non-ethernet PHYs dependent on Linux network drivers which is not acceptable. What if some product line does not need network subsystem at all?

As you can see from above points, trying to re-use Linux Ethernet MDIO mux framework for non-Ethernet PHYs is not the right way. The sole reason being Linux MDIO mux framework is not generic enough to be shared across IO subsystems. Due to this reason we had to come-up with "Shared MDIO framework" which is very simple, generic and independent of I/O subsystems.

I'll add PCIe PHYs driver based on Shared MDIO framework in next patch revision to get a feel of its need.

Regards,
Pramod

Quoted 5 lines

-----Original Message-----
From: Andrew Lunn [mailto:andrew at lunn.ch]
Sent: 26 April 2016 02:27
To: Pramod Kumar
Cc: Rob Herring; Catalin Marinas; Will Deacon; Masahiro Yamada; Chen-Yu

Tsai;

Quoted 1 line

Mark Rutland; devicetree at vger.kernel.org; Pawel Moll; Arnd Bergmann;

Suzuki

Quoted 8 lines

K Poulose; netdev at vger.kernel.org; Punit Agrawal; linux- kernel at vger.kernel.org; BCM Kernel Feedback; linux-arm- kernel at lists.infradead.org; Anup Patel
Subject: Re: [PATCH 1/6] bus: Add shared MDIO bus framework

Hi Pramod

I took a closer look. I don't see why the current MDIO code should not

be used,

Quoted 3 lines

rather than adding a new framework.

What you need for your Non Ethernet PHYs is that they are somehow

probed.

Quoted 1 line

The current MDIO code will do that, based on the compatible string. An

mdio

Quoted 1 line

device gets passed a struct mdio_device * to its probe function, giving

you the

Quoted 1 line

bus and address on the bus for the device. Your PHY driver can then

register

Quoted 1 line

itself using devm_of_phy_provider_register(). The user of the PHY then

needs to

Quoted 9 lines

use
devm_phy_get() to get a handle on the phy, and can then use phy_power_on()/phy_power_off().

There is a very simple example here for an MDIO device driver:

http://thread.gmane.org/gmane.linux.network/393532

The muxing of the MDIO busses looks a little tricky. At the moment you

have:

Quoted 5 lines
    writel(cmd, base + MDIO_PARAM_OFFSET);

which mixes together the muxing parameters and the write value. Can this register be accessed as two 16 bit registers? If it can be, you can

cleanly

Quoted 6 lines

separate out the muxing.

Take a look at mdio-mux-gpio.c and mdio-mux-mmioreg.c for examples of MDIO muxes.

Andrew

maintainer
#6 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

Quoted 11 lines · Pramod Kumar

Hi Andrew,

Thanks for reviewing. I really appreciate your effort it.

I am already aware of MDIO mux framework but did not see it fit for our use case due to below limitations:

1. Current MDIO mux framework is Ethernet centric and it is only meant to mux multiple MII buses using same MDIO controller. This means it is only meant for MII-compliant PHY devices (i.e. PHY devices having registers as-per MII specs).

Nope, this is wrong. You can have a mixture of PHYs and other MDIO devices on the MII bus. The framework does not care. A PHY is a special case of an MDIO device.

Quoted 4 lines

2. The MDIO mux framework registers each child bus as MII bus. The Linux Ethernet MDIO framework will scan for all attached PHY devices on given MII bus and try to read MII PHY_ID register which is not present in all Broadcom non-ethernet PHYs.

It only performs a scan if you don't list the devices in the device tree. If you do list devices, and include the address on the bus, it never scans.

A good example of this is Ethernet switches. They occupy multiple addresses on the MDIO bus, and also do not implement the PHY_ID register at each address. Yet the MDIO layer is happy with this.

Quoted 3 lines

3. Let's say we ignore point1 and point2 above and go ahead and use MDIO mux framework then we will still have to emulated MII PHY_ID read for non-ethernet PHYs.

Nope. Not at all. You have an MDIO device on the bus, not an Ethernet PHY. Hence the device is not liked to the PHY state machine, etc.

The key concept to get here is that there are MDIO devices, and a subset of MDIO devices are Ethernet PHYs.....

Quoted 4 lines

4. Apart from these, by using MDIO mux framework we are making our non-ethernet PHYs dependent on Linux network drivers which is not acceptable. What if some product line does not need network subsystem at all?

This is your only valid point. However, does Broadcom have a product line which does not include networking? Is not Broadcom a network SoC vendor?

Quoted 3 lines

As you can see from above points, trying to re-use Linux Ethernet MDIO mux framework for non-Ethernet PHYs is not the right way.

And as i pointed out, all your arguments are wrong, bar one. And i doubt that one argument is sufficient to duplicate a lot of code which already exists and does 95% of what you need.

Quoted 2 lines

I'll add PCIe PHYs driver based on Shared MDIO framework in next patch revision to get a feel of its need.

Great. Lets then see what is needed to turn it into an MDIO device.

Andrew

maintainer
#7 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

From: Andrew Lunn <[email protected]>
Date: Tue, 26 Apr 2016 14:13:35 +0200

Quoted 7 lines · Pramod Kumar
Quoted 2 lines

As you can see from above points, trying to re-use Linux Ethernet MDIO mux framework for non-Ethernet PHYs is not the right way.

And as i pointed out, all your arguments are wrong, bar one. And i doubt that one argument is sufficient to duplicate a lot of code which already exists and does 95% of what you need.

+1

#8 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

In reply to Andrew Lunn
Quoted 8 lines · Andrew Lunn
Quoted 4 lines

4. Apart from these, by using MDIO mux framework we are making our non-ethernet PHYs dependent on Linux network drivers which is not acceptable. What if some product line does not need network subsystem at all?

This is your only valid point. However, does Broadcom have a product line which does not include networking? Is not Broadcom a network SoC vendor?

But even with that, there is no reason why we could not decouple the PHYLIB MDIO framework from PHYLIB and make it available as a more standalone subsystem which can be utilized when you have a mix of MDIO devices like here.

I am not clear on how common a shared MDIO bus is on other SoCs, but the other Broadcom SoCs I am familiar with have dedicated MDIO buses instances per type of PHY (PCIe, BUSB, Ethernet), thus making the split a ton easier.

Signature · 1 line
Florian
maintainer
#9 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

Quoted 4 lines

I am not clear on how common a shared MDIO bus is on other SoCs, but the other Broadcom SoCs I am familiar with have dedicated MDIO buses instances per type of PHY (PCIe, BUSB, Ethernet), thus making the split a ton easier.

I don't actually see this shared bus being an issue, once the mux it implemented. With the mux, you see N MDIO busses, each acting like a normal MDIO bus. I've used the GPIO variety and had no issues:

http://marc.info/?l=linux-arm-kernel&m=145910090401796&w=2

Andrew

#10 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

In reply to Florian Fainelli
Quoted 6 lines · On Tuesday 26 April 2016 10:23:02 Florian Fainelli wrote:
Quoted 5 lines · Andrew Lunn
Quoted 4 lines

4. Apart from these, by using MDIO mux framework we are making our non-ethernet PHYs dependent on Linux network drivers which is not acceptable. What if some product line does not need network subsystem at all?

Quoted 8 lines
Quoted 3 lines

This is your only valid point. However, does Broadcom have a product line which does not include networking? Is not Broadcom a network SoC vendor?

But even with that, there is no reason why we could not decouple the PHYLIB MDIO framework from PHYLIB and make it available as a more standalone subsystem which can be utilized when you have a mix of MDIO devices like here.

[adding Kishon Vijay Abraham]

We should also consider how this fits in with drivers/phy/, which is the generic framework for all PHY devices that are not for ethernet.

The most straightforward way that you mention would be to allow generic PHY devices to be probed on an MIO bus or mux. This should just work using mdio_module_driver(), as Andrew already explained.

A more complex problem would be having a PHY driver for a device that can be either an ethernet phy or some other phy. With today's frameworks that would require two separate drivers, one in drivers/phy and one in drivers/net/phy/. If that turns out to be a common problem, we might want to come up with a way to nest one on top of the other, or merge two two device structures (struct phy_device and struct phy).

Quoted 4 lines

I am not clear on how common a shared MDIO bus is on other SoCs, but the other Broadcom SoCs I am familiar with have dedicated MDIO buses instances per type of PHY (PCIe, BUSB, Ethernet), thus making the split a ton easier.

I think most commonly, the other PHYs are not on MDIO at all, but are integrated inside of the SoC as an MMIO based device.

Arnd

maintainer
#11 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

Quoted 2 lines

A more complex problem would be having a PHY driver for a device that can be either an ethernet phy or some other phy.

I doubt that ever happens. You can have up to 32 different devices on an MDIO bus. Since an Ethernet PHY and a "some other sort of PHY" are completely different things, why would a hardware engineer place them on the same address? It is like saying your ATA controller and VGA controller share the same slot on the PCI bus...

Andrew

#12 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

Quoted 8 lines · On Tuesday 26 April 2016 20:23:35 Andrew Lunn wrote:
Quoted 2 lines

A more complex problem would be having a PHY driver for a device that can be either an ethernet phy or some other phy.

I doubt that ever happens. You can have up to 32 different devices on an MDIO bus. Since an Ethernet PHY and a "some other sort of PHY" are completely different things, why would a hardware engineer place them on the same address? It is like saying your ATA controller and VGA controller share the same slot on the PCI bus...

To clarify: what I meant is a device that is designed as a PHY for similar hardware (e.g. SATA, USB3 and PCIe) and that has a common register set and a single driver, but that driver can operate in multiple modes. You typically have multiple instances of such hardware, with each instance linked to exactly one host device, but one driver for all of them.

See Documentation/devicetree/bindings/phy/apm-xgene-phy.txt and drivers/phy/phy-xgene.c for one such example.

Arnd

maintainer
#13 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

Quoted 17 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 26 April 2016 20:23:35 Andrew Lunn wrote:
Quoted 2 lines

A more complex problem would be having a PHY driver for a device that can be either an ethernet phy or some other phy.

I doubt that ever happens. You can have up to 32 different devices on an MDIO bus. Since an Ethernet PHY and a "some other sort of PHY" are completely different things, why would a hardware engineer place them on the same address? It is like saying your ATA controller and VGA controller share the same slot on the PCI bus...

To clarify: what I meant is a device that is designed as a PHY for similar hardware (e.g. SATA, USB3 and PCIe) and that has a common register set and a single driver, but that driver can operate in multiple modes. You typically have multiple instances of such hardware, with each instance linked to exactly one host device, but one driver for all of them.

Quoted 2 lines

See Documentation/devicetree/bindings/phy/apm-xgene-phy.txt and drivers/phy/phy-xgene.c for one such example.

Interesting. Also, that this lists SGMII. I assume this is a phy in the MAC in order to talk to the Ethernet PHY.

I still don't see it being a big problem if a phy driver implements an Ethernet PHY. It just needs to call phy_device_create() and phy_device_register().

Andrew

#14 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

Quoted 21 lines · Andrew Lunn
Quoted 17 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 26 April 2016 20:23:35 Andrew Lunn wrote:
Quoted 2 lines

A more complex problem would be having a PHY driver for a device that can be either an ethernet phy or some other phy.

I doubt that ever happens. You can have up to 32 different devices on an MDIO bus. Since an Ethernet PHY and a "some other sort of PHY" are completely different things, why would a hardware engineer place them on the same address? It is like saying your ATA controller and VGA controller share the same slot on the PCI bus...

To clarify: what I meant is a device that is designed as a PHY for similar hardware (e.g. SATA, USB3 and PCIe) and that has a common register set and a single driver, but that driver can operate in multiple modes. You typically have multiple instances of such hardware, with each instance linked to exactly one host device, but one driver for all of them.

Quoted 2 lines

See Documentation/devicetree/bindings/phy/apm-xgene-phy.txt and drivers/phy/phy-xgene.c for one such example.

Quoted 8 lines

Interesting. Also, that this lists SGMII. I assume this is a phy in the MAC in order to talk to the Ethernet PHY.

I still don't see it being a big problem if a phy driver implements an Ethernet PHY. It just needs to call phy_device_create() and phy_device_register().

Andrew

It is really interesting to see the evolution of MDIO bus:

1. Traditionally, MDIO controller used to be part of each ethernet controller itself so each ethernet controller used to have it's own 2 wire MDIO bus

2. Next, we saw SoC with multiple ethernet controllers sharing same MDIO bus. In other words, we saw multiple MDIO bus being muxed over single MDIO bus with additional bus select lines (I think this is when drivers/net/phy/mdio-mux.c APIs were implemented but at this point all PHYs on muxed MDIO bus were ethernet PHYs).

3. Then, we saw SoC with ethernet switch devices also accessible over shared MDIO bus (or Muxed MDIO bus) along with ethernet PHYs (I guess this is why we have drivers/net/phy/mdio_device.c which adds "mdio_device" for non-ethernet-PHY devices on MDIO bus).

4. Now, we have SoC with SATA PHYs, PCIe PHYs, USB PHYs, and Ethernet PHYs all accessible over same shared MDIO bus (or Muxed MDIO bus). The SATA PHYs and PCIe PHYs are registered to "Generic PHY framework". For USB PHYs, we can either register to "Generic PHY framework" or "USB PHY framework". For Ethernet PHYs, we register MDIO bus instance to "Ethernet MDIO framework".

The devices on ARM64 SoC has to be within first 4GB and RAM has to start from first 4GB to be ARM compliant because ARM64 CPUs have 32bit mode and all devices and RAM should be available to 32bit mode with MMU disabled. This means that we only have 4GB to fit all devices registers and some portion of RAM. Some of these non-Ethernet PHYs have tons of registers so as number of PHYs increase in a SoC they will eat-up lot of first 4GB address space. Using same MDIO bus for all types of PHYs (SATA, PCIe, USB, and Ethernet) is actually a good approach because it actually saves lot of first 4GB address space. In future, more devices will be moved to a shared MDIO bus which are less frequently accessed.

For Broadcom iProc SoCs, the design choice has already been made to use shared MDIO bus for all PHYs. In fact, Broadcom iProc NS2 SoC already has a shared MDIO bus for SATA PHYs, USB PHYs, PCIe PHYs, and Ethernet PHYs and more Broadcom iProc SoCs are on their way. Of course, there are few exceptions in iProc SoCs such as SATA PHYs where we also have memory mapped registers to access PHYs but other PHYs don't have such memory mapped registers.

Clearly from above, the traditional 2 wire MDIO bus is now a shared MDIO bus with 2-wire plus additional select lines. Also, now we have SoCs (such as Broadcom iProc SoCs) which has such shared MDIO bus and I think in-future we will have SoCs with a shared MDIO bus for variety of devices.

For long term, we really need a clean solution to fit shared MDIO based PHY drivers in Linux kernel. Also, shared MDIO based PHY drivers should not be dependent on any particular IO subsystem (such as Linux Ethernet) because there are lot of use-cases where people want strip down kernel image by not-compiling IO subsystems which are not required.

IMHO, we have several options in front of us:
1. Use some light-weight framework (such as shared_mdio.c implemented by this patchset) under drivers/bus
2. Extend "Generic PHY framework" to allow something like shared MDIO bus (as-per Arnd's suggestion)
3. Move-out "MDIO-mux APIs" from drivers/net/phy to something like drivers/mdio-mux and make it independent of "Linux Ethernet subsystem". (... may be more options ...)

Regards,
Anup

#15 lore raw

Re: [PATCH 1/6] bus: Add shared MDIO bus framework

Quoted 16 lines · On Wednesday 27 April 2016 10:16:40 Anup Patel wrote:

It is really interesting to see the evolution of MDIO bus:

1. Traditionally, MDIO controller used to be part of each ethernet controller itself so each ethernet controller used to have it's own 2 wire MDIO bus

2. Next, we saw SoC with multiple ethernet controllers sharing same MDIO bus. In other words, we saw multiple MDIO bus being muxed over single MDIO bus with additional bus select lines (I think this is when drivers/net/phy/mdio-mux.c APIs were implemented but at this point all PHYs on muxed MDIO bus were ethernet PHYs).

3. Then, we saw SoC with ethernet switch devices also accessible over shared MDIO bus (or Muxed MDIO bus) along with ethernet PHYs (I guess this is why we have drivers/net/phy/mdio_device.c which adds "mdio_device" for non-ethernet-PHY devices on MDIO bus).

Quoted 6 lines

4. Now, we have SoC with SATA PHYs, PCIe PHYs, USB PHYs, and Ethernet PHYs all accessible over same shared MDIO bus (or Muxed MDIO bus). The SATA PHYs and PCIe PHYs are registered to "Generic PHY framework". For USB PHYs, we can either register to "Generic PHY framework" or "USB PHY framework". For Ethernet PHYs, we register MDIO bus instance to "Ethernet MDIO framework".

Thanks for the extra background information.

Quoted 10 lines

The devices on ARM64 SoC has to be within first 4GB and RAM has to start from first 4GB to be ARM compliant because ARM64 CPUs have 32bit mode and all devices and RAM should be available to 32bit mode with MMU disabled. This means that we only have 4GB to fit all devices registers and some portion of RAM. Some of these non-Ethernet PHYs have tons of registers so as number of PHYs increase in a SoC they will eat-up lot of first 4GB address space. Using same MDIO bus for all types of PHYs (SATA, PCIe, USB, and Ethernet) is actually a good approach because it actually saves lot of first 4GB address space. In future, more devices will be moved to a shared MDIO bus which are less frequently accessed.

I think it remains to be seen if anyone other than Broadcom follows this model. I have no idea if that's likely or not, perhaps everyone does this, perhaps you are the only ones.

Quoted 19 lines

For Broadcom iProc SoCs, the design choice has already been made to use shared MDIO bus for all PHYs. In fact, Broadcom iProc NS2 SoC already has a shared MDIO bus for SATA PHYs, USB PHYs, PCIe PHYs, and Ethernet PHYs and more Broadcom iProc SoCs are on their way. Of course, there are few exceptions in iProc SoCs such as SATA PHYs where we also have memory mapped registers to access PHYs but other PHYs don't have such memory mapped registers.

Clearly from above, the traditional 2 wire MDIO bus is now a shared MDIO bus with 2-wire plus additional select lines. Also, now we have SoCs (such as Broadcom iProc SoCs) which has such shared MDIO bus and I think in-future we will have SoCs with a shared MDIO bus for variety of devices.

For long term, we really need a clean solution to fit shared MDIO based PHY drivers in Linux kernel. Also, shared MDIO based PHY drivers should not be dependent on any particular IO subsystem (such as Linux Ethernet) because there are lot of use-cases where people want strip down kernel image by not-compiling IO subsystems which are not required.

Quoted 3 lines

IMHO, we have several options in front of us:
1. Use some light-weight framework (such as shared_mdio.c implemented by this patchset) under drivers/bus

I think this has been sufficiently NAKed by everyone

Quoted 5 lines

2. Extend "Generic PHY framework" to allow something like shared MDIO bus (as-per Arnd's suggestion)
3. Move-out "MDIO-mux APIs" from drivers/net/phy to something like drivers/mdio-mux and make it independent of "Linux Ethernet subsystem". (... may be more options ...)

while these two really describe the same thing. I think as a first step, we can reorganize the Kconfig structure to put ethernet PHY and the MDIO bus as two separate submenus in drivers/phy/Kconfig, and make the latter independent of CONFIG_NETDEVICES, see patch below. With that, you should already be able to write a generic phy driver that registers itself as an MDIO device driver.

We can also debate moving files from drivers/net/phy and drivers/usb/phy into drivers/phy/{net,mdio,usb}/ as a follow-up, but the file location is really not all that important here.

Arnd

drivers/net/Kconfig +0 -2
index befd67df08e1..c58b60e70ab2 100644
@@ -356,8 +356,6 @@ config NET_SB1000
 
 	  If you don't have this card, of course say N.
 
-source "drivers/net/phy/Kconfig"
-
 source "drivers/net/plip/Kconfig"
 
 source "drivers/net/ppp/Kconfig"
drivers/net/ethernet/Kconfig +0 -3
index 2ffd63463299..2e2491b344d9 100644
@@ -11,9 +11,6 @@ menuconfig ETHERNET
 
 if ETHERNET
 
-config MDIO
-	tristate
-
 config SUNGEM_PHY
 	tristate
 
drivers/net/phy/Kconfig +13 -2
index 6dad9a9c356c..58447866fe64 100644
@@ -3,8 +3,9 @@
 #
 
 menuconfig PHYLIB
-	tristate "PHY Device support and infrastructure"
+	tristate "Ethernet PHY Device support and infrastructure"
 	depends on NETDEVICES
+	select MDIO
 	help
 	  Ethernet controllers are usually attached to PHY
 	  devices.  This option provides infrastructure for
@@ -164,6 +165,16 @@ config FIXED_PHY
 	  PHYs that are not connected to the real MDIO bus.
 
 	  Currently tested with mpc866ads and mpc8349e-mitx.
+endif # PHYLIB
+
+config MDIO
+	tristate
+	help
+	  The MDIO bus is typically used ethernet PHYs, but can also be
+	  used by other PHY drivers.
+
+menu "MDIO bus drivers"
+	depends on MDIO
 
 config MDIO_BITBANG
 	tristate "Support for bitbanged MDIO buses"
@@ -271,7 +282,7 @@ config MDIO_BCM_IPROC
 	  This module provides a driver for the MDIO busses found in the
 	  Broadcom iProc SoC's.
 
-endif # PHYLIB
+endmenu # MDIO
 
 config MICREL_KS8995MA
 	tristate "Micrel KS8995MA 5-ports 10/100 managed Ethernet switch"
drivers/phy/Kconfig +7 -1
index ce29c17359e9..298893744a17 100644
@@ -2,7 +2,9 @@
 # PHY
 #
 
-menu "PHY Subsystem"
+menu "PHY drivers"
+
+menu "Generic PHY subsystem"
 
 config GENERIC_PHY
 	bool "PHY Core"
@@ -425,3 +427,7 @@ config PHY_CYGNUS_PCIE
 source "drivers/phy/tegra/Kconfig"
 
 endmenu
+
+source "drivers/net/phy/Kconfig"
+
+endmenu
#16 lore raw

PATCH 2/6 Documentation: DT binding doc for iProc Shared MDIO Controller.

In reply to Pramod Kumar

Add DT binding doc for iProc Shared MDIO Controller which populate all masters to Shared MDIO framework.

---
 .../bindings/bus/brcm,iproc-shared-mdio.txt        | 76 ++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +76 -0
new file mode 100644
index 0000000..f455f3d
@@ -0,0 +1,76 @@
+Broadcom iProc Shared MDIO Controller
+
+Required properties:
+- compatible:
+    "brcm,iproc-shared-mdio" for shared MDIO controller.
+- reg: specifies the base physical address and size of the registers
+- reg-names: should be "mdio"
+- #address-cells: must be 1.
+- #size-cells: must be 0.
+
+optional:
+child nodes: Masters are represented as a child node of shared MDIO controller
+and all the PHYs handled by this master are represented as its child node.
+
+Master nodes properties are defined as-
+
+Required properties:
+- compatible: Used to match driver of this PHY.
+- reg: MDIO master ID.
+- #address-cells: must be 1.
+- #size-cells: must be 0.
+
+optional:
+-brcm,phy-internal: if presents, PHYs are internal. Absence shows phy is
+external.
+-brcm,is-c45: if presents, Controller uses Clause-45 to issue MDIO transaction.
+else Controller uses Clause-22 for transactions.
+
+PHY nodes are represented as the child node of Master. Child nodes properties
+are defined as-
+
+Required properties:
+-reg: phy id of attached PHY.
+
+optional:
+There could be additional properties required to configure the specific phy like
+phy-mode in case of gpphy node below. These should be defined here and used by
+respective drivers.
+
+Example:
+iproc_mdio: iproc_mdio at 663f0000 {
+	compatible = "brcm,iproc-shared-mdio";
+	reg = <0x6602023c 0x14>;
+	reg-names = "mdio";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	sata-master at 6 {
+		compatible = "brcm,iproc-ns2-sata-phy";
+		reg = <0x6>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		brcm,phy-internal;
+
+		sata_phy0: sata-phy at 1 {
+			reg = <0x1>;
+			#phy-cells = <0>;
+		};
+
+		sata_phy1: sata-phy at 2 {
+			reg = <0x2>;
+			#phy-cells = <0>;
+		};
+	};
+
+	eth-master at 0 {
+		compatible = "brcm,iproc-mdio-master-eth";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gphy0: eth-phy at 10 {
+			reg = <0x10>;
+			phy-mode = "mii";
+		};
+	};
+};
Signature · 1 line
1.9.1
maintainer
#17 lore raw

Re: [PATCH 2/6] Documentation: DT binding doc for iProc Shared MDIO Controller.

Quoted 20 lines · Pramod Kumar

Add DT binding doc for iProc Shared MDIO Controller which populate all masters to Shared MDIO framework.

---
 .../bindings/bus/brcm,iproc-shared-mdio.txt        | 76 ++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +3 -0
new file mode 100644
index 0000000..f455f3d
@@ -0,0 +1,76 @@
+Broadcom iProc Shared MDIO Controller
+
+Required properties:

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 13

Quoted 10 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +10 -0
+- compatible:
+    "brcm,iproc-shared-mdio" for shared MDIO controller.
+- reg: specifies the base physical address and size of the registers
+- reg-names: should be "mdio"
+- #address-cells: must be 1.
+- #size-cells: must be 0.
+
+optional:
+child nodes: Masters are represented as a child node of shared MDIO controller
+and all the PHYs handled by this master are represented as its child node.

Seems kind of useless if child nodes are optional.

Quoted 4 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +4 -0
+
+Master nodes properties are defined as-
+
+Required properties:

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 27

Quoted 10 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +10 -0
+- compatible: Used to match driver of this PHY.
+- reg: MDIO master ID.
+- #address-cells: must be 1.
+- #size-cells: must be 0.
+
+optional:
+-brcm,phy-internal: if presents, PHYs are internal. Absence shows phy is
+external.
+-brcm,is-c45: if presents, Controller uses Clause-45 to issue MDIO transaction.
+else Controller uses Clause-22 for transactions.

Isn't this a property of the phy? IIRC, there is a standard property or compatible string for this.

Quoted 11 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +11 -0
+
+PHY nodes are represented as the child node of Master. Child nodes properties
+are defined as-
+
+Required properties:
+-reg: phy id of attached PHY.
+
+optional:
+There could be additional properties required to configure the specific phy like
+phy-mode in case of gpphy node below. These should be defined here and used by
+respective drivers.

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 48

Quoted 10 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +10 -0
+
+Example:
+iproc_mdio: iproc_mdio at 663f0000 {
+	compatible = "brcm,iproc-shared-mdio";
+	reg = <0x6602023c 0x14>;
+	reg-names = "mdio";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	sata-master at 6 {

mdio at 6

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 55

Quoted 7 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +7 -0
+		compatible = "brcm,iproc-ns2-sata-phy";
+		reg = <0x6>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		brcm,phy-internal;
+
+		sata_phy0: sata-phy at 1 {

phy at 1

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 60

Quoted 5 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +5 -0
+			reg = <0x1>;
+			#phy-cells = <0>;
+		};
+
+		sata_phy1: sata-phy at 2 {

phy at 2

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 66

Quoted 6 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +6 -0
+			reg = <0x2>;
+			#phy-cells = <0>;
+		};
+	};
+
+	eth-master at 0 {

mdio at 0

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 71

Quoted 5 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +5 -0
+		compatible = "brcm,iproc-mdio-master-eth";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gphy0: eth-phy at 10 {

phy at 10

Quoted 13 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +5 -0
+			reg = <0x10>;
+			phy-mode = "mii";
+		};
+	};
+};
Signature · 7 lines
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#18 lore raw

RE: [PATCH 2/6] Documentation: DT binding doc for iProc Shared MDIO Controller.

Hi Rob,

Thanks for reviewing and providing your valuable comments.

Quoted 7 lines

-----Original Message-----
From: Rob Herring [mailto:robh at kernel.org]
Sent: 23 April 2016 01:41
To: Pramod Kumar
Cc: Catalin Marinas; Will Deacon; Masahiro Yamada; Chen-Yu Tsai; Mark Rutland; devicetree at vger.kernel.org; Pawel Moll; Arnd Bergmann; Suzuki K Poulose; netdev at vger.kernel.org; Punit Agrawal;

linux-kernel at vger.kernel.org;

Quoted 2 lines

BCM Kernel Feedback; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH 2/6] Documentation: DT binding doc for iProc Shared

MDIO

Quoted 29 lines

Controller.

Quoted 8 lines · Pramod Kumar

Add DT binding doc for iProc Shared MDIO Controller which populate all masters to Shared MDIO framework.

---
 .../bindings/bus/brcm,iproc-shared-mdio.txt        | 76

++++++++++++++++++++++

Quoted 17 lines
 1 file changed, 76 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt

diff --git a/Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt b/Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file mode 100644
index 0000000..f455f3d

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +5 -0
@@ -0,0 +1,76 @@
+Broadcom iProc Shared MDIO Controller
+
+Required properties:
+- compatible:
+    "brcm,iproc-shared-mdio" for shared MDIO controller.
Quoted 8 lines

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt

Quoted 8 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +8 -0
+- reg: specifies the base physical address and size of the registers
+- reg-names: should be "mdio"
+- #address-cells: must be 1.
+- #size-cells: must be 0.
+
+optional:
+child nodes: Masters are represented as a child node of shared MDIO
+controller and all the PHYs handled by this master are represented as

its child

Quoted 4 lines

node.

Seems kind of useless if child nodes are optional.

I agree. I'll put it under required properties.

Quoted 14 lines

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt

Quoted 13 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +13 -0
+
+Master nodes properties are defined as-
+
+Required properties:
+- compatible: Used to match driver of this PHY.
+- reg: MDIO master ID.
+- #address-cells: must be 1.
+- #size-cells: must be 0.
+
+optional:
+-brcm,phy-internal: if presents, PHYs are internal. Absence shows phy
+is external.
+-brcm,is-c45: if presents, Controller uses Clause-45 to issue MDIO

transaction.

Quoted 3 lines

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 27

Quoted 1 line
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +1 -0
+else Controller uses Clause-22 for transactions.

Isn't this a property of the phy? IIRC, there is a standard property or

compatible

Quoted 2 lines

string for this.

Shared MDIO controller's master holds all above property to ensure the proper MDIO transaction over its bus. Hence tried to pinned here. These properties are standard one for the Ethernet PHY but Broadcom SoCs MDIO is shared even with other I/O subsystem. Other subsystem does not defines this property hence has been defined here.

Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +15 -0
+
+PHY nodes are represented as the child node of Master. Child nodes
+properties are defined as-
+
+Required properties:
+-reg: phy id of attached PHY.
+
+optional:
+There could be additional properties required to configure the
+specific phy like phy-mode in case of gpphy node below. These should
+be defined here and used by respective drivers.
+
+Example:
+iproc_mdio: iproc_mdio at 663f0000 {
+	compatible = "brcm,iproc-shared-mdio";
Quoted 8 lines

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 48

Quoted 6 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +6 -0
+	reg = <0x6602023c 0x14>;
+	reg-names = "mdio";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	sata-master at 6 {

mdio at 6

Do you advise us to rename the node name as mdio at 6? If yes, I don't have any personal preferences here and would do it. I'd thought to give proper name so that consumer could get what this node is representing. Please suggest us.

Quoted 11 lines

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 55

Quoted 8 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +7 -0
+		compatible = "brcm,iproc-ns2-sata-phy";
+		reg = <0x6>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		brcm,phy-internal;
+
+		sata_phy0: sata-phy at 1 {

phy at 1

Same as above.

Quoted 8 lines

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 60

Quoted 5 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +5 -0
+			reg = <0x1>;
+			#phy-cells = <0>;
+		};
+
+		sata_phy1: sata-phy at 2 {

phy at 2

Same as above.

Quoted 8 lines

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 66

Quoted 6 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +6 -0
+			reg = <0x2>;
+			#phy-cells = <0>;
+		};
+	};
+
+	eth-master at 0 {

mdio at 0

Same as above.

Quoted 9 lines

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 71

Quoted 6 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +5 -0
+		compatible = "brcm,iproc-mdio-master-eth";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gphy0: eth-phy at 10 {

phy at 10

Same as above.

Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +5 -1
+			reg = <0x10>;
+			phy-mode = "mii";
+		};
+	};
+};
--

1.9.1

Quoted 4 lines
Quoted 4 lines

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Regards,
Pramod

maintainer
#19 lore raw

Re: [PATCH 2/6] Documentation: DT binding doc for iProc Shared MDIO Controller.

In reply to Pramod Kumar
Quoted 27 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +27 -0
+Example:
+iproc_mdio: iproc_mdio at 663f0000 {
+	compatible = "brcm,iproc-shared-mdio";
+	reg = <0x6602023c 0x14>;
+	reg-names = "mdio";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	sata-master at 6 {
+		compatible = "brcm,iproc-ns2-sata-phy";
+		reg = <0x6>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		brcm,phy-internal;
+
+		sata_phy0: sata-phy at 1 {
+			reg = <0x1>;
+			#phy-cells = <0>;
+		};
+
+		sata_phy1: sata-phy at 2 {
+			reg = <0x2>;
+			#phy-cells = <0>;
+		};
+	};
+
+	eth-master at 0 {

Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt line 76

Quoted 10 lines
Documentation/devicetree/bindings/bus/brcm,iproc-shared-mdio.txt new file +10 -0
+		compatible = "brcm,iproc-mdio-master-eth";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gphy0: eth-phy at 10 {
+			reg = <0x10>;
+			phy-mode = "mii";
+		};
+	};
+};

So looking at this, you have an MDIO bus, an MDIO mux on top of that, and then some MDIO devices on the muxed busses. You don't need a whole new framework for this. You need a new mdio-mux driver, but the existing MDIO framework should do what you need.

Andrew

#20 lore raw

PATCH 3/6 bus: Add platform driver for iProc shared MDIO Controller

In reply to Pramod Kumar

Add platform driver to populate shared MDIO masters on iProc SoC.

---
 drivers/bus/Kconfig             |  11 ++
 drivers/bus/Makefile            |   1 +
 drivers/bus/iproc_shared_mdio.c | 287 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 299 insertions(+)
 create mode 100644 drivers/bus/iproc_shared_mdio.c
drivers/bus/Kconfig +11 -0
index 1b51b1a..c3f2cb9 100644
@@ -118,6 +118,17 @@ config SHARED_MDIO
 	  Respective drivers would be called matching a compatible string
 	  provided in master node.
 
+config IPROC_SHARED_MDIO
+	tristate "iProc Shared MDIO Driver"
+	depends on OF
+	select SHARED_MDIO
+	default ARCH_BCM_IPROC
+	help
+	  Platform driver for shared MDIO controller. Broadcom's iProc based
+	  SoCs have many masters which uses one shared bus to accessed its PHY.
+	  This platform driver populates all master to Shared bus and provide
+	  the MDIO controller specific implementation.
+
 config SIMPLE_PM_BUS
 	bool "Simple Power-Managed Bus Driver"
 	depends on OF && PM
drivers/bus/Makefile +1 -0
index 2b6d6e9..3e364da 100644
@@ -20,3 +20,4 @@ obj-$(CONFIG_SIMPLE_PM_BUS)	+= simple-pm-bus.o
 obj-$(CONFIG_UNIPHIER_SYSTEM_BUS)	+= uniphier-system-bus.o
 obj-$(CONFIG_VEXPRESS_CONFIG)	+= vexpress-config.o
 obj-$(CONFIG_SHARED_MDIO)	+= shared_mdio.o
+obj-$(CONFIG_IPROC_SHARED_MDIO)	+= iproc_shared_mdio.o
drivers/bus/iproc_shared_mdio.c new file +287 -0

287 lines not on this page · raw message

Signature · 1 line
1.9.1
#21 lore raw

PATCH 4/6 dt: Add Shared MDIO Controller node for NS2

In reply to Pramod Kumar

Add NS2 Shared MDIO Controller DT node having eth phy as child. This node represents the NS2 AMAC eth phy.

---
 arch/arm64/boot/dts/broadcom/ns2-svk.dts | 15 +++++++++++++++
 arch/arm64/boot/dts/broadcom/ns2.dtsi    |  8 ++++++++
 2 files changed, 23 insertions(+)
arch/arm64/boot/dts/broadcom/ns2-svk.dts +15 -0
index ce0ab84..2944418 100644
@@ -87,3 +87,18 @@
 		#size-cells = <1>;
 	};
 };
+
+&iproc_shared_mdio {
+	eth-master at 0 {
+		compatible = "brcm,iproc-mdio-master-eth";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "ok";
+
+		gphy0: eth-phy at 10 {
+			reg = <0x10>;
+			phy-mode = "mii";
+		};
+	};
+};
arch/arm64/boot/dts/broadcom/ns2.dtsi +8 -0
index 6f81c9d..5b98c81 100644
@@ -330,6 +330,14 @@
 			      <0x65260000 0x1000>;
 		};
 
+		iproc_shared_mdio: iproc_shared_mdio at 6602023c {
+			compatible = "brcm,iproc-shared-mdio";
+			reg = <0x6602023c 0x14>;
+			reg-names = "mdio";
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
 		timer0: timer at 66030000 {
 			compatible = "arm,sp804", "arm,primecell";
 			reg = <0x66030000 0x1000>;
Signature · 1 line
1.9.1
#22 lore raw

PATCH 5/6 Documentation: Binding doc for ethernet master in NS2

In reply to Pramod Kumar

Adding binding doc for ethernet master present in shared MDIO controller.

---
 .../bindings/net/brcm,iproc-mdio-shared.txt        | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt
Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt new file +32 -0
new file mode 100644
index 0000000..1ffdd4b
@@ -0,0 +1,32 @@
+Broadcom Ethernet master for shared mdio controller
+
+Required properties:
+- compatible: must be "brcm,iproc-mdio-master-eth"
+- reg: master id of Ethernet block
+- address-cells: should be 1
+- size-cells: should be 0
+
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
+- reg: the PHY number
+- phy-mode: media type connecting the PHY and MAC.
+
+
+Example:
+	eth-master at 0 {
+		compatible = "brcm,iproc-mdio-master-eth";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gphy0: eth-phy at 10 {
+			reg = <0x10>;
+			phy-mode = "mii";
+		};
+		status = "ok"
+	};
+
+For more info on ethernet phy binding, please,refer to:
+Documentation/devicetree/bindings/net/phy.txt
+Documentation/devicetree/bindings/net/ethernet.txt
Signature · 1 line
1.9.1
maintainer
#23 lore raw

Re: [PATCH 5/6] Documentation: Binding doc for ethernet master in NS2

Quoted 25 lines · Pramod Kumar

Adding binding doc for ethernet master present in shared MDIO controller.

---
 .../bindings/net/brcm,iproc-mdio-shared.txt        | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt
Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt new file +8 -0
new file mode 100644
index 0000000..1ffdd4b
@@ -0,0 +1,32 @@
+Broadcom Ethernet master for shared mdio controller
+
+Required properties:
+- compatible: must be "brcm,iproc-mdio-master-eth"
+- reg: master id of Ethernet block
+- address-cells: should be 1
+- size-cells: should be 0
+

Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt new file +10 -0
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
+- reg: the PHY number
+- phy-mode: media type connecting the PHY and MAC.
+
+
+Example:
+	eth-master at 0 {

Is this a child of something?

Why is this not just an mdio bus underneath the ethernet controller? How is this accessed?

Quoted 17 lines
Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt new file +14 -0
+		compatible = "brcm,iproc-mdio-master-eth";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gphy0: eth-phy at 10 {
+			reg = <0x10>;
+			phy-mode = "mii";
+		};
+		status = "ok"
+	};
+
+For more info on ethernet phy binding, please,refer to:
+Documentation/devicetree/bindings/net/phy.txt
+Documentation/devicetree/bindings/net/ethernet.txt
Signature · 1 line
1.9.1
#24 lore raw

RE: [PATCH 5/6] Documentation: Binding doc for ethernet master in NS2

Hi Rob,

Thanks for review and providing your valuable comments.

Quoted 5 lines

-----Original Message-----
From: Rob Herring [mailto:robh at kernel.org]
Sent: 23 April 2016 01:44
To: Pramod Kumar
Cc: Catalin Marinas; Will Deacon; Masahiro Yamada; Chen-Yu Tsai; BCM

Kernel

Quoted 1 line

Feedback; Pawel Moll; Mark Rutland; Arnd Bergmann; Suzuki K Poulose;

Punit

Quoted 1 line

Agrawal; devicetree at vger.kernel.org;

linux-arm-kernel at lists.infradead.org;

Quoted 2 lines

linux-kernel at vger.kernel.org; netdev at vger.kernel.org
Subject: Re: [PATCH 5/6] Documentation: Binding doc for ethernet master

in

Quoted 36 lines

NS2

Quoted 8 lines · Pramod Kumar

Adding binding doc for ethernet master present in shared MDIO controller.

---
 .../bindings/net/brcm,iproc-mdio-shared.txt        | 32

++++++++++++++++++++++

Quoted 24 lines
 1 file changed, 32 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt

diff --git a/Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt b/Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt new file mode 100644
index 0000000..1ffdd4b

Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt new file +12 -0
@@ -0,0 +1,32 @@
+Broadcom Ethernet master for shared mdio controller
+
+Required properties:
+- compatible: must be "brcm,iproc-mdio-master-eth"
+- reg: master id of Ethernet block
+- address-cells: should be 1
+- size-cells: should be 0
+
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
Quoted 9 lines

Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt line 18

Quoted 6 lines
Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt new file +6 -0
+- reg: the PHY number
+- phy-mode: media type connecting the PHY and MAC.
+
+
+Example:
+	eth-master at 0 {

Is this a child of something?

This is an Shared MDIO master node as described in cover letter and is the child node of iProc_shared_mdio plarform driver.

Quoted 1 line

Why is this not just an mdio bus underneath the ethernet controller? How

is this

Quoted 1 line

accessed?

This is the part for Shared MDIO controller which is shared among other subsystem as well hence defined here. This works as glue layer between This controller and legacy MDIO framework and register the MDIO bus to legacy framework.
When any read/write request is issue from Legacy MDIO controller framework it gets propagated to Shared controller platform driver via this driver and finally platform driver issue MDIO transaction over bus.

Quoted 10 lines
Quoted 10 lines
Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt new file +9 -0
+		compatible = "brcm,iproc-mdio-master-eth";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gphy0: eth-phy at 10 {
+			reg = <0x10>;
+			phy-mode = "mii";
+		};
+		status = "ok"
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/net/brcm,iproc-mdio-shared.txt new file +5 -1
+	};
+
+For more info on ethernet phy binding, please,refer to:
+Documentation/devicetree/bindings/net/phy.txt
+Documentation/devicetree/bindings/net/ethernet.txt
--

1.9.1

Regards,
Pramod

#25 lore raw

PATCH 6/6 net:phy: Add Ethernet Master for iProc Shared MDIO Controller

In reply to Pramod Kumar

Add Ethernet master driver which registers the ethernet phy to standard legacy mdio framework.

---
 drivers/net/phy/Kconfig                 |  11 +++
 drivers/net/phy/Makefile                |   1 +
 drivers/net/phy/mdio-bcm-iproc-shared.c | 116 ++++++++++++++++++++++++++++++++
 3 files changed, 128 insertions(+)
 create mode 100644 drivers/net/phy/mdio-bcm-iproc-shared.c
drivers/net/phy/Kconfig +11 -0
index 6dad9a9..35a7d59 100644
@@ -271,6 +271,17 @@ config MDIO_BCM_IPROC
 	  This module provides a driver for the MDIO busses found in the
 	  Broadcom iProc SoC's.
 
+config MDIO_BCM_IPROC_SHARED
+	tristate "Ethernet Master for Broadcom iProc Shared MDIO Controller"
+	depends on OF && OF_MDIO && (ARCH_BCM_IPROC || COMPILE_TEST)
+	default ARCH_BCM_IPROC
+	help
+	  This module provides a driver for the ethernet master found in
+	  shared MDIO controller in the Broadcom iProc SoC's.
+
+	  Enable this to support the Shared MDIO controller.
+	  if unsure, say N.
+
 endif # PHYLIB
 
 config MICREL_KS8995MA
drivers/net/phy/Makefile +1 -0
index fcdbb92..e1c0bc5 100644
@@ -44,3 +44,4 @@ obj-$(CONFIG_MDIO_MOXART)	+= mdio-moxart.o
 obj-$(CONFIG_MDIO_BCM_UNIMAC)	+= mdio-bcm-unimac.o
 obj-$(CONFIG_MICROCHIP_PHY)	+= microchip.o
 obj-$(CONFIG_MDIO_BCM_IPROC)	+= mdio-bcm-iproc.o
+obj-$(CONFIG_MDIO_BCM_IPROC_SHARED)	+= mdio-bcm-iproc-shared.o
drivers/net/phy/mdio-bcm-iproc-shared.c new file +116 -0

116 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#26 lore raw
In reply to Pramod Kumar
Quoted 7 lines · Pramod Kumar

Broadcom iProc based SoCs uses MDIO bus for programming PHYs belonging to different I/O subsystem like USB, SATA, PCIe, ETHERNET etc. Every subsystem is referred as "Master" When a master is selected, all PHYs belonging to this subsystem get active on the MDIO bus and responds to MDIO transaction. In this way one MDIO controller is shared among all masters hence named as "Shared MDIO controller".

Quoted 7 lines

We have two important entities in "Shared MDIO Bus" framework:
1) shared_mdio_master and
2) shared_mdio_driver.

The shared MDIO controller driver is registered as platform driver and it creates shared_mdio_master instances and adds them to "Shared MDIO Bus" framework.

Hi Pramod

What i'm missing is an explanation why the existing MDIO bus framework cannot be used. I recently made it more generic so that you can hang any type of device off it, not just PHYs.

Thanks
Andrew