aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2014-12-03 12:56:59 -0500
committerDavid S. Miller <davem@davemloft.net>2014-12-08 21:33:29 -0500
commitb04a2f5b9ff5460a0bfbc97c9d6dd0017ad0cbe5 (patch)
tree1b47528e4549c4235c439161283372e65ae8fd5d
parent6db70e3e1d988005c9ae6cf0f023e3c653628efb (diff)
net: bcmgenet: add support for new GENET PHY revision scheme
Starting with GPHY revision G0, the GENET register layout has changed to use the same numbering scheme as the Starfighter 2 switch. This means that GPHY major revision is in bits 15:12, minor in bits 11:8 and patch level is in bits 7:4. Introduce a small heuristic which checks for the old scheme first, tests for the new scheme and finally attempts to catch reserved values and aborts. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index adfef5ca0d55..7078bd386fb7 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2504,6 +2504,7 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)
2504 struct bcmgenet_hw_params *params; 2504 struct bcmgenet_hw_params *params;
2505 u32 reg; 2505 u32 reg;
2506 u8 major; 2506 u8 major;
2507 u16 gphy_rev;
2507 2508
2508 if (GENET_IS_V4(priv)) { 2509 if (GENET_IS_V4(priv)) {
2509 bcmgenet_dma_regs = bcmgenet_dma_regs_v3plus; 2510 bcmgenet_dma_regs = bcmgenet_dma_regs_v3plus;
@@ -2552,8 +2553,29 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)
2552 * to pass this information to the PHY driver. The PHY driver expects 2553 * to pass this information to the PHY driver. The PHY driver expects
2553 * to find the PHY major revision in bits 15:8 while the GENET register 2554 * to find the PHY major revision in bits 15:8 while the GENET register
2554 * stores that information in bits 7:0, account for that. 2555 * stores that information in bits 7:0, account for that.
2556 *
2557 * On newer chips, starting with PHY revision G0, a new scheme is
2558 * deployed similar to the Starfighter 2 switch with GPHY major
2559 * revision in bits 15:8 and patch level in bits 7:0. Major revision 0
2560 * is reserved as well as special value 0x01ff, we have a small
2561 * heuristic to check for the new GPHY revision and re-arrange things
2562 * so the GPHY driver is happy.
2555 */ 2563 */
2556 priv->gphy_rev = (reg & 0xffff) << 8; 2564 gphy_rev = reg & 0xffff;
2565
2566 /* This is the good old scheme, just GPHY major, no minor nor patch */
2567 if ((gphy_rev & 0xf0) != 0)
2568 priv->gphy_rev = gphy_rev << 8;
2569
2570 /* This is the new scheme, GPHY major rolls over with 0x10 = rev G0 */
2571 else if ((gphy_rev & 0xff00) != 0)
2572 priv->gphy_rev = gphy_rev;
2573
2574 /* This is reserved so should require special treatment */
2575 else if (gphy_rev == 0 || gphy_rev == 0x01ff) {
2576 pr_warn("Invalid GPHY revision detected: 0x%04x\n", gphy_rev);
2577 return;
2578 }
2557 2579
2558#ifdef CONFIG_PHYS_ADDR_T_64BIT 2580#ifdef CONFIG_PHYS_ADDR_T_64BIT
2559 if (!(params->flags & GENET_HAS_40BITS)) 2581 if (!(params->flags & GENET_HAS_40BITS))