Lines Matching full:sc
253 #define IS_OPERATIONAL(sc) \ argument
254 ((UEA_CHIP_VERSION(sc) != EAGLE_IV) ? \
255 (GET_STATUS(sc->stats.phy.state) == 2) : \
256 (sc->stats.phy.state == 7))
547 #define uea_wait(sc, cond, timeo) \ argument
549 int _r = wait_event_freezable_timeout(sc->sync_q, \
558 if (sc->usbatm->atm_dev) \
559 sc->usbatm->atm_dev->type = val; \
564 if (sc->usbatm->atm_dev) \
565 atm_dev_signal_change(sc->usbatm->atm_dev, val); \
821 static int uea_idma_write(struct uea_softc *sc, const void *data, u32 size) in uea_idma_write() argument
829 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); in uea_idma_write()
833 ret = usb_bulk_msg(sc->usb_dev, in uea_idma_write()
834 usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE), in uea_idma_write()
841 uea_err(INS_TO_USBDEV(sc), "size != bytes_read %d %d\n", size, in uea_idma_write()
849 static int request_dsp(struct uea_softc *sc) in request_dsp() argument
854 if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { in request_dsp()
855 if (IS_ISDN(sc)) in request_dsp()
859 } else if (UEA_CHIP_VERSION(sc) == ADI930) { in request_dsp()
860 if (IS_ISDN(sc)) in request_dsp()
865 if (IS_ISDN(sc)) in request_dsp()
871 ret = request_firmware(&sc->dsp_firm, dsp_name, &sc->usb_dev->dev); in request_dsp()
873 uea_err(INS_TO_USBDEV(sc), in request_dsp()
879 if (UEA_CHIP_VERSION(sc) == EAGLE_IV) in request_dsp()
880 ret = check_dsp_e4(sc->dsp_firm->data, sc->dsp_firm->size); in request_dsp()
882 ret = check_dsp_e1(sc->dsp_firm->data, sc->dsp_firm->size); in request_dsp()
885 uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", in request_dsp()
887 release_firmware(sc->dsp_firm); in request_dsp()
888 sc->dsp_firm = NULL; in request_dsp()
900 struct uea_softc *sc = container_of(work, struct uea_softc, task); in uea_load_page_e1() local
901 u16 pageno = sc->pageno; in uea_load_page_e1()
902 u16 ovl = sc->ovl; in uea_load_page_e1()
913 release_firmware(sc->dsp_firm); in uea_load_page_e1()
914 sc->dsp_firm = NULL; in uea_load_page_e1()
917 if (sc->dsp_firm == NULL && request_dsp(sc) < 0) in uea_load_page_e1()
920 p = sc->dsp_firm->data; in uea_load_page_e1()
933 p = sc->dsp_firm->data + pageoffset; in uea_load_page_e1()
937 uea_dbg(INS_TO_USBDEV(sc), in uea_load_page_e1()
956 if (uea_idma_write(sc, &bi, E1_BLOCK_INFO_SIZE)) in uea_load_page_e1()
960 if (uea_idma_write(sc, p, blocksize)) in uea_load_page_e1()
969 uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", i); in uea_load_page_e1()
972 uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n", pageno); in uea_load_page_e1()
975 static void __uea_load_page_e4(struct uea_softc *sc, u8 pageno, int boot) in __uea_load_page_e4() argument
979 struct l1_code *p = (struct l1_code *) sc->dsp_firm->data; in __uea_load_page_e4()
993 blockoffset = sc->dsp_firm->data + le32_to_cpu( in __uea_load_page_e4()
999 uea_dbg(INS_TO_USBDEV(sc), in __uea_load_page_e4()
1006 if (uea_idma_write(sc, &bi, E4_BLOCK_INFO_SIZE)) in __uea_load_page_e4()
1010 if (uea_idma_write(sc, blockoffset, blocksize)) in __uea_load_page_e4()
1019 uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", blockno); in __uea_load_page_e4()
1025 struct uea_softc *sc = container_of(work, struct uea_softc, task); in uea_load_page_e4() local
1026 u8 pageno = sc->pageno; in uea_load_page_e4()
1031 uea_dbg(INS_TO_USBDEV(sc), "sending DSP page %u\n", pageno); in uea_load_page_e4()
1035 release_firmware(sc->dsp_firm); in uea_load_page_e4()
1036 sc->dsp_firm = NULL; in uea_load_page_e4()
1039 if (sc->dsp_firm == NULL && request_dsp(sc) < 0) in uea_load_page_e4()
1042 p = (struct l1_code *) sc->dsp_firm->data; in uea_load_page_e4()
1044 uea_err(INS_TO_USBDEV(sc), "invalid DSP " in uea_load_page_e4()
1050 __uea_load_page_e4(sc, pageno, 0); in uea_load_page_e4()
1054 uea_dbg(INS_TO_USBDEV(sc), in uea_load_page_e4()
1059 __uea_load_page_e4(sc, i, 1); in uea_load_page_e4()
1062 uea_dbg(INS_TO_USBDEV(sc) , "sending start bi\n"); in uea_load_page_e4()
1072 if (uea_idma_write(sc, &bi, E4_BLOCK_INFO_SIZE)) in uea_load_page_e4()
1073 uea_err(INS_TO_USBDEV(sc), "sending DSP start bi failed\n"); in uea_load_page_e4()
1076 static inline void wake_up_cmv_ack(struct uea_softc *sc) in wake_up_cmv_ack() argument
1078 BUG_ON(sc->cmv_ack); in wake_up_cmv_ack()
1079 sc->cmv_ack = 1; in wake_up_cmv_ack()
1080 wake_up(&sc->sync_q); in wake_up_cmv_ack()
1083 static inline int wait_cmv_ack(struct uea_softc *sc) in wait_cmv_ack() argument
1085 int ret = uea_wait(sc, sc->cmv_ack , ACK_TIMEOUT); in wait_cmv_ack()
1087 sc->cmv_ack = 0; in wait_cmv_ack()
1089 uea_dbg(INS_TO_USBDEV(sc), "wait_event_timeout : %d ms\n", in wait_cmv_ack()
1100 static int uea_request(struct uea_softc *sc, in uea_request() argument
1108 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); in uea_request()
1112 ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0), in uea_request()
1119 uea_err(INS_TO_USBDEV(sc), "usb_control_msg error %d\n", ret); in uea_request()
1124 uea_err(INS_TO_USBDEV(sc), in uea_request()
1133 static int uea_cmv_e1(struct uea_softc *sc, in uea_cmv_e1() argument
1139 uea_enters(INS_TO_USBDEV(sc)); in uea_cmv_e1()
1140 uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Address : %c%c%c%c, " in uea_cmv_e1()
1149 sc->cmv_dsc.e1.function = function | 0x2; in uea_cmv_e1()
1150 sc->cmv_dsc.e1.idx++; in uea_cmv_e1()
1151 sc->cmv_dsc.e1.address = address; in uea_cmv_e1()
1152 sc->cmv_dsc.e1.offset = offset; in uea_cmv_e1()
1157 cmv.wIndex = cpu_to_le16(sc->cmv_dsc.e1.idx); in uea_cmv_e1()
1162 ret = uea_request(sc, UEA_E1_SET_BLOCK, UEA_MPTX_START, in uea_cmv_e1()
1166 ret = wait_cmv_ack(sc); in uea_cmv_e1()
1167 uea_leaves(INS_TO_USBDEV(sc)); in uea_cmv_e1()
1171 static int uea_cmv_e4(struct uea_softc *sc, in uea_cmv_e4() argument
1177 uea_enters(INS_TO_USBDEV(sc)); in uea_cmv_e4()
1180 uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Group : 0x%04x, " in uea_cmv_e4()
1186 sc->cmv_dsc.e4.function = function | (0x1 << 4); in uea_cmv_e4()
1187 sc->cmv_dsc.e4.offset = offset; in uea_cmv_e4()
1188 sc->cmv_dsc.e4.address = address; in uea_cmv_e4()
1189 sc->cmv_dsc.e4.group = group; in uea_cmv_e4()
1197 ret = uea_request(sc, UEA_E4_SET_BLOCK, UEA_MPTX_START, in uea_cmv_e4()
1201 ret = wait_cmv_ack(sc); in uea_cmv_e4()
1202 uea_leaves(INS_TO_USBDEV(sc)); in uea_cmv_e4()
1206 static inline int uea_read_cmv_e1(struct uea_softc *sc, in uea_read_cmv_e1() argument
1209 int ret = uea_cmv_e1(sc, E1_MAKEFUNCTION(E1_MEMACCESS, E1_REQUESTREAD), in uea_read_cmv_e1()
1212 uea_err(INS_TO_USBDEV(sc), in uea_read_cmv_e1()
1215 *data = sc->data; in uea_read_cmv_e1()
1220 static inline int uea_read_cmv_e4(struct uea_softc *sc, in uea_read_cmv_e4() argument
1223 int ret = uea_cmv_e4(sc, E4_MAKEFUNCTION(E4_MEMACCESS, in uea_read_cmv_e4()
1227 uea_err(INS_TO_USBDEV(sc), in uea_read_cmv_e4()
1230 *data = sc->data; in uea_read_cmv_e4()
1233 *(data + 1) = sc->data1; in uea_read_cmv_e4()
1238 static inline int uea_write_cmv_e1(struct uea_softc *sc, in uea_write_cmv_e1() argument
1241 int ret = uea_cmv_e1(sc, E1_MAKEFUNCTION(E1_MEMACCESS, E1_REQUESTWRITE), in uea_write_cmv_e1()
1244 uea_err(INS_TO_USBDEV(sc), in uea_write_cmv_e1()
1250 static inline int uea_write_cmv_e4(struct uea_softc *sc, in uea_write_cmv_e4() argument
1253 int ret = uea_cmv_e4(sc, E4_MAKEFUNCTION(E4_MEMACCESS, in uea_write_cmv_e4()
1257 uea_err(INS_TO_USBDEV(sc), in uea_write_cmv_e4()
1263 static void uea_set_bulk_timeout(struct uea_softc *sc, u32 dsrate) in uea_set_bulk_timeout() argument
1274 if (UEA_CHIP_VERSION(sc) == ADI930 || in uea_set_bulk_timeout()
1275 altsetting[sc->modem_index] > 0 || in uea_set_bulk_timeout()
1276 sc->stats.phy.dsrate == dsrate) in uea_set_bulk_timeout()
1281 ret = uea_request(sc, UEA_SET_TIMEOUT, timeout, 0, NULL); in uea_set_bulk_timeout()
1282 uea_info(INS_TO_USBDEV(sc), "setting new timeout %d%s\n", in uea_set_bulk_timeout()
1292 static int uea_stat_e1(struct uea_softc *sc) in uea_stat_e1() argument
1297 uea_enters(INS_TO_USBDEV(sc)); in uea_stat_e1()
1298 data = sc->stats.phy.state; in uea_stat_e1()
1300 ret = uea_read_cmv_e1(sc, E1_SA_STAT, 0, &sc->stats.phy.state); in uea_stat_e1()
1304 switch (GET_STATUS(sc->stats.phy.state)) { in uea_stat_e1()
1306 uea_dbg(INS_TO_USBDEV(sc), in uea_stat_e1()
1311 uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n"); in uea_stat_e1()
1315 uea_vdbg(INS_TO_USBDEV(sc), "modem operational\n"); in uea_stat_e1()
1319 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed" in uea_stat_e1()
1324 uea_warn(INS_TO_USBDEV(sc), in uea_stat_e1()
1329 uea_info(INS_TO_USBDEV(sc), "modem in fast-retain mode\n"); in uea_stat_e1()
1332 uea_err(INS_TO_USBDEV(sc), "modem invalid SW mode %d\n", in uea_stat_e1()
1333 GET_STATUS(sc->stats.phy.state)); in uea_stat_e1()
1338 uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL); in uea_stat_e1()
1339 uea_info(INS_TO_USBDEV(sc), "modem operational\n"); in uea_stat_e1()
1344 release_firmware(sc->dsp_firm); in uea_stat_e1()
1345 sc->dsp_firm = NULL; in uea_stat_e1()
1354 wake_up(&sc->sync_q); in uea_stat_e1()
1356 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 2, &sc->stats.phy.flags); in uea_stat_e1()
1359 sc->stats.phy.mflags |= sc->stats.phy.flags; in uea_stat_e1()
1364 if (sc->stats.phy.flags) { in uea_stat_e1()
1365 uea_dbg(INS_TO_USBDEV(sc), "Stat flag = 0x%x\n", in uea_stat_e1()
1366 sc->stats.phy.flags); in uea_stat_e1()
1370 ret = uea_read_cmv_e1(sc, E1_SA_RATE, 0, &data); in uea_stat_e1()
1374 uea_set_bulk_timeout(sc, (data >> 16) * 32); in uea_stat_e1()
1375 sc->stats.phy.dsrate = (data >> 16) * 32; in uea_stat_e1()
1376 sc->stats.phy.usrate = (data & 0xffff) * 32; in uea_stat_e1()
1377 UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424); in uea_stat_e1()
1379 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 23, &data); in uea_stat_e1()
1382 sc->stats.phy.dsattenuation = (data & 0xff) / 2; in uea_stat_e1()
1384 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 47, &data); in uea_stat_e1()
1387 sc->stats.phy.usattenuation = (data & 0xff) / 2; in uea_stat_e1()
1389 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 25, &sc->stats.phy.dsmargin); in uea_stat_e1()
1393 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 49, &sc->stats.phy.usmargin); in uea_stat_e1()
1397 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 51, &sc->stats.phy.rxflow); in uea_stat_e1()
1401 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 52, &sc->stats.phy.txflow); in uea_stat_e1()
1405 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 54, &sc->stats.phy.dsunc); in uea_stat_e1()
1410 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 58, &sc->stats.phy.usunc); in uea_stat_e1()
1414 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 53, &sc->stats.phy.dscorr); in uea_stat_e1()
1419 ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 57, &sc->stats.phy.uscorr); in uea_stat_e1()
1423 ret = uea_read_cmv_e1(sc, E1_SA_INFO, 8, &sc->stats.phy.vidco); in uea_stat_e1()
1427 ret = uea_read_cmv_e1(sc, E1_SA_INFO, 13, &sc->stats.phy.vidcpe); in uea_stat_e1()
1434 static int uea_stat_e4(struct uea_softc *sc) in uea_stat_e4() argument
1440 uea_enters(INS_TO_USBDEV(sc)); in uea_stat_e4()
1441 data = sc->stats.phy.state; in uea_stat_e4()
1444 ret = uea_read_cmv_e4(sc, 1, E4_SA_STAT, 0, 0, &sc->stats.phy.state); in uea_stat_e4()
1448 switch (sc->stats.phy.state) { in uea_stat_e4()
1453 uea_dbg(INS_TO_USBDEV(sc), "modem not yet " in uea_stat_e4()
1460 uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n"); in uea_stat_e4()
1463 uea_info(INS_TO_USBDEV(sc), "modem synchronization " in uea_stat_e4()
1469 uea_warn(INS_TO_USBDEV(sc), "unknown state: %x\n", in uea_stat_e4()
1470 sc->stats.phy.state); in uea_stat_e4()
1475 uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL); in uea_stat_e4()
1476 uea_info(INS_TO_USBDEV(sc), "modem operational\n"); in uea_stat_e4()
1481 release_firmware(sc->dsp_firm); in uea_stat_e4()
1482 sc->dsp_firm = NULL; in uea_stat_e4()
1491 wake_up(&sc->sync_q); in uea_stat_e4()
1498 ret = uea_read_cmv_e4(sc, 1, E4_SA_DIAG, 0, 0, &sc->stats.phy.flags); in uea_stat_e4()
1501 sc->stats.phy.mflags |= sc->stats.phy.flags; in uea_stat_e4()
1506 if (sc->stats.phy.flags) { in uea_stat_e4()
1507 uea_dbg(INS_TO_USBDEV(sc), "Stat flag = 0x%x\n", in uea_stat_e4()
1508 sc->stats.phy.flags); in uea_stat_e4()
1509 if (sc->stats.phy.flags & 1) /* delineation LOSS */ in uea_stat_e4()
1511 if (sc->stats.phy.flags & 0x4000) /* Reset Flag */ in uea_stat_e4()
1517 ret = uea_read_cmv_e4(sc, 4, E4_SA_RATE, 0, 0, tmp_arr); in uea_stat_e4()
1521 sc->stats.phy.usrate = data / 1000; in uea_stat_e4()
1523 ret = uea_read_cmv_e4(sc, 4, E4_SA_RATE, 1, 0, tmp_arr); in uea_stat_e4()
1527 uea_set_bulk_timeout(sc, data / 1000); in uea_stat_e4()
1528 sc->stats.phy.dsrate = data / 1000; in uea_stat_e4()
1529 UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424); in uea_stat_e4()
1531 ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 68, 1, &data); in uea_stat_e4()
1534 sc->stats.phy.dsattenuation = data / 10; in uea_stat_e4()
1536 ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 69, 1, &data); in uea_stat_e4()
1539 sc->stats.phy.usattenuation = data / 10; in uea_stat_e4()
1541 ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 68, 3, &data); in uea_stat_e4()
1544 sc->stats.phy.dsmargin = data / 2; in uea_stat_e4()
1546 ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 69, 3, &data); in uea_stat_e4()
1549 sc->stats.phy.usmargin = data / 10; in uea_stat_e4()
1554 static void cmvs_file_name(struct uea_softc *sc, char *const cmv_name, int ver) in cmvs_file_name() argument
1561 if (cmv_file[sc->modem_index] == NULL) { in cmvs_file_name()
1562 if (UEA_CHIP_VERSION(sc) == ADI930) in cmvs_file_name()
1564 else if (UEA_CHIP_VERSION(sc) == EAGLE_IV) in cmvs_file_name()
1569 file_arr[4] = IS_ISDN(sc) ? 'i' : 'p'; in cmvs_file_name()
1572 file = cmv_file[sc->modem_index]; in cmvs_file_name()
1581 static int request_cmvs_old(struct uea_softc *sc, in request_cmvs_old() argument
1588 cmvs_file_name(sc, cmv_name, 1); in request_cmvs_old()
1589 ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev); in request_cmvs_old()
1591 uea_err(INS_TO_USBDEV(sc), in request_cmvs_old()
1609 uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", cmv_name); in request_cmvs_old()
1614 static int request_cmvs(struct uea_softc *sc, in request_cmvs() argument
1622 cmvs_file_name(sc, cmv_name, 2); in request_cmvs()
1623 ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev); in request_cmvs()
1627 uea_warn(INS_TO_USBDEV(sc), "requesting " in request_cmvs()
1630 return request_cmvs_old(sc, cmvs, fw); in request_cmvs()
1632 uea_err(INS_TO_USBDEV(sc), in request_cmvs()
1642 uea_warn(INS_TO_USBDEV(sc), "firmware %s is corrupted," in request_cmvs()
1645 return request_cmvs_old(sc, cmvs, fw); in request_cmvs()
1670 uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", cmv_name); in request_cmvs()
1675 static int uea_send_cmvs_e1(struct uea_softc *sc) in uea_send_cmvs_e1() argument
1683 ret = uea_write_cmv_e1(sc, E1_SA_CNTL, 0, 1); in uea_send_cmvs_e1()
1688 ret = uea_read_cmv_e1(sc, E1_SA_INFO, 10, &sc->stats.phy.firmid); in uea_send_cmvs_e1()
1691 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n", in uea_send_cmvs_e1()
1692 sc->stats.phy.firmid); in uea_send_cmvs_e1()
1695 ret = len = request_cmvs(sc, &cmvs_ptr, &cmvs_fw, &ver); in uea_send_cmvs_e1()
1703 uea_warn(INS_TO_USBDEV(sc), "use deprecated cmvs version, " in uea_send_cmvs_e1()
1707 ret = uea_write_cmv_e1(sc, in uea_send_cmvs_e1()
1718 ret = uea_write_cmv_e1(sc, in uea_send_cmvs_e1()
1727 uea_err(INS_TO_USBDEV(sc), "bad cmvs version %d\n", ver); in uea_send_cmvs_e1()
1732 ret = uea_write_cmv_e1(sc, E1_SA_CNTL, 0, 2); in uea_send_cmvs_e1()
1733 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); in uea_send_cmvs_e1()
1734 uea_info(INS_TO_USBDEV(sc), "modem started, waiting " in uea_send_cmvs_e1()
1741 static int uea_send_cmvs_e4(struct uea_softc *sc) in uea_send_cmvs_e4() argument
1749 ret = uea_write_cmv_e4(sc, 1, E4_SA_CNTL, 0, 0, 1); in uea_send_cmvs_e4()
1755 ret = uea_read_cmv_e4(sc, 2, E4_SA_INFO, 55, 0, &sc->stats.phy.firmid); in uea_send_cmvs_e4()
1758 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n", in uea_send_cmvs_e4()
1759 sc->stats.phy.firmid); in uea_send_cmvs_e4()
1763 ret = len = request_cmvs(sc, &cmvs_ptr, &cmvs_fw, &ver); in uea_send_cmvs_e4()
1772 ret = uea_write_cmv_e4(sc, 1, in uea_send_cmvs_e4()
1782 uea_err(INS_TO_USBDEV(sc), "bad cmvs version %d\n", ver); in uea_send_cmvs_e4()
1787 ret = uea_write_cmv_e4(sc, 1, E4_SA_CNTL, 0, 0, 2); in uea_send_cmvs_e4()
1788 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); in uea_send_cmvs_e4()
1789 uea_info(INS_TO_USBDEV(sc), "modem started, waiting " in uea_send_cmvs_e4()
1802 static int uea_start_reset(struct uea_softc *sc) in uea_start_reset() argument
1807 uea_enters(INS_TO_USBDEV(sc)); in uea_start_reset()
1808 uea_info(INS_TO_USBDEV(sc), "(re)booting started\n"); in uea_start_reset()
1811 sc->booting = 1; in uea_start_reset()
1816 sc->cmv_ack = 0; in uea_start_reset()
1820 memset(&sc->stats, 0, sizeof(struct uea_stats)); in uea_start_reset()
1823 uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL); in uea_start_reset()
1824 uea_request(sc, UEA_SET_MODE, UEA_BOOT_IDMA, 0, NULL); in uea_start_reset()
1827 uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL); in uea_start_reset()
1830 ret = uea_wait(sc, 0, msecs_to_jiffies(100)); in uea_start_reset()
1835 uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL); in uea_start_reset()
1837 if (UEA_CHIP_VERSION(sc) != EAGLE_IV) { in uea_start_reset()
1839 uea_request(sc, UEA_SET_2183_DATA, UEA_MPTX_MAILBOX, 2, &zero); in uea_start_reset()
1840 uea_request(sc, UEA_SET_2183_DATA, UEA_MPRX_MAILBOX, 2, &zero); in uea_start_reset()
1841 uea_request(sc, UEA_SET_2183_DATA, UEA_SWAP_MAILBOX, 2, &zero); in uea_start_reset()
1844 ret = uea_wait(sc, 0, msecs_to_jiffies(1000)); in uea_start_reset()
1848 if (UEA_CHIP_VERSION(sc) == EAGLE_IV) in uea_start_reset()
1849 sc->cmv_dsc.e4.function = E4_MAKEFUNCTION(E4_ADSLDIRECTIVE, in uea_start_reset()
1852 sc->cmv_dsc.e1.function = E1_MAKEFUNCTION(E1_ADSLDIRECTIVE, in uea_start_reset()
1856 sc->booting = 0; in uea_start_reset()
1859 sc->pageno = 0; in uea_start_reset()
1860 sc->ovl = 0; in uea_start_reset()
1861 schedule_work(&sc->task); in uea_start_reset()
1864 ret = wait_cmv_ack(sc); in uea_start_reset()
1868 uea_vdbg(INS_TO_USBDEV(sc), "Ready CMV received\n"); in uea_start_reset()
1870 ret = sc->send_cmvs(sc); in uea_start_reset()
1874 sc->reset = 0; in uea_start_reset()
1875 uea_leaves(INS_TO_USBDEV(sc)); in uea_start_reset()
1887 struct uea_softc *sc = data; in uea_kthread() local
1891 uea_enters(INS_TO_USBDEV(sc)); in uea_kthread()
1893 if (ret < 0 || sc->reset) in uea_kthread()
1894 ret = uea_start_reset(sc); in uea_kthread()
1896 ret = sc->stat(sc); in uea_kthread()
1898 uea_wait(sc, 0, msecs_to_jiffies(1000)); in uea_kthread()
1900 uea_leaves(INS_TO_USBDEV(sc)); in uea_kthread()
1905 static int load_XILINX_firmware(struct uea_softc *sc) in load_XILINX_firmware() argument
1913 uea_enters(INS_TO_USBDEV(sc)); in load_XILINX_firmware()
1915 ret = request_firmware(&fw_entry, fw_name, &sc->usb_dev->dev); in load_XILINX_firmware()
1917 uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n", in load_XILINX_firmware()
1925 uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", in load_XILINX_firmware()
1932 ret = uea_request(sc, 0xe, 0, ln, pfw + u); in load_XILINX_firmware()
1934 uea_err(INS_TO_USBDEV(sc), in load_XILINX_firmware()
1941 ret = uea_request(sc, 0xe, 1, 0, NULL); in load_XILINX_firmware()
1943 uea_err(INS_TO_USBDEV(sc), in load_XILINX_firmware()
1950 ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value); in load_XILINX_firmware()
1952 uea_err(sc->usb_dev, "elsa de-assert failed with error" in load_XILINX_firmware()
1958 uea_leaves(INS_TO_USBDEV(sc)); in load_XILINX_firmware()
1963 static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr) in uea_dispatch_cmv_e1() argument
1965 struct cmv_dsc_e1 *dsc = &sc->cmv_dsc.e1; in uea_dispatch_cmv_e1()
1968 uea_enters(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
1979 if (UEA_CHIP_VERSION(sc) == ADI930 in uea_dispatch_cmv_e1()
1991 wake_up_cmv_ack(sc); in uea_dispatch_cmv_e1()
1992 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
2002 sc->data = get_unaligned_le32(&cmv->dwData); in uea_dispatch_cmv_e1()
2003 sc->data = sc->data << 16 | sc->data >> 16; in uea_dispatch_cmv_e1()
2005 wake_up_cmv_ack(sc); in uea_dispatch_cmv_e1()
2006 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
2010 uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " in uea_dispatch_cmv_e1()
2014 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
2018 uea_err(INS_TO_USBDEV(sc), "invalid cmv received, " in uea_dispatch_cmv_e1()
2021 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
2025 static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr) in uea_dispatch_cmv_e4() argument
2027 struct cmv_dsc_e4 *dsc = &sc->cmv_dsc.e4; in uea_dispatch_cmv_e4()
2030 uea_enters(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e4()
2031 uea_dbg(INS_TO_USBDEV(sc), "cmv %x %x %x %x %x %x\n", in uea_dispatch_cmv_e4()
2041 wake_up_cmv_ack(sc); in uea_dispatch_cmv_e4()
2042 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e4()
2052 sc->data = be32_to_cpu(cmv->dwData[0]); in uea_dispatch_cmv_e4()
2053 sc->data1 = be32_to_cpu(cmv->dwData[1]); in uea_dispatch_cmv_e4()
2054 wake_up_cmv_ack(sc); in uea_dispatch_cmv_e4()
2055 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e4()
2059 uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " in uea_dispatch_cmv_e4()
2063 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e4()
2067 static void uea_schedule_load_page_e1(struct uea_softc *sc, in uea_schedule_load_page_e1() argument
2070 sc->pageno = intr->e1_bSwapPageNo; in uea_schedule_load_page_e1()
2071 sc->ovl = intr->e1_bOvl >> 4 | intr->e1_bOvl << 4; in uea_schedule_load_page_e1()
2072 schedule_work(&sc->task); in uea_schedule_load_page_e1()
2075 static void uea_schedule_load_page_e4(struct uea_softc *sc, in uea_schedule_load_page_e4() argument
2078 sc->pageno = intr->e4_bSwapPageNo; in uea_schedule_load_page_e4()
2079 schedule_work(&sc->task); in uea_schedule_load_page_e4()
2087 struct uea_softc *sc = urb->context; in uea_intr() local
2091 uea_enters(INS_TO_USBDEV(sc)); in uea_intr()
2094 uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n", in uea_intr()
2100 if (intr->bType != 0x08 || sc->booting) { in uea_intr()
2101 uea_err(INS_TO_USBDEV(sc), "wrong interrupt\n"); in uea_intr()
2107 sc->schedule_load_page(sc, intr); in uea_intr()
2111 sc->dispatch_cmv(sc, intr); in uea_intr()
2115 uea_err(INS_TO_USBDEV(sc), "unknown interrupt %u\n", in uea_intr()
2120 usb_submit_urb(sc->urb_int, GFP_ATOMIC); in uea_intr()
2126 static int uea_boot(struct uea_softc *sc, struct usb_interface *intf) in uea_boot() argument
2132 uea_enters(INS_TO_USBDEV(sc)); in uea_boot()
2134 if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { in uea_boot()
2136 sc->dispatch_cmv = uea_dispatch_cmv_e4; in uea_boot()
2137 sc->schedule_load_page = uea_schedule_load_page_e4; in uea_boot()
2138 sc->stat = uea_stat_e4; in uea_boot()
2139 sc->send_cmvs = uea_send_cmvs_e4; in uea_boot()
2140 INIT_WORK(&sc->task, uea_load_page_e4); in uea_boot()
2143 sc->dispatch_cmv = uea_dispatch_cmv_e1; in uea_boot()
2144 sc->schedule_load_page = uea_schedule_load_page_e1; in uea_boot()
2145 sc->stat = uea_stat_e1; in uea_boot()
2146 sc->send_cmvs = uea_send_cmvs_e1; in uea_boot()
2147 INIT_WORK(&sc->task, uea_load_page_e1); in uea_boot()
2150 init_waitqueue_head(&sc->sync_q); in uea_boot()
2152 if (UEA_CHIP_VERSION(sc) == ADI930) in uea_boot()
2153 load_XILINX_firmware(sc); in uea_boot()
2164 sc->urb_int = usb_alloc_urb(0, GFP_KERNEL); in uea_boot()
2165 if (!sc->urb_int) in uea_boot()
2168 usb_fill_int_urb(sc->urb_int, sc->usb_dev, in uea_boot()
2169 usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE), in uea_boot()
2170 intr, size, uea_intr, sc, in uea_boot()
2173 ret = usb_submit_urb(sc->urb_int, GFP_KERNEL); in uea_boot()
2175 uea_err(INS_TO_USBDEV(sc), in uea_boot()
2183 sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm"); in uea_boot()
2184 if (IS_ERR(sc->kthread)) { in uea_boot()
2185 uea_err(INS_TO_USBDEV(sc), "failed to create thread\n"); in uea_boot()
2186 ret = PTR_ERR(sc->kthread); in uea_boot()
2190 uea_leaves(INS_TO_USBDEV(sc)); in uea_boot()
2194 usb_kill_urb(sc->urb_int); in uea_boot()
2196 usb_free_urb(sc->urb_int); in uea_boot()
2197 sc->urb_int = NULL; in uea_boot()
2200 uea_leaves(INS_TO_USBDEV(sc)); in uea_boot()
2207 static void uea_stop(struct uea_softc *sc) in uea_stop() argument
2210 uea_enters(INS_TO_USBDEV(sc)); in uea_stop()
2211 ret = kthread_stop(sc->kthread); in uea_stop()
2212 uea_dbg(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret); in uea_stop()
2214 uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL); in uea_stop()
2216 usb_kill_urb(sc->urb_int); in uea_stop()
2217 kfree(sc->urb_int->transfer_buffer); in uea_stop()
2218 usb_free_urb(sc->urb_int); in uea_stop()
2221 flush_work(&sc->task); in uea_stop()
2223 release_firmware(sc->dsp_firm); in uea_stop()
2224 uea_leaves(INS_TO_USBDEV(sc)); in uea_stop()
2248 struct uea_softc *sc; in stat_status_show() local
2251 sc = dev_to_uea(dev); in stat_status_show()
2252 if (!sc) in stat_status_show()
2254 ret = sysfs_emit(buf, "%08x\n", sc->stats.phy.state); in stat_status_show()
2264 struct uea_softc *sc; in stat_status_store() local
2267 sc = dev_to_uea(dev); in stat_status_store()
2268 if (!sc) in stat_status_store()
2270 sc->reset = 1; in stat_status_store()
2284 struct uea_softc *sc; in stat_human_status_show() local
2287 sc = dev_to_uea(dev); in stat_human_status_show()
2288 if (!sc) in stat_human_status_show()
2291 if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { in stat_human_status_show()
2292 switch (sc->stats.phy.state) { in stat_human_status_show()
2316 modem_state = GET_STATUS(sc->stats.phy.state); in stat_human_status_show()
2346 struct uea_softc *sc; in stat_delin_show() local
2350 sc = dev_to_uea(dev); in stat_delin_show()
2351 if (!sc) in stat_delin_show()
2354 if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { in stat_delin_show()
2355 if (sc->stats.phy.flags & 0x4000) in stat_delin_show()
2357 else if (sc->stats.phy.flags & 0x0001) in stat_delin_show()
2360 if (sc->stats.phy.flags & 0x0C00) in stat_delin_show()
2362 else if (sc->stats.phy.flags & 0x0030) in stat_delin_show()
2380 struct uea_softc *sc; \
2383 sc = dev_to_uea(dev); \
2384 if (!sc) \
2386 ret = sysfs_emit(buf, "%08x\n", sc->stats.phy.name); \
2388 sc->stats.phy.name = 0; \
2414 static int uea_getesi(struct uea_softc *sc, u_char *esi) in uea_getesi() argument
2419 (sc->usb_dev, sc->usb_dev->descriptor.iSerialNumber, mac_str, in uea_getesi()
2433 struct uea_softc *sc = usbatm->driver_data; in uea_atm_open() local
2435 return uea_getesi(sc, atm_dev->esi); in uea_atm_open()
2440 struct uea_softc *sc = usbatm->driver_data; in uea_heavy() local
2442 wait_event_interruptible(sc->sync_q, IS_OPERATIONAL(sc)); in uea_heavy()
2493 struct uea_softc *sc; in uea_bind() local
2518 sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL); in uea_bind()
2519 if (!sc) in uea_bind()
2522 sc->usb_dev = usb; in uea_bind()
2523 usbatm->driver_data = sc; in uea_bind()
2524 sc->usbatm = usbatm; in uea_bind()
2525 sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0; in uea_bind()
2526 sc->driver_info = id->driver_info; in uea_bind()
2529 if (annex[sc->modem_index] == 1) in uea_bind()
2530 sc->annex = ANNEXA; in uea_bind()
2531 else if (annex[sc->modem_index] == 2) in uea_bind()
2532 sc->annex = ANNEXB; in uea_bind()
2534 else if (sc->driver_info & AUTO_ANNEX_A) in uea_bind()
2535 sc->annex = ANNEXA; in uea_bind()
2536 else if (sc->driver_info & AUTO_ANNEX_B) in uea_bind()
2537 sc->annex = ANNEXB; in uea_bind()
2539 sc->annex = (le16_to_cpu in uea_bind()
2540 (sc->usb_dev->descriptor.bcdDevice) & 0x80) ? ANNEXB : ANNEXA; in uea_bind()
2542 alt = altsetting[sc->modem_index]; in uea_bind()
2556 ret = uea_boot(sc, intf); in uea_bind()
2563 kfree(sc); in uea_bind()
2569 struct uea_softc *sc = usbatm->driver_data; in uea_unbind() local
2571 uea_stop(sc); in uea_unbind()
2572 kfree(sc); in uea_unbind()
2606 struct uea_softc *sc = usbatm->driver_data; in uea_probe() local
2612 wake_up_process(sc->kthread); in uea_probe()