Hi David,
This patch sets the change to of_phy_connect() that you have seen before,
this time with the full context of why it is useful and applicable here.
Due to some design decision, the internal PHY on Broadcom BCM7xxx chips
is not entirely self contained and does not report its internal revision
through MII_PHYSID2, that is left to external PHY designs.
This forces us to get the PHY revision from the GENET and SF2 switch drivers
because those two peripherals integrate such a PHY and do contain the PHY
revision in their registers.
The approach taken here is hopefully easy to extend to similar needs for
other chips/ as well.
Thanks!
Florian Fainelli (8):
of: mdio: honor flags passed to of_phy_connect
net: phy: broadcom: add helper for PHY revision and patch level
net: phy: bcm7xxx: do not use PHY_BRCM_100MBPS_WAR
net: bcmgenet: remove PHY_BRCM_100MBPS_WAR
net: bcmgenet: communicate integrated PHY revision to PHY driver
net: dsa: allow switch drivers to specify phy_device::dev_flags
net: dsa: bcm_sf2: communicate integrated PHY revision to PHY driver
net: phy: bcm7xxx: utilize PHY revision in config_init
drivers/net/dsa/bcm_sf2.c | 16 ++++++++++++++++
drivers/net/dsa/bcm_sf2.h | 1 +
drivers/net/dsa/bcm_sf2_regs.h | 1 +
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 7 +++++++
drivers/net/ethernet/broadcom/genet/bcmgenet.h | 1 +
drivers/net/ethernet/broadcom/genet/bcmmii.c | 18 ++++++------------
drivers/net/phy/bcm7xxx.c | 25 +++++++++++++++++--------
drivers/of/of_mdio.c | 2 ++
include/linux/brcmphy.h | 3 ++-
include/net/dsa.h | 1 +
net/dsa/slave.c | 9 ++++++++-
11 files changed, 62 insertions(+), 22 deletions(-)
--
1.9.1
Commit f9a8f83b04e0 ("net: phy: remove flags argument from phy_{attach,
connect, connect_direct}") removed the flags argument to the PHY library
calls to: phy_{attach,connect,connect_direct}.
Most Device Tree aware drivers call of_phy_connect() with the flag
argument set to 0, but some of them might want to set a different value
there in order for the PHY driver to key a specific behavior based on
the phy_device::phy_flags value.
Allow such drivers to set custom phy_flags as part of the
of_phy_connect() call since of_phy_connect() does start the PHY state
machine, it will call into the PHY driver config_init() callback which
is usually where a specific phy_flags value is important.
Fixes: f9a8f83b04e0 ("net: phy: remove flags argument from phy_{attach, connect, connect_direct}")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/of/of_mdio.c | 2 ++
1 file changed, 2 insertions(+)
The Broadcom BCM7xxx internal PHYs do not contain any useful revision
information in the low 4-bits of their MII_PHYSID2 (MII register 3)
which could allow us to properly identify them.
As a result, we need the actual hardware block integrating these PHYs:
GENET or the SF2 switch to tell us what revision they are built with. To
assist with that, add two helper macros for fetching the the PHY
revision and patch level from the struct phy_device::dev_flags.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
include/linux/brcmphy.h | 2 ++
1 file changed, 2 insertions(+)
Now that we have removed the need for the PHY_BRCM_100MBPS_WAR flag, we
can remove it from the GENET driver and the broadcom shared header file.
The PHY driver checks the PHY supported bitmask instead.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/broadcom/genet/bcmmii.c | 10 ----------
include/linux/brcmphy.h | 1 -
2 files changed, 11 deletions(-)
@@ -296,7 +296,6 @@ static int bcmgenet_mii_probe(struct net_device *dev)structbcmgenet_priv*priv=netdev_priv(dev);structdevice_node*dn=priv->pdev->dev.of_node;structphy_device*phydev;-unsignedintphy_flags;intret;if(priv->phydev){
@@ -338,15 +337,6 @@ static int bcmgenet_mii_probe(struct net_device *dev)returnret;}-phy_flags=PHY_BRCM_100MBPS_WAR;--/* workarounds are only needed for 100Mpbs PHYs, and-*neveronGENETV1hardware-*/-if((phydev->supported&PHY_GBIT_FEATURES)||GENET_IS_V1(priv))-phy_flags=0;--phydev->dev_flags|=phy_flags;phydev->advertising=phydev->supported;/* The internal PHY has its link interrupts routed to the
There is no need for the PHY driver to check PHY_BRCM_100MBPS_WAR since
that is redundant with checking the PHY device supported features. Get
rid of that workaround flag.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/bcm7xxx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -257,8 +257,8 @@ static int bcm7xxx_config_init(struct phy_device *phydev)phy_write(phydev,MII_BCM7XXX_AUX_MODE,MII_BCM7XX_64CLK_MDIO);phy_read(phydev,MII_BCM7XXX_AUX_MODE);-/* Workaround only required for 100Mbits/sec */-if(!(phydev->dev_flags&PHY_BRCM_100MBPS_WAR))+/* Workaround only required for 100Mbits/sec capable PHYs */+if(phydev->supported&PHY_GBIT_FEATURES)return0;/* set shadow mode 2 */
The integrated BCM7xxx PHY contains no useful revision information in
its MII_PHYSID2 bits 3:0, that information is instead contained in the
GENET hardware block.
We already read the GENET 32-bit revision register, so store the
integrated PHY revision in the driver private structure, and then
communicate this revision value to the PHY driver by overriding the
phy_flags value.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 7 +++++++
drivers/net/ethernet/broadcom/genet/bcmgenet.h | 1 +
drivers/net/ethernet/broadcom/genet/bcmmii.c | 8 ++++++--
3 files changed, 14 insertions(+), 2 deletions(-)
@@ -2432,6 +2432,13 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)dev_info(&priv->pdev->dev,"GENET "GENET_VER_FMT,major,(reg>>16)&0x0f,reg&0xffff);+/* Store the integrated PHY revision for the MDIO probing function+*topassthisinformationtothePHYdriver.ThePHYdriverexpects+*tofindthePHYmajorrevisioninbits15:8whiletheGENETregister+*storesthatinformationinbits7:0,accountforthat.+*/+priv->gphy_rev=(reg&0xffff)<<8;+#ifdef CONFIG_PHYS_ADDR_T_64BITif(!(params->flags&GENET_HAS_40BITS))pr_warn("GENET does not support 40-bits PA\n");
@@ -296,6 +296,7 @@ static int bcmgenet_mii_probe(struct net_device *dev)structbcmgenet_priv*priv=netdev_priv(dev);structdevice_node*dn=priv->pdev->dev.of_node;structphy_device*phydev;+u32phy_flags;intret;if(priv->phydev){
@@ -314,8 +315,11 @@ static int bcmgenet_mii_probe(struct net_device *dev)priv->phy_dn=of_node_get(dn);}-phydev=of_phy_connect(dev,priv->phy_dn,bcmgenet_mii_setup,0,-priv->phy_interface);+/* Communicate the integrated PHY revision */+phy_flags=priv->gphy_rev;++phydev=of_phy_connect(dev,priv->phy_dn,bcmgenet_mii_setup,+phy_flags,priv->phy_interface);if(!phydev){pr_err("could not attach to PHY\n");return-ENODEV;
Some switch drivers (e.g: bcm_sf2) may have to communicate specific
workarounds or flags towards the PHY device driver. Allow switches
driver to be delegated that task by introducing a get_phy_flags()
callback which will do just that.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
include/net/dsa.h | 1 +
net/dsa/slave.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
The integrated BCM7xxx PHY contains no useful revision information
in its MII_PHYSID2 bits 3:0, that information is instead contained in
the SWITCH_REG_PHY_REVISION register.
Read this register, store its value, and return it by implementing the
dsa_switch::get_phy_flags() callback accordingly. The register layout is
already matching what the BCM7xxx PHY driver is expecting to find.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/dsa/bcm_sf2.c | 16 ++++++++++++++++
drivers/net/dsa/bcm_sf2.h | 1 +
drivers/net/dsa/bcm_sf2_regs.h | 1 +
3 files changed, 18 insertions(+)
Now that the GENET and SF2 drivers have been updated to communicate us
what is the revision of the BCM7xxx integrated PHY, utilize that
information in the config_init() callback to call into the appropriate
workaround function based on our revision.
While at it, we also print the revision and patch level to help debug
new chips.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/bcm7xxx.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
This patch sets the change to of_phy_connect() that you have seen before,
this time with the full context of why it is useful and applicable here.
Due to some design decision, the internal PHY on Broadcom BCM7xxx chips
is not entirely self contained and does not report its internal revision
through MII_PHYSID2, that is left to external PHY designs.
This forces us to get the PHY revision from the GENET and SF2 switch drivers
because those two peripherals integrate such a PHY and do contain the PHY
revision in their registers.
The approach taken here is hopefully easy to extend to similar needs for
other chips/ as well.
From: David Miller <davem@davemloft.net> Date: 2014-09-19 19:55:56
From: David Miller <davem@davemloft.net>
Date: Fri, 19 Sep 2014 15:41:04 -0400 (EDT)
Series applied, thanks Florian.
Actually I had to revert:
net/dsa/slave.c: In function ‘dsa_slave_phy_setup’:
net/dsa/slave.c:395:42: error: ‘port’ undeclared (first use in this function)
phy_flags = ds->drv->get_phy_flags(ds, port);
^
net/dsa/slave.c:395:42: note: each undeclared identifier is reported only once for each function it appears in
From: David Miller <davem@davemloft.net>
Date: Fri, 19 Sep 2014 15:41:04 -0400 (EDT)
quoted
Series applied, thanks Florian.
Actually I had to revert:
net/dsa/slave.c: In function ‘dsa_slave_phy_setup’:
net/dsa/slave.c:395:42: error: ‘port’ undeclared (first use in this function)
phy_flags = ds->drv->get_phy_flags(ds, port);
^
net/dsa/slave.c:395:42: note: each undeclared identifier is reported only once for each function it appears in