netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net-next 0/2] platform data controls for mdio-gpio
@ 2018-12-08 15:12 Andrew Lunn
  2018-12-08 15:12 ` [PATCH v2 net-next 1/2] net: phy: mdio-gpio: Add platform_data support for phy_mask Andrew Lunn
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Andrew Lunn @ 2018-12-08 15:12 UTC (permalink / raw)
  To: David Miller; +Cc: Florian Fainelli, Heiner Kallweit, netdev, Andrew Lunn

Soon to be mainlined is an x86 platform with a Marvell switch, and a
bit-banging MDIO bus. In order to make this work, the phy_mask of the
MDIO bus needs to be set to prevent scanning for PHYs, and the
phy_ignore_ta_mask needs to be set because the switch has broken
turnaround.

Add a platform_data structure with these parameters.

Andrew Lunn (2):
  net: phy: mdio-gpio: Add platform_data support for phy_mask
  net: phy: mdio-gpio: Add phy_ignore_ta_mask to platform data

 MAINTAINERS                             |  1 +
 drivers/net/phy/mdio-gpio.c             |  7 +++++++
 include/linux/platform_data/mdio-gpio.h | 14 ++++++++++++++
 3 files changed, 22 insertions(+)
 create mode 100644 include/linux/platform_data/mdio-gpio.h

-- 
2.19.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 net-next 1/2] net: phy: mdio-gpio: Add platform_data support for phy_mask
  2018-12-08 15:12 [PATCH v2 net-next 0/2] platform data controls for mdio-gpio Andrew Lunn
@ 2018-12-08 15:12 ` Andrew Lunn
  2018-12-08 16:57   ` Florian Fainelli
  2018-12-08 15:12 ` [PATCH v2 net-next 2/2] net: phy: mdio-gpio: Add phy_ignore_ta_mask to platform data Andrew Lunn
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2018-12-08 15:12 UTC (permalink / raw)
  To: David Miller; +Cc: Florian Fainelli, Heiner Kallweit, netdev, Andrew Lunn

It is sometimes necessary to instantiate a bit-banging MDIO bus as a
platform device, without the aid of device tree.

When device tree is being used, the bus is not scanned for devices,
only those devices which are in device tree are probed. Without device
tree, by default, all addresses on the bus are scanned. This may then
find a device which is not a PHY, e.g. a switch. And the switch may
have registers containing values which look like a PHY. So during the
scan, a PHY device is wrongly created.

After the bus has been registered, a search is made for
mdio_board_info structures which indicates devices on the bus, and the
driver which should be used for them. This is typically used to
instantiate Ethernet switches from platform drivers.  However, if the
scanning of the bus has created a PHY device at the same location as
indicated into the board info for a switch, the switch device is not
created, since the address is already busy.

This can be avoided by setting the phy_mask of the mdio bus. This mask
prevents addresses on the bus being scanned.

v2
--
int -> u32 in platform data structure

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 MAINTAINERS                             |  1 +
 drivers/net/phy/mdio-gpio.c             |  5 +++++
 include/linux/platform_data/mdio-gpio.h | 13 +++++++++++++
 3 files changed, 19 insertions(+)
 create mode 100644 include/linux/platform_data/mdio-gpio.h

diff --git a/MAINTAINERS b/MAINTAINERS
index fb88b6863d10..9d3b899f9ba2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5610,6 +5610,7 @@ F:	include/linux/of_net.h
 F:	include/linux/phy.h
 F:	include/linux/phy_fixed.h
 F:	include/linux/platform_data/mdio-bcm-unimac.h
+F:	include/linux/platform_data/mdio-gpio.h
 F:	include/trace/events/mdio.h
 F:	include/uapi/linux/mdio.h
 F:	include/uapi/linux/mii.h
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 0fbcedcdf6e2..1e296dd4067a 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -24,6 +24,7 @@
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/platform_data/mdio-gpio.h>
 #include <linux/mdio-bitbang.h>
 #include <linux/mdio-gpio.h>
 #include <linux/gpio/consumer.h>
@@ -112,6 +113,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 					  struct mdio_gpio_info *bitbang,
 					  int bus_id)
 {
+	struct mdio_gpio_platform_data *pdata = dev_get_platdata(dev);
 	struct mii_bus *new_bus;
 
 	bitbang->ctrl.ops = &mdio_gpio_ops;
@@ -128,6 +130,9 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 	else
 		strncpy(new_bus->id, "gpio", MII_BUS_ID_SIZE);
 
+	if (pdata)
+		new_bus->phy_mask = pdata->phy_mask;
+
 	dev_set_drvdata(dev, new_bus);
 
 	return new_bus;
diff --git a/include/linux/platform_data/mdio-gpio.h b/include/linux/platform_data/mdio-gpio.h
new file mode 100644
index 000000000000..a5d5ff5e174c
--- /dev/null
+++ b/include/linux/platform_data/mdio-gpio.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * MDIO-GPIO bus platform data structure
+ */
+
+#ifndef __LINUX_MDIO_GPIO_PDATA_H
+#define __LINUX_MDIO_GPIO_PDATA_H
+
+struct mdio_gpio_platform_data {
+	u32 phy_mask;
+};
+
+#endif /* __LINUX_MDIO_GPIO_PDATA_H */
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 net-next 2/2] net: phy: mdio-gpio: Add phy_ignore_ta_mask to platform data
  2018-12-08 15:12 [PATCH v2 net-next 0/2] platform data controls for mdio-gpio Andrew Lunn
  2018-12-08 15:12 ` [PATCH v2 net-next 1/2] net: phy: mdio-gpio: Add platform_data support for phy_mask Andrew Lunn
@ 2018-12-08 15:12 ` Andrew Lunn
  2018-12-08 16:58   ` Florian Fainelli
  2018-12-08 16:59 ` [PATCH v2 net-next 0/2] platform data controls for mdio-gpio Florian Fainelli
  2018-12-09  5:33 ` David Miller
  3 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2018-12-08 15:12 UTC (permalink / raw)
  To: David Miller; +Cc: Florian Fainelli, Heiner Kallweit, netdev, Andrew Lunn

The Marvell 6390 Ethernet switch family does not perform MDIO
turnaround correctly. Many hardware MDIO bus masters don't care about
this, but the bitbangging implementation in Linux does by default. Add
phy_ignore_ta_mask to the platform data so that the bitbangging code
can be told which devices are known to get TA wrong.

v2
--
int -> u32 in platform data structure

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/mdio-gpio.c             | 4 +++-
 include/linux/platform_data/mdio-gpio.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 1e296dd4067a..ea9a0e339778 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -130,8 +130,10 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 	else
 		strncpy(new_bus->id, "gpio", MII_BUS_ID_SIZE);
 
-	if (pdata)
+	if (pdata) {
 		new_bus->phy_mask = pdata->phy_mask;
+		new_bus->phy_ignore_ta_mask = pdata->phy_ignore_ta_mask;
+	}
 
 	dev_set_drvdata(dev, new_bus);
 
diff --git a/include/linux/platform_data/mdio-gpio.h b/include/linux/platform_data/mdio-gpio.h
index a5d5ff5e174c..13874fa6e767 100644
--- a/include/linux/platform_data/mdio-gpio.h
+++ b/include/linux/platform_data/mdio-gpio.h
@@ -8,6 +8,7 @@
 
 struct mdio_gpio_platform_data {
 	u32 phy_mask;
+	u32 phy_ignore_ta_mask;
 };
 
 #endif /* __LINUX_MDIO_GPIO_PDATA_H */
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 net-next 1/2] net: phy: mdio-gpio: Add platform_data support for phy_mask
  2018-12-08 15:12 ` [PATCH v2 net-next 1/2] net: phy: mdio-gpio: Add platform_data support for phy_mask Andrew Lunn
@ 2018-12-08 16:57   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-12-08 16:57 UTC (permalink / raw)
  To: Andrew Lunn, David Miller; +Cc: Heiner Kallweit, netdev

Le 12/8/18 à 7:12 AM, Andrew Lunn a écrit :
> It is sometimes necessary to instantiate a bit-banging MDIO bus as a
> platform device, without the aid of device tree.
> 
> When device tree is being used, the bus is not scanned for devices,
> only those devices which are in device tree are probed. Without device
> tree, by default, all addresses on the bus are scanned. This may then
> find a device which is not a PHY, e.g. a switch. And the switch may
> have registers containing values which look like a PHY. So during the
> scan, a PHY device is wrongly created.
> 
> After the bus has been registered, a search is made for
> mdio_board_info structures which indicates devices on the bus, and the
> driver which should be used for them. This is typically used to
> instantiate Ethernet switches from platform drivers.  However, if the
> scanning of the bus has created a PHY device at the same location as
> indicated into the board info for a switch, the switch device is not
> created, since the address is already busy.
> 
> This can be avoided by setting the phy_mask of the mdio bus. This mask
> prevents addresses on the bus being scanned.
> 
> v2
> --
> int -> u32 in platform data structure
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 net-next 2/2] net: phy: mdio-gpio: Add phy_ignore_ta_mask to platform data
  2018-12-08 15:12 ` [PATCH v2 net-next 2/2] net: phy: mdio-gpio: Add phy_ignore_ta_mask to platform data Andrew Lunn
@ 2018-12-08 16:58   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-12-08 16:58 UTC (permalink / raw)
  To: Andrew Lunn, David Miller; +Cc: Heiner Kallweit, netdev

Le 12/8/18 à 7:12 AM, Andrew Lunn a écrit :
> The Marvell 6390 Ethernet switch family does not perform MDIO
> turnaround correctly. Many hardware MDIO bus masters don't care about
> this, but the bitbangging implementation in Linux does by default. Add
> phy_ignore_ta_mask to the platform data so that the bitbangging code
> can be told which devices are known to get TA wrong.
> 
> v2
> --
> int -> u32 in platform data structure
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 net-next 0/2] platform data controls for mdio-gpio
  2018-12-08 15:12 [PATCH v2 net-next 0/2] platform data controls for mdio-gpio Andrew Lunn
  2018-12-08 15:12 ` [PATCH v2 net-next 1/2] net: phy: mdio-gpio: Add platform_data support for phy_mask Andrew Lunn
  2018-12-08 15:12 ` [PATCH v2 net-next 2/2] net: phy: mdio-gpio: Add phy_ignore_ta_mask to platform data Andrew Lunn
@ 2018-12-08 16:59 ` Florian Fainelli
  2018-12-09  5:33 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-12-08 16:59 UTC (permalink / raw)
  To: Andrew Lunn, David Miller; +Cc: Heiner Kallweit, netdev

Le 12/8/18 à 7:12 AM, Andrew Lunn a écrit :
> Soon to be mainlined is an x86 platform with a Marvell switch, and a
> bit-banging MDIO bus. In order to make this work, the phy_mask of the
> MDIO bus needs to be set to prevent scanning for PHYs, and the
> phy_ignore_ta_mask needs to be set because the switch has broken
> turnaround.
> 
> Add a platform_data structure with these parameters.

Looks good thanks Andrew. I do wonder if we could define a common
mii_bus_platform_data structure eventually which is comprised of these
two members (if nothing else) and maybe update the common
mdiobus_register() code path to look for these members. If a subsequent
platform data/device MDIO bus shows up we could do that at that time.

Thanks!

> 
> Andrew Lunn (2):
>   net: phy: mdio-gpio: Add platform_data support for phy_mask
>   net: phy: mdio-gpio: Add phy_ignore_ta_mask to platform data
> 
>  MAINTAINERS                             |  1 +
>  drivers/net/phy/mdio-gpio.c             |  7 +++++++
>  include/linux/platform_data/mdio-gpio.h | 14 ++++++++++++++
>  3 files changed, 22 insertions(+)
>  create mode 100644 include/linux/platform_data/mdio-gpio.h
> 


-- 
Florian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 net-next 0/2] platform data controls for mdio-gpio
  2018-12-08 15:12 [PATCH v2 net-next 0/2] platform data controls for mdio-gpio Andrew Lunn
                   ` (2 preceding siblings ...)
  2018-12-08 16:59 ` [PATCH v2 net-next 0/2] platform data controls for mdio-gpio Florian Fainelli
@ 2018-12-09  5:33 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2018-12-09  5:33 UTC (permalink / raw)
  To: andrew; +Cc: f.fainelli, hkallweit1, netdev

From: Andrew Lunn <andrew@lunn.ch>
Date: Sat,  8 Dec 2018 16:12:11 +0100

> Soon to be mainlined is an x86 platform with a Marvell switch, and a
> bit-banging MDIO bus. In order to make this work, the phy_mask of the
> MDIO bus needs to be set to prevent scanning for PHYs, and the
> phy_ignore_ta_mask needs to be set because the switch has broken
> turnaround.
> 
> Add a platform_data structure with these parameters.

Series applied.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-12-09  5:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-08 15:12 [PATCH v2 net-next 0/2] platform data controls for mdio-gpio Andrew Lunn
2018-12-08 15:12 ` [PATCH v2 net-next 1/2] net: phy: mdio-gpio: Add platform_data support for phy_mask Andrew Lunn
2018-12-08 16:57   ` Florian Fainelli
2018-12-08 15:12 ` [PATCH v2 net-next 2/2] net: phy: mdio-gpio: Add phy_ignore_ta_mask to platform data Andrew Lunn
2018-12-08 16:58   ` Florian Fainelli
2018-12-08 16:59 ` [PATCH v2 net-next 0/2] platform data controls for mdio-gpio Florian Fainelli
2018-12-09  5:33 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).