From: Jeremy Linton <jeremy.linton@arm.com>
To: netdev@vger.kernel.org
Cc: opendmb@gmail.com, f.fainelli@gmail.com, davem@davemloft.net,
bcm-kernel-feedback-list@broadcom.com,
linux-kernel@vger.kernel.org, wahrenst@gmx.net, andrew@lunn.ch,
hkallweit1@gmail.com, Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH 2/6] net: bcmgenet: refactor phy mode configuration
Date: Sat, 1 Feb 2020 01:46:21 -0600 [thread overview]
Message-ID: <20200201074625.8698-3-jeremy.linton@arm.com> (raw)
In-Reply-To: <20200201074625.8698-1-jeremy.linton@arm.com>
The DT phy mode is similar to what we want for ACPI
lets factor it out of the of path, and change the
of_ call to device_. Further if the phy-mode property
cannot be found instead of failing the driver load lets
just default it to RGMII.
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
drivers/net/ethernet/broadcom/genet/bcmmii.c | 39 +++++++++++---------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 6392a2530183..2049f8218589 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -477,12 +477,30 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv)
return ret;
}
+static int bcmgenet_phy_interface_init(struct bcmgenet_priv *priv)
+{
+ struct device *kdev = &priv->pdev->dev;
+
+ priv->phy_interface = device_get_phy_mode(kdev);
+ if (priv->phy_interface < 0) {
+ dev_dbg(kdev, "invalid PHY mode property\n");
+ priv->phy_interface = PHY_INTERFACE_MODE_RGMII;
+ }
+
+ /* We need to specifically look up whether this PHY interface is internal
+ * or not *before* we even try to probe the PHY driver over MDIO as we
+ * may have shut down the internal PHY for power saving purposes.
+ */
+ if (priv->phy_interface == PHY_INTERFACE_MODE_INTERNAL)
+ priv->internal_phy = true;
+
+ return 0;
+}
+
static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
{
struct device_node *dn = priv->pdev->dev.of_node;
- struct device *kdev = &priv->pdev->dev;
struct phy_device *phydev;
- phy_interface_t phy_mode;
int ret;
/* Fetch the PHY phandle */
@@ -500,23 +518,10 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
}
/* Get the link mode */
- ret = of_get_phy_mode(dn, &phy_mode);
- if (ret) {
- dev_err(kdev, "invalid PHY mode property\n");
- return ret;
- }
-
- priv->phy_interface = phy_mode;
-
- /* We need to specifically look up whether this PHY interface is internal
- * or not *before* we even try to probe the PHY driver over MDIO as we
- * may have shut down the internal PHY for power saving purposes.
- */
- if (priv->phy_interface == PHY_INTERFACE_MODE_INTERNAL)
- priv->internal_phy = true;
+ bcmgenet_phy_interface_init(priv);
/* Make sure we initialize MoCA PHYs with a link down */
- if (phy_mode == PHY_INTERFACE_MODE_MOCA) {
+ if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
phydev = of_phy_find_device(dn);
if (phydev) {
phydev->link = 0;
--
2.24.1
next prev parent reply other threads:[~2020-02-01 7:46 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-01 7:46 [PATCH 0/6] Add ACPI bindings to the genet Jeremy Linton
2020-02-01 7:46 ` [PATCH 1/6] mdio_bus: Add generic mdio_find_bus() Jeremy Linton
2020-02-01 7:46 ` Jeremy Linton [this message]
2020-02-01 16:24 ` [PATCH 2/6] net: bcmgenet: refactor phy mode configuration Florian Fainelli
2020-02-01 19:10 ` Jeremy Linton
2020-02-03 1:17 ` Andrew Lunn
2020-02-03 3:24 ` Florian Fainelli
2020-02-03 18:46 ` Jeremy Linton
2020-02-03 18:55 ` Florian Fainelli
2020-02-05 21:05 ` kbuild test robot
2020-02-01 7:46 ` [PATCH 3/6] net: bcmgenet: enable automatic phy discovery Jeremy Linton
2020-02-01 15:25 ` Andrew Lunn
2020-02-01 19:07 ` Jeremy Linton
2020-02-03 20:55 ` Florian Fainelli
2020-02-03 21:21 ` Andrew Lunn
2020-02-01 20:02 ` Jeremy Linton
2020-02-03 1:15 ` Andrew Lunn
2020-02-03 21:10 ` Jeremy Linton
2020-02-01 7:46 ` [PATCH 4/6] net: bcmgenet: Initial bcmgenet ACPI support Jeremy Linton
2020-02-01 15:33 ` Andrew Lunn
2020-02-01 19:09 ` Jeremy Linton
2020-02-01 7:46 ` [PATCH 5/6] net: bcmgenet: Fetch MAC address from the adapter Jeremy Linton
2020-02-01 15:37 ` Andrew Lunn
2020-02-01 19:20 ` Jeremy Linton
2020-02-01 7:46 ` [PATCH 6/6] net: bcmgenet: reduce severity of missing clock warnings Jeremy Linton
2020-02-01 16:18 ` Florian Fainelli
2020-02-01 16:44 ` Stefan Wahren
2020-02-01 19:27 ` Jeremy Linton
2020-02-03 18:36 ` Nicolas Saenz Julienne
2020-02-03 19:08 ` Stefan Wahren
2020-02-03 21:21 ` Florian Fainelli
2020-02-05 18:42 ` Stefan Wahren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200201074625.8698-3-jeremy.linton@arm.com \
--to=jeremy.linton@arm.com \
--cc=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=opendmb@gmail.com \
--cc=wahrenst@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).