diff options
| author | Ingo Molnar <mingo@elte.hu> | 2008-07-21 09:06:09 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-07-21 09:06:09 -0400 |
| commit | e66d90fb4abd0a27ee96f57a32fb561221c4d6ae (patch) | |
| tree | 3337cba94c7444b06fdb0e8b487287d07b71f4a0 /drivers/net/phy/broadcom.c | |
| parent | 55ca089e2579de90f048aca2a3030b8b2f864813 (diff) | |
| parent | 14b395e35d1afdd8019d11b92e28041fad591b71 (diff) | |
Merge branch 'linus' into xen-64bit
Diffstat (limited to 'drivers/net/phy/broadcom.c')
| -rw-r--r-- | drivers/net/phy/broadcom.c | 201 |
1 files changed, 199 insertions, 2 deletions
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index 60c5cfe96918..4b4dc98ad165 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c | |||
| @@ -24,6 +24,12 @@ | |||
| 24 | #define MII_BCM54XX_ESR 0x11 /* BCM54xx extended status register */ | 24 | #define MII_BCM54XX_ESR 0x11 /* BCM54xx extended status register */ |
| 25 | #define MII_BCM54XX_ESR_IS 0x1000 /* Interrupt status */ | 25 | #define MII_BCM54XX_ESR_IS 0x1000 /* Interrupt status */ |
| 26 | 26 | ||
| 27 | #define MII_BCM54XX_EXP_DATA 0x15 /* Expansion register data */ | ||
| 28 | #define MII_BCM54XX_EXP_SEL 0x17 /* Expansion register select */ | ||
| 29 | #define MII_BCM54XX_EXP_SEL_SSD 0x0e00 /* Secondary SerDes select */ | ||
| 30 | #define MII_BCM54XX_EXP_SEL_ER 0x0f00 /* Expansion register select */ | ||
| 31 | |||
| 32 | #define MII_BCM54XX_AUX_CTL 0x18 /* Auxiliary control register */ | ||
| 27 | #define MII_BCM54XX_ISR 0x1a /* BCM54xx interrupt status register */ | 33 | #define MII_BCM54XX_ISR 0x1a /* BCM54xx interrupt status register */ |
| 28 | #define MII_BCM54XX_IMR 0x1b /* BCM54xx interrupt mask register */ | 34 | #define MII_BCM54XX_IMR 0x1b /* BCM54xx interrupt mask register */ |
| 29 | #define MII_BCM54XX_INT_CRCERR 0x0001 /* CRC error */ | 35 | #define MII_BCM54XX_INT_CRCERR 0x0001 /* CRC error */ |
| @@ -42,10 +48,120 @@ | |||
| 42 | #define MII_BCM54XX_INT_MDIX 0x2000 /* MDIX status change */ | 48 | #define MII_BCM54XX_INT_MDIX 0x2000 /* MDIX status change */ |
| 43 | #define MII_BCM54XX_INT_PSERR 0x4000 /* Pair swap error */ | 49 | #define MII_BCM54XX_INT_PSERR 0x4000 /* Pair swap error */ |
| 44 | 50 | ||
| 51 | #define MII_BCM54XX_SHD 0x1c /* 0x1c shadow registers */ | ||
| 52 | #define MII_BCM54XX_SHD_WRITE 0x8000 | ||
| 53 | #define MII_BCM54XX_SHD_VAL(x) ((x & 0x1f) << 10) | ||
| 54 | #define MII_BCM54XX_SHD_DATA(x) ((x & 0x3ff) << 0) | ||
| 55 | |||
| 56 | /* | ||
| 57 | * Broadcom LED source encodings. These are used in BCM5461, BCM5481, | ||
| 58 | * BCM5482, and possibly some others. | ||
| 59 | */ | ||
| 60 | #define BCM_LED_SRC_LINKSPD1 0x0 | ||
| 61 | #define BCM_LED_SRC_LINKSPD2 0x1 | ||
| 62 | #define BCM_LED_SRC_XMITLED 0x2 | ||
| 63 | #define BCM_LED_SRC_ACTIVITYLED 0x3 | ||
| 64 | #define BCM_LED_SRC_FDXLED 0x4 | ||
| 65 | #define BCM_LED_SRC_SLAVE 0x5 | ||
| 66 | #define BCM_LED_SRC_INTR 0x6 | ||
| 67 | #define BCM_LED_SRC_QUALITY 0x7 | ||
| 68 | #define BCM_LED_SRC_RCVLED 0x8 | ||
| 69 | #define BCM_LED_SRC_MULTICOLOR1 0xa | ||
| 70 | #define BCM_LED_SRC_OPENSHORT 0xb | ||
| 71 | #define BCM_LED_SRC_OFF 0xe /* Tied high */ | ||
| 72 | #define BCM_LED_SRC_ON 0xf /* Tied low */ | ||
| 73 | |||
| 74 | /* | ||
| 75 | * BCM5482: Shadow registers | ||
| 76 | * Shadow values go into bits [14:10] of register 0x1c to select a shadow | ||
| 77 | * register to access. | ||
| 78 | */ | ||
| 79 | #define BCM5482_SHD_LEDS1 0x0d /* 01101: LED Selector 1 */ | ||
| 80 | /* LED3 / ~LINKSPD[2] selector */ | ||
| 81 | #define BCM5482_SHD_LEDS1_LED3(src) ((src & 0xf) << 4) | ||
| 82 | /* LED1 / ~LINKSPD[1] selector */ | ||
| 83 | #define BCM5482_SHD_LEDS1_LED1(src) ((src & 0xf) << 0) | ||
| 84 | #define BCM5482_SHD_SSD 0x14 /* 10100: Secondary SerDes control */ | ||
| 85 | #define BCM5482_SHD_SSD_LEDM 0x0008 /* SSD LED Mode enable */ | ||
| 86 | #define BCM5482_SHD_SSD_EN 0x0001 /* SSD enable */ | ||
| 87 | #define BCM5482_SHD_MODE 0x1f /* 11111: Mode Control Register */ | ||
| 88 | #define BCM5482_SHD_MODE_1000BX 0x0001 /* Enable 1000BASE-X registers */ | ||
| 89 | |||
| 90 | /* | ||
| 91 | * BCM5482: Secondary SerDes registers | ||
| 92 | */ | ||
| 93 | #define BCM5482_SSD_1000BX_CTL 0x00 /* 1000BASE-X Control */ | ||
| 94 | #define BCM5482_SSD_1000BX_CTL_PWRDOWN 0x0800 /* Power-down SSD */ | ||
| 95 | #define BCM5482_SSD_SGMII_SLAVE 0x15 /* SGMII Slave Register */ | ||
| 96 | #define BCM5482_SSD_SGMII_SLAVE_EN 0x0002 /* Slave mode enable */ | ||
| 97 | #define BCM5482_SSD_SGMII_SLAVE_AD 0x0001 /* Slave auto-detection */ | ||
| 98 | |||
| 99 | /* | ||
| 100 | * Device flags for PHYs that can be configured for different operating | ||
| 101 | * modes. | ||
| 102 | */ | ||
| 103 | #define PHY_BCM_FLAGS_VALID 0x80000000 | ||
| 104 | #define PHY_BCM_FLAGS_INTF_XAUI 0x00000020 | ||
| 105 | #define PHY_BCM_FLAGS_INTF_SGMII 0x00000010 | ||
| 106 | #define PHY_BCM_FLAGS_MODE_1000BX 0x00000002 | ||
| 107 | #define PHY_BCM_FLAGS_MODE_COPPER 0x00000001 | ||
| 108 | |||
| 45 | MODULE_DESCRIPTION("Broadcom PHY driver"); | 109 | MODULE_DESCRIPTION("Broadcom PHY driver"); |
| 46 | MODULE_AUTHOR("Maciej W. Rozycki"); | 110 | MODULE_AUTHOR("Maciej W. Rozycki"); |
| 47 | MODULE_LICENSE("GPL"); | 111 | MODULE_LICENSE("GPL"); |
| 48 | 112 | ||
| 113 | /* | ||
| 114 | * Indirect register access functions for the 1000BASE-T/100BASE-TX/10BASE-T | ||
| 115 | * 0x1c shadow registers. | ||
| 116 | */ | ||
| 117 | static int bcm54xx_shadow_read(struct phy_device *phydev, u16 shadow) | ||
| 118 | { | ||
| 119 | phy_write(phydev, MII_BCM54XX_SHD, MII_BCM54XX_SHD_VAL(shadow)); | ||
| 120 | return MII_BCM54XX_SHD_DATA(phy_read(phydev, MII_BCM54XX_SHD)); | ||
| 121 | } | ||
| 122 | |||
| 123 | static int bcm54xx_shadow_write(struct phy_device *phydev, u16 shadow, u16 val) | ||
| 124 | { | ||
| 125 | return phy_write(phydev, MII_BCM54XX_SHD, | ||
| 126 | MII_BCM54XX_SHD_WRITE | | ||
| 127 | MII_BCM54XX_SHD_VAL(shadow) | | ||
| 128 | MII_BCM54XX_SHD_DATA(val)); | ||
| 129 | } | ||
| 130 | |||
| 131 | /* | ||
| 132 | * Indirect register access functions for the Expansion Registers | ||
| 133 | * and Secondary SerDes registers (when sec_serdes=1). | ||
| 134 | */ | ||
| 135 | static int bcm54xx_exp_read(struct phy_device *phydev, | ||
| 136 | int sec_serdes, u8 regnum) | ||
| 137 | { | ||
| 138 | int val; | ||
| 139 | |||
| 140 | phy_write(phydev, MII_BCM54XX_EXP_SEL, | ||
| 141 | (sec_serdes ? MII_BCM54XX_EXP_SEL_SSD : | ||
| 142 | MII_BCM54XX_EXP_SEL_ER) | | ||
| 143 | regnum); | ||
| 144 | val = phy_read(phydev, MII_BCM54XX_EXP_DATA); | ||
| 145 | phy_write(phydev, MII_BCM54XX_EXP_SEL, regnum); | ||
| 146 | |||
| 147 | return val; | ||
| 148 | } | ||
| 149 | |||
| 150 | static int bcm54xx_exp_write(struct phy_device *phydev, | ||
| 151 | int sec_serdes, u8 regnum, u16 val) | ||
| 152 | { | ||
| 153 | int ret; | ||
| 154 | |||
| 155 | phy_write(phydev, MII_BCM54XX_EXP_SEL, | ||
| 156 | (sec_serdes ? MII_BCM54XX_EXP_SEL_SSD : | ||
| 157 | MII_BCM54XX_EXP_SEL_ER) | | ||
| 158 | regnum); | ||
| 159 | ret = phy_write(phydev, MII_BCM54XX_EXP_DATA, val); | ||
| 160 | phy_write(phydev, MII_BCM54XX_EXP_SEL, regnum); | ||
| 161 | |||
| 162 | return ret; | ||
| 163 | } | ||
| 164 | |||
| 49 | static int bcm54xx_config_init(struct phy_device *phydev) | 165 | static int bcm54xx_config_init(struct phy_device *phydev) |
| 50 | { | 166 | { |
| 51 | int reg, err; | 167 | int reg, err; |
| @@ -70,6 +186,87 @@ static int bcm54xx_config_init(struct phy_device *phydev) | |||
| 70 | return 0; | 186 | return 0; |
| 71 | } | 187 | } |
| 72 | 188 | ||
| 189 | static int bcm5482_config_init(struct phy_device *phydev) | ||
| 190 | { | ||
| 191 | int err, reg; | ||
| 192 | |||
| 193 | err = bcm54xx_config_init(phydev); | ||
| 194 | |||
| 195 | if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX) { | ||
| 196 | /* | ||
| 197 | * Enable secondary SerDes and its use as an LED source | ||
| 198 | */ | ||
| 199 | reg = bcm54xx_shadow_read(phydev, BCM5482_SHD_SSD); | ||
| 200 | bcm54xx_shadow_write(phydev, BCM5482_SHD_SSD, | ||
| 201 | reg | | ||
| 202 | BCM5482_SHD_SSD_LEDM | | ||
| 203 | BCM5482_SHD_SSD_EN); | ||
| 204 | |||
| 205 | /* | ||
| 206 | * Enable SGMII slave mode and auto-detection | ||
| 207 | */ | ||
| 208 | reg = bcm54xx_exp_read(phydev, 1, BCM5482_SSD_SGMII_SLAVE); | ||
| 209 | bcm54xx_exp_write(phydev, 1, BCM5482_SSD_SGMII_SLAVE, | ||
| 210 | reg | | ||
| 211 | BCM5482_SSD_SGMII_SLAVE_EN | | ||
| 212 | BCM5482_SSD_SGMII_SLAVE_AD); | ||
| 213 | |||
| 214 | /* | ||
| 215 | * Disable secondary SerDes powerdown | ||
| 216 | */ | ||
| 217 | reg = bcm54xx_exp_read(phydev, 1, BCM5482_SSD_1000BX_CTL); | ||
| 218 | bcm54xx_exp_write(phydev, 1, BCM5482_SSD_1000BX_CTL, | ||
| 219 | reg & ~BCM5482_SSD_1000BX_CTL_PWRDOWN); | ||
| 220 | |||
| 221 | /* | ||
| 222 | * Select 1000BASE-X register set (primary SerDes) | ||
| 223 | */ | ||
| 224 | reg = bcm54xx_shadow_read(phydev, BCM5482_SHD_MODE); | ||
| 225 | bcm54xx_shadow_write(phydev, BCM5482_SHD_MODE, | ||
| 226 | reg | BCM5482_SHD_MODE_1000BX); | ||
| 227 | |||
| 228 | /* | ||
| 229 | * LED1=ACTIVITYLED, LED3=LINKSPD[2] | ||
| 230 | * (Use LED1 as secondary SerDes ACTIVITY LED) | ||
| 231 | */ | ||
| 232 | bcm54xx_shadow_write(phydev, BCM5482_SHD_LEDS1, | ||
| 233 | BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_ACTIVITYLED) | | ||
| 234 | BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_LINKSPD2)); | ||
| 235 | |||
| 236 | /* | ||
| 237 | * Auto-negotiation doesn't seem to work quite right | ||
| 238 | * in this mode, so we disable it and force it to the | ||
| 239 | * right speed/duplex setting. Only 'link status' | ||
| 240 | * is important. | ||
| 241 | */ | ||
| 242 | phydev->autoneg = AUTONEG_DISABLE; | ||
| 243 | phydev->speed = SPEED_1000; | ||
| 244 | phydev->duplex = DUPLEX_FULL; | ||
| 245 | } | ||
| 246 | |||
| 247 | return err; | ||
| 248 | } | ||
| 249 | |||
| 250 | static int bcm5482_read_status(struct phy_device *phydev) | ||
| 251 | { | ||
| 252 | int err; | ||
| 253 | |||
| 254 | err = genphy_read_status(phydev); | ||
| 255 | |||
| 256 | if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX) { | ||
| 257 | /* | ||
| 258 | * Only link status matters for 1000Base-X mode, so force | ||
| 259 | * 1000 Mbit/s full-duplex status | ||
| 260 | */ | ||
| 261 | if (phydev->link) { | ||
| 262 | phydev->speed = SPEED_1000; | ||
| 263 | phydev->duplex = DUPLEX_FULL; | ||
| 264 | } | ||
| 265 | } | ||
| 266 | |||
| 267 | return err; | ||
| 268 | } | ||
| 269 | |||
| 73 | static int bcm54xx_ack_interrupt(struct phy_device *phydev) | 270 | static int bcm54xx_ack_interrupt(struct phy_device *phydev) |
| 74 | { | 271 | { |
| 75 | int reg; | 272 | int reg; |
| @@ -210,9 +407,9 @@ static struct phy_driver bcm5482_driver = { | |||
| 210 | .name = "Broadcom BCM5482", | 407 | .name = "Broadcom BCM5482", |
| 211 | .features = PHY_GBIT_FEATURES, | 408 | .features = PHY_GBIT_FEATURES, |
| 212 | .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, | 409 | .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, |
| 213 | .config_init = bcm54xx_config_init, | 410 | .config_init = bcm5482_config_init, |
| 214 | .config_aneg = genphy_config_aneg, | 411 | .config_aneg = genphy_config_aneg, |
| 215 | .read_status = genphy_read_status, | 412 | .read_status = bcm5482_read_status, |
| 216 | .ack_interrupt = bcm54xx_ack_interrupt, | 413 | .ack_interrupt = bcm54xx_ack_interrupt, |
| 217 | .config_intr = bcm54xx_config_intr, | 414 | .config_intr = bcm54xx_config_intr, |
| 218 | .driver = { .owner = THIS_MODULE }, | 415 | .driver = { .owner = THIS_MODULE }, |
