Lines Matching refs:mac

61 static struct phydata *mii_get_valid_phydata(mii_handle_t mac, int phy);
62 static void mii_portmon(mii_handle_t mac);
71 static void postreset_ICS1890(mii_handle_t mac, int phy);
72 static void postreset_NS83840(mii_handle_t mac, int phy);
88 mii_handle_t mac;
91 if ((mac = (mii_handle_t)
95 mac->mii_write = writefunc;
96 mac->mii_read = readfunc;
97 mac->mii_dip = dip;
98 *macp = mac;
109 mii_probe_phy(mii_handle_t mac, int phy)
114 if (!mac || phy < 0 || phy > 31)
117 dip = mac->mii_dip;
120 mac->mii_read(dip, phy, MII_STATUS);
121 status = mac->mii_read(dip, phy, MII_STATUS);
124 mac->mii_read(dip, phy, MII_CONTROL);
127 mac->mii_read(dip, phy, MII_CONTROL), status);
148 mii_init_phy(mii_handle_t mac, int phy)
154 if ((mac == (mii_handle_t)NULL) || phy < 0 || phy > 31)
157 dip = mac->mii_dip;
160 if (mac->phys[phy])
163 mac->phys[phy] = phydata = (struct phydata *)
169 phydata->id = (ulong_t)mac->mii_read(dip, phy, MII_PHYIDH) << 16;
170 phydata->id |= (ulong_t)mac->mii_read(dip, phy, MII_PHYIDL);
176 mac->mii_dip, DDI_PROP_DONTPASS, "full-duplex", 0);
180 mac->mii_dip, DDI_PROP_DONTPASS, "speed", 0);
182 status = mac->mii_read(dip, phy, MII_STATUS);
203 kmem_free(mac->phys[phy], sizeof (struct phydata));
204 mac->phys[phy] = NULL;
278 (void) mii_sync(mac, phy);
280 if (ddi_getprop(DDI_DEV_T_NONE, mac->mii_dip, DDI_PROP_DONTPASS,
282 (void) mii_dump_phy(mac, phy);
292 mii_reset_phy(mii_handle_t mac, int phy, enum mii_wait_type wait)
297 if (!(phyd = mii_get_valid_phydata(mac, phy)))
301 mac->mii_write(mac->mii_dip, phy, MII_CONTROL,
313 control = mac->mii_read(mac->mii_dip, phy, MII_CONTROL);
324 control = mac->mii_read(mac->mii_dip, phy, MII_CONTROL);
337 (void) mii_sync(mac, phy);
352 mii_sync(mii_handle_t mac, int phy)
354 struct phydata *phyd = mac->phys[phy];
371 if (ddi_getlongprop(DDI_DEV_T_ANY, mac->mii_dip,
376 mac->mii_write(mac->mii_dip, phy,
386 mac->mii_write(mac->mii_dip, phy, MII_CONTROL, phyd->control);
388 phyd->phy_postreset(mac, phy);
391 (void) mii_fixspeed(mac, phy, phyd->fix_speed,
405 mii_disable_fullduplex(mii_handle_t mac, int phy)
407 void *dip = mac->mii_dip;
413 if (!(mac->mii_read(dip, phy, MII_STATUS) & MII_STATUS_CANAUTONEG)) {
423 miiadvert = mac->mii_read(dip, phy, MII_AN_ADVERT);
425 mac->mii_write(dip, phy, MII_AN_ADVERT,
430 expansion = mac->mii_read(dip, phy, MII_AN_EXPANSION);
439 return (mii_rsan(mac, phy, mii_wait_none));
449 mii_autoneg_enab(mii_handle_t mac, int phy)
452 if (!(phyd = mii_get_valid_phydata(mac, phy)))
455 mac->mii_write(mac->mii_dip, phy, MII_CONTROL, phyd->control);
463 mii_linkup(mii_handle_t mac, int phy)
471 mac->mii_read(mac->mii_dip, phy, MII_STATUS);
472 status = mac->mii_read(mac->mii_dip, phy, MII_STATUS);
486 mii_getspeed(mii_handle_t mac, int phy, int *speed, int *fulld)
490 if (!(phyd = mii_get_valid_phydata(mac, phy)))
506 return (phyd->phy_getspeed(mac, phy, speed, fulld));
514 mii_fixspeed(mii_handle_t mac, int phy, int speed, int fullduplex)
520 ddi_get_name(mac->mii_dip), speed,
524 if (!(phyd = mii_get_valid_phydata(mac, phy)))
534 ddi_get_name(mac->mii_dip), speed);
541 mac->mii_write(mac->mii_dip, phy, MII_CONTROL, phyd->control);
551 mii_isolate(mii_handle_t mac, int phy)
555 if (!(phyd = mii_get_valid_phydata(mac, phy)))
559 mac->mii_write(mac->mii_dip, phy, MII_CONTROL, phyd->control);
567 mii_unisolate(mii_handle_t mac, int phy)
571 if (!(phyd = mii_get_valid_phydata(mac, phy)))
575 mac->mii_write(mac->mii_dip, phy, MII_CONTROL, phyd->control);
584 mii_rsan(mii_handle_t mac, int phy, enum mii_wait_type wait)
591 !(phyd = mii_get_valid_phydata(mac, phy)))
597 dip = mac->mii_dip;
600 mac->mii_write(dip, phy, MII_CONTROL, phyd->control|MII_CONTROL_RSAN);
611 if (mac->mii_read(dip, phy, MII_STATUS) &
617 ddi_get_name(mac->mii_dip));
627 mii_dump_phy(mii_handle_t mac, int phy)
644 if (!(phydat = mii_get_valid_phydata(mac, phy)))
647 cmn_err(CE_NOTE, "%s: PHY %d, type %s", ddi_get_name(mac->mii_dip), phy,
652 miiregs[i], mac->mii_read(mac->mii_dip, phy, i));
655 phydat->phy_dump((struct mii_info *)mac, phy);
666 mii_start_portmon(mii_handle_t mac, mii_linkfunc_t notify, kmutex_t *lock)
668 if (mac->mii_linknotify || mac->portmon_timer)
670 mac->mii_linknotify = notify;
675 mac->lock = NULL; /* portmon wont try to aquire any lock this time */
676 mii_portmon(mac);
677 mac->lock = lock;
682 mii_stop_portmon(mii_handle_t mac)
684 if (!mac->mii_linknotify || !mac->portmon_timer)
687 mac->mii_linknotify = NULL;
688 mac->lock = NULL;
689 (void) untimeout(mac->portmon_timer);
690 mac->portmon_timer = 0;
695 mii_portmon(mii_handle_t mac)
705 if (!mac->mii_linknotify) /* Exiting */
708 if (mac->lock)
709 mutex_enter(mac->lock);
713 * callback to the mac driver if it has
716 if ((phydata = mac->phys[i]) != 0) {
717 state = mii_linkup(mac, i) ?
723 ddi_get_name(mac->mii_dip), i,
728 mac->mii_linknotify(mac->mii_dip, i, state);
733 mac->portmon_timer = timeout((void (*)(void*))mii_portmon, (void *)mac,
735 if (mac->lock)
736 mutex_exit(mac->lock);
744 mii_destroy(mii_handle_t mac)
749 (void) mii_stop_portmon(mac);
752 if (mac->phys[i])
753 kmem_free(mac->phys[i], sizeof (struct phydata));
755 kmem_free(mac, sizeof (*mac));
764 mii_get_valid_phydata(mii_handle_t mac, int phy)
766 if (!mac || phy > 31 || phy < 0 || !mac->phys[phy]) {
770 return (mac->phys[phy]);
778 dump_NS83840(mii_handle_t mac, int phy)
783 dip = mac->mii_dip;
785 mac->mii_read(dip, phy, 0x12));
787 mac->mii_read(dip, phy, 0x13));
789 mac->mii_read(dip, phy, 0x15));
791 mac->mii_read(dip, phy, 0x16));
793 mac->mii_read(dip, phy, 0x17));
796 mac->mii_read(dip, phy, 0x18));
798 mac->mii_read(dip, phy, 0x19)&0xf);
800 reg = mac->mii_read(dip, phy, 0x1b);
813 getspeed_NS83840(mii_handle_t mac, int phy, int *speed, int *fulld)
815 int exten = mac->mii_read(mac->mii_dip, phy, MII_AN_EXPANSION);
823 lpable = mac->mii_read(mac->mii_dip, phy, MII_AN_LPABLE);
824 anadv = mac->mii_read(mac->mii_dip, phy, MII_AN_ADVERT);
844 int addr = mac->mii_read(mac->mii_dip, phy, MII_83840_ADDR);
857 getspeed_82553(mii_handle_t mac, int phy, int *speed, int *fulld)
859 int ex0 = mac->mii_read(mac->mii_dip, phy, MII_82553_EX0);
870 getspeed_ICS1890(mii_handle_t mac, int phy, int *speed, int *fulld)
872 ushort_t quickpoll = mac->mii_read(mac->mii_dip, phy, ICS_QUICKPOLL);
879 dump_ICS1890(mii_handle_t mac, int phy)
881 ushort_t quickpoll = mac->mii_read(mac->mii_dip, phy, ICS_QUICKPOLL);
889 postreset_NS83840(mii_handle_t mac, int phy)
892 struct phydata *phyd = mac->phys[phy];
902 reg = mac->mii_read(mac->mii_dip, phy, 23) | (1<<10) | (1<<5);
903 mac->mii_write(mac->mii_dip, phy, 23, reg);
922 mac->mii_read(mac->mii_dip, phy, MII_AN_ADVERT));
924 mac->mii_write(mac->mii_dip, phy, MII_AN_ADVERT, 0x1e1);
929 postreset_ICS1890(mii_handle_t mac, int phy)
932 (void) mii_unisolate(mac, phy);
939 getspeed_generic(mii_handle_t mac, int phy, int *speed, int *fulld)
941 int exten = mac->mii_read(mac->mii_dip, phy, MII_AN_EXPANSION);
949 lpable = mac->mii_read(mac->mii_dip, phy, MII_AN_LPABLE);
950 anadv = mac->mii_read(mac->mii_dip, phy, MII_AN_ADVERT);