@@ -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;
@@ -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;
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(-)