From patchwork Wed Apr 20 12:40:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 12820184 X-Patchwork-Delegate: kuba@kernel.org 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 7D9D1C433FE for ; Wed, 20 Apr 2022 13:00:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378676AbiDTNCx (ORCPT ); Wed, 20 Apr 2022 09:02:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353465AbiDTNCw (ORCPT ); Wed, 20 Apr 2022 09:02:52 -0400 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A112313E8F; Wed, 20 Apr 2022 06:00:05 -0700 (PDT) Received: from localhost.localdomain (36-229-224-240.dynamic-ip.hinet.net [36.229.224.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 73B6A3FA13; Wed, 20 Apr 2022 12:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1650458471; bh=IuGCtf3zsB/O4RdOMcLBokmiioeblM6BUDmAgq58MJg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=muLIKpoXBwJKSydkivyRZuCnkKzuV8fu+vL1nKSK5mcu0Vy1xZr0/ve2M3OrxkTTj zMPerWxBgytunUxAT6t05LFZI6CAQJEJGWawlW7VUSInDb/HjCHx2defOP5MqGVAhk +rHf7Mz1NDDk1JLnJAO2bs77Cmi4srGXJaZnRHg4yINLnB6mHlFHxgp9nSeThlYp37 wZeaOwfA9aNDnAiu832x9ORIwdc0w/5SOL9ktByRKWC4B9s677nAfQlVj0CTz1itGp +8okbfi7tWECHrZqsMt/vLmJclKGhMIegl4q/l0Gk652iDInsLg/REDO7+9THcIebZ G+MQdgVfizhgw== From: Kai-Heng Feng To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: Kai-Heng Feng , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] net: mdio: Mask PHY only when its ACPI node is present Date: Wed, 20 Apr 2022 20:40:48 +0800 Message-Id: <20220420124053.853891-2-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420124053.853891-1-kai.heng.feng@canonical.com> References: <20220420124053.853891-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Not all PHY has an ACPI node, for those nodes auto probing is still needed. So only mask those PHYs with ACPI nodes. Signed-off-by: Kai-Heng Feng --- drivers/net/mdio/acpi_mdio.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c index d77c987fda9cd..f9369319ada19 100644 --- a/drivers/net/mdio/acpi_mdio.c +++ b/drivers/net/mdio/acpi_mdio.c @@ -33,8 +33,15 @@ int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode) u32 addr; int ret; - /* Mask out all PHYs from auto probing. */ - mdio->phy_mask = GENMASK(31, 0); + /* Loop over the child nodes and mask out PHY from auto probing */ + fwnode_for_each_child_node(fwnode, child) { + ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr); + if (ret || addr >= PHY_MAX_ADDR) + continue; + + mdio->phy_mask |= BIT(addr); + } + ret = mdiobus_register(mdio); if (ret) return ret; From patchwork Wed Apr 20 12:40:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 12820187 X-Patchwork-Delegate: kuba@kernel.org 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 CEA5FC433EF for ; Wed, 20 Apr 2022 13:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378692AbiDTNC5 (ORCPT ); Wed, 20 Apr 2022 09:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353831AbiDTNCw (ORCPT ); Wed, 20 Apr 2022 09:02:52 -0400 X-Greylist: delayed 1132 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 20 Apr 2022 06:00:05 PDT Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8784B13E0B; Wed, 20 Apr 2022 06:00:05 -0700 (PDT) Received: from localhost.localdomain (36-229-224-240.dynamic-ip.hinet.net [36.229.224.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 8C4833FA42; Wed, 20 Apr 2022 12:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1650458476; bh=/DaWrz00GeCdKC/jBwXJP0sO2B3OU8ZY2ztBd4prWu4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hkgJgkJJngylqyfUc6lVGz7ZtwxbhMpJRH1mg1fssA9wiI2Foi2AljyQJBE5tpCaG r7e0IKEs7EGbBNEA69/YwH2wDgRf0SMn/qar7CfKdQSTWc+r3GTu1Uf2DE//WDDNod ycynC+GkenJ3M4fEWWnr2U/7LJSNoTK3khWLUhfdXKr+axMEYhT4WftDLJlxQ5kS4I tt+0XxGNdMN7NEst41uXaok5EPrathr12ggX54NPw2YztJ1vfTZR4Lcb1PGve9Fy3O ISKI+NA3M8C4wf9XuBye1b+e7fe+umH8rh+gZyGJl26+VMohQedILkq3TkoupXHnO2 s0c2w8BcG2iNQ== From: Kai-Heng Feng To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: Kai-Heng Feng , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] net: mdio: Add "use-firmware-led" firmware property Date: Wed, 20 Apr 2022 20:40:49 +0800 Message-Id: <20220420124053.853891-3-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420124053.853891-1-kai.heng.feng@canonical.com> References: <20220420124053.853891-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some system may prefer preset PHY LED setting instead of the one hardcoded in the PHY driver, so adding a new firmware property, "use-firmware-led", to cope with that. On ACPI based system the ASL looks like this: Scope (_SB.PC00.OTN0) { Device (PHY0) { Name (_ADR, One) // _ADR: Address Name (_DSD, Package (0x02) // _DSD: Device-Specific Data { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */, Package (0x01) { Package (0x02) { "use-firmware-led", One } } }) } Name (_DSD, Package (0x02) // _DSD: Device-Specific Data { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */, Package (0x01) { Package (0x02) { "phy-handle", PHY0 } } }) } Basically use the "phy-handle" reference to read the "use-firmware-led" boolean. Signed-off-by: Kai-Heng Feng --- drivers/net/mdio/fwnode_mdio.c | 4 ++++ include/linux/phy.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index 1c1584fca6327..bfca67b42164b 100644 --- a/drivers/net/mdio/fwnode_mdio.c +++ b/drivers/net/mdio/fwnode_mdio.c @@ -144,6 +144,10 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, */ if (mii_ts) phy->mii_ts = mii_ts; + + phy->use_firmware_led = + fwnode_property_read_bool(child, "use-firmware-led"); + return 0; } EXPORT_SYMBOL(fwnode_mdiobus_register_phy); diff --git a/include/linux/phy.h b/include/linux/phy.h index 36ca2b5c22533..53e693b3430ec 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -656,6 +656,7 @@ struct phy_device { /* Energy efficient ethernet modes which should be prohibited */ u32 eee_broken_modes; + bool use_firmware_led; #ifdef CONFIG_LED_TRIGGER_PHY struct phy_led_trigger *phy_led_triggers; unsigned int phy_num_led_triggers; From patchwork Wed Apr 20 12:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 12820185 X-Patchwork-Delegate: kuba@kernel.org 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 2B78FC433EF for ; Wed, 20 Apr 2022 13:00:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378681AbiDTNCz (ORCPT ); Wed, 20 Apr 2022 09:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353867AbiDTNCw (ORCPT ); Wed, 20 Apr 2022 09:02:52 -0400 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A139813EB8; Wed, 20 Apr 2022 06:00:05 -0700 (PDT) Received: from localhost.localdomain (36-229-224-240.dynamic-ip.hinet.net [36.229.224.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id AE6313F151; Wed, 20 Apr 2022 12:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1650458481; bh=VntAryp7pHS3IpGhF1ep2QtdusC6JspGmTfDst4i0T0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bcq9fWIS45Ke4/bGsBi2ya90q7vx4PUBxQ0Rb2jKYjZK2ysKAu+z08ubBuQ7nd7tU /zToGHu9RMwbv572gaa6c3ynEDBAW+0iNCR5n8t6UYTx1voSItZt+nshR8/vNDA6My Pt9+p0yfFCla4Xcln9vGb50Gyty0E76uQeqQJApZeT6aHN3Q8zd0mwkptA0h/XZdSK ifDgSlzASR9navM2IbkumU7ixyGMy2Tl1J3z5Aozj0dz+nOdvQdrn3WU98YHG0vn0r 1Dokb624F+D2nJfJD0ztHQKTlhm9KRiw+RpydmvAaR8v1QU7cQFCAptn19+4C8+m4h rvoZy4fntC2Ng== From: Kai-Heng Feng To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: Kai-Heng Feng , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] net: phy: Add helpers to save and restore firmware LED Date: Wed, 20 Apr 2022 20:40:50 +0800 Message-Id: <20220420124053.853891-4-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420124053.853891-1-kai.heng.feng@canonical.com> References: <20220420124053.853891-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org PHY drivers may set hardcoded LED config in phy_init_hw(), so to preserve the firmware LED after init or system sleep, it needs to be saved before init and be restored after. To do so, create helpers and driver callbacks to access and save LED config for the need. Signed-off-by: Kai-Heng Feng --- drivers/net/phy/phy_device.c | 22 ++++++++++++++++++++++ include/linux/phy.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8406ac739def8..33b402279febe 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1154,6 +1154,24 @@ static int phy_poll_reset(struct phy_device *phydev) return 0; } +static void phy_save_led(struct phy_device *phydev) +{ + if (!phydev->use_firmware_led) + return; + + if (phydev->drv->get_led_config) + phydev->led_config = phydev->drv->get_led_config(phydev); +} + +static void phy_restore_led(struct phy_device *phydev) +{ + if (!phydev->use_firmware_led) + return; + + if (phydev->drv->set_led_config && phydev->led_config) + phydev->drv->set_led_config(phydev, phydev->led_config); +} + int phy_init_hw(struct phy_device *phydev) { int ret = 0; @@ -1463,6 +1481,8 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, if (dev) netif_carrier_off(phydev->attached_dev); + phy_save_led(phydev); + /* Do initial configuration here, now that * we have certain key parameters * (dev_flags and interface) @@ -1803,6 +1823,8 @@ int __phy_resume(struct phy_device *phydev) if (!ret) phydev->suspended = false; + phy_restore_led(phydev); + return ret; } EXPORT_SYMBOL(__phy_resume); diff --git a/include/linux/phy.h b/include/linux/phy.h index 53e693b3430ec..cd9c05ff75ee1 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -657,6 +657,7 @@ struct phy_device { u32 eee_broken_modes; bool use_firmware_led; + int led_config; #ifdef CONFIG_LED_TRIGGER_PHY struct phy_led_trigger *phy_led_triggers; unsigned int phy_num_led_triggers; @@ -933,6 +934,9 @@ struct phy_driver { int (*get_sqi)(struct phy_device *dev); /** @get_sqi_max: Get the maximum signal quality indication */ int (*get_sqi_max)(struct phy_device *dev); + + int (*get_led_config)(struct phy_device *dev); + void (*set_led_config)(struct phy_device *dev, int led_config); }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) From patchwork Wed Apr 20 12:40:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 12820186 X-Patchwork-Delegate: kuba@kernel.org 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 EF888C4332F for ; Wed, 20 Apr 2022 13:00:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378687AbiDTNC5 (ORCPT ); Wed, 20 Apr 2022 09:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353788AbiDTNCw (ORCPT ); Wed, 20 Apr 2022 09:02:52 -0400 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EF0D13E26; Wed, 20 Apr 2022 06:00:05 -0700 (PDT) Received: from localhost.localdomain (36-229-224-240.dynamic-ip.hinet.net [36.229.224.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id B2A143FA44; Wed, 20 Apr 2022 12:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1650458486; bh=fXMvSxrY2aODO0+qKp3eX7m9XPpjBPG2a64kKMSOZyQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OXnXrirEZez7fYw9oGdYhn+wnVci61w3zyuSi1uSYiyxWdF9k6G2DDaUhzrGLDv4Z hYQuE5hsqsFpT6qBGd2W/N8cqAJ+DFlH5gwPzEP8r4RmilYsBkLbXxogpxoYiZTmts FzS4QUm+L8CkKWXEWvyrhHz1geIpQidMmRut6ILmLQ+6I1EBigH7U+La7aseJZ0VlD kNrXUOG1uNnMw431VhKpraTcfnKA9wFvRX2BpX3bBG2DndYdeGiYj46ZaZbU6eDkpi 2LdUAw9NmJ6GmWy4Tl+MeLGG3v0Soi1oLU3UuPdWmykeO9wG4QtMjko+6y/HABOL6j gYVbpQoibvyDQ== From: Kai-Heng Feng To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: Kai-Heng Feng , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] net: phy: marvell: Add LED accessors for Marvell 88E1510 Date: Wed, 20 Apr 2022 20:40:51 +0800 Message-Id: <20220420124053.853891-5-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420124053.853891-1-kai.heng.feng@canonical.com> References: <20220420124053.853891-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Implement get_led_config() and set_led_config() callbacks so phy core can use firmware LED as platform requested. Signed-off-by: Kai-Heng Feng --- drivers/net/phy/marvell.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 2702faf7b0f60..c5f13e09b0692 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -750,6 +750,30 @@ static int m88e1510_config_aneg(struct phy_device *phydev) return err; } +static int marvell_get_led_config(struct phy_device *phydev) +{ + int led; + + led = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL); + if (led < 0) { + phydev_warn(phydev, "Fail to get marvell phy LED.\n"); + led = 0; + } + + return led; +} + +static void marvell_set_led_config(struct phy_device *phydev, int led_config) +{ + int err; + + err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL, + led_config); + + if (err < 0) + phydev_warn(phydev, "Fail to set marvell phy LED.\n"); +} + static void marvell_config_led(struct phy_device *phydev) { u16 def_config; @@ -3139,6 +3163,8 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .get_led_config = marvell_get_led_config, + .set_led_config = marvell_set_led_config, }, { .phy_id = MARVELL_PHY_ID_88E1540, From patchwork Wed Apr 20 12:40:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 12820183 X-Patchwork-Delegate: kuba@kernel.org 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 75DBBC433EF for ; Wed, 20 Apr 2022 13:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355599AbiDTNCw (ORCPT ); Wed, 20 Apr 2022 09:02:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343572AbiDTNCw (ORCPT ); Wed, 20 Apr 2022 09:02:52 -0400 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 957D413E1E; Wed, 20 Apr 2022 06:00:05 -0700 (PDT) Received: from localhost.localdomain (36-229-224-240.dynamic-ip.hinet.net [36.229.224.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id D00893FA47; Wed, 20 Apr 2022 12:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1650458492; bh=SKjQnef4t+NYwjHc80rBUTUJdxxhm2rF2h/H64pus8k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aVhDslsDfu3NINdHmfYaY9uRiLennv/4jmsXRqZgK1SAGKGJNEgdwCf6h6BNXSBZD G+2PcfrUYj2iywGzbxDa4CjMQDc9K308UBX9w4H2LzeMMxgey0nOLodqVOUYT2vVg/ WwVuLU54sOAgdl/GT9DvN3V2M0XnHwtnw4fqpJRsdh1nKLsI2ATK6rrc1TPD2Ehkfl NCFWADZEEXI3uP2eI8fCx4kyTQ5Tp85rSN2hKQOdnxhPkRlUPzE0HWdrG3ZztMexml KO+XzChdIMV/zng9m06yJYOUETKIkuth8Yn0TDbxr6t1FJhVW91YWbcPiO1TJ8MAg9 TG312LAp8n8Ow== From: Kai-Heng Feng To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: Kai-Heng Feng , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] net: stmmac: Use acpi_mdiobus_register() for ACPI based system Date: Wed, 20 Apr 2022 20:40:52 +0800 Message-Id: <20220420124053.853891-6-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420124053.853891-1-kai.heng.feng@canonical.com> References: <20220420124053.853891-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Child nodes of stmmac ACPI node may have additional properties that the PHY layer can use. To achieve that, use acpi_mdiobus_register() to find PHY nodes references via "phy-handle", so the properties of PHY nodes can be used by the PHY layer. Signed-off-by: Kai-Heng Feng --- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index a5d150c5f3d8c..37cebd8f2ec5c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -10,6 +10,8 @@ Maintainer: Giuseppe Cavallaro *******************************************************************************/ +#include +#include #include #include #include @@ -445,6 +447,7 @@ int stmmac_mdio_register(struct net_device *ndev) struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; struct device_node *mdio_node = priv->plat->mdio_node; struct device *dev = ndev->dev.parent; + struct fwnode_handle *fwnode = dev->fwnode; int addr, found, max_addr; if (!mdio_bus_data) @@ -488,7 +491,10 @@ int stmmac_mdio_register(struct net_device *ndev) new_bus->phy_mask = mdio_bus_data->phy_mask; new_bus->parent = priv->device; - err = of_mdiobus_register(new_bus, mdio_node); + if (is_acpi_node(fwnode)) + err = acpi_mdiobus_register(new_bus, fwnode); + else + err = of_mdiobus_register(new_bus, mdio_node); if (err != 0) { dev_err(dev, "Cannot register the MDIO bus\n"); goto bus_register_fail;