Lines Matching +full:off +full:- +full:chip

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
33 * USB-To-Ethernet adapter driver for Microchip's LAN78XX and related families.
41 * USB 2 to 10/100/1000 Mbps Ethernet with built-in USB hub
44 * This driver is based on the if_smsc driver, with lan78xx-specific
48 * ------------------
52 * - TX checksum offloading: Nothing has been implemented yet.
53 * - Direct address translation filtering: Implemented but untested.
54 * - VLAN tag removal.
55 * - Support for USB interrupt endpoints.
56 * - Latency Tolerance Messaging (LTM) support.
57 * - TCP LSO support.
119 "Microchip LAN78xx USB-GigE");
140 device_printf((sc)->sc_ue.ue_dev, "debug: " fmt, ##args); \
147 device_printf((sc)->sc_ue.ue_dev, "warning: " fmt, ##args)
150 device_printf((sc)->sc_ue.ue_dev, "error: " fmt, ##args)
191 #define MUGE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
192 #define MUGE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
193 #define MUGE_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t)
243 * The chip supports interrupt endpoints, however they aren't
263 * lan78xx_read_reg - Read a 32-bit register on the device
265 * @off: offset of the register
275 lan78xx_read_reg(struct muge_softc *sc, uint32_t off, uint32_t *data) in lan78xx_read_reg() argument
286 USETW(req.wIndex, off); in lan78xx_read_reg()
289 err = uether_do_request(&sc->sc_ue, &req, &buf, 1000); in lan78xx_read_reg()
291 muge_warn_printf(sc, "Failed to read register 0x%0x\n", off); in lan78xx_read_reg()
297 * lan78xx_write_reg - Write a 32-bit register on the device
299 * @off: offset of the register
300 * @data: the 32-bit value to write into the register
309 lan78xx_write_reg(struct muge_softc *sc, uint32_t off, uint32_t data) in lan78xx_write_reg() argument
322 USETW(req.wIndex, off); in lan78xx_write_reg()
325 err = uether_do_request(&sc->sc_ue, &req, &buf, 1000); in lan78xx_write_reg()
327 muge_warn_printf(sc, "Failed to write register 0x%0x\n", off); in lan78xx_write_reg()
332 * lan78xx_wait_for_bits - Poll on a register value until bits are cleared
359 uether_pause(&sc->sc_ue, hz / 100); in lan78xx_wait_for_bits()
360 } while (((usb_ticks_t)(ticks - start_ticks)) < max_ticks); in lan78xx_wait_for_bits()
366 * lan78xx_eeprom_read_raw - Read the attached EEPROM
368 * @off: the eeprom address offset
381 lan78xx_eeprom_read_raw(struct muge_softc *sc, uint16_t off, uint8_t *buf, in lan78xx_eeprom_read_raw() argument
391 locked = mtx_owned(&sc->sc_mtx); /* XXX */ in lan78xx_eeprom_read_raw()
395 if (sc->chipid == ETH_ID_REV_CHIP_ID_7800_) { in lan78xx_eeprom_read_raw()
413 val |= (ETH_E2P_CMD_ADDR_MASK_ & (off + i)); in lan78xx_eeprom_read_raw()
426 uether_pause(&sc->sc_ue, hz / 100); in lan78xx_eeprom_read_raw()
427 } while (((usb_ticks_t)(ticks - start_ticks)) < max_ticks); in lan78xx_eeprom_read_raw()
444 if (sc->chipid == ETH_ID_REV_CHIP_ID_7800_) { in lan78xx_eeprom_read_raw()
464 * @off: the otp address offset
478 lan78xx_otp_read_raw(struct muge_softc *sc, uint16_t off, uint8_t *buf, in lan78xx_otp_read_raw() argument
485 locked = mtx_owned(&sc->sc_mtx); in lan78xx_otp_read_raw()
497 muge_warn_printf(sc, "OTP off? failed to read data\n"); in lan78xx_otp_read_raw()
504 ((off + i) >> 8) & OTP_ADDR1_15_11); in lan78xx_otp_read_raw()
506 ((off + i) & OTP_ADDR2_10_3)); in lan78xx_otp_read_raw()
531 * @off: the otp address offset
544 lan78xx_otp_read(struct muge_softc *sc, uint16_t off, uint8_t *buf, in lan78xx_otp_read() argument
554 off += 0x100; /* XXX */ in lan78xx_otp_read()
556 err = -EINVAL; in lan78xx_otp_read()
559 err = lan78xx_otp_read_raw(sc, off, buf, buflen); in lan78xx_otp_read()
565 * lan78xx_setmacaddress - Set the mac address in the device
641 * lan78xx_miibus_readreg - Read a MII/MDIO register
650 * Returns the 16-bits read from the MII register, if this function fails
661 locked = mtx_owned(&sc->sc_mtx); in lan78xx_miibus_readreg()
692 * lan78xx_miibus_writereg - Writes a MII/MDIO register
713 if (sc->sc_phyno != phy) in lan78xx_miibus_writereg()
716 locked = mtx_owned(&sc->sc_mtx); in lan78xx_miibus_writereg()
743 * lan78xx_miibus_statchg - Called to detect phy status change
756 struct mii_data *mii = uether_getmii(&sc->sc_ue); in lan78xx_miibus_statchg()
763 locked = mtx_owned(&sc->sc_mtx); in lan78xx_miibus_statchg()
767 ifp = uether_getifp(&sc->sc_ue); in lan78xx_miibus_statchg()
773 sc->sc_flags &= ~MUGE_FLAG_LINK; in lan78xx_miibus_statchg()
774 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == in lan78xx_miibus_statchg()
777 switch (IFM_SUBTYPE(mii->mii_media_active)) { in lan78xx_miibus_statchg()
780 sc->sc_flags |= MUGE_FLAG_LINK; in lan78xx_miibus_statchg()
784 sc->sc_flags |= MUGE_FLAG_LINK; in lan78xx_miibus_statchg()
792 if ((sc->sc_flags & MUGE_FLAG_LINK) == 0) { in lan78xx_miibus_statchg()
806 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) { in lan78xx_miibus_statchg()
810 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_TXPAUSE) != 0) in lan78xx_miibus_statchg()
813 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0) in lan78xx_miibus_statchg()
818 switch(usbd_get_speed(sc->sc_ue.ue_udev)) { in lan78xx_miibus_statchg()
840 * lan78xx_set_mdix_auto - Configure the device to enable automatic
841 * crossover and polarity detection. LAN7800 provides HP Auto-MDIX
854 err = lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_set_mdix_auto()
857 buf = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_set_mdix_auto()
862 lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR); in lan78xx_set_mdix_auto()
863 err += lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_set_mdix_auto()
866 err += lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_set_mdix_auto()
872 sc->sc_mdix_ctl = buf; in lan78xx_set_mdix_auto()
876 * lan78xx_phy_init - Initialises the in-built MUGE phy
879 * Resets the PHY part of the chip and then initialises it to default
880 * values. The 'link down' and 'auto-negotiation complete' interrupts
899 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR, in lan78xx_phy_init()
904 uether_pause(&sc->sc_ue, hz / 100); in lan78xx_phy_init()
905 bmcr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
907 } while ((bmcr & BMCR_RESET) && ((ticks - start_ticks) < max_ticks)); in lan78xx_phy_init()
909 if (((usb_ticks_t)(ticks - start_ticks)) >= max_ticks) { in lan78xx_phy_init()
910 muge_err_printf(sc, "PHY reset timed-out\n"); in lan78xx_phy_init()
915 lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
917 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
921 /* Enable Auto-MDIX for crossover and polarity detection. */ in lan78xx_phy_init()
925 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_ANAR, in lan78xx_phy_init()
929 /* Restart auto-negotiation. */ in lan78xx_phy_init()
932 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR, bmcr); in lan78xx_phy_init()
933 bmcr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR); in lan78xx_phy_init()
936 if (sc->sc_led_modes_mask != 0) { in lan78xx_phy_init()
937 lmsr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
939 lmsr &= ~sc->sc_led_modes_mask; in lan78xx_phy_init()
940 lmsr |= sc->sc_led_modes; in lan78xx_phy_init()
941 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
946 if (sc->sc_leds != 0 && in lan78xx_phy_init()
950 hw_reg |= sc->sc_leds; in lan78xx_phy_init()
957 * lan78xx_chip_init - Initialises the chip after power on
981 "timed-out waiting for lite reset to complete\n"); in lan78xx_chip_init()
986 if ((err = lan78xx_setmacaddress(sc, sc->sc_ue.ue_eaddr)) != 0) { in lan78xx_chip_init()
997 sc->chipid = (buf & ETH_ID_REV_CHIP_ID_MASK_) >> 16; in lan78xx_chip_init()
998 sc->chiprev = buf & ETH_ID_REV_CHIP_REV_MASK_; in lan78xx_chip_init()
999 switch (sc->chipid) { in lan78xx_chip_init()
1004 muge_warn_printf(sc, "Chip ID 0x%04x not yet supported\n", in lan78xx_chip_init()
1005 sc->chipid); in lan78xx_chip_init()
1008 device_printf(sc->sc_ue.ue_dev, "Chip ID 0x%04x rev %04x\n", sc->chipid, in lan78xx_chip_init()
1009 sc->chiprev); in lan78xx_chip_init()
1011 /* Respond to BULK-IN tokens with a NAK when RX FIFO is empty. */ in lan78xx_chip_init()
1024 switch (usbd_get_speed(sc->sc_ue.ue_udev)) { in lan78xx_chip_init()
1060 buf = (MUGE_MAX_RX_FIFO_SIZE - 512) / 512; in lan78xx_chip_init()
1063 buf = (MUGE_MAX_TX_FIFO_SIZE - 512) / 512; in lan78xx_chip_init()
1071 * properly set is handled in link-reset function in the Linux driver. in lan78xx_chip_init()
1095 "timed-out waiting for phy reset to complete\n"); in lan78xx_chip_init()
1100 if (sc->chipid == ETH_ID_REV_CHIP_ID_7800_ && in lan78xx_chip_init()
1130 * Set max frame length. In linux this is dev->mtu (which by default in lan78xx_chip_init()
1149 sc->sc_flags |= MUGE_FLAG_INIT_DONE; in lan78xx_chip_init()
1161 struct usb_ether *ue = &sc->sc_ue; in muge_bulk_read_callback()
1168 int off; in muge_bulk_read_callback() local
1189 off = 0; in muge_bulk_read_callback()
1191 while (off < actlen) { in muge_bulk_read_callback()
1193 off = ((off + 0x3) & ~0x3); in muge_bulk_read_callback()
1196 if (off + sizeof(rx_cmd_a) > actlen) in muge_bulk_read_callback()
1198 usbd_copy_out(pc, off, &rx_cmd_a, sizeof(rx_cmd_a)); in muge_bulk_read_callback()
1199 off += (sizeof(rx_cmd_a)); in muge_bulk_read_callback()
1203 if (off + sizeof(rx_cmd_b) > actlen) in muge_bulk_read_callback()
1205 usbd_copy_out(pc, off, &rx_cmd_b, sizeof(rx_cmd_b)); in muge_bulk_read_callback()
1206 off += (sizeof(rx_cmd_b)); in muge_bulk_read_callback()
1210 if (off + sizeof(rx_cmd_c) > actlen) in muge_bulk_read_callback()
1212 usbd_copy_out(pc, off, &rx_cmd_c, sizeof(rx_cmd_c)); in muge_bulk_read_callback()
1213 off += (sizeof(rx_cmd_c)); in muge_bulk_read_callback()
1216 if (off > actlen) in muge_bulk_read_callback()
1223 " pktlen %d actlen %d off %d\n", in muge_bulk_read_callback()
1224 rx_cmd_a, rx_cmd_b, rx_cmd_c, pktlen, actlen, off); in muge_bulk_read_callback()
1233 (pktlen > (actlen - off))) in muge_bulk_read_callback()
1245 if (pktlen > m->m_len) { in muge_bulk_read_callback()
1248 pktlen, m->m_len); in muge_bulk_read_callback()
1253 usbd_copy_out(pc, off, mtod(m, uint8_t *), in muge_bulk_read_callback()
1280 m->m_pkthdr.csum_flags |= in muge_bulk_read_callback()
1291 (off + pktlen), in muge_bulk_read_callback()
1292 &m->m_pkthdr.csum_data, 2); in muge_bulk_read_callback()
1300 m->m_pkthdr.csum_data = in muge_bulk_read_callback()
1305 m->m_pkthdr.csum_data); in muge_bulk_read_callback()
1315 uether_rxmbuf(ue, m, pktlen - 4); in muge_bulk_read_callback()
1322 off += pktlen; in muge_bulk_read_callback()
1343 * muge_bulk_write_callback - Write callback used to send ethernet frame(s)
1347 * The main write function that pulls ethernet frames off the queue and
1355 if_t ifp = uether_getifp(&sc->sc_ue); in muge_bulk_write_callback()
1370 if ((sc->sc_flags & MUGE_FLAG_LINK) == 0 || in muge_bulk_write_callback()
1373 "sc->sc_flags & MUGE_FLAG_LINK: %d\n", in muge_bulk_write_callback()
1374 (sc->sc_flags & MUGE_FLAG_LINK)); in muge_bulk_write_callback()
1398 * Each frame is prefixed with two 32-bit values in muge_bulk_write_callback()
1401 tx_cmd_a = (m->m_pkthdr.len & TX_CMD_A_LEN_MASK_) | in muge_bulk_write_callback()
1415 usbd_m_copy_in(pc, frm_len, m, 0, m->m_pkthdr.len); in muge_bulk_write_callback()
1416 frm_len += m->m_pkthdr.len; in muge_bulk_write_callback()
1455 * muge_set_mac_addr - Initiailizes NIC MAC address
1459 * EEPROM, DTB blob. If all sources fail - generates random MAC.
1467 memset(ue->ue_eaddr, 0xff, ETHER_ADDR_LEN); in muge_set_mac_addr()
1475 ue->ue_eaddr[5] = (uint8_t)((mac_h >> 8) & 0xff); in muge_set_mac_addr()
1476 ue->ue_eaddr[4] = (uint8_t)((mac_h) & 0xff); in muge_set_mac_addr()
1477 ue->ue_eaddr[3] = (uint8_t)((mac_l >> 24) & 0xff); in muge_set_mac_addr()
1478 ue->ue_eaddr[2] = (uint8_t)((mac_l >> 16) & 0xff); in muge_set_mac_addr()
1479 ue->ue_eaddr[1] = (uint8_t)((mac_l >> 8) & 0xff); in muge_set_mac_addr()
1480 ue->ue_eaddr[0] = (uint8_t)((mac_l) & 0xff); in muge_set_mac_addr()
1488 if (ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1491 ETH_E2P_MAC_OFFSET, ue->ue_eaddr, ETHER_ADDR_LEN) == 0 && in muge_set_mac_addr()
1492 ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1494 } else if (lan78xx_otp_read(sc, OTP_MAC_OFFSET, ue->ue_eaddr, in muge_set_mac_addr()
1495 ETHER_ADDR_LEN) == 0 && ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1500 /* ue->ue_eaddr modified only if config exists for this dev instance. */ in muge_set_mac_addr()
1501 usb_fdt_get_mac_addr(ue->ue_dev, ue); in muge_set_mac_addr()
1502 if (ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1507 if (!ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1509 arc4rand(ue->ue_eaddr, ETHER_ADDR_LEN, 0); in muge_set_mac_addr()
1510 ue->ue_eaddr[0] &= ~0x01; /* unicast */ in muge_set_mac_addr()
1511 ue->ue_eaddr[0] |= 0x02; /* locally administered */ in muge_set_mac_addr()
1516 * muge_set_leds - Initializes NIC LEDs pattern
1532 if ((node = usb_fdt_get_node(ue->ue_dev, ue->ue_udev)) != -1 && in muge_set_leds()
1533 (proplen = OF_getencprop(node, "microchip,led-modes", modes, in muge_set_leds()
1536 sc->sc_leds = (count > 0) * ETH_HW_CFG_LEDO_EN_ | in muge_set_leds()
1540 while (count-- > 0) { in muge_set_leds()
1541 sc->sc_led_modes |= (modes[count] & 0xf) << (4 * count); in muge_set_leds()
1542 sc->sc_led_modes_mask |= 0xf << (4 * count); in muge_set_leds()
1550 * muge_attach_post - Called after the driver attached to the USB interface
1553 * This is where the chip is intialised for the first time. This is
1566 sc->sc_phyno = 1; in muge_attach_post()
1571 /* Initialise the chip for the first time */ in muge_attach_post()
1576 * muge_attach_post_sub - Called after attach to the USB interface
1581 * that the chip supports H/W checksumming.
1594 ifp = ue->ue_ifp; in muge_attach_post_sub()
1603 * The chip supports TCP/UDP checksum offloading on TX and RX paths, in muge_attach_post_sub()
1632 mii_attach(ue->ue_dev, &ue->ue_miibus, ifp, uether_ifmedia_upd, in muge_attach_post_sub()
1633 ue->ue_methods->ue_mii_sts, BMSR_DEFCAPMASK, sc->sc_phyno, in muge_attach_post_sub()
1641 * muge_start - Starts communication with the LAN78xx chip
1652 usbd_transfer_start(sc->sc_xfer[MUGE_BULK_DT_RD]); in muge_start()
1653 usbd_transfer_start(sc->sc_xfer[MUGE_BULK_DT_WR]); in muge_start()
1657 * muge_ioctl - ioctl function for the device
1688 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in muge_ioctl()
1712 * muge_reset - Reset the SMSC chip
1724 cd = usbd_get_config_descriptor(sc->sc_ue.ue_udev); in muge_reset()
1726 err = usbd_req_set_config(sc->sc_ue.ue_udev, &sc->sc_mtx, in muge_reset()
1727 cd->bConfigurationValue); in muge_reset()
1731 /* Wait a little while for the chip to get its brains in order. */ in muge_reset()
1732 uether_pause(&sc->sc_ue, hz / 100); in muge_reset()
1757 sc->sc_pfilter_table[index][1] = tmp; in muge_set_addr_filter()
1761 sc->sc_pfilter_table[index][0] = tmp; in muge_set_addr_filter()
1766 * lan78xx_dataport_write - write to the selected RAM
1770 * @buf: word-sized buffer to write to RAM, starting at @addr.
1823 sc->sc_mchash_table); in muge_multicast_write()
1828 sc->sc_pfilter_table[i][1]); in muge_multicast_write()
1830 sc->sc_pfilter_table[i][0]); in muge_multicast_write()
1835 * muge_hash - Calculate the hash of a mac address
1843 * Returns a value from 0-63 value which is the hash of the mac address.
1862 sc->sc_mchash_table[bitnum / 32] |= (1 << (bitnum % 32)); in muge_hash_maddr()
1863 sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_HASH_; in muge_hash_maddr()
1870 * muge_setmulti - Setup multicast
1888 sc->sc_rfe_ctl &= ~(ETH_RFE_CTL_UCAST_EN_ | ETH_RFE_CTL_MCAST_EN_ | in muge_setmulti()
1893 sc->sc_mchash_table[i] = 0; in muge_setmulti()
1897 sc->sc_pfilter_table[i][0] = sc->sc_pfilter_table[i][1] = 0; in muge_setmulti()
1900 sc->sc_rfe_ctl |= ETH_RFE_CTL_BCAST_EN_; in muge_setmulti()
1904 sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_EN_ | ETH_RFE_CTL_UCAST_EN_; in muge_setmulti()
1907 sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_EN_; in muge_setmulti()
1912 lan78xx_write_reg(sc, ETH_RFE_CTL, sc->sc_rfe_ctl); in muge_setmulti()
1916 * muge_setpromisc - Enables/disables promiscuous mode
1934 sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_EN_ | ETH_RFE_CTL_UCAST_EN_; in muge_setpromisc()
1936 sc->sc_rfe_ctl &= ~(ETH_RFE_CTL_MCAST_EN_); in muge_setpromisc()
1938 lan78xx_write_reg(sc, ETH_RFE_CTL, sc->sc_rfe_ctl); in muge_setpromisc()
1942 * muge_sethwcsum - Enable or disable H/W UDP and TCP checksumming
1954 if_t ifp = uether_getifp(&sc->sc_ue); in muge_sethwcsum()
1958 return (-EIO); in muge_sethwcsum()
1963 sc->sc_rfe_ctl |= ETH_RFE_CTL_IGMP_COE_ | ETH_RFE_CTL_ICMP_COE_; in muge_sethwcsum()
1964 sc->sc_rfe_ctl |= ETH_RFE_CTL_TCPUDP_COE_ | ETH_RFE_CTL_IP_COE_; in muge_sethwcsum()
1966 sc->sc_rfe_ctl &= in muge_sethwcsum()
1968 sc->sc_rfe_ctl &= in muge_sethwcsum()
1972 sc->sc_rfe_ctl &= ~ETH_RFE_CTL_VLAN_FILTER_; in muge_sethwcsum()
1974 err = lan78xx_write_reg(sc, ETH_RFE_CTL, sc->sc_rfe_ctl); in muge_sethwcsum()
1986 * muge_ifmedia_upd - Set media options
2003 struct mii_data *mii = uether_getmii(&sc->sc_ue); in muge_ifmedia_upd()
2009 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) in muge_ifmedia_upd()
2016 * muge_init - Initialises the LAN95xx chip
2051 usbd_xfer_set_stall(sc->sc_xfer[MUGE_BULK_DT_WR]); in muge_init()
2062 * muge_stop - Stops communication with the LAN78xx chip
2074 sc->sc_flags &= ~MUGE_FLAG_LINK; in muge_stop()
2079 usbd_transfer_stop(sc->sc_xfer[MUGE_BULK_DT_WR]); in muge_stop()
2080 usbd_transfer_stop(sc->sc_xfer[MUGE_BULK_DT_RD]); in muge_stop()
2084 * muge_tick - Called periodically to monitor the state of the LAN95xx chip
2097 struct mii_data *mii = uether_getmii(&sc->sc_ue); in muge_tick()
2102 if ((sc->sc_flags & MUGE_FLAG_LINK) == 0) { in muge_tick()
2103 lan78xx_miibus_statchg(ue->ue_dev); in muge_tick()
2104 if ((sc->sc_flags & MUGE_FLAG_LINK) != 0) in muge_tick()
2110 * muge_ifmedia_sts - Report current media status
2123 struct mii_data *mii = uether_getmii(&sc->sc_ue); in muge_ifmedia_sts()
2127 ifmr->ifm_active = mii->mii_media_active; in muge_ifmedia_sts()
2128 ifmr->ifm_status = mii->mii_media_status; in muge_ifmedia_sts()
2133 * muge_probe - Probe the interface.
2146 if (uaa->usb_mode != USB_MODE_HOST) in muge_probe()
2148 if (uaa->info.bConfigIndex != MUGE_CONFIG_INDEX) in muge_probe()
2150 if (uaa->info.bIfaceIndex != MUGE_IFACE_IDX) in muge_probe()
2156 * muge_attach - Attach the interface.
2169 struct usb_ether *ue = &sc->sc_ue; in muge_attach()
2173 sc->sc_flags = USB_GET_DRIVER_INFO(uaa); in muge_attach()
2177 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); in muge_attach()
2181 err = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, in muge_attach()
2182 muge_config, MUGE_N_TRANSFER, sc, &sc->sc_mtx); in muge_attach()
2188 ue->ue_sc = sc; in muge_attach()
2189 ue->ue_dev = dev; in muge_attach()
2190 ue->ue_udev = uaa->device; in muge_attach()
2191 ue->ue_mtx = &sc->sc_mtx; in muge_attach()
2192 ue->ue_methods = &muge_ue_methods; in muge_attach()
2200 /* Wait for lan78xx_chip_init from post-attach callback to complete. */ in muge_attach()
2202 if (!(sc->sc_flags & MUGE_FLAG_INIT_DONE)) in muge_attach()
2210 usbd_transfer_unsetup(sc->sc_xfer, MUGE_N_TRANSFER); in muge_attach()
2212 mtx_destroy(&sc->sc_mtx); in muge_attach()
2217 * muge_detach - Detach the interface.
2228 struct usb_ether *ue = &sc->sc_ue; in muge_detach()
2230 usbd_transfer_unsetup(sc->sc_xfer, MUGE_N_TRANSFER); in muge_detach()
2232 mtx_destroy(&sc->sc_mtx); in muge_detach()