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()
459 sungem_phy_write(phy, 0x1c, 0x9002); in bcm5421_init()
460 sungem_phy_write(phy, 0x1c, 0xa821); in bcm5421_init()
461 sungem_phy_write(phy, 0x1c, 0x941d); in bcm5421_init()
469 static int bcm54xx_setup_aneg(struct mii_phy *phy, u32 advertise) in bcm54xx_setup_aneg() argument
473 phy->autoneg = 1; in bcm54xx_setup_aneg()
474 phy->speed = SPEED_10; in bcm54xx_setup_aneg()
475 phy->duplex = DUPLEX_HALF; in bcm54xx_setup_aneg()
476 phy->pause = 0; in bcm54xx_setup_aneg()
477 phy->advertising = advertise; in bcm54xx_setup_aneg()
480 adv = sungem_phy_read(phy, MII_ADVERTISE); in bcm54xx_setup_aneg()
494 sungem_phy_write(phy, MII_ADVERTISE, adv); in bcm54xx_setup_aneg()
497 adv = sungem_phy_read(phy, MII_1000BASETCONTROL); in bcm54xx_setup_aneg()
503 sungem_phy_write(phy, MII_1000BASETCONTROL, adv); in bcm54xx_setup_aneg()
506 ctl = sungem_phy_read(phy, MII_BMCR); in bcm54xx_setup_aneg()
508 sungem_phy_write(phy, MII_BMCR, ctl); in bcm54xx_setup_aneg()
513 static int bcm54xx_setup_forced(struct mii_phy *phy, int speed, int fd) in bcm54xx_setup_forced() argument
517 phy->autoneg = 0; in bcm54xx_setup_forced()
518 phy->speed = speed; in bcm54xx_setup_forced()
519 phy->duplex = fd; in bcm54xx_setup_forced()
520 phy->pause = 0; in bcm54xx_setup_forced()
522 ctl = sungem_phy_read(phy, MII_BMCR); in bcm54xx_setup_forced()
525 /* First reset the PHY */ in bcm54xx_setup_forced()
526 sungem_phy_write(phy, MII_BMCR, ctl | BMCR_RESET); in bcm54xx_setup_forced()
543 sungem_phy_write(phy, MII_BMCR, ctl); in bcm54xx_setup_forced()
548 static int bcm54xx_read_link(struct mii_phy *phy) in bcm54xx_read_link() argument
553 if (phy->autoneg) { in bcm54xx_read_link()
554 val = sungem_phy_read(phy, MII_BCM5400_AUXSTATUS); in bcm54xx_read_link()
557 phy->duplex = phy_BCM5400_link_table[link_mode][0] ? in bcm54xx_read_link()
559 phy->speed = phy_BCM5400_link_table[link_mode][2] ? in bcm54xx_read_link()
563 val = sungem_phy_read(phy, MII_LPA); in bcm54xx_read_link()
564 phy->pause = (phy->duplex == DUPLEX_FULL) && in bcm54xx_read_link()
574 static int marvell88e1111_init(struct mii_phy* phy) in marvell88e1111_init() argument
579 rev = sungem_phy_read(phy, MII_PHYSID2) & 0x000f; in marvell88e1111_init()
581 sungem_phy_write(phy, 0x1d, 0x000a); in marvell88e1111_init()
582 sungem_phy_write(phy, 0x1e, 0x0821); in marvell88e1111_init()
584 sungem_phy_write(phy, 0x1d, 0x0006); in marvell88e1111_init()
585 sungem_phy_write(phy, 0x1e, 0x8600); in marvell88e1111_init()
587 sungem_phy_write(phy, 0x1d, 0x000b); in marvell88e1111_init()
588 sungem_phy_write(phy, 0x1e, 0x0100); in marvell88e1111_init()
590 sungem_phy_write(phy, 0x1d, 0x0004); in marvell88e1111_init()
591 sungem_phy_write(phy, 0x1e, 0x4850); in marvell88e1111_init()
598 static int bcm5421_poll_link(struct mii_phy* phy) in bcm5421_poll_link() argument
604 sungem_phy_write(phy, MII_NCONFIG, 0x1000); in bcm5421_poll_link()
605 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5421_poll_link()
610 return genmii_poll_link(phy); in bcm5421_poll_link()
613 sungem_phy_write(phy, MII_NCONFIG, 0x2000); in bcm5421_poll_link()
614 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5421_poll_link()
622 static int bcm5421_read_link(struct mii_phy* phy) in bcm5421_read_link() argument
628 sungem_phy_write(phy, MII_NCONFIG, 0x1000); in bcm5421_read_link()
629 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5421_read_link()
634 return bcm54xx_read_link(phy); in bcm5421_read_link()
636 phy->speed = SPEED_1000; in bcm5421_read_link()
639 sungem_phy_write(phy, MII_NCONFIG, 0x2000); in bcm5421_read_link()
640 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5421_read_link()
643 phy->duplex |= DUPLEX_HALF; in bcm5421_read_link()
645 phy->duplex |= DUPLEX_FULL; in bcm5421_read_link()
650 static int bcm5421_enable_fiber(struct mii_phy* phy, int autoneg) in bcm5421_enable_fiber() argument
653 sungem_phy_write(phy, MII_NCONFIG, 0x9020); in bcm5421_enable_fiber()
655 sungem_phy_write(phy, MII_NCONFIG, 0x945f); in bcm5421_enable_fiber()
659 sungem_phy_write(phy, MII_NCONFIG, 0xfc01); in bcm5421_enable_fiber()
660 sungem_phy_write(phy, 0x0b, 0x0004); in bcm5421_enable_fiber()
663 phy->autoneg = autoneg; in bcm5421_enable_fiber()
671 static int bcm5461_poll_link(struct mii_phy* phy) in bcm5461_poll_link() argument
677 sungem_phy_write(phy, MII_NCONFIG, 0x7c00); in bcm5461_poll_link()
678 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5461_poll_link()
683 return genmii_poll_link(phy); in bcm5461_poll_link()
686 sungem_phy_write(phy, MII_NCONFIG, 0x7000); in bcm5461_poll_link()
687 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5461_poll_link()
697 static int bcm5461_read_link(struct mii_phy* phy) in bcm5461_read_link() argument
703 sungem_phy_write(phy, MII_NCONFIG, 0x7c00); in bcm5461_read_link()
704 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5461_read_link()
709 return bcm54xx_read_link(phy); in bcm5461_read_link()
712 phy->speed = SPEED_1000; in bcm5461_read_link()
715 sungem_phy_write(phy, MII_NCONFIG, 0x7000); in bcm5461_read_link()
716 phy_reg = sungem_phy_read(phy, MII_NCONFIG); in bcm5461_read_link()
719 phy->duplex |= DUPLEX_FULL; in bcm5461_read_link()
721 phy->duplex |= DUPLEX_HALF; in bcm5461_read_link()
726 static int bcm5461_enable_fiber(struct mii_phy* phy, int autoneg) in bcm5461_enable_fiber() argument
729 sungem_phy_write(phy, MII_NCONFIG, 0xfc0b); in bcm5461_enable_fiber()
733 sungem_phy_write(phy, MII_ADVERTISE, 0x01e0); in bcm5461_enable_fiber()
734 sungem_phy_write(phy, MII_BMCR, 0x1140); in bcm5461_enable_fiber()
737 sungem_phy_write(phy, MII_BMCR, 0x0140); in bcm5461_enable_fiber()
740 phy->autoneg = autoneg; in bcm5461_enable_fiber()
745 static int marvell_setup_aneg(struct mii_phy *phy, u32 advertise) in marvell_setup_aneg() argument
749 phy->autoneg = 1; in marvell_setup_aneg()
750 phy->speed = SPEED_10; in marvell_setup_aneg()
751 phy->duplex = DUPLEX_HALF; in marvell_setup_aneg()
752 phy->pause = 0; in marvell_setup_aneg()
753 phy->advertising = advertise; in marvell_setup_aneg()
756 adv = sungem_phy_read(phy, MII_ADVERTISE); in marvell_setup_aneg()
770 sungem_phy_write(phy, MII_ADVERTISE, adv); in marvell_setup_aneg()
778 adv = sungem_phy_read(phy, MII_M1011_PHY_SPEC_CONTROL); in marvell_setup_aneg()
786 sungem_phy_write(phy, MII_1000BASETCONTROL, adv); in marvell_setup_aneg()
789 ctl = sungem_phy_read(phy, MII_BMCR); in marvell_setup_aneg()
791 sungem_phy_write(phy, MII_BMCR, ctl); in marvell_setup_aneg()
796 static int marvell_setup_forced(struct mii_phy *phy, int speed, int fd) in marvell_setup_forced() argument
800 phy->autoneg = 0; in marvell_setup_forced()
801 phy->speed = speed; in marvell_setup_forced()
802 phy->duplex = fd; in marvell_setup_forced()
803 phy->pause = 0; in marvell_setup_forced()
805 ctl = sungem_phy_read(phy, MII_BMCR); in marvell_setup_forced()
828 ctl2 = sungem_phy_read(phy, MII_M1011_PHY_SPEC_CONTROL); in marvell_setup_forced()
837 sungem_phy_write(phy, MII_1000BASETCONTROL, ctl2); in marvell_setup_forced()
841 sungem_phy_write(phy, MII_BMCR, ctl); in marvell_setup_forced()
846 static int marvell_read_link(struct mii_phy *phy) in marvell_read_link() argument
850 if (phy->autoneg) { in marvell_read_link()
851 status = sungem_phy_read(phy, MII_M1011_PHY_SPEC_STATUS); in marvell_read_link()
855 phy->speed = SPEED_1000; in marvell_read_link()
857 phy->speed = SPEED_100; in marvell_read_link()
859 phy->speed = SPEED_10; in marvell_read_link()
861 phy->duplex = DUPLEX_FULL; in marvell_read_link()
863 phy->duplex = DUPLEX_HALF; in marvell_read_link()
866 phy->pause = (status & pmask) == pmask; in marvell_read_link()
1160 int sungem_phy_probe(struct mii_phy *phy, int mii_id) in sungem_phy_probe() argument
1168 * may re-probe the PHY regulary in sungem_phy_probe()
1170 phy->mii_id = mii_id; in sungem_phy_probe()
1172 /* Take PHY out of isloate mode and reset it. */ in sungem_phy_probe()
1173 rc = reset_one_mii_phy(phy, mii_id); in sungem_phy_probe()
1178 id = (sungem_phy_read(phy, MII_PHYSID1) << 16 | sungem_phy_read(phy, MII_PHYSID2)); in sungem_phy_probe()
1179 printk(KERN_DEBUG KBUILD_MODNAME ": " "PHY ID: %x, addr: %x\n", in sungem_phy_probe()
1188 phy->def = def; in sungem_phy_probe()
1192 phy->speed = 0; in sungem_phy_probe()
1193 phy->duplex = 0; in sungem_phy_probe()
1194 phy->pause = 0; in sungem_phy_probe()
1195 phy->advertising = 0; in sungem_phy_probe()