Lines Matching refs:mii_info

117 static void config_genmii_advert(struct uec_mii_info *mii_info);
118 static void genmii_setup_forced(struct uec_mii_info *mii_info);
119 static void genmii_restart_aneg(struct uec_mii_info *mii_info);
120 static int gbit_config_aneg(struct uec_mii_info *mii_info);
121 static int genmii_config_aneg(struct uec_mii_info *mii_info);
122 static int genmii_update_link(struct uec_mii_info *mii_info);
123 static int genmii_read_status(struct uec_mii_info *mii_info);
124 static u16 uec_phy_read(struct uec_mii_info *mii_info, u16 regnum);
125 static void uec_phy_write(struct uec_mii_info *mii_info, u16 regnum,
223 void mii_clear_phy_interrupt(struct uec_mii_info *mii_info) in mii_clear_phy_interrupt() argument
225 if (mii_info->phyinfo->ack_interrupt) in mii_clear_phy_interrupt()
226 mii_info->phyinfo->ack_interrupt(mii_info); in mii_clear_phy_interrupt()
229 void mii_configure_phy_interrupt(struct uec_mii_info *mii_info, in mii_configure_phy_interrupt() argument
232 mii_info->interrupts = interrupts; in mii_configure_phy_interrupt()
233 if (mii_info->phyinfo->config_intr) in mii_configure_phy_interrupt()
234 mii_info->phyinfo->config_intr(mii_info); in mii_configure_phy_interrupt()
241 static void config_genmii_advert(struct uec_mii_info *mii_info) in config_genmii_advert() argument
247 mii_info->advertising &= mii_info->phyinfo->features; in config_genmii_advert()
248 advertise = mii_info->advertising; in config_genmii_advert()
251 adv = uec_phy_read(mii_info, MII_ADVERTISE); in config_genmii_advert()
261 uec_phy_write(mii_info, MII_ADVERTISE, adv); in config_genmii_advert()
264 static void genmii_setup_forced(struct uec_mii_info *mii_info) in genmii_setup_forced() argument
267 u32 features = mii_info->phyinfo->features; in genmii_setup_forced()
269 ctrl = uec_phy_read(mii_info, MII_BMCR); in genmii_setup_forced()
275 switch (mii_info->speed) { in genmii_setup_forced()
282 mii_info->speed = SPEED_100; in genmii_setup_forced()
289 mii_info->speed = SPEED_10; in genmii_setup_forced()
295 ugphy_err("%s: Bad speed!", mii_info->dev->name); in genmii_setup_forced()
299 uec_phy_write(mii_info, MII_BMCR, ctrl); in genmii_setup_forced()
303 static void genmii_restart_aneg(struct uec_mii_info *mii_info) in genmii_restart_aneg() argument
307 ctl = uec_phy_read(mii_info, MII_BMCR); in genmii_restart_aneg()
309 uec_phy_write(mii_info, MII_BMCR, ctl); in genmii_restart_aneg()
312 static int gbit_config_aneg(struct uec_mii_info *mii_info) in gbit_config_aneg() argument
317 if (mii_info->autoneg) { in gbit_config_aneg()
319 config_genmii_advert(mii_info); in gbit_config_aneg()
320 advertise = mii_info->advertising; in gbit_config_aneg()
322 adv = uec_phy_read(mii_info, MII_CTRL1000); in gbit_config_aneg()
329 uec_phy_write(mii_info, MII_CTRL1000, adv); in gbit_config_aneg()
332 genmii_restart_aneg(mii_info); in gbit_config_aneg()
334 genmii_setup_forced(mii_info); in gbit_config_aneg()
340 static int marvell_config_aneg(struct uec_mii_info *mii_info) in marvell_config_aneg() argument
347 uec_phy_write(mii_info, MII_BMCR, BMCR_RESET); in marvell_config_aneg()
349 uec_phy_write(mii_info, 0x1d, 0x1f); in marvell_config_aneg()
350 uec_phy_write(mii_info, 0x1e, 0x200c); in marvell_config_aneg()
351 uec_phy_write(mii_info, 0x1d, 0x5); in marvell_config_aneg()
352 uec_phy_write(mii_info, 0x1e, 0); in marvell_config_aneg()
353 uec_phy_write(mii_info, 0x1e, 0x100); in marvell_config_aneg()
355 gbit_config_aneg(mii_info); in marvell_config_aneg()
360 static int genmii_config_aneg(struct uec_mii_info *mii_info) in genmii_config_aneg() argument
362 if (mii_info->autoneg) { in genmii_config_aneg()
367 if (!genmii_read_status(mii_info) && mii_info->link) in genmii_config_aneg()
368 if (mii_info->duplex == DUPLEX_FULL && in genmii_config_aneg()
369 mii_info->speed == SPEED_100) in genmii_config_aneg()
370 if (mii_info->advertising & in genmii_config_aneg()
374 config_genmii_advert(mii_info); in genmii_config_aneg()
375 genmii_restart_aneg(mii_info); in genmii_config_aneg()
377 genmii_setup_forced(mii_info); in genmii_config_aneg()
383 static int genmii_update_link(struct uec_mii_info *mii_info) in genmii_update_link() argument
388 uec_phy_read(mii_info, MII_BMSR); in genmii_update_link()
394 status = uec_phy_read(mii_info, MII_BMSR); in genmii_update_link()
404 mii_info->link = 0; in genmii_update_link()
410 status = uec_phy_read(mii_info, MII_BMSR); in genmii_update_link()
412 mii_info->link = 1; in genmii_update_link()
415 mii_info->link = 1; in genmii_update_link()
417 mii_info->link = 0; in genmii_update_link()
423 static int genmii_read_status(struct uec_mii_info *mii_info) in genmii_read_status() argument
429 err = genmii_update_link(mii_info); in genmii_read_status()
433 if (mii_info->autoneg) { in genmii_read_status()
434 status = uec_phy_read(mii_info, MII_STAT1000); in genmii_read_status()
437 mii_info->speed = SPEED_1000; in genmii_read_status()
439 mii_info->duplex = DUPLEX_FULL; in genmii_read_status()
441 mii_info->duplex = DUPLEX_HALF; in genmii_read_status()
443 status = uec_phy_read(mii_info, MII_LPA); in genmii_read_status()
446 mii_info->duplex = DUPLEX_FULL; in genmii_read_status()
448 mii_info->duplex = DUPLEX_HALF; in genmii_read_status()
450 mii_info->speed = SPEED_100; in genmii_read_status()
452 mii_info->speed = SPEED_10; in genmii_read_status()
454 mii_info->pause = 0; in genmii_read_status()
463 static int bcm_init(struct uec_mii_info *mii_info) in bcm_init() argument
465 struct eth_device *edev = mii_info->dev; in bcm_init()
468 gbit_config_aneg(mii_info); in bcm_init()
478 val = uec_phy_read(mii_info, MII_BMSR); in bcm_init()
482 uec_phy_write(mii_info, 0x18, 0x7 | (7 << 12)); in bcm_init()
484 val = uec_phy_read(mii_info, 0x18); in bcm_init()
490 uec_phy_write(mii_info, 0x18, val); in bcm_init()
496 static int uec_marvell_init(struct uec_mii_info *mii_info) in uec_marvell_init() argument
498 struct eth_device *edev = mii_info->dev; in uec_marvell_init()
509 temp = uec_phy_read(mii_info, MII_M1111_PHY_EXT_CR); in uec_marvell_init()
519 uec_phy_write(mii_info, MII_M1111_PHY_EXT_CR, temp); in uec_marvell_init()
521 temp = uec_phy_read(mii_info, MII_M1111_PHY_EXT_SR); in uec_marvell_init()
524 uec_phy_write(mii_info, MII_M1111_PHY_EXT_SR, temp); in uec_marvell_init()
526 uec_phy_write(mii_info, MII_BMCR, BMCR_RESET); in uec_marvell_init()
532 static int marvell_read_status(struct uec_mii_info *mii_info) in marvell_read_status() argument
538 err = genmii_update_link(mii_info); in marvell_read_status()
547 if (mii_info->autoneg && mii_info->link) { in marvell_read_status()
550 status = uec_phy_read(mii_info, MII_M1011_PHY_SPEC_STATUS); in marvell_read_status()
554 mii_info->duplex = DUPLEX_FULL; in marvell_read_status()
556 mii_info->duplex = DUPLEX_HALF; in marvell_read_status()
562 mii_info->speed = SPEED_1000; in marvell_read_status()
565 mii_info->speed = SPEED_100; in marvell_read_status()
568 mii_info->speed = SPEED_10; in marvell_read_status()
571 mii_info->pause = 0; in marvell_read_status()
577 static int marvell_ack_interrupt(struct uec_mii_info *mii_info) in marvell_ack_interrupt() argument
580 uec_phy_read(mii_info, MII_M1011_IEVENT); in marvell_ack_interrupt()
585 static int marvell_config_intr(struct uec_mii_info *mii_info) in marvell_config_intr() argument
587 if (mii_info->interrupts == MII_INTERRUPT_ENABLED) in marvell_config_intr()
588 uec_phy_write(mii_info, MII_M1011_IMASK, MII_M1011_IMASK_INIT); in marvell_config_intr()
590 uec_phy_write(mii_info, MII_M1011_IMASK, in marvell_config_intr()
596 static int dm9161_init(struct uec_mii_info *mii_info) in dm9161_init() argument
599 uec_phy_write(mii_info, MII_BMCR, uec_phy_read(mii_info, MII_BMCR) | in dm9161_init()
602 uec_phy_write(mii_info, MII_BMCR, uec_phy_read(mii_info, MII_BMCR) & in dm9161_init()
605 uec_phy_write(mii_info, MII_DM9161_SCR, MII_DM9161_SCR_INIT); in dm9161_init()
607 config_genmii_advert(mii_info); in dm9161_init()
609 genmii_config_aneg(mii_info); in dm9161_init()
614 static int dm9161_config_aneg(struct uec_mii_info *mii_info) in dm9161_config_aneg() argument
619 static int dm9161_read_status(struct uec_mii_info *mii_info) in dm9161_read_status() argument
625 err = genmii_update_link(mii_info); in dm9161_read_status()
632 if (mii_info->autoneg && mii_info->link) { in dm9161_read_status()
633 status = uec_phy_read(mii_info, MII_DM9161_SCSR); in dm9161_read_status()
635 mii_info->speed = SPEED_100; in dm9161_read_status()
637 mii_info->speed = SPEED_10; in dm9161_read_status()
640 mii_info->duplex = DUPLEX_FULL; in dm9161_read_status()
642 mii_info->duplex = DUPLEX_HALF; in dm9161_read_status()
648 static int dm9161_ack_interrupt(struct uec_mii_info *mii_info) in dm9161_ack_interrupt() argument
651 uec_phy_read(mii_info, MII_DM9161_INTR); in dm9161_ack_interrupt()
656 static int dm9161_config_intr(struct uec_mii_info *mii_info) in dm9161_config_intr() argument
658 if (mii_info->interrupts == MII_INTERRUPT_ENABLED) in dm9161_config_intr()
659 uec_phy_write(mii_info, MII_DM9161_INTR, MII_DM9161_INTR_INIT); in dm9161_config_intr()
661 uec_phy_write(mii_info, MII_DM9161_INTR, MII_DM9161_INTR_STOP); in dm9161_config_intr()
666 static void dm9161_close(struct uec_mii_info *mii_info) in dm9161_close() argument
670 static int fixed_phy_aneg(struct uec_mii_info *mii_info) in fixed_phy_aneg() argument
672 mii_info->autoneg = 0; /* Turn off auto negotiation for fixed phy */ in fixed_phy_aneg()
676 static int fixed_phy_read_status(struct uec_mii_info *mii_info) in fixed_phy_read_status() argument
681 if (strncmp(mii_info->dev->name, fixed_phy_port[i].name, in fixed_phy_read_status()
682 strlen(mii_info->dev->name)) == 0) { in fixed_phy_read_status()
683 mii_info->speed = fixed_phy_port[i].speed; in fixed_phy_read_status()
684 mii_info->duplex = fixed_phy_port[i].duplex; in fixed_phy_read_status()
685 mii_info->link = 1; /* Link is always UP */ in fixed_phy_read_status()
686 mii_info->pause = 0; in fixed_phy_read_status()
693 static int smsc_config_aneg(struct uec_mii_info *mii_info) in smsc_config_aneg() argument
698 static int smsc_read_status(struct uec_mii_info *mii_info) in smsc_read_status() argument
704 err = genmii_update_link(mii_info); in smsc_read_status()
713 if (mii_info->autoneg && mii_info->link) { in smsc_read_status()
716 status = uec_phy_read(mii_info, 0x1f); in smsc_read_status()
721 mii_info->duplex = DUPLEX_HALF; in smsc_read_status()
722 mii_info->speed = SPEED_10; in smsc_read_status()
725 mii_info->duplex = DUPLEX_FULL; in smsc_read_status()
726 mii_info->speed = SPEED_10; in smsc_read_status()
729 mii_info->duplex = DUPLEX_HALF; in smsc_read_status()
730 mii_info->speed = SPEED_100; in smsc_read_status()
733 mii_info->duplex = DUPLEX_FULL; in smsc_read_status()
734 mii_info->speed = SPEED_100; in smsc_read_status()
737 mii_info->pause = 0; in smsc_read_status()
824 static u16 uec_phy_read(struct uec_mii_info *mii_info, u16 regnum) in uec_phy_read() argument
826 return mii_info->mdio_read(mii_info->dev, mii_info->mii_id, regnum); in uec_phy_read()
829 static void uec_phy_write(struct uec_mii_info *mii_info, u16 regnum, u16 val) in uec_phy_write() argument
831 mii_info->mdio_write(mii_info->dev, mii_info->mii_id, regnum, val); in uec_phy_write()
837 struct phy_info *uec_get_phy_info(struct uec_mii_info *mii_info) in uec_get_phy_info() argument
845 phy_reg = uec_phy_read(mii_info, MII_PHYSID1); in uec_get_phy_info()
849 phy_reg = uec_phy_read(mii_info, MII_PHYSID2); in uec_get_phy_info()
875 struct uec_mii_info *mii_info; in marvell_phy_interface_mode() local
878 if (!uec->mii_info) { in marvell_phy_interface_mode()
882 mii_info = uec->mii_info; in marvell_phy_interface_mode()
886 uec_phy_write(mii_info, 0x00, 0x9140); in marvell_phy_interface_mode()
887 uec_phy_write(mii_info, 0x1d, 0x001f); in marvell_phy_interface_mode()
888 uec_phy_write(mii_info, 0x1e, 0x200c); in marvell_phy_interface_mode()
889 uec_phy_write(mii_info, 0x1d, 0x0005); in marvell_phy_interface_mode()
890 uec_phy_write(mii_info, 0x1e, 0x0000); in marvell_phy_interface_mode()
891 uec_phy_write(mii_info, 0x1e, 0x0100); in marvell_phy_interface_mode()
892 uec_phy_write(mii_info, 0x09, 0x0e00); in marvell_phy_interface_mode()
893 uec_phy_write(mii_info, 0x04, 0x01e1); in marvell_phy_interface_mode()
894 uec_phy_write(mii_info, 0x00, 0x9140); in marvell_phy_interface_mode()
895 uec_phy_write(mii_info, 0x00, 0x1000); in marvell_phy_interface_mode()
897 uec_phy_write(mii_info, 0x00, 0x2900); in marvell_phy_interface_mode()
898 uec_phy_write(mii_info, 0x14, 0x0cd2); in marvell_phy_interface_mode()
899 uec_phy_write(mii_info, 0x00, 0xa100); in marvell_phy_interface_mode()
900 uec_phy_write(mii_info, 0x09, 0x0000); in marvell_phy_interface_mode()
901 uec_phy_write(mii_info, 0x1b, 0x800b); in marvell_phy_interface_mode()
902 uec_phy_write(mii_info, 0x04, 0x05e1); in marvell_phy_interface_mode()
903 uec_phy_write(mii_info, 0x00, 0xa100); in marvell_phy_interface_mode()
904 uec_phy_write(mii_info, 0x00, 0x2100); in marvell_phy_interface_mode()
907 uec_phy_write(mii_info, 0x14, 0x8e40); in marvell_phy_interface_mode()
908 uec_phy_write(mii_info, 0x1b, 0x800b); in marvell_phy_interface_mode()
909 uec_phy_write(mii_info, 0x14, 0x0c82); in marvell_phy_interface_mode()
910 uec_phy_write(mii_info, 0x00, 0x8100); in marvell_phy_interface_mode()
916 if (mii_info->autoneg) { in marvell_phy_interface_mode()
917 status = uec_phy_read(mii_info, MII_BMCR); in marvell_phy_interface_mode()
918 uec_phy_write(mii_info, MII_BMCR, status | BMCR_ANENABLE); in marvell_phy_interface_mode()