ueagle-atm.c 44 KB

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