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

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
34 * USB-To-Ethernet adapter driver for Microchip's LAN78XX and related families.
42 * USB 2 to 10/100/1000 Mbps Ethernet with built-in USB hub
45 * This driver is based on the if_smsc driver, with lan78xx-specific
49 * ------------------
53 * - TX checksum offloading: Nothing has been implemented yet.
54 * - Direct address translation filtering: Implemented but untested.
55 * - VLAN tag removal.
56 * - Support for USB interrupt endpoints.
57 * - Latency Tolerance Messaging (LTM) support.
58 * - TCP LSO support.
120 "Microchip LAN78xx USB-GigE");
141 device_printf((sc)->sc_ue.ue_dev, "debug: " fmt, ##args); \
148 device_printf((sc)->sc_ue.ue_dev, "warning: " fmt, ##args)
151 device_printf((sc)->sc_ue.ue_dev, "error: " fmt, ##args)
192 #define MUGE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
193 #define MUGE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
194 #define MUGE_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t)
244 * The chip supports interrupt endpoints, however they aren't
264 * lan78xx_read_reg - Read a 32-bit register on the device
266 * @off: offset of the register
276 lan78xx_read_reg(struct muge_softc *sc, uint32_t off, uint32_t *data) in lan78xx_read_reg() argument
287 USETW(req.wIndex, off); in lan78xx_read_reg()
290 err = uether_do_request(&sc->sc_ue, &req, &buf, 1000); in lan78xx_read_reg()
292 muge_warn_printf(sc, "Failed to read register 0x%0x\n", off); in lan78xx_read_reg()
298 * lan78xx_write_reg - Write a 32-bit register on the device
300 * @off: offset of the register
301 * @data: the 32-bit value to write into the register
310 lan78xx_write_reg(struct muge_softc *sc, uint32_t off, uint32_t data) in lan78xx_write_reg() argument
323 USETW(req.wIndex, off); in lan78xx_write_reg()
326 err = uether_do_request(&sc->sc_ue, &req, &buf, 1000); in lan78xx_write_reg()
328 muge_warn_printf(sc, "Failed to write register 0x%0x\n", off); in lan78xx_write_reg()
333 * lan78xx_wait_for_bits - Poll on a register value until bits are cleared
360 uether_pause(&sc->sc_ue, hz / 100); in lan78xx_wait_for_bits()
361 } while (((usb_ticks_t)(ticks - start_ticks)) < max_ticks); in lan78xx_wait_for_bits()
367 * lan78xx_eeprom_read_raw - Read the attached EEPROM
369 * @off: the eeprom address offset
382 lan78xx_eeprom_read_raw(struct muge_softc *sc, uint16_t off, uint8_t *buf, in lan78xx_eeprom_read_raw() argument
392 locked = mtx_owned(&sc->sc_mtx); /* XXX */ in lan78xx_eeprom_read_raw()
396 if (sc->chipid == ETH_ID_REV_CHIP_ID_7800_) { in lan78xx_eeprom_read_raw()
414 val |= (ETH_E2P_CMD_ADDR_MASK_ & (off + i)); in lan78xx_eeprom_read_raw()
427 uether_pause(&sc->sc_ue, hz / 100); in lan78xx_eeprom_read_raw()
428 } while (((usb_ticks_t)(ticks - start_ticks)) < max_ticks); in lan78xx_eeprom_read_raw()
445 if (sc->chipid == ETH_ID_REV_CHIP_ID_7800_) { in lan78xx_eeprom_read_raw()
465 * @off: the otp address offset
479 lan78xx_otp_read_raw(struct muge_softc *sc, uint16_t off, uint8_t *buf, in lan78xx_otp_read_raw() argument
486 locked = mtx_owned(&sc->sc_mtx); in lan78xx_otp_read_raw()
498 muge_warn_printf(sc, "OTP off? failed to read data\n"); in lan78xx_otp_read_raw()
505 ((off + i) >> 8) & OTP_ADDR1_15_11); in lan78xx_otp_read_raw()
507 ((off + i) & OTP_ADDR2_10_3)); in lan78xx_otp_read_raw()
532 * @off: the otp address offset
545 lan78xx_otp_read(struct muge_softc *sc, uint16_t off, uint8_t *buf, in lan78xx_otp_read() argument
555 off += 0x100; /* XXX */ in lan78xx_otp_read()
557 err = -EINVAL; in lan78xx_otp_read()
560 err = lan78xx_otp_read_raw(sc, off, buf, buflen); in lan78xx_otp_read()
566 * lan78xx_setmacaddress - Set the mac address in the device
642 * lan78xx_miibus_readreg - Read a MII/MDIO register
651 * Returns the 16-bits read from the MII register, if this function fails
662 locked = mtx_owned(&sc->sc_mtx); in lan78xx_miibus_readreg()
693 * lan78xx_miibus_writereg - Writes a MII/MDIO register
714 if (sc->sc_phyno != phy) in lan78xx_miibus_writereg()
717 locked = mtx_owned(&sc->sc_mtx); in lan78xx_miibus_writereg()
744 * lan78xx_miibus_statchg - Called to detect phy status change
757 struct mii_data *mii = uether_getmii(&sc->sc_ue); in lan78xx_miibus_statchg()
764 locked = mtx_owned(&sc->sc_mtx); in lan78xx_miibus_statchg()
768 ifp = uether_getifp(&sc->sc_ue); in lan78xx_miibus_statchg()
774 sc->sc_flags &= ~MUGE_FLAG_LINK; in lan78xx_miibus_statchg()
775 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == in lan78xx_miibus_statchg()
778 switch (IFM_SUBTYPE(mii->mii_media_active)) { in lan78xx_miibus_statchg()
781 sc->sc_flags |= MUGE_FLAG_LINK; in lan78xx_miibus_statchg()
785 sc->sc_flags |= MUGE_FLAG_LINK; in lan78xx_miibus_statchg()
793 if ((sc->sc_flags & MUGE_FLAG_LINK) == 0) { in lan78xx_miibus_statchg()
807 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) { in lan78xx_miibus_statchg()
811 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_TXPAUSE) != 0) in lan78xx_miibus_statchg()
814 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0) in lan78xx_miibus_statchg()
819 switch(usbd_get_speed(sc->sc_ue.ue_udev)) { in lan78xx_miibus_statchg()
841 * lan78xx_set_mdix_auto - Configure the device to enable automatic
842 * crossover and polarity detection. LAN7800 provides HP Auto-MDIX
855 err = lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_set_mdix_auto()
858 buf = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_set_mdix_auto()
863 lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR); in lan78xx_set_mdix_auto()
864 err += lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_set_mdix_auto()
867 err += lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_set_mdix_auto()
873 sc->sc_mdix_ctl = buf; in lan78xx_set_mdix_auto()
877 * lan78xx_phy_init - Initialises the in-built MUGE phy
880 * Resets the PHY part of the chip and then initialises it to default
881 * values. The 'link down' and 'auto-negotiation complete' interrupts
900 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR, in lan78xx_phy_init()
905 uether_pause(&sc->sc_ue, hz / 100); in lan78xx_phy_init()
906 bmcr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
908 } while ((bmcr & BMCR_RESET) && ((ticks - start_ticks) < max_ticks)); in lan78xx_phy_init()
910 if (((usb_ticks_t)(ticks - start_ticks)) >= max_ticks) { in lan78xx_phy_init()
911 muge_err_printf(sc, "PHY reset timed-out\n"); in lan78xx_phy_init()
916 lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
918 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
922 /* Enable Auto-MDIX for crossover and polarity detection. */ in lan78xx_phy_init()
926 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_ANAR, in lan78xx_phy_init()
930 /* Restart auto-negotiation. */ in lan78xx_phy_init()
933 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR, bmcr); in lan78xx_phy_init()
934 bmcr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR); in lan78xx_phy_init()
937 if (sc->sc_led_modes_mask != 0) { in lan78xx_phy_init()
938 lmsr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
940 lmsr &= ~sc->sc_led_modes_mask; in lan78xx_phy_init()
941 lmsr |= sc->sc_led_modes; in lan78xx_phy_init()
942 lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, in lan78xx_phy_init()
947 if (sc->sc_leds != 0 && in lan78xx_phy_init()
951 hw_reg |= sc->sc_leds; in lan78xx_phy_init()
958 * lan78xx_chip_init - Initialises the chip after power on
982 "timed-out waiting for lite reset to complete\n"); in lan78xx_chip_init()
987 if ((err = lan78xx_setmacaddress(sc, sc->sc_ue.ue_eaddr)) != 0) { in lan78xx_chip_init()
998 sc->chipid = (buf & ETH_ID_REV_CHIP_ID_MASK_) >> 16; in lan78xx_chip_init()
999 sc->chiprev = buf & ETH_ID_REV_CHIP_REV_MASK_; in lan78xx_chip_init()
1000 switch (sc->chipid) { in lan78xx_chip_init()
1005 muge_warn_printf(sc, "Chip ID 0x%04x not yet supported\n", in lan78xx_chip_init()
1006 sc->chipid); in lan78xx_chip_init()
1009 device_printf(sc->sc_ue.ue_dev, "Chip ID 0x%04x rev %04x\n", sc->chipid, in lan78xx_chip_init()
1010 sc->chiprev); in lan78xx_chip_init()
1012 /* Respond to BULK-IN tokens with a NAK when RX FIFO is empty. */ in lan78xx_chip_init()
1025 switch (usbd_get_speed(sc->sc_ue.ue_udev)) { in lan78xx_chip_init()
1061 buf = (MUGE_MAX_RX_FIFO_SIZE - 512) / 512; in lan78xx_chip_init()
1064 buf = (MUGE_MAX_TX_FIFO_SIZE - 512) / 512; in lan78xx_chip_init()
1072 * properly set is handled in link-reset function in the Linux driver. in lan78xx_chip_init()
1096 "timed-out waiting for phy reset to complete\n"); in lan78xx_chip_init()
1101 if (sc->chipid == ETH_ID_REV_CHIP_ID_7800_ && in lan78xx_chip_init()
1131 * Set max frame length. In linux this is dev->mtu (which by default in lan78xx_chip_init()
1150 sc->sc_flags |= MUGE_FLAG_INIT_DONE; in lan78xx_chip_init()
1162 struct usb_ether *ue = &sc->sc_ue; in muge_bulk_read_callback()
1169 int off; in muge_bulk_read_callback() local
1190 off = 0; in muge_bulk_read_callback()
1192 while (off < actlen) { in muge_bulk_read_callback()
1194 off = ((off + 0x3) & ~0x3); in muge_bulk_read_callback()
1197 if (off + sizeof(rx_cmd_a) > actlen) in muge_bulk_read_callback()
1199 usbd_copy_out(pc, off, &rx_cmd_a, sizeof(rx_cmd_a)); in muge_bulk_read_callback()
1200 off += (sizeof(rx_cmd_a)); in muge_bulk_read_callback()
1204 if (off + sizeof(rx_cmd_b) > actlen) in muge_bulk_read_callback()
1206 usbd_copy_out(pc, off, &rx_cmd_b, sizeof(rx_cmd_b)); in muge_bulk_read_callback()
1207 off += (sizeof(rx_cmd_b)); in muge_bulk_read_callback()
1211 if (off + sizeof(rx_cmd_c) > actlen) in muge_bulk_read_callback()
1213 usbd_copy_out(pc, off, &rx_cmd_c, sizeof(rx_cmd_c)); in muge_bulk_read_callback()
1214 off += (sizeof(rx_cmd_c)); in muge_bulk_read_callback()
1217 if (off > actlen) in muge_bulk_read_callback()
1224 " pktlen %d actlen %d off %d\n", in muge_bulk_read_callback()
1225 rx_cmd_a, rx_cmd_b, rx_cmd_c, pktlen, actlen, off); in muge_bulk_read_callback()
1234 (pktlen > (actlen - off))) in muge_bulk_read_callback()
1246 if (pktlen > m->m_len) { in muge_bulk_read_callback()
1249 pktlen, m->m_len); in muge_bulk_read_callback()
1254 usbd_copy_out(pc, off, mtod(m, uint8_t *), in muge_bulk_read_callback()
1281 m->m_pkthdr.csum_flags |= in muge_bulk_read_callback()
1292 (off + pktlen), in muge_bulk_read_callback()
1293 &m->m_pkthdr.csum_data, 2); in muge_bulk_read_callback()
1301 m->m_pkthdr.csum_data = in muge_bulk_read_callback()
1306 m->m_pkthdr.csum_data); in muge_bulk_read_callback()
1316 uether_rxmbuf(ue, m, pktlen - 4); in muge_bulk_read_callback()
1323 off += pktlen; in muge_bulk_read_callback()
1344 * muge_bulk_write_callback - Write callback used to send ethernet frame(s)
1348 * The main write function that pulls ethernet frames off the queue and
1356 if_t ifp = uether_getifp(&sc->sc_ue); in muge_bulk_write_callback()
1371 if ((sc->sc_flags & MUGE_FLAG_LINK) == 0 || in muge_bulk_write_callback()
1374 "sc->sc_flags & MUGE_FLAG_LINK: %d\n", in muge_bulk_write_callback()
1375 (sc->sc_flags & MUGE_FLAG_LINK)); in muge_bulk_write_callback()
1399 * Each frame is prefixed with two 32-bit values in muge_bulk_write_callback()
1402 tx_cmd_a = (m->m_pkthdr.len & TX_CMD_A_LEN_MASK_) | in muge_bulk_write_callback()
1416 usbd_m_copy_in(pc, frm_len, m, 0, m->m_pkthdr.len); in muge_bulk_write_callback()
1417 frm_len += m->m_pkthdr.len; in muge_bulk_write_callback()
1456 * muge_set_mac_addr - Initiailizes NIC MAC address
1460 * EEPROM, DTB blob. If all sources fail - generates random MAC.
1468 memset(ue->ue_eaddr, 0xff, ETHER_ADDR_LEN); in muge_set_mac_addr()
1476 ue->ue_eaddr[5] = (uint8_t)((mac_h >> 8) & 0xff); in muge_set_mac_addr()
1477 ue->ue_eaddr[4] = (uint8_t)((mac_h) & 0xff); in muge_set_mac_addr()
1478 ue->ue_eaddr[3] = (uint8_t)((mac_l >> 24) & 0xff); in muge_set_mac_addr()
1479 ue->ue_eaddr[2] = (uint8_t)((mac_l >> 16) & 0xff); in muge_set_mac_addr()
1480 ue->ue_eaddr[1] = (uint8_t)((mac_l >> 8) & 0xff); in muge_set_mac_addr()
1481 ue->ue_eaddr[0] = (uint8_t)((mac_l) & 0xff); in muge_set_mac_addr()
1489 if (ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1492 ETH_E2P_MAC_OFFSET, ue->ue_eaddr, ETHER_ADDR_LEN) == 0 && in muge_set_mac_addr()
1493 ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1495 } else if (lan78xx_otp_read(sc, OTP_MAC_OFFSET, ue->ue_eaddr, in muge_set_mac_addr()
1496 ETHER_ADDR_LEN) == 0 && ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1501 /* ue->ue_eaddr modified only if config exists for this dev instance. */ in muge_set_mac_addr()
1502 usb_fdt_get_mac_addr(ue->ue_dev, ue); in muge_set_mac_addr()
1503 if (ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1508 if (!ETHER_IS_VALID(ue->ue_eaddr)) { in muge_set_mac_addr()
1510 arc4rand(ue->ue_eaddr, ETHER_ADDR_LEN, 0); in muge_set_mac_addr()
1511 ue->ue_eaddr[0] &= ~0x01; /* unicast */ in muge_set_mac_addr()
1512 ue->ue_eaddr[0] |= 0x02; /* locally administered */ in muge_set_mac_addr()
1517 * muge_set_leds - Initializes NIC LEDs pattern
1533 if ((node = usb_fdt_get_node(ue->ue_dev, ue->ue_udev)) != -1 && in muge_set_leds()
1534 (proplen = OF_getencprop(node, "microchip,led-modes", modes, in muge_set_leds()
1537 sc->sc_leds = (count > 0) * ETH_HW_CFG_LEDO_EN_ | in muge_set_leds()
1541 while (count-- > 0) { in muge_set_leds()
1542 sc->sc_led_modes |= (modes[count] & 0xf) << (4 * count); in muge_set_leds()
1543 sc->sc_led_modes_mask |= 0xf << (4 * count); in muge_set_leds()
1551 * muge_attach_post - Called after the driver attached to the USB interface
1554 * This is where the chip is intialised for the first time. This is
1567 sc->sc_phyno = 1; in muge_attach_post()
1572 /* Initialise the chip for the first time */ in muge_attach_post()
1577 * muge_attach_post_sub - Called after attach to the USB interface
1582 * that the chip supports H/W checksumming.
1595 ifp = ue->ue_ifp; in muge_attach_post_sub()
1604 * The chip supports TCP/UDP checksum offloading on TX and RX paths, in muge_attach_post_sub()
1633 mii_attach(ue->ue_dev, &ue->ue_miibus, ifp, uether_ifmedia_upd, in muge_attach_post_sub()
1634 ue->ue_methods->ue_mii_sts, BMSR_DEFCAPMASK, sc->sc_phyno, in muge_attach_post_sub()
1642 * muge_start - Starts communication with the LAN78xx chip
1653 usbd_transfer_start(sc->sc_xfer[MUGE_BULK_DT_RD]); in muge_start()
1654 usbd_transfer_start(sc->sc_xfer[MUGE_BULK_DT_WR]); in muge_start()
1658 * muge_ioctl - ioctl function for the device
1689 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in muge_ioctl()
1713 * muge_reset - Reset the SMSC chip
1725 cd = usbd_get_config_descriptor(sc->sc_ue.ue_udev); in muge_reset()
1727 err = usbd_req_set_config(sc->sc_ue.ue_udev, &sc->sc_mtx, in muge_reset()
1728 cd->bConfigurationValue); in muge_reset()
1732 /* Wait a little while for the chip to get its brains in order. */ in muge_reset()
1733 uether_pause(&sc->sc_ue, hz / 100); in muge_reset()
1758 sc->sc_pfilter_table[index][1] = tmp; in muge_set_addr_filter()
1762 sc->sc_pfilter_table[index][0] = tmp; in muge_set_addr_filter()
1767 * lan78xx_dataport_write - write to the selected RAM
1771 * @buf: word-sized buffer to write to RAM, starting at @addr.
1824 sc->sc_mchash_table); in muge_multicast_write()
1829 sc->sc_pfilter_table[i][1]); in muge_multicast_write()
1831 sc->sc_pfilter_table[i][0]); in muge_multicast_write()
1836 * muge_hash - Calculate the hash of a mac address
1844 * Returns a value from 0-63 value which is the hash of the mac address.
1863 sc->sc_mchash_table[bitnum / 32] |= (1 << (bitnum % 32)); in muge_hash_maddr()
1864 sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_HASH_; in muge_hash_maddr()
1871 * muge_setmulti - Setup multicast
1889 sc->sc_rfe_ctl &= ~(ETH_RFE_CTL_UCAST_EN_ | ETH_RFE_CTL_MCAST_EN_ | in muge_setmulti()
1894 sc->sc_mchash_table[i] = 0; in muge_setmulti()
1898 sc->sc_pfilter_table[i][0] = sc->sc_pfilter_table[i][1] = 0; in muge_setmulti()
1901 sc->sc_rfe_ctl |= ETH_RFE_CTL_BCAST_EN_; in muge_setmulti()
1905 sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_EN_ | ETH_RFE_CTL_UCAST_EN_; in muge_setmulti()
1908 sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_EN_; in muge_setmulti()
1913 lan78xx_write_reg(sc, ETH_RFE_CTL, sc->sc_rfe_ctl); in muge_setmulti()
1917 * muge_setpromisc - Enables/disables promiscuous mode
1935 sc->sc_rfe_ctl |= ETH_RFE_CTL_MCAST_EN_ | ETH_RFE_CTL_UCAST_EN_; in muge_setpromisc()
1937 sc->sc_rfe_ctl &= ~(ETH_RFE_CTL_MCAST_EN_); in muge_setpromisc()
1939 lan78xx_write_reg(sc, ETH_RFE_CTL, sc->sc_rfe_ctl); in muge_setpromisc()
1943 * muge_sethwcsum - Enable or disable H/W UDP and TCP checksumming
1955 if_t ifp = uether_getifp(&sc->sc_ue); in muge_sethwcsum()
1959 return (-EIO); in muge_sethwcsum()
1964 sc->sc_rfe_ctl |= ETH_RFE_CTL_IGMP_COE_ | ETH_RFE_CTL_ICMP_COE_; in muge_sethwcsum()
1965 sc->sc_rfe_ctl |= ETH_RFE_CTL_TCPUDP_COE_ | ETH_RFE_CTL_IP_COE_; in muge_sethwcsum()
1967 sc->sc_rfe_ctl &= in muge_sethwcsum()
1969 sc->sc_rfe_ctl &= in muge_sethwcsum()
1973 sc->sc_rfe_ctl &= ~ETH_RFE_CTL_VLAN_FILTER_; in muge_sethwcsum()
1975 err = lan78xx_write_reg(sc, ETH_RFE_CTL, sc->sc_rfe_ctl); in muge_sethwcsum()
1987 * muge_ifmedia_upd - Set media options
2004 struct mii_data *mii = uether_getmii(&sc->sc_ue); in muge_ifmedia_upd()
2010 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) in muge_ifmedia_upd()
2017 * muge_init - Initialises the LAN95xx chip
2052 usbd_xfer_set_stall(sc->sc_xfer[MUGE_BULK_DT_WR]); in muge_init()
2063 * muge_stop - Stops communication with the LAN78xx chip
2075 sc->sc_flags &= ~MUGE_FLAG_LINK; in muge_stop()
2080 usbd_transfer_stop(sc->sc_xfer[MUGE_BULK_DT_WR]); in muge_stop()
2081 usbd_transfer_stop(sc->sc_xfer[MUGE_BULK_DT_RD]); in muge_stop()
2085 * muge_tick - Called periodically to monitor the state of the LAN95xx chip
2098 struct mii_data *mii = uether_getmii(&sc->sc_ue); in muge_tick()
2103 if ((sc->sc_flags & MUGE_FLAG_LINK) == 0) { in muge_tick()
2104 lan78xx_miibus_statchg(ue->ue_dev); in muge_tick()
2105 if ((sc->sc_flags & MUGE_FLAG_LINK) != 0) in muge_tick()
2111 * muge_ifmedia_sts - Report current media status
2124 struct mii_data *mii = uether_getmii(&sc->sc_ue); in muge_ifmedia_sts()
2128 ifmr->ifm_active = mii->mii_media_active; in muge_ifmedia_sts()
2129 ifmr->ifm_status = mii->mii_media_status; in muge_ifmedia_sts()
2134 * muge_probe - Probe the interface.
2147 if (uaa->usb_mode != USB_MODE_HOST) in muge_probe()
2149 if (uaa->info.bConfigIndex != MUGE_CONFIG_INDEX) in muge_probe()
2151 if (uaa->info.bIfaceIndex != MUGE_IFACE_IDX) in muge_probe()
2157 * muge_attach - Attach the interface.
2170 struct usb_ether *ue = &sc->sc_ue; in muge_attach()
2174 sc->sc_flags = USB_GET_DRIVER_INFO(uaa); in muge_attach()
2178 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); in muge_attach()
2182 err = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, in muge_attach()
2183 muge_config, MUGE_N_TRANSFER, sc, &sc->sc_mtx); in muge_attach()
2189 ue->ue_sc = sc; in muge_attach()
2190 ue->ue_dev = dev; in muge_attach()
2191 ue->ue_udev = uaa->device; in muge_attach()
2192 ue->ue_mtx = &sc->sc_mtx; in muge_attach()
2193 ue->ue_methods = &muge_ue_methods; in muge_attach()
2201 /* Wait for lan78xx_chip_init from post-attach callback to complete. */ in muge_attach()
2203 if (!(sc->sc_flags & MUGE_FLAG_INIT_DONE)) in muge_attach()
2211 usbd_transfer_unsetup(sc->sc_xfer, MUGE_N_TRANSFER); in muge_attach()
2213 mtx_destroy(&sc->sc_mtx); in muge_attach()
2218 * muge_detach - Detach the interface.
2229 struct usb_ether *ue = &sc->sc_ue; in muge_detach()
2231 usbd_transfer_unsetup(sc->sc_xfer, MUGE_N_TRANSFER); in muge_detach()
2233 mtx_destroy(&sc->sc_mtx); in muge_detach()