58 #include <linux/module.h>
64 #include <linux/ctype.h>
65 #include <linux/sched.h>
69 #include <linux/slab.h>
70 #include <linux/kernel.h>
72 #include <asm/unaligned.h>
76 #define EAGLEUSBVERSION "ueagle 1.4"
82 #define uea_dbg(usb_dev, format, args...) \
85 dev_dbg(&(usb_dev)->dev, \
86 "[ueagle-atm dbg] %s: " format, \
90 #define uea_vdbg(usb_dev, format, args...) \
93 dev_dbg(&(usb_dev)->dev, \
94 "[ueagle-atm vdbg] " format, ##args); \
97 #define uea_enters(usb_dev) \
98 uea_vdbg(usb_dev, "entering %s\n" , __func__)
100 #define uea_leaves(usb_dev) \
101 uea_vdbg(usb_dev, "leaving %s\n" , __func__)
103 #define uea_err(usb_dev, format, args...) \
104 dev_err(&(usb_dev)->dev , "[UEAGLE-ATM] " format , ##args)
106 #define uea_warn(usb_dev, format, args...) \
107 dev_warn(&(usb_dev)->dev , "[Ueagle-atm] " format, ##args)
109 #define uea_info(usb_dev, format, args...) \
110 dev_info(&(usb_dev)->dev , "[ueagle-atm] " format, ##args)
210 #define ELSA_VID 0x05CC
211 #define ELSA_PID_PSTFIRM 0x3350
212 #define ELSA_PID_PREFIRM 0x3351
214 #define ELSA_PID_A_PREFIRM 0x3352
215 #define ELSA_PID_A_PSTFIRM 0x3353
216 #define ELSA_PID_B_PREFIRM 0x3362
217 #define ELSA_PID_B_PSTFIRM 0x3363
222 #define DEVOLO_VID 0x1039
223 #define DEVOLO_EAGLE_I_A_PID_PSTFIRM 0x2110
224 #define DEVOLO_EAGLE_I_A_PID_PREFIRM 0x2111
226 #define DEVOLO_EAGLE_I_B_PID_PSTFIRM 0x2100
227 #define DEVOLO_EAGLE_I_B_PID_PREFIRM 0x2101
229 #define DEVOLO_EAGLE_II_A_PID_PSTFIRM 0x2130
230 #define DEVOLO_EAGLE_II_A_PID_PREFIRM 0x2131
232 #define DEVOLO_EAGLE_II_B_PID_PSTFIRM 0x2120
233 #define DEVOLO_EAGLE_II_B_PID_PREFIRM 0x2121
238 #define ANALOG_VID 0x1110
239 #define ADI930_PID_PREFIRM 0x9001
240 #define ADI930_PID_PSTFIRM 0x9000
242 #define EAGLE_I_PID_PREFIRM 0x9010
243 #define EAGLE_I_PID_PSTFIRM 0x900F
245 #define EAGLE_IIC_PID_PREFIRM 0x9024
246 #define EAGLE_IIC_PID_PSTFIRM 0x9023
248 #define EAGLE_II_PID_PREFIRM 0x9022
249 #define EAGLE_II_PID_PSTFIRM 0x9021
251 #define EAGLE_III_PID_PREFIRM 0x9032
252 #define EAGLE_III_PID_PSTFIRM 0x9031
254 #define EAGLE_IV_PID_PREFIRM 0x9042
255 #define EAGLE_IV_PID_PSTFIRM 0x9041
260 #define USR_VID 0x0BAF
261 #define MILLER_A_PID_PREFIRM 0x00F2
262 #define MILLER_A_PID_PSTFIRM 0x00F1
263 #define MILLER_B_PID_PREFIRM 0x00FA
264 #define MILLER_B_PID_PSTFIRM 0x00F9
265 #define HEINEKEN_A_PID_PREFIRM 0x00F6
266 #define HEINEKEN_A_PID_PSTFIRM 0x00F5
267 #define HEINEKEN_B_PID_PREFIRM 0x00F8
268 #define HEINEKEN_B_PID_PSTFIRM 0x00F7
271 #define PSTFIRM (1<<7)
272 #define AUTO_ANNEX_A (1<<8)
273 #define AUTO_ANNEX_B (1<<9)
284 #define UEA_IS_PREFIRM(x) \
285 (!((x)->driver_info & PSTFIRM))
286 #define UEA_CHIP_VERSION(x) \
287 ((x)->driver_info & 0xf)
290 ((x)->annex & ANNEXB)
292 #define INS_TO_USBDEV(ins) (ins->usb_dev)
294 #define GET_STATUS(data) \
297 #define IS_OPERATIONAL(sc) \
298 ((UEA_CHIP_VERSION(sc) != EAGLE_IV) ? \
299 (GET_STATUS(sc->stats.phy.state) == 2) : \
300 (sc->stats.phy.state == 7))
307 #define FW_GET_BYTE(p) (*((__u8 *) (p)))
309 #define FW_DIR "ueagle-atm/"
310 #define EAGLE_FIRMWARE FW_DIR "eagle.fw"
311 #define ADI930_FIRMWARE FW_DIR "adi930.fw"
312 #define EAGLE_I_FIRMWARE FW_DIR "eagleI.fw"
313 #define EAGLE_II_FIRMWARE FW_DIR "eagleII.fw"
314 #define EAGLE_III_FIRMWARE FW_DIR "eagleIII.fw"
315 #define EAGLE_IV_FIRMWARE FW_DIR "eagleIV.fw"
317 #define DSP4I_FIRMWARE FW_DIR "DSP4i.bin"
318 #define DSP4P_FIRMWARE FW_DIR "DSP4p.bin"
319 #define DSP9I_FIRMWARE FW_DIR "DSP9i.bin"
320 #define DSP9P_FIRMWARE FW_DIR "DSP9p.bin"
321 #define DSPEI_FIRMWARE FW_DIR "DSPei.bin"
322 #define DSPEP_FIRMWARE FW_DIR "DSPep.bin"
323 #define FPGA930_FIRMWARE FW_DIR "930-fpga.bin"
325 #define CMV4P_FIRMWARE FW_DIR "CMV4p.bin"
326 #define CMV4PV2_FIRMWARE FW_DIR "CMV4p.bin.v2"
327 #define CMV4I_FIRMWARE FW_DIR "CMV4i.bin"
328 #define CMV4IV2_FIRMWARE FW_DIR "CMV4i.bin.v2"
329 #define CMV9P_FIRMWARE FW_DIR "CMV9p.bin"
330 #define CMV9PV2_FIRMWARE FW_DIR "CMV9p.bin.v2"
331 #define CMV9I_FIRMWARE FW_DIR "CMV9i.bin"
332 #define CMV9IV2_FIRMWARE FW_DIR "CMV9i.bin.v2"
333 #define CMVEP_FIRMWARE FW_DIR "CMVep.bin"
334 #define CMVEPV2_FIRMWARE FW_DIR "CMVep.bin.v2"
335 #define CMVEI_FIRMWARE FW_DIR "CMVei.bin"
336 #define CMVEIV2_FIRMWARE FW_DIR "CMVei.bin.v2"
338 #define UEA_FW_NAME_MAX 30
341 #define BULK_TIMEOUT 300
342 #define CTRL_TIMEOUT 1000
344 #define ACK_TIMEOUT msecs_to_jiffies(3000)
346 #define UEA_INTR_IFACE_NO 0
347 #define UEA_US_IFACE_NO 1
348 #define UEA_DS_IFACE_NO 2
350 #define FASTEST_ISO_INTF 8
352 #define UEA_BULK_DATA_PIPE 0x02
353 #define UEA_IDMA_PIPE 0x04
354 #define UEA_INTR_PIPE 0x04
355 #define UEA_ISO_DATA_PIPE 0x08
357 #define UEA_E1_SET_BLOCK 0x0001
358 #define UEA_E4_SET_BLOCK 0x002c
359 #define UEA_SET_MODE 0x0003
360 #define UEA_SET_2183_DATA 0x0004
361 #define UEA_SET_TIMEOUT 0x0011
363 #define UEA_LOOPBACK_OFF 0x0002
364 #define UEA_LOOPBACK_ON 0x0003
365 #define UEA_BOOT_IDMA 0x0006
366 #define UEA_START_RESET 0x0007
367 #define UEA_END_RESET 0x0008
369 #define UEA_SWAP_MAILBOX (0x3fcd | 0x4000)
370 #define UEA_MPTX_START (0x3fce | 0x4000)
371 #define UEA_MPTX_MAILBOX (0x3fd6 | 0x4000)
372 #define UEA_MPRX_MAILBOX (0x3fdf | 0x4000)
385 #define E4_IS_BOOT_PAGE(PageSize) ((le32_to_cpu(PageSize)) & 0x80000000)
386 #define E4_PAGE_BYTES(PageSize) ((le32_to_cpu(PageSize) & 0x7fffffff) * 4)
388 #define E4_L1_STRING_HEADER 0x10
389 #define E4_MAX_PAGE_NUMBER 0x58
390 #define E4_NO_SWAPPAGE_HEADERS 0x31
409 #define E1_BLOCK_INFO_SIZE 12
419 #define E4_BLOCK_INFO_SIZE 14
421 #define UEA_BIHDR 0xabcd
422 #define UEA_RESERVED 0xffff
425 #define E1_PREAMBLE 0x535c
426 #define E1_MODEMTOHOST 0x01
427 #define E1_HOSTTOMODEM 0x10
429 #define E1_MEMACCESS 0x1
430 #define E1_ADSLDIRECTIVE 0x7
431 #define E1_FUNCTION_TYPE(f) ((f) >> 4)
432 #define E1_FUNCTION_SUBTYPE(f) ((f) & 0x0f)
434 #define E4_MEMACCESS 0
435 #define E4_ADSLDIRECTIVE 0xf
436 #define E4_FUNCTION_TYPE(f) ((f) >> 8)
437 #define E4_FUNCTION_SIZE(f) ((f) & 0x0f)
438 #define E4_FUNCTION_SUBTYPE(f) (((f) >> 4) & 0x0f)
441 #define E1_REQUESTREAD 0x0
442 #define E1_REQUESTWRITE 0x1
443 #define E1_REPLYREAD 0x2
444 #define E1_REPLYWRITE 0x3
446 #define E4_REQUESTREAD 0x0
447 #define E4_REQUESTWRITE 0x4
448 #define E4_REPLYREAD (E4_REQUESTREAD | 1)
449 #define E4_REPLYWRITE (E4_REQUESTWRITE | 1)
452 #define E1_KERNELREADY 0x0
453 #define E1_MODEMREADY 0x1
455 #define E4_KERNELREADY 0x0
456 #define E4_MODEMREADY 0x1
458 #define E1_MAKEFUNCTION(t, s) (((t) & 0xf) << 4 | ((s) & 0xf))
459 #define E4_MAKEFUNCTION(t, st, s) (((t) & 0xf) << 8 | \
460 ((st) & 0xf) << 4 | ((s) & 0xf))
462 #define E1_MAKESA(a, b, c, d) \
463 (((c) & 0xff) << 24 | \
464 ((d) & 0xff) << 16 | \
465 ((a) & 0xff) << 8 | \
468 #define E1_GETSA1(a) ((a >> 8) & 0xff)
469 #define E1_GETSA2(a) (a & 0xff)
470 #define E1_GETSA3(a) ((a >> 24) & 0xff)
471 #define E1_GETSA4(a) ((a >> 16) & 0xff)
473 #define E1_SA_CNTL E1_MAKESA('C', 'N', 'T', 'L')
474 #define E1_SA_DIAG E1_MAKESA('D', 'I', 'A', 'G')
475 #define E1_SA_INFO E1_MAKESA('I', 'N', 'F', 'O')
476 #define E1_SA_OPTN E1_MAKESA('O', 'P', 'T', 'N')
477 #define E1_SA_RATE E1_MAKESA('R', 'A', 'T', 'E')
478 #define E1_SA_STAT E1_MAKESA('S', 'T', 'A', 'T')
519 #define e1_bSwapPageNo u.e1.s1.swapinfo.bSwapPageNo
520 #define e1_bOvl u.e1.s1.swapinfo.bOvl
521 #define e4_bSwapPageNo u.e4.s1.swapinfo.bSwapPageNo
523 #define INT_LOADSWAPPAGE 0x0001
524 #define INT_INCOMINGCMV 0x0002
561 #define E1_INTR_PKT_SIZE 28
562 #define E4_INTR_PKT_SIZE 64
564 static struct usb_driver uea_driver;
566 static const char *
const chip_name[] = {
567 "ADI930",
"Eagle I",
"Eagle II",
"Eagle III",
"Eagle IV"};
569 static int modem_index;
570 static unsigned int debug;
571 static unsigned int altsetting[
NB_MODEM] = {
580 MODULE_PARM_DESC(altsetting,
"alternate setting for incoming traffic: 0=bulk, "
581 "1=isoc slowest, ... , 8=isoc fastest (default)");
583 MODULE_PARM_DESC(sync_wait,
"wait the synchronisation before starting ATM");
586 "file name with configuration and management variables");
589 "manually set annex a/b (0=auto, 1=annex a, 2=annex b)");
591 #define uea_wait(sc, cond, timeo) \
593 int _r = wait_event_interruptible_timeout(sc->sync_q, \
594 (cond) || kthread_should_stop(), timeo); \
595 if (kthread_should_stop()) \
600 #define UPDATE_ATM_STAT(type, val) \
602 if (sc->usbatm->atm_dev) \
603 sc->usbatm->atm_dev->type = val; \
606 #define UPDATE_ATM_SIGNAL(val) \
608 if (sc->usbatm->atm_dev) \
609 atm_dev_signal_change(sc->usbatm->atm_dev, val); \
614 #define LOAD_INTERNAL 0xA0
615 #define F8051_USBCS 0x7f92
620 static int uea_send_modem_cmd(
struct usb_device *
usb,
629 usb_sndctrlpipe(usb, 0),
640 return (ret == size) ? 0 : -
EIO;
643 static void uea_upload_pre_firmware(
const struct firmware *fw_entry,
654 uea_err(usb,
"firmware is not available\n");
658 pfw = fw_entry->
data;
659 size = fw_entry->
size;
661 goto err_fw_corrupted;
667 goto err_fw_corrupted;
673 ret = uea_send_modem_cmd(usb,
F8051_USBCS,
sizeof(value), &value);
676 uea_err(usb,
"modem reset failed with error %d\n", ret);
682 u16 add = get_unaligned_le16(pfw + 1);
686 goto err_fw_corrupted;
688 ret = uea_send_modem_cmd(usb, add, len, pfw + 3);
690 uea_err(usb,
"uploading firmware data failed "
691 "with error %d\n", ret);
698 goto err_fw_corrupted;
704 ret = uea_send_modem_cmd(usb,
F8051_USBCS, 1, &value);
706 uea_err(usb,
"modem de-assert failed with error %d\n", ret);
708 uea_info(usb,
"firmware uploaded\n");
713 uea_err(usb,
"firmware is corrupted\n");
722 static int uea_load_firmware(
struct usb_device *usb,
unsigned int ver)
728 uea_info(usb,
"pre-firmware device, uploading firmware\n");
750 uea_upload_pre_firmware);
752 uea_err(usb,
"firmware %s is not available\n", fw_name);
754 uea_info(usb,
"loading firmware %s\n", fw_name);
766 static int check_dsp_e1(
const u8 *
dsp,
unsigned int len)
768 u8 pagecount, blockcount;
771 unsigned int i,
j,
p,
pp;
777 if (p + 4 * pagecount > len)
780 for (i = 0; i < pagecount; i++) {
789 if (pageoffset >= len)
796 for (j = 0; j < blockcount; j++) {
803 blocksize = get_unaligned_le16(dsp + pp);
807 if (pp + blocksize > len)
817 static int check_dsp_e4(
const u8 *dsp,
int len)
843 if ((
u8 *)(blockidx + 1) - dsp >= len)
859 return (sum == len) ? 0 : 1;
884 if (size != bytes_read) {
893 static int request_dsp(
struct uea_softc *sc)
918 "requesting firmware %s failed with error %d\n",
950 u8 pagecount, blockcount;
951 u16 blockaddr, blocksize;
956 if (ovl == 0 && pageno == 0 && sc->
dsp_firm) {
968 if (pageno >= pagecount)
977 p = sc->
dsp_firm->data + pageoffset;
982 "sending %u blocks for DSP page %u\n", blockcount, pageno);
988 for (i = 0; i < blockcount; i++) {
989 blockaddr = get_unaligned_le16(p);
992 blocksize = get_unaligned_le16(p);
1004 if (uea_idma_write(sc, p, blocksize))
1019 static void __uea_load_page_e4(
struct uea_softc *sc,
u8 pageno,
int boot)
1027 bi.bBootPage = boot;
1028 bi.bPageNumber = pageno;
1032 const u8 *blockoffset;
1033 unsigned int blocksize;
1044 "sending block %u for DSP page "
1045 "%u size %u address %x\n",
1046 blockno, pageno, blocksize,
1054 if (uea_idma_write(sc, blockoffset, blocksize))
1067 static void uea_load_page_e4(
struct work_struct *work)
1089 "page %u requested\n", pageno);
1094 __uea_load_page_e4(sc, pageno, 0);
1099 "sending Main DSP page %u\n", p->
page_header[0].PageNumber);
1103 __uea_load_page_e4(sc, i, 1);
1110 bi.bPageNumber = 0xff;
1120 static inline void wake_up_cmv_ack(
struct uea_softc *sc)
1127 static inline int wait_cmv_ack(
struct uea_softc *sc)
1142 #define UCDC_SEND_ENCAPSULATED_COMMAND 0x00
1144 static int uea_request(
struct uea_softc *sc,
1169 "usb_control_msg send only %d bytes (instead of %d)\n",
1177 static int uea_cmv_e1(
struct uea_softc *sc,
1185 "offset : 0x%04x, data : 0x%08x\n",
1193 sc->
cmv_dsc.
e1.function =
function | 0x2;
1200 cmv.bFunction =
function;
1210 ret = wait_cmv_ack(sc);
1215 static int uea_cmv_e4(
struct uea_softc *sc,
1222 memset(&cmv, 0,
sizeof(cmv));
1225 "Address : 0x%04x, offset : 0x%04x, data : 0x%08x\n",
1227 group, address, offset, data);
1230 sc->
cmv_dsc.
e4.function =
function | (0x1 << 4);
1245 ret = wait_cmv_ack(sc);
1250 static inline int uea_read_cmv_e1(
struct uea_softc *sc,
1254 address, offset, 0);
1257 "reading cmv failed with error %d\n", ret);
1264 static inline int uea_read_cmv_e4(
struct uea_softc *sc,
1269 group, address, offset, 0);
1272 "reading cmv failed with error %d\n", ret);
1277 *(data + 1) = sc->
data1;
1282 static inline int uea_write_cmv_e1(
struct uea_softc *sc,
1286 address, offset, data);
1289 "writing cmv failed with error %d\n", ret);
1294 static inline int uea_write_cmv_e4(
struct uea_softc *sc,
1299 group, address, offset, data);
1302 "writing cmv failed with error %d\n", ret);
1307 static void uea_set_bulk_timeout(
struct uea_softc *sc,
u32 dsrate)
1320 sc->
stats.phy.dsrate == dsrate)
1324 timeout = (dsrate <= 1024*1024) ? 0 : 1;
1327 timeout, ret < 0 ?
" failed" :
"");
1336 static int uea_stat_e1(
struct uea_softc *sc)
1342 data = sc->
stats.phy.state;
1351 "modem not yet synchronized\n");
1364 " (may be try other cmv/dsp)\n");
1369 "modem in test mode - not supported\n");
1408 if (sc->
stats.phy.flags) {
1410 sc->
stats.phy.flags);
1414 ret = uea_read_cmv_e1(sc,
E1_SA_RATE, 0, &data);
1418 uea_set_bulk_timeout(sc, (data >> 16) * 32);
1419 sc->
stats.phy.dsrate = (data >> 16) * 32;
1420 sc->
stats.phy.usrate = (data & 0xffff) * 32;
1423 ret = uea_read_cmv_e1(sc,
E1_SA_DIAG, 23, &data);
1426 sc->
stats.phy.dsattenuation = (data & 0xff) / 2;
1428 ret = uea_read_cmv_e1(sc,
E1_SA_DIAG, 47, &data);
1431 sc->
stats.phy.usattenuation = (data & 0xff) / 2;
1478 static int uea_stat_e4(
struct uea_softc *sc)
1485 data = sc->
stats.phy.state;
1492 switch (sc->
stats.phy.state) {
1508 "failed (may be try other cmv/dsp)\n");
1514 sc->
stats.phy.state);
1550 if (sc->
stats.phy.flags) {
1552 sc->
stats.phy.flags);
1553 if (sc->
stats.phy.flags & 1)
1555 if (sc->
stats.phy.flags & 0x4000)
1561 ret = uea_read_cmv_e4(sc, 4,
E4_SA_RATE, 0, 0, tmp_arr);
1564 data = (tmp_arr[0]) ? tmp_arr[0] : tmp_arr[1];
1565 sc->
stats.phy.usrate = data / 1000;
1567 ret = uea_read_cmv_e4(sc, 4,
E4_SA_RATE, 1, 0, tmp_arr);
1570 data = (tmp_arr[0]) ? tmp_arr[0] : tmp_arr[1];
1571 uea_set_bulk_timeout(sc, data / 1000);
1572 sc->
stats.phy.dsrate = data / 1000;
1575 ret = uea_read_cmv_e4(sc, 1,
E4_SA_INFO, 68, 1, &data);
1578 sc->
stats.phy.dsattenuation = data / 10;
1580 ret = uea_read_cmv_e4(sc, 1,
E4_SA_INFO, 69, 1, &data);
1583 sc->
stats.phy.usattenuation = data / 10;
1585 ret = uea_read_cmv_e4(sc, 1,
E4_SA_INFO, 68, 3, &data);
1588 sc->
stats.phy.dsmargin = data / 2;
1590 ret = uea_read_cmv_e4(sc, 1,
E4_SA_INFO, 69, 3, &data);
1593 sc->
stats.phy.usmargin = data / 10;
1598 static void cmvs_file_name(
struct uea_softc *sc,
char *
const cmv_name,
int ver)
1600 char file_arr[] =
"CMVxy.bin";
1613 file_arr[4] =
IS_ISDN(sc) ?
'i' :
'p';
1625 static int request_cmvs_old(
struct uea_softc *sc,
1632 cmvs_file_name(sc, cmv_name, 1);
1636 "requesting firmware %s failed with error %d\n",
1641 data = (
u8 *) (*fw)->data;
1644 goto err_fw_corrupted;
1646 if (size != *data *
sizeof(
struct uea_cmvs_v1) + 1)
1647 goto err_fw_corrupted;
1649 *cmvs = (
void *)(data + 1);
1658 static int request_cmvs(
struct uea_softc *sc,
1659 void **cmvs,
const struct firmware **fw,
int *ver)
1666 cmvs_file_name(sc, cmv_name, 2);
1672 "firmware %s failed, "
1673 "try to get older cmvs\n", cmv_name);
1674 return request_cmvs_old(sc, cmvs, fw);
1677 "requesting firmware %s failed with error %d\n",
1683 data = (
u8 *) (*fw)->data;
1684 if (size < 4 ||
strncmp(data,
"cmv2", 4) != 0) {
1687 " try to get older cmvs\n", cmv_name);
1689 return request_cmvs_old(sc, cmvs, fw);
1691 goto err_fw_corrupted;
1699 goto err_fw_corrupted;
1704 if (
crc32_be(0, data, size) != crc)
1705 goto err_fw_corrupted;
1707 if (size != *data *
sizeof(
struct uea_cmvs_v2) + 1)
1708 goto err_fw_corrupted;
1710 *cmvs = (
void *) (data + 1);
1719 static int uea_send_cmvs_e1(
struct uea_softc *sc)
1727 ret = uea_write_cmv_e1(sc,
E1_SA_CNTL, 0, 1);
1736 sc->
stats.phy.firmid);
1739 ret = len = request_cmvs(sc, &cmvs_ptr, &cmvs_fw, &ver);
1748 "please update your firmware\n");
1750 for (i = 0; i < len; i++) {
1751 ret = uea_write_cmv_e1(sc,
1753 get_unaligned_le16(&cmvs_v1[i].offset),
1758 }
else if (ver == 2) {
1761 for (i = 0; i < len; i++) {
1762 ret = uea_write_cmv_e1(sc,
1776 ret = uea_write_cmv_e1(sc,
E1_SA_CNTL, 0, 2);
1779 "synchronization...\n");
1785 static int uea_send_cmvs_e4(
struct uea_softc *sc)
1793 ret = uea_write_cmv_e4(sc, 1,
E4_SA_CNTL, 0, 0, 1);
1799 ret = uea_read_cmv_e4(sc, 2,
E4_SA_INFO, 55, 0, &sc->
stats.phy.firmid);
1803 sc->
stats.phy.firmid);
1807 ret = len = request_cmvs(sc, &cmvs_ptr, &cmvs_fw, &ver);
1815 for (i = 0; i < len; i++) {
1816 ret = uea_write_cmv_e4(sc, 1,
1831 ret = uea_write_cmv_e4(sc, 1,
E4_SA_CNTL, 0, 0, 2);
1834 "synchronization...\n");
1846 static int uea_start_reset(
struct uea_softc *sc)
1908 ret = wait_cmv_ack(sc);
1929 static int uea_kthread(
void *data)
1937 if (ret < 0 || sc->
reset)
1938 ret = uea_start_reset(sc);
1950 static int load_XILINX_firmware(
struct uea_softc *sc)
1967 pfw = fw_entry->
data;
1968 size = fw_entry->
size;
1969 if (size != 0x577B) {
1975 for (u = 0; u <
size; u += ln) {
1976 ln =
min(size - u, 64);
1977 ret = uea_request(sc, 0
xe, 0, ln, pfw + u);
1980 "elsa download data failed (%d)\n", ret);
1986 ret = uea_request(sc, 0
xe, 1, 0,
NULL);
1989 "elsa download data failed (%d)\n", ret);
1995 ret = uea_send_modem_cmd(sc->
usb_dev, 0
xe, 1, &value);
2036 wake_up_cmv_ack(sc);
2050 wake_up_cmv_ack(sc);
2056 "Function : %d, Subfunction : %d\n",
2064 "wPreamble %d, bDirection %d\n",
2086 wake_up_cmv_ack(sc);
2099 wake_up_cmv_ack(sc);
2105 "Function : %d, Subfunction : %d\n",
2112 static void uea_schedule_load_page_e1(
struct uea_softc *sc,
2115 sc->
pageno = intr->e1_bSwapPageNo;
2116 sc->
ovl = intr->e1_bOvl >> 4 | intr->e1_bOvl << 4;
2120 static void uea_schedule_load_page_e4(
struct uea_softc *sc,
2123 sc->
pageno = intr->e4_bSwapPageNo;
2130 static void uea_intr(
struct urb *
urb)
2133 struct intr_pkt *intr = urb->transfer_buffer;
2134 int status = urb->status;
2171 static int uea_boot(
struct uea_softc *sc)
2182 sc->
stat = uea_stat_e4;
2189 sc->
stat = uea_stat_e1;
2197 load_XILINX_firmware(sc);
2202 "cannot allocate interrupt package\n");
2214 intr, size, uea_intr, sc,
2215 sc->
usb_dev->actconfig->interface[0]->altsetting[0].
2221 "urb submition failed with error %d\n", ret);
2251 static void uea_stop(
struct uea_softc *sc)
2277 intf = to_usb_interface(dev);
2281 usbatm = usb_get_intfdata(intf);
2295 sc = dev_to_uea(dev);
2305 const char *buf,
size_t count)
2311 sc = dev_to_uea(dev);
2331 sc = dev_to_uea(dev);
2336 switch (sc->
stats.phy.state) {
2362 switch (modem_state) {
2364 ret =
sprintf(buf,
"Modem is booting\n");
2367 ret =
sprintf(buf,
"Modem is initializing\n");
2370 ret =
sprintf(buf,
"Modem is operational\n");
2373 ret =
sprintf(buf,
"Modem synchronization failed\n");
2376 ret =
sprintf(buf,
"Modem state is unknown\n");
2391 char *delin =
"GOOD";
2394 sc = dev_to_uea(dev);
2399 if (sc->
stats.phy.flags & 0x4000)
2401 else if (sc->
stats.phy.flags & 0x0001)
2404 if (sc->
stats.phy.flags & 0x0C00)
2406 else if (sc->
stats.phy.flags & 0x0030)
2410 ret =
sprintf(buf,
"%s\n", delin);
2418 #define UEA_ATTR(name, reset) \
2420 static ssize_t read_##name(struct device *dev, \
2421 struct device_attribute *attr, char *buf) \
2423 int ret = -ENODEV; \
2424 struct uea_softc *sc; \
2426 mutex_lock(&uea_mutex); \
2427 sc = dev_to_uea(dev); \
2430 ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \
2432 sc->stats.phy.name = 0; \
2434 mutex_unlock(&uea_mutex); \
2438 static DEVICE_ATTR(stat_##name, S_IRUGO, read_##name, NULL)
2460 unsigned char mac_str[2 *
ETH_ALEN + 1];
2479 return uea_getesi(sc, atm_dev->
esi);
2492 static int claim_interface(
struct usb_device *
usb_dev,
2499 uea_err(usb_dev,
"interface %d not found\n", ifnum);
2505 uea_err(usb_dev,
"can't claim interface %d, error %d\n", ifnum,
2511 &dev_attr_stat_status.attr,
2512 &dev_attr_stat_mflags.attr,
2513 &dev_attr_stat_human_status.attr,
2514 &dev_attr_stat_delin.attr,
2515 &dev_attr_stat_vidcpe.attr,
2516 &dev_attr_stat_usrate.attr,
2517 &dev_attr_stat_dsrate.attr,
2518 &dev_attr_stat_usattenuation.attr,
2519 &dev_attr_stat_dsattenuation.attr,
2520 &dev_attr_stat_usmargin.attr,
2521 &dev_attr_stat_dsmargin.attr,
2522 &dev_attr_stat_txflow.attr,
2523 &dev_attr_stat_rxflow.attr,
2524 &dev_attr_stat_uscorr.attr,
2525 &dev_attr_stat_dscorr.attr,
2526 &dev_attr_stat_usunc.attr,
2527 &dev_attr_stat_dsunc.attr,
2528 &dev_attr_stat_firmid.attr,
2538 struct usb_device *usb = interface_to_usbdev(intf);
2540 int ret, ifnum = intf->altsetting->desc.bInterfaceNumber;
2566 uea_err(usb,
"uea_init: not enough memory !\n");
2595 uea_dbg(usb,
"set alternate %u for 2 interface\n", alt);
2599 uea_err(usb,
"setting alternate %u failed for "
2600 "2 interface, using bulk mode\n", alt);
2631 .driver_name =
"ueagle-atm",
2633 .atm_start = uea_atm_open,
2634 .unbind = uea_unbind,
2635 .heavy_init = uea_heavy,
2643 struct usb_device *usb = interface_to_usbdev(intf);
2647 uea_info(usb,
"ADSL device founded vid (%#X) pid (%#X) Rev (%#X): %s\n",
2660 struct usbatm_data *usbatm = usb_get_intfdata(intf);
2675 struct usb_device *usb = interface_to_usbdev(intf);
2676 int ifnum = intf->altsetting->desc.bInterfaceNumber;
2682 if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
2686 uea_info(usb,
"ADSL device removed\n");
2770 static struct usb_driver uea_driver = {
2771 .name =
"ueagle-atm",
2772 .id_table = uea_ids,
2774 .disconnect = uea_disconnect,
2781 MODULE_AUTHOR(
"Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka");