Lines Matching defs:sc
596 urtw_led_init(struct urtw_softc *sc)
601 if (error = urtw_read8_c(sc, URTW_PSR, &sc->sc_psr, 0))
603 error = urtw_eprom_read32(sc, URTW_EPROM_SWREV, &rev);
609 sc->sc_strategy = URTW_SW_LED_MODE1;
612 sc->sc_strategy = URTW_SW_LED_MODE3;
615 sc->sc_strategy = URTW_HW_LED;
620 sc->sc_strategy = URTW_SW_LED_MODE0;
624 sc->sc_gpio_ledpin = URTW_LED_PIN_GPIO0;
631 urtw_8225_write_s16(struct urtw_softc *sc, uint8_t addr, int index,
658 error = usb_pipe_ctrl_xfer_wait(sc->sc_udev->dev_default_ph, &req, &mp,
661 URTW8187_DBG(URTW_DEBUG_DEVREQ, (sc->sc_dev, CE_CONT,
672 urtw_8225_read(struct urtw_softc *sc, uint8_t addr, uint32_t *data)
682 if (error = urtw_read16_c(sc, URTW_RF_PINS_OUTPUT, &o1, 0))
684 if (error = urtw_read16_c(sc, URTW_RF_PINS_ENABLE, &o2, 0))
686 if (error = urtw_read16_c(sc, URTW_RF_PINS_SELECT, &o3, 0))
688 if (error = urtw_write16_c(sc, URTW_RF_PINS_ENABLE, o2 | 0xf, 0))
690 if (error = urtw_write16_c(sc, URTW_RF_PINS_SELECT, o3 | 0xf, 0))
693 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
697 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT, o1, 0))
704 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
708 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
712 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
720 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
724 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
728 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
733 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
737 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
741 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
748 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
752 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
756 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
760 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
765 if (error = urtw_read16_c(sc, URTW_RF_PINS_INPUT, &tmp, 0))
768 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
774 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
780 if (error = urtw_write16_c(sc, URTW_RF_PINS_ENABLE, o2, 0))
782 if (error = urtw_write16_c(sc, URTW_RF_PINS_SELECT, o3, 0))
784 error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT, 0x3a0, 0);
799 urtw_8225_write_c(struct urtw_softc *sc, uint8_t addr, uint16_t data)
804 if (error = urtw_read16_c(sc, URTW_RF_PINS_OUTPUT, &d80, 0))
807 if (error = urtw_read16_c(sc, URTW_RF_PINS_ENABLE, &d82, 0))
809 if (error = urtw_read16_c(sc, URTW_RF_PINS_SELECT, &d84, 0))
812 if (error = urtw_write16_c(sc, URTW_RF_PINS_ENABLE,
815 if (error = urtw_write16_c(sc, URTW_RF_PINS_SELECT,
819 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
823 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT, d80, 0))
826 error = urtw_8225_write_s16(sc, addr, 0x8225, &data);
830 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
833 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT,
836 error = urtw_write16_c(sc, URTW_RF_PINS_SELECT, d84, 0);
843 urtw_8225_isv2(struct urtw_softc *sc, int *ret)
850 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT, 0x0080, 0))
852 if (error = urtw_write16_c(sc, URTW_RF_PINS_SELECT, 0x0080, 0))
854 if (error = urtw_write16_c(sc, URTW_RF_PINS_ENABLE, 0x0080, 0))
858 if (error = urtw_8225_write_c(sc, 0x0, 0x1b7))
861 error = urtw_8225_read(sc, 0x8, &data);
867 error = urtw_8225_read(sc, 0x9, &data);
874 error = urtw_8225_write_c(sc, 0x0, 0xb7);
880 urtw_get_rfchip(struct urtw_softc *sc)
882 struct urtw_rf *rf = &sc->sc_rf;
887 rf->rf_sc = sc;
889 if (sc->sc_hwrev & URTW_HWREV_8187) {
890 error = urtw_eprom_read32(sc, URTW_EPROM_RFCHIPID, &data);
897 error = urtw_8225_isv2(sc, &ret);
900 (sc->sc_dev, CE_CONT,
906 (sc->sc_dev, CE_CONT,
913 (sc->sc_dev, CE_CONT,
925 (sc->sc_dev, CE_CONT,
943 urtw_get_txpwr(struct urtw_softc *sc)
949 error = urtw_eprom_read32(sc, URTW_EPROM_TXPW_BASE, &data);
952 sc->sc_txpwr_cck_base = data & 0xf;
953 sc->sc_txpwr_ofdm_base = (data >> 4) & 0xf;
956 error = urtw_eprom_read32(sc, URTW_EPROM_TXPW0 + j, &data);
959 sc->sc_txpwr_cck[i] = data & 0xf;
960 sc->sc_txpwr_cck[i + 1] = (data & 0xf00) >> 8;
961 sc->sc_txpwr_ofdm[i] = (data & 0xf0) >> 4;
962 sc->sc_txpwr_ofdm[i + 1] = (data & 0xf000) >> 12;
965 error = urtw_eprom_read32(sc, URTW_EPROM_TXPW1 + j, &data);
968 sc->sc_txpwr_cck[i + 6] = data & 0xf;
969 sc->sc_txpwr_cck[i + 6 + 1] = (data & 0xf00) >> 8;
970 sc->sc_txpwr_ofdm[i + 6] = (data & 0xf0) >> 4;
971 sc->sc_txpwr_ofdm[i + 6 + 1] = (data & 0xf000) >> 12;
973 if (sc->sc_hwrev & URTW_HWREV_8187) {
975 error = urtw_eprom_read32(sc, URTW_EPROM_TXPW2 + j,
979 sc->sc_txpwr_cck[i + 6 + 4] = data & 0xf;
980 sc->sc_txpwr_cck[i + 6 + 4 + 1] = (data & 0xf00) >> 8;
981 sc->sc_txpwr_ofdm[i + 6 + 4] = (data & 0xf0) >> 4;
982 sc->sc_txpwr_ofdm[i + 6 + 4 + 1] =
987 error = urtw_eprom_read32(sc, 0x1b, &data);
990 sc->sc_txpwr_cck[11] = data & 0xf;
991 sc->sc_txpwr_ofdm[11] = (data & 0xf0) >> 4;
994 error = urtw_eprom_read32(sc, 0xa, &data);
997 sc->sc_txpwr_cck[12] = data & 0xf;
998 sc->sc_txpwr_ofdm[12] = (data & 0xf0) >> 4;
1001 error = urtw_eprom_read32(sc, 0x1c, &data);
1004 sc->sc_txpwr_cck[13] = data & 0xf;
1005 sc->sc_txpwr_ofdm[13] = (data & 0xf0) >> 4;
1006 sc->sc_txpwr_cck[14] = (data & 0xf00) >> 8;
1007 sc->sc_txpwr_ofdm[14] = (data & 0xf000) >> 12;
1015 urtw_get_macaddr(struct urtw_softc *sc)
1021 error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR, &data);
1024 sc->sc_bssid[0] = data & 0xff;
1025 sc->sc_bssid[1] = (data & 0xff00) >> 8;
1026 error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 1, &data);
1029 sc->sc_bssid[2] = data & 0xff;
1030 sc->sc_bssid[3] = (data & 0xff00) >> 8;
1031 error = urtw_eprom_read32(sc, URTW_EPROM_MACADDR + 2, &data);
1034 sc->sc_bssid[4] = data & 0xff;
1035 sc->sc_bssid[5] = (data & 0xff00) >> 8;
1036 bcopy(sc->sc_bssid, sc->sc_ic.ic_macaddr, IEEE80211_ADDR_LEN);
1037 m = sc->sc_bssid;
1038 URTW8187_DBG(URTW_DEBUG_HWTYPE, (sc->sc_dev, CE_CONT,
1046 urtw_eprom_read32(struct urtw_softc *sc, uint32_t addr, uint32_t *data)
1057 if (error = urtw_write8_c(sc, URTW_EPROM_CMD,
1062 error = urtw_eprom_cs(sc, URTW_EPROM_ENABLE);
1065 error = urtw_eprom_ck(sc);
1068 error = urtw_eprom_sendbits(sc, readcmd, URTW_READCMD_LEN);
1071 if (sc->sc_epromtype == URTW_EEPROM_93C56) {
1090 error = urtw_eprom_sendbits(sc, addrstr, addrlen);
1094 error = urtw_eprom_writebit(sc, 0);
1099 error = urtw_eprom_ck(sc);
1102 error = urtw_eprom_readbit(sc, &data16);
1109 error = urtw_eprom_cs(sc, URTW_EPROM_DISABLE);
1112 error = urtw_eprom_ck(sc);
1117 error = urtw_write8_c(sc, URTW_EPROM_CMD,
1125 urtw_eprom_readbit(struct urtw_softc *sc, int16_t *data)
1130 error = urtw_read8_c(sc, URTW_EPROM_CMD, &data8, 0);
1137 urtw_eprom_sendbits(struct urtw_softc *sc, int16_t *buf, int buflen)
1143 error = urtw_eprom_writebit(sc, buf[i]);
1146 error = urtw_eprom_ck(sc);
1155 urtw_eprom_writebit(struct urtw_softc *sc, int16_t bit)
1160 if (error = urtw_read8_c(sc, URTW_EPROM_CMD, &data, 0))
1163 error = urtw_write8_c(sc, URTW_EPROM_CMD,
1166 error = urtw_write8_c(sc, URTW_EPROM_CMD,
1174 urtw_eprom_ck(struct urtw_softc *sc)
1180 if (error = urtw_read8_c(sc, URTW_EPROM_CMD, &data, 0))
1182 if (error = urtw_write8_c(sc, URTW_EPROM_CMD, data | URTW_EPROM_CK, 0))
1186 if (error = urtw_read8_c(sc, URTW_EPROM_CMD, &data, 0))
1188 error = urtw_write8_c(sc, URTW_EPROM_CMD, data & ~URTW_EPROM_CK, 0);
1195 urtw_eprom_cs(struct urtw_softc *sc, int able)
1200 if (error = urtw_read8_c(sc, URTW_EPROM_CMD, &data, 0))
1203 error = urtw_write8_c(sc, URTW_EPROM_CMD,
1206 error = urtw_write8_c(sc, URTW_EPROM_CMD,
1214 urtw_read8_c(struct urtw_softc *sc, int val, uint8_t *data, uint8_t idx)
1229 error = usb_pipe_ctrl_xfer_wait(sc->sc_udev->dev_default_ph, &req, &mp,
1233 URTW8187_DBG(URTW_DEBUG_DEVREQ, (sc->sc_dev, CE_CONT,
1245 urtw_read8e(struct urtw_softc *sc, int val, uint8_t *data)
1260 error = usb_pipe_ctrl_xfer_wait(sc->sc_udev->dev_default_ph, &req, &mp,
1264 URTW8187_DBG(URTW_DEBUG_DEVREQ, (sc->sc_dev, CE_CONT,
1278 urtw_read16_c(struct urtw_softc *sc, int val, uint16_t *data, uint8_t idx)
1293 error = usb_pipe_ctrl_xfer_wait(sc->sc_udev->dev_default_ph, &req, &mp,
1297 URTW8187_DBG(URTW_DEBUG_DEVREQ, (sc->sc_dev, CE_CONT,
1311 urtw_read32_c(struct urtw_softc *sc, int val, uint32_t *data, uint8_t idx)
1327 error = usb_pipe_ctrl_xfer_wait(sc->sc_udev->dev_default_ph, &req, &mp,
1331 URTW8187_DBG(URTW_DEBUG_DEVREQ, (sc->sc_dev, CE_CONT,
1345 urtw_write8_c(struct urtw_softc *sc, int val, uint8_t data, uint8_t idx)
1368 error = usb_pipe_ctrl_xfer_wait(sc->sc_udev->dev_default_ph, &req, &mp,
1371 URTW8187_DBG(URTW_DEBUG_DEVREQ, (sc->sc_dev, CE_CONT,
1381 urtw_write8e(struct urtw_softc *sc, int val, uint8_t data)
1405 error = usb_pipe_ctrl_xfer_wait(sc->sc_udev->dev_default_ph, &req, &mp,
1408 URTW8187_DBG(URTW_DEBUG_DEVREQ, (sc->sc_dev, CE_CONT,
1419 urtw_write16_c(struct urtw_softc *sc, int val, uint16_t data, uint8_t idx)
1442 error = usb_pipe_ctrl_xfer_wait(sc->sc_udev->dev_default_ph, &req, &mp,
1445 URTW8187_DBG(URTW_DEBUG_DEVREQ, (sc->sc_dev, CE_CONT,
1456 urtw_write32_c(struct urtw_softc *sc, int val, uint32_t data, uint8_t idx)
1479 error = usb_pipe_ctrl_xfer_wait(sc->sc_udev->dev_default_ph, &req, &mp,
1482 URTW8187_DBG(URTW_DEBUG_DEVREQ, (sc->sc_dev, CE_CONT,
1494 urtw_set_mode(struct urtw_softc *sc, uint32_t mode)
1499 if (error = urtw_read8_c(sc, URTW_EPROM_CMD, &data, 0))
1503 error = urtw_write8_c(sc, URTW_EPROM_CMD, data, 0);
1509 urtw_8180_set_anaparam(struct urtw_softc *sc, uint32_t val)
1514 error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG);
1518 if (error = urtw_read8_c(sc, URTW_CONFIG3, &data, 0))
1520 if (error = urtw_write8_c(sc, URTW_CONFIG3,
1523 if (error = urtw_write32_c(sc, URTW_ANAPARAM, val, 0))
1525 if (error = urtw_read8_c(sc, URTW_CONFIG3, &data, 0))
1527 if (error = urtw_write8_c(sc, URTW_CONFIG3,
1531 error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL);
1539 urtw_8185_set_anaparam2(struct urtw_softc *sc, uint32_t val)
1544 error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG);
1548 if (error = urtw_read8_c(sc, URTW_CONFIG3, &data, 0))
1550 if (error = urtw_write8_c(sc, URTW_CONFIG3,
1553 if (error = urtw_write32_c(sc, URTW_ANAPARAM2, val, 0))
1555 if (error = urtw_read8_c(sc, URTW_CONFIG3, &data, 0))
1557 if (error = urtw_write8_c(sc, URTW_CONFIG3,
1561 error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL);
1569 urtw_intr_disable(struct urtw_softc *sc)
1573 error = urtw_write16_c(sc, URTW_INTR_MASK, 0, 0);
1578 urtw_8187_reset(struct urtw_softc *sc)
1583 error = urtw_8180_set_anaparam(sc, URTW_8187_8225_ANAPARAM_ON);
1586 error = urtw_8185_set_anaparam2(sc, URTW_8187_8225_ANAPARAM2_ON);
1590 error = urtw_intr_disable(sc);
1595 error = urtw_write8e(sc, 0x18, 0x10);
1598 error = urtw_write8e(sc, 0x18, 0x11);
1601 error = urtw_write8e(sc, 0x18, 0x00);
1606 if (error = urtw_read8_c(sc, URTW_CMD, &data, 0))
1609 if (error = urtw_write8_c(sc, URTW_CMD, data, 0))
1613 if (error = urtw_read8_c(sc, URTW_CMD, &data, 0))
1619 error = urtw_set_mode(sc, URTW_EPROM_CMD_LOAD);
1624 error = urtw_8180_set_anaparam(sc, URTW_8187_8225_ANAPARAM_ON);
1627 error = urtw_8185_set_anaparam2(sc, URTW_8187_8225_ANAPARAM2_ON);
1635 urtw_led_on(struct urtw_softc *sc, int type)
1638 switch (sc->sc_gpio_ledpin) {
1640 (void) urtw_write8_c(sc, URTW_GPIO, 0x01, 0);
1641 (void) urtw_write8_c(sc, URTW_GP_ENABLE, 0x00, 0);
1645 sc->sc_gpio_ledpin);
1653 sc->sc_gpio_ledon = 1;
1658 urtw_led_off(struct urtw_softc *sc, int type)
1661 switch (sc->sc_gpio_ledpin) {
1663 (void) urtw_write8_c(sc, URTW_GPIO, 0x01, 0);
1664 (void) urtw_write8_c(sc, URTW_GP_ENABLE, 0x01, 0);
1668 sc->sc_gpio_ledpin);
1676 sc->sc_gpio_ledon = 0;
1681 urtw_led_mode0(struct urtw_softc *sc, int mode)
1683 URTW8187_DBG(URTW_DEBUG_LED, (sc->sc_dev, CE_CONT,
1687 sc->sc_gpio_ledstate = URTW_LED_POWER_ON_BLINK;
1690 if (sc->sc_gpio_ledinprogress == 1)
1692 sc->sc_gpio_ledstate = URTW_LED_BLINK_NORMAL;
1693 sc->sc_gpio_blinktime =
1694 (sc->sc_ic.ic_state == IEEE80211_S_RUN ? 4:2);
1697 sc->sc_gpio_ledstate = URTW_LED_ON;
1704 switch (sc->sc_gpio_ledstate) {
1706 if (sc->sc_gpio_ledinprogress != 0)
1708 (void) urtw_led_on(sc, URTW_LED_GPIO);
1711 if (sc->sc_gpio_ledinprogress != 0)
1713 sc->sc_gpio_ledinprogress = 1;
1714 sc->sc_gpio_blinkstate = (sc->sc_gpio_ledon != 0) ?
1716 URTW_LEDLOCK(sc);
1717 if (sc->sc_led_ch == 0) {
1718 URTW8187_DBG(URTW_DEBUG_LED, (sc->sc_dev, CE_CONT,
1720 sc->sc_led_ch = timeout(urtw_led_launch,
1721 (void *)sc,
1722 drv_usectohz((sc->sc_ic.ic_state ==
1726 sc->sc_gpio_ledinprogress = 0;
1728 URTW_LEDUNLOCK(sc);
1731 (void) urtw_led_on(sc, URTW_LED_GPIO);
1733 (void) urtw_led_off(sc, URTW_LED_GPIO);
1736 URTW8187_DBG(URTW_DEBUG_LED, (sc->sc_dev, CE_CONT,
1738 sc->sc_gpio_ledstate));
1744 urtw_led_mode1(struct urtw_softc *sc, int mode)
1746 cmn_err(CE_WARN, "urtw sc %p, mode %d not supported", (void *)sc, mode);
1751 urtw_led_mode2(struct urtw_softc *sc, int mode)
1753 cmn_err(CE_WARN, "urtw sc %p, mode %d not supported", (void *)sc, mode);
1758 urtw_led_mode3(struct urtw_softc *sc, int mode)
1760 cmn_err(CE_WARN, "urtw sc %p, mode %d not supported", (void *)sc, mode);
1765 urtw_led_blink(struct urtw_softc *sc)
1769 URTW8187_DBG(URTW_DEBUG_LED, (sc->sc_dev, CE_CONT,
1771 sc->sc_gpio_blinkstate));
1772 if (sc->sc_gpio_blinkstate == URTW_LED_ON)
1773 (void) urtw_led_on(sc, URTW_LED_GPIO);
1775 (void) urtw_led_off(sc, URTW_LED_GPIO);
1776 sc->sc_gpio_blinktime--;
1777 if (sc->sc_gpio_blinktime == 0)
1780 if (sc->sc_gpio_ledstate != URTW_LED_BLINK_NORMAL &&
1781 sc->sc_gpio_ledstate != URTW_LED_BLINK_SLOWLY &&
1782 sc->sc_gpio_ledstate != URTW_LED_BLINK_CM3)
1786 if (sc->sc_gpio_ledstate == URTW_LED_ON &&
1787 sc->sc_gpio_ledon == 0)
1788 (void) urtw_led_on(sc, URTW_LED_GPIO);
1789 else if (sc->sc_gpio_ledstate == URTW_LED_OFF &&
1790 sc->sc_gpio_ledon == 1)
1791 (void) urtw_led_off(sc, URTW_LED_GPIO);
1793 sc->sc_gpio_blinktime = 0;
1794 sc->sc_gpio_ledinprogress = 0;
1798 sc->sc_gpio_blinkstate = (sc->sc_gpio_blinkstate != URTW_LED_ON) ?
1801 switch (sc->sc_gpio_ledstate) {
1803 URTW8187_DBG(URTW_DEBUG_LED, (sc->sc_dev, CE_CONT,
1807 URTW8187_DBG(URTW_DEBUG_LED, (sc->sc_dev, CE_CONT,
1808 "unknown LED status 0x%x", sc->sc_gpio_ledstate));
1814 urtw_led_ctl(struct urtw_softc *sc, int mode)
1818 switch (sc->sc_strategy) {
1820 error = urtw_led_mode0(sc, mode);
1823 error = urtw_led_mode1(sc, mode);
1826 error = urtw_led_mode2(sc, mode);
1829 error = urtw_led_mode3(sc, mode);
1832 cmn_err(CE_CONT, "unsupported LED mode %d\n", sc->sc_strategy);
1841 urtw_update_msr(struct urtw_softc *sc, int nstate)
1843 struct ieee80211com *ic = &sc->sc_ic;
1847 if (error = urtw_read8_c(sc, URTW_MSR, &data, 0))
1852 if (sc->sc_hwrev & URTW_HWREV_8187B)
1875 error = urtw_write8_c(sc, URTW_MSR, data, 0);
1910 urtw_set_rate(struct urtw_softc *sc)
1919 if (error = urtw_write8_c(sc, URTW_RESP_RATE,
1924 if (error = urtw_read16_c(sc, URTW_BRSR, &data, 0))
1931 error = urtw_write16_c(sc, URTW_BRSR, data, 0);
1937 urtw_intr_enable(struct urtw_softc *sc)
1941 error = urtw_write16_c(sc, URTW_INTR_MASK, 0xffff, 0);
1946 urtw_rx_setconf(struct urtw_softc *sc)
1948 struct ieee80211com *ic = &sc->sc_ic;
1952 if (urtw_read32_c(sc, URTW_RX, &data, 0))
1962 if (sc->sc_crcmon == 1 && ic->ic_opmode == IEEE80211_M_MONITOR)
1973 error = urtw_write32_c(sc, URTW_RX, data, 0);
1979 urtw_rx_enable(struct urtw_softc *sc)
1985 sc->rx_queued = 0;
1987 if (urtw_rx_start(sc) != 0) {
1992 error = urtw_rx_setconf(sc);
1996 if (error = urtw_read8_c(sc, URTW_CMD, &data, 0))
1998 error = urtw_write8_c(sc, URTW_CMD, data | URTW_CMD_RX_ENABLE, 0);
2004 urtw_tx_enable(struct urtw_softc *sc)
2009 if (sc->sc_hwrev & URTW_HWREV_8187) {
2010 (void) urtw_read8_c(sc, URTW_CW_CONF, &data8, 0);
2013 (void) urtw_write8_c(sc, URTW_CW_CONF, data8, 0);
2014 (void) urtw_read8_c(sc, URTW_TX_AGC_CTL, &data8, 0);
2018 (void) urtw_write8_c(sc, URTW_TX_AGC_CTL, data8, 0);
2020 (void) urtw_read32_c(sc, URTW_TX_CONF, &data, 0);
2024 data |= sc->sc_tx_retry << URTW_TX_DPRETRY_SHIFT;
2025 data |= sc->sc_rts_retry << URTW_TX_RTSRETRY_SHIFT;
2030 (void) urtw_write32_c(sc, URTW_TX_CONF, data, 0);
2035 (void) urtw_write32_c(sc, URTW_TX_CONF, data, 0);
2038 (void) urtw_read8_c(sc, URTW_CMD, &data8, 0);
2039 (void) urtw_write8_c(sc, URTW_CMD, data8 | URTW_CMD_TX_ENABLE, 0);
2045 struct urtw_softc *sc = arg;
2047 struct urtw_rf *rf = &sc->sc_rf;
2050 urtw_stop(sc);
2051 URTW_LOCK(sc);
2052 error = urtw_8187_reset(sc);
2056 (void) urtw_write8_c(sc, 0x85, 0, 0);
2057 (void) urtw_write8_c(sc, URTW_GPIO, 0, 0);
2060 (void) urtw_write8_c(sc, 0x85, 4, 0);
2061 error = urtw_led_ctl(sc, URTW_LED_CTL_POWER_ON);
2065 error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG);
2071 (void) urtw_write8_c(sc, URTW_MAC0 + i,
2072 sc->sc_ic.ic_macaddr[i], 0);
2073 error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL);
2077 error = urtw_update_msr(sc, IEEE80211_S_INIT);
2081 (void) urtw_write32_c(sc, URTW_INT_TIMEOUT, 0, 0);
2082 (void) urtw_write8_c(sc, URTW_WPA_CONFIG, 0, 0);
2083 (void) urtw_write8_c(sc, URTW_RATE_FALLBACK, 0x81, 0);
2084 error = urtw_set_rate(sc);
2094 (void) urtw_write16_c(sc, 0x5e, 1, 0);
2095 (void) urtw_write16_c(sc, 0xfe, 0x10, 0);
2096 (void) urtw_write8_c(sc, URTW_TALLY_SEL, 0x80, 0);
2097 (void) urtw_write8_c(sc, 0xff, 0x60, 0);
2098 (void) urtw_write16_c(sc, 0x5e, 0, 0);
2099 (void) urtw_write8_c(sc, 0x85, 4, 0);
2101 error = urtw_intr_enable(sc);
2105 error = urtw_open_pipes(sc);
2108 sc->sc_tx_low_queued = 0;
2109 sc->sc_tx_normal_queued = 0;
2110 error = urtw_rx_enable(sc);
2113 urtw_tx_enable(sc);
2116 URTW8187_DBG(URTW_DEBUG_ACTIVE, (sc->sc_dev,
2118 sc->sc_flags |= URTW_FLAG_RUNNING;
2119 URTW_UNLOCK(sc);
2124 URTW_UNLOCK(sc);
2125 urtw_stop(sc);
2131 urtw_8225_usb_init(struct urtw_softc *sc)
2136 if (error = urtw_write8_c(sc, URTW_RF_PINS_SELECT + 1, 0, 0))
2138 if (error = urtw_write8_c(sc, URTW_GPIO, 0, 0))
2140 if (error = urtw_read8e(sc, 0x53, &data))
2142 if (error = urtw_write8e(sc, 0x53, data | (1 << 7)))
2144 if (error = urtw_write8_c(sc, URTW_RF_PINS_SELECT + 1, 4, 0))
2146 if (error = urtw_write8_c(sc, URTW_GPIO, 0x20, 0))
2148 if (error = urtw_write8_c(sc, URTW_GP_ENABLE, 0, 0))
2150 if (error = urtw_write16_c(sc, URTW_RF_PINS_OUTPUT, 0x80, 0))
2152 if (error = urtw_write16_c(sc, URTW_RF_PINS_SELECT, 0x80, 0))
2154 error = urtw_write16_c(sc, URTW_RF_PINS_ENABLE, 0x80, 0);
2162 urtw_8185_rf_pins_enable(struct urtw_softc *sc)
2166 error = urtw_write16_c(sc, URTW_RF_PINS_ENABLE, 0x1ff7, 0);
2171 urtw_8187_write_phy(struct urtw_softc *sc, uint8_t addr, uint32_t data)
2177 if (error = urtw_write8_c(sc, 0x7f, ((phyw & 0xff000000) >> 24), 0))
2179 if (error = urtw_write8_c(sc, 0x7e, ((phyw & 0x00ff0000) >> 16), 0))
2181 if (error = urtw_write8_c(sc, 0x7d, ((phyw & 0x0000ff00) >> 8), 0))
2183 error = urtw_write8_c(sc, 0x7c, (phyw & 0x000000ff), 0);
2186 * usbd_delay_ms(sc->sc_udev, 1);
2193 urtw_8187_write_phy_ofdm_c(struct urtw_softc *sc, uint8_t addr, uint32_t data)
2196 return (urtw_8187_write_phy(sc, addr, data));
2200 urtw_8187_write_phy_cck_c(struct urtw_softc *sc, uint8_t addr, uint32_t data)
2203 return (urtw_8187_write_phy(sc, addr, (data | 0x10000)));
2207 urtw_8225_setgain(struct urtw_softc *sc, int16_t gain)
2211 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x0d,
2214 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x1b,
2217 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x1d,
2220 error = urtw_8187_write_phy_ofdm_c(sc, 0x23,
2227 urtw_8225_set_txpwrlvl(struct urtw_softc *sc, int chan)
2232 uint8_t cck_pwrlvl = sc->sc_txpwr_cck[chan] & 0xff;
2233 uint8_t ofdm_pwrlvl = sc->sc_txpwr_ofdm[chan] & 0xff;
2248 if (error = urtw_write8_c(sc, URTW_TX_GAIN_CCK,
2252 if (error = urtw_8187_write_phy_cck_c(sc, 0x44 + i,
2264 error = urtw_8185_set_anaparam2(sc, URTW_8187_8225_ANAPARAM2_ON);
2267 if (error = urtw_8187_write_phy_ofdm_c(sc, 2, 0x42))
2269 if (error = urtw_8187_write_phy_ofdm_c(sc, 6, 0))
2271 if (error = urtw_8187_write_phy_ofdm_c(sc, 8, 0))
2274 if (error = urtw_write8_c(sc, URTW_TX_GAIN_OFDM,
2277 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x5,
2280 error = urtw_8187_write_phy_ofdm_c(sc, 0x7,
2288 urtw_8185_tx_antenna(struct urtw_softc *sc, uint8_t ant)
2292 error = urtw_write8_c(sc, URTW_TX_ANTENNA, ant, 0);
2304 struct urtw_softc *sc = rf->rf_sc;
2306 error = urtw_8180_set_anaparam(sc, URTW_8187_8225_ANAPARAM_ON);
2310 if (error = urtw_8225_usb_init(sc))
2312 if (error = urtw_write32_c(sc, URTW_RF_TIMING, 0x000a8008, 0))
2314 if (error = urtw_read16_c(sc, URTW_BRSR, &data, 0))
2316 if (error = urtw_write16_c(sc, URTW_BRSR, 0xffff, 0))
2318 if (error = urtw_write32_c(sc, URTW_RF_PARA, 0x100044, 0))
2321 if (error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG))
2323 if (error = urtw_write8_c(sc, URTW_CONFIG3, 0x44, 0))
2325 if (error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL))
2327 if (error = urtw_8185_rf_pins_enable(sc))
2332 if (error = urtw_8225_write_c(sc, urtw_8225_rf_part1[i].reg,
2338 if (error = urtw_8225_write_c(sc, 0x2, 0xc4d))
2341 if (error = urtw_8225_write_c(sc, 0x2, 0x44d))
2344 if (error = urtw_8225_write_c(sc, 0x0, 0x127))
2348 if (error = urtw_8225_write_c(sc, 0x1, (uint8_t)(i + 1)))
2350 if (error = urtw_8225_write_c(sc, 0x2, urtw_8225_rxgain[i]))
2354 if (error = urtw_8225_write_c(sc, 0x0, 0x27))
2356 if (error = urtw_8225_write_c(sc, 0x0, 0x22f))
2360 if (error = urtw_8187_write_phy_ofdm_c(sc, 0xb,
2364 if (error = urtw_8187_write_phy_ofdm_c(sc, 0xa,
2371 if (error = urtw_8187_write_phy_ofdm_c(sc,
2377 error = urtw_8225_setgain(sc, 4);
2382 if (error = urtw_8187_write_phy_cck_c(sc,
2389 if (error = urtw_write8_c(sc, 0x5b, 0x0d, 0))
2391 if (error = urtw_8225_set_txpwrlvl(sc, 1))
2393 if (error = urtw_8187_write_phy_cck_c(sc, 0x10, 0x9b))
2396 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x26, 0x90))
2401 if (error = urtw_8185_tx_antenna(sc, 0x3))
2403 if (error = urtw_write32_c(sc, 0x94, 0x3dc00002, 0))
2407 ieee80211_chan2ieee(&sc->sc_ic, sc->sc_ic.ic_curchan));
2421 struct urtw_softc *sc = rf->rf_sc;
2422 struct ieee80211com *ic = &sc->sc_ic;
2427 if (error = urtw_8225_set_txpwrlvl(sc, chan))
2429 if (urtw_8225_write_c(sc, 0x7, urtw_8225_channel[chan]))
2433 if (error = urtw_write8_c(sc, URTW_SIFS, 0x22, 0))
2438 if (error = urtw_write8_c(sc, URTW_SLOT, 0x9, 0))
2441 if (error = urtw_write8_c(sc, URTW_SLOT, 0x14, 0))
2445 if (error = urtw_write8_c(sc, URTW_DIFS, 0x14, 0))
2447 if (error = urtw_write8_c(sc, URTW_EIFS, 0x5b - 0x14, 0))
2449 error = urtw_write8_c(sc, URTW_CW_VAL, 0x73, 0);
2452 if (error = urtw_write8_c(sc, URTW_DIFS, 0x24, 0))
2454 if (error = urtw_write8_c(sc, URTW_EIFS, 0x5b - 0x24, 0))
2456 error = urtw_write8_c(sc, URTW_CW_VAL, 0xa5, 0);
2467 struct urtw_softc *sc = rf->rf_sc;
2473 if (error = urtw_8225_write_c(sc, 0x0c, 0x850))
2476 if (error = urtw_8225_write_c(sc, 0x0c, 0x50))
2480 if (error = urtw_8225_setgain(sc, rf->sens))
2482 error = urtw_8187_write_phy_cck_c(sc, 0x41,
2489 urtw_stop(struct urtw_softc *sc)
2491 URTW_LOCK(sc);
2492 sc->sc_flags &= ~URTW_FLAG_RUNNING;
2493 URTW_UNLOCK(sc);
2494 urtw_close_pipes(sc);
2510 struct urtw_softc *sc = (struct urtw_softc *)req->bulk_client_private;
2511 struct ieee80211com *ic = &sc->sc_ic;
2523 sc->sc_rx_err++;
2524 URTW8187_DBG(URTW_DEBUG_RX_PROC, (sc->sc_dev, CE_CONT,
2534 if (sc->sc_hwrev & URTW_HWREV_8187)
2546 sc->sc_rx_err++;
2552 if (sc->sc_hwrev & URTW_HWREV_8187) {
2567 URTW8187_DBG(URTW_DEBUG_RX_PROC, (sc->sc_dev, CE_CONT,
2575 sc->sc_currate = (rate > 0) ? rate : sc->sc_currate;
2576 URTW8187_DBG(URTW_DEBUG_RX_PROC, (sc->sc_dev, CE_CONT,
2578 sc->sc_currate));
2588 mutex_enter(&sc->rx_lock);
2589 sc->rx_queued--;
2590 mutex_exit(&sc->rx_lock);
2592 if (URTW_IS_RUNNING(sc) && !URTW_IS_SUSPENDING(sc))
2593 (void) urtw_rx_start(sc);
2597 urtw_8225v2_setgain(struct urtw_softc *sc, int16_t gain)
2604 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x0d, gainp[gain * 3]))
2607 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x1b, gainp[gain * 3 + 1]))
2609 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x1d, gainp[gain * 3 + 2]))
2612 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x21, 0x17))
2620 urtw_8225v2_set_txpwrlvl(struct urtw_softc *sc, int chan)
2625 uint8_t cck_pwrlvl = sc->sc_txpwr_cck[chan] & 0xff;
2626 uint8_t ofdm_pwrlvl = sc->sc_txpwr_ofdm[chan] & 0xff;
2632 cck_pwrlvl += sc->sc_txpwr_cck_base;
2638 if (error = urtw_8187_write_phy_cck_c(sc, 0x44 + i,
2642 if (error = urtw_write8_c(sc, URTW_TX_GAIN_CCK,
2650 ofdm_pwrlvl += sc->sc_txpwr_ofdm_base;
2653 error = urtw_8185_set_anaparam2(sc, URTW_8187_8225_ANAPARAM2_ON);
2657 if (error = urtw_8187_write_phy_ofdm_c(sc, 2, 0x42))
2659 if (error = urtw_8187_write_phy_ofdm_c(sc, 5, 0x0))
2661 if (error = urtw_8187_write_phy_ofdm_c(sc, 6, 0x40))
2663 if (error = urtw_8187_write_phy_ofdm_c(sc, 7, 0x0))
2665 if (error = urtw_8187_write_phy_ofdm_c(sc, 8, 0x40))
2668 error = urtw_write8_c(sc, URTW_TX_GAIN_OFDM,
2683 struct urtw_softc *sc = rf->rf_sc;
2685 if (error = urtw_8180_set_anaparam(sc, URTW_8187_8225_ANAPARAM_ON))
2687 if (error = urtw_8225_usb_init(sc))
2689 if (error = urtw_write32_c(sc, URTW_RF_TIMING, 0x000a8008, 0))
2691 if (error = urtw_read16_c(sc, URTW_BRSR, &data, 0))
2693 if (error = urtw_write16_c(sc, URTW_BRSR, 0xffff, 0))
2695 if (error = urtw_write32_c(sc, URTW_RF_PARA, 0x100044, 0))
2697 if (error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG))
2699 if (error = urtw_write8_c(sc, URTW_CONFIG3, 0x44, 0))
2701 if (error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL))
2703 if (error = urtw_8185_rf_pins_enable(sc))
2709 if (error = urtw_8225_write_c(sc, urtw_8225v2_rf_part1[i].reg,
2716 if (error = urtw_8225_write_c(sc, 0x0, 0x1b7))
2720 if (error = urtw_8225_write_c(sc, 0x1, (uint8_t)(i + 1)))
2723 if (error = urtw_8225_write_c(sc, 0x2, urtw_8225v2_rxgain[i]))
2728 if (error = urtw_8225_write_c(sc, 0x3, 0x2))
2731 if (error = urtw_8225_write_c(sc, 0x5, 0x4))
2734 if (error = urtw_8225_write_c(sc, 0x0, 0xb7))
2737 if (error = urtw_8225_write_c(sc, 0x2, 0xc4d))
2740 if (error = urtw_8225_write_c(sc, 0x2, 0x44d))
2744 if (error = urtw_8225_read(sc, 0x6, &data32))
2752 if (error = urtw_8225_write_c(sc, 0x02, 0x0c4d))
2755 if (error = urtw_8225_write_c(sc, 0x02, 0x044d))
2758 if (error = urtw_8225_read(sc, 0x6, &data32))
2765 if (error = urtw_8225_write_c(sc, 0x0, 0x2bf))
2768 if (error = urtw_8187_write_phy_ofdm_c(sc, 0xb,
2772 if (error = urtw_8187_write_phy_ofdm_c(sc, 0xa,
2780 if (error = urtw_8187_write_phy_ofdm_c(sc,
2786 error = urtw_8225v2_setgain(sc, 4);
2791 if (error = urtw_8187_write_phy_cck_c(sc,
2798 if (error = urtw_write8_c(sc, 0x5b, 0x0d, 0))
2800 if (error = urtw_8225v2_set_txpwrlvl(sc, 1))
2802 if (error = urtw_8187_write_phy_cck_c(sc, 0x10, 0x9b))
2805 if (error = urtw_8187_write_phy_ofdm_c(sc, 0x26, 0x90))
2810 if (error = urtw_8185_tx_antenna(sc, 0x3))
2812 if (error = urtw_write32_c(sc, 0x94, 0x3dc00002, 0))
2816 ieee80211_chan2ieee(&sc->sc_ic, sc->sc_ic.ic_curchan));
2825 struct urtw_softc *sc = rf->rf_sc;
2826 struct ieee80211com *ic = &sc->sc_ic;
2831 if (error = urtw_8225v2_set_txpwrlvl(sc, chan))
2834 if (error = urtw_8225_write_c(sc, 0x7, urtw_8225_channel[chan]))
2839 if (error = urtw_write8_c(sc, URTW_SIFS, 0x22, 0))
2844 if (error = urtw_write8_c(sc, URTW_SLOT, 0x9, 0))
2847 if (error = urtw_write8_c(sc, URTW_SLOT, 0x14, 0))
2851 if (error = urtw_write8_c(sc, URTW_DIFS, 0x14, 0))
2853 if (error = urtw_write8_c(sc, URTW_EIFS, 0x5b - 0x14, 0))
2855 if (error = urtw_write8_c(sc, URTW_CW_VAL, 0x73, 0))
2859 if (error = urtw_write8_c(sc, URTW_DIFS, 0x24, 0))
2861 if (error = urtw_write8_c(sc, URTW_EIFS, 0x5b - 0x24, 0))
2863 if (error = urtw_write8_c(sc, URTW_CW_VAL, 0xa5, 0))
2872 urtw_set_channel(struct urtw_softc *sc)
2874 struct ieee80211com *ic = &sc->sc_ic;
2875 struct urtw_rf *rf = &sc->sc_rf;
2879 if (error = urtw_read32_c(sc, URTW_TX_CONF, &data, 0))
2882 if (error = urtw_write32_c(sc, URTW_TX_CONF,
2889 error = urtw_write32_c(sc, URTW_TX_CONF,
2899 struct urtw_softc *sc = (struct urtw_softc *)req->bulk_client_private;
2900 struct ieee80211com *ic = &sc->sc_ic;
2902 URTW8187_DBG(URTW_DEBUG_TX_PROC, (sc->sc_dev, CE_CONT,
2907 sc->sc_tx_low_queued));
2908 mutex_enter(&sc->tx_lock);
2914 if (sc->sc_need_sched) {
2915 sc->sc_need_sched = 0;
2919 sc->sc_tx_low_queued--;
2920 mutex_exit(&sc->tx_lock);
2928 struct urtw_softc *sc = (struct urtw_softc *)req->bulk_client_private;
2929 struct ieee80211com *ic = &sc->sc_ic;
2931 URTW8187_DBG(URTW_DEBUG_ACTIVE, (sc->sc_dev, CE_CONT,
2936 sc->sc_tx_normal_queued));
2938 mutex_enter(&sc->tx_lock);
2944 if (sc->sc_need_sched) {
2945 sc->sc_need_sched = 0;
2949 sc->sc_tx_normal_queued--;
2950 mutex_exit(&sc->tx_lock);
2973 urtw_8187b_update_wmm(struct urtw_softc *sc)
2975 struct ieee80211com *ic = &sc->sc_ic;
2994 (void) urtw_write32_c(sc, URTW_AC_VO, data, 0);
2995 (void) urtw_write32_c(sc, URTW_AC_VI, data, 0);
2996 (void) urtw_write32_c(sc, URTW_AC_BE, data, 0);
2997 (void) urtw_write32_c(sc, URTW_AC_BK, data, 0);
3001 urtw_8187b_reset(struct urtw_softc *sc)
3006 error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG);
3010 (void) urtw_read8_c(sc, URTW_CONFIG3, &data, 0);
3011 (void) urtw_write8_c(sc, URTW_CONFIG3,
3015 (void) urtw_write32_c(sc, URTW_ANAPARAM2,
3017 (void) urtw_write32_c(sc, URTW_ANAPARAM,
3019 (void) urtw_write8_c(sc, URTW_ANAPARAM3,
3022 (void) urtw_write8_c(sc, 0x61, 0x10, 0);
3023 (void) urtw_read8_c(sc, 0x62, &data, 0);
3024 (void) urtw_write8_c(sc, 0x62, data & ~(1 << 5), 0);
3025 (void) urtw_write8_c(sc, 0x62, data | (1 << 5), 0);
3027 (void) urtw_read8_c(sc, URTW_CONFIG3, &data, 0);
3028 (void) urtw_write8_c(sc, URTW_CONFIG3,
3031 error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL);
3035 (void) urtw_read8_c(sc, URTW_CMD, &data, 0);
3037 (void) urtw_write8_c(sc, URTW_CMD, data, 0);
3040 (void) urtw_read8_c(sc, URTW_CMD, &data, 0);
3053 struct urtw_softc *sc = arg;
3054 struct urtw_rf *rf = &sc->sc_rf;
3055 struct ieee80211com *ic = &sc->sc_ic;
3060 urtw_stop(sc);
3061 URTW_LOCK(sc);
3062 urtw_8187b_update_wmm(sc);
3063 error = urtw_8187b_reset(sc);
3067 error = urtw_open_pipes(sc);
3071 error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG);
3075 (void) urtw_write8_c(sc, URTW_MAC0 + i,
3077 error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL);
3081 error = urtw_update_msr(sc, IEEE80211_S_INIT);
3088 error = urtw_intr_enable(sc);
3092 error = urtw_write8e(sc, 0x41, 0xf4);
3095 error = urtw_write8e(sc, 0x40, 0x00);
3098 error = urtw_write8e(sc, 0x42, 0x00);
3101 error = urtw_write8e(sc, 0x42, 0x01);
3104 error = urtw_write8e(sc, 0x40, 0x0f);
3107 error = urtw_write8e(sc, 0x42, 0x00);
3110 error = urtw_write8e(sc, 0x42, 0x01);
3114 (void) urtw_read8_c(sc, 0xdb, &data, 0);
3115 (void) urtw_write8_c(sc, 0xdb, data | (1 << 2), 0);
3116 (void) urtw_write16_c(sc, 0x72, 0x59fa, 3);
3117 (void) urtw_write16_c(sc, 0x74, 0x59d2, 3);
3118 (void) urtw_write16_c(sc, 0x76, 0x59d2, 3);
3119 (void) urtw_write16_c(sc, 0x78, 0x19fa, 3);
3120 (void) urtw_write16_c(sc, 0x7a, 0x19fa, 3);
3121 (void) urtw_write16_c(sc, 0x7c, 0x00d0, 3);
3122 (void) urtw_write8_c(sc, 0x61, 0, 0);
3123 (void) urtw_write8_c(sc, 0x80, 0x0f, 1);
3124 (void) urtw_write8_c(sc, 0x83, 0x03, 1);
3125 (void) urtw_write8_c(sc, 0xda, 0x10, 0);
3126 (void) urtw_write8_c(sc, 0x4d, 0x08, 2);
3128 (void) urtw_write32_c(sc, URTW_HSSI_PARA, 0x0600321b, 0);
3129 (void) urtw_write16_c(sc, 0xec, 0x0800, 1);
3130 (void) urtw_write8_c(sc, URTW_ACM_CONTROL, 0, 0);
3132 sc->sc_tx_low_queued = 0;
3133 sc->sc_tx_normal_queued = 0;
3134 error = urtw_rx_enable(sc);
3137 urtw_tx_enable(sc);
3140 URTW8187_DBG(URTW_DEBUG_ACTIVE, (sc->sc_dev,
3142 sc->sc_flags |= URTW_FLAG_RUNNING;
3143 URTW_UNLOCK(sc);
3149 URTW_UNLOCK(sc);
3150 urtw_stop(sc);
3155 urtw_8225v2_b_config_mac(struct urtw_softc *sc)
3162 (void) urtw_write8_c(sc, urtw_8187b_regtbl[i].reg,
3166 (void) urtw_write16_c(sc, URTW_TID_AC_MAP, 0xfa50, 0);
3167 (void) urtw_write16_c(sc, URTW_INT_MIG, 0, 0);
3169 (void) urtw_write32_c(sc, 0xf0, 0, 1);
3170 (void) urtw_write32_c(sc, 0xf4, 0, 1);
3171 (void) urtw_write8_c(sc, 0xf8, 0, 1);
3173 (void) urtw_write32_c(sc, URTW_RF_TIMING, 0x00004001, 0);
3177 urtw_8225v2_b_init_rfe(struct urtw_softc *sc)
3179 (void) urtw_write16_c(sc, URTW_RF_PINS_OUTPUT, 0x0480, 0);
3180 (void) urtw_write16_c(sc, URTW_RF_PINS_SELECT, 0x2488, 0);
3181 (void) urtw_write16_c(sc, URTW_RF_PINS_ENABLE, 0x1fff, 0);
3186 urtw_8225v2_b_update_chan(struct urtw_softc *sc)
3188 struct ieee80211com *ic = &sc->sc_ic;
3192 (void) urtw_write8_c(sc, URTW_SIFS, 0x22, 0);
3206 (void) urtw_write8_c(sc, URTW_SLOT, slot, 0);
3208 (void) urtw_write8_c(sc, URTW_AC_VO, aifs, 0);
3209 (void) urtw_write8_c(sc, URTW_AC_VI, aifs, 0);
3210 (void) urtw_write8_c(sc, URTW_AC_BE, aifs, 0);
3211 (void) urtw_write8_c(sc, URTW_AC_BK, aifs, 0);
3213 (void) urtw_write8_c(sc, URTW_DIFS, difs, 0);
3214 (void) urtw_write8_c(sc, URTW_8187B_EIFS, eifs, 0);
3221 struct urtw_softc *sc = rf->rf_sc;
3227 (void) urtw_write16_c(sc, URTW_8187B_BRSR, 0x0fff, 0);
3228 (void) urtw_read8_c(sc, URTW_CW_CONF, &data, 0);
3229 (void) urtw_write8_c(sc, URTW_CW_CONF, data |
3231 (void) urtw_read8_c(sc, URTW_TX_AGC_CTL, &data, 0);
3232 (void) urtw_write8_c(sc, URTW_TX_AGC_CTL, data |
3237 (void) urtw_write16_c(sc, URTW_ARFR, 0x0fff, 1); /* 1M ~ 54M */
3238 (void) urtw_read8_c(sc, URTW_RATE_FALLBACK, &data, 0);
3239 (void) urtw_write8_c(sc, URTW_RATE_FALLBACK, data |
3242 (void) urtw_write16_c(sc, URTW_BEACON_INTERVAL, 0x3ff, 0);
3243 (void) urtw_write16_c(sc, URTW_ATIM_WND, 2, 0);
3244 (void) urtw_write16_c(sc, URTW_FEMR, 0xffff, 1);
3246 error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG);
3249 (void) urtw_read8_c(sc, URTW_CONFIG1, &data, 0);
3250 (void) urtw_write8_c(sc, URTW_CONFIG1, (data & 0x3f) | 0x80, 0);
3251 error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL);
3255 (void) urtw_write8_c(sc, URTW_WPA_CONFIG, 0, 0);
3256 urtw_8225v2_b_config_mac(sc);
3257 (void) urtw_write16_c(sc, URTW_RFSW_CTRL, 0x569a, 2);
3259 error = urtw_set_mode(sc, URTW_EPROM_CMD_CONFIG);
3262 (void) urtw_read8_c(sc, URTW_CONFIG3, &data, 0);
3263 (void) urtw_write8_c(sc, URTW_CONFIG3,
3265 error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL);
3269 urtw_8225v2_b_init_rfe(sc);
3273 (void) urtw_8225_write_c(sc, urtw_8225v2_b_rf[i].reg,
3279 (void) urtw_8225_write_c(sc, 0x1, (uint8_t)(i + 1));
3280 (void) urtw_8225_write_c(sc, 0x2, urtw_8225v2_rxgain[i]);
3283 (void) urtw_8225_write_c(sc, 0x03, 0x080);
3284 (void) urtw_8225_write_c(sc, 0x05, 0x004);
3285 (void) urtw_8225_write_c(sc, 0x00, 0x0b7);
3286 (void) urtw_8225_write_c(sc, 0x02, 0xc4d);
3288 (void) urtw_8225_write_c(sc, 0x02, 0x44d);
3290 (void) urtw_8225_write_c(sc, 0x00, 0x2bf);
3293 (void) urtw_write8_c(sc, URTW_TX_GAIN_CCK, 0x03, 0);
3294 (void) urtw_write8_c(sc, URTW_TX_GAIN_OFDM, 0x07, 0);
3295 (void) urtw_write8_c(sc, URTW_TX_ANTENNA, 0x03, 0);
3297 (void) urtw_8187_write_phy_ofdm_c(sc, 0x80, 0x12);
3300 (void) urtw_8187_write_phy_ofdm_c(sc, 0x0f, urtw_8225v2_agc[i]);
3301 (void) urtw_8187_write_phy_ofdm_c(sc, 0x0e, (uint8_t)i + 0x80);
3302 (void) urtw_8187_write_phy_ofdm_c(sc, 0x0e, 0);
3304 (void) urtw_8187_write_phy_ofdm_c(sc, 0x80, 0x10);
3308 (void) urtw_8187_write_phy_ofdm_c(sc, i, urtw_8225v2_ofdm[i]);
3310 (void) urtw_8225v2_b_update_chan(sc);
3312 (void) urtw_8187_write_phy_ofdm_c(sc, 0x97, 0x46);
3313 (void) urtw_8187_write_phy_ofdm_c(sc, 0xa4, 0xb6);
3314 (void) urtw_8187_write_phy_ofdm_c(sc, 0x85, 0xfc);
3315 (void) urtw_8187_write_phy_cck_c(sc, 0xc1, 0x88);
3318 ieee80211_chan2ieee(&sc->sc_ic, sc->sc_ic.ic_curchan));
3326 struct urtw_softc *sc = rf->rf_sc;
3329 urtw_8225v2_b_set_txpwrlvl(sc, chan);
3330 error = urtw_8225_write_c(sc, 0x7, urtw_8225_channel[chan]);
3335 * usbd_delay_ms(sc->sc_udev, 10);
3338 error = urtw_write16_c(sc, URTW_AC_VO, 0x5114, 0);
3341 error = urtw_write16_c(sc, URTW_AC_VI, 0x5114, 0);
3344 error = urtw_write16_c(sc, URTW_AC_BE, 0x5114, 0);
3347 error = urtw_write16_c(sc, URTW_AC_BK, 0x5114, 0);
3353 urtw_8225v2_b_set_txpwrlvl(struct urtw_softc *sc, int chan)
3359 int8_t cck_pwrlvl = sc->sc_txpwr_cck[chan] & 0xff;
3360 int8_t ofdm_pwrlvl = sc->sc_txpwr_ofdm[chan] & 0xff;
3362 if (sc->sc_hwrev & URTW_HWREV_8187B_B) {
3378 cck_pwrlvl += sc->sc_txpwr_cck_base;
3385 if (sc->sc_hwrev & URTW_HWREV_8187B_B) {
3400 (void) urtw_8187_write_phy_cck_c(sc, 0x44 + i, cck_pwrtable[i]);
3403 (void) urtw_write8_c(sc, URTW_TX_GAIN_CCK,
3407 * usbd_delay_ms(sc->sc_udev, 1);
3414 ofdm_pwrlvl += sc->sc_txpwr_ofdm_base;
3418 (void) urtw_write8_c(sc, URTW_TX_GAIN_OFDM,
3421 if (sc->sc_hwrev & URTW_HWREV_8187B_B) {
3423 (void) urtw_8187_write_phy_ofdm_c(sc, 0x87, 0x60);
3424 (void) urtw_8187_write_phy_ofdm_c(sc, 0x89, 0x60);
3426 (void) urtw_8187_write_phy_ofdm_c(sc, 0x87, 0x5c);
3427 (void) urtw_8187_write_phy_ofdm_c(sc, 0x89, 0x5c);
3431 (void) urtw_8187_write_phy_ofdm_c(sc, 0x87, 0x5c);
3432 (void) urtw_8187_write_phy_ofdm_c(sc, 0x89, 0x5c);
3434 (void) urtw_8187_write_phy_ofdm_c(sc, 0x87, 0x54);
3435 (void) urtw_8187_write_phy_ofdm_c(sc, 0x89, 0x54);
3437 (void) urtw_8187_write_phy_ofdm_c(sc, 0x87, 0x50);
3438 (void) urtw_8187_write_phy_ofdm_c(sc, 0x89, 0x50);
3444 * usbd_delay_ms(sc->sc_udev, 1);
3452 struct urtw_softc *sc = (struct urtw_softc *)ic;
3460 mutex_enter(&sc->tx_lock);
3464 if (URTW_IS_SUSPENDING(sc)) {
3469 if (((priority)? sc->sc_tx_normal_queued : sc->sc_tx_low_queued) >=
3471 URTW8187_DBG(URTW_DEBUG_XMIT, (sc->sc_dev, CE_CONT,
3473 sc->sc_tx_nobuf++;
3517 if (sc->sc_hwrev & URTW_HWREV_8187)
3548 if (sc->sc_hwrev & URTW_HWREV_8187) {
3558 (void) urtw_led_ctl(sc, URTW_LED_CTL_TX);
3561 URTW8187_DBG(URTW_DEBUG_XMIT, (sc->sc_dev, CE_CONT,
3565 err = urtw_tx_start(sc, mtx, priority);
3586 sc->sc_need_sched = 1;
3588 mutex_exit(&sc->tx_lock);
3596 struct urtw_softc *sc = (struct urtw_softc *)arg;
3598 if (URTW_IS_NOT_RUNNING(sc)) {
3599 sc->sc_scan_id = 0;
3606 sc->sc_scan_id = 0;
3612 struct urtw_softc *sc = arg;
3613 ieee80211com_t *ic = &sc->sc_ic;
3616 URTW_LEDLOCK(sc);
3617 if ((sc->sc_strategy != URTW_SW_LED_MODE0) ||
3618 URTW_IS_NOT_RUNNING(sc) ||
3619 URTW_IS_SUSPENDING(sc)) {
3620 URTW8187_DBG(URTW_DEBUG_LED, (sc->sc_dev, CE_CONT,
3622 sc->sc_strategy,
3623 sc->sc_flags));
3624 sc->sc_led_ch = 0;
3625 sc->sc_gpio_ledinprogress = 0;
3626 URTW_LEDUNLOCK(sc);
3629 error = urtw_led_blink(sc);
3631 sc->sc_led_ch = timeout(urtw_led_launch, (void *)sc,
3634 URTW8187_DBG(URTW_DEBUG_LED, (sc->sc_dev, CE_CONT,
3637 sc->sc_led_ch = 0;
3638 URTW8187_DBG(URTW_DEBUG_LED, (sc->sc_dev, CE_CONT,
3641 URTW_LEDUNLOCK(sc);
3647 struct urtw_softc *sc = (struct urtw_softc *)ic;
3651 if (sc->sc_scan_id != 0) {
3652 (void) untimeout(sc->sc_scan_id);
3653 sc->sc_scan_id = 0;
3655 URTW_LOCK(sc);
3659 (sc->sc_dev, CE_CONT, "-> IEEE80211_S_INIT...arg(%d)\n",
3661 if (sc->sc_flags & URTW_FLAG_HP)
3663 (void) urtw_update_msr(sc, nstate);
3664 (void) urtw_led_off(sc, URTW_LED_GPIO);
3669 (sc->sc_dev, CE_CONT,
3672 error = urtw_set_channel(sc);
3675 (sc->sc_dev, CE_CONT, "scan setchan failed"));
3678 sc->sc_scan_id = timeout(urtw_next_scan, (void *)sc,
3679 drv_usectohz(sc->dwelltime * 1000));
3683 URTW8187_DBG(URTW_DEBUG_STATE, (sc->sc_dev, CE_CONT,
3686 error = urtw_set_channel(sc);
3689 (sc->sc_dev, CE_CONT, "auth setchan failed"));
3694 URTW8187_DBG(URTW_DEBUG_STATE, (sc->sc_dev, CE_CONT,
3697 error = urtw_set_channel(sc);
3700 (sc->sc_dev, CE_CONT, "assoc setchan failed"));
3706 (sc->sc_dev, CE_CONT,
3709 error = urtw_set_channel(sc);
3712 (sc->sc_dev, CE_CONT, "run setchan failed"));
3717 (void) urtw_write32_c(sc, URTW_BSSID,
3719 (void) urtw_write16_c(sc, URTW_BSSID + 4,
3721 (void) urtw_update_msr(sc, nstate);
3727 URTW_UNLOCK(sc);
3730 URTW8187_DBG(URTW_DEBUG_STATE, (sc->sc_dev, CE_CONT,
3734 error = sc->sc_newstate(ic, nstate, arg);
3739 urtw_close_pipes(struct urtw_softc *sc)
3743 if (sc->sc_rxpipe != NULL) {
3744 usb_pipe_reset(sc->sc_dev,
3745 sc->sc_rxpipe, flags, NULL, 0);
3746 usb_pipe_close(sc->sc_dev,
3747 sc->sc_rxpipe, flags, NULL, 0);
3748 sc->sc_rxpipe = NULL;
3751 if (sc->sc_txpipe_low != NULL) {
3752 usb_pipe_reset(sc->sc_dev,
3753 sc->sc_txpipe_low, flags, NULL, 0);
3754 usb_pipe_close(sc->sc_dev,
3755 sc->sc_txpipe_low, flags, NULL, 0);
3756 sc->sc_txpipe_low = NULL;
3759 if (sc->sc_txpipe_normal != NULL) {
3760 usb_pipe_reset(sc->sc_dev,
3761 sc->sc_txpipe_normal, flags, NULL, 0);
3762 usb_pipe_close(sc->sc_dev,
3763 sc->sc_txpipe_normal, flags, NULL, 0);
3764 sc->sc_txpipe_normal = NULL;
3769 urtw_open_pipes(struct urtw_softc *sc)
3776 if (sc->sc_rxpipe || sc->sc_txpipe_low || sc->sc_txpipe_normal)
3779 if ((sc->sc_hwrev & URTW_HWREV_8187) == 0) {
3782 ep_node = usb_lookup_ep_data(sc->sc_dev, sc->sc_udev, 0, 0,
3788 if ((err = usb_pipe_open(sc->sc_dev,
3790 &sc->sc_txpipe_low)) != USB_SUCCESS) {
3791 URTW8187_DBG(URTW_DEBUG_ACTIVE, (sc->sc_dev, CE_CONT,
3797 ep_node = usb_lookup_ep_data(sc->sc_dev, sc->sc_udev, 0, 0,
3803 if ((err = usb_pipe_open(sc->sc_dev,
3805 &sc->sc_txpipe_normal)) != USB_SUCCESS) {
3806 URTW8187_DBG(URTW_DEBUG_ACTIVE, (sc->sc_dev, CE_CONT,
3812 ep_node = usb_lookup_ep_data(sc->sc_dev, sc->sc_udev, 0, 0, 0,
3818 if ((err = usb_pipe_open(sc->sc_dev,
3820 &sc->sc_rxpipe)) != USB_SUCCESS) {
3821 URTW8187_DBG(URTW_DEBUG_ACTIVE, (sc->sc_dev, CE_CONT,
3829 urtw_close_pipes(sc);
3834 urtw_tx_start(struct urtw_softc *sc, mblk_t *mp, int priority)
3839 req = usb_alloc_bulk_req(sc->sc_dev, 0, USB_FLAGS_SLEEP);
3841 URTW8187_DBG(URTW_DEBUG_TX_PROC, (sc->sc_dev, CE_CONT,
3849 req->bulk_client_private = (usb_opaque_t)sc;
3858 (priority)?sc->sc_txpipe_normal:sc->sc_txpipe_low, req, 0))
3860 sc->sc_ic.ic_stats.is_tx_failed++;
3861 URTW8187_DBG(URTW_DEBUG_TX_PROC, (sc->sc_dev, CE_CONT,
3868 sc->sc_tx_normal_queued++;
3870 sc->sc_tx_low_queued++;
3877 urtw_rx_start(struct urtw_softc *sc)
3882 req = usb_alloc_bulk_req(sc->sc_dev, URTW_RXBUF_SIZE, USB_FLAGS_SLEEP);
3884 URTW8187_DBG(URTW_DEBUG_RECV, (sc->sc_dev, CE_CONT,
3890 req->bulk_client_private = (usb_opaque_t)sc;
3899 err = usb_pipe_bulk_xfer(sc->sc_rxpipe, req, 0);
3902 URTW8187_DBG(URTW_DEBUG_RECV, (sc->sc_dev, CE_CONT,
3908 mutex_enter(&sc->rx_lock);
3909 sc->rx_queued++;
3910 mutex_exit(&sc->rx_lock);
3918 struct urtw_softc *sc;
3920 sc = ddi_get_soft_state(urtw_soft_state_p, ddi_get_instance(devinfo));
3922 (sc->sc_dev, CE_CONT, "urtw_offline()\n"));
3924 if (URTW_IS_RUNNING(sc)) {
3925 urtw_stop(sc);
3926 URTW_LOCK(sc);
3927 sc->sc_flags |= URTW_FLAG_PLUGIN_ONLINE;
3928 URTW_UNLOCK(sc);
3930 sc->sc_flags |= URTW_FLAG_HP;
3931 ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1);
3932 ieee80211_stop_watchdog(&sc->sc_ic);
3939 struct urtw_softc *sc;
3941 sc = ddi_get_soft_state(urtw_soft_state_p, ddi_get_instance(devinfo));
3942 if (usb_check_same_device(sc->sc_dev, NULL, USB_LOG_L2, -1,
3945 URTW8187_DBG(URTW_DEBUG_HOTPLUG, (sc->sc_dev, CE_CONT,
3947 sc->sc_flags &= ~URTW_FLAG_HP;
3948 if (URTW_IS_PLUGIN_ONLINE(sc)) {
3949 error = sc->urtw_init(sc);
3951 URTW_LOCK(sc);
3952 sc->sc_flags &= ~URTW_FLAG_PLUGIN_ONLINE;
3953 URTW_UNLOCK(sc);
3962 struct urtw_softc *sc = (struct urtw_softc *)arg;
3963 struct ieee80211com *ic = &sc->sc_ic;
3967 URTW_IS_SUSPENDING(sc)) {
3987 struct urtw_softc *sc = (struct urtw_softc *)arg;
3991 (sc->sc_dev, CE_CONT, "urtw_m_start\n"));
3992 error = sc->urtw_init(sc);
3999 struct urtw_softc *sc = (struct urtw_softc *)arg;
4001 URTW8187_DBG(URTW_DEBUG_ACTIVE, (sc->sc_dev, CE_CONT,
4003 ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1);
4004 ieee80211_stop_watchdog(&sc->sc_ic);
4005 (void) urtw_stop(sc);
4033 struct urtw_softc *sc = (struct urtw_softc *)arg;
4036 err = ieee80211_getprop(&sc->sc_ic, pr_name, wldp_pr_num,
4045 struct urtw_softc *sc = (struct urtw_softc *)arg;
4047 ieee80211_propinfo(&sc->sc_ic, pr_name, wldp_pr_num, mph);
4054 struct urtw_softc *sc = (struct urtw_softc *)arg;
4055 struct ieee80211com *ic = &sc->sc_ic;
4060 URTW_LOCK(sc);
4062 if (URTW_IS_RUNNING(sc) && ic->ic_des_esslen) {
4063 URTW_UNLOCK(sc);
4064 err = sc->urtw_init(sc);
4067 (sc->sc_dev, CE_CONT,
4072 URTW_LOCK(sc);
4076 URTW_UNLOCK(sc);
4083 struct urtw_softc *sc = (struct urtw_softc *)arg;
4084 struct ieee80211com *ic = &sc->sc_ic;
4088 URTW_LOCK(sc);
4090 if (URTW_IS_RUNNING(sc) && ic->ic_des_esslen) {
4091 URTW_UNLOCK(sc);
4092 err = sc->urtw_init(sc);
4095 (sc->sc_dev,
4100 URTW_LOCK(sc);
4103 URTW_UNLOCK(sc);
4109 struct urtw_softc *sc = (struct urtw_softc *)arg;
4110 ieee80211com_t *ic = &sc->sc_ic;
4114 URTW_LOCK(sc);
4124 *val = sc->sc_tx_nobuf;
4127 *val = sc->sc_rx_nobuf;
4130 *val = sc->sc_rx_err;
4159 URTW_UNLOCK(sc);
4162 URTW_UNLOCK(sc);
4165 URTW_UNLOCK(sc);
4173 struct urtw_softc *sc = arg;
4174 struct ieee80211com *ic = &sc->sc_ic;
4178 URTW_LOCK(sc);
4179 if (URTW_IS_NOT_RUNNING(sc)) {
4180 URTW_UNLOCK(sc);
4184 URTW_UNLOCK(sc);
4191 (sc->sc_dev, CE_CONT,
4203 struct urtw_softc *sc;
4218 sc = ddi_get_soft_state(urtw_soft_state_p,
4220 ASSERT(sc != NULL);
4222 (sc->sc_dev, CE_CONT, "urtw: resume\n"));
4223 URTW_LOCK(sc);
4224 sc->sc_flags &= ~URTW_FLAG_SUSPEND;
4225 URTW_UNLOCK(sc);
4226 if (URTW_IS_PLUGIN_ONLINE(sc)) {
4227 error = sc->urtw_init(sc);
4229 URTW_LOCK(sc);
4230 sc->sc_flags &= ~URTW_FLAG_PLUGIN_ONLINE;
4231 URTW_UNLOCK(sc);
4246 sc = ddi_get_soft_state(urtw_soft_state_p, instance);
4247 ic = (ieee80211com_t *)&sc->sc_ic;
4248 sc->sc_dev = devinfo;
4255 if (usb_get_dev_data(devinfo, &sc->sc_udev,
4257 sc->sc_udev = NULL;
4261 mutex_init(&sc->sc_genlock, NULL, MUTEX_DRIVER, NULL);
4262 mutex_init(&sc->tx_lock, NULL, MUTEX_DRIVER, NULL);
4263 mutex_init(&sc->rx_lock, NULL, MUTEX_DRIVER, NULL);
4264 mutex_init(&sc->sc_ledlock, NULL, MUTEX_DRIVER, NULL);
4266 e = urtw_lookup(sc->sc_udev->dev_descr->idVendor,
4267 sc->sc_udev->dev_descr->idProduct);
4272 sc->sc_hwrev = e->rev;
4274 if (sc->sc_hwrev & URTW_HWREV_8187) {
4275 (void) urtw_read32_c(sc, URTW_TX_CONF, &data, 0);
4279 sc->sc_hwrev |= URTW_HWREV_8187_D;
4287 sc->sc_hwrev = URTW_HWREV_8187B | URTW_HWREV_8187B_B;
4291 sc->sc_hwrev |= URTW_HWREV_8187_B;
4297 (void) urtw_read8_c(sc, URTW_8187B_HWREV, &data8, 0);
4300 sc->sc_hwrev |= URTW_HWREV_8187B_B;
4304 sc->sc_hwrev |= URTW_HWREV_8187B_D;
4308 sc->sc_hwrev |= URTW_HWREV_8187B_E;
4312 sc->sc_hwrev |= URTW_HWREV_8187B_B;
4318 URTW8187_DBG(URTW_DEBUG_HWTYPE, (sc->sc_dev, CE_CONT,
4320 if (sc->sc_hwrev & URTW_HWREV_8187) {
4321 sc->urtw_init = urtw_8187_init;
4323 sc->urtw_init = urtw_8187b_init;
4326 if (urtw_read32_c(sc, URTW_RX, &data, 0))
4328 sc->sc_epromtype = (data & URTW_RX_9356SEL) ? URTW_EEPROM_93C56 :
4330 if (sc->sc_epromtype == URTW_EEPROM_93C56)
4331 URTW8187_DBG(URTW_DEBUG_HWTYPE, (sc->sc_dev, CE_CONT,
4334 URTW8187_DBG(URTW_DEBUG_HWTYPE, (sc->sc_dev, CE_CONT,
4336 error = urtw_get_rfchip(sc);
4339 error = urtw_get_macaddr(sc);
4342 error = urtw_get_txpwr(sc);
4345 error = urtw_led_init(sc); /* XXX incompleted */
4349 sc->sc_rts_retry = URTW_DEFAULT_RTS_RETRY;
4350 sc->sc_tx_retry = URTW_DEFAULT_TX_RETRY;
4351 sc->sc_currate = 3;
4353 sc->sc_preamble_mode = 2;
4388 sc->sc_newstate = ic->ic_newstate;
4394 sc->dwelltime = 250;
4395 sc->sc_flags = 0;
4406 URTW8187_DBG(URTW_DEBUG_ATTACH, (sc->sc_dev, CE_CONT,
4412 macp->m_driver = sc;
4449 URTW8187_DBG(URTW_DEBUG_ATTACH, (sc->sc_dev, CE_CONT,
4458 mutex_destroy(&sc->sc_genlock);
4459 mutex_destroy(&sc->tx_lock);
4460 mutex_destroy(&sc->rx_lock);
4461 mutex_destroy(&sc->sc_ledlock);
4463 usb_client_detach(sc->sc_dev, sc->sc_udev);
4473 struct urtw_softc *sc;
4475 sc = ddi_get_soft_state(urtw_soft_state_p, ddi_get_instance(devinfo));
4476 URTW8187_DBG(URTW_DEBUG_ATTACH, (sc->sc_dev,
4484 (sc->sc_dev, CE_CONT, "urtw: suspend\n"));
4486 ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1);
4487 ieee80211_stop_watchdog(&sc->sc_ic);
4489 URTW_LOCK(sc);
4490 sc->sc_flags |= URTW_FLAG_SUSPEND;
4491 URTW_UNLOCK(sc);
4492 if (URTW_IS_RUNNING(sc)) {
4493 urtw_stop(sc);
4494 URTW_LOCK(sc);
4495 sc->sc_flags |= URTW_FLAG_PLUGIN_ONLINE;
4496 URTW_UNLOCK(sc);
4503 if (mac_disable(sc->sc_ic.ic_mach) != 0)
4505 urtw_stop(sc);
4509 (void) mac_unregister(sc->sc_ic.ic_mach);
4511 ieee80211_detach(&sc->sc_ic);
4513 usb_client_detach(devinfo, sc->sc_udev);
4514 mutex_destroy(&sc->sc_genlock);
4515 mutex_destroy(&sc->tx_lock);
4516 mutex_destroy(&sc->rx_lock);
4517 mutex_destroy(&sc->sc_ledlock);
4518 sc->sc_udev = NULL;