• Home
  • Raw
  • Download

Lines Matching full:phy

3  * PHY drivers for the sungem ethernet driver.
39 /* Link modes of the BCM5400 PHY */
51 static inline int __sungem_phy_read(struct mii_phy* phy, int id, int reg) in __sungem_phy_read() argument
53 return phy->mdio_read(phy->dev, id, reg); in __sungem_phy_read()
56 static inline void __sungem_phy_write(struct mii_phy* phy, int id, int reg, int val) in __sungem_phy_write() argument
58 phy->mdio_write(phy->dev, id, reg, val); in __sungem_phy_write()
61 static inline int sungem_phy_read(struct mii_phy* phy, int reg) in sungem_phy_read() argument
63 return phy->mdio_read(phy->dev, phy->mii_id, reg); in sungem_phy_read()
66 static inline void sungem_phy_write(struct mii_phy* phy, int reg, int val) in sungem_phy_write() argument
68 phy->mdio_write(phy->dev, phy->mii_id, reg, val); in sungem_phy_write()
71 static int reset_one_mii_phy(struct mii_phy* phy, int phy_id) in reset_one_mii_phy() argument
76 val = __sungem_phy_read(phy, phy_id, MII_BMCR); in reset_one_mii_phy()
79 __sungem_phy_write(phy, phy_id, MII_BMCR, val); in reset_one_mii_phy()
84 val = __sungem_phy_read(phy, phy_id, MII_BMCR); in reset_one_mii_phy()
90 __sungem_phy_write(phy, phy_id, MII_BMCR, val & ~BMCR_ISOLATE); in reset_one_mii_phy()
95 static int bcm5201_init(struct mii_phy* phy) in bcm5201_init() argument
99 data = sungem_phy_read(phy, MII_BCM5201_MULTIPHY); in bcm5201_init()
101 sungem_phy_write(phy, MII_BCM5201_MULTIPHY, data); in bcm5201_init()
103 sungem_phy_write(phy, MII_BCM5201_INTERRUPT, 0); in bcm5201_init()
108 static int bcm5201_suspend(struct mii_phy* phy) in bcm5201_suspend() argument
110 sungem_phy_write(phy, MII_BCM5201_INTERRUPT, 0); in bcm5201_suspend()
111 sungem_phy_write(phy, MII_BCM5201_MULTIPHY, MII_BCM5201_MULTIPHY_SUPERISOLATE); in bcm5201_suspend()
116 static int bcm5221_init(struct mii_phy* phy) in bcm5221_init() argument
120 data = sungem_phy_read(phy, MII_BCM5221_TEST); in bcm5221_init()
121 sungem_phy_write(phy, MII_BCM5221_TEST, in bcm5221_init()
124 data = sungem_phy_read(phy, MII_BCM5221_SHDOW_AUX_STAT2); in bcm5221_init()
125 sungem_phy_write(phy, MII_BCM5221_SHDOW_AUX_STAT2, in bcm5221_init()
128 data = sungem_phy_read(phy, MII_BCM5221_SHDOW_AUX_MODE4); in bcm5221_init()
129 sungem_phy_write(phy, MII_BCM5221_SHDOW_AUX_MODE4, in bcm5221_init()
132 data = sungem_phy_read(phy, MII_BCM5221_TEST); in bcm5221_init()
133 sungem_phy_write(phy, MII_BCM5221_TEST, in bcm5221_init()
139 static int bcm5221_suspend(struct mii_phy* phy) in bcm5221_suspend() argument
143 data = sungem_phy_read(phy, MII_BCM5221_TEST); in bcm5221_suspend()
144 sungem_phy_write(phy, MII_BCM5221_TEST, in bcm5221_suspend()
147 data = sungem_phy_read(phy, MII_BCM5221_SHDOW_AUX_MODE4); in bcm5221_suspend()
148 sungem_phy_write(phy, MII_BCM5221_SHDOW_AUX_MODE4, in bcm5221_suspend()
154 static int bcm5241_init(struct mii_phy* phy) in bcm5241_init() argument
158 data = sungem_phy_read(phy, MII_BCM5221_TEST); in bcm5241_init()
159 sungem_phy_write(phy, MII_BCM5221_TEST, in bcm5241_init()
162 data = sungem_phy_read(phy, MII_BCM5221_SHDOW_AUX_STAT2); in bcm5241_init()
163 sungem_phy_write(phy, MII_BCM5221_SHDOW_AUX_STAT2, in bcm5241_init()
166 data = sungem_phy_read(phy, MII_BCM5221_SHDOW_AUX_MODE4); in bcm5241_init()
167 sungem_phy_write(phy, MII_BCM5221_SHDOW_AUX_MODE4, in bcm5241_init()
170 data = sungem_phy_read(phy, MII_BCM5221_TEST); in bcm5241_init()
171 sungem_phy_write(phy, MII_BCM5221_TEST, in bcm5241_init()
177 static int bcm5241_suspend(struct mii_phy* phy) in bcm5241_suspend() argument
181 data = sungem_phy_read(phy, MII_BCM5221_TEST); in bcm5241_suspend()
182 sungem_phy_write(phy, MII_BCM5221_TEST, in bcm5241_suspend()
185 data = sungem_phy_read(phy, MII_BCM5221_SHDOW_AUX_MODE4); in bcm5241_suspend()
186 sungem_phy_write(phy, MII_BCM5221_SHDOW_AUX_MODE4, in bcm5241_suspend()
192 static int bcm5400_init(struct mii_phy* phy) in bcm5400_init() argument
197 data = sungem_phy_read(phy, MII_BCM5400_AUXCONTROL); in bcm5400_init()
199 sungem_phy_write(phy, MII_BCM5400_AUXCONTROL, data); in bcm5400_init()
201 data = sungem_phy_read(phy, MII_BCM5400_GB_CONTROL); in bcm5400_init()
203 sungem_phy_write(phy, MII_BCM5400_GB_CONTROL, data); in bcm5400_init()
207 /* Reset and configure cascaded 10/100 PHY */ in bcm5400_init()
208 (void)reset_one_mii_phy(phy, 0x1f); in bcm5400_init()
210 data = __sungem_phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY); in bcm5400_init()
212 __sungem_phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data); in bcm5400_init()
214 data = sungem_phy_read(phy, MII_BCM5400_AUXCONTROL); in bcm5400_init()
216 sungem_phy_write(phy, MII_BCM5400_AUXCONTROL, data); in bcm5400_init()
221 static int bcm5400_suspend(struct mii_phy* phy) in bcm5400_suspend() argument
224 sungem_phy_write(phy, MII_BMCR, BMCR_PDOWN); in bcm5400_suspend()
229 static int bcm5401_init(struct mii_phy* phy) in bcm5401_init() argument
234 rev = sungem_phy_read(phy, MII_PHYSID2) & 0x000f; in bcm5401_init()
247 sungem_phy_write(phy, 0x18, 0x0c20); in bcm5401_init()
248 sungem_phy_write(phy, 0x17, 0x0012); in bcm5401_init()
249 sungem_phy_write(phy, 0x15, 0x1804); in bcm5401_init()
250 sungem_phy_write(phy, 0x17, 0x0013); in bcm5401_init()
251 sungem_phy_write(phy, 0x15, 0x1204); in bcm5401_init()
252 sungem_phy_write(phy, 0x17, 0x8006); in bcm5401_init()
253 sungem_phy_write(phy, 0x15, 0x0132); in bcm5401_init()
254 sungem_phy_write(phy, 0x17, 0x8006); in bcm5401_init()
255 sungem_phy_write(phy, 0x15, 0x0232); in bcm5401_init()
256 sungem_phy_write(phy, 0x17, 0x201f); in bcm5401_init()
257 sungem_phy_write(phy, 0x15, 0x0a20); in bcm5401_init()
261 data = sungem_phy_read(phy, MII_BCM5400_GB_CONTROL); in bcm5401_init()
263 sungem_phy_write(phy, MII_BCM5400_GB_CONTROL, data); in bcm5401_init()
267 /* Reset and configure cascaded 10/100 PHY */ in bcm5401_init()
268 (void)reset_one_mii_phy(phy, 0x1f); in bcm5401_init()
270 data = __sungem_phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY); in bcm5401_init()
272 __sungem_phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data); in bcm5401_init()
277 static int bcm5401_suspend(struct mii_phy* phy) in bcm5401_suspend() argument
280 sungem_phy_write(phy, MII_BMCR, BMCR_PDOWN); in bcm5401_suspend()
285 static int bcm5411_init(struct mii_phy* phy) in bcm5411_init() argument
292 sungem_phy_write(phy, 0x1c, 0x8c23); in bcm5411_init()
293 sungem_phy_write(phy, 0x1c, 0x8ca3); in bcm5411_init()
294 sungem_phy_write(phy, 0x1c, 0x8c23); in bcm5411_init()
299 sungem_phy_write(phy, MII_BMCR, BMCR_RESET); in bcm5411_init()
300 sungem_phy_write(phy, MII_BMCR, 0x1340); in bcm5411_init()
302 data = sungem_phy_read(phy, MII_BCM5400_GB_CONTROL); in bcm5411_init()
304 sungem_phy_write(phy, MII_BCM5400_GB_CONTROL, data); in bcm5411_init()
308 /* Reset and configure cascaded 10/100 PHY */ in bcm5411_init()
309 (void)reset_one_mii_phy(phy, 0x1f); in bcm5411_init()
314 static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise) in genmii_setup_aneg() argument
318 phy->autoneg = 1; in genmii_setup_aneg()
319 phy->speed = SPEED_10; in genmii_setup_aneg()
320 phy->duplex = DUPLEX_HALF; in genmii_setup_aneg()
321 phy->pause = 0; in genmii_setup_aneg()
322 phy->advertising = advertise; in genmii_setup_aneg()
325 adv = sungem_phy_read(phy, MII_ADVERTISE); in genmii_setup_aneg()
335 sungem_phy_write(phy, MII_ADVERTISE, adv); in genmii_setup_aneg()
338 ctl = sungem_phy_read(phy, MII_BMCR); in genmii_setup_aneg()
340 sungem_phy_write(phy, MII_BMCR, ctl); in genmii_setup_aneg()
345 static int genmii_setup_forced(struct mii_phy *phy, int speed, int fd) in genmii_setup_forced() argument
349 phy->autoneg = 0; in genmii_setup_forced()
350 phy->speed = speed; in genmii_setup_forced()
351 phy->duplex = fd; in genmii_setup_forced()
352 phy->pause = 0; in genmii_setup_forced()
354 ctl = sungem_phy_read(phy, MII_BMCR); in genmii_setup_forced()
357 /* First reset the PHY */ in genmii_setup_forced()
358 sungem_phy_write(phy, MII_BMCR, ctl | BMCR_RESET); in genmii_setup_forced()
373 sungem_phy_write(phy, MII_BMCR, ctl); in genmii_setup_forced()
378 static int genmii_poll_link(struct mii_phy *phy) in genmii_poll_link() argument
382 (void)sungem_phy_read(phy, MII_BMSR); in genmii_poll_link()
383 status = sungem_phy_read(phy, MII_BMSR); in genmii_poll_link()
386 if (phy->autoneg && !(status & BMSR_ANEGCOMPLETE)) in genmii_poll_link()
391 static int genmii_read_link(struct mii_phy *phy) in genmii_read_link() argument
395 if (phy->autoneg) { in genmii_read_link()
396 lpa = sungem_phy_read(phy, MII_LPA); in genmii_read_link()
399 phy->duplex = DUPLEX_FULL; in genmii_read_link()
401 phy->duplex = DUPLEX_HALF; in genmii_read_link()
403 phy->speed = SPEED_100; in genmii_read_link()
405 phy->speed = SPEED_10; in genmii_read_link()
406 phy->pause = 0; in genmii_read_link()
415 static int generic_suspend(struct mii_phy* phy) in generic_suspend() argument
417 sungem_phy_write(phy, MII_BMCR, BMCR_PDOWN); in generic_suspend()
422 static int bcm5421_init(struct mii_phy* phy) in bcm5421_init() argument
427 id = (sungem_phy_read(phy, MII_PHYSID1) << 16 | sungem_phy_read(phy, MII_PHYSID2)); in bcm5421_init()
433 sungem_phy_write(phy, 0x18, 0x1007); in bcm5421_init()
434 data = sungem_phy_read(phy, 0x18); in bcm5421_init()
435 sungem_phy_write(phy, 0x18, data | 0x0400); in bcm5421_init()
436 sungem_phy_write(phy, 0x18, 0x0007); in bcm5421_init()
437 data = sungem_phy_read(phy, 0x18); in bcm5421_init()
438 sungem_phy_write(phy, 0x18, data | 0x0800); in bcm5421_init()
439 sungem_phy_write(phy, 0x17, 0x000a); in bcm5421_init()
440 data = sungem_phy_read(phy, 0x15); in bcm5421_init()
441 sungem_phy_write(phy, 0x15, data | 0x0200); in bcm5421_init()
446 sungem_phy_write(phy, 4, 0x01e1); in bcm5421_init()
447 sungem_phy_write(phy, 9, 0x0300); in bcm5421_init()
452 if (phy->platform_data) { in bcm5421_init()
453 struct device_node *np = of_get_parent(phy->platform_data); in bcm5421_init()
460 sungem_phy_write(phy, 0x1c, 0x9002); in bcm5421_init()
461 sungem_phy_write(phy, 0x1c, 0xa821); in bcm5421_init()
462 sungem_phy_write(phy, 0x1c, 0x941d); in bcm5421_init()
470 static int bcm54xx_setup_aneg(struct mii_phy *phy, u32 advertise) in bcm54xx_setup_aneg() argument
474 phy->autoneg = 1; in bcm54xx_setup_aneg()
475 phy->speed = SPEED_10; in bcm54xx_setup_aneg()
476 phy->duplex = DUPLEX_HALF; in bcm54xx_setup_aneg()
477 phy->pause = 0; in bcm54xx_setup_aneg()
478 phy->advertising = advertise; in bcm54xx_setup_aneg()
481 adv = sungem_phy_read(phy, MII_ADVERTISE); in bcm54xx_setup_aneg()
495 sungem_phy_write(phy, MII_ADVERTISE, adv); in bcm54xx_setup_aneg()
498 adv = sungem_phy_read(phy, MII_1000BASETCONTROL); in bcm54xx_setup_aneg()
504 sungem_phy_write(phy, MII_1000BASETCONTROL, adv); in bcm54xx_setup_aneg()
507 ctl = sungem_phy_read(phy, MII_BMCR); in bcm54xx_setup_aneg()
509 sungem_phy_write(phy, MII_BMCR, ctl); in bcm54xx_setup_aneg()
514 static int bcm54xx_setup_forced(struct mii_phy *phy, int speed, int fd) in bcm54xx_setup_forced() argument
518 phy->autoneg = 0; in bcm54xx_setup_forced()
519 phy->speed = speed; in bcm54xx_setup_forced()
520 phy->duplex = fd; in bcm54xx_setup_forced()
521 phy->pause = 0; in bcm54xx_setup_forced()
523 ctl = sungem_phy_read(phy, MII_BMCR); in bcm54xx_setup_forced()
526 /* First reset the PHY */ in bcm54xx_setup_forced()
527 sungem_phy_write(phy, MII_BMCR, ctl | BMCR_RESET); in bcm54xx_setup_forced()
544 sungem_phy_write(phy, MII_BMCR, ctl); in bcm54xx_setup_forced()
549 static int bcm54xx_read_link(struct mii_phy *phy) in bcm54xx_read_link() argument
554 if (phy->autoneg) { in bcm54xx_read_link()
555 val = sungem_phy_read(phy, MII_BCM5400_AUXSTATUS); in bcm54xx_read_link()
558 phy->duplex = phy_BCM5400_link_table[link_mode][0] ? in bcm54xx_read_link()
560 phy->speed = phy_BCM5400_link_table[link_mode][2] ? in bcm54xx_read_link()
564 val = sungem_phy_read(phy, MII_LPA); in bcm54xx_read_link()
565 phy->pause = (phy->duplex == DUPLEX_FULL) && in bcm54xx_read_link()
575 static int marvell88e1111_init(struct mii_phy* phy) in marvell88e1111_init() argument
580 rev = sungem_phy_read(phy, MII_PHYSID2) & 0x000f; in marvell88e1111_init()
582 sungem_phy_write(phy, 0x1d, 0x000a); in marvell88e1111_init()
583 sungem_phy_write(phy, 0x1e, 0x0821); in marvell88e1111_init()
585 sungem_phy_write(phy, 0x1d, 0x0006); in marvell88e1111_init()
586 sungem_phy_write(phy, 0x1e, 0x8600); in marvell88e1111_init()
588 sungem_phy_write(phy, 0x1d, 0x000b); in marvell88e1111_init()
589 sungem_phy_write(phy, 0x1e, 0x0100); in marvell88e1111_init()
591 sungem_phy_write(phy, 0x1d, 0x0004); in marvell88e1111_init()
592 sungem_phy_write(phy, 0x1e, 0x4850); in marvell88e1111_init()
599 static int bcm5421_poll_link(struct mii_phy* phy) in bcm5421_poll_link() argument
605 sungem_phy_write(phy, MII_NCONFIG, 0x1000); in bcm5421_poll_link()
606 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5421_poll_link()
611 return genmii_poll_link(phy); in bcm5421_poll_link()
614 sungem_phy_write(phy, MII_NCONFIG, 0x2000); in bcm5421_poll_link()
615 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5421_poll_link()
623 static int bcm5421_read_link(struct mii_phy* phy) in bcm5421_read_link() argument
629 sungem_phy_write(phy, MII_NCONFIG, 0x1000); in bcm5421_read_link()
630 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5421_read_link()
635 return bcm54xx_read_link(phy); in bcm5421_read_link()
637 phy->speed = SPEED_1000; in bcm5421_read_link()
640 sungem_phy_write(phy, MII_NCONFIG, 0x2000); in bcm5421_read_link()
641 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5421_read_link()
644 phy->duplex |= DUPLEX_HALF; in bcm5421_read_link()
646 phy->duplex |= DUPLEX_FULL; in bcm5421_read_link()
651 static int bcm5421_enable_fiber(struct mii_phy* phy, int autoneg) in bcm5421_enable_fiber() argument
654 sungem_phy_write(phy, MII_NCONFIG, 0x9020); in bcm5421_enable_fiber()
656 sungem_phy_write(phy, MII_NCONFIG, 0x945f); in bcm5421_enable_fiber()
660 sungem_phy_write(phy, MII_NCONFIG, 0xfc01); in bcm5421_enable_fiber()
661 sungem_phy_write(phy, 0x0b, 0x0004); in bcm5421_enable_fiber()
664 phy->autoneg = autoneg; in bcm5421_enable_fiber()
672 static int bcm5461_poll_link(struct mii_phy* phy) in bcm5461_poll_link() argument
678 sungem_phy_write(phy, MII_NCONFIG, 0x7c00); in bcm5461_poll_link()
679 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5461_poll_link()
684 return genmii_poll_link(phy); in bcm5461_poll_link()
687 sungem_phy_write(phy, MII_NCONFIG, 0x7000); in bcm5461_poll_link()
688 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5461_poll_link()
698 static int bcm5461_read_link(struct mii_phy* phy) in bcm5461_read_link() argument
704 sungem_phy_write(phy, MII_NCONFIG, 0x7c00); in bcm5461_read_link()
705 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5461_read_link()
710 return bcm54xx_read_link(phy); in bcm5461_read_link()
713 phy->speed = SPEED_1000; in bcm5461_read_link()
716 sungem_phy_write(phy, MII_NCONFIG, 0x7000); in bcm5461_read_link()
717 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5461_read_link()
720 phy->duplex |= DUPLEX_FULL; in bcm5461_read_link()
722 phy->duplex |= DUPLEX_HALF; in bcm5461_read_link()
727 static int bcm5461_enable_fiber(struct mii_phy* phy, int autoneg) in bcm5461_enable_fiber() argument
730 sungem_phy_write(phy, MII_NCONFIG, 0xfc0b); in bcm5461_enable_fiber()
734 sungem_phy_write(phy, MII_ADVERTISE, 0x01e0); in bcm5461_enable_fiber()
735 sungem_phy_write(phy, MII_BMCR, 0x1140); in bcm5461_enable_fiber()
738 sungem_phy_write(phy, MII_BMCR, 0x0140); in bcm5461_enable_fiber()
741 phy->autoneg = autoneg; in bcm5461_enable_fiber()
746 static int marvell_setup_aneg(struct mii_phy *phy, u32 advertise) in marvell_setup_aneg() argument
750 phy->autoneg = 1; in marvell_setup_aneg()
751 phy->speed = SPEED_10; in marvell_setup_aneg()
752 phy->duplex = DUPLEX_HALF; in marvell_setup_aneg()
753 phy->pause = 0; in marvell_setup_aneg()
754 phy->advertising = advertise; in marvell_setup_aneg()
757 adv = sungem_phy_read(phy, MII_ADVERTISE); in marvell_setup_aneg()
771 sungem_phy_write(phy, MII_ADVERTISE, adv); in marvell_setup_aneg()
779 adv = sungem_phy_read(phy, MII_M1011_PHY_SPEC_CONTROL); in marvell_setup_aneg()
787 sungem_phy_write(phy, MII_1000BASETCONTROL, adv); in marvell_setup_aneg()
790 ctl = sungem_phy_read(phy, MII_BMCR); in marvell_setup_aneg()
792 sungem_phy_write(phy, MII_BMCR, ctl); in marvell_setup_aneg()
797 static int marvell_setup_forced(struct mii_phy *phy, int speed, int fd) in marvell_setup_forced() argument
801 phy->autoneg = 0; in marvell_setup_forced()
802 phy->speed = speed; in marvell_setup_forced()
803 phy->duplex = fd; in marvell_setup_forced()
804 phy->pause = 0; in marvell_setup_forced()
806 ctl = sungem_phy_read(phy, MII_BMCR); in marvell_setup_forced()
829 ctl2 = sungem_phy_read(phy, MII_M1011_PHY_SPEC_CONTROL); in marvell_setup_forced()
838 sungem_phy_write(phy, MII_1000BASETCONTROL, ctl2); in marvell_setup_forced()
842 sungem_phy_write(phy, MII_BMCR, ctl); in marvell_setup_forced()
847 static int marvell_read_link(struct mii_phy *phy) in marvell_read_link() argument
851 if (phy->autoneg) { in marvell_read_link()
852 status = sungem_phy_read(phy, MII_M1011_PHY_SPEC_STATUS); in marvell_read_link()
856 phy->speed = SPEED_1000; in marvell_read_link()
858 phy->speed = SPEED_100; in marvell_read_link()
860 phy->speed = SPEED_10; in marvell_read_link()
862 phy->duplex = DUPLEX_FULL; in marvell_read_link()
864 phy->duplex = DUPLEX_HALF; in marvell_read_link()
867 phy->pause = (status & pmask) == pmask; in marvell_read_link()
1161 int sungem_phy_probe(struct mii_phy *phy, int mii_id) in sungem_phy_probe() argument
1169 * may re-probe the PHY regulary in sungem_phy_probe()
1171 phy->mii_id = mii_id; in sungem_phy_probe()
1173 /* Take PHY out of isloate mode and reset it. */ in sungem_phy_probe()
1174 rc = reset_one_mii_phy(phy, mii_id); in sungem_phy_probe()
1179 id = (sungem_phy_read(phy, MII_PHYSID1) << 16 | sungem_phy_read(phy, MII_PHYSID2)); in sungem_phy_probe()
1180 printk(KERN_DEBUG KBUILD_MODNAME ": " "PHY ID: %x, addr: %x\n", in sungem_phy_probe()
1189 phy->def = def; in sungem_phy_probe()
1193 phy->speed = 0; in sungem_phy_probe()
1194 phy->duplex = 0; in sungem_phy_probe()
1195 phy->pause = 0; in sungem_phy_probe()
1196 phy->advertising = 0; in sungem_phy_probe()