ueagle-atm.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813
  1. /*-
  2. * Copyright (c) 2003, 2004
  3. * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
  4. *
  5. * Copyright (c) 2005 Matthieu Castet <castet.matthieu@free.fr>
  6. *
  7. * This software is available to you under a choice of one of two
  8. * licenses. You may choose to be licensed under the terms of the GNU
  9. * General Public License (GPL) Version 2, available from the file
  10. * COPYING in the main directory of this source tree, or the
  11. * BSD license below:
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions
  15. * are met:
  16. * 1. Redistributions of source code must retain the above copyright
  17. * notice unmodified, this list of conditions, and the following
  18. * disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the distribution.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  27. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. * SUCH DAMAGE.
  34. *
  35. * GPL license :
  36. * This program is free software; you can redistribute it and/or
  37. * modify it under the terms of the GNU General Public License
  38. * as published by the Free Software Foundation; either version 2
  39. * of the License, or (at your option) any later version.
  40. *
  41. * This program is distributed in the hope that it will be useful,
  42. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  43. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  44. * GNU General Public License for more details.
  45. *
  46. * You should have received a copy of the GNU General Public License
  47. * along with this program; if not, write to the Free Software
  48. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  49. *
  50. *
  51. * HISTORY : some part of the code was base on ueagle 1.3 BSD driver,
  52. * Damien Bergamini agree to put his code under a DUAL GPL/BSD license.
  53. *
  54. * The rest of the code was was rewritten from scratch.
  55. */
  56. #include <linux/module.h>
  57. #include <linux/moduleparam.h>
  58. #include <linux/init.h>
  59. #include <linux/crc32.h>
  60. #include <linux/usb.h>
  61. #include <linux/firmware.h>
  62. #include <linux/ctype.h>
  63. #include <linux/kthread.h>
  64. #include <linux/version.h>
  65. #include <asm/unaligned.h>
  66. #include "usbatm.h"
  67. #define EAGLEUSBVERSION "ueagle 1.1"
  68. /*
  69. * Debug macros
  70. */
  71. #define uea_dbg(usb_dev, format, args...) \
  72. do { \
  73. if (debug >= 1) \
  74. dev_dbg(&(usb_dev)->dev, \
  75. "[ueagle-atm dbg] %s: " format, \
  76. __FUNCTION__, ##args); \
  77. } while (0)
  78. #define uea_vdbg(usb_dev, format, args...) \
  79. do { \
  80. if (debug >= 2) \
  81. dev_dbg(&(usb_dev)->dev, \
  82. "[ueagle-atm vdbg] " format, ##args); \
  83. } while (0)
  84. #define uea_enters(usb_dev) \
  85. uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__)
  86. #define uea_leaves(usb_dev) \
  87. uea_vdbg(usb_dev, "leaving %s\n", __FUNCTION__)
  88. #define uea_err(usb_dev, format,args...) \
  89. dev_err(&(usb_dev)->dev ,"[UEAGLE-ATM] " format , ##args)
  90. #define uea_warn(usb_dev, format,args...) \
  91. dev_warn(&(usb_dev)->dev ,"[Ueagle-atm] " format, ##args)
  92. #define uea_info(usb_dev, format,args...) \
  93. dev_info(&(usb_dev)->dev ,"[ueagle-atm] " format, ##args)
  94. struct uea_cmvs {
  95. u32 address;
  96. u16 offset;
  97. u32 data;
  98. } __attribute__ ((packed));
  99. struct uea_softc {
  100. struct usb_device *usb_dev;
  101. struct usbatm_data *usbatm;
  102. int modem_index;
  103. unsigned int driver_info;
  104. int booting;
  105. int reset;
  106. wait_queue_head_t sync_q;
  107. struct task_struct *kthread;
  108. u32 data;
  109. wait_queue_head_t cmv_ack_wait;
  110. int cmv_ack;
  111. struct work_struct task;
  112. u16 pageno;
  113. u16 ovl;
  114. const struct firmware *dsp_firm;
  115. struct urb *urb_int;
  116. u8 cmv_function;
  117. u16 cmv_idx;
  118. u32 cmv_address;
  119. u16 cmv_offset;
  120. /* keep in sync with eaglectl */
  121. struct uea_stats {
  122. struct {
  123. u32 state;
  124. u32 flags;
  125. u32 mflags;
  126. u32 vidcpe;
  127. u32 vidco;
  128. u32 dsrate;
  129. u32 usrate;
  130. u32 dsunc;
  131. u32 usunc;
  132. u32 dscorr;
  133. u32 uscorr;
  134. u32 txflow;
  135. u32 rxflow;
  136. u32 usattenuation;
  137. u32 dsattenuation;
  138. u32 dsmargin;
  139. u32 usmargin;
  140. u32 firmid;
  141. } phy;
  142. } stats;
  143. };
  144. /*
  145. * Elsa IDs
  146. */
  147. #define ELSA_VID 0x05CC
  148. #define ELSA_PID_PSTFIRM 0x3350
  149. #define ELSA_PID_PREFIRM 0x3351
  150. /*
  151. * Sagem USB IDs
  152. */
  153. #define EAGLE_VID 0x1110
  154. #define EAGLE_I_PID_PREFIRM 0x9010 /* Eagle I */
  155. #define EAGLE_I_PID_PSTFIRM 0x900F /* Eagle I */
  156. #define EAGLE_IIC_PID_PREFIRM 0x9024 /* Eagle IIC */
  157. #define EAGLE_IIC_PID_PSTFIRM 0x9023 /* Eagle IIC */
  158. #define EAGLE_II_PID_PREFIRM 0x9022 /* Eagle II */
  159. #define EAGLE_II_PID_PSTFIRM 0x9021 /* Eagle II */
  160. /*
  161. * Eagle III Pid
  162. */
  163. #define EAGLE_III_PID_PREFIRM 0x9032 /* Eagle III */
  164. #define EAGLE_III_PID_PSTFIRM 0x9031 /* Eagle III */
  165. /*
  166. * USR USB IDs
  167. */
  168. #define USR_VID 0x0BAF
  169. #define MILLER_A_PID_PREFIRM 0x00F2
  170. #define MILLER_A_PID_PSTFIRM 0x00F1
  171. #define MILLER_B_PID_PREFIRM 0x00FA
  172. #define MILLER_B_PID_PSTFIRM 0x00F9
  173. #define HEINEKEN_A_PID_PREFIRM 0x00F6
  174. #define HEINEKEN_A_PID_PSTFIRM 0x00F5
  175. #define HEINEKEN_B_PID_PREFIRM 0x00F8
  176. #define HEINEKEN_B_PID_PSTFIRM 0x00F7
  177. #define PREFIRM 0
  178. #define PSTFIRM (1<<7)
  179. enum {
  180. ADI930 = 0,
  181. EAGLE_I,
  182. EAGLE_II,
  183. EAGLE_III
  184. };
  185. /* macros for both struct usb_device_id and struct uea_softc */
  186. #define UEA_IS_PREFIRM(x) \
  187. (!((x)->driver_info & PSTFIRM))
  188. #define UEA_CHIP_VERSION(x) \
  189. ((x)->driver_info & 0xf)
  190. #define IS_ISDN(sc) \
  191. (le16_to_cpu(sc->usb_dev->descriptor.bcdDevice) & 0x80)
  192. #define INS_TO_USBDEV(ins) ins->usb_dev
  193. #define GET_STATUS(data) \
  194. ((data >> 8) & 0xf)
  195. #define IS_OPERATIONAL(sc) \
  196. (GET_STATUS(sc->stats.phy.state) == 2)
  197. /*
  198. * Set of macros to handle unaligned data in the firmware blob.
  199. * The FW_GET_BYTE() macro is provided only for consistency.
  200. */
  201. #define FW_GET_BYTE(p) *((__u8 *) (p))
  202. #define FW_GET_WORD(p) le16_to_cpu(get_unaligned((__le16 *) (p)))
  203. #define FW_GET_LONG(p) le32_to_cpu(get_unaligned((__le32 *) (p)))
  204. #define FW_DIR "ueagle-atm/"
  205. #define NB_MODEM 4
  206. #define BULK_TIMEOUT 300
  207. #define CTRL_TIMEOUT 1000
  208. #define ACK_TIMEOUT msecs_to_jiffies(1500)
  209. #define UEA_INTR_IFACE_NO 0
  210. #define UEA_US_IFACE_NO 1
  211. #define UEA_DS_IFACE_NO 2
  212. #define FASTEST_ISO_INTF 8
  213. #define UEA_BULK_DATA_PIPE 0x02
  214. #define UEA_IDMA_PIPE 0x04
  215. #define UEA_INTR_PIPE 0x04
  216. #define UEA_ISO_DATA_PIPE 0x08
  217. #define UEA_SET_BLOCK 0x0001
  218. #define UEA_SET_MODE 0x0003
  219. #define UEA_SET_2183_DATA 0x0004
  220. #define UEA_SET_TIMEOUT 0x0011
  221. #define UEA_LOOPBACK_OFF 0x0002
  222. #define UEA_LOOPBACK_ON 0x0003
  223. #define UEA_BOOT_IDMA 0x0006
  224. #define UEA_START_RESET 0x0007
  225. #define UEA_END_RESET 0x0008
  226. #define UEA_SWAP_MAILBOX (0x3fcd | 0x4000)
  227. #define UEA_MPTX_START (0x3fce | 0x4000)
  228. #define UEA_MPTX_MAILBOX (0x3fd6 | 0x4000)
  229. #define UEA_MPRX_MAILBOX (0x3fdf | 0x4000)
  230. /* structure describing a block within a DSP page */
  231. struct block_info {
  232. __le16 wHdr;
  233. #define UEA_BIHDR 0xabcd
  234. __le16 wAddress;
  235. __le16 wSize;
  236. __le16 wOvlOffset;
  237. __le16 wOvl; /* overlay */
  238. __le16 wLast;
  239. } __attribute__ ((packed));
  240. #define BLOCK_INFO_SIZE 12
  241. /* structure representing a CMV (Configuration and Management Variable) */
  242. struct cmv {
  243. __le16 wPreamble;
  244. #define PREAMBLE 0x535c
  245. __u8 bDirection;
  246. #define MODEMTOHOST 0x01
  247. #define HOSTTOMODEM 0x10
  248. __u8 bFunction;
  249. #define FUNCTION_TYPE(f) ((f) >> 4)
  250. #define MEMACCESS 0x1
  251. #define ADSLDIRECTIVE 0x7
  252. #define FUNCTION_SUBTYPE(f) ((f) & 0x0f)
  253. /* for MEMACCESS */
  254. #define REQUESTREAD 0x0
  255. #define REQUESTWRITE 0x1
  256. #define REPLYREAD 0x2
  257. #define REPLYWRITE 0x3
  258. /* for ADSLDIRECTIVE */
  259. #define KERNELREADY 0x0
  260. #define MODEMREADY 0x1
  261. #define MAKEFUNCTION(t, s) (((t) & 0xf) << 4 | ((s) & 0xf))
  262. __le16 wIndex;
  263. __le32 dwSymbolicAddress;
  264. #define MAKESA(a, b, c, d) \
  265. (((c) & 0xff) << 24 | \
  266. ((d) & 0xff) << 16 | \
  267. ((a) & 0xff) << 8 | \
  268. ((b) & 0xff))
  269. #define SA_CNTL MAKESA('C', 'N', 'T', 'L')
  270. #define SA_DIAG MAKESA('D', 'I', 'A', 'G')
  271. #define SA_INFO MAKESA('I', 'N', 'F', 'O')
  272. #define SA_OPTN MAKESA('O', 'P', 'T', 'N')
  273. #define SA_RATE MAKESA('R', 'A', 'T', 'E')
  274. #define SA_STAT MAKESA('S', 'T', 'A', 'T')
  275. __le16 wOffsetAddress;
  276. __le32 dwData;
  277. } __attribute__ ((packed));
  278. #define CMV_SIZE 16
  279. /* structure representing swap information */
  280. struct swap_info {
  281. __u8 bSwapPageNo;
  282. __u8 bOvl; /* overlay */
  283. } __attribute__ ((packed));
  284. /* structure representing interrupt data */
  285. struct intr_pkt {
  286. __u8 bType;
  287. __u8 bNotification;
  288. __le16 wValue;
  289. __le16 wIndex;
  290. __le16 wLength;
  291. __le16 wInterrupt;
  292. #define INT_LOADSWAPPAGE 0x0001
  293. #define INT_INCOMINGCMV 0x0002
  294. union {
  295. struct {
  296. struct swap_info swapinfo;
  297. __le16 wDataSize;
  298. } __attribute__ ((packed)) s1;
  299. struct {
  300. struct cmv cmv;
  301. __le16 wDataSize;
  302. } __attribute__ ((packed)) s2;
  303. } __attribute__ ((packed)) u;
  304. #define bSwapPageNo u.s1.swapinfo.bSwapPageNo
  305. #define bOvl u.s1.swapinfo.bOvl
  306. } __attribute__ ((packed));
  307. #define INTR_PKT_SIZE 28
  308. static struct usb_driver uea_driver;
  309. static DECLARE_MUTEX(uea_semaphore);
  310. static const char *chip_name[] = {"ADI930", "Eagle I", "Eagle II", "Eagle III"};
  311. static int modem_index;
  312. static unsigned int debug;
  313. static int sync_wait[NB_MODEM];
  314. static char *cmv_file[NB_MODEM];
  315. module_param(debug, uint, 0644);
  316. MODULE_PARM_DESC(debug, "module debug level (0=off,1=on,2=verbose)");
  317. module_param_array(sync_wait, bool, NULL, 0644);
  318. MODULE_PARM_DESC(sync_wait, "wait the synchronisation before starting ATM");
  319. module_param_array(cmv_file, charp, NULL, 0644);
  320. MODULE_PARM_DESC(cmv_file,
  321. "file name with configuration and management variables");
  322. #define UPDATE_ATM_STAT(type, val) \
  323. do { \
  324. if (sc->usbatm->atm_dev) \
  325. sc->usbatm->atm_dev->type = val; \
  326. } while (0)
  327. /* Firmware loading */
  328. #define LOAD_INTERNAL 0xA0
  329. #define F8051_USBCS 0x7f92
  330. /**
  331. * uea_send_modem_cmd - Send a command for pre-firmware devices.
  332. */
  333. static int uea_send_modem_cmd(struct usb_device *usb,
  334. u16 addr, u16 size, u8 * buff)
  335. {
  336. int ret = -ENOMEM;
  337. u8 *xfer_buff;
  338. xfer_buff = kmalloc(size, GFP_KERNEL);
  339. if (xfer_buff) {
  340. memcpy(xfer_buff, buff, size);
  341. ret = usb_control_msg(usb,
  342. usb_sndctrlpipe(usb, 0),
  343. LOAD_INTERNAL,
  344. USB_DIR_OUT | USB_TYPE_VENDOR |
  345. USB_RECIP_DEVICE, addr, 0, xfer_buff,
  346. size, CTRL_TIMEOUT);
  347. kfree(xfer_buff);
  348. }
  349. if (ret < 0)
  350. return ret;
  351. return (ret == size) ? 0 : -EIO;
  352. }
  353. static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *context)
  354. {
  355. struct usb_device *usb = context;
  356. u8 *pfw, value;
  357. u32 crc = 0;
  358. int ret, size;
  359. uea_enters(usb);
  360. if (!fw_entry) {
  361. uea_err(usb, "firmware is not available\n");
  362. goto err;
  363. }
  364. pfw = fw_entry->data;
  365. size = fw_entry->size;
  366. crc = FW_GET_LONG(pfw);
  367. pfw += 4;
  368. size -= 4;
  369. if (crc32_be(0, pfw, size) != crc) {
  370. uea_err(usb, "firmware is corrupted\n");
  371. goto err;
  372. }
  373. /*
  374. * Start to upload formware : send reset
  375. */
  376. value = 1;
  377. ret = uea_send_modem_cmd(usb, F8051_USBCS, sizeof(value), &value);
  378. if (ret < 0) {
  379. uea_err(usb, "modem reset failed with error %d\n", ret);
  380. goto err;
  381. }
  382. while (size > 0) {
  383. u8 len = FW_GET_BYTE(pfw);
  384. u16 add = FW_GET_WORD(pfw + 1);
  385. ret = uea_send_modem_cmd(usb, add, len, pfw + 3);
  386. if (ret < 0) {
  387. uea_err(usb, "uploading firmware data failed "
  388. "with error %d\n", ret);
  389. goto err;
  390. }
  391. pfw += len + 3;
  392. size -= len + 3;
  393. }
  394. /*
  395. * Tell the modem we finish : de-assert reset
  396. */
  397. value = 0;
  398. ret = uea_send_modem_cmd(usb, F8051_USBCS, 1, &value);
  399. if (ret < 0)
  400. uea_err(usb, "modem de-assert failed with error %d\n", ret);
  401. else
  402. uea_info(usb, "firmware uploaded\n");
  403. err:
  404. uea_leaves(usb);
  405. }
  406. /**
  407. * uea_load_firmware - Load usb firmware for pre-firmware devices.
  408. */
  409. static int uea_load_firmware(struct usb_device *usb, unsigned int ver)
  410. {
  411. int ret;
  412. char *fw_name = FW_DIR "eagle.fw";
  413. uea_enters(usb);
  414. uea_info(usb, "pre-firmware device, uploading firmware\n");
  415. switch (ver) {
  416. case ADI930:
  417. fw_name = FW_DIR "adi930.fw";
  418. break;
  419. case EAGLE_I:
  420. fw_name = FW_DIR "eagleI.fw";
  421. break;
  422. case EAGLE_II:
  423. fw_name = FW_DIR "eagleII.fw";
  424. break;
  425. case EAGLE_III:
  426. fw_name = FW_DIR "eagleIII.fw";
  427. break;
  428. }
  429. ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev, usb, uea_upload_pre_firmware);
  430. if (ret)
  431. uea_err(usb, "firmware %s is not available\n", fw_name);
  432. else
  433. uea_info(usb, "loading firmware %s\n", fw_name);
  434. uea_leaves(usb);
  435. return ret;
  436. }
  437. /* modem management : dsp firmware, send/read CMV, monitoring statistic
  438. */
  439. /*
  440. * Make sure that the DSP code provided is safe to use.
  441. */
  442. static int check_dsp(u8 *dsp, unsigned int len)
  443. {
  444. u8 pagecount, blockcount;
  445. u16 blocksize;
  446. u32 pageoffset;
  447. unsigned int i, j, p, pp;
  448. /* enough space for pagecount? */
  449. if (len < 1)
  450. return 1;
  451. pagecount = FW_GET_BYTE(dsp);
  452. p = 1;
  453. /* enough space for page offsets? */
  454. if (p + 4 * pagecount > len)
  455. return 1;
  456. for (i = 0; i < pagecount; i++) {
  457. pageoffset = FW_GET_LONG(dsp + p);
  458. p += 4;
  459. if (pageoffset == 0)
  460. continue;
  461. /* enough space for blockcount? */
  462. if (pageoffset >= len)
  463. return 1;
  464. pp = pageoffset;
  465. blockcount = FW_GET_BYTE(dsp + pp);
  466. pp += 1;
  467. for (j = 0; j < blockcount; j++) {
  468. /* enough space for block header? */
  469. if (pp + 4 > len)
  470. return 1;
  471. pp += 2; /* skip blockaddr */
  472. blocksize = FW_GET_WORD(dsp + pp);
  473. pp += 2;
  474. /* enough space for block data? */
  475. if (pp + blocksize > len)
  476. return 1;
  477. pp += blocksize;
  478. }
  479. }
  480. return 0;
  481. }
  482. /*
  483. * send data to the idma pipe
  484. * */
  485. static int uea_idma_write(struct uea_softc *sc, void *data, u32 size)
  486. {
  487. int ret = -ENOMEM;
  488. u8 *xfer_buff;
  489. int bytes_read;
  490. xfer_buff = kmalloc(size, GFP_KERNEL);
  491. if (!xfer_buff) {
  492. uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
  493. return ret;
  494. }
  495. memcpy(xfer_buff, data, size);
  496. ret = usb_bulk_msg(sc->usb_dev,
  497. usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE),
  498. xfer_buff, size, &bytes_read, BULK_TIMEOUT);
  499. kfree(xfer_buff);
  500. if (ret < 0)
  501. return ret;
  502. if (size != bytes_read) {
  503. uea_err(INS_TO_USBDEV(sc), "size != bytes_read %d %d\n", size,
  504. bytes_read);
  505. return -EIO;
  506. }
  507. return 0;
  508. }
  509. static int request_dsp(struct uea_softc *sc)
  510. {
  511. int ret;
  512. char *dsp_name;
  513. if (UEA_CHIP_VERSION(sc) == ADI930) {
  514. if (IS_ISDN(sc))
  515. dsp_name = FW_DIR "DSP9i.bin";
  516. else
  517. dsp_name = FW_DIR "DSP9p.bin";
  518. } else {
  519. if (IS_ISDN(sc))
  520. dsp_name = FW_DIR "DSPei.bin";
  521. else
  522. dsp_name = FW_DIR "DSPep.bin";
  523. }
  524. ret = request_firmware(&sc->dsp_firm,
  525. dsp_name, &sc->usb_dev->dev);
  526. if (ret < 0) {
  527. uea_err(INS_TO_USBDEV(sc),
  528. "requesting firmware %s failed with error %d\n",
  529. dsp_name, ret);
  530. return ret;
  531. }
  532. if (check_dsp(sc->dsp_firm->data, sc->dsp_firm->size)) {
  533. uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
  534. dsp_name);
  535. release_firmware(sc->dsp_firm);
  536. sc->dsp_firm = NULL;
  537. return -EILSEQ;
  538. }
  539. return 0;
  540. }
  541. /*
  542. * The uea_load_page() function must be called within a process context
  543. */
  544. static void uea_load_page(void *xsc)
  545. {
  546. struct uea_softc *sc = xsc;
  547. u16 pageno = sc->pageno;
  548. u16 ovl = sc->ovl;
  549. struct block_info bi;
  550. u8 *p;
  551. u8 pagecount, blockcount;
  552. u16 blockaddr, blocksize;
  553. u32 pageoffset;
  554. int i;
  555. /* reload firmware when reboot start and it's loaded already */
  556. if (ovl == 0 && pageno == 0 && sc->dsp_firm) {
  557. release_firmware(sc->dsp_firm);
  558. sc->dsp_firm = NULL;
  559. }
  560. if (sc->dsp_firm == NULL && request_dsp(sc) < 0)
  561. return;
  562. p = sc->dsp_firm->data;
  563. pagecount = FW_GET_BYTE(p);
  564. p += 1;
  565. if (pageno >= pagecount)
  566. goto bad1;
  567. p += 4 * pageno;
  568. pageoffset = FW_GET_LONG(p);
  569. if (pageoffset == 0)
  570. goto bad1;
  571. p = sc->dsp_firm->data + pageoffset;
  572. blockcount = FW_GET_BYTE(p);
  573. p += 1;
  574. uea_dbg(INS_TO_USBDEV(sc),
  575. "sending %u blocks for DSP page %u\n", blockcount, pageno);
  576. bi.wHdr = cpu_to_le16(UEA_BIHDR);
  577. bi.wOvl = cpu_to_le16(ovl);
  578. bi.wOvlOffset = cpu_to_le16(ovl | 0x8000);
  579. for (i = 0; i < blockcount; i++) {
  580. blockaddr = FW_GET_WORD(p);
  581. p += 2;
  582. blocksize = FW_GET_WORD(p);
  583. p += 2;
  584. bi.wSize = cpu_to_le16(blocksize);
  585. bi.wAddress = cpu_to_le16(blockaddr);
  586. bi.wLast = cpu_to_le16((i == blockcount - 1) ? 1 : 0);
  587. /* send block info through the IDMA pipe */
  588. if (uea_idma_write(sc, &bi, BLOCK_INFO_SIZE))
  589. goto bad2;
  590. /* send block data through the IDMA pipe */
  591. if (uea_idma_write(sc, p, blocksize))
  592. goto bad2;
  593. p += blocksize;
  594. }
  595. return;
  596. bad2:
  597. uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", i);
  598. return;
  599. bad1:
  600. uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n",pageno);
  601. }
  602. static inline void wake_up_cmv_ack(struct uea_softc *sc)
  603. {
  604. sc->cmv_ack = 1;
  605. wake_up(&sc->cmv_ack_wait);
  606. }
  607. static inline int wait_cmv_ack(struct uea_softc *sc)
  608. {
  609. int ret = wait_event_timeout(sc->cmv_ack_wait,
  610. sc->cmv_ack, ACK_TIMEOUT);
  611. sc->cmv_ack = 0;
  612. if (ret < 0)
  613. return ret;
  614. return (ret == 0) ? -ETIMEDOUT : 0;
  615. }
  616. #define UCDC_SEND_ENCAPSULATED_COMMAND 0x00
  617. static int uea_request(struct uea_softc *sc,
  618. u16 value, u16 index, u16 size, void *data)
  619. {
  620. u8 *xfer_buff;
  621. int ret = -ENOMEM;
  622. xfer_buff = kmalloc(size, GFP_KERNEL);
  623. if (!xfer_buff) {
  624. uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
  625. return ret;
  626. }
  627. memcpy(xfer_buff, data, size);
  628. ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0),
  629. UCDC_SEND_ENCAPSULATED_COMMAND,
  630. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  631. value, index, xfer_buff, size, CTRL_TIMEOUT);
  632. kfree(xfer_buff);
  633. if (ret < 0) {
  634. uea_err(INS_TO_USBDEV(sc), "usb_control_msg error %d\n", ret);
  635. return ret;
  636. }
  637. if (ret != size) {
  638. uea_err(INS_TO_USBDEV(sc),
  639. "usb_control_msg send only %d bytes (instead of %d)\n",
  640. ret, size);
  641. return -EIO;
  642. }
  643. return 0;
  644. }
  645. static int uea_cmv(struct uea_softc *sc,
  646. u8 function, u32 address, u16 offset, u32 data)
  647. {
  648. struct cmv cmv;
  649. int ret;
  650. /* we send a request, but we expect a reply */
  651. sc->cmv_function = function | 0x2;
  652. sc->cmv_idx++;
  653. sc->cmv_address = address;
  654. sc->cmv_offset = offset;
  655. cmv.wPreamble = cpu_to_le16(PREAMBLE);
  656. cmv.bDirection = HOSTTOMODEM;
  657. cmv.bFunction = function;
  658. cmv.wIndex = cpu_to_le16(sc->cmv_idx);
  659. put_unaligned(cpu_to_le32(address), &cmv.dwSymbolicAddress);
  660. cmv.wOffsetAddress = cpu_to_le16(offset);
  661. put_unaligned(cpu_to_le32(data >> 16 | data << 16), &cmv.dwData);
  662. ret = uea_request(sc, UEA_SET_BLOCK, UEA_MPTX_START, CMV_SIZE, &cmv);
  663. if (ret < 0)
  664. return ret;
  665. return wait_cmv_ack(sc);
  666. }
  667. static inline int uea_read_cmv(struct uea_softc *sc,
  668. u32 address, u16 offset, u32 *data)
  669. {
  670. int ret = uea_cmv(sc, MAKEFUNCTION(MEMACCESS, REQUESTREAD),
  671. address, offset, 0);
  672. if (ret < 0)
  673. uea_err(INS_TO_USBDEV(sc),
  674. "reading cmv failed with error %d\n", ret);
  675. else
  676. *data = sc->data;
  677. return ret;
  678. }
  679. static inline int uea_write_cmv(struct uea_softc *sc,
  680. u32 address, u16 offset, u32 data)
  681. {
  682. int ret = uea_cmv(sc, MAKEFUNCTION(MEMACCESS, REQUESTWRITE),
  683. address, offset, data);
  684. if (ret < 0)
  685. uea_err(INS_TO_USBDEV(sc),
  686. "writing cmv failed with error %d\n", ret);
  687. return ret;
  688. }
  689. /*
  690. * Monitor the modem and update the stat
  691. * return 0 if everything is ok
  692. * return < 0 if an error occurs (-EAGAIN reboot needed)
  693. */
  694. static int uea_stat(struct uea_softc *sc)
  695. {
  696. u32 data;
  697. int ret;
  698. uea_enters(INS_TO_USBDEV(sc));
  699. data = sc->stats.phy.state;
  700. ret = uea_read_cmv(sc, SA_STAT, 0, &sc->stats.phy.state);
  701. if (ret < 0)
  702. return ret;
  703. switch (GET_STATUS(sc->stats.phy.state)) {
  704. case 0: /* not yet synchronized */
  705. uea_dbg(INS_TO_USBDEV(sc),
  706. "modem not yet synchronized\n");
  707. return 0;
  708. case 1: /* initialization */
  709. uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n");
  710. return 0;
  711. case 2: /* operational */
  712. uea_vdbg(INS_TO_USBDEV(sc), "modem operational\n");
  713. break;
  714. case 3: /* fail ... */
  715. uea_info(INS_TO_USBDEV(sc), "modem synchronization failed\n");
  716. return -EAGAIN;
  717. case 4 ... 6: /* test state */
  718. uea_warn(INS_TO_USBDEV(sc),
  719. "modem in test mode - not supported\n");
  720. return -EAGAIN;
  721. case 7: /* fast-retain ... */
  722. uea_info(INS_TO_USBDEV(sc), "modem in fast-retain mode\n");
  723. return 0;
  724. default:
  725. uea_err(INS_TO_USBDEV(sc), "modem invalid SW mode %d\n",
  726. GET_STATUS(sc->stats.phy.state));
  727. return -EAGAIN;
  728. }
  729. if (GET_STATUS(data) != 2) {
  730. uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL);
  731. uea_info(INS_TO_USBDEV(sc), "modem operational\n");
  732. /* release the dsp firmware as it is not needed until
  733. * the next failure
  734. */
  735. if (sc->dsp_firm) {
  736. release_firmware(sc->dsp_firm);
  737. sc->dsp_firm = NULL;
  738. }
  739. ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
  740. if (ret < 0)
  741. return ret;
  742. uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
  743. sc->stats.phy.firmid);
  744. }
  745. /* always update it as atm layer could not be init when we switch to
  746. * operational state
  747. */
  748. UPDATE_ATM_STAT(signal, ATM_PHY_SIG_FOUND);
  749. /* wake up processes waiting for synchronization */
  750. wake_up(&sc->sync_q);
  751. ret = uea_read_cmv(sc, SA_DIAG, 2, &sc->stats.phy.flags);
  752. if (ret < 0)
  753. return ret;
  754. sc->stats.phy.mflags |= sc->stats.phy.flags;
  755. /* in case of a flags ( for example delineation LOSS (& 0x10)),
  756. * we check the status again in order to detect the failure earlier
  757. */
  758. if (sc->stats.phy.flags) {
  759. uea_dbg(INS_TO_USBDEV(sc), "Stat flag = %d\n",
  760. sc->stats.phy.flags);
  761. return 0;
  762. }
  763. ret = uea_read_cmv(sc, SA_RATE, 0, &data);
  764. if (ret < 0)
  765. return ret;
  766. /* in bulk mode the modem have problem with high rate
  767. * changing internal timing could improve things, but the
  768. * value is misterious.
  769. * ADI930 don't support it (-EPIPE error).
  770. */
  771. if (UEA_CHIP_VERSION(sc) != ADI930
  772. && sc->stats.phy.dsrate != (data >> 16) * 32) {
  773. /* Original timming from ADI(used in windows driver)
  774. * 0x20ffff>>16 * 32 = 32 * 32 = 1Mbits
  775. */
  776. u16 timeout = (data <= 0x20ffff) ? 0 : 1;
  777. ret = uea_request(sc, UEA_SET_TIMEOUT, timeout, 0, NULL);
  778. uea_info(INS_TO_USBDEV(sc),
  779. "setting new timeout %d%s\n", timeout,
  780. ret < 0?" failed":"");
  781. }
  782. sc->stats.phy.dsrate = (data >> 16) * 32;
  783. sc->stats.phy.usrate = (data & 0xffff) * 32;
  784. UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424);
  785. ret = uea_read_cmv(sc, SA_DIAG, 23, &data);
  786. if (ret < 0)
  787. return ret;
  788. sc->stats.phy.dsattenuation = (data & 0xff) / 2;
  789. ret = uea_read_cmv(sc, SA_DIAG, 47, &data);
  790. if (ret < 0)
  791. return ret;
  792. sc->stats.phy.usattenuation = (data & 0xff) / 2;
  793. ret = uea_read_cmv(sc, SA_DIAG, 25, &sc->stats.phy.dsmargin);
  794. if (ret < 0)
  795. return ret;
  796. ret = uea_read_cmv(sc, SA_DIAG, 49, &sc->stats.phy.usmargin);
  797. if (ret < 0)
  798. return ret;
  799. ret = uea_read_cmv(sc, SA_DIAG, 51, &sc->stats.phy.rxflow);
  800. if (ret < 0)
  801. return ret;
  802. ret = uea_read_cmv(sc, SA_DIAG, 52, &sc->stats.phy.txflow);
  803. if (ret < 0)
  804. return ret;
  805. ret = uea_read_cmv(sc, SA_DIAG, 54, &sc->stats.phy.dsunc);
  806. if (ret < 0)
  807. return ret;
  808. /* only for atu-c */
  809. ret = uea_read_cmv(sc, SA_DIAG, 58, &sc->stats.phy.usunc);
  810. if (ret < 0)
  811. return ret;
  812. ret = uea_read_cmv(sc, SA_DIAG, 53, &sc->stats.phy.dscorr);
  813. if (ret < 0)
  814. return ret;
  815. /* only for atu-c */
  816. ret = uea_read_cmv(sc, SA_DIAG, 57, &sc->stats.phy.uscorr);
  817. if (ret < 0)
  818. return ret;
  819. ret = uea_read_cmv(sc, SA_INFO, 8, &sc->stats.phy.vidco);
  820. if (ret < 0)
  821. return ret;
  822. ret = uea_read_cmv(sc, SA_INFO, 13, &sc->stats.phy.vidcpe);
  823. if (ret < 0)
  824. return ret;
  825. return 0;
  826. }
  827. static int request_cmvs(struct uea_softc *sc,
  828. struct uea_cmvs **cmvs, const struct firmware **fw)
  829. {
  830. int ret, size;
  831. u8 *data;
  832. char *file;
  833. static char cmv_name[256] = FW_DIR;
  834. if (cmv_file[sc->modem_index] == NULL) {
  835. if (UEA_CHIP_VERSION(sc) == ADI930)
  836. file = (IS_ISDN(sc)) ? "CMV9i.bin" : "CMV9p.bin";
  837. else
  838. file = (IS_ISDN(sc)) ? "CMVei.bin" : "CMVep.bin";
  839. } else
  840. file = cmv_file[sc->modem_index];
  841. strcpy(cmv_name, FW_DIR);
  842. strlcat(cmv_name, file, sizeof(cmv_name));
  843. ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev);
  844. if (ret < 0) {
  845. uea_err(INS_TO_USBDEV(sc),
  846. "requesting firmware %s failed with error %d\n",
  847. cmv_name, ret);
  848. return ret;
  849. }
  850. data = (u8 *) (*fw)->data;
  851. size = *data * sizeof(struct uea_cmvs) + 1;
  852. if (size != (*fw)->size) {
  853. uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
  854. cmv_name);
  855. release_firmware(*fw);
  856. return -EILSEQ;
  857. }
  858. *cmvs = (struct uea_cmvs *)(data + 1);
  859. return *data;
  860. }
  861. /* Start boot post firmware modem:
  862. * - send reset commands through usb control pipe
  863. * - start workqueue for DSP loading
  864. * - send CMV options to modem
  865. */
  866. static int uea_start_reset(struct uea_softc *sc)
  867. {
  868. u16 zero = 0; /* ;-) */
  869. int i, len, ret;
  870. struct uea_cmvs *cmvs;
  871. const struct firmware *cmvs_fw;
  872. uea_enters(INS_TO_USBDEV(sc));
  873. uea_info(INS_TO_USBDEV(sc), "(re)booting started\n");
  874. sc->booting = 1;
  875. UPDATE_ATM_STAT(signal, ATM_PHY_SIG_LOST);
  876. /* reset statistics */
  877. memset(&sc->stats, 0, sizeof(struct uea_stats));
  878. /* tell the modem that we want to boot in IDMA mode */
  879. uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL);
  880. uea_request(sc, UEA_SET_MODE, UEA_BOOT_IDMA, 0, NULL);
  881. /* enter reset mode */
  882. uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL);
  883. /* original driver use 200ms, but windows driver use 100ms */
  884. msleep(100);
  885. /* leave reset mode */
  886. uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL);
  887. /* clear tx and rx mailboxes */
  888. uea_request(sc, UEA_SET_2183_DATA, UEA_MPTX_MAILBOX, 2, &zero);
  889. uea_request(sc, UEA_SET_2183_DATA, UEA_MPRX_MAILBOX, 2, &zero);
  890. uea_request(sc, UEA_SET_2183_DATA, UEA_SWAP_MAILBOX, 2, &zero);
  891. msleep(1000);
  892. sc->cmv_function = MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY);
  893. sc->booting = 0;
  894. /* start loading DSP */
  895. sc->pageno = 0;
  896. sc->ovl = 0;
  897. schedule_work(&sc->task);
  898. /* wait for modem ready CMV */
  899. ret = wait_cmv_ack(sc);
  900. if (ret < 0)
  901. return ret;
  902. /* Enter in R-IDLE (cmv) until instructed otherwise */
  903. ret = uea_write_cmv(sc, SA_CNTL, 0, 1);
  904. if (ret < 0)
  905. return ret;
  906. /* get options */
  907. ret = len = request_cmvs(sc, &cmvs, &cmvs_fw);
  908. if (ret < 0)
  909. return ret;
  910. /* send options */
  911. for (i = 0; i < len; i++) {
  912. ret = uea_write_cmv(sc, FW_GET_LONG(&cmvs[i].address),
  913. FW_GET_WORD(&cmvs[i].offset),
  914. FW_GET_LONG(&cmvs[i].data));
  915. if (ret < 0)
  916. goto out;
  917. }
  918. /* Enter in R-ACT-REQ */
  919. ret = uea_write_cmv(sc, SA_CNTL, 0, 2);
  920. out:
  921. release_firmware(cmvs_fw);
  922. sc->reset = 0;
  923. uea_leaves(INS_TO_USBDEV(sc));
  924. return ret;
  925. }
  926. /*
  927. * In case of an error wait 1s before rebooting the modem
  928. * if the modem don't request reboot (-EAGAIN).
  929. * Monitor the modem every 1s.
  930. */
  931. static int uea_kthread(void *data)
  932. {
  933. struct uea_softc *sc = data;
  934. int ret = -EAGAIN;
  935. uea_enters(INS_TO_USBDEV(sc));
  936. while (!kthread_should_stop()) {
  937. if (ret < 0 || sc->reset)
  938. ret = uea_start_reset(sc);
  939. if (!ret)
  940. ret = uea_stat(sc);
  941. if (ret != -EAGAIN)
  942. msleep(1000);
  943. }
  944. uea_leaves(INS_TO_USBDEV(sc));
  945. return ret;
  946. }
  947. /* Load second usb firmware for ADI930 chip */
  948. static int load_XILINX_firmware(struct uea_softc *sc)
  949. {
  950. const struct firmware *fw_entry;
  951. int ret, size, u, ln;
  952. u8 *pfw, value;
  953. char *fw_name = FW_DIR "930-fpga.bin";
  954. uea_enters(INS_TO_USBDEV(sc));
  955. ret = request_firmware(&fw_entry, fw_name, &sc->usb_dev->dev);
  956. if (ret) {
  957. uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n",
  958. fw_name);
  959. goto err0;
  960. }
  961. pfw = fw_entry->data;
  962. size = fw_entry->size;
  963. if (size != 0x577B) {
  964. uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
  965. fw_name);
  966. ret = -EILSEQ;
  967. goto err1;
  968. }
  969. for (u = 0; u < size; u += ln) {
  970. ln = min(size - u, 64);
  971. ret = uea_request(sc, 0xe, 0, ln, pfw + u);
  972. if (ret < 0) {
  973. uea_err(INS_TO_USBDEV(sc),
  974. "elsa download data failed (%d)\n", ret);
  975. goto err1;
  976. }
  977. }
  978. /* finish to send the fpga
  979. */
  980. ret = uea_request(sc, 0xe, 1, 0, NULL);
  981. if (ret < 0) {
  982. uea_err(INS_TO_USBDEV(sc),
  983. "elsa download data failed (%d)\n", ret);
  984. goto err1;
  985. }
  986. /*
  987. * Tell the modem we finish : de-assert reset
  988. */
  989. value = 0;
  990. ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value);
  991. if (ret < 0)
  992. uea_err(sc->usb_dev, "elsa de-assert failed with error %d\n", ret);
  993. err1:
  994. release_firmware(fw_entry);
  995. err0:
  996. uea_leaves(INS_TO_USBDEV(sc));
  997. return ret;
  998. }
  999. static void uea_dispatch_cmv(struct uea_softc *sc, struct cmv* cmv)
  1000. {
  1001. uea_enters(INS_TO_USBDEV(sc));
  1002. if (le16_to_cpu(cmv->wPreamble) != PREAMBLE)
  1003. goto bad1;
  1004. if (cmv->bDirection != MODEMTOHOST)
  1005. goto bad1;
  1006. /* FIXME : ADI930 reply wrong preambule (func = 2, sub = 2) to
  1007. * the first MEMACESS cmv. Ignore it...
  1008. */
  1009. if (cmv->bFunction != sc->cmv_function) {
  1010. if (UEA_CHIP_VERSION(sc) == ADI930
  1011. && cmv->bFunction == MAKEFUNCTION(2, 2)) {
  1012. cmv->wIndex = cpu_to_le16(sc->cmv_idx);
  1013. put_unaligned(cpu_to_le32(sc->cmv_address), &cmv->dwSymbolicAddress);
  1014. cmv->wOffsetAddress = cpu_to_le16(sc->cmv_offset);
  1015. }
  1016. else
  1017. goto bad2;
  1018. }
  1019. if (cmv->bFunction == MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY)) {
  1020. wake_up_cmv_ack(sc);
  1021. return;
  1022. }
  1023. /* in case of MEMACCESS */
  1024. if (le16_to_cpu(cmv->wIndex) != sc->cmv_idx ||
  1025. le32_to_cpu(get_unaligned(&cmv->dwSymbolicAddress)) !=
  1026. sc->cmv_address
  1027. || le16_to_cpu(cmv->wOffsetAddress) != sc->cmv_offset)
  1028. goto bad2;
  1029. sc->data = le32_to_cpu(get_unaligned(&cmv->dwData));
  1030. sc->data = sc->data << 16 | sc->data >> 16;
  1031. wake_up_cmv_ack(sc);
  1032. return;
  1033. bad2:
  1034. uea_err(INS_TO_USBDEV(sc), "unexpected cmv received,"
  1035. "Function : %d, Subfunction : %d\n",
  1036. FUNCTION_TYPE(cmv->bFunction),
  1037. FUNCTION_SUBTYPE(cmv->bFunction));
  1038. return;
  1039. bad1:
  1040. uea_err(INS_TO_USBDEV(sc), "invalid cmv received, "
  1041. "wPreamble %d, bDirection %d\n",
  1042. le16_to_cpu(cmv->wPreamble), cmv->bDirection);
  1043. }
  1044. /*
  1045. * interrupt handler
  1046. */
  1047. static void uea_intr(struct urb *urb, struct pt_regs *regs)
  1048. {
  1049. struct uea_softc *sc = (struct uea_softc *)urb->context;
  1050. struct intr_pkt *intr;
  1051. uea_enters(INS_TO_USBDEV(sc));
  1052. if (urb->status < 0) {
  1053. uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n",
  1054. urb->status);
  1055. return;
  1056. }
  1057. intr = (struct intr_pkt *) urb->transfer_buffer;
  1058. /* device-to-host interrupt */
  1059. if (intr->bType != 0x08 || sc->booting) {
  1060. uea_err(INS_TO_USBDEV(sc), "wrong intr\n");
  1061. // rebooting ?
  1062. // sc->reset = 1;
  1063. goto resubmit;
  1064. }
  1065. switch (le16_to_cpu(intr->wInterrupt)) {
  1066. case INT_LOADSWAPPAGE:
  1067. sc->pageno = intr->bSwapPageNo;
  1068. sc->ovl = intr->bOvl >> 4 | intr->bOvl << 4;
  1069. schedule_work(&sc->task);
  1070. break;
  1071. case INT_INCOMINGCMV:
  1072. uea_dispatch_cmv(sc, &intr->u.s2.cmv);
  1073. break;
  1074. default:
  1075. uea_err(INS_TO_USBDEV(sc), "unknown intr %u\n",
  1076. le16_to_cpu(intr->wInterrupt));
  1077. }
  1078. resubmit:
  1079. usb_submit_urb(sc->urb_int, GFP_ATOMIC);
  1080. }
  1081. /*
  1082. * Start the modem : init the data and start kernel thread
  1083. */
  1084. static int uea_boot(struct uea_softc *sc)
  1085. {
  1086. int ret;
  1087. struct intr_pkt *intr;
  1088. uea_enters(INS_TO_USBDEV(sc));
  1089. INIT_WORK(&sc->task, uea_load_page, sc);
  1090. init_waitqueue_head(&sc->sync_q);
  1091. init_waitqueue_head(&sc->cmv_ack_wait);
  1092. if (UEA_CHIP_VERSION(sc) == ADI930)
  1093. load_XILINX_firmware(sc);
  1094. intr = kmalloc(INTR_PKT_SIZE, GFP_KERNEL);
  1095. if (!intr) {
  1096. uea_err(INS_TO_USBDEV(sc),
  1097. "cannot allocate interrupt package\n");
  1098. uea_leaves(INS_TO_USBDEV(sc));
  1099. return -ENOMEM;
  1100. }
  1101. sc->urb_int = usb_alloc_urb(0, GFP_KERNEL);
  1102. if (!sc->urb_int) {
  1103. uea_err(INS_TO_USBDEV(sc), "cannot allocate interrupt URB\n");
  1104. goto err;
  1105. }
  1106. usb_fill_int_urb(sc->urb_int, sc->usb_dev,
  1107. usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE),
  1108. intr, INTR_PKT_SIZE, uea_intr, sc,
  1109. sc->usb_dev->actconfig->interface[0]->altsetting[0].
  1110. endpoint[0].desc.bInterval);
  1111. ret = usb_submit_urb(sc->urb_int, GFP_KERNEL);
  1112. if (ret < 0) {
  1113. uea_err(INS_TO_USBDEV(sc),
  1114. "urb submition failed with error %d\n", ret);
  1115. goto err1;
  1116. }
  1117. sc->kthread = kthread_run(uea_kthread, sc, "ueagle-atm");
  1118. if (sc->kthread == ERR_PTR(-ENOMEM)) {
  1119. uea_err(INS_TO_USBDEV(sc), "failed to create thread\n");
  1120. goto err2;
  1121. }
  1122. uea_leaves(INS_TO_USBDEV(sc));
  1123. return 0;
  1124. err2:
  1125. usb_kill_urb(sc->urb_int);
  1126. err1:
  1127. kfree(intr);
  1128. err:
  1129. usb_free_urb(sc->urb_int);
  1130. uea_leaves(INS_TO_USBDEV(sc));
  1131. return -ENOMEM;
  1132. }
  1133. /*
  1134. * Stop the modem : kill kernel thread and free data
  1135. */
  1136. static void uea_stop(struct uea_softc *sc)
  1137. {
  1138. int ret;
  1139. uea_enters(INS_TO_USBDEV(sc));
  1140. ret = kthread_stop(sc->kthread);
  1141. uea_info(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret);
  1142. /* stop any pending boot process */
  1143. flush_scheduled_work();
  1144. uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL);
  1145. usb_kill_urb(sc->urb_int);
  1146. kfree(sc->urb_int->transfer_buffer);
  1147. usb_free_urb(sc->urb_int);
  1148. if (sc->dsp_firm)
  1149. release_firmware(sc->dsp_firm);
  1150. uea_leaves(INS_TO_USBDEV(sc));
  1151. }
  1152. /* syfs interface */
  1153. static struct uea_softc *dev_to_uea(struct device *dev)
  1154. {
  1155. struct usb_interface *intf;
  1156. struct usbatm_data *usbatm;
  1157. intf = to_usb_interface(dev);
  1158. if (!intf)
  1159. return NULL;
  1160. usbatm = usb_get_intfdata(intf);
  1161. if (!usbatm)
  1162. return NULL;
  1163. return usbatm->driver_data;
  1164. }
  1165. static ssize_t read_status(struct device *dev, struct device_attribute *attr,
  1166. char *buf)
  1167. {
  1168. int ret = -ENODEV;
  1169. struct uea_softc *sc;
  1170. down(&uea_semaphore);
  1171. sc = dev_to_uea(dev);
  1172. if (!sc)
  1173. goto out;
  1174. ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state);
  1175. out:
  1176. up(&uea_semaphore);
  1177. return ret;
  1178. }
  1179. static ssize_t reboot(struct device *dev, struct device_attribute *attr,
  1180. const char *buf, size_t count)
  1181. {
  1182. int ret = -ENODEV;
  1183. struct uea_softc *sc;
  1184. down(&uea_semaphore);
  1185. sc = dev_to_uea(dev);
  1186. if (!sc)
  1187. goto out;
  1188. sc->reset = 1;
  1189. ret = count;
  1190. out:
  1191. up(&uea_semaphore);
  1192. return ret;
  1193. }
  1194. static DEVICE_ATTR(stat_status, S_IWUGO | S_IRUGO, read_status, reboot);
  1195. static ssize_t read_human_status(struct device *dev, struct device_attribute *attr,
  1196. char *buf)
  1197. {
  1198. int ret = -ENODEV;
  1199. struct uea_softc *sc;
  1200. down(&uea_semaphore);
  1201. sc = dev_to_uea(dev);
  1202. if (!sc)
  1203. goto out;
  1204. switch (GET_STATUS(sc->stats.phy.state)) {
  1205. case 0:
  1206. ret = sprintf(buf, "Modem is booting\n");
  1207. break;
  1208. case 1:
  1209. ret = sprintf(buf, "Modem is initializing\n");
  1210. break;
  1211. case 2:
  1212. ret = sprintf(buf, "Modem is operational\n");
  1213. break;
  1214. default:
  1215. ret = sprintf(buf, "Modem synchronization failed\n");
  1216. break;
  1217. }
  1218. out:
  1219. up(&uea_semaphore);
  1220. return ret;
  1221. }
  1222. static DEVICE_ATTR(stat_human_status, S_IWUGO | S_IRUGO, read_human_status, NULL);
  1223. static ssize_t read_delin(struct device *dev, struct device_attribute *attr,
  1224. char *buf)
  1225. {
  1226. int ret = -ENODEV;
  1227. struct uea_softc *sc;
  1228. down(&uea_semaphore);
  1229. sc = dev_to_uea(dev);
  1230. if (!sc)
  1231. goto out;
  1232. if (sc->stats.phy.flags & 0x0C00)
  1233. ret = sprintf(buf, "ERROR\n");
  1234. else if (sc->stats.phy.flags & 0x0030)
  1235. ret = sprintf(buf, "LOSS\n");
  1236. else
  1237. ret = sprintf(buf, "GOOD\n");
  1238. out:
  1239. up(&uea_semaphore);
  1240. return ret;
  1241. }
  1242. static DEVICE_ATTR(stat_delin, S_IWUGO | S_IRUGO, read_delin, NULL);
  1243. #define UEA_ATTR(name, reset) \
  1244. \
  1245. static ssize_t read_##name(struct device *dev, \
  1246. struct device_attribute *attr, char *buf) \
  1247. { \
  1248. int ret = -ENODEV; \
  1249. struct uea_softc *sc; \
  1250. \
  1251. down(&uea_semaphore); \
  1252. sc = dev_to_uea(dev); \
  1253. if (!sc) \
  1254. goto out; \
  1255. ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \
  1256. if (reset) \
  1257. sc->stats.phy.name = 0; \
  1258. out: \
  1259. up(&uea_semaphore); \
  1260. return ret; \
  1261. } \
  1262. \
  1263. static DEVICE_ATTR(stat_##name, S_IRUGO, read_##name, NULL)
  1264. UEA_ATTR(mflags, 1);
  1265. UEA_ATTR(vidcpe, 0);
  1266. UEA_ATTR(usrate, 0);
  1267. UEA_ATTR(dsrate, 0);
  1268. UEA_ATTR(usattenuation, 0);
  1269. UEA_ATTR(dsattenuation, 0);
  1270. UEA_ATTR(usmargin, 0);
  1271. UEA_ATTR(dsmargin, 0);
  1272. UEA_ATTR(txflow, 0);
  1273. UEA_ATTR(rxflow, 0);
  1274. UEA_ATTR(uscorr, 0);
  1275. UEA_ATTR(dscorr, 0);
  1276. UEA_ATTR(usunc, 0);
  1277. UEA_ATTR(dsunc, 0);
  1278. /* Retrieve the device End System Identifier (MAC) */
  1279. #define htoi(x) (isdigit(x) ? x-'0' : toupper(x)-'A'+10)
  1280. static int uea_getesi(struct uea_softc *sc, u_char * esi)
  1281. {
  1282. unsigned char mac_str[2 * ETH_ALEN + 1];
  1283. int i;
  1284. if (usb_string
  1285. (sc->usb_dev, sc->usb_dev->descriptor.iSerialNumber, mac_str,
  1286. sizeof(mac_str)) != 2 * ETH_ALEN)
  1287. return 1;
  1288. for (i = 0; i < ETH_ALEN; i++)
  1289. esi[i] = htoi(mac_str[2 * i]) * 16 + htoi(mac_str[2 * i + 1]);
  1290. return 0;
  1291. }
  1292. /* ATM stuff */
  1293. static int uea_atm_open(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
  1294. {
  1295. struct uea_softc *sc = usbatm->driver_data;
  1296. return uea_getesi(sc, atm_dev->esi);
  1297. }
  1298. static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf)
  1299. {
  1300. struct uea_softc *sc = usbatm->driver_data;
  1301. wait_event(sc->sync_q, IS_OPERATIONAL(sc));
  1302. return 0;
  1303. }
  1304. static int claim_interface(struct usb_device *usb_dev,
  1305. struct usbatm_data *usbatm, int ifnum)
  1306. {
  1307. int ret;
  1308. struct usb_interface *intf = usb_ifnum_to_if(usb_dev, ifnum);
  1309. if (!intf) {
  1310. uea_err(usb_dev, "interface %d not found\n", ifnum);
  1311. return -ENODEV;
  1312. }
  1313. ret = usb_driver_claim_interface(&uea_driver, intf, usbatm);
  1314. if (ret != 0)
  1315. uea_err(usb_dev, "can't claim interface %d, error %d\n", ifnum,
  1316. ret);
  1317. return ret;
  1318. }
  1319. static void create_fs_entries(struct uea_softc *sc, struct usb_interface *intf)
  1320. {
  1321. /* sysfs interface */
  1322. device_create_file(&intf->dev, &dev_attr_stat_status);
  1323. device_create_file(&intf->dev, &dev_attr_stat_mflags);
  1324. device_create_file(&intf->dev, &dev_attr_stat_human_status);
  1325. device_create_file(&intf->dev, &dev_attr_stat_delin);
  1326. device_create_file(&intf->dev, &dev_attr_stat_vidcpe);
  1327. device_create_file(&intf->dev, &dev_attr_stat_usrate);
  1328. device_create_file(&intf->dev, &dev_attr_stat_dsrate);
  1329. device_create_file(&intf->dev, &dev_attr_stat_usattenuation);
  1330. device_create_file(&intf->dev, &dev_attr_stat_dsattenuation);
  1331. device_create_file(&intf->dev, &dev_attr_stat_usmargin);
  1332. device_create_file(&intf->dev, &dev_attr_stat_dsmargin);
  1333. device_create_file(&intf->dev, &dev_attr_stat_txflow);
  1334. device_create_file(&intf->dev, &dev_attr_stat_rxflow);
  1335. device_create_file(&intf->dev, &dev_attr_stat_uscorr);
  1336. device_create_file(&intf->dev, &dev_attr_stat_dscorr);
  1337. device_create_file(&intf->dev, &dev_attr_stat_usunc);
  1338. device_create_file(&intf->dev, &dev_attr_stat_dsunc);
  1339. }
  1340. static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
  1341. const struct usb_device_id *id, int *heavy)
  1342. {
  1343. struct usb_device *usb = interface_to_usbdev(intf);
  1344. struct uea_softc *sc;
  1345. int ret, ifnum = intf->altsetting->desc.bInterfaceNumber;
  1346. uea_enters(usb);
  1347. /* interface 0 is for firmware/monitoring */
  1348. if (ifnum != UEA_INTR_IFACE_NO)
  1349. return -ENODEV;
  1350. *heavy = sync_wait[modem_index];
  1351. /* interface 1 is for outbound traffic */
  1352. ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO);
  1353. if (ret < 0)
  1354. return ret;
  1355. /* ADI930 has only 2 interfaces and inbound traffic
  1356. * is on interface 1
  1357. */
  1358. if (UEA_CHIP_VERSION(id) != ADI930) {
  1359. /* interface 2 is for inbound traffic */
  1360. ret = claim_interface(usb, usbatm, UEA_DS_IFACE_NO);
  1361. if (ret < 0)
  1362. return ret;
  1363. }
  1364. sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL);
  1365. if (!sc) {
  1366. uea_err(INS_TO_USBDEV(sc), "uea_init: not enough memory !\n");
  1367. return -ENOMEM;
  1368. }
  1369. sc->usb_dev = usb;
  1370. usbatm->driver_data = sc;
  1371. sc->usbatm = usbatm;
  1372. sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0;
  1373. sc->driver_info = id->driver_info;
  1374. ret = uea_boot(sc);
  1375. if (ret < 0) {
  1376. kfree(sc);
  1377. return ret;
  1378. }
  1379. create_fs_entries(sc, intf);
  1380. return 0;
  1381. }
  1382. static void destroy_fs_entries(struct uea_softc *sc, struct usb_interface *intf)
  1383. {
  1384. /* sysfs interface */
  1385. device_remove_file(&intf->dev, &dev_attr_stat_status);
  1386. device_remove_file(&intf->dev, &dev_attr_stat_mflags);
  1387. device_remove_file(&intf->dev, &dev_attr_stat_human_status);
  1388. device_remove_file(&intf->dev, &dev_attr_stat_delin);
  1389. device_remove_file(&intf->dev, &dev_attr_stat_vidcpe);
  1390. device_remove_file(&intf->dev, &dev_attr_stat_usrate);
  1391. device_remove_file(&intf->dev, &dev_attr_stat_dsrate);
  1392. device_remove_file(&intf->dev, &dev_attr_stat_usattenuation);
  1393. device_remove_file(&intf->dev, &dev_attr_stat_dsattenuation);
  1394. device_remove_file(&intf->dev, &dev_attr_stat_usmargin);
  1395. device_remove_file(&intf->dev, &dev_attr_stat_dsmargin);
  1396. device_remove_file(&intf->dev, &dev_attr_stat_txflow);
  1397. device_remove_file(&intf->dev, &dev_attr_stat_rxflow);
  1398. device_remove_file(&intf->dev, &dev_attr_stat_uscorr);
  1399. device_remove_file(&intf->dev, &dev_attr_stat_dscorr);
  1400. device_remove_file(&intf->dev, &dev_attr_stat_usunc);
  1401. device_remove_file(&intf->dev, &dev_attr_stat_dsunc);
  1402. }
  1403. static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
  1404. {
  1405. struct uea_softc *sc = usbatm->driver_data;
  1406. destroy_fs_entries(sc, intf);
  1407. uea_stop(sc);
  1408. kfree(sc);
  1409. }
  1410. static struct usbatm_driver uea_usbatm_driver = {
  1411. .driver_name = "ueagle-atm",
  1412. .owner = THIS_MODULE,
  1413. .bind = uea_bind,
  1414. .atm_start = uea_atm_open,
  1415. .unbind = uea_unbind,
  1416. .heavy_init = uea_heavy,
  1417. .in = UEA_BULK_DATA_PIPE,
  1418. .out = UEA_BULK_DATA_PIPE,
  1419. };
  1420. static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
  1421. {
  1422. struct usb_device *usb = interface_to_usbdev(intf);
  1423. uea_enters(usb);
  1424. uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s\n",
  1425. le16_to_cpu(usb->descriptor.idVendor),
  1426. le16_to_cpu(usb->descriptor.idProduct),
  1427. chip_name[UEA_CHIP_VERSION(id)]);
  1428. usb_reset_device(usb);
  1429. if (UEA_IS_PREFIRM(id))
  1430. return uea_load_firmware(usb, UEA_CHIP_VERSION(id));
  1431. return usbatm_usb_probe(intf, id, &uea_usbatm_driver);
  1432. }
  1433. static void uea_disconnect(struct usb_interface *intf)
  1434. {
  1435. struct usb_device *usb = interface_to_usbdev(intf);
  1436. int ifnum = intf->altsetting->desc.bInterfaceNumber;
  1437. uea_enters(usb);
  1438. /* ADI930 has 2 interfaces and eagle 3 interfaces.
  1439. * Pre-firmware device has one interface
  1440. */
  1441. if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
  1442. down(&uea_semaphore);
  1443. usbatm_usb_disconnect(intf);
  1444. up(&uea_semaphore);
  1445. uea_info(usb, "ADSL device removed\n");
  1446. }
  1447. uea_leaves(usb);
  1448. }
  1449. /*
  1450. * List of supported VID/PID
  1451. */
  1452. static const struct usb_device_id uea_ids[] = {
  1453. {USB_DEVICE(ELSA_VID, ELSA_PID_PREFIRM), .driver_info = ADI930 | PREFIRM},
  1454. {USB_DEVICE(ELSA_VID, ELSA_PID_PSTFIRM), .driver_info = ADI930 | PSTFIRM},
  1455. {USB_DEVICE(EAGLE_VID, EAGLE_I_PID_PREFIRM), .driver_info = EAGLE_I | PREFIRM},
  1456. {USB_DEVICE(EAGLE_VID, EAGLE_I_PID_PSTFIRM), .driver_info = EAGLE_I | PSTFIRM},
  1457. {USB_DEVICE(EAGLE_VID, EAGLE_II_PID_PREFIRM), .driver_info = EAGLE_II | PREFIRM},
  1458. {USB_DEVICE(EAGLE_VID, EAGLE_II_PID_PSTFIRM), .driver_info = EAGLE_II | PSTFIRM},
  1459. {USB_DEVICE(EAGLE_VID, EAGLE_IIC_PID_PREFIRM), .driver_info = EAGLE_II | PREFIRM},
  1460. {USB_DEVICE(EAGLE_VID, EAGLE_IIC_PID_PSTFIRM), .driver_info = EAGLE_II | PSTFIRM},
  1461. {USB_DEVICE(EAGLE_VID, EAGLE_III_PID_PREFIRM), .driver_info = EAGLE_III | PREFIRM},
  1462. {USB_DEVICE(EAGLE_VID, EAGLE_III_PID_PSTFIRM), .driver_info = EAGLE_III | PSTFIRM},
  1463. {USB_DEVICE(USR_VID, MILLER_A_PID_PREFIRM), .driver_info = EAGLE_I | PREFIRM},
  1464. {USB_DEVICE(USR_VID, MILLER_A_PID_PSTFIRM), .driver_info = EAGLE_I | PSTFIRM},
  1465. {USB_DEVICE(USR_VID, MILLER_B_PID_PREFIRM), .driver_info = EAGLE_I | PREFIRM},
  1466. {USB_DEVICE(USR_VID, MILLER_B_PID_PSTFIRM), .driver_info = EAGLE_I | PSTFIRM},
  1467. {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PREFIRM),.driver_info = EAGLE_I | PREFIRM},
  1468. {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PSTFIRM),.driver_info = EAGLE_I | PSTFIRM},
  1469. {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PREFIRM),.driver_info = EAGLE_I | PREFIRM},
  1470. {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PSTFIRM),.driver_info = EAGLE_I | PSTFIRM},
  1471. {}
  1472. };
  1473. /*
  1474. * USB driver descriptor
  1475. */
  1476. static struct usb_driver uea_driver = {
  1477. .owner = THIS_MODULE,
  1478. .name = "ueagle-atm",
  1479. .id_table = uea_ids,
  1480. .probe = uea_probe,
  1481. .disconnect = uea_disconnect,
  1482. };
  1483. MODULE_DEVICE_TABLE(usb, uea_ids);
  1484. /**
  1485. * uea_init - Initialize the module.
  1486. * Register to USB subsystem
  1487. */
  1488. static int __init uea_init(void)
  1489. {
  1490. printk(KERN_INFO "[ueagle-atm] driver " EAGLEUSBVERSION " loaded\n");
  1491. usb_register(&uea_driver);
  1492. return 0;
  1493. }
  1494. module_init(uea_init);
  1495. /**
  1496. * uea_exit - Destroy module
  1497. * Deregister with USB subsystem
  1498. */
  1499. static void __exit uea_exit(void)
  1500. {
  1501. /*
  1502. * This calls automatically the uea_disconnect method if necessary:
  1503. */
  1504. usb_deregister(&uea_driver);
  1505. printk(KERN_INFO "[ueagle-atm] driver unloaded\n");
  1506. }
  1507. module_exit(uea_exit);
  1508. MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka");
  1509. MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver");
  1510. MODULE_LICENSE("Dual BSD/GPL");