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.c83
1 files changed, 41 insertions, 42 deletions
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index f5434b1cbb1e..f6b9f7e1f716 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.3" 71#define EAGLEUSBVERSION "ueagle 1.4"
72 72
73 73
74/* 74/*
@@ -80,14 +80,14 @@
80 dev_dbg(&(usb_dev)->dev, \ 80 dev_dbg(&(usb_dev)->dev, \
81 "[ueagle-atm dbg] %s: " format, \ 81 "[ueagle-atm dbg] %s: " format, \
82 __FUNCTION__, ##args); \ 82 __FUNCTION__, ##args); \
83 } while (0) 83 } while (0)
84 84
85#define uea_vdbg(usb_dev, format, args...) \ 85#define uea_vdbg(usb_dev, format, args...) \
86 do { \ 86 do { \
87 if (debug >= 2) \ 87 if (debug >= 2) \
88 dev_dbg(&(usb_dev)->dev, \ 88 dev_dbg(&(usb_dev)->dev, \
89 "[ueagle-atm vdbg] " format, ##args); \ 89 "[ueagle-atm vdbg] " format, ##args); \
90 } while (0) 90 } while (0)
91 91
92#define uea_enters(usb_dev) \ 92#define uea_enters(usb_dev) \
93 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__) 93 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__)
@@ -218,8 +218,8 @@ enum {
218#define UEA_CHIP_VERSION(x) \ 218#define UEA_CHIP_VERSION(x) \
219 ((x)->driver_info & 0xf) 219 ((x)->driver_info & 0xf)
220 220
221#define IS_ISDN(sc) \ 221#define IS_ISDN(usb_dev) \
222 (le16_to_cpu(sc->usb_dev->descriptor.bcdDevice) & 0x80) 222 (le16_to_cpu((usb_dev)->descriptor.bcdDevice) & 0x80)
223 223
224#define INS_TO_USBDEV(ins) ins->usb_dev 224#define INS_TO_USBDEV(ins) ins->usb_dev
225 225
@@ -625,12 +625,12 @@ static int request_dsp(struct uea_softc *sc)
625 char *dsp_name; 625 char *dsp_name;
626 626
627 if (UEA_CHIP_VERSION(sc) == ADI930) { 627 if (UEA_CHIP_VERSION(sc) == ADI930) {
628 if (IS_ISDN(sc)) 628 if (IS_ISDN(sc->usb_dev))
629 dsp_name = FW_DIR "DSP9i.bin"; 629 dsp_name = FW_DIR "DSP9i.bin";
630 else 630 else
631 dsp_name = FW_DIR "DSP9p.bin"; 631 dsp_name = FW_DIR "DSP9p.bin";
632 } else { 632 } else {
633 if (IS_ISDN(sc)) 633 if (IS_ISDN(sc->usb_dev))
634 dsp_name = FW_DIR "DSPei.bin"; 634 dsp_name = FW_DIR "DSPei.bin";
635 else 635 else
636 dsp_name = FW_DIR "DSPep.bin"; 636 dsp_name = FW_DIR "DSPep.bin";
@@ -744,7 +744,7 @@ static inline void wake_up_cmv_ack(struct uea_softc *sc)
744 744
745static inline int wait_cmv_ack(struct uea_softc *sc) 745static inline int wait_cmv_ack(struct uea_softc *sc)
746{ 746{
747 int ret = wait_event_timeout(sc->cmv_ack_wait, 747 int ret = wait_event_interruptible_timeout(sc->cmv_ack_wait,
748 sc->cmv_ack, ACK_TIMEOUT); 748 sc->cmv_ack, ACK_TIMEOUT);
749 sc->cmv_ack = 0; 749 sc->cmv_ack = 0;
750 750
@@ -885,7 +885,8 @@ static int uea_stat(struct uea_softc *sc)
885 break; 885 break;
886 886
887 case 3: /* fail ... */ 887 case 3: /* fail ... */
888 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed\n"); 888 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed"
889 " (may be try other cmv/dsp)\n");
889 return -EAGAIN; 890 return -EAGAIN;
890 891
891 case 4 ... 6: /* test state */ 892 case 4 ... 6: /* test state */
@@ -913,12 +914,6 @@ static int uea_stat(struct uea_softc *sc)
913 release_firmware(sc->dsp_firm); 914 release_firmware(sc->dsp_firm);
914 sc->dsp_firm = NULL; 915 sc->dsp_firm = NULL;
915 } 916 }
916
917 ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
918 if (ret < 0)
919 return ret;
920 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
921 sc->stats.phy.firmid);
922 } 917 }
923 918
924 /* always update it as atm layer could not be init when we switch to 919 /* always update it as atm layer could not be init when we switch to
@@ -1033,9 +1028,9 @@ static int request_cmvs(struct uea_softc *sc,
1033 1028
1034 if (cmv_file[sc->modem_index] == NULL) { 1029 if (cmv_file[sc->modem_index] == NULL) {
1035 if (UEA_CHIP_VERSION(sc) == ADI930) 1030 if (UEA_CHIP_VERSION(sc) == ADI930)
1036 file = (IS_ISDN(sc)) ? "CMV9i.bin" : "CMV9p.bin"; 1031 file = (IS_ISDN(sc->usb_dev)) ? "CMV9i.bin" : "CMV9p.bin";
1037 else 1032 else
1038 file = (IS_ISDN(sc)) ? "CMVei.bin" : "CMVep.bin"; 1033 file = (IS_ISDN(sc->usb_dev)) ? "CMVei.bin" : "CMVep.bin";
1039 } else 1034 } else
1040 file = cmv_file[sc->modem_index]; 1035 file = cmv_file[sc->modem_index];
1041 1036
@@ -1131,6 +1126,13 @@ static int uea_start_reset(struct uea_softc *sc)
1131 if (ret < 0) 1126 if (ret < 0)
1132 return ret; 1127 return ret;
1133 1128
1129 /* Dump firmware version */
1130 ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
1131 if (ret < 0)
1132 return ret;
1133 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
1134 sc->stats.phy.firmid);
1135
1134 /* get options */ 1136 /* get options */
1135 ret = len = request_cmvs(sc, &cmvs, &cmvs_fw); 1137 ret = len = request_cmvs(sc, &cmvs, &cmvs_fw);
1136 if (ret < 0) 1138 if (ret < 0)
@@ -1147,6 +1149,8 @@ static int uea_start_reset(struct uea_softc *sc)
1147 /* Enter in R-ACT-REQ */ 1149 /* Enter in R-ACT-REQ */
1148 ret = uea_write_cmv(sc, SA_CNTL, 0, 2); 1150 ret = uea_write_cmv(sc, SA_CNTL, 0, 2);
1149 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); 1151 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n");
1152 uea_info(INS_TO_USBDEV(sc), "Modem started, "
1153 "waiting synchronization\n");
1150out: 1154out:
1151 release_firmware(cmvs_fw); 1155 release_firmware(cmvs_fw);
1152 sc->reset = 0; 1156 sc->reset = 0;
@@ -1172,7 +1176,10 @@ static int uea_kthread(void *data)
1172 if (!ret) 1176 if (!ret)
1173 ret = uea_stat(sc); 1177 ret = uea_stat(sc);
1174 if (ret != -EAGAIN) 1178 if (ret != -EAGAIN)
1175 msleep(1000); 1179 msleep_interruptible(1000);
1180 if (try_to_freeze())
1181 uea_err(INS_TO_USBDEV(sc), "suspend/resume not supported, "
1182 "please unplug/replug your modem\n");
1176 } 1183 }
1177 uea_leaves(INS_TO_USBDEV(sc)); 1184 uea_leaves(INS_TO_USBDEV(sc));
1178 return ret; 1185 return ret;
@@ -1566,6 +1573,7 @@ UEA_ATTR(uscorr, 0);
1566UEA_ATTR(dscorr, 0); 1573UEA_ATTR(dscorr, 0);
1567UEA_ATTR(usunc, 0); 1574UEA_ATTR(usunc, 0);
1568UEA_ATTR(dsunc, 0); 1575UEA_ATTR(dsunc, 0);
1576UEA_ATTR(firmid, 0);
1569 1577
1570/* Retrieve the device End System Identifier (MAC) */ 1578/* Retrieve the device End System Identifier (MAC) */
1571 1579
@@ -1597,7 +1605,7 @@ static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf)
1597{ 1605{
1598 struct uea_softc *sc = usbatm->driver_data; 1606 struct uea_softc *sc = usbatm->driver_data;
1599 1607
1600 wait_event(sc->sync_q, IS_OPERATIONAL(sc)); 1608 wait_event_interruptible(sc->sync_q, IS_OPERATIONAL(sc));
1601 1609
1602 return 0; 1610 return 0;
1603 1611
@@ -1639,16 +1647,13 @@ static struct attribute *attrs[] = {
1639 &dev_attr_stat_dscorr.attr, 1647 &dev_attr_stat_dscorr.attr,
1640 &dev_attr_stat_usunc.attr, 1648 &dev_attr_stat_usunc.attr,
1641 &dev_attr_stat_dsunc.attr, 1649 &dev_attr_stat_dsunc.attr,
1650 &dev_attr_stat_firmid.attr,
1651 NULL,
1642}; 1652};
1643static struct attribute_group attr_grp = { 1653static struct attribute_group attr_grp = {
1644 .attrs = attrs, 1654 .attrs = attrs,
1645}; 1655};
1646 1656
1647static int create_fs_entries(struct usb_interface *intf)
1648{
1649 return sysfs_create_group(&intf->dev.kobj, &attr_grp);
1650}
1651
1652static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, 1657static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1653 const struct usb_device_id *id) 1658 const struct usb_device_id *id)
1654{ 1659{
@@ -1708,31 +1713,25 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1708 } 1713 }
1709 } 1714 }
1710 1715
1716 ret = sysfs_create_group(&intf->dev.kobj, &attr_grp);
1717 if (ret < 0)
1718 goto error;
1719
1711 ret = uea_boot(sc); 1720 ret = uea_boot(sc);
1712 if (ret < 0) { 1721 if (ret < 0)
1713 kfree(sc); 1722 goto error;
1714 return ret;
1715 }
1716 1723
1717 ret = create_fs_entries(intf);
1718 if (ret) {
1719 uea_stop(sc);
1720 kfree(sc);
1721 return ret;
1722 }
1723 return 0; 1724 return 0;
1724} 1725error:
1725 1726 kfree(sc);
1726static void destroy_fs_entries(struct usb_interface *intf) 1727 return ret;
1727{
1728 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1729} 1728}
1730 1729
1731static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) 1730static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
1732{ 1731{
1733 struct uea_softc *sc = usbatm->driver_data; 1732 struct uea_softc *sc = usbatm->driver_data;
1734 1733
1735 destroy_fs_entries(intf); 1734 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1736 uea_stop(sc); 1735 uea_stop(sc);
1737 kfree(sc); 1736 kfree(sc);
1738} 1737}
@@ -1753,10 +1752,10 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
1753 struct usb_device *usb = interface_to_usbdev(intf); 1752 struct usb_device *usb = interface_to_usbdev(intf);
1754 1753
1755 uea_enters(usb); 1754 uea_enters(usb);
1756 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s\n", 1755 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s %s\n",
1757 le16_to_cpu(usb->descriptor.idVendor), 1756 le16_to_cpu(usb->descriptor.idVendor),
1758 le16_to_cpu(usb->descriptor.idProduct), 1757 le16_to_cpu(usb->descriptor.idProduct),
1759 chip_name[UEA_CHIP_VERSION(id)]); 1758 chip_name[UEA_CHIP_VERSION(id)], IS_ISDN(usb)?"isdn":"pots");
1760 1759
1761 usb_reset_device(usb); 1760 usb_reset_device(usb);
1762 1761