aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/atm/ueagle-atm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/atm/ueagle-atm.c')
-rw-r--r--drivers/usb/atm/ueagle-atm.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 830d2c982670..b38990adf1cd 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -68,7 +68,7 @@
68 68
69#include "usbatm.h" 69#include "usbatm.h"
70 70
71#define EAGLEUSBVERSION "ueagle 1.2" 71#define EAGLEUSBVERSION "ueagle 1.3"
72 72
73 73
74/* 74/*
@@ -243,7 +243,7 @@ enum {
243#define BULK_TIMEOUT 300 243#define BULK_TIMEOUT 300
244#define CTRL_TIMEOUT 1000 244#define CTRL_TIMEOUT 1000
245 245
246#define ACK_TIMEOUT msecs_to_jiffies(1500) 246#define ACK_TIMEOUT msecs_to_jiffies(3000)
247 247
248#define UEA_INTR_IFACE_NO 0 248#define UEA_INTR_IFACE_NO 0
249#define UEA_US_IFACE_NO 1 249#define UEA_US_IFACE_NO 1
@@ -314,6 +314,10 @@ struct cmv {
314 ((d) & 0xff) << 16 | \ 314 ((d) & 0xff) << 16 | \
315 ((a) & 0xff) << 8 | \ 315 ((a) & 0xff) << 8 | \
316 ((b) & 0xff)) 316 ((b) & 0xff))
317#define GETSA1(a) ((a >> 8) & 0xff)
318#define GETSA2(a) (a & 0xff)
319#define GETSA3(a) ((a >> 24) & 0xff)
320#define GETSA4(a) ((a >> 16) & 0xff)
317 321
318#define SA_CNTL MAKESA('C', 'N', 'T', 'L') 322#define SA_CNTL MAKESA('C', 'N', 'T', 'L')
319#define SA_DIAG MAKESA('D', 'I', 'A', 'G') 323#define SA_DIAG MAKESA('D', 'I', 'A', 'G')
@@ -728,11 +732,12 @@ bad2:
728 uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", i); 732 uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", i);
729 return; 733 return;
730bad1: 734bad1:
731 uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n",pageno); 735 uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n", pageno);
732} 736}
733 737
734static inline void wake_up_cmv_ack(struct uea_softc *sc) 738static inline void wake_up_cmv_ack(struct uea_softc *sc)
735{ 739{
740 BUG_ON(sc->cmv_ack);
736 sc->cmv_ack = 1; 741 sc->cmv_ack = 1;
737 wake_up(&sc->cmv_ack_wait); 742 wake_up(&sc->cmv_ack_wait);
738} 743}
@@ -743,6 +748,9 @@ static inline int wait_cmv_ack(struct uea_softc *sc)
743 sc->cmv_ack, ACK_TIMEOUT); 748 sc->cmv_ack, ACK_TIMEOUT);
744 sc->cmv_ack = 0; 749 sc->cmv_ack = 0;
745 750
751 uea_dbg(INS_TO_USBDEV(sc), "wait_event_timeout : %d ms\n",
752 jiffies_to_msecs(ret));
753
746 if (ret < 0) 754 if (ret < 0)
747 return ret; 755 return ret;
748 756
@@ -791,6 +799,12 @@ static int uea_cmv(struct uea_softc *sc,
791 struct cmv cmv; 799 struct cmv cmv;
792 int ret; 800 int ret;
793 801
802 uea_enters(INS_TO_USBDEV(sc));
803 uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Address : %c%c%c%c, "
804 "offset : 0x%04x, data : 0x%08x\n",
805 FUNCTION_TYPE(function), FUNCTION_SUBTYPE(function),
806 GETSA1(address), GETSA2(address), GETSA3(address),
807 GETSA4(address), offset, data);
794 /* we send a request, but we expect a reply */ 808 /* we send a request, but we expect a reply */
795 sc->cmv_function = function | 0x2; 809 sc->cmv_function = function | 0x2;
796 sc->cmv_idx++; 810 sc->cmv_idx++;
@@ -808,7 +822,9 @@ static int uea_cmv(struct uea_softc *sc,
808 ret = uea_request(sc, UEA_SET_BLOCK, UEA_MPTX_START, CMV_SIZE, &cmv); 822 ret = uea_request(sc, UEA_SET_BLOCK, UEA_MPTX_START, CMV_SIZE, &cmv);
809 if (ret < 0) 823 if (ret < 0)
810 return ret; 824 return ret;
811 return wait_cmv_ack(sc); 825 ret = wait_cmv_ack(sc);
826 uea_leaves(INS_TO_USBDEV(sc));
827 return ret;
812} 828}
813 829
814static inline int uea_read_cmv(struct uea_softc *sc, 830static inline int uea_read_cmv(struct uea_softc *sc,
@@ -922,7 +938,7 @@ static int uea_stat(struct uea_softc *sc)
922 * we check the status again in order to detect the failure earlier 938 * we check the status again in order to detect the failure earlier
923 */ 939 */
924 if (sc->stats.phy.flags) { 940 if (sc->stats.phy.flags) {
925 uea_dbg(INS_TO_USBDEV(sc), "Stat flag = %d\n", 941 uea_dbg(INS_TO_USBDEV(sc), "Stat flag = 0x%x\n",
926 sc->stats.phy.flags); 942 sc->stats.phy.flags);
927 return 0; 943 return 0;
928 } 944 }
@@ -1063,7 +1079,13 @@ static int uea_start_reset(struct uea_softc *sc)
1063 uea_enters(INS_TO_USBDEV(sc)); 1079 uea_enters(INS_TO_USBDEV(sc));
1064 uea_info(INS_TO_USBDEV(sc), "(re)booting started\n"); 1080 uea_info(INS_TO_USBDEV(sc), "(re)booting started\n");
1065 1081
1082 /* mask interrupt */
1066 sc->booting = 1; 1083 sc->booting = 1;
1084 /* We need to set this here because, a ack timeout could have occured,
1085 * but before we start the reboot, the ack occurs and set this to 1.
1086 * So we will failed to wait Ready CMV.
1087 */
1088 sc->cmv_ack = 0;
1067 UPDATE_ATM_STAT(signal, ATM_PHY_SIG_LOST); 1089 UPDATE_ATM_STAT(signal, ATM_PHY_SIG_LOST);
1068 1090
1069 /* reset statistics */ 1091 /* reset statistics */
@@ -1089,6 +1111,7 @@ static int uea_start_reset(struct uea_softc *sc)
1089 1111
1090 msleep(1000); 1112 msleep(1000);
1091 sc->cmv_function = MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY); 1113 sc->cmv_function = MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY);
1114 /* demask interrupt */
1092 sc->booting = 0; 1115 sc->booting = 0;
1093 1116
1094 /* start loading DSP */ 1117 /* start loading DSP */
@@ -1101,6 +1124,8 @@ static int uea_start_reset(struct uea_softc *sc)
1101 if (ret < 0) 1124 if (ret < 0)
1102 return ret; 1125 return ret;
1103 1126
1127 uea_vdbg(INS_TO_USBDEV(sc), "Ready CMV received\n");
1128
1104 /* Enter in R-IDLE (cmv) until instructed otherwise */ 1129 /* Enter in R-IDLE (cmv) until instructed otherwise */
1105 ret = uea_write_cmv(sc, SA_CNTL, 0, 1); 1130 ret = uea_write_cmv(sc, SA_CNTL, 0, 1);
1106 if (ret < 0) 1131 if (ret < 0)
@@ -1121,6 +1146,7 @@ static int uea_start_reset(struct uea_softc *sc)
1121 } 1146 }
1122 /* Enter in R-ACT-REQ */ 1147 /* Enter in R-ACT-REQ */
1123 ret = uea_write_cmv(sc, SA_CNTL, 0, 2); 1148 ret = uea_write_cmv(sc, SA_CNTL, 0, 2);
1149 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n");
1124out: 1150out:
1125 release_firmware(cmvs_fw); 1151 release_firmware(cmvs_fw);
1126 sc->reset = 0; 1152 sc->reset = 0;
@@ -1235,6 +1261,7 @@ static void uea_dispatch_cmv(struct uea_softc *sc, struct cmv* cmv)
1235 1261
1236 if (cmv->bFunction == MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY)) { 1262 if (cmv->bFunction == MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY)) {
1237 wake_up_cmv_ack(sc); 1263 wake_up_cmv_ack(sc);
1264 uea_leaves(INS_TO_USBDEV(sc));
1238 return; 1265 return;
1239 } 1266 }
1240 1267
@@ -1249,6 +1276,7 @@ static void uea_dispatch_cmv(struct uea_softc *sc, struct cmv* cmv)
1249 sc->data = sc->data << 16 | sc->data >> 16; 1276 sc->data = sc->data << 16 | sc->data >> 16;
1250 1277
1251 wake_up_cmv_ack(sc); 1278 wake_up_cmv_ack(sc);
1279 uea_leaves(INS_TO_USBDEV(sc));
1252 return; 1280 return;
1253 1281
1254bad2: 1282bad2:
@@ -1256,12 +1284,14 @@ bad2:
1256 "Function : %d, Subfunction : %d\n", 1284 "Function : %d, Subfunction : %d\n",
1257 FUNCTION_TYPE(cmv->bFunction), 1285 FUNCTION_TYPE(cmv->bFunction),
1258 FUNCTION_SUBTYPE(cmv->bFunction)); 1286 FUNCTION_SUBTYPE(cmv->bFunction));
1287 uea_leaves(INS_TO_USBDEV(sc));
1259 return; 1288 return;
1260 1289
1261bad1: 1290bad1:
1262 uea_err(INS_TO_USBDEV(sc), "invalid cmv received, " 1291 uea_err(INS_TO_USBDEV(sc), "invalid cmv received, "
1263 "wPreamble %d, bDirection %d\n", 1292 "wPreamble %d, bDirection %d\n",
1264 le16_to_cpu(cmv->wPreamble), cmv->bDirection); 1293 le16_to_cpu(cmv->wPreamble), cmv->bDirection);
1294 uea_leaves(INS_TO_USBDEV(sc));
1265} 1295}
1266 1296
1267/* 1297/*
@@ -1346,7 +1376,7 @@ static int uea_boot(struct uea_softc *sc)
1346 if (ret < 0) { 1376 if (ret < 0) {
1347 uea_err(INS_TO_USBDEV(sc), 1377 uea_err(INS_TO_USBDEV(sc),
1348 "urb submition failed with error %d\n", ret); 1378 "urb submition failed with error %d\n", ret);
1349 goto err1; 1379 goto err;
1350 } 1380 }
1351 1381
1352 sc->kthread = kthread_run(uea_kthread, sc, "ueagle-atm"); 1382 sc->kthread = kthread_run(uea_kthread, sc, "ueagle-atm");
@@ -1360,10 +1390,10 @@ static int uea_boot(struct uea_softc *sc)
1360 1390
1361err2: 1391err2:
1362 usb_kill_urb(sc->urb_int); 1392 usb_kill_urb(sc->urb_int);
1363err1:
1364 kfree(intr);
1365err: 1393err:
1366 usb_free_urb(sc->urb_int); 1394 usb_free_urb(sc->urb_int);
1395 sc->urb_int = NULL;
1396 kfree(intr);
1367 uea_leaves(INS_TO_USBDEV(sc)); 1397 uea_leaves(INS_TO_USBDEV(sc));
1368 return -ENOMEM; 1398 return -ENOMEM;
1369} 1399}
@@ -1508,7 +1538,7 @@ static ssize_t read_##name(struct device *dev, \
1508 int ret = -ENODEV; \ 1538 int ret = -ENODEV; \
1509 struct uea_softc *sc; \ 1539 struct uea_softc *sc; \
1510 \ 1540 \
1511 mutex_lock(&uea_mutex); \ 1541 mutex_lock(&uea_mutex); \
1512 sc = dev_to_uea(dev); \ 1542 sc = dev_to_uea(dev); \
1513 if (!sc) \ 1543 if (!sc) \
1514 goto out; \ 1544 goto out; \
@@ -1516,7 +1546,7 @@ static ssize_t read_##name(struct device *dev, \
1516 if (reset) \ 1546 if (reset) \
1517 sc->stats.phy.name = 0; \ 1547 sc->stats.phy.name = 0; \
1518out: \ 1548out: \
1519 mutex_unlock(&uea_mutex); \ 1549 mutex_unlock(&uea_mutex); \
1520 return ret; \ 1550 return ret; \
1521} \ 1551} \
1522 \ 1552 \
@@ -1643,7 +1673,7 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1643 1673
1644 sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL); 1674 sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL);
1645 if (!sc) { 1675 if (!sc) {
1646 uea_err(INS_TO_USBDEV(sc), "uea_init: not enough memory !\n"); 1676 uea_err(usb, "uea_init: not enough memory !\n");
1647 return -ENOMEM; 1677 return -ENOMEM;
1648 } 1678 }
1649 1679