| 1 | From 85e4551e033df7cb043e93042661fc1e58799efa Mon Sep 17 00:00:00 2001 |
| 2 | From: Jonas Gorski <jonas.gorski@gmail.com> |
| 3 | Date: Sun, 8 Jul 2012 15:36:23 +0200 |
| 4 | Subject: [PATCH 52/84] BCM63XX: use port id for deciding external phy |
| 5 | |
| 6 | Ports 0-3 always use the internal phy, while 4+ always need an external |
| 7 | phy to work. |
| 8 | --- |
| 9 | .../include/asm/mach-bcm63xx/bcm63xx_dev_enet.h | 3 ++- |
| 10 | drivers/net/ethernet/broadcom/bcm63xx_enet.c | 15 ++++++++------- |
| 11 | drivers/net/ethernet/broadcom/bcm63xx_enet.h | 5 +++++ |
| 12 | 3 files changed, 15 insertions(+), 8 deletions(-) |
| 13 | |
| 14 | --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h |
| 15 | +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h |
| 16 | @@ -45,9 +45,10 @@ struct bcm63xx_enet_platform_data { |
| 17 | #define ENETSW_MAX_PORT 6 |
| 18 | #define ENETSW_PORTS_6368 6 /* 4 FE PHY + 2 RGMII */ |
| 19 | |
| 20 | +#define ENETSW_RGMII_PORT0 4 |
| 21 | + |
| 22 | struct bcm63xx_enetsw_port { |
| 23 | int used; |
| 24 | - int external_phy; |
| 25 | int phy_id; |
| 26 | |
| 27 | int bypass_link; |
| 28 | --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c |
| 29 | +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c |
| 30 | @@ -2046,6 +2046,7 @@ static void swphy_poll_timer(unsigned lo |
| 31 | for (i = 0; i < priv->num_ports; i++) { |
| 32 | struct bcm63xx_enetsw_port *port; |
| 33 | int val, j, up, advertise, lpa, lpa2, speed, duplex, media; |
| 34 | + int external_phy = bcm_enet_port_is_rgmii(i); |
| 35 | u8 override; |
| 36 | |
| 37 | port = &priv->used_ports[i]; |
| 38 | @@ -2057,7 +2058,7 @@ static void swphy_poll_timer(unsigned lo |
| 39 | |
| 40 | /* dummy read to clear */ |
| 41 | for (j = 0; j < 2; j++) |
| 42 | - val = bcmenet_sw_mdio_read(priv, port->external_phy, |
| 43 | + val = bcmenet_sw_mdio_read(priv, external_phy, |
| 44 | port->phy_id, MII_BMSR); |
| 45 | |
| 46 | if (val == 0xffff) |
| 47 | @@ -2081,14 +2082,14 @@ static void swphy_poll_timer(unsigned lo |
| 48 | continue; |
| 49 | } |
| 50 | |
| 51 | - advertise = bcmenet_sw_mdio_read(priv, port->external_phy, |
| 52 | + advertise = bcmenet_sw_mdio_read(priv, external_phy, |
| 53 | port->phy_id, MII_ADVERTISE); |
| 54 | |
| 55 | - lpa = bcmenet_sw_mdio_read(priv, port->external_phy, |
| 56 | - port->phy_id, MII_LPA); |
| 57 | + lpa = bcmenet_sw_mdio_read(priv, external_phy, port->phy_id, |
| 58 | + MII_LPA); |
| 59 | |
| 60 | - lpa2 = bcmenet_sw_mdio_read(priv, port->external_phy, |
| 61 | - port->phy_id, MII_STAT1000); |
| 62 | + lpa2 = bcmenet_sw_mdio_read(priv, external_phy, port->phy_id, |
| 63 | + MII_STAT1000); |
| 64 | |
| 65 | /* figure out media and duplex from advertise and LPA values */ |
| 66 | media = mii_nway_result(lpa & advertise); |
| 67 | @@ -2457,7 +2458,7 @@ static int bcm_enetsw_phy_is_external(st |
| 68 | if (!priv->used_ports[i].used) |
| 69 | continue; |
| 70 | if (priv->used_ports[i].phy_id == phy_id) |
| 71 | - return priv->used_ports[i].external_phy; |
| 72 | + return bcm_enet_port_is_rgmii(i); |
| 73 | } |
| 74 | |
| 75 | printk_once(KERN_WARNING "bcm63xx_enet: could not find a used port " |
| 76 | --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.h |
| 77 | +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.h |
| 78 | @@ -365,4 +365,9 @@ struct bcm_enet_priv { |
| 79 | spinlock_t enetsw_mdio_lock; |
| 80 | }; |
| 81 | |
| 82 | +static inline int bcm_enet_port_is_rgmii(int portid) |
| 83 | +{ |
| 84 | + return portid >= ENETSW_RGMII_PORT0; |
| 85 | +} |
| 86 | + |
| 87 | #endif /* ! BCM63XX_ENET_H_ */ |
| 88 | |