Add the possibility to override the mdiodev parent device. This is
required for the TJA1102 dual-port phy where the 2nd port uses the first
port device.
Signed-off-by: Marco Felsch <[email protected]>
---
drivers/net/phy/phy_device.c | 2 +-
include/linux/phy.h | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index a784ac06e6a9..30b3ac9818b1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -642,7 +642,7 @@ static struct phy_device *phy_device_alloc(struct phy_device_config *config)
return ERR_PTR(-ENOMEM);
mdiodev = &dev->mdio;
- mdiodev->dev.parent = &bus->dev;
+ mdiodev->dev.parent = config->parent_mdiodev ? : &bus->dev;
mdiodev->dev.bus = &mdio_bus_type;
mdiodev->dev.type = &mdio_bus_phy_type;
mdiodev->bus = bus;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index bdf6d27faefb..d7aea8622a95 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -760,6 +760,8 @@ static inline struct phy_device *to_phy_device(const struct device *dev)
* struct phy_device_config - Configuration of a PHY
*
* @mii_bus: The target MII bus the PHY is connected to
+ * @parent_mdiodev: Set the MDIO device parent if specified else mii_bus->dev is
+ * used as parent.
* @phy_addr: PHY address on the MII bus
* @fwnode: The PHY firmware handle
* @phy_id: UID for this device found during discovery
@@ -774,6 +776,7 @@ static inline struct phy_device *to_phy_device(const struct device *dev)
struct phy_device_config {
struct mii_bus *mii_bus;
+ struct device *parent_mdiodev;
int phy_addr;
struct fwnode_handle *fwnode;
u32 phy_id;
--
2.39.2