Commit 04fa26ba authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: phy: mdio-gpio: Add platform_data support for phy_mask

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
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 97ef7b4c
...@@ -5610,6 +5610,7 @@ F: include/linux/of_net.h ...@@ -5610,6 +5610,7 @@ F: include/linux/of_net.h
F: include/linux/phy.h F: include/linux/phy.h
F: include/linux/phy_fixed.h F: include/linux/phy_fixed.h
F: include/linux/platform_data/mdio-bcm-unimac.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/trace/events/mdio.h
F: include/uapi/linux/mdio.h F: include/uapi/linux/mdio.h
F: include/uapi/linux/mii.h F: include/uapi/linux/mii.h
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/platform_data/mdio-gpio.h>
#include <linux/mdio-bitbang.h> #include <linux/mdio-bitbang.h>
#include <linux/mdio-gpio.h> #include <linux/mdio-gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
...@@ -112,6 +113,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev, ...@@ -112,6 +113,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
struct mdio_gpio_info *bitbang, struct mdio_gpio_info *bitbang,
int bus_id) int bus_id)
{ {
struct mdio_gpio_platform_data *pdata = dev_get_platdata(dev);
struct mii_bus *new_bus; struct mii_bus *new_bus;
bitbang->ctrl.ops = &mdio_gpio_ops; bitbang->ctrl.ops = &mdio_gpio_ops;
...@@ -128,6 +130,9 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev, ...@@ -128,6 +130,9 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
else else
strncpy(new_bus->id, "gpio", MII_BUS_ID_SIZE); strncpy(new_bus->id, "gpio", MII_BUS_ID_SIZE);
if (pdata)
new_bus->phy_mask = pdata->phy_mask;
dev_set_drvdata(dev, new_bus); dev_set_drvdata(dev, new_bus);
return new_bus; return new_bus;
......
/* 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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment