diff mbox series

[08/12] net: phy: add possibility to specify mdio device parent

Message ID 20230405-net-next-topic-net-phy-reset-v1-8-7e5329f08002@pengutronix.de
State New
Headers show
Series Rework PHY reset handling | expand

Commit Message

Marco Felsch April 5, 2023, 9:26 a.m. UTC
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 <m.felsch@pengutronix.de>
---
 drivers/net/phy/phy_device.c | 2 +-
 include/linux/phy.h          | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

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;