Lines Matching refs: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_interruptible_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()
1901 uea_leaves(INS_TO_USBDEV(sc)); in uea_kthread()
1906 static int load_XILINX_firmware(struct uea_softc *sc) in load_XILINX_firmware() argument
1914 uea_enters(INS_TO_USBDEV(sc)); in load_XILINX_firmware()
1916 ret = request_firmware(&fw_entry, fw_name, &sc->usb_dev->dev); in load_XILINX_firmware()
1918 uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n", in load_XILINX_firmware()
1926 uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", in load_XILINX_firmware()
1933 ret = uea_request(sc, 0xe, 0, ln, pfw + u); in load_XILINX_firmware()
1935 uea_err(INS_TO_USBDEV(sc), in load_XILINX_firmware()
1942 ret = uea_request(sc, 0xe, 1, 0, NULL); in load_XILINX_firmware()
1944 uea_err(INS_TO_USBDEV(sc), in load_XILINX_firmware()
1951 ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value); in load_XILINX_firmware()
1953 uea_err(sc->usb_dev, "elsa de-assert failed with error" in load_XILINX_firmware()
1959 uea_leaves(INS_TO_USBDEV(sc)); in load_XILINX_firmware()
1964 static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr) in uea_dispatch_cmv_e1() argument
1966 struct cmv_dsc_e1 *dsc = &sc->cmv_dsc.e1; in uea_dispatch_cmv_e1()
1969 uea_enters(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
1980 if (UEA_CHIP_VERSION(sc) == ADI930 in uea_dispatch_cmv_e1()
1992 wake_up_cmv_ack(sc); in uea_dispatch_cmv_e1()
1993 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
2003 sc->data = get_unaligned_le32(&cmv->dwData); in uea_dispatch_cmv_e1()
2004 sc->data = sc->data << 16 | sc->data >> 16; in uea_dispatch_cmv_e1()
2006 wake_up_cmv_ack(sc); in uea_dispatch_cmv_e1()
2007 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
2011 uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " in uea_dispatch_cmv_e1()
2015 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
2019 uea_err(INS_TO_USBDEV(sc), "invalid cmv received, " in uea_dispatch_cmv_e1()
2022 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e1()
2026 static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr) in uea_dispatch_cmv_e4() argument
2028 struct cmv_dsc_e4 *dsc = &sc->cmv_dsc.e4; in uea_dispatch_cmv_e4()
2031 uea_enters(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e4()
2032 uea_dbg(INS_TO_USBDEV(sc), "cmv %x %x %x %x %x %x\n", in uea_dispatch_cmv_e4()
2042 wake_up_cmv_ack(sc); in uea_dispatch_cmv_e4()
2043 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e4()
2053 sc->data = be32_to_cpu(cmv->dwData[0]); in uea_dispatch_cmv_e4()
2054 sc->data1 = be32_to_cpu(cmv->dwData[1]); in uea_dispatch_cmv_e4()
2055 wake_up_cmv_ack(sc); in uea_dispatch_cmv_e4()
2056 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e4()
2060 uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " in uea_dispatch_cmv_e4()
2064 uea_leaves(INS_TO_USBDEV(sc)); in uea_dispatch_cmv_e4()
2068 static void uea_schedule_load_page_e1(struct uea_softc *sc, in uea_schedule_load_page_e1() argument
2071 sc->pageno = intr->e1_bSwapPageNo; in uea_schedule_load_page_e1()
2072 sc->ovl = intr->e1_bOvl >> 4 | intr->e1_bOvl << 4; in uea_schedule_load_page_e1()
2073 schedule_work(&sc->task); in uea_schedule_load_page_e1()
2076 static void uea_schedule_load_page_e4(struct uea_softc *sc, in uea_schedule_load_page_e4() argument
2079 sc->pageno = intr->e4_bSwapPageNo; in uea_schedule_load_page_e4()
2080 schedule_work(&sc->task); in uea_schedule_load_page_e4()
2088 struct uea_softc *sc = urb->context; in uea_intr() local
2092 uea_enters(INS_TO_USBDEV(sc)); in uea_intr()
2095 uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n", in uea_intr()
2101 if (intr->bType != 0x08 || sc->booting) { in uea_intr()
2102 uea_err(INS_TO_USBDEV(sc), "wrong interrupt\n"); in uea_intr()
2108 sc->schedule_load_page(sc, intr); in uea_intr()
2112 sc->dispatch_cmv(sc, intr); in uea_intr()
2116 uea_err(INS_TO_USBDEV(sc), "unknown interrupt %u\n", in uea_intr()
2121 usb_submit_urb(sc->urb_int, GFP_ATOMIC); in uea_intr()
2127 static int uea_boot(struct uea_softc *sc, struct usb_interface *intf) in uea_boot() argument
2133 uea_enters(INS_TO_USBDEV(sc)); in uea_boot()
2135 if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { in uea_boot()
2137 sc->dispatch_cmv = uea_dispatch_cmv_e4; in uea_boot()
2138 sc->schedule_load_page = uea_schedule_load_page_e4; in uea_boot()
2139 sc->stat = uea_stat_e4; in uea_boot()
2140 sc->send_cmvs = uea_send_cmvs_e4; in uea_boot()
2141 INIT_WORK(&sc->task, uea_load_page_e4); in uea_boot()
2144 sc->dispatch_cmv = uea_dispatch_cmv_e1; in uea_boot()
2145 sc->schedule_load_page = uea_schedule_load_page_e1; in uea_boot()
2146 sc->stat = uea_stat_e1; in uea_boot()
2147 sc->send_cmvs = uea_send_cmvs_e1; in uea_boot()
2148 INIT_WORK(&sc->task, uea_load_page_e1); in uea_boot()
2151 init_waitqueue_head(&sc->sync_q); in uea_boot()
2153 if (UEA_CHIP_VERSION(sc) == ADI930) in uea_boot()
2154 load_XILINX_firmware(sc); in uea_boot()
2165 sc->urb_int = usb_alloc_urb(0, GFP_KERNEL); in uea_boot()
2166 if (!sc->urb_int) in uea_boot()
2169 usb_fill_int_urb(sc->urb_int, sc->usb_dev, in uea_boot()
2170 usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE), in uea_boot()
2171 intr, size, uea_intr, sc, in uea_boot()
2174 ret = usb_submit_urb(sc->urb_int, GFP_KERNEL); in uea_boot()
2176 uea_err(INS_TO_USBDEV(sc), in uea_boot()
2184 sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm"); in uea_boot()
2185 if (IS_ERR(sc->kthread)) { in uea_boot()
2186 uea_err(INS_TO_USBDEV(sc), "failed to create thread\n"); in uea_boot()
2187 ret = PTR_ERR(sc->kthread); in uea_boot()
2191 uea_leaves(INS_TO_USBDEV(sc)); in uea_boot()
2195 usb_kill_urb(sc->urb_int); in uea_boot()
2197 usb_free_urb(sc->urb_int); in uea_boot()
2198 sc->urb_int = NULL; in uea_boot()
2201 uea_leaves(INS_TO_USBDEV(sc)); in uea_boot()
2208 static void uea_stop(struct uea_softc *sc) in uea_stop() argument
2211 uea_enters(INS_TO_USBDEV(sc)); in uea_stop()
2212 ret = kthread_stop(sc->kthread); in uea_stop()
2213 uea_dbg(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret); in uea_stop()
2215 uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL); in uea_stop()
2217 usb_kill_urb(sc->urb_int); in uea_stop()
2218 kfree(sc->urb_int->transfer_buffer); in uea_stop()
2219 usb_free_urb(sc->urb_int); in uea_stop()
2222 flush_work(&sc->task); in uea_stop()
2224 release_firmware(sc->dsp_firm); in uea_stop()
2225 uea_leaves(INS_TO_USBDEV(sc)); in uea_stop()
2249 struct uea_softc *sc; in stat_status_show() local
2252 sc = dev_to_uea(dev); in stat_status_show()
2253 if (!sc) in stat_status_show()
2255 ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state); in stat_status_show()
2265 struct uea_softc *sc; in stat_status_store() local
2268 sc = dev_to_uea(dev); in stat_status_store()
2269 if (!sc) in stat_status_store()
2271 sc->reset = 1; in stat_status_store()
2285 struct uea_softc *sc; in stat_human_status_show() local
2288 sc = dev_to_uea(dev); in stat_human_status_show()
2289 if (!sc) in stat_human_status_show()
2292 if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { in stat_human_status_show()
2293 switch (sc->stats.phy.state) { in stat_human_status_show()
2317 modem_state = GET_STATUS(sc->stats.phy.state); in stat_human_status_show()
2347 struct uea_softc *sc; in stat_delin_show() local
2351 sc = dev_to_uea(dev); in stat_delin_show()
2352 if (!sc) in stat_delin_show()
2355 if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { in stat_delin_show()
2356 if (sc->stats.phy.flags & 0x4000) in stat_delin_show()
2358 else if (sc->stats.phy.flags & 0x0001) in stat_delin_show()
2361 if (sc->stats.phy.flags & 0x0C00) in stat_delin_show()
2363 else if (sc->stats.phy.flags & 0x0030) in stat_delin_show()
2381 struct uea_softc *sc; \
2384 sc = dev_to_uea(dev); \
2385 if (!sc) \
2387 ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \
2389 sc->stats.phy.name = 0; \
2415 static int uea_getesi(struct uea_softc *sc, u_char *esi) in uea_getesi() argument
2420 (sc->usb_dev, sc->usb_dev->descriptor.iSerialNumber, mac_str, in uea_getesi()
2434 struct uea_softc *sc = usbatm->driver_data; in uea_atm_open() local
2436 return uea_getesi(sc, atm_dev->esi); in uea_atm_open()
2441 struct uea_softc *sc = usbatm->driver_data; in uea_heavy() local
2443 wait_event_interruptible(sc->sync_q, IS_OPERATIONAL(sc)); in uea_heavy()
2494 struct uea_softc *sc; in uea_bind() local
2519 sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL); in uea_bind()
2520 if (!sc) in uea_bind()
2523 sc->usb_dev = usb; in uea_bind()
2524 usbatm->driver_data = sc; in uea_bind()
2525 sc->usbatm = usbatm; in uea_bind()
2526 sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0; in uea_bind()
2527 sc->driver_info = id->driver_info; in uea_bind()
2530 if (annex[sc->modem_index] == 1) in uea_bind()
2531 sc->annex = ANNEXA; in uea_bind()
2532 else if (annex[sc->modem_index] == 2) in uea_bind()
2533 sc->annex = ANNEXB; in uea_bind()
2535 else if (sc->driver_info & AUTO_ANNEX_A) in uea_bind()
2536 sc->annex = ANNEXA; in uea_bind()
2537 else if (sc->driver_info & AUTO_ANNEX_B) in uea_bind()
2538 sc->annex = ANNEXB; in uea_bind()
2540 sc->annex = (le16_to_cpu in uea_bind()
2541 (sc->usb_dev->descriptor.bcdDevice) & 0x80) ? ANNEXB : ANNEXA; in uea_bind()
2543 alt = altsetting[sc->modem_index]; in uea_bind()
2557 ret = uea_boot(sc, intf); in uea_bind()
2564 kfree(sc); in uea_bind()
2570 struct uea_softc *sc = usbatm->driver_data; in uea_unbind() local
2572 uea_stop(sc); in uea_unbind()
2573 kfree(sc); in uea_unbind()
2607 struct uea_softc *sc = usbatm->driver_data; in uea_probe() local
2613 wake_up_process(sc->kthread); in uea_probe()