orinoco_usb.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769
  1. /*
  2. * USB Orinoco driver
  3. *
  4. * Copyright (c) 2003 Manuel Estrada Sainz
  5. *
  6. * The contents of this file are subject to the Mozilla Public License
  7. * Version 1.1 (the "License"); you may not use this file except in
  8. * compliance with the License. You may obtain a copy of the License
  9. * at http://www.mozilla.org/MPL/
  10. *
  11. * Software distributed under the License is distributed on an "AS IS"
  12. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  13. * the License for the specific language governing rights and
  14. * limitations under the License.
  15. *
  16. * Alternatively, the contents of this file may be used under the
  17. * terms of the GNU General Public License version 2 (the "GPL"), in
  18. * which case the provisions of the GPL are applicable instead of the
  19. * above. If you wish to allow the use of your version of this file
  20. * only under the terms of the GPL and not to allow others to use your
  21. * version of this file under the MPL, indicate your decision by
  22. * deleting the provisions above and replace them with the notice and
  23. * other provisions required by the GPL. If you do not delete the
  24. * provisions above, a recipient may use your version of this file
  25. * under either the MPL or the GPL.
  26. *
  27. * Queueing code based on linux-wlan-ng 0.2.1-pre5
  28. *
  29. * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
  30. *
  31. * The license is the same as above.
  32. *
  33. * Initialy based on USB Skeleton driver - 0.7
  34. *
  35. * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
  36. *
  37. * This program is free software; you can redistribute it and/or
  38. * modify it under the terms of the GNU General Public License as
  39. * published by the Free Software Foundation; either version 2 of
  40. * the License, or (at your option) any later version.
  41. *
  42. * NOTE: The original USB Skeleton driver is GPL, but all that code is
  43. * gone so MPL/GPL applies.
  44. */
  45. #define DRIVER_NAME "orinoco_usb"
  46. #define PFX DRIVER_NAME ": "
  47. #include <linux/module.h>
  48. #include <linux/kernel.h>
  49. #include <linux/sched.h>
  50. #include <linux/signal.h>
  51. #include <linux/errno.h>
  52. #include <linux/poll.h>
  53. #include <linux/init.h>
  54. #include <linux/slab.h>
  55. #include <linux/fcntl.h>
  56. #include <linux/spinlock.h>
  57. #include <linux/list.h>
  58. #include <linux/usb.h>
  59. #include <linux/timer.h>
  60. #include <linux/netdevice.h>
  61. #include <linux/if_arp.h>
  62. #include <linux/etherdevice.h>
  63. #include <linux/wireless.h>
  64. #include <linux/firmware.h>
  65. #include "mic.h"
  66. #include "orinoco.h"
  67. #ifndef URB_ASYNC_UNLINK
  68. #define URB_ASYNC_UNLINK 0
  69. #endif
  70. /* 802.2 LLC/SNAP header used for Ethernet encapsulation over 802.11 */
  71. static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
  72. #define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
  73. struct header_struct {
  74. /* 802.3 */
  75. u8 dest[ETH_ALEN];
  76. u8 src[ETH_ALEN];
  77. __be16 len;
  78. /* 802.2 */
  79. u8 dsap;
  80. u8 ssap;
  81. u8 ctrl;
  82. /* SNAP */
  83. u8 oui[3];
  84. __be16 ethertype;
  85. } __packed;
  86. struct ez_usb_fw {
  87. u16 size;
  88. const u8 *code;
  89. };
  90. static struct ez_usb_fw firmware = {
  91. .size = 0,
  92. .code = NULL,
  93. };
  94. #ifdef CONFIG_USB_DEBUG
  95. static int debug = 1;
  96. #else
  97. static int debug;
  98. #endif
  99. /* Debugging macros */
  100. #undef dbg
  101. #define dbg(format, arg...) \
  102. do { if (debug) printk(KERN_DEBUG PFX "%s: " format "\n", \
  103. __func__ , ## arg); } while (0)
  104. #undef err
  105. #define err(format, arg...) \
  106. do { printk(KERN_ERR PFX format "\n", ## arg); } while (0)
  107. /* Module paramaters */
  108. module_param(debug, int, 0644);
  109. MODULE_PARM_DESC(debug, "Debug enabled or not");
  110. MODULE_FIRMWARE("orinoco_ezusb_fw");
  111. /*
  112. * Under some conditions, the card gets stuck and stops paying attention
  113. * to the world (i.e. data communication stalls) until we do something to
  114. * it. Sending an INQ_TALLIES command seems to be enough and should be
  115. * harmless otherwise. This behaviour has been observed when using the
  116. * driver on a systemimager client during installation. In the past a
  117. * timer was used to send INQ_TALLIES commands when there was no other
  118. * activity, but it was troublesome and was removed.
  119. */
  120. #define USB_COMPAQ_VENDOR_ID 0x049f /* Compaq Computer Corp. */
  121. #define USB_COMPAQ_WL215_ID 0x001f /* Compaq WL215 USB Adapter */
  122. #define USB_COMPAQ_W200_ID 0x0076 /* Compaq W200 USB Adapter */
  123. #define USB_HP_WL215_ID 0x0082 /* Compaq WL215 USB Adapter */
  124. #define USB_MELCO_VENDOR_ID 0x0411
  125. #define USB_BUFFALO_L11_ID 0x0006 /* BUFFALO WLI-USB-L11 */
  126. #define USB_BUFFALO_L11G_WR_ID 0x000B /* BUFFALO WLI-USB-L11G-WR */
  127. #define USB_BUFFALO_L11G_ID 0x000D /* BUFFALO WLI-USB-L11G */
  128. #define USB_LUCENT_VENDOR_ID 0x047E /* Lucent Technologies */
  129. #define USB_LUCENT_ORINOCO_ID 0x0300 /* Lucent/Agere Orinoco USB Client */
  130. #define USB_AVAYA8_VENDOR_ID 0x0D98
  131. #define USB_AVAYAE_VENDOR_ID 0x0D9E
  132. #define USB_AVAYA_WIRELESS_ID 0x0300 /* Avaya Wireless USB Card */
  133. #define USB_AGERE_VENDOR_ID 0x0D4E /* Agere Systems */
  134. #define USB_AGERE_MODEL0801_ID 0x1000 /* Wireless USB Card Model 0801 */
  135. #define USB_AGERE_MODEL0802_ID 0x1001 /* Wireless USB Card Model 0802 */
  136. #define USB_AGERE_REBRANDED_ID 0x047A /* WLAN USB Card */
  137. #define USB_ELSA_VENDOR_ID 0x05CC
  138. #define USB_ELSA_AIRLANCER_ID 0x3100 /* ELSA AirLancer USB-11 */
  139. #define USB_LEGEND_VENDOR_ID 0x0E7C
  140. #define USB_LEGEND_JOYNET_ID 0x0300 /* Joynet WLAN USB Card */
  141. #define USB_SAMSUNG_VENDOR_ID 0x04E8
  142. #define USB_SAMSUNG_SEW2001U1_ID 0x5002 /* Samsung SEW-2001u Card */
  143. #define USB_SAMSUNG_SEW2001U2_ID 0x5B11 /* Samsung SEW-2001u Card */
  144. #define USB_SAMSUNG_SEW2003U_ID 0x7011 /* Samsung SEW-2003U Card */
  145. #define USB_IGATE_VENDOR_ID 0x0681
  146. #define USB_IGATE_IGATE_11M_ID 0x0012 /* I-GATE 11M USB Card */
  147. #define USB_FUJITSU_VENDOR_ID 0x0BF8
  148. #define USB_FUJITSU_E1100_ID 0x1002 /* connect2AIR WLAN E-1100 USB */
  149. #define USB_2WIRE_VENDOR_ID 0x1630
  150. #define USB_2WIRE_WIRELESS_ID 0xff81 /* 2Wire Wireless USB adapter */
  151. #define EZUSB_REQUEST_FW_TRANS 0xA0
  152. #define EZUSB_REQUEST_TRIGER 0xAA
  153. #define EZUSB_REQUEST_TRIG_AC 0xAC
  154. #define EZUSB_CPUCS_REG 0x7F92
  155. #define EZUSB_RID_TX 0x0700
  156. #define EZUSB_RID_RX 0x0701
  157. #define EZUSB_RID_INIT1 0x0702
  158. #define EZUSB_RID_ACK 0x0710
  159. #define EZUSB_RID_READ_PDA 0x0800
  160. #define EZUSB_RID_PROG_INIT 0x0852
  161. #define EZUSB_RID_PROG_SET_ADDR 0x0853
  162. #define EZUSB_RID_PROG_BYTES 0x0854
  163. #define EZUSB_RID_PROG_END 0x0855
  164. #define EZUSB_RID_DOCMD 0x0860
  165. /* Recognize info frames */
  166. #define EZUSB_IS_INFO(id) ((id >= 0xF000) && (id <= 0xF2FF))
  167. #define EZUSB_MAGIC 0x0210
  168. #define EZUSB_FRAME_DATA 1
  169. #define EZUSB_FRAME_CONTROL 2
  170. #define DEF_TIMEOUT (3 * HZ)
  171. #define BULK_BUF_SIZE 2048
  172. #define MAX_DL_SIZE (BULK_BUF_SIZE - sizeof(struct ezusb_packet))
  173. #define FW_BUF_SIZE 64
  174. #define FW_VAR_OFFSET_PTR 0x359
  175. #define FW_VAR_VALUE 0
  176. #define FW_HOLE_START 0x100
  177. #define FW_HOLE_END 0x300
  178. struct ezusb_packet {
  179. __le16 magic; /* 0x0210 */
  180. u8 req_reply_count;
  181. u8 ans_reply_count;
  182. __le16 frame_type; /* 0x01 for data frames, 0x02 otherwise */
  183. __le16 size; /* transport size */
  184. __le16 crc; /* CRC up to here */
  185. __le16 hermes_len;
  186. __le16 hermes_rid;
  187. u8 data[0];
  188. } __packed;
  189. /* Table of devices that work or may work with this driver */
  190. static struct usb_device_id ezusb_table[] = {
  191. {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_COMPAQ_WL215_ID)},
  192. {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_HP_WL215_ID)},
  193. {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_COMPAQ_W200_ID)},
  194. {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11_ID)},
  195. {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11G_WR_ID)},
  196. {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11G_ID)},
  197. {USB_DEVICE(USB_LUCENT_VENDOR_ID, USB_LUCENT_ORINOCO_ID)},
  198. {USB_DEVICE(USB_AVAYA8_VENDOR_ID, USB_AVAYA_WIRELESS_ID)},
  199. {USB_DEVICE(USB_AVAYAE_VENDOR_ID, USB_AVAYA_WIRELESS_ID)},
  200. {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_MODEL0801_ID)},
  201. {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_MODEL0802_ID)},
  202. {USB_DEVICE(USB_ELSA_VENDOR_ID, USB_ELSA_AIRLANCER_ID)},
  203. {USB_DEVICE(USB_LEGEND_VENDOR_ID, USB_LEGEND_JOYNET_ID)},
  204. {USB_DEVICE_VER(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2001U1_ID,
  205. 0, 0)},
  206. {USB_DEVICE(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2001U2_ID)},
  207. {USB_DEVICE(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2003U_ID)},
  208. {USB_DEVICE(USB_IGATE_VENDOR_ID, USB_IGATE_IGATE_11M_ID)},
  209. {USB_DEVICE(USB_FUJITSU_VENDOR_ID, USB_FUJITSU_E1100_ID)},
  210. {USB_DEVICE(USB_2WIRE_VENDOR_ID, USB_2WIRE_WIRELESS_ID)},
  211. {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_REBRANDED_ID)},
  212. {} /* Terminating entry */
  213. };
  214. MODULE_DEVICE_TABLE(usb, ezusb_table);
  215. /* Structure to hold all of our device specific stuff */
  216. struct ezusb_priv {
  217. struct usb_device *udev;
  218. struct net_device *dev;
  219. struct mutex mtx;
  220. spinlock_t req_lock;
  221. struct list_head req_pending;
  222. struct list_head req_active;
  223. spinlock_t reply_count_lock;
  224. u16 hermes_reg_fake[0x40];
  225. u8 *bap_buf;
  226. struct urb *read_urb;
  227. int read_pipe;
  228. int write_pipe;
  229. u8 reply_count;
  230. };
  231. enum ezusb_state {
  232. EZUSB_CTX_START,
  233. EZUSB_CTX_QUEUED,
  234. EZUSB_CTX_REQ_SUBMITTED,
  235. EZUSB_CTX_REQ_COMPLETE,
  236. EZUSB_CTX_RESP_RECEIVED,
  237. EZUSB_CTX_REQ_TIMEOUT,
  238. EZUSB_CTX_REQ_FAILED,
  239. EZUSB_CTX_RESP_TIMEOUT,
  240. EZUSB_CTX_REQSUBMIT_FAIL,
  241. EZUSB_CTX_COMPLETE,
  242. };
  243. struct request_context {
  244. struct list_head list;
  245. atomic_t refcount;
  246. struct completion done; /* Signals that CTX is dead */
  247. int killed;
  248. struct urb *outurb; /* OUT for req pkt */
  249. struct ezusb_priv *upriv;
  250. struct ezusb_packet *buf;
  251. int buf_length;
  252. struct timer_list timer; /* Timeout handling */
  253. enum ezusb_state state; /* Current state */
  254. /* the RID that we will wait for */
  255. u16 out_rid;
  256. u16 in_rid;
  257. };
  258. /* Forward declarations */
  259. static void ezusb_ctx_complete(struct request_context *ctx);
  260. static void ezusb_req_queue_run(struct ezusb_priv *upriv);
  261. static void ezusb_bulk_in_callback(struct urb *urb);
  262. static inline u8 ezusb_reply_inc(u8 count)
  263. {
  264. if (count < 0x7F)
  265. return count + 1;
  266. else
  267. return 1;
  268. }
  269. static void ezusb_request_context_put(struct request_context *ctx)
  270. {
  271. if (!atomic_dec_and_test(&ctx->refcount))
  272. return;
  273. WARN_ON(!ctx->done.done);
  274. BUG_ON(ctx->outurb->status == -EINPROGRESS);
  275. BUG_ON(timer_pending(&ctx->timer));
  276. usb_free_urb(ctx->outurb);
  277. kfree(ctx->buf);
  278. kfree(ctx);
  279. }
  280. static inline void ezusb_mod_timer(struct ezusb_priv *upriv,
  281. struct timer_list *timer,
  282. unsigned long expire)
  283. {
  284. if (!upriv->udev)
  285. return;
  286. mod_timer(timer, expire);
  287. }
  288. static void ezusb_request_timerfn(u_long _ctx)
  289. {
  290. struct request_context *ctx = (void *) _ctx;
  291. ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
  292. if (usb_unlink_urb(ctx->outurb) == -EINPROGRESS) {
  293. ctx->state = EZUSB_CTX_REQ_TIMEOUT;
  294. } else {
  295. ctx->state = EZUSB_CTX_RESP_TIMEOUT;
  296. dbg("couldn't unlink");
  297. atomic_inc(&ctx->refcount);
  298. ctx->killed = 1;
  299. ezusb_ctx_complete(ctx);
  300. ezusb_request_context_put(ctx);
  301. }
  302. };
  303. static struct request_context *ezusb_alloc_ctx(struct ezusb_priv *upriv,
  304. u16 out_rid, u16 in_rid)
  305. {
  306. struct request_context *ctx;
  307. ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
  308. if (!ctx)
  309. return NULL;
  310. ctx->buf = kmalloc(BULK_BUF_SIZE, GFP_ATOMIC);
  311. if (!ctx->buf) {
  312. kfree(ctx);
  313. return NULL;
  314. }
  315. ctx->outurb = usb_alloc_urb(0, GFP_ATOMIC);
  316. if (!ctx->outurb) {
  317. kfree(ctx->buf);
  318. kfree(ctx);
  319. return NULL;
  320. }
  321. ctx->upriv = upriv;
  322. ctx->state = EZUSB_CTX_START;
  323. ctx->out_rid = out_rid;
  324. ctx->in_rid = in_rid;
  325. atomic_set(&ctx->refcount, 1);
  326. init_completion(&ctx->done);
  327. init_timer(&ctx->timer);
  328. ctx->timer.function = ezusb_request_timerfn;
  329. ctx->timer.data = (u_long) ctx;
  330. return ctx;
  331. }
  332. /* Hopefully the real complete_all will soon be exported, in the mean
  333. * while this should work. */
  334. static inline void ezusb_complete_all(struct completion *comp)
  335. {
  336. complete(comp);
  337. complete(comp);
  338. complete(comp);
  339. complete(comp);
  340. }
  341. static void ezusb_ctx_complete(struct request_context *ctx)
  342. {
  343. struct ezusb_priv *upriv = ctx->upriv;
  344. unsigned long flags;
  345. spin_lock_irqsave(&upriv->req_lock, flags);
  346. list_del_init(&ctx->list);
  347. if (upriv->udev) {
  348. spin_unlock_irqrestore(&upriv->req_lock, flags);
  349. ezusb_req_queue_run(upriv);
  350. spin_lock_irqsave(&upriv->req_lock, flags);
  351. }
  352. switch (ctx->state) {
  353. case EZUSB_CTX_COMPLETE:
  354. case EZUSB_CTX_REQSUBMIT_FAIL:
  355. case EZUSB_CTX_REQ_FAILED:
  356. case EZUSB_CTX_REQ_TIMEOUT:
  357. case EZUSB_CTX_RESP_TIMEOUT:
  358. spin_unlock_irqrestore(&upriv->req_lock, flags);
  359. if ((ctx->out_rid == EZUSB_RID_TX) && upriv->dev) {
  360. struct net_device *dev = upriv->dev;
  361. struct orinoco_private *priv = ndev_priv(dev);
  362. struct net_device_stats *stats = &priv->stats;
  363. if (ctx->state != EZUSB_CTX_COMPLETE)
  364. stats->tx_errors++;
  365. else
  366. stats->tx_packets++;
  367. netif_wake_queue(dev);
  368. }
  369. ezusb_complete_all(&ctx->done);
  370. ezusb_request_context_put(ctx);
  371. break;
  372. default:
  373. spin_unlock_irqrestore(&upriv->req_lock, flags);
  374. if (!upriv->udev) {
  375. /* This is normal, as all request contexts get flushed
  376. * when the device is disconnected */
  377. err("Called, CTX not terminating, but device gone");
  378. ezusb_complete_all(&ctx->done);
  379. ezusb_request_context_put(ctx);
  380. break;
  381. }
  382. err("Called, CTX not in terminating state.");
  383. /* Things are really bad if this happens. Just leak
  384. * the CTX because it may still be linked to the
  385. * queue or the OUT urb may still be active.
  386. * Just leaking at least prevents an Oops or Panic.
  387. */
  388. break;
  389. }
  390. }
  391. /**
  392. * ezusb_req_queue_run:
  393. * Description:
  394. * Note: Only one active CTX at any one time, because there's no
  395. * other (reliable) way to match the response URB to the correct
  396. * CTX.
  397. **/
  398. static void ezusb_req_queue_run(struct ezusb_priv *upriv)
  399. {
  400. unsigned long flags;
  401. struct request_context *ctx;
  402. int result;
  403. spin_lock_irqsave(&upriv->req_lock, flags);
  404. if (!list_empty(&upriv->req_active))
  405. goto unlock;
  406. if (list_empty(&upriv->req_pending))
  407. goto unlock;
  408. ctx =
  409. list_entry(upriv->req_pending.next, struct request_context,
  410. list);
  411. if (!ctx->upriv->udev)
  412. goto unlock;
  413. /* We need to split this off to avoid a race condition */
  414. list_move_tail(&ctx->list, &upriv->req_active);
  415. if (ctx->state == EZUSB_CTX_QUEUED) {
  416. atomic_inc(&ctx->refcount);
  417. result = usb_submit_urb(ctx->outurb, GFP_ATOMIC);
  418. if (result) {
  419. ctx->state = EZUSB_CTX_REQSUBMIT_FAIL;
  420. spin_unlock_irqrestore(&upriv->req_lock, flags);
  421. err("Fatal, failed to submit command urb."
  422. " error=%d\n", result);
  423. ezusb_ctx_complete(ctx);
  424. ezusb_request_context_put(ctx);
  425. goto done;
  426. }
  427. ctx->state = EZUSB_CTX_REQ_SUBMITTED;
  428. ezusb_mod_timer(ctx->upriv, &ctx->timer,
  429. jiffies + DEF_TIMEOUT);
  430. }
  431. unlock:
  432. spin_unlock_irqrestore(&upriv->req_lock, flags);
  433. done:
  434. return;
  435. }
  436. static void ezusb_req_enqueue_run(struct ezusb_priv *upriv,
  437. struct request_context *ctx)
  438. {
  439. unsigned long flags;
  440. spin_lock_irqsave(&upriv->req_lock, flags);
  441. if (!ctx->upriv->udev) {
  442. spin_unlock_irqrestore(&upriv->req_lock, flags);
  443. goto done;
  444. }
  445. atomic_inc(&ctx->refcount);
  446. list_add_tail(&ctx->list, &upriv->req_pending);
  447. spin_unlock_irqrestore(&upriv->req_lock, flags);
  448. ctx->state = EZUSB_CTX_QUEUED;
  449. ezusb_req_queue_run(upriv);
  450. done:
  451. return;
  452. }
  453. static void ezusb_request_out_callback(struct urb *urb)
  454. {
  455. unsigned long flags;
  456. enum ezusb_state state;
  457. struct request_context *ctx = urb->context;
  458. struct ezusb_priv *upriv = ctx->upriv;
  459. spin_lock_irqsave(&upriv->req_lock, flags);
  460. del_timer(&ctx->timer);
  461. if (ctx->killed) {
  462. spin_unlock_irqrestore(&upriv->req_lock, flags);
  463. pr_warning("interrupt called with dead ctx");
  464. goto out;
  465. }
  466. state = ctx->state;
  467. if (urb->status == 0) {
  468. switch (state) {
  469. case EZUSB_CTX_REQ_SUBMITTED:
  470. if (ctx->in_rid) {
  471. ctx->state = EZUSB_CTX_REQ_COMPLETE;
  472. /* reply URB still pending */
  473. ezusb_mod_timer(upriv, &ctx->timer,
  474. jiffies + DEF_TIMEOUT);
  475. spin_unlock_irqrestore(&upriv->req_lock,
  476. flags);
  477. break;
  478. }
  479. /* fall through */
  480. case EZUSB_CTX_RESP_RECEIVED:
  481. /* IN already received before this OUT-ACK */
  482. ctx->state = EZUSB_CTX_COMPLETE;
  483. spin_unlock_irqrestore(&upriv->req_lock, flags);
  484. ezusb_ctx_complete(ctx);
  485. break;
  486. default:
  487. spin_unlock_irqrestore(&upriv->req_lock, flags);
  488. err("Unexpected state(0x%x, %d) in OUT URB",
  489. state, urb->status);
  490. break;
  491. }
  492. } else {
  493. /* If someone cancels the OUT URB then its status
  494. * should be either -ECONNRESET or -ENOENT.
  495. */
  496. switch (state) {
  497. case EZUSB_CTX_REQ_SUBMITTED:
  498. case EZUSB_CTX_RESP_RECEIVED:
  499. ctx->state = EZUSB_CTX_REQ_FAILED;
  500. /* fall through */
  501. case EZUSB_CTX_REQ_FAILED:
  502. case EZUSB_CTX_REQ_TIMEOUT:
  503. spin_unlock_irqrestore(&upriv->req_lock, flags);
  504. ezusb_ctx_complete(ctx);
  505. break;
  506. default:
  507. spin_unlock_irqrestore(&upriv->req_lock, flags);
  508. err("Unexpected state(0x%x, %d) in OUT URB",
  509. state, urb->status);
  510. break;
  511. }
  512. }
  513. out:
  514. ezusb_request_context_put(ctx);
  515. }
  516. static void ezusb_request_in_callback(struct ezusb_priv *upriv,
  517. struct urb *urb)
  518. {
  519. struct ezusb_packet *ans = urb->transfer_buffer;
  520. struct request_context *ctx = NULL;
  521. enum ezusb_state state;
  522. unsigned long flags;
  523. /* Find the CTX on the active queue that requested this URB */
  524. spin_lock_irqsave(&upriv->req_lock, flags);
  525. if (upriv->udev) {
  526. struct list_head *item;
  527. list_for_each(item, &upriv->req_active) {
  528. struct request_context *c;
  529. int reply_count;
  530. c = list_entry(item, struct request_context, list);
  531. reply_count =
  532. ezusb_reply_inc(c->buf->req_reply_count);
  533. if ((ans->ans_reply_count == reply_count)
  534. && (le16_to_cpu(ans->hermes_rid) == c->in_rid)) {
  535. ctx = c;
  536. break;
  537. }
  538. dbg("Skipped (0x%x/0x%x) (%d/%d)",
  539. le16_to_cpu(ans->hermes_rid),
  540. c->in_rid, ans->ans_reply_count, reply_count);
  541. }
  542. }
  543. if (ctx == NULL) {
  544. spin_unlock_irqrestore(&upriv->req_lock, flags);
  545. err("%s: got unexpected RID: 0x%04X", __func__,
  546. le16_to_cpu(ans->hermes_rid));
  547. ezusb_req_queue_run(upriv);
  548. return;
  549. }
  550. /* The data we want is in the in buffer, exchange */
  551. urb->transfer_buffer = ctx->buf;
  552. ctx->buf = (void *) ans;
  553. ctx->buf_length = urb->actual_length;
  554. state = ctx->state;
  555. switch (state) {
  556. case EZUSB_CTX_REQ_SUBMITTED:
  557. /* We have received our response URB before
  558. * our request has been acknowledged. Do NOT
  559. * destroy our CTX yet, because our OUT URB
  560. * is still alive ...
  561. */
  562. ctx->state = EZUSB_CTX_RESP_RECEIVED;
  563. spin_unlock_irqrestore(&upriv->req_lock, flags);
  564. /* Let the machine continue running. */
  565. break;
  566. case EZUSB_CTX_REQ_COMPLETE:
  567. /* This is the usual path: our request
  568. * has already been acknowledged, and
  569. * we have now received the reply.
  570. */
  571. ctx->state = EZUSB_CTX_COMPLETE;
  572. /* Stop the intimer */
  573. del_timer(&ctx->timer);
  574. spin_unlock_irqrestore(&upriv->req_lock, flags);
  575. /* Call the completion handler */
  576. ezusb_ctx_complete(ctx);
  577. break;
  578. default:
  579. spin_unlock_irqrestore(&upriv->req_lock, flags);
  580. pr_warning("Matched IN URB, unexpected context state(0x%x)",
  581. state);
  582. /* Throw this CTX away and try submitting another */
  583. del_timer(&ctx->timer);
  584. ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
  585. usb_unlink_urb(ctx->outurb);
  586. ezusb_req_queue_run(upriv);
  587. break;
  588. } /* switch */
  589. }
  590. static void ezusb_req_ctx_wait(struct ezusb_priv *upriv,
  591. struct request_context *ctx)
  592. {
  593. switch (ctx->state) {
  594. case EZUSB_CTX_QUEUED:
  595. case EZUSB_CTX_REQ_SUBMITTED:
  596. case EZUSB_CTX_REQ_COMPLETE:
  597. case EZUSB_CTX_RESP_RECEIVED:
  598. if (in_softirq()) {
  599. /* If we get called from a timer, timeout timers don't
  600. * get the chance to run themselves. So we make sure
  601. * that we don't sleep for ever */
  602. int msecs = DEF_TIMEOUT * (1000 / HZ);
  603. while (!ctx->done.done && msecs--)
  604. udelay(1000);
  605. } else {
  606. wait_event_interruptible(ctx->done.wait,
  607. ctx->done.done);
  608. }
  609. break;
  610. default:
  611. /* Done or failed - nothing to wait for */
  612. break;
  613. }
  614. }
  615. static inline u16 build_crc(struct ezusb_packet *data)
  616. {
  617. u16 crc = 0;
  618. u8 *bytes = (u8 *)data;
  619. int i;
  620. for (i = 0; i < 8; i++)
  621. crc = (crc << 1) + bytes[i];
  622. return crc;
  623. }
  624. /**
  625. * ezusb_fill_req:
  626. *
  627. * if data == NULL and length > 0 the data is assumed to be already in
  628. * the target buffer and only the header is filled.
  629. *
  630. */
  631. static int ezusb_fill_req(struct ezusb_packet *req, u16 length, u16 rid,
  632. const void *data, u16 frame_type, u8 reply_count)
  633. {
  634. int total_size = sizeof(*req) + length;
  635. BUG_ON(total_size > BULK_BUF_SIZE);
  636. req->magic = cpu_to_le16(EZUSB_MAGIC);
  637. req->req_reply_count = reply_count;
  638. req->ans_reply_count = 0;
  639. req->frame_type = cpu_to_le16(frame_type);
  640. req->size = cpu_to_le16(length + 4);
  641. req->crc = cpu_to_le16(build_crc(req));
  642. req->hermes_len = cpu_to_le16(HERMES_BYTES_TO_RECLEN(length));
  643. req->hermes_rid = cpu_to_le16(rid);
  644. if (data)
  645. memcpy(req->data, data, length);
  646. return total_size;
  647. }
  648. static int ezusb_submit_in_urb(struct ezusb_priv *upriv)
  649. {
  650. int retval = 0;
  651. void *cur_buf = upriv->read_urb->transfer_buffer;
  652. if (upriv->read_urb->status == -EINPROGRESS) {
  653. dbg("urb busy, not resubmiting");
  654. retval = -EBUSY;
  655. goto exit;
  656. }
  657. usb_fill_bulk_urb(upriv->read_urb, upriv->udev, upriv->read_pipe,
  658. cur_buf, BULK_BUF_SIZE,
  659. ezusb_bulk_in_callback, upriv);
  660. upriv->read_urb->transfer_flags = 0;
  661. retval = usb_submit_urb(upriv->read_urb, GFP_ATOMIC);
  662. if (retval)
  663. err("%s submit failed %d", __func__, retval);
  664. exit:
  665. return retval;
  666. }
  667. static inline int ezusb_8051_cpucs(struct ezusb_priv *upriv, int reset)
  668. {
  669. u8 res_val = reset; /* avoid argument promotion */
  670. if (!upriv->udev) {
  671. err("%s: !upriv->udev", __func__);
  672. return -EFAULT;
  673. }
  674. return usb_control_msg(upriv->udev,
  675. usb_sndctrlpipe(upriv->udev, 0),
  676. EZUSB_REQUEST_FW_TRANS,
  677. USB_TYPE_VENDOR | USB_RECIP_DEVICE |
  678. USB_DIR_OUT, EZUSB_CPUCS_REG, 0, &res_val,
  679. sizeof(res_val), DEF_TIMEOUT);
  680. }
  681. static int ezusb_firmware_download(struct ezusb_priv *upriv,
  682. struct ez_usb_fw *fw)
  683. {
  684. u8 *fw_buffer;
  685. int retval, addr;
  686. int variant_offset;
  687. fw_buffer = kmalloc(FW_BUF_SIZE, GFP_KERNEL);
  688. if (!fw_buffer) {
  689. printk(KERN_ERR PFX "Out of memory for firmware buffer.\n");
  690. return -ENOMEM;
  691. }
  692. /*
  693. * This byte is 1 and should be replaced with 0. The offset is
  694. * 0x10AD in version 0.0.6. The byte in question should follow
  695. * the end of the code pointed to by the jump in the beginning
  696. * of the firmware. Also, it is read by code located at 0x358.
  697. */
  698. variant_offset = be16_to_cpup((__be16 *) &fw->code[FW_VAR_OFFSET_PTR]);
  699. if (variant_offset >= fw->size) {
  700. printk(KERN_ERR PFX "Invalid firmware variant offset: "
  701. "0x%04x\n", variant_offset);
  702. retval = -EINVAL;
  703. goto fail;
  704. }
  705. retval = ezusb_8051_cpucs(upriv, 1);
  706. if (retval < 0)
  707. goto fail;
  708. for (addr = 0; addr < fw->size; addr += FW_BUF_SIZE) {
  709. /* 0x100-0x300 should be left alone, it contains card
  710. * specific data, like USB enumeration information */
  711. if ((addr >= FW_HOLE_START) && (addr < FW_HOLE_END))
  712. continue;
  713. memcpy(fw_buffer, &fw->code[addr], FW_BUF_SIZE);
  714. if (variant_offset >= addr &&
  715. variant_offset < addr + FW_BUF_SIZE) {
  716. dbg("Patching card_variant byte at 0x%04X",
  717. variant_offset);
  718. fw_buffer[variant_offset - addr] = FW_VAR_VALUE;
  719. }
  720. retval = usb_control_msg(upriv->udev,
  721. usb_sndctrlpipe(upriv->udev, 0),
  722. EZUSB_REQUEST_FW_TRANS,
  723. USB_TYPE_VENDOR | USB_RECIP_DEVICE
  724. | USB_DIR_OUT,
  725. addr, 0x0,
  726. fw_buffer, FW_BUF_SIZE,
  727. DEF_TIMEOUT);
  728. if (retval < 0)
  729. goto fail;
  730. }
  731. retval = ezusb_8051_cpucs(upriv, 0);
  732. if (retval < 0)
  733. goto fail;
  734. goto exit;
  735. fail:
  736. printk(KERN_ERR PFX "Firmware download failed, error %d\n",
  737. retval);
  738. exit:
  739. kfree(fw_buffer);
  740. return retval;
  741. }
  742. static int ezusb_access_ltv(struct ezusb_priv *upriv,
  743. struct request_context *ctx,
  744. u16 length, const void *data, u16 frame_type,
  745. void *ans_buff, unsigned ans_size, u16 *ans_length)
  746. {
  747. int req_size;
  748. int retval = 0;
  749. enum ezusb_state state;
  750. BUG_ON(in_irq());
  751. if (!upriv->udev) {
  752. dbg("Device disconnected");
  753. retval = -ENODEV;
  754. goto exit;
  755. }
  756. if (upriv->read_urb->status != -EINPROGRESS)
  757. err("%s: in urb not pending", __func__);
  758. /* protect upriv->reply_count, guarantee sequential numbers */
  759. spin_lock_bh(&upriv->reply_count_lock);
  760. req_size = ezusb_fill_req(ctx->buf, length, ctx->out_rid, data,
  761. frame_type, upriv->reply_count);
  762. usb_fill_bulk_urb(ctx->outurb, upriv->udev, upriv->write_pipe,
  763. ctx->buf, req_size,
  764. ezusb_request_out_callback, ctx);
  765. if (ctx->in_rid)
  766. upriv->reply_count = ezusb_reply_inc(upriv->reply_count);
  767. ezusb_req_enqueue_run(upriv, ctx);
  768. spin_unlock_bh(&upriv->reply_count_lock);
  769. if (ctx->in_rid)
  770. ezusb_req_ctx_wait(upriv, ctx);
  771. state = ctx->state;
  772. switch (state) {
  773. case EZUSB_CTX_COMPLETE:
  774. retval = ctx->outurb->status;
  775. break;
  776. case EZUSB_CTX_QUEUED:
  777. case EZUSB_CTX_REQ_SUBMITTED:
  778. if (!ctx->in_rid)
  779. break;
  780. default:
  781. err("%s: Unexpected context state %d", __func__,
  782. state);
  783. /* fall though */
  784. case EZUSB_CTX_REQ_TIMEOUT:
  785. case EZUSB_CTX_REQ_FAILED:
  786. case EZUSB_CTX_RESP_TIMEOUT:
  787. case EZUSB_CTX_REQSUBMIT_FAIL:
  788. printk(KERN_ERR PFX "Access failed, resetting (state %d,"
  789. " reply_count %d)\n", state, upriv->reply_count);
  790. upriv->reply_count = 0;
  791. if (state == EZUSB_CTX_REQ_TIMEOUT
  792. || state == EZUSB_CTX_RESP_TIMEOUT) {
  793. printk(KERN_ERR PFX "ctx timed out\n");
  794. retval = -ETIMEDOUT;
  795. } else {
  796. printk(KERN_ERR PFX "ctx failed\n");
  797. retval = -EFAULT;
  798. }
  799. goto exit;
  800. break;
  801. }
  802. if (ctx->in_rid) {
  803. struct ezusb_packet *ans = ctx->buf;
  804. unsigned exp_len;
  805. if (ans->hermes_len != 0)
  806. exp_len = le16_to_cpu(ans->hermes_len) * 2 + 12;
  807. else
  808. exp_len = 14;
  809. if (exp_len != ctx->buf_length) {
  810. err("%s: length mismatch for RID 0x%04x: "
  811. "expected %d, got %d", __func__,
  812. ctx->in_rid, exp_len, ctx->buf_length);
  813. retval = -EIO;
  814. goto exit;
  815. }
  816. if (ans_buff)
  817. memcpy(ans_buff, ans->data, min(exp_len, ans_size));
  818. if (ans_length)
  819. *ans_length = le16_to_cpu(ans->hermes_len);
  820. }
  821. exit:
  822. ezusb_request_context_put(ctx);
  823. return retval;
  824. }
  825. static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid,
  826. u16 length, const void *data)
  827. {
  828. struct ezusb_priv *upriv = hw->priv;
  829. u16 frame_type;
  830. struct request_context *ctx;
  831. if (length == 0)
  832. return -EINVAL;
  833. length = HERMES_RECLEN_TO_BYTES(length);
  834. /* On memory mapped devices HERMES_RID_CNFGROUPADDRESSES can be
  835. * set to be empty, but the USB bridge doesn't like it */
  836. if (length == 0)
  837. return 0;
  838. ctx = ezusb_alloc_ctx(upriv, rid, EZUSB_RID_ACK);
  839. if (!ctx)
  840. return -ENOMEM;
  841. if (rid == EZUSB_RID_TX)
  842. frame_type = EZUSB_FRAME_DATA;
  843. else
  844. frame_type = EZUSB_FRAME_CONTROL;
  845. return ezusb_access_ltv(upriv, ctx, length, data, frame_type,
  846. NULL, 0, NULL);
  847. }
  848. static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid,
  849. unsigned bufsize, u16 *length, void *buf)
  850. {
  851. struct ezusb_priv *upriv = hw->priv;
  852. struct request_context *ctx;
  853. if (bufsize % 2)
  854. return -EINVAL;
  855. ctx = ezusb_alloc_ctx(upriv, rid, rid);
  856. if (!ctx)
  857. return -ENOMEM;
  858. return ezusb_access_ltv(upriv, ctx, 0, NULL, EZUSB_FRAME_CONTROL,
  859. buf, bufsize, length);
  860. }
  861. static int ezusb_doicmd_wait(struct hermes *hw, u16 cmd, u16 parm0, u16 parm1,
  862. u16 parm2, struct hermes_response *resp)
  863. {
  864. struct ezusb_priv *upriv = hw->priv;
  865. struct request_context *ctx;
  866. __le16 data[4] = {
  867. cpu_to_le16(cmd),
  868. cpu_to_le16(parm0),
  869. cpu_to_le16(parm1),
  870. cpu_to_le16(parm2),
  871. };
  872. dbg("0x%04X, parm0 0x%04X, parm1 0x%04X, parm2 0x%04X",
  873. cmd, parm0, parm1, parm2);
  874. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK);
  875. if (!ctx)
  876. return -ENOMEM;
  877. return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  878. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  879. }
  880. static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0,
  881. struct hermes_response *resp)
  882. {
  883. struct ezusb_priv *upriv = hw->priv;
  884. struct request_context *ctx;
  885. __le16 data[4] = {
  886. cpu_to_le16(cmd),
  887. cpu_to_le16(parm0),
  888. 0,
  889. 0,
  890. };
  891. dbg("0x%04X, parm0 0x%04X", cmd, parm0);
  892. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK);
  893. if (!ctx)
  894. return -ENOMEM;
  895. return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  896. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  897. }
  898. static int ezusb_bap_pread(struct hermes *hw, int bap,
  899. void *buf, int len, u16 id, u16 offset)
  900. {
  901. struct ezusb_priv *upriv = hw->priv;
  902. struct ezusb_packet *ans = (void *) upriv->read_urb->transfer_buffer;
  903. int actual_length = upriv->read_urb->actual_length;
  904. if (id == EZUSB_RID_RX) {
  905. if ((sizeof(*ans) + offset + len) > actual_length) {
  906. printk(KERN_ERR PFX "BAP read beyond buffer end "
  907. "in rx frame\n");
  908. return -EINVAL;
  909. }
  910. memcpy(buf, ans->data + offset, len);
  911. return 0;
  912. }
  913. if (EZUSB_IS_INFO(id)) {
  914. /* Include 4 bytes for length/type */
  915. if ((sizeof(*ans) + offset + len - 4) > actual_length) {
  916. printk(KERN_ERR PFX "BAP read beyond buffer end "
  917. "in info frame\n");
  918. return -EFAULT;
  919. }
  920. memcpy(buf, ans->data + offset - 4, len);
  921. } else {
  922. printk(KERN_ERR PFX "Unexpected fid 0x%04x\n", id);
  923. return -EINVAL;
  924. }
  925. return 0;
  926. }
  927. static int ezusb_read_pda(struct hermes *hw, __le16 *pda,
  928. u32 pda_addr, u16 pda_len)
  929. {
  930. struct ezusb_priv *upriv = hw->priv;
  931. struct request_context *ctx;
  932. __le16 data[] = {
  933. cpu_to_le16(pda_addr & 0xffff),
  934. cpu_to_le16(pda_len - 4)
  935. };
  936. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_READ_PDA, EZUSB_RID_READ_PDA);
  937. if (!ctx)
  938. return -ENOMEM;
  939. /* wl_lkm does not include PDA size in the PDA area.
  940. * We will pad the information into pda, so other routines
  941. * don't have to be modified */
  942. pda[0] = cpu_to_le16(pda_len - 2);
  943. /* Includes CFG_PROD_DATA but not itself */
  944. pda[1] = cpu_to_le16(0x0800); /* CFG_PROD_DATA */
  945. return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  946. EZUSB_FRAME_CONTROL, &pda[2], pda_len - 4,
  947. NULL);
  948. }
  949. static int ezusb_program_init(struct hermes *hw, u32 entry_point)
  950. {
  951. struct ezusb_priv *upriv = hw->priv;
  952. struct request_context *ctx;
  953. __le32 data = cpu_to_le32(entry_point);
  954. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_INIT, EZUSB_RID_ACK);
  955. if (!ctx)
  956. return -ENOMEM;
  957. return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  958. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  959. }
  960. static int ezusb_program_end(struct hermes *hw)
  961. {
  962. struct ezusb_priv *upriv = hw->priv;
  963. struct request_context *ctx;
  964. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_END, EZUSB_RID_ACK);
  965. if (!ctx)
  966. return -ENOMEM;
  967. return ezusb_access_ltv(upriv, ctx, 0, NULL,
  968. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  969. }
  970. static int ezusb_program_bytes(struct hermes *hw, const char *buf,
  971. u32 addr, u32 len)
  972. {
  973. struct ezusb_priv *upriv = hw->priv;
  974. struct request_context *ctx;
  975. __le32 data = cpu_to_le32(addr);
  976. int err;
  977. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_SET_ADDR, EZUSB_RID_ACK);
  978. if (!ctx)
  979. return -ENOMEM;
  980. err = ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  981. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  982. if (err)
  983. return err;
  984. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_BYTES, EZUSB_RID_ACK);
  985. if (!ctx)
  986. return -ENOMEM;
  987. return ezusb_access_ltv(upriv, ctx, len, buf,
  988. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  989. }
  990. static int ezusb_program(struct hermes *hw, const char *buf,
  991. u32 addr, u32 len)
  992. {
  993. u32 ch_addr;
  994. u32 ch_len;
  995. int err = 0;
  996. /* We can only send 2048 bytes out of the bulk xmit at a time,
  997. * so we have to split any programming into chunks of <2048
  998. * bytes. */
  999. ch_len = (len < MAX_DL_SIZE) ? len : MAX_DL_SIZE;
  1000. ch_addr = addr;
  1001. while (ch_addr < (addr + len)) {
  1002. pr_debug("Programming subblock of length %d "
  1003. "to address 0x%08x. Data @ %p\n",
  1004. ch_len, ch_addr, &buf[ch_addr - addr]);
  1005. err = ezusb_program_bytes(hw, &buf[ch_addr - addr],
  1006. ch_addr, ch_len);
  1007. if (err)
  1008. break;
  1009. ch_addr += ch_len;
  1010. ch_len = ((addr + len - ch_addr) < MAX_DL_SIZE) ?
  1011. (addr + len - ch_addr) : MAX_DL_SIZE;
  1012. }
  1013. return err;
  1014. }
  1015. static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev)
  1016. {
  1017. struct orinoco_private *priv = ndev_priv(dev);
  1018. struct net_device_stats *stats = &priv->stats;
  1019. struct ezusb_priv *upriv = priv->card;
  1020. u8 mic[MICHAEL_MIC_LEN + 1];
  1021. int err = 0;
  1022. int tx_control;
  1023. unsigned long flags;
  1024. struct request_context *ctx;
  1025. u8 *buf;
  1026. int tx_size;
  1027. if (!netif_running(dev)) {
  1028. printk(KERN_ERR "%s: Tx on stopped device!\n",
  1029. dev->name);
  1030. return NETDEV_TX_BUSY;
  1031. }
  1032. if (netif_queue_stopped(dev)) {
  1033. printk(KERN_DEBUG "%s: Tx while transmitter busy!\n",
  1034. dev->name);
  1035. return NETDEV_TX_BUSY;
  1036. }
  1037. if (orinoco_lock(priv, &flags) != 0) {
  1038. printk(KERN_ERR
  1039. "%s: ezusb_xmit() called while hw_unavailable\n",
  1040. dev->name);
  1041. return NETDEV_TX_BUSY;
  1042. }
  1043. if (!netif_carrier_ok(dev) ||
  1044. (priv->iw_mode == NL80211_IFTYPE_MONITOR)) {
  1045. /* Oops, the firmware hasn't established a connection,
  1046. silently drop the packet (this seems to be the
  1047. safest approach). */
  1048. goto drop;
  1049. }
  1050. /* Check packet length */
  1051. if (skb->len < ETH_HLEN)
  1052. goto drop;
  1053. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0);
  1054. if (!ctx)
  1055. goto busy;
  1056. memset(ctx->buf, 0, BULK_BUF_SIZE);
  1057. buf = ctx->buf->data;
  1058. tx_control = 0;
  1059. err = orinoco_process_xmit_skb(skb, dev, priv, &tx_control,
  1060. &mic[0]);
  1061. if (err)
  1062. goto drop;
  1063. {
  1064. __le16 *tx_cntl = (__le16 *)buf;
  1065. *tx_cntl = cpu_to_le16(tx_control);
  1066. buf += sizeof(*tx_cntl);
  1067. }
  1068. memcpy(buf, skb->data, skb->len);
  1069. buf += skb->len;
  1070. if (tx_control & HERMES_TXCTRL_MIC) {
  1071. u8 *m = mic;
  1072. /* Mic has been offset so it can be copied to an even
  1073. * address. We're copying eveything anyway, so we
  1074. * don't need to copy that first byte. */
  1075. if (skb->len % 2)
  1076. m++;
  1077. memcpy(buf, m, MICHAEL_MIC_LEN);
  1078. buf += MICHAEL_MIC_LEN;
  1079. }
  1080. /* Finally, we actually initiate the send */
  1081. netif_stop_queue(dev);
  1082. /* The card may behave better if we send evenly sized usb transfers */
  1083. tx_size = ALIGN(buf - ctx->buf->data, 2);
  1084. err = ezusb_access_ltv(upriv, ctx, tx_size, NULL,
  1085. EZUSB_FRAME_DATA, NULL, 0, NULL);
  1086. if (err) {
  1087. netif_start_queue(dev);
  1088. if (net_ratelimit())
  1089. printk(KERN_ERR "%s: Error %d transmitting packet\n",
  1090. dev->name, err);
  1091. goto busy;
  1092. }
  1093. dev->trans_start = jiffies;
  1094. stats->tx_bytes += skb->len;
  1095. goto ok;
  1096. drop:
  1097. stats->tx_errors++;
  1098. stats->tx_dropped++;
  1099. ok:
  1100. orinoco_unlock(priv, &flags);
  1101. dev_kfree_skb(skb);
  1102. return NETDEV_TX_OK;
  1103. busy:
  1104. orinoco_unlock(priv, &flags);
  1105. return NETDEV_TX_BUSY;
  1106. }
  1107. static int ezusb_allocate(struct hermes *hw, u16 size, u16 *fid)
  1108. {
  1109. *fid = EZUSB_RID_TX;
  1110. return 0;
  1111. }
  1112. static int ezusb_hard_reset(struct orinoco_private *priv)
  1113. {
  1114. struct ezusb_priv *upriv = priv->card;
  1115. int retval = ezusb_8051_cpucs(upriv, 1);
  1116. if (retval < 0) {
  1117. err("Failed to reset");
  1118. return retval;
  1119. }
  1120. retval = ezusb_8051_cpucs(upriv, 0);
  1121. if (retval < 0) {
  1122. err("Failed to unreset");
  1123. return retval;
  1124. }
  1125. dbg("sending control message");
  1126. retval = usb_control_msg(upriv->udev,
  1127. usb_sndctrlpipe(upriv->udev, 0),
  1128. EZUSB_REQUEST_TRIGER,
  1129. USB_TYPE_VENDOR | USB_RECIP_DEVICE |
  1130. USB_DIR_OUT, 0x0, 0x0, NULL, 0,
  1131. DEF_TIMEOUT);
  1132. if (retval < 0) {
  1133. err("EZUSB_REQUEST_TRIGER failed retval %d", retval);
  1134. return retval;
  1135. }
  1136. #if 0
  1137. dbg("Sending EZUSB_REQUEST_TRIG_AC");
  1138. retval = usb_control_msg(upriv->udev,
  1139. usb_sndctrlpipe(upriv->udev, 0),
  1140. EZUSB_REQUEST_TRIG_AC,
  1141. USB_TYPE_VENDOR | USB_RECIP_DEVICE |
  1142. USB_DIR_OUT, 0x00FA, 0x0, NULL, 0,
  1143. DEF_TIMEOUT);
  1144. if (retval < 0) {
  1145. err("EZUSB_REQUEST_TRIG_AC failed retval %d", retval);
  1146. return retval;
  1147. }
  1148. #endif
  1149. return 0;
  1150. }
  1151. static int ezusb_init(struct hermes *hw)
  1152. {
  1153. struct ezusb_priv *upriv = hw->priv;
  1154. int retval;
  1155. BUG_ON(in_interrupt());
  1156. BUG_ON(!upriv);
  1157. upriv->reply_count = 0;
  1158. /* Write the MAGIC number on the simulated registers to keep
  1159. * orinoco.c happy */
  1160. hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC);
  1161. hermes_write_regn(hw, RXFID, EZUSB_RID_RX);
  1162. usb_kill_urb(upriv->read_urb);
  1163. ezusb_submit_in_urb(upriv);
  1164. retval = ezusb_write_ltv(hw, 0, EZUSB_RID_INIT1,
  1165. HERMES_BYTES_TO_RECLEN(2), "\x10\x00");
  1166. if (retval < 0) {
  1167. printk(KERN_ERR PFX "EZUSB_RID_INIT1 error %d\n", retval);
  1168. return retval;
  1169. }
  1170. retval = ezusb_docmd_wait(hw, HERMES_CMD_INIT, 0, NULL);
  1171. if (retval < 0) {
  1172. printk(KERN_ERR PFX "HERMES_CMD_INIT error %d\n", retval);
  1173. return retval;
  1174. }
  1175. return 0;
  1176. }
  1177. static void ezusb_bulk_in_callback(struct urb *urb)
  1178. {
  1179. struct ezusb_priv *upriv = (struct ezusb_priv *) urb->context;
  1180. struct ezusb_packet *ans = urb->transfer_buffer;
  1181. u16 crc;
  1182. u16 hermes_rid;
  1183. if (upriv->udev == NULL) {
  1184. dbg("disconnected");
  1185. return;
  1186. }
  1187. if (urb->status == -ETIMEDOUT) {
  1188. /* When a device gets unplugged we get this every time
  1189. * we resubmit, flooding the logs. Since we don't use
  1190. * USB timeouts, it shouldn't happen any other time*/
  1191. pr_warning("%s: urb timed out, not resubmiting", __func__);
  1192. return;
  1193. }
  1194. if (urb->status == -ECONNABORTED) {
  1195. pr_warning("%s: connection abort, resubmiting urb",
  1196. __func__);
  1197. goto resubmit;
  1198. }
  1199. if ((urb->status == -EILSEQ)
  1200. || (urb->status == -ENOENT)
  1201. || (urb->status == -ECONNRESET)) {
  1202. dbg("status %d, not resubmiting", urb->status);
  1203. return;
  1204. }
  1205. if (urb->status)
  1206. dbg("status: %d length: %d",
  1207. urb->status, urb->actual_length);
  1208. if (urb->actual_length < sizeof(*ans)) {
  1209. err("%s: short read, ignoring", __func__);
  1210. goto resubmit;
  1211. }
  1212. crc = build_crc(ans);
  1213. if (le16_to_cpu(ans->crc) != crc) {
  1214. err("CRC error, ignoring packet");
  1215. goto resubmit;
  1216. }
  1217. hermes_rid = le16_to_cpu(ans->hermes_rid);
  1218. if ((hermes_rid != EZUSB_RID_RX) && !EZUSB_IS_INFO(hermes_rid)) {
  1219. ezusb_request_in_callback(upriv, urb);
  1220. } else if (upriv->dev) {
  1221. struct net_device *dev = upriv->dev;
  1222. struct orinoco_private *priv = ndev_priv(dev);
  1223. struct hermes *hw = &priv->hw;
  1224. if (hermes_rid == EZUSB_RID_RX) {
  1225. __orinoco_ev_rx(dev, hw);
  1226. } else {
  1227. hermes_write_regn(hw, INFOFID,
  1228. le16_to_cpu(ans->hermes_rid));
  1229. __orinoco_ev_info(dev, hw);
  1230. }
  1231. }
  1232. resubmit:
  1233. if (upriv->udev)
  1234. ezusb_submit_in_urb(upriv);
  1235. }
  1236. static inline void ezusb_delete(struct ezusb_priv *upriv)
  1237. {
  1238. struct net_device *dev;
  1239. struct list_head *item;
  1240. struct list_head *tmp_item;
  1241. unsigned long flags;
  1242. BUG_ON(in_interrupt());
  1243. BUG_ON(!upriv);
  1244. dev = upriv->dev;
  1245. mutex_lock(&upriv->mtx);
  1246. upriv->udev = NULL; /* No timer will be rearmed from here */
  1247. usb_kill_urb(upriv->read_urb);
  1248. spin_lock_irqsave(&upriv->req_lock, flags);
  1249. list_for_each_safe(item, tmp_item, &upriv->req_active) {
  1250. struct request_context *ctx;
  1251. int err;
  1252. ctx = list_entry(item, struct request_context, list);
  1253. atomic_inc(&ctx->refcount);
  1254. ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
  1255. err = usb_unlink_urb(ctx->outurb);
  1256. spin_unlock_irqrestore(&upriv->req_lock, flags);
  1257. if (err == -EINPROGRESS)
  1258. wait_for_completion(&ctx->done);
  1259. del_timer_sync(&ctx->timer);
  1260. /* FIXME: there is an slight chance for the irq handler to
  1261. * be running */
  1262. if (!list_empty(&ctx->list))
  1263. ezusb_ctx_complete(ctx);
  1264. ezusb_request_context_put(ctx);
  1265. spin_lock_irqsave(&upriv->req_lock, flags);
  1266. }
  1267. spin_unlock_irqrestore(&upriv->req_lock, flags);
  1268. list_for_each_safe(item, tmp_item, &upriv->req_pending)
  1269. ezusb_ctx_complete(list_entry(item,
  1270. struct request_context, list));
  1271. if (upriv->read_urb && upriv->read_urb->status == -EINPROGRESS)
  1272. printk(KERN_ERR PFX "Some URB in progress\n");
  1273. mutex_unlock(&upriv->mtx);
  1274. if (upriv->read_urb) {
  1275. kfree(upriv->read_urb->transfer_buffer);
  1276. usb_free_urb(upriv->read_urb);
  1277. }
  1278. kfree(upriv->bap_buf);
  1279. if (upriv->dev) {
  1280. struct orinoco_private *priv = ndev_priv(upriv->dev);
  1281. orinoco_if_del(priv);
  1282. free_orinocodev(priv);
  1283. }
  1284. }
  1285. static void ezusb_lock_irqsave(spinlock_t *lock,
  1286. unsigned long *flags) __acquires(lock)
  1287. {
  1288. spin_lock_bh(lock);
  1289. }
  1290. static void ezusb_unlock_irqrestore(spinlock_t *lock,
  1291. unsigned long *flags) __releases(lock)
  1292. {
  1293. spin_unlock_bh(lock);
  1294. }
  1295. static void ezusb_lock_irq(spinlock_t *lock) __acquires(lock)
  1296. {
  1297. spin_lock_bh(lock);
  1298. }
  1299. static void ezusb_unlock_irq(spinlock_t *lock) __releases(lock)
  1300. {
  1301. spin_unlock_bh(lock);
  1302. }
  1303. static const struct hermes_ops ezusb_ops = {
  1304. .init = ezusb_init,
  1305. .cmd_wait = ezusb_docmd_wait,
  1306. .init_cmd_wait = ezusb_doicmd_wait,
  1307. .allocate = ezusb_allocate,
  1308. .read_ltv = ezusb_read_ltv,
  1309. .write_ltv = ezusb_write_ltv,
  1310. .bap_pread = ezusb_bap_pread,
  1311. .read_pda = ezusb_read_pda,
  1312. .program_init = ezusb_program_init,
  1313. .program_end = ezusb_program_end,
  1314. .program = ezusb_program,
  1315. .lock_irqsave = ezusb_lock_irqsave,
  1316. .unlock_irqrestore = ezusb_unlock_irqrestore,
  1317. .lock_irq = ezusb_lock_irq,
  1318. .unlock_irq = ezusb_unlock_irq,
  1319. };
  1320. static const struct net_device_ops ezusb_netdev_ops = {
  1321. .ndo_open = orinoco_open,
  1322. .ndo_stop = orinoco_stop,
  1323. .ndo_start_xmit = ezusb_xmit,
  1324. .ndo_set_rx_mode = orinoco_set_multicast_list,
  1325. .ndo_change_mtu = orinoco_change_mtu,
  1326. .ndo_set_mac_address = eth_mac_addr,
  1327. .ndo_validate_addr = eth_validate_addr,
  1328. .ndo_tx_timeout = orinoco_tx_timeout,
  1329. .ndo_get_stats = orinoco_get_stats,
  1330. };
  1331. static int ezusb_probe(struct usb_interface *interface,
  1332. const struct usb_device_id *id)
  1333. {
  1334. struct usb_device *udev = interface_to_usbdev(interface);
  1335. struct orinoco_private *priv;
  1336. struct hermes *hw;
  1337. struct ezusb_priv *upriv = NULL;
  1338. struct usb_interface_descriptor *iface_desc;
  1339. struct usb_endpoint_descriptor *ep;
  1340. const struct firmware *fw_entry = NULL;
  1341. int retval = 0;
  1342. int i;
  1343. priv = alloc_orinocodev(sizeof(*upriv), &udev->dev,
  1344. ezusb_hard_reset, NULL);
  1345. if (!priv) {
  1346. err("Couldn't allocate orinocodev");
  1347. goto exit;
  1348. }
  1349. hw = &priv->hw;
  1350. upriv = priv->card;
  1351. mutex_init(&upriv->mtx);
  1352. spin_lock_init(&upriv->reply_count_lock);
  1353. spin_lock_init(&upriv->req_lock);
  1354. INIT_LIST_HEAD(&upriv->req_pending);
  1355. INIT_LIST_HEAD(&upriv->req_active);
  1356. upriv->udev = udev;
  1357. hw->iobase = (void __force __iomem *) &upriv->hermes_reg_fake;
  1358. hw->reg_spacing = HERMES_16BIT_REGSPACING;
  1359. hw->priv = upriv;
  1360. hw->ops = &ezusb_ops;
  1361. /* set up the endpoint information */
  1362. /* check out the endpoints */
  1363. iface_desc = &interface->altsetting[0].desc;
  1364. for (i = 0; i < iface_desc->bNumEndpoints; ++i) {
  1365. ep = &interface->altsetting[0].endpoint[i].desc;
  1366. if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
  1367. == USB_DIR_IN) &&
  1368. ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
  1369. == USB_ENDPOINT_XFER_BULK)) {
  1370. /* we found a bulk in endpoint */
  1371. if (upriv->read_urb != NULL) {
  1372. pr_warning("Found a second bulk in ep, ignored");
  1373. continue;
  1374. }
  1375. upriv->read_urb = usb_alloc_urb(0, GFP_KERNEL);
  1376. if (!upriv->read_urb) {
  1377. err("No free urbs available");
  1378. goto error;
  1379. }
  1380. if (le16_to_cpu(ep->wMaxPacketSize) != 64)
  1381. pr_warning("bulk in: wMaxPacketSize!= 64");
  1382. if (ep->bEndpointAddress != (2 | USB_DIR_IN))
  1383. pr_warning("bulk in: bEndpointAddress: %d",
  1384. ep->bEndpointAddress);
  1385. upriv->read_pipe = usb_rcvbulkpipe(udev,
  1386. ep->
  1387. bEndpointAddress);
  1388. upriv->read_urb->transfer_buffer =
  1389. kmalloc(BULK_BUF_SIZE, GFP_KERNEL);
  1390. if (!upriv->read_urb->transfer_buffer) {
  1391. err("Couldn't allocate IN buffer");
  1392. goto error;
  1393. }
  1394. }
  1395. if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
  1396. == USB_DIR_OUT) &&
  1397. ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
  1398. == USB_ENDPOINT_XFER_BULK)) {
  1399. /* we found a bulk out endpoint */
  1400. if (upriv->bap_buf != NULL) {
  1401. pr_warning("Found a second bulk out ep, ignored");
  1402. continue;
  1403. }
  1404. if (le16_to_cpu(ep->wMaxPacketSize) != 64)
  1405. pr_warning("bulk out: wMaxPacketSize != 64");
  1406. if (ep->bEndpointAddress != 2)
  1407. pr_warning("bulk out: bEndpointAddress: %d",
  1408. ep->bEndpointAddress);
  1409. upriv->write_pipe = usb_sndbulkpipe(udev,
  1410. ep->
  1411. bEndpointAddress);
  1412. upriv->bap_buf = kmalloc(BULK_BUF_SIZE, GFP_KERNEL);
  1413. if (!upriv->bap_buf) {
  1414. err("Couldn't allocate bulk_out_buffer");
  1415. goto error;
  1416. }
  1417. }
  1418. }
  1419. if (!upriv->bap_buf || !upriv->read_urb) {
  1420. err("Didn't find the required bulk endpoints");
  1421. goto error;
  1422. }
  1423. if (request_firmware(&fw_entry, "orinoco_ezusb_fw",
  1424. &interface->dev) == 0) {
  1425. firmware.size = fw_entry->size;
  1426. firmware.code = fw_entry->data;
  1427. }
  1428. if (firmware.size && firmware.code) {
  1429. if (ezusb_firmware_download(upriv, &firmware))
  1430. goto error;
  1431. } else {
  1432. err("No firmware to download");
  1433. goto error;
  1434. }
  1435. if (ezusb_hard_reset(priv) < 0) {
  1436. err("Cannot reset the device");
  1437. goto error;
  1438. }
  1439. /* If the firmware is already downloaded orinoco.c will call
  1440. * ezusb_init but if the firmware is not already there, that will make
  1441. * the kernel very unstable, so we try initializing here and quit in
  1442. * case of error */
  1443. if (ezusb_init(hw) < 0) {
  1444. err("Couldn't initialize the device");
  1445. err("Firmware may not be downloaded or may be wrong.");
  1446. goto error;
  1447. }
  1448. /* Initialise the main driver */
  1449. if (orinoco_init(priv) != 0) {
  1450. err("orinoco_init() failed\n");
  1451. goto error;
  1452. }
  1453. if (orinoco_if_add(priv, 0, 0, &ezusb_netdev_ops) != 0) {
  1454. upriv->dev = NULL;
  1455. err("%s: orinoco_if_add() failed", __func__);
  1456. goto error;
  1457. }
  1458. upriv->dev = priv->ndev;
  1459. goto exit;
  1460. error:
  1461. ezusb_delete(upriv);
  1462. if (upriv->dev) {
  1463. /* upriv->dev was 0, so ezusb_delete() didn't free it */
  1464. free_orinocodev(priv);
  1465. }
  1466. upriv = NULL;
  1467. retval = -EFAULT;
  1468. exit:
  1469. if (fw_entry) {
  1470. firmware.code = NULL;
  1471. firmware.size = 0;
  1472. release_firmware(fw_entry);
  1473. }
  1474. usb_set_intfdata(interface, upriv);
  1475. return retval;
  1476. }
  1477. static void ezusb_disconnect(struct usb_interface *intf)
  1478. {
  1479. struct ezusb_priv *upriv = usb_get_intfdata(intf);
  1480. usb_set_intfdata(intf, NULL);
  1481. ezusb_delete(upriv);
  1482. printk(KERN_INFO PFX "Disconnected\n");
  1483. }
  1484. /* usb specific object needed to register this driver with the usb subsystem */
  1485. static struct usb_driver orinoco_driver = {
  1486. .name = DRIVER_NAME,
  1487. .probe = ezusb_probe,
  1488. .disconnect = ezusb_disconnect,
  1489. .id_table = ezusb_table,
  1490. .disable_hub_initiated_lpm = 1,
  1491. };
  1492. module_usb_driver(orinoco_driver);
  1493. MODULE_AUTHOR("Manuel Estrada Sainz");
  1494. MODULE_DESCRIPTION("Driver for Orinoco wireless LAN cards using EZUSB bridge");
  1495. MODULE_LICENSE("Dual MPL/GPL");