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 <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. if (size < 4)
  367. goto err_fw_corrupted;
  368. crc = FW_GET_LONG(pfw);
  369. pfw += 4;
  370. size -= 4;
  371. if (crc32_be(0, pfw, size) != crc)
  372. goto err_fw_corrupted;
  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 > 3) {
  383. u8 len = FW_GET_BYTE(pfw);
  384. u16 add = FW_GET_WORD(pfw + 1);
  385. size -= len + 3;
  386. if (size < 0)
  387. goto err_fw_corrupted;
  388. ret = uea_send_modem_cmd(usb, add, len, pfw + 3);
  389. if (ret < 0) {
  390. uea_err(usb, "uploading firmware data failed "
  391. "with error %d\n", ret);
  392. goto err;
  393. }
  394. pfw += len + 3;
  395. }
  396. if (size != 0)
  397. goto err_fw_corrupted;
  398. /*
  399. * Tell the modem we finish : de-assert reset
  400. */
  401. value = 0;
  402. ret = uea_send_modem_cmd(usb, F8051_USBCS, 1, &value);
  403. if (ret < 0)
  404. uea_err(usb, "modem de-assert failed with error %d\n", ret);
  405. else
  406. uea_info(usb, "firmware uploaded\n");
  407. uea_leaves(usb);
  408. return;
  409. err_fw_corrupted:
  410. uea_err(usb, "firmware is corrupted\n");
  411. err:
  412. uea_leaves(usb);
  413. }
  414. /**
  415. * uea_load_firmware - Load usb firmware for pre-firmware devices.
  416. */
  417. static int uea_load_firmware(struct usb_device *usb, unsigned int ver)
  418. {
  419. int ret;
  420. char *fw_name = FW_DIR "eagle.fw";
  421. uea_enters(usb);
  422. uea_info(usb, "pre-firmware device, uploading firmware\n");
  423. switch (ver) {
  424. case ADI930:
  425. fw_name = FW_DIR "adi930.fw";
  426. break;
  427. case EAGLE_I:
  428. fw_name = FW_DIR "eagleI.fw";
  429. break;
  430. case EAGLE_II:
  431. fw_name = FW_DIR "eagleII.fw";
  432. break;
  433. case EAGLE_III:
  434. fw_name = FW_DIR "eagleIII.fw";
  435. break;
  436. }
  437. ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev, usb, uea_upload_pre_firmware);
  438. if (ret)
  439. uea_err(usb, "firmware %s is not available\n", fw_name);
  440. else
  441. uea_info(usb, "loading firmware %s\n", fw_name);
  442. uea_leaves(usb);
  443. return ret;
  444. }
  445. /* modem management : dsp firmware, send/read CMV, monitoring statistic
  446. */
  447. /*
  448. * Make sure that the DSP code provided is safe to use.
  449. */
  450. static int check_dsp(u8 *dsp, unsigned int len)
  451. {
  452. u8 pagecount, blockcount;
  453. u16 blocksize;
  454. u32 pageoffset;
  455. unsigned int i, j, p, pp;
  456. pagecount = FW_GET_BYTE(dsp);
  457. p = 1;
  458. /* enough space for page offsets? */
  459. if (p + 4 * pagecount > len)
  460. return 1;
  461. for (i = 0; i < pagecount; i++) {
  462. pageoffset = FW_GET_LONG(dsp + p);
  463. p += 4;
  464. if (pageoffset == 0)
  465. continue;
  466. /* enough space for blockcount? */
  467. if (pageoffset >= len)
  468. return 1;
  469. pp = pageoffset;
  470. blockcount = FW_GET_BYTE(dsp + pp);
  471. pp += 1;
  472. for (j = 0; j < blockcount; j++) {
  473. /* enough space for block header? */
  474. if (pp + 4 > len)
  475. return 1;
  476. pp += 2; /* skip blockaddr */
  477. blocksize = FW_GET_WORD(dsp + pp);
  478. pp += 2;
  479. /* enough space for block data? */
  480. if (pp + blocksize > len)
  481. return 1;
  482. pp += blocksize;
  483. }
  484. }
  485. return 0;
  486. }
  487. /*
  488. * send data to the idma pipe
  489. * */
  490. static int uea_idma_write(struct uea_softc *sc, void *data, u32 size)
  491. {
  492. int ret = -ENOMEM;
  493. u8 *xfer_buff;
  494. int bytes_read;
  495. xfer_buff = kmalloc(size, GFP_KERNEL);
  496. if (!xfer_buff) {
  497. uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
  498. return ret;
  499. }
  500. memcpy(xfer_buff, data, size);
  501. ret = usb_bulk_msg(sc->usb_dev,
  502. usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE),
  503. xfer_buff, size, &bytes_read, BULK_TIMEOUT);
  504. kfree(xfer_buff);
  505. if (ret < 0)
  506. return ret;
  507. if (size != bytes_read) {
  508. uea_err(INS_TO_USBDEV(sc), "size != bytes_read %d %d\n", size,
  509. bytes_read);
  510. return -EIO;
  511. }
  512. return 0;
  513. }
  514. static int request_dsp(struct uea_softc *sc)
  515. {
  516. int ret;
  517. char *dsp_name;
  518. if (UEA_CHIP_VERSION(sc) == ADI930) {
  519. if (IS_ISDN(sc))
  520. dsp_name = FW_DIR "DSP9i.bin";
  521. else
  522. dsp_name = FW_DIR "DSP9p.bin";
  523. } else {
  524. if (IS_ISDN(sc))
  525. dsp_name = FW_DIR "DSPei.bin";
  526. else
  527. dsp_name = FW_DIR "DSPep.bin";
  528. }
  529. ret = request_firmware(&sc->dsp_firm,
  530. dsp_name, &sc->usb_dev->dev);
  531. if (ret < 0) {
  532. uea_err(INS_TO_USBDEV(sc),
  533. "requesting firmware %s failed with error %d\n",
  534. dsp_name, ret);
  535. return ret;
  536. }
  537. if (check_dsp(sc->dsp_firm->data, sc->dsp_firm->size)) {
  538. uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
  539. dsp_name);
  540. release_firmware(sc->dsp_firm);
  541. sc->dsp_firm = NULL;
  542. return -EILSEQ;
  543. }
  544. return 0;
  545. }
  546. /*
  547. * The uea_load_page() function must be called within a process context
  548. */
  549. static void uea_load_page(void *xsc)
  550. {
  551. struct uea_softc *sc = xsc;
  552. u16 pageno = sc->pageno;
  553. u16 ovl = sc->ovl;
  554. struct block_info bi;
  555. u8 *p;
  556. u8 pagecount, blockcount;
  557. u16 blockaddr, blocksize;
  558. u32 pageoffset;
  559. int i;
  560. /* reload firmware when reboot start and it's loaded already */
  561. if (ovl == 0 && pageno == 0 && sc->dsp_firm) {
  562. release_firmware(sc->dsp_firm);
  563. sc->dsp_firm = NULL;
  564. }
  565. if (sc->dsp_firm == NULL && request_dsp(sc) < 0)
  566. return;
  567. p = sc->dsp_firm->data;
  568. pagecount = FW_GET_BYTE(p);
  569. p += 1;
  570. if (pageno >= pagecount)
  571. goto bad1;
  572. p += 4 * pageno;
  573. pageoffset = FW_GET_LONG(p);
  574. if (pageoffset == 0)
  575. goto bad1;
  576. p = sc->dsp_firm->data + pageoffset;
  577. blockcount = FW_GET_BYTE(p);
  578. p += 1;
  579. uea_dbg(INS_TO_USBDEV(sc),
  580. "sending %u blocks for DSP page %u\n", blockcount, pageno);
  581. bi.wHdr = cpu_to_le16(UEA_BIHDR);
  582. bi.wOvl = cpu_to_le16(ovl);
  583. bi.wOvlOffset = cpu_to_le16(ovl | 0x8000);
  584. for (i = 0; i < blockcount; i++) {
  585. blockaddr = FW_GET_WORD(p);
  586. p += 2;
  587. blocksize = FW_GET_WORD(p);
  588. p += 2;
  589. bi.wSize = cpu_to_le16(blocksize);
  590. bi.wAddress = cpu_to_le16(blockaddr);
  591. bi.wLast = cpu_to_le16((i == blockcount - 1) ? 1 : 0);
  592. /* send block info through the IDMA pipe */
  593. if (uea_idma_write(sc, &bi, BLOCK_INFO_SIZE))
  594. goto bad2;
  595. /* send block data through the IDMA pipe */
  596. if (uea_idma_write(sc, p, blocksize))
  597. goto bad2;
  598. p += blocksize;
  599. }
  600. return;
  601. bad2:
  602. uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", i);
  603. return;
  604. bad1:
  605. uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n",pageno);
  606. }
  607. static inline void wake_up_cmv_ack(struct uea_softc *sc)
  608. {
  609. sc->cmv_ack = 1;
  610. wake_up(&sc->cmv_ack_wait);
  611. }
  612. static inline int wait_cmv_ack(struct uea_softc *sc)
  613. {
  614. int ret = wait_event_timeout(sc->cmv_ack_wait,
  615. sc->cmv_ack, ACK_TIMEOUT);
  616. sc->cmv_ack = 0;
  617. if (ret < 0)
  618. return ret;
  619. return (ret == 0) ? -ETIMEDOUT : 0;
  620. }
  621. #define UCDC_SEND_ENCAPSULATED_COMMAND 0x00
  622. static int uea_request(struct uea_softc *sc,
  623. u16 value, u16 index, u16 size, void *data)
  624. {
  625. u8 *xfer_buff;
  626. int ret = -ENOMEM;
  627. xfer_buff = kmalloc(size, GFP_KERNEL);
  628. if (!xfer_buff) {
  629. uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
  630. return ret;
  631. }
  632. memcpy(xfer_buff, data, size);
  633. ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0),
  634. UCDC_SEND_ENCAPSULATED_COMMAND,
  635. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  636. value, index, xfer_buff, size, CTRL_TIMEOUT);
  637. kfree(xfer_buff);
  638. if (ret < 0) {
  639. uea_err(INS_TO_USBDEV(sc), "usb_control_msg error %d\n", ret);
  640. return ret;
  641. }
  642. if (ret != size) {
  643. uea_err(INS_TO_USBDEV(sc),
  644. "usb_control_msg send only %d bytes (instead of %d)\n",
  645. ret, size);
  646. return -EIO;
  647. }
  648. return 0;
  649. }
  650. static int uea_cmv(struct uea_softc *sc,
  651. u8 function, u32 address, u16 offset, u32 data)
  652. {
  653. struct cmv cmv;
  654. int ret;
  655. /* we send a request, but we expect a reply */
  656. sc->cmv_function = function | 0x2;
  657. sc->cmv_idx++;
  658. sc->cmv_address = address;
  659. sc->cmv_offset = offset;
  660. cmv.wPreamble = cpu_to_le16(PREAMBLE);
  661. cmv.bDirection = HOSTTOMODEM;
  662. cmv.bFunction = function;
  663. cmv.wIndex = cpu_to_le16(sc->cmv_idx);
  664. put_unaligned(cpu_to_le32(address), &cmv.dwSymbolicAddress);
  665. cmv.wOffsetAddress = cpu_to_le16(offset);
  666. put_unaligned(cpu_to_le32(data >> 16 | data << 16), &cmv.dwData);
  667. ret = uea_request(sc, UEA_SET_BLOCK, UEA_MPTX_START, CMV_SIZE, &cmv);
  668. if (ret < 0)
  669. return ret;
  670. return wait_cmv_ack(sc);
  671. }
  672. static inline int uea_read_cmv(struct uea_softc *sc,
  673. u32 address, u16 offset, u32 *data)
  674. {
  675. int ret = uea_cmv(sc, MAKEFUNCTION(MEMACCESS, REQUESTREAD),
  676. address, offset, 0);
  677. if (ret < 0)
  678. uea_err(INS_TO_USBDEV(sc),
  679. "reading cmv failed with error %d\n", ret);
  680. else
  681. *data = sc->data;
  682. return ret;
  683. }
  684. static inline int uea_write_cmv(struct uea_softc *sc,
  685. u32 address, u16 offset, u32 data)
  686. {
  687. int ret = uea_cmv(sc, MAKEFUNCTION(MEMACCESS, REQUESTWRITE),
  688. address, offset, data);
  689. if (ret < 0)
  690. uea_err(INS_TO_USBDEV(sc),
  691. "writing cmv failed with error %d\n", ret);
  692. return ret;
  693. }
  694. /*
  695. * Monitor the modem and update the stat
  696. * return 0 if everything is ok
  697. * return < 0 if an error occurs (-EAGAIN reboot needed)
  698. */
  699. static int uea_stat(struct uea_softc *sc)
  700. {
  701. u32 data;
  702. int ret;
  703. uea_enters(INS_TO_USBDEV(sc));
  704. data = sc->stats.phy.state;
  705. ret = uea_read_cmv(sc, SA_STAT, 0, &sc->stats.phy.state);
  706. if (ret < 0)
  707. return ret;
  708. switch (GET_STATUS(sc->stats.phy.state)) {
  709. case 0: /* not yet synchronized */
  710. uea_dbg(INS_TO_USBDEV(sc),
  711. "modem not yet synchronized\n");
  712. return 0;
  713. case 1: /* initialization */
  714. uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n");
  715. return 0;
  716. case 2: /* operational */
  717. uea_vdbg(INS_TO_USBDEV(sc), "modem operational\n");
  718. break;
  719. case 3: /* fail ... */
  720. uea_info(INS_TO_USBDEV(sc), "modem synchronization failed\n");
  721. return -EAGAIN;
  722. case 4 ... 6: /* test state */
  723. uea_warn(INS_TO_USBDEV(sc),
  724. "modem in test mode - not supported\n");
  725. return -EAGAIN;
  726. case 7: /* fast-retain ... */
  727. uea_info(INS_TO_USBDEV(sc), "modem in fast-retain mode\n");
  728. return 0;
  729. default:
  730. uea_err(INS_TO_USBDEV(sc), "modem invalid SW mode %d\n",
  731. GET_STATUS(sc->stats.phy.state));
  732. return -EAGAIN;
  733. }
  734. if (GET_STATUS(data) != 2) {
  735. uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL);
  736. uea_info(INS_TO_USBDEV(sc), "modem operational\n");
  737. /* release the dsp firmware as it is not needed until
  738. * the next failure
  739. */
  740. if (sc->dsp_firm) {
  741. release_firmware(sc->dsp_firm);
  742. sc->dsp_firm = NULL;
  743. }
  744. ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
  745. if (ret < 0)
  746. return ret;
  747. uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
  748. sc->stats.phy.firmid);
  749. }
  750. /* always update it as atm layer could not be init when we switch to
  751. * operational state
  752. */
  753. UPDATE_ATM_STAT(signal, ATM_PHY_SIG_FOUND);
  754. /* wake up processes waiting for synchronization */
  755. wake_up(&sc->sync_q);
  756. ret = uea_read_cmv(sc, SA_DIAG, 2, &sc->stats.phy.flags);
  757. if (ret < 0)
  758. return ret;
  759. sc->stats.phy.mflags |= sc->stats.phy.flags;
  760. /* in case of a flags ( for example delineation LOSS (& 0x10)),
  761. * we check the status again in order to detect the failure earlier
  762. */
  763. if (sc->stats.phy.flags) {
  764. uea_dbg(INS_TO_USBDEV(sc), "Stat flag = %d\n",
  765. sc->stats.phy.flags);
  766. return 0;
  767. }
  768. ret = uea_read_cmv(sc, SA_RATE, 0, &data);
  769. if (ret < 0)
  770. return ret;
  771. /* in bulk mode the modem have problem with high rate
  772. * changing internal timing could improve things, but the
  773. * value is misterious.
  774. * ADI930 don't support it (-EPIPE error).
  775. */
  776. if (UEA_CHIP_VERSION(sc) != ADI930
  777. && sc->stats.phy.dsrate != (data >> 16) * 32) {
  778. /* Original timming from ADI(used in windows driver)
  779. * 0x20ffff>>16 * 32 = 32 * 32 = 1Mbits
  780. */
  781. u16 timeout = (data <= 0x20ffff) ? 0 : 1;
  782. ret = uea_request(sc, UEA_SET_TIMEOUT, timeout, 0, NULL);
  783. uea_info(INS_TO_USBDEV(sc),
  784. "setting new timeout %d%s\n", timeout,
  785. ret < 0?" failed":"");
  786. }
  787. sc->stats.phy.dsrate = (data >> 16) * 32;
  788. sc->stats.phy.usrate = (data & 0xffff) * 32;
  789. UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424);
  790. ret = uea_read_cmv(sc, SA_DIAG, 23, &data);
  791. if (ret < 0)
  792. return ret;
  793. sc->stats.phy.dsattenuation = (data & 0xff) / 2;
  794. ret = uea_read_cmv(sc, SA_DIAG, 47, &data);
  795. if (ret < 0)
  796. return ret;
  797. sc->stats.phy.usattenuation = (data & 0xff) / 2;
  798. ret = uea_read_cmv(sc, SA_DIAG, 25, &sc->stats.phy.dsmargin);
  799. if (ret < 0)
  800. return ret;
  801. ret = uea_read_cmv(sc, SA_DIAG, 49, &sc->stats.phy.usmargin);
  802. if (ret < 0)
  803. return ret;
  804. ret = uea_read_cmv(sc, SA_DIAG, 51, &sc->stats.phy.rxflow);
  805. if (ret < 0)
  806. return ret;
  807. ret = uea_read_cmv(sc, SA_DIAG, 52, &sc->stats.phy.txflow);
  808. if (ret < 0)
  809. return ret;
  810. ret = uea_read_cmv(sc, SA_DIAG, 54, &sc->stats.phy.dsunc);
  811. if (ret < 0)
  812. return ret;
  813. /* only for atu-c */
  814. ret = uea_read_cmv(sc, SA_DIAG, 58, &sc->stats.phy.usunc);
  815. if (ret < 0)
  816. return ret;
  817. ret = uea_read_cmv(sc, SA_DIAG, 53, &sc->stats.phy.dscorr);
  818. if (ret < 0)
  819. return ret;
  820. /* only for atu-c */
  821. ret = uea_read_cmv(sc, SA_DIAG, 57, &sc->stats.phy.uscorr);
  822. if (ret < 0)
  823. return ret;
  824. ret = uea_read_cmv(sc, SA_INFO, 8, &sc->stats.phy.vidco);
  825. if (ret < 0)
  826. return ret;
  827. ret = uea_read_cmv(sc, SA_INFO, 13, &sc->stats.phy.vidcpe);
  828. if (ret < 0)
  829. return ret;
  830. return 0;
  831. }
  832. static int request_cmvs(struct uea_softc *sc,
  833. struct uea_cmvs **cmvs, const struct firmware **fw)
  834. {
  835. int ret, size;
  836. u8 *data;
  837. char *file;
  838. static char cmv_name[256] = FW_DIR;
  839. if (cmv_file[sc->modem_index] == NULL) {
  840. if (UEA_CHIP_VERSION(sc) == ADI930)
  841. file = (IS_ISDN(sc)) ? "CMV9i.bin" : "CMV9p.bin";
  842. else
  843. file = (IS_ISDN(sc)) ? "CMVei.bin" : "CMVep.bin";
  844. } else
  845. file = cmv_file[sc->modem_index];
  846. strcpy(cmv_name, FW_DIR);
  847. strlcat(cmv_name, file, sizeof(cmv_name));
  848. ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev);
  849. if (ret < 0) {
  850. uea_err(INS_TO_USBDEV(sc),
  851. "requesting firmware %s failed with error %d\n",
  852. cmv_name, ret);
  853. return ret;
  854. }
  855. data = (u8 *) (*fw)->data;
  856. size = *data * sizeof(struct uea_cmvs) + 1;
  857. if (size != (*fw)->size) {
  858. uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
  859. cmv_name);
  860. release_firmware(*fw);
  861. return -EILSEQ;
  862. }
  863. *cmvs = (struct uea_cmvs *)(data + 1);
  864. return *data;
  865. }
  866. /* Start boot post firmware modem:
  867. * - send reset commands through usb control pipe
  868. * - start workqueue for DSP loading
  869. * - send CMV options to modem
  870. */
  871. static int uea_start_reset(struct uea_softc *sc)
  872. {
  873. u16 zero = 0; /* ;-) */
  874. int i, len, ret;
  875. struct uea_cmvs *cmvs;
  876. const struct firmware *cmvs_fw;
  877. uea_enters(INS_TO_USBDEV(sc));
  878. uea_info(INS_TO_USBDEV(sc), "(re)booting started\n");
  879. sc->booting = 1;
  880. UPDATE_ATM_STAT(signal, ATM_PHY_SIG_LOST);
  881. /* reset statistics */
  882. memset(&sc->stats, 0, sizeof(struct uea_stats));
  883. /* tell the modem that we want to boot in IDMA mode */
  884. uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL);
  885. uea_request(sc, UEA_SET_MODE, UEA_BOOT_IDMA, 0, NULL);
  886. /* enter reset mode */
  887. uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL);
  888. /* original driver use 200ms, but windows driver use 100ms */
  889. msleep(100);
  890. /* leave reset mode */
  891. uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL);
  892. /* clear tx and rx mailboxes */
  893. uea_request(sc, UEA_SET_2183_DATA, UEA_MPTX_MAILBOX, 2, &zero);
  894. uea_request(sc, UEA_SET_2183_DATA, UEA_MPRX_MAILBOX, 2, &zero);
  895. uea_request(sc, UEA_SET_2183_DATA, UEA_SWAP_MAILBOX, 2, &zero);
  896. msleep(1000);
  897. sc->cmv_function = MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY);
  898. sc->booting = 0;
  899. /* start loading DSP */
  900. sc->pageno = 0;
  901. sc->ovl = 0;
  902. schedule_work(&sc->task);
  903. /* wait for modem ready CMV */
  904. ret = wait_cmv_ack(sc);
  905. if (ret < 0)
  906. return ret;
  907. /* Enter in R-IDLE (cmv) until instructed otherwise */
  908. ret = uea_write_cmv(sc, SA_CNTL, 0, 1);
  909. if (ret < 0)
  910. return ret;
  911. /* get options */
  912. ret = len = request_cmvs(sc, &cmvs, &cmvs_fw);
  913. if (ret < 0)
  914. return ret;
  915. /* send options */
  916. for (i = 0; i < len; i++) {
  917. ret = uea_write_cmv(sc, FW_GET_LONG(&cmvs[i].address),
  918. FW_GET_WORD(&cmvs[i].offset),
  919. FW_GET_LONG(&cmvs[i].data));
  920. if (ret < 0)
  921. goto out;
  922. }
  923. /* Enter in R-ACT-REQ */
  924. ret = uea_write_cmv(sc, SA_CNTL, 0, 2);
  925. out:
  926. release_firmware(cmvs_fw);
  927. sc->reset = 0;
  928. uea_leaves(INS_TO_USBDEV(sc));
  929. return ret;
  930. }
  931. /*
  932. * In case of an error wait 1s before rebooting the modem
  933. * if the modem don't request reboot (-EAGAIN).
  934. * Monitor the modem every 1s.
  935. */
  936. static int uea_kthread(void *data)
  937. {
  938. struct uea_softc *sc = data;
  939. int ret = -EAGAIN;
  940. uea_enters(INS_TO_USBDEV(sc));
  941. while (!kthread_should_stop()) {
  942. if (ret < 0 || sc->reset)
  943. ret = uea_start_reset(sc);
  944. if (!ret)
  945. ret = uea_stat(sc);
  946. if (ret != -EAGAIN)
  947. msleep(1000);
  948. }
  949. uea_leaves(INS_TO_USBDEV(sc));
  950. return ret;
  951. }
  952. /* Load second usb firmware for ADI930 chip */
  953. static int load_XILINX_firmware(struct uea_softc *sc)
  954. {
  955. const struct firmware *fw_entry;
  956. int ret, size, u, ln;
  957. u8 *pfw, value;
  958. char *fw_name = FW_DIR "930-fpga.bin";
  959. uea_enters(INS_TO_USBDEV(sc));
  960. ret = request_firmware(&fw_entry, fw_name, &sc->usb_dev->dev);
  961. if (ret) {
  962. uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n",
  963. fw_name);
  964. goto err0;
  965. }
  966. pfw = fw_entry->data;
  967. size = fw_entry->size;
  968. if (size != 0x577B) {
  969. uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
  970. fw_name);
  971. ret = -EILSEQ;
  972. goto err1;
  973. }
  974. for (u = 0; u < size; u += ln) {
  975. ln = min(size - u, 64);
  976. ret = uea_request(sc, 0xe, 0, ln, pfw + u);
  977. if (ret < 0) {
  978. uea_err(INS_TO_USBDEV(sc),
  979. "elsa download data failed (%d)\n", ret);
  980. goto err1;
  981. }
  982. }
  983. /* finish to send the fpga
  984. */
  985. ret = uea_request(sc, 0xe, 1, 0, NULL);
  986. if (ret < 0) {
  987. uea_err(INS_TO_USBDEV(sc),
  988. "elsa download data failed (%d)\n", ret);
  989. goto err1;
  990. }
  991. /*
  992. * Tell the modem we finish : de-assert reset
  993. */
  994. value = 0;
  995. ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value);
  996. if (ret < 0)
  997. uea_err(sc->usb_dev, "elsa de-assert failed with error %d\n", ret);
  998. err1:
  999. release_firmware(fw_entry);
  1000. err0:
  1001. uea_leaves(INS_TO_USBDEV(sc));
  1002. return ret;
  1003. }
  1004. static void uea_dispatch_cmv(struct uea_softc *sc, struct cmv* cmv)
  1005. {
  1006. uea_enters(INS_TO_USBDEV(sc));
  1007. if (le16_to_cpu(cmv->wPreamble) != PREAMBLE)
  1008. goto bad1;
  1009. if (cmv->bDirection != MODEMTOHOST)
  1010. goto bad1;
  1011. /* FIXME : ADI930 reply wrong preambule (func = 2, sub = 2) to
  1012. * the first MEMACESS cmv. Ignore it...
  1013. */
  1014. if (cmv->bFunction != sc->cmv_function) {
  1015. if (UEA_CHIP_VERSION(sc) == ADI930
  1016. && cmv->bFunction == MAKEFUNCTION(2, 2)) {
  1017. cmv->wIndex = cpu_to_le16(sc->cmv_idx);
  1018. put_unaligned(cpu_to_le32(sc->cmv_address), &cmv->dwSymbolicAddress);
  1019. cmv->wOffsetAddress = cpu_to_le16(sc->cmv_offset);
  1020. }
  1021. else
  1022. goto bad2;
  1023. }
  1024. if (cmv->bFunction == MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY)) {
  1025. wake_up_cmv_ack(sc);
  1026. return;
  1027. }
  1028. /* in case of MEMACCESS */
  1029. if (le16_to_cpu(cmv->wIndex) != sc->cmv_idx ||
  1030. le32_to_cpu(get_unaligned(&cmv->dwSymbolicAddress)) !=
  1031. sc->cmv_address
  1032. || le16_to_cpu(cmv->wOffsetAddress) != sc->cmv_offset)
  1033. goto bad2;
  1034. sc->data = le32_to_cpu(get_unaligned(&cmv->dwData));
  1035. sc->data = sc->data << 16 | sc->data >> 16;
  1036. wake_up_cmv_ack(sc);
  1037. return;
  1038. bad2:
  1039. uea_err(INS_TO_USBDEV(sc), "unexpected cmv received,"
  1040. "Function : %d, Subfunction : %d\n",
  1041. FUNCTION_TYPE(cmv->bFunction),
  1042. FUNCTION_SUBTYPE(cmv->bFunction));
  1043. return;
  1044. bad1:
  1045. uea_err(INS_TO_USBDEV(sc), "invalid cmv received, "
  1046. "wPreamble %d, bDirection %d\n",
  1047. le16_to_cpu(cmv->wPreamble), cmv->bDirection);
  1048. }
  1049. /*
  1050. * interrupt handler
  1051. */
  1052. static void uea_intr(struct urb *urb, struct pt_regs *regs)
  1053. {
  1054. struct uea_softc *sc = (struct uea_softc *)urb->context;
  1055. struct intr_pkt *intr;
  1056. uea_enters(INS_TO_USBDEV(sc));
  1057. if (urb->status < 0) {
  1058. uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n",
  1059. urb->status);
  1060. return;
  1061. }
  1062. intr = (struct intr_pkt *) urb->transfer_buffer;
  1063. /* device-to-host interrupt */
  1064. if (intr->bType != 0x08 || sc->booting) {
  1065. uea_err(INS_TO_USBDEV(sc), "wrong intr\n");
  1066. // rebooting ?
  1067. // sc->reset = 1;
  1068. goto resubmit;
  1069. }
  1070. switch (le16_to_cpu(intr->wInterrupt)) {
  1071. case INT_LOADSWAPPAGE:
  1072. sc->pageno = intr->bSwapPageNo;
  1073. sc->ovl = intr->bOvl >> 4 | intr->bOvl << 4;
  1074. schedule_work(&sc->task);
  1075. break;
  1076. case INT_INCOMINGCMV:
  1077. uea_dispatch_cmv(sc, &intr->u.s2.cmv);
  1078. break;
  1079. default:
  1080. uea_err(INS_TO_USBDEV(sc), "unknown intr %u\n",
  1081. le16_to_cpu(intr->wInterrupt));
  1082. }
  1083. resubmit:
  1084. usb_submit_urb(sc->urb_int, GFP_ATOMIC);
  1085. }
  1086. /*
  1087. * Start the modem : init the data and start kernel thread
  1088. */
  1089. static int uea_boot(struct uea_softc *sc)
  1090. {
  1091. int ret;
  1092. struct intr_pkt *intr;
  1093. uea_enters(INS_TO_USBDEV(sc));
  1094. INIT_WORK(&sc->task, uea_load_page, sc);
  1095. init_waitqueue_head(&sc->sync_q);
  1096. init_waitqueue_head(&sc->cmv_ack_wait);
  1097. if (UEA_CHIP_VERSION(sc) == ADI930)
  1098. load_XILINX_firmware(sc);
  1099. intr = kmalloc(INTR_PKT_SIZE, GFP_KERNEL);
  1100. if (!intr) {
  1101. uea_err(INS_TO_USBDEV(sc),
  1102. "cannot allocate interrupt package\n");
  1103. uea_leaves(INS_TO_USBDEV(sc));
  1104. return -ENOMEM;
  1105. }
  1106. sc->urb_int = usb_alloc_urb(0, GFP_KERNEL);
  1107. if (!sc->urb_int) {
  1108. uea_err(INS_TO_USBDEV(sc), "cannot allocate interrupt URB\n");
  1109. goto err;
  1110. }
  1111. usb_fill_int_urb(sc->urb_int, sc->usb_dev,
  1112. usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE),
  1113. intr, INTR_PKT_SIZE, uea_intr, sc,
  1114. sc->usb_dev->actconfig->interface[0]->altsetting[0].
  1115. endpoint[0].desc.bInterval);
  1116. ret = usb_submit_urb(sc->urb_int, GFP_KERNEL);
  1117. if (ret < 0) {
  1118. uea_err(INS_TO_USBDEV(sc),
  1119. "urb submition failed with error %d\n", ret);
  1120. goto err1;
  1121. }
  1122. sc->kthread = kthread_run(uea_kthread, sc, "ueagle-atm");
  1123. if (sc->kthread == ERR_PTR(-ENOMEM)) {
  1124. uea_err(INS_TO_USBDEV(sc), "failed to create thread\n");
  1125. goto err2;
  1126. }
  1127. uea_leaves(INS_TO_USBDEV(sc));
  1128. return 0;
  1129. err2:
  1130. usb_kill_urb(sc->urb_int);
  1131. err1:
  1132. kfree(intr);
  1133. err:
  1134. usb_free_urb(sc->urb_int);
  1135. uea_leaves(INS_TO_USBDEV(sc));
  1136. return -ENOMEM;
  1137. }
  1138. /*
  1139. * Stop the modem : kill kernel thread and free data
  1140. */
  1141. static void uea_stop(struct uea_softc *sc)
  1142. {
  1143. int ret;
  1144. uea_enters(INS_TO_USBDEV(sc));
  1145. ret = kthread_stop(sc->kthread);
  1146. uea_info(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret);
  1147. /* stop any pending boot process */
  1148. flush_scheduled_work();
  1149. uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL);
  1150. usb_kill_urb(sc->urb_int);
  1151. kfree(sc->urb_int->transfer_buffer);
  1152. usb_free_urb(sc->urb_int);
  1153. if (sc->dsp_firm)
  1154. release_firmware(sc->dsp_firm);
  1155. uea_leaves(INS_TO_USBDEV(sc));
  1156. }
  1157. /* syfs interface */
  1158. static struct uea_softc *dev_to_uea(struct device *dev)
  1159. {
  1160. struct usb_interface *intf;
  1161. struct usbatm_data *usbatm;
  1162. intf = to_usb_interface(dev);
  1163. if (!intf)
  1164. return NULL;
  1165. usbatm = usb_get_intfdata(intf);
  1166. if (!usbatm)
  1167. return NULL;
  1168. return usbatm->driver_data;
  1169. }
  1170. static ssize_t read_status(struct device *dev, struct device_attribute *attr,
  1171. char *buf)
  1172. {
  1173. int ret = -ENODEV;
  1174. struct uea_softc *sc;
  1175. down(&uea_semaphore);
  1176. sc = dev_to_uea(dev);
  1177. if (!sc)
  1178. goto out;
  1179. ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state);
  1180. out:
  1181. up(&uea_semaphore);
  1182. return ret;
  1183. }
  1184. static ssize_t reboot(struct device *dev, struct device_attribute *attr,
  1185. const char *buf, size_t count)
  1186. {
  1187. int ret = -ENODEV;
  1188. struct uea_softc *sc;
  1189. down(&uea_semaphore);
  1190. sc = dev_to_uea(dev);
  1191. if (!sc)
  1192. goto out;
  1193. sc->reset = 1;
  1194. ret = count;
  1195. out:
  1196. up(&uea_semaphore);
  1197. return ret;
  1198. }
  1199. static DEVICE_ATTR(stat_status, S_IWUGO | S_IRUGO, read_status, reboot);
  1200. static ssize_t read_human_status(struct device *dev, struct device_attribute *attr,
  1201. char *buf)
  1202. {
  1203. int ret = -ENODEV;
  1204. struct uea_softc *sc;
  1205. down(&uea_semaphore);
  1206. sc = dev_to_uea(dev);
  1207. if (!sc)
  1208. goto out;
  1209. switch (GET_STATUS(sc->stats.phy.state)) {
  1210. case 0:
  1211. ret = sprintf(buf, "Modem is booting\n");
  1212. break;
  1213. case 1:
  1214. ret = sprintf(buf, "Modem is initializing\n");
  1215. break;
  1216. case 2:
  1217. ret = sprintf(buf, "Modem is operational\n");
  1218. break;
  1219. default:
  1220. ret = sprintf(buf, "Modem synchronization failed\n");
  1221. break;
  1222. }
  1223. out:
  1224. up(&uea_semaphore);
  1225. return ret;
  1226. }
  1227. static DEVICE_ATTR(stat_human_status, S_IWUGO | S_IRUGO, read_human_status, NULL);
  1228. static ssize_t read_delin(struct device *dev, struct device_attribute *attr,
  1229. char *buf)
  1230. {
  1231. int ret = -ENODEV;
  1232. struct uea_softc *sc;
  1233. down(&uea_semaphore);
  1234. sc = dev_to_uea(dev);
  1235. if (!sc)
  1236. goto out;
  1237. if (sc->stats.phy.flags & 0x0C00)
  1238. ret = sprintf(buf, "ERROR\n");
  1239. else if (sc->stats.phy.flags & 0x0030)
  1240. ret = sprintf(buf, "LOSS\n");
  1241. else
  1242. ret = sprintf(buf, "GOOD\n");
  1243. out:
  1244. up(&uea_semaphore);
  1245. return ret;
  1246. }
  1247. static DEVICE_ATTR(stat_delin, S_IWUGO | S_IRUGO, read_delin, NULL);
  1248. #define UEA_ATTR(name, reset) \
  1249. \
  1250. static ssize_t read_##name(struct device *dev, \
  1251. struct device_attribute *attr, char *buf) \
  1252. { \
  1253. int ret = -ENODEV; \
  1254. struct uea_softc *sc; \
  1255. \
  1256. down(&uea_semaphore); \
  1257. sc = dev_to_uea(dev); \
  1258. if (!sc) \
  1259. goto out; \
  1260. ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \
  1261. if (reset) \
  1262. sc->stats.phy.name = 0; \
  1263. out: \
  1264. up(&uea_semaphore); \
  1265. return ret; \
  1266. } \
  1267. \
  1268. static DEVICE_ATTR(stat_##name, S_IRUGO, read_##name, NULL)
  1269. UEA_ATTR(mflags, 1);
  1270. UEA_ATTR(vidcpe, 0);
  1271. UEA_ATTR(usrate, 0);
  1272. UEA_ATTR(dsrate, 0);
  1273. UEA_ATTR(usattenuation, 0);
  1274. UEA_ATTR(dsattenuation, 0);
  1275. UEA_ATTR(usmargin, 0);
  1276. UEA_ATTR(dsmargin, 0);
  1277. UEA_ATTR(txflow, 0);
  1278. UEA_ATTR(rxflow, 0);
  1279. UEA_ATTR(uscorr, 0);
  1280. UEA_ATTR(dscorr, 0);
  1281. UEA_ATTR(usunc, 0);
  1282. UEA_ATTR(dsunc, 0);
  1283. /* Retrieve the device End System Identifier (MAC) */
  1284. #define htoi(x) (isdigit(x) ? x-'0' : toupper(x)-'A'+10)
  1285. static int uea_getesi(struct uea_softc *sc, u_char * esi)
  1286. {
  1287. unsigned char mac_str[2 * ETH_ALEN + 1];
  1288. int i;
  1289. if (usb_string
  1290. (sc->usb_dev, sc->usb_dev->descriptor.iSerialNumber, mac_str,
  1291. sizeof(mac_str)) != 2 * ETH_ALEN)
  1292. return 1;
  1293. for (i = 0; i < ETH_ALEN; i++)
  1294. esi[i] = htoi(mac_str[2 * i]) * 16 + htoi(mac_str[2 * i + 1]);
  1295. return 0;
  1296. }
  1297. /* ATM stuff */
  1298. static int uea_atm_open(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
  1299. {
  1300. struct uea_softc *sc = usbatm->driver_data;
  1301. return uea_getesi(sc, atm_dev->esi);
  1302. }
  1303. static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf)
  1304. {
  1305. struct uea_softc *sc = usbatm->driver_data;
  1306. wait_event(sc->sync_q, IS_OPERATIONAL(sc));
  1307. return 0;
  1308. }
  1309. static int claim_interface(struct usb_device *usb_dev,
  1310. struct usbatm_data *usbatm, int ifnum)
  1311. {
  1312. int ret;
  1313. struct usb_interface *intf = usb_ifnum_to_if(usb_dev, ifnum);
  1314. if (!intf) {
  1315. uea_err(usb_dev, "interface %d not found\n", ifnum);
  1316. return -ENODEV;
  1317. }
  1318. ret = usb_driver_claim_interface(&uea_driver, intf, usbatm);
  1319. if (ret != 0)
  1320. uea_err(usb_dev, "can't claim interface %d, error %d\n", ifnum,
  1321. ret);
  1322. return ret;
  1323. }
  1324. static void create_fs_entries(struct uea_softc *sc, struct usb_interface *intf)
  1325. {
  1326. /* sysfs interface */
  1327. device_create_file(&intf->dev, &dev_attr_stat_status);
  1328. device_create_file(&intf->dev, &dev_attr_stat_mflags);
  1329. device_create_file(&intf->dev, &dev_attr_stat_human_status);
  1330. device_create_file(&intf->dev, &dev_attr_stat_delin);
  1331. device_create_file(&intf->dev, &dev_attr_stat_vidcpe);
  1332. device_create_file(&intf->dev, &dev_attr_stat_usrate);
  1333. device_create_file(&intf->dev, &dev_attr_stat_dsrate);
  1334. device_create_file(&intf->dev, &dev_attr_stat_usattenuation);
  1335. device_create_file(&intf->dev, &dev_attr_stat_dsattenuation);
  1336. device_create_file(&intf->dev, &dev_attr_stat_usmargin);
  1337. device_create_file(&intf->dev, &dev_attr_stat_dsmargin);
  1338. device_create_file(&intf->dev, &dev_attr_stat_txflow);
  1339. device_create_file(&intf->dev, &dev_attr_stat_rxflow);
  1340. device_create_file(&intf->dev, &dev_attr_stat_uscorr);
  1341. device_create_file(&intf->dev, &dev_attr_stat_dscorr);
  1342. device_create_file(&intf->dev, &dev_attr_stat_usunc);
  1343. device_create_file(&intf->dev, &dev_attr_stat_dsunc);
  1344. }
  1345. static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
  1346. const struct usb_device_id *id, int *heavy)
  1347. {
  1348. struct usb_device *usb = interface_to_usbdev(intf);
  1349. struct uea_softc *sc;
  1350. int ret, ifnum = intf->altsetting->desc.bInterfaceNumber;
  1351. uea_enters(usb);
  1352. /* interface 0 is for firmware/monitoring */
  1353. if (ifnum != UEA_INTR_IFACE_NO)
  1354. return -ENODEV;
  1355. *heavy = sync_wait[modem_index];
  1356. /* interface 1 is for outbound traffic */
  1357. ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO);
  1358. if (ret < 0)
  1359. return ret;
  1360. /* ADI930 has only 2 interfaces and inbound traffic
  1361. * is on interface 1
  1362. */
  1363. if (UEA_CHIP_VERSION(id) != ADI930) {
  1364. /* interface 2 is for inbound traffic */
  1365. ret = claim_interface(usb, usbatm, UEA_DS_IFACE_NO);
  1366. if (ret < 0)
  1367. return ret;
  1368. }
  1369. sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL);
  1370. if (!sc) {
  1371. uea_err(INS_TO_USBDEV(sc), "uea_init: not enough memory !\n");
  1372. return -ENOMEM;
  1373. }
  1374. sc->usb_dev = usb;
  1375. usbatm->driver_data = sc;
  1376. sc->usbatm = usbatm;
  1377. sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0;
  1378. sc->driver_info = id->driver_info;
  1379. ret = uea_boot(sc);
  1380. if (ret < 0) {
  1381. kfree(sc);
  1382. return ret;
  1383. }
  1384. create_fs_entries(sc, intf);
  1385. return 0;
  1386. }
  1387. static void destroy_fs_entries(struct uea_softc *sc, struct usb_interface *intf)
  1388. {
  1389. /* sysfs interface */
  1390. device_remove_file(&intf->dev, &dev_attr_stat_status);
  1391. device_remove_file(&intf->dev, &dev_attr_stat_mflags);
  1392. device_remove_file(&intf->dev, &dev_attr_stat_human_status);
  1393. device_remove_file(&intf->dev, &dev_attr_stat_delin);
  1394. device_remove_file(&intf->dev, &dev_attr_stat_vidcpe);
  1395. device_remove_file(&intf->dev, &dev_attr_stat_usrate);
  1396. device_remove_file(&intf->dev, &dev_attr_stat_dsrate);
  1397. device_remove_file(&intf->dev, &dev_attr_stat_usattenuation);
  1398. device_remove_file(&intf->dev, &dev_attr_stat_dsattenuation);
  1399. device_remove_file(&intf->dev, &dev_attr_stat_usmargin);
  1400. device_remove_file(&intf->dev, &dev_attr_stat_dsmargin);
  1401. device_remove_file(&intf->dev, &dev_attr_stat_txflow);
  1402. device_remove_file(&intf->dev, &dev_attr_stat_rxflow);
  1403. device_remove_file(&intf->dev, &dev_attr_stat_uscorr);
  1404. device_remove_file(&intf->dev, &dev_attr_stat_dscorr);
  1405. device_remove_file(&intf->dev, &dev_attr_stat_usunc);
  1406. device_remove_file(&intf->dev, &dev_attr_stat_dsunc);
  1407. }
  1408. static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
  1409. {
  1410. struct uea_softc *sc = usbatm->driver_data;
  1411. destroy_fs_entries(sc, intf);
  1412. uea_stop(sc);
  1413. kfree(sc);
  1414. }
  1415. static struct usbatm_driver uea_usbatm_driver = {
  1416. .driver_name = "ueagle-atm",
  1417. .owner = THIS_MODULE,
  1418. .bind = uea_bind,
  1419. .atm_start = uea_atm_open,
  1420. .unbind = uea_unbind,
  1421. .heavy_init = uea_heavy,
  1422. .in = UEA_BULK_DATA_PIPE,
  1423. .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. down(&uea_semaphore);
  1448. usbatm_usb_disconnect(intf);
  1449. up(&uea_semaphore);
  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");