aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sungem_phy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sungem_phy.c')
-rw-r--r--drivers/net/sungem_phy.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
index 9282b4b0c022..49800b25907d 100644
--- a/drivers/net/sungem_phy.c
+++ b/drivers/net/sungem_phy.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * PHY drivers for the sungem ethernet driver. 2 * PHY drivers for the sungem ethernet driver.
3 * 3 *
4 * This file could be shared with other drivers. 4 * This file could be shared with other drivers.
5 * 5 *
6 * (c) 2002, Benjamin Herrenscmidt (benh@kernel.crashing.org) 6 * (c) 2002, Benjamin Herrenscmidt (benh@kernel.crashing.org)
7 * 7 *
8 * TODO: 8 * TODO:
@@ -19,7 +19,6 @@
19 * of darwin, still need to reverse engineer that 19 * of darwin, still need to reverse engineer that
20 */ 20 */
21 21
22#include <linux/config.h>
23 22
24#include <linux/module.h> 23#include <linux/module.h>
25 24
@@ -74,7 +73,7 @@ static int reset_one_mii_phy(struct mii_phy* phy, int phy_id)
74{ 73{
75 u16 val; 74 u16 val;
76 int limit = 10000; 75 int limit = 10000;
77 76
78 val = __phy_read(phy, phy_id, MII_BMCR); 77 val = __phy_read(phy, phy_id, MII_BMCR);
79 val &= ~(BMCR_ISOLATE | BMCR_PDOWN); 78 val &= ~(BMCR_ISOLATE | BMCR_PDOWN);
80 val |= BMCR_RESET; 79 val |= BMCR_RESET;
@@ -90,7 +89,7 @@ static int reset_one_mii_phy(struct mii_phy* phy, int phy_id)
90 } 89 }
91 if ((val & BMCR_ISOLATE) && limit > 0) 90 if ((val & BMCR_ISOLATE) && limit > 0)
92 __phy_write(phy, phy_id, MII_BMCR, val & ~BMCR_ISOLATE); 91 __phy_write(phy, phy_id, MII_BMCR, val & ~BMCR_ISOLATE);
93 92
94 return (limit <= 0); 93 return (limit <= 0);
95} 94}
96 95
@@ -161,16 +160,16 @@ static int bcm5400_init(struct mii_phy* phy)
161 data = phy_read(phy, MII_BCM5400_AUXCONTROL); 160 data = phy_read(phy, MII_BCM5400_AUXCONTROL);
162 data |= MII_BCM5400_AUXCONTROL_PWR10BASET; 161 data |= MII_BCM5400_AUXCONTROL_PWR10BASET;
163 phy_write(phy, MII_BCM5400_AUXCONTROL, data); 162 phy_write(phy, MII_BCM5400_AUXCONTROL, data);
164 163
165 data = phy_read(phy, MII_BCM5400_GB_CONTROL); 164 data = phy_read(phy, MII_BCM5400_GB_CONTROL);
166 data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; 165 data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP;
167 phy_write(phy, MII_BCM5400_GB_CONTROL, data); 166 phy_write(phy, MII_BCM5400_GB_CONTROL, data);
168 167
169 udelay(100); 168 udelay(100);
170 169
171 /* Reset and configure cascaded 10/100 PHY */ 170 /* Reset and configure cascaded 10/100 PHY */
172 (void)reset_one_mii_phy(phy, 0x1f); 171 (void)reset_one_mii_phy(phy, 0x1f);
173 172
174 data = __phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY); 173 data = __phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY);
175 data |= MII_BCM5201_MULTIPHY_SERIALMODE; 174 data |= MII_BCM5201_MULTIPHY_SERIALMODE;
176 __phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data); 175 __phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data);
@@ -200,7 +199,7 @@ static int bcm5401_init(struct mii_phy* phy)
200 /* Some revisions of 5401 appear to need this 199 /* Some revisions of 5401 appear to need this
201 * initialisation sequence to disable, according 200 * initialisation sequence to disable, according
202 * to OF, "tap power management" 201 * to OF, "tap power management"
203 * 202 *
204 * WARNING ! OF and Darwin don't agree on the 203 * WARNING ! OF and Darwin don't agree on the
205 * register addresses. OF seem to interpret the 204 * register addresses. OF seem to interpret the
206 * register numbers below as decimal 205 * register numbers below as decimal
@@ -220,7 +219,7 @@ static int bcm5401_init(struct mii_phy* phy)
220 phy_write(phy, 0x17, 0x201f); 219 phy_write(phy, 0x17, 0x201f);
221 phy_write(phy, 0x15, 0x0a20); 220 phy_write(phy, 0x15, 0x0a20);
222 } 221 }
223 222
224 /* Configure for gigabit full duplex */ 223 /* Configure for gigabit full duplex */
225 data = phy_read(phy, MII_BCM5400_GB_CONTROL); 224 data = phy_read(phy, MII_BCM5400_GB_CONTROL);
226 data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; 225 data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP;
@@ -230,7 +229,7 @@ static int bcm5401_init(struct mii_phy* phy)
230 229
231 /* Reset and configure cascaded 10/100 PHY */ 230 /* Reset and configure cascaded 10/100 PHY */
232 (void)reset_one_mii_phy(phy, 0x1f); 231 (void)reset_one_mii_phy(phy, 0x1f);
233 232
234 data = __phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY); 233 data = __phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY);
235 data |= MII_BCM5201_MULTIPHY_SERIALMODE; 234 data |= MII_BCM5201_MULTIPHY_SERIALMODE;
236 __phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data); 235 __phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data);
@@ -271,7 +270,7 @@ static int bcm5411_init(struct mii_phy* phy)
271 270
272 /* Reset and configure cascaded 10/100 PHY */ 271 /* Reset and configure cascaded 10/100 PHY */
273 (void)reset_one_mii_phy(phy, 0x1f); 272 (void)reset_one_mii_phy(phy, 0x1f);
274 273
275 return 0; 274 return 0;
276} 275}
277 276
@@ -356,7 +355,7 @@ static int bcm5461_enable_fiber(struct mii_phy* phy)
356static int bcm54xx_setup_aneg(struct mii_phy *phy, u32 advertise) 355static int bcm54xx_setup_aneg(struct mii_phy *phy, u32 advertise)
357{ 356{
358 u16 ctl, adv; 357 u16 ctl, adv;
359 358
360 phy->autoneg = 1; 359 phy->autoneg = 1;
361 phy->speed = SPEED_10; 360 phy->speed = SPEED_10;
362 phy->duplex = DUPLEX_HALF; 361 phy->duplex = DUPLEX_HALF;
@@ -396,7 +395,7 @@ static int bcm54xx_setup_aneg(struct mii_phy *phy, u32 advertise)
396static int bcm54xx_setup_forced(struct mii_phy *phy, int speed, int fd) 395static int bcm54xx_setup_forced(struct mii_phy *phy, int speed, int fd)
397{ 396{
398 u16 ctl; 397 u16 ctl;
399 398
400 phy->autoneg = 0; 399 phy->autoneg = 0;
401 phy->speed = speed; 400 phy->speed = speed;
402 phy->duplex = fd; 401 phy->duplex = fd;
@@ -422,7 +421,7 @@ static int bcm54xx_setup_forced(struct mii_phy *phy, int speed, int fd)
422 ctl |= BMCR_FULLDPLX; 421 ctl |= BMCR_FULLDPLX;
423 422
424 // XXX Should we set the sungem to GII now on 1000BT ? 423 // XXX Should we set the sungem to GII now on 1000BT ?
425 424
426 phy_write(phy, MII_BMCR, ctl); 425 phy_write(phy, MII_BMCR, ctl);
427 426
428 return 0; 427 return 0;
@@ -430,9 +429,9 @@ static int bcm54xx_setup_forced(struct mii_phy *phy, int speed, int fd)
430 429
431static int bcm54xx_read_link(struct mii_phy *phy) 430static int bcm54xx_read_link(struct mii_phy *phy)
432{ 431{
433 int link_mode; 432 int link_mode;
434 u16 val; 433 u16 val;
435 434
436 if (phy->autoneg) { 435 if (phy->autoneg) {
437 val = phy_read(phy, MII_BCM5400_AUXSTATUS); 436 val = phy_read(phy, MII_BCM5400_AUXSTATUS);
438 link_mode = ((val & MII_BCM5400_AUXSTATUS_LINKMODE_MASK) >> 437 link_mode = ((val & MII_BCM5400_AUXSTATUS_LINKMODE_MASK) >>
@@ -454,7 +453,7 @@ static int bcm54xx_read_link(struct mii_phy *phy)
454static int marvell_setup_aneg(struct mii_phy *phy, u32 advertise) 453static int marvell_setup_aneg(struct mii_phy *phy, u32 advertise)
455{ 454{
456 u16 ctl, adv; 455 u16 ctl, adv;
457 456
458 phy->autoneg = 1; 457 phy->autoneg = 1;
459 phy->speed = SPEED_10; 458 phy->speed = SPEED_10;
460 phy->duplex = DUPLEX_HALF; 459 phy->duplex = DUPLEX_HALF;
@@ -501,7 +500,7 @@ static int marvell_setup_aneg(struct mii_phy *phy, u32 advertise)
501static int marvell_setup_forced(struct mii_phy *phy, int speed, int fd) 500static int marvell_setup_forced(struct mii_phy *phy, int speed, int fd)
502{ 501{
503 u16 ctl, ctl2; 502 u16 ctl, ctl2;
504 503
505 phy->autoneg = 0; 504 phy->autoneg = 0;
506 phy->speed = speed; 505 phy->speed = speed;
507 phy->duplex = fd; 506 phy->duplex = fd;
@@ -542,7 +541,7 @@ static int marvell_setup_forced(struct mii_phy *phy, int speed, int fd)
542 phy_write(phy, MII_1000BASETCONTROL, ctl2); 541 phy_write(phy, MII_1000BASETCONTROL, ctl2);
543 542
544 // XXX Should we set the sungem to GII now on 1000BT ? 543 // XXX Should we set the sungem to GII now on 1000BT ?
545 544
546 phy_write(phy, MII_BMCR, ctl); 545 phy_write(phy, MII_BMCR, ctl);
547 546
548 return 0; 547 return 0;
@@ -578,7 +577,7 @@ static int marvell_read_link(struct mii_phy *phy)
578static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise) 577static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise)
579{ 578{
580 u16 ctl, adv; 579 u16 ctl, adv;
581 580
582 phy->autoneg = 1; 581 phy->autoneg = 1;
583 phy->speed = SPEED_10; 582 phy->speed = SPEED_10;
584 phy->duplex = DUPLEX_HALF; 583 phy->duplex = DUPLEX_HALF;
@@ -609,7 +608,7 @@ static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise)
609static int genmii_setup_forced(struct mii_phy *phy, int speed, int fd) 608static int genmii_setup_forced(struct mii_phy *phy, int speed, int fd)
610{ 609{
611 u16 ctl; 610 u16 ctl;
612 611
613 phy->autoneg = 0; 612 phy->autoneg = 0;
614 phy->speed = speed; 613 phy->speed = speed;
615 phy->duplex = fd; 614 phy->duplex = fd;
@@ -642,7 +641,7 @@ static int genmii_setup_forced(struct mii_phy *phy, int speed, int fd)
642static int genmii_poll_link(struct mii_phy *phy) 641static int genmii_poll_link(struct mii_phy *phy)
643{ 642{
644 u16 status; 643 u16 status;
645 644
646 (void)phy_read(phy, MII_BMSR); 645 (void)phy_read(phy, MII_BMSR);
647 status = phy_read(phy, MII_BMSR); 646 status = phy_read(phy, MII_BMSR);
648 if ((status & BMSR_LSTATUS) == 0) 647 if ((status & BMSR_LSTATUS) == 0)
@@ -919,13 +918,13 @@ int mii_phy_probe(struct mii_phy *phy, int mii_id)
919 * may re-probe the PHY regulary 918 * may re-probe the PHY regulary
920 */ 919 */
921 phy->mii_id = mii_id; 920 phy->mii_id = mii_id;
922 921
923 /* Take PHY out of isloate mode and reset it. */ 922 /* Take PHY out of isloate mode and reset it. */
924 rc = reset_one_mii_phy(phy, mii_id); 923 rc = reset_one_mii_phy(phy, mii_id);
925 if (rc) 924 if (rc)
926 goto fail; 925 goto fail;
927 926
928 /* Read ID and find matching entry */ 927 /* Read ID and find matching entry */
929 id = (phy_read(phy, MII_PHYSID1) << 16 | phy_read(phy, MII_PHYSID2)); 928 id = (phy_read(phy, MII_PHYSID1) << 16 | phy_read(phy, MII_PHYSID2));
930 printk(KERN_DEBUG "PHY ID: %x, addr: %x\n", id, mii_id); 929 printk(KERN_DEBUG "PHY ID: %x, addr: %x\n", id, mii_id);
931 for (i=0; (def = mii_phy_table[i]) != NULL; i++) 930 for (i=0; (def = mii_phy_table[i]) != NULL; i++)
@@ -936,7 +935,7 @@ int mii_phy_probe(struct mii_phy *phy, int mii_id)
936 goto fail; 935 goto fail;
937 936
938 phy->def = def; 937 phy->def = def;
939 938
940 return 0; 939 return 0;
941fail: 940fail:
942 phy->speed = 0; 941 phy->speed = 0;