From patchwork Wed Apr 5 09:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 670601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40B91C77B6C for ; Wed, 5 Apr 2023 09:27:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237051AbjDEJ1T (ORCPT ); Wed, 5 Apr 2023 05:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237318AbjDEJ1S (ORCPT ); Wed, 5 Apr 2023 05:27:18 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 508BC46B4 for ; Wed, 5 Apr 2023 02:27:16 -0700 (PDT) Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1pjzQ6-0004pA-Oy; Wed, 05 Apr 2023 11:27:10 +0200 From: Marco Felsch Date: Wed, 05 Apr 2023 11:26:59 +0200 Subject: [PATCH 08/12] net: phy: add possibility to specify mdio device parent MIME-Version: 1.0 Message-Id: <20230405-net-next-topic-net-phy-reset-v1-8-7e5329f08002@pengutronix.de> References: <20230405-net-next-topic-net-phy-reset-v1-0-7e5329f08002@pengutronix.de> In-Reply-To: <20230405-net-next-topic-net-phy-reset-v1-0-7e5329f08002@pengutronix.de> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Broadcom internal kernel review list , Richard Cochran , Radu Pirea , Shyam Sundar S K , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , "Rafael J. Wysocki" , Len Brown , Rob Herring , Frank Rowand Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de X-Mailer: b4 0.12.1 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 --- 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;