Message ID | 20210921120215.27924-1-zajec5@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [RFC] net: bgmac: improve handling PHY | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | warning | Target tree name not specified in the subject |
netdev/cc_maintainers | warning | 2 maintainers not CCed: kuba@kernel.org davem@davemloft.net |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 54 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
On 9/21/21 5:02 AM, Rafał Miłecki wrote: > From: Rafał Miłecki <rafal@milecki.pl> > > 1. Use info from DT if available > > It allows describing for example a fixed link. It's more accurate than > just guessing there may be one (depending on a chipset). > > 2. Verify PHY ID before trying to connect PHY > > PHY addr 0x1e (30) is special in Broadcom routers and means a switch > connected as MDIO devices instead of a real PHY. Don't try connecting to > it. > > Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Yes this does appear to be a better strategy, you would want to put that in the same patch set that adds support for the "mdio" node container to avoid regressions, thanks! > --- > drivers/net/ethernet/broadcom/bgmac-bcma.c | 33 ++++++++++++++-------- > 1 file changed, 21 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c > index 85fa0ab7201c..e39361042aa1 100644 > --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c > +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c > @@ -11,6 +11,7 @@ > #include <linux/bcma/bcma.h> > #include <linux/brcmphy.h> > #include <linux/etherdevice.h> > +#include <linux/of_mdio.h> > #include <linux/of_net.h> > #include "bgmac.h" > > @@ -86,17 +87,28 @@ static int bcma_phy_connect(struct bgmac *bgmac) > struct phy_device *phy_dev; > char bus_id[MII_BUS_ID_SIZE + 3]; > > + /* DT info should be the most accurate */ > + phy_dev = of_phy_get_and_connect(bgmac->net_dev, bgmac->dev->of_node, > + bgmac_adjust_link); > + if (phy_dev) > + return 0; > + > /* Connect to the PHY */ > - snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, bgmac->mii_bus->id, > - bgmac->phyaddr); > - phy_dev = phy_connect(bgmac->net_dev, bus_id, bgmac_adjust_link, > - PHY_INTERFACE_MODE_MII); > - if (IS_ERR(phy_dev)) { > - dev_err(bgmac->dev, "PHY connection failed\n"); > - return PTR_ERR(phy_dev); > + if (bgmac->mii_bus && bgmac->phyaddr != BGMAC_PHY_NOREGS) { > + snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, bgmac->mii_bus->id, > + bgmac->phyaddr); > + phy_dev = phy_connect(bgmac->net_dev, bus_id, bgmac_adjust_link, > + PHY_INTERFACE_MODE_MII); > + if (IS_ERR(phy_dev)) { > + dev_err(bgmac->dev, "PHY connection failed\n"); > + return PTR_ERR(phy_dev); > + } > + > + return 0; > } > > - return 0; > + /* Assume a fixed link to the switch port */ > + return bgmac_phy_connect_direct(bgmac); > } > > static const struct bcma_device_id bgmac_bcma_tbl[] = { > @@ -295,10 +307,7 @@ static int bgmac_probe(struct bcma_device *core) > bgmac->cco_ctl_maskset = bcma_bgmac_cco_ctl_maskset; > bgmac->get_bus_clock = bcma_bgmac_get_bus_clock; > bgmac->cmn_maskset32 = bcma_bgmac_cmn_maskset32; > - if (bgmac->mii_bus) > - bgmac->phy_connect = bcma_phy_connect; > - else > - bgmac->phy_connect = bgmac_phy_connect_direct; > + bgmac->phy_connect = bcma_phy_connect; > > err = bgmac_enet_probe(bgmac); > if (err) >
diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c index 85fa0ab7201c..e39361042aa1 100644 --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c @@ -11,6 +11,7 @@ #include <linux/bcma/bcma.h> #include <linux/brcmphy.h> #include <linux/etherdevice.h> +#include <linux/of_mdio.h> #include <linux/of_net.h> #include "bgmac.h" @@ -86,17 +87,28 @@ static int bcma_phy_connect(struct bgmac *bgmac) struct phy_device *phy_dev; char bus_id[MII_BUS_ID_SIZE + 3]; + /* DT info should be the most accurate */ + phy_dev = of_phy_get_and_connect(bgmac->net_dev, bgmac->dev->of_node, + bgmac_adjust_link); + if (phy_dev) + return 0; + /* Connect to the PHY */ - snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, bgmac->mii_bus->id, - bgmac->phyaddr); - phy_dev = phy_connect(bgmac->net_dev, bus_id, bgmac_adjust_link, - PHY_INTERFACE_MODE_MII); - if (IS_ERR(phy_dev)) { - dev_err(bgmac->dev, "PHY connection failed\n"); - return PTR_ERR(phy_dev); + if (bgmac->mii_bus && bgmac->phyaddr != BGMAC_PHY_NOREGS) { + snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, bgmac->mii_bus->id, + bgmac->phyaddr); + phy_dev = phy_connect(bgmac->net_dev, bus_id, bgmac_adjust_link, + PHY_INTERFACE_MODE_MII); + if (IS_ERR(phy_dev)) { + dev_err(bgmac->dev, "PHY connection failed\n"); + return PTR_ERR(phy_dev); + } + + return 0; } - return 0; + /* Assume a fixed link to the switch port */ + return bgmac_phy_connect_direct(bgmac); } static const struct bcma_device_id bgmac_bcma_tbl[] = { @@ -295,10 +307,7 @@ static int bgmac_probe(struct bcma_device *core) bgmac->cco_ctl_maskset = bcma_bgmac_cco_ctl_maskset; bgmac->get_bus_clock = bcma_bgmac_get_bus_clock; bgmac->cmn_maskset32 = bcma_bgmac_cmn_maskset32; - if (bgmac->mii_bus) - bgmac->phy_connect = bcma_phy_connect; - else - bgmac->phy_connect = bgmac_phy_connect_direct; + bgmac->phy_connect = bcma_phy_connect; err = bgmac_enet_probe(bgmac); if (err)