atusb.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  1. /*
  2. * atusb.c - Driver for the ATUSB IEEE 802.15.4 dongle
  3. *
  4. * Written 2013 by Werner Almesberger <werner@almesberger.net>
  5. *
  6. * Copyright (c) 2015 - 2016 Stefan Schmidt <stefan@datenfreihafen.org>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation, version 2
  11. *
  12. * Based on at86rf230.c and spi_atusb.c.
  13. * at86rf230.c is
  14. * Copyright (C) 2009 Siemens AG
  15. * Written by: Dmitry Eremin-Solenikov <dmitry.baryshkov@siemens.com>
  16. *
  17. * spi_atusb.c is
  18. * Copyright (c) 2011 Richard Sharpe <realrichardsharpe@gmail.com>
  19. * Copyright (c) 2011 Stefan Schmidt <stefan@datenfreihafen.org>
  20. * Copyright (c) 2011 Werner Almesberger <werner@almesberger.net>
  21. *
  22. * USB initialization is
  23. * Copyright (c) 2013 Alexander Aring <alex.aring@gmail.com>
  24. *
  25. * Busware HUL support is
  26. * Copyright (c) 2017 Josef Filzmaier <j.filzmaier@gmx.at>
  27. */
  28. #include <linux/kernel.h>
  29. #include <linux/slab.h>
  30. #include <linux/module.h>
  31. #include <linux/jiffies.h>
  32. #include <linux/usb.h>
  33. #include <linux/skbuff.h>
  34. #include <net/cfg802154.h>
  35. #include <net/mac802154.h>
  36. #include "at86rf230.h"
  37. #include "atusb.h"
  38. #define ATUSB_JEDEC_ATMEL 0x1f /* JEDEC manufacturer ID */
  39. #define ATUSB_NUM_RX_URBS 4 /* allow for a bit of local latency */
  40. #define ATUSB_ALLOC_DELAY_MS 100 /* delay after failed allocation */
  41. #define ATUSB_TX_TIMEOUT_MS 200 /* on the air timeout */
  42. struct atusb {
  43. struct ieee802154_hw *hw;
  44. struct usb_device *usb_dev;
  45. struct atusb_chip_data *data;
  46. int shutdown; /* non-zero if shutting down */
  47. int err; /* set by first error */
  48. /* RX variables */
  49. struct delayed_work work; /* memory allocations */
  50. struct usb_anchor idle_urbs; /* URBs waiting to be submitted */
  51. struct usb_anchor rx_urbs; /* URBs waiting for reception */
  52. /* TX variables */
  53. struct usb_ctrlrequest tx_dr;
  54. struct urb *tx_urb;
  55. struct sk_buff *tx_skb;
  56. u8 tx_ack_seq; /* current TX ACK sequence number */
  57. /* Firmware variable */
  58. unsigned char fw_ver_maj; /* Firmware major version number */
  59. unsigned char fw_ver_min; /* Firmware minor version number */
  60. unsigned char fw_hw_type; /* Firmware hardware type */
  61. };
  62. struct atusb_chip_data {
  63. u16 t_channel_switch;
  64. int rssi_base_val;
  65. int (*set_channel)(struct ieee802154_hw*, u8, u8);
  66. int (*set_txpower)(struct ieee802154_hw*, s32);
  67. };
  68. /* ----- USB commands without data ----------------------------------------- */
  69. /* To reduce the number of error checks in the code, we record the first error
  70. * in atusb->err and reject all subsequent requests until the error is cleared.
  71. */
  72. static int atusb_control_msg(struct atusb *atusb, unsigned int pipe,
  73. __u8 request, __u8 requesttype,
  74. __u16 value, __u16 index,
  75. void *data, __u16 size, int timeout)
  76. {
  77. struct usb_device *usb_dev = atusb->usb_dev;
  78. int ret;
  79. if (atusb->err)
  80. return atusb->err;
  81. ret = usb_control_msg(usb_dev, pipe, request, requesttype,
  82. value, index, data, size, timeout);
  83. if (ret < 0) {
  84. atusb->err = ret;
  85. dev_err(&usb_dev->dev,
  86. "%s: req 0x%02x val 0x%x idx 0x%x, error %d\n",
  87. __func__, request, value, index, ret);
  88. }
  89. return ret;
  90. }
  91. static int atusb_command(struct atusb *atusb, u8 cmd, u8 arg)
  92. {
  93. struct usb_device *usb_dev = atusb->usb_dev;
  94. dev_dbg(&usb_dev->dev, "%s: cmd = 0x%x\n", __func__, cmd);
  95. return atusb_control_msg(atusb, usb_sndctrlpipe(usb_dev, 0),
  96. cmd, ATUSB_REQ_TO_DEV, arg, 0, NULL, 0, 1000);
  97. }
  98. static int atusb_write_reg(struct atusb *atusb, u8 reg, u8 value)
  99. {
  100. struct usb_device *usb_dev = atusb->usb_dev;
  101. dev_dbg(&usb_dev->dev, "%s: 0x%02x <- 0x%02x\n", __func__, reg, value);
  102. return atusb_control_msg(atusb, usb_sndctrlpipe(usb_dev, 0),
  103. ATUSB_REG_WRITE, ATUSB_REQ_TO_DEV,
  104. value, reg, NULL, 0, 1000);
  105. }
  106. static int atusb_read_reg(struct atusb *atusb, u8 reg)
  107. {
  108. struct usb_device *usb_dev = atusb->usb_dev;
  109. int ret;
  110. u8 *buffer;
  111. u8 value;
  112. buffer = kmalloc(1, GFP_KERNEL);
  113. if (!buffer)
  114. return -ENOMEM;
  115. dev_dbg(&usb_dev->dev, "%s: reg = 0x%x\n", __func__, reg);
  116. ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
  117. ATUSB_REG_READ, ATUSB_REQ_FROM_DEV,
  118. 0, reg, buffer, 1, 1000);
  119. if (ret >= 0) {
  120. value = buffer[0];
  121. kfree(buffer);
  122. return value;
  123. } else {
  124. kfree(buffer);
  125. return ret;
  126. }
  127. }
  128. static int atusb_write_subreg(struct atusb *atusb, u8 reg, u8 mask,
  129. u8 shift, u8 value)
  130. {
  131. struct usb_device *usb_dev = atusb->usb_dev;
  132. u8 orig, tmp;
  133. int ret = 0;
  134. dev_dbg(&usb_dev->dev, "%s: 0x%02x <- 0x%02x\n", __func__, reg, value);
  135. orig = atusb_read_reg(atusb, reg);
  136. /* Write the value only into that part of the register which is allowed
  137. * by the mask. All other bits stay as before.
  138. */
  139. tmp = orig & ~mask;
  140. tmp |= (value << shift) & mask;
  141. if (tmp != orig)
  142. ret = atusb_write_reg(atusb, reg, tmp);
  143. return ret;
  144. }
  145. static int atusb_read_subreg(struct atusb *lp,
  146. unsigned int addr, unsigned int mask,
  147. unsigned int shift)
  148. {
  149. int rc;
  150. rc = atusb_read_reg(lp, addr);
  151. rc = (rc & mask) >> shift;
  152. return rc;
  153. }
  154. static int atusb_get_and_clear_error(struct atusb *atusb)
  155. {
  156. int err = atusb->err;
  157. atusb->err = 0;
  158. return err;
  159. }
  160. /* ----- skb allocation ---------------------------------------------------- */
  161. #define MAX_PSDU 127
  162. #define MAX_RX_XFER (1 + MAX_PSDU + 2 + 1) /* PHR+PSDU+CRC+LQI */
  163. #define SKB_ATUSB(skb) (*(struct atusb **)(skb)->cb)
  164. static void atusb_in(struct urb *urb);
  165. static int atusb_submit_rx_urb(struct atusb *atusb, struct urb *urb)
  166. {
  167. struct usb_device *usb_dev = atusb->usb_dev;
  168. struct sk_buff *skb = urb->context;
  169. int ret;
  170. if (!skb) {
  171. skb = alloc_skb(MAX_RX_XFER, GFP_KERNEL);
  172. if (!skb) {
  173. dev_warn_ratelimited(&usb_dev->dev,
  174. "atusb_in: can't allocate skb\n");
  175. return -ENOMEM;
  176. }
  177. skb_put(skb, MAX_RX_XFER);
  178. SKB_ATUSB(skb) = atusb;
  179. }
  180. usb_fill_bulk_urb(urb, usb_dev, usb_rcvbulkpipe(usb_dev, 1),
  181. skb->data, MAX_RX_XFER, atusb_in, skb);
  182. usb_anchor_urb(urb, &atusb->rx_urbs);
  183. ret = usb_submit_urb(urb, GFP_KERNEL);
  184. if (ret) {
  185. usb_unanchor_urb(urb);
  186. kfree_skb(skb);
  187. urb->context = NULL;
  188. }
  189. return ret;
  190. }
  191. static void atusb_work_urbs(struct work_struct *work)
  192. {
  193. struct atusb *atusb =
  194. container_of(to_delayed_work(work), struct atusb, work);
  195. struct usb_device *usb_dev = atusb->usb_dev;
  196. struct urb *urb;
  197. int ret;
  198. if (atusb->shutdown)
  199. return;
  200. do {
  201. urb = usb_get_from_anchor(&atusb->idle_urbs);
  202. if (!urb)
  203. return;
  204. ret = atusb_submit_rx_urb(atusb, urb);
  205. } while (!ret);
  206. usb_anchor_urb(urb, &atusb->idle_urbs);
  207. dev_warn_ratelimited(&usb_dev->dev,
  208. "atusb_in: can't allocate/submit URB (%d)\n", ret);
  209. schedule_delayed_work(&atusb->work,
  210. msecs_to_jiffies(ATUSB_ALLOC_DELAY_MS) + 1);
  211. }
  212. /* ----- Asynchronous USB -------------------------------------------------- */
  213. static void atusb_tx_done(struct atusb *atusb, u8 seq)
  214. {
  215. struct usb_device *usb_dev = atusb->usb_dev;
  216. u8 expect = atusb->tx_ack_seq;
  217. dev_dbg(&usb_dev->dev, "%s (0x%02x/0x%02x)\n", __func__, seq, expect);
  218. if (seq == expect) {
  219. /* TODO check for ifs handling in firmware */
  220. ieee802154_xmit_complete(atusb->hw, atusb->tx_skb, false);
  221. } else {
  222. /* TODO I experience this case when atusb has a tx complete
  223. * irq before probing, we should fix the firmware it's an
  224. * unlikely case now that seq == expect is then true, but can
  225. * happen and fail with a tx_skb = NULL;
  226. */
  227. ieee802154_wake_queue(atusb->hw);
  228. if (atusb->tx_skb)
  229. dev_kfree_skb_irq(atusb->tx_skb);
  230. }
  231. }
  232. static void atusb_in_good(struct urb *urb)
  233. {
  234. struct usb_device *usb_dev = urb->dev;
  235. struct sk_buff *skb = urb->context;
  236. struct atusb *atusb = SKB_ATUSB(skb);
  237. u8 len, lqi;
  238. if (!urb->actual_length) {
  239. dev_dbg(&usb_dev->dev, "atusb_in: zero-sized URB ?\n");
  240. return;
  241. }
  242. len = *skb->data;
  243. if (urb->actual_length == 1) {
  244. atusb_tx_done(atusb, len);
  245. return;
  246. }
  247. if (len + 1 > urb->actual_length - 1) {
  248. dev_dbg(&usb_dev->dev, "atusb_in: frame len %d+1 > URB %u-1\n",
  249. len, urb->actual_length);
  250. return;
  251. }
  252. if (!ieee802154_is_valid_psdu_len(len)) {
  253. dev_dbg(&usb_dev->dev, "atusb_in: frame corrupted\n");
  254. return;
  255. }
  256. lqi = skb->data[len + 1];
  257. dev_dbg(&usb_dev->dev, "atusb_in: rx len %d lqi 0x%02x\n", len, lqi);
  258. skb_pull(skb, 1); /* remove PHR */
  259. skb_trim(skb, len); /* get payload only */
  260. ieee802154_rx_irqsafe(atusb->hw, skb, lqi);
  261. urb->context = NULL; /* skb is gone */
  262. }
  263. static void atusb_in(struct urb *urb)
  264. {
  265. struct usb_device *usb_dev = urb->dev;
  266. struct sk_buff *skb = urb->context;
  267. struct atusb *atusb = SKB_ATUSB(skb);
  268. dev_dbg(&usb_dev->dev, "%s: status %d len %d\n", __func__,
  269. urb->status, urb->actual_length);
  270. if (urb->status) {
  271. if (urb->status == -ENOENT) { /* being killed */
  272. kfree_skb(skb);
  273. urb->context = NULL;
  274. return;
  275. }
  276. dev_dbg(&usb_dev->dev, "%s: URB error %d\n", __func__, urb->status);
  277. } else {
  278. atusb_in_good(urb);
  279. }
  280. usb_anchor_urb(urb, &atusb->idle_urbs);
  281. if (!atusb->shutdown)
  282. schedule_delayed_work(&atusb->work, 0);
  283. }
  284. /* ----- URB allocation/deallocation --------------------------------------- */
  285. static void atusb_free_urbs(struct atusb *atusb)
  286. {
  287. struct urb *urb;
  288. while (1) {
  289. urb = usb_get_from_anchor(&atusb->idle_urbs);
  290. if (!urb)
  291. break;
  292. kfree_skb(urb->context);
  293. usb_free_urb(urb);
  294. }
  295. }
  296. static int atusb_alloc_urbs(struct atusb *atusb, int n)
  297. {
  298. struct urb *urb;
  299. while (n) {
  300. urb = usb_alloc_urb(0, GFP_KERNEL);
  301. if (!urb) {
  302. atusb_free_urbs(atusb);
  303. return -ENOMEM;
  304. }
  305. usb_anchor_urb(urb, &atusb->idle_urbs);
  306. n--;
  307. }
  308. return 0;
  309. }
  310. /* ----- IEEE 802.15.4 interface operations -------------------------------- */
  311. static void atusb_xmit_complete(struct urb *urb)
  312. {
  313. dev_dbg(&urb->dev->dev, "atusb_xmit urb completed");
  314. }
  315. static int atusb_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
  316. {
  317. struct atusb *atusb = hw->priv;
  318. struct usb_device *usb_dev = atusb->usb_dev;
  319. int ret;
  320. dev_dbg(&usb_dev->dev, "%s (%d)\n", __func__, skb->len);
  321. atusb->tx_skb = skb;
  322. atusb->tx_ack_seq++;
  323. atusb->tx_dr.wIndex = cpu_to_le16(atusb->tx_ack_seq);
  324. atusb->tx_dr.wLength = cpu_to_le16(skb->len);
  325. usb_fill_control_urb(atusb->tx_urb, usb_dev,
  326. usb_sndctrlpipe(usb_dev, 0),
  327. (unsigned char *)&atusb->tx_dr, skb->data,
  328. skb->len, atusb_xmit_complete, NULL);
  329. ret = usb_submit_urb(atusb->tx_urb, GFP_ATOMIC);
  330. dev_dbg(&usb_dev->dev, "%s done (%d)\n", __func__, ret);
  331. return ret;
  332. }
  333. static int atusb_ed(struct ieee802154_hw *hw, u8 *level)
  334. {
  335. WARN_ON(!level);
  336. *level = 0xbe;
  337. return 0;
  338. }
  339. static int atusb_set_hw_addr_filt(struct ieee802154_hw *hw,
  340. struct ieee802154_hw_addr_filt *filt,
  341. unsigned long changed)
  342. {
  343. struct atusb *atusb = hw->priv;
  344. struct device *dev = &atusb->usb_dev->dev;
  345. if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
  346. u16 addr = le16_to_cpu(filt->short_addr);
  347. dev_vdbg(dev, "%s called for saddr\n", __func__);
  348. atusb_write_reg(atusb, RG_SHORT_ADDR_0, addr);
  349. atusb_write_reg(atusb, RG_SHORT_ADDR_1, addr >> 8);
  350. }
  351. if (changed & IEEE802154_AFILT_PANID_CHANGED) {
  352. u16 pan = le16_to_cpu(filt->pan_id);
  353. dev_vdbg(dev, "%s called for pan id\n", __func__);
  354. atusb_write_reg(atusb, RG_PAN_ID_0, pan);
  355. atusb_write_reg(atusb, RG_PAN_ID_1, pan >> 8);
  356. }
  357. if (changed & IEEE802154_AFILT_IEEEADDR_CHANGED) {
  358. u8 i, addr[IEEE802154_EXTENDED_ADDR_LEN];
  359. memcpy(addr, &filt->ieee_addr, IEEE802154_EXTENDED_ADDR_LEN);
  360. dev_vdbg(dev, "%s called for IEEE addr\n", __func__);
  361. for (i = 0; i < 8; i++)
  362. atusb_write_reg(atusb, RG_IEEE_ADDR_0 + i, addr[i]);
  363. }
  364. if (changed & IEEE802154_AFILT_PANC_CHANGED) {
  365. dev_vdbg(dev, "%s called for panc change\n", __func__);
  366. if (filt->pan_coord)
  367. atusb_write_subreg(atusb, SR_AACK_I_AM_COORD, 1);
  368. else
  369. atusb_write_subreg(atusb, SR_AACK_I_AM_COORD, 0);
  370. }
  371. return atusb_get_and_clear_error(atusb);
  372. }
  373. static int atusb_start(struct ieee802154_hw *hw)
  374. {
  375. struct atusb *atusb = hw->priv;
  376. struct usb_device *usb_dev = atusb->usb_dev;
  377. int ret;
  378. dev_dbg(&usb_dev->dev, "%s\n", __func__);
  379. schedule_delayed_work(&atusb->work, 0);
  380. atusb_command(atusb, ATUSB_RX_MODE, 1);
  381. ret = atusb_get_and_clear_error(atusb);
  382. if (ret < 0)
  383. usb_kill_anchored_urbs(&atusb->idle_urbs);
  384. return ret;
  385. }
  386. static void atusb_stop(struct ieee802154_hw *hw)
  387. {
  388. struct atusb *atusb = hw->priv;
  389. struct usb_device *usb_dev = atusb->usb_dev;
  390. dev_dbg(&usb_dev->dev, "%s\n", __func__);
  391. usb_kill_anchored_urbs(&atusb->idle_urbs);
  392. atusb_command(atusb, ATUSB_RX_MODE, 0);
  393. atusb_get_and_clear_error(atusb);
  394. }
  395. #define ATUSB_MAX_TX_POWERS 0xF
  396. static const s32 atusb_powers[ATUSB_MAX_TX_POWERS + 1] = {
  397. 300, 280, 230, 180, 130, 70, 0, -100, -200, -300, -400, -500, -700,
  398. -900, -1200, -1700,
  399. };
  400. static int
  401. atusb_txpower(struct ieee802154_hw *hw, s32 mbm)
  402. {
  403. struct atusb *atusb = hw->priv;
  404. if (atusb->data)
  405. return atusb->data->set_txpower(hw, mbm);
  406. else
  407. return -ENOTSUPP;
  408. }
  409. static int
  410. atusb_set_txpower(struct ieee802154_hw *hw, s32 mbm)
  411. {
  412. struct atusb *atusb = hw->priv;
  413. u32 i;
  414. for (i = 0; i < hw->phy->supported.tx_powers_size; i++) {
  415. if (hw->phy->supported.tx_powers[i] == mbm)
  416. return atusb_write_subreg(atusb, SR_TX_PWR_23X, i);
  417. }
  418. return -EINVAL;
  419. }
  420. static int
  421. hulusb_set_txpower(struct ieee802154_hw *hw, s32 mbm)
  422. {
  423. u32 i;
  424. for (i = 0; i < hw->phy->supported.tx_powers_size; i++) {
  425. if (hw->phy->supported.tx_powers[i] == mbm)
  426. return atusb_write_subreg(hw->priv, SR_TX_PWR_212, i);
  427. }
  428. return -EINVAL;
  429. }
  430. #define ATUSB_MAX_ED_LEVELS 0xF
  431. static const s32 atusb_ed_levels[ATUSB_MAX_ED_LEVELS + 1] = {
  432. -9100, -8900, -8700, -8500, -8300, -8100, -7900, -7700, -7500, -7300,
  433. -7100, -6900, -6700, -6500, -6300, -6100,
  434. };
  435. #define AT86RF212_MAX_TX_POWERS 0x1F
  436. static const s32 at86rf212_powers[AT86RF212_MAX_TX_POWERS + 1] = {
  437. 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700,
  438. -800, -900, -1000, -1100, -1200, -1300, -1400, -1500, -1600, -1700,
  439. -1800, -1900, -2000, -2100, -2200, -2300, -2400, -2500, -2600,
  440. };
  441. #define AT86RF2XX_MAX_ED_LEVELS 0xF
  442. static const s32 at86rf212_ed_levels_100[AT86RF2XX_MAX_ED_LEVELS + 1] = {
  443. -10000, -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200,
  444. -8000, -7800, -7600, -7400, -7200, -7000,
  445. };
  446. static const s32 at86rf212_ed_levels_98[AT86RF2XX_MAX_ED_LEVELS + 1] = {
  447. -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200, -8000,
  448. -7800, -7600, -7400, -7200, -7000, -6800,
  449. };
  450. static int
  451. atusb_set_cca_mode(struct ieee802154_hw *hw, const struct wpan_phy_cca *cca)
  452. {
  453. struct atusb *atusb = hw->priv;
  454. u8 val;
  455. /* mapping 802.15.4 to driver spec */
  456. switch (cca->mode) {
  457. case NL802154_CCA_ENERGY:
  458. val = 1;
  459. break;
  460. case NL802154_CCA_CARRIER:
  461. val = 2;
  462. break;
  463. case NL802154_CCA_ENERGY_CARRIER:
  464. switch (cca->opt) {
  465. case NL802154_CCA_OPT_ENERGY_CARRIER_AND:
  466. val = 3;
  467. break;
  468. case NL802154_CCA_OPT_ENERGY_CARRIER_OR:
  469. val = 0;
  470. break;
  471. default:
  472. return -EINVAL;
  473. }
  474. break;
  475. default:
  476. return -EINVAL;
  477. }
  478. return atusb_write_subreg(atusb, SR_CCA_MODE, val);
  479. }
  480. static int hulusb_set_cca_ed_level(struct atusb *lp, int rssi_base_val)
  481. {
  482. unsigned int cca_ed_thres;
  483. cca_ed_thres = atusb_read_subreg(lp, SR_CCA_ED_THRES);
  484. switch (rssi_base_val) {
  485. case -98:
  486. lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_98;
  487. lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_98);
  488. lp->hw->phy->cca_ed_level = at86rf212_ed_levels_98[cca_ed_thres];
  489. break;
  490. case -100:
  491. lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
  492. lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
  493. lp->hw->phy->cca_ed_level = at86rf212_ed_levels_100[cca_ed_thres];
  494. break;
  495. default:
  496. WARN_ON(1);
  497. }
  498. return 0;
  499. }
  500. static int
  501. atusb_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
  502. {
  503. struct atusb *atusb = hw->priv;
  504. u32 i;
  505. for (i = 0; i < hw->phy->supported.cca_ed_levels_size; i++) {
  506. if (hw->phy->supported.cca_ed_levels[i] == mbm)
  507. return atusb_write_subreg(atusb, SR_CCA_ED_THRES, i);
  508. }
  509. return -EINVAL;
  510. }
  511. static int atusb_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
  512. {
  513. struct atusb *atusb = hw->priv;
  514. int ret = -ENOTSUPP;
  515. if (atusb->data) {
  516. ret = atusb->data->set_channel(hw, page, channel);
  517. /* @@@ ugly synchronization */
  518. msleep(atusb->data->t_channel_switch);
  519. }
  520. return ret;
  521. }
  522. static int atusb_set_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
  523. {
  524. struct atusb *atusb = hw->priv;
  525. int ret;
  526. ret = atusb_write_subreg(atusb, SR_CHANNEL, channel);
  527. if (ret < 0)
  528. return ret;
  529. return 0;
  530. }
  531. static int hulusb_set_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
  532. {
  533. int rc;
  534. int rssi_base_val;
  535. struct atusb *lp = hw->priv;
  536. if (channel == 0)
  537. rc = atusb_write_subreg(lp, SR_SUB_MODE, 0);
  538. else
  539. rc = atusb_write_subreg(lp, SR_SUB_MODE, 1);
  540. if (rc < 0)
  541. return rc;
  542. if (page == 0) {
  543. rc = atusb_write_subreg(lp, SR_BPSK_QPSK, 0);
  544. rssi_base_val = -100;
  545. } else {
  546. rc = atusb_write_subreg(lp, SR_BPSK_QPSK, 1);
  547. rssi_base_val = -98;
  548. }
  549. if (rc < 0)
  550. return rc;
  551. rc = hulusb_set_cca_ed_level(lp, rssi_base_val);
  552. if (rc < 0)
  553. return rc;
  554. /* This sets the symbol_duration according frequency on the 212.
  555. * TODO move this handling while set channel and page in cfg802154.
  556. * We can do that, this timings are according 802.15.4 standard.
  557. * If we do that in cfg802154, this is a more generic calculation.
  558. *
  559. * This should also protected from ifs_timer. Means cancel timer and
  560. * init with a new value. For now, this is okay.
  561. */
  562. if (channel == 0) {
  563. if (page == 0) {
  564. /* SUB:0 and BPSK:0 -> BPSK-20 */
  565. lp->hw->phy->symbol_duration = 50;
  566. } else {
  567. /* SUB:1 and BPSK:0 -> BPSK-40 */
  568. lp->hw->phy->symbol_duration = 25;
  569. }
  570. } else {
  571. if (page == 0)
  572. /* SUB:0 and BPSK:1 -> OQPSK-100/200/400 */
  573. lp->hw->phy->symbol_duration = 40;
  574. else
  575. /* SUB:1 and BPSK:1 -> OQPSK-250/500/1000 */
  576. lp->hw->phy->symbol_duration = 16;
  577. }
  578. lp->hw->phy->lifs_period = IEEE802154_LIFS_PERIOD *
  579. lp->hw->phy->symbol_duration;
  580. lp->hw->phy->sifs_period = IEEE802154_SIFS_PERIOD *
  581. lp->hw->phy->symbol_duration;
  582. return atusb_write_subreg(lp, SR_CHANNEL, channel);
  583. }
  584. static int
  585. atusb_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be, u8 retries)
  586. {
  587. struct atusb *atusb = hw->priv;
  588. int ret;
  589. ret = atusb_write_subreg(atusb, SR_MIN_BE, min_be);
  590. if (ret)
  591. return ret;
  592. ret = atusb_write_subreg(atusb, SR_MAX_BE, max_be);
  593. if (ret)
  594. return ret;
  595. return atusb_write_subreg(atusb, SR_MAX_CSMA_RETRIES, retries);
  596. }
  597. static int
  598. hulusb_set_lbt(struct ieee802154_hw *hw, bool on)
  599. {
  600. struct atusb *atusb = hw->priv;
  601. return atusb_write_subreg(atusb, SR_CSMA_LBT_MODE, on);
  602. }
  603. static int
  604. atusb_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
  605. {
  606. struct atusb *atusb = hw->priv;
  607. return atusb_write_subreg(atusb, SR_MAX_FRAME_RETRIES, retries);
  608. }
  609. static int
  610. atusb_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
  611. {
  612. struct atusb *atusb = hw->priv;
  613. int ret;
  614. if (on) {
  615. ret = atusb_write_subreg(atusb, SR_AACK_DIS_ACK, 1);
  616. if (ret < 0)
  617. return ret;
  618. ret = atusb_write_subreg(atusb, SR_AACK_PROM_MODE, 1);
  619. if (ret < 0)
  620. return ret;
  621. } else {
  622. ret = atusb_write_subreg(atusb, SR_AACK_PROM_MODE, 0);
  623. if (ret < 0)
  624. return ret;
  625. ret = atusb_write_subreg(atusb, SR_AACK_DIS_ACK, 0);
  626. if (ret < 0)
  627. return ret;
  628. }
  629. return 0;
  630. }
  631. static struct atusb_chip_data atusb_chip_data = {
  632. .t_channel_switch = 1,
  633. .rssi_base_val = -91,
  634. .set_txpower = atusb_set_txpower,
  635. .set_channel = atusb_set_channel,
  636. };
  637. static struct atusb_chip_data hulusb_chip_data = {
  638. .t_channel_switch = 11,
  639. .rssi_base_val = -100,
  640. .set_txpower = hulusb_set_txpower,
  641. .set_channel = hulusb_set_channel,
  642. };
  643. static const struct ieee802154_ops atusb_ops = {
  644. .owner = THIS_MODULE,
  645. .xmit_async = atusb_xmit,
  646. .ed = atusb_ed,
  647. .set_channel = atusb_channel,
  648. .start = atusb_start,
  649. .stop = atusb_stop,
  650. .set_hw_addr_filt = atusb_set_hw_addr_filt,
  651. .set_txpower = atusb_txpower,
  652. .set_lbt = hulusb_set_lbt,
  653. .set_cca_mode = atusb_set_cca_mode,
  654. .set_cca_ed_level = atusb_set_cca_ed_level,
  655. .set_csma_params = atusb_set_csma_params,
  656. .set_frame_retries = atusb_set_frame_retries,
  657. .set_promiscuous_mode = atusb_set_promiscuous_mode,
  658. };
  659. /* ----- Firmware and chip version information ----------------------------- */
  660. static int atusb_get_and_show_revision(struct atusb *atusb)
  661. {
  662. struct usb_device *usb_dev = atusb->usb_dev;
  663. char *hw_name;
  664. unsigned char *buffer;
  665. int ret;
  666. buffer = kmalloc(3, GFP_KERNEL);
  667. if (!buffer)
  668. return -ENOMEM;
  669. /* Get a couple of the ATMega Firmware values */
  670. ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
  671. ATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0,
  672. buffer, 3, 1000);
  673. if (ret >= 0) {
  674. atusb->fw_ver_maj = buffer[0];
  675. atusb->fw_ver_min = buffer[1];
  676. atusb->fw_hw_type = buffer[2];
  677. switch (atusb->fw_hw_type) {
  678. case ATUSB_HW_TYPE_100813:
  679. case ATUSB_HW_TYPE_101216:
  680. case ATUSB_HW_TYPE_110131:
  681. hw_name = "ATUSB";
  682. atusb->data = &atusb_chip_data;
  683. break;
  684. case ATUSB_HW_TYPE_RZUSB:
  685. hw_name = "RZUSB";
  686. atusb->data = &atusb_chip_data;
  687. break;
  688. case ATUSB_HW_TYPE_HULUSB:
  689. hw_name = "HULUSB";
  690. atusb->data = &hulusb_chip_data;
  691. break;
  692. default:
  693. hw_name = "UNKNOWN";
  694. atusb->err = -ENOTSUPP;
  695. ret = -ENOTSUPP;
  696. break;
  697. }
  698. dev_info(&usb_dev->dev,
  699. "Firmware: major: %u, minor: %u, hardware type: %s (%d)\n",
  700. atusb->fw_ver_maj, atusb->fw_ver_min, hw_name,
  701. atusb->fw_hw_type);
  702. }
  703. if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 2) {
  704. dev_info(&usb_dev->dev,
  705. "Firmware version (%u.%u) predates our first public release.",
  706. atusb->fw_ver_maj, atusb->fw_ver_min);
  707. dev_info(&usb_dev->dev, "Please update to version 0.2 or newer");
  708. }
  709. kfree(buffer);
  710. return ret;
  711. }
  712. static int atusb_get_and_show_build(struct atusb *atusb)
  713. {
  714. struct usb_device *usb_dev = atusb->usb_dev;
  715. char *build;
  716. int ret;
  717. build = kmalloc(ATUSB_BUILD_SIZE + 1, GFP_KERNEL);
  718. if (!build)
  719. return -ENOMEM;
  720. ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
  721. ATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0,
  722. build, ATUSB_BUILD_SIZE, 1000);
  723. if (ret >= 0) {
  724. build[ret] = 0;
  725. dev_info(&usb_dev->dev, "Firmware: build %s\n", build);
  726. }
  727. kfree(build);
  728. return ret;
  729. }
  730. static int atusb_get_and_conf_chip(struct atusb *atusb)
  731. {
  732. struct usb_device *usb_dev = atusb->usb_dev;
  733. u8 man_id_0, man_id_1, part_num, version_num;
  734. const char *chip;
  735. struct ieee802154_hw *hw = atusb->hw;
  736. man_id_0 = atusb_read_reg(atusb, RG_MAN_ID_0);
  737. man_id_1 = atusb_read_reg(atusb, RG_MAN_ID_1);
  738. part_num = atusb_read_reg(atusb, RG_PART_NUM);
  739. version_num = atusb_read_reg(atusb, RG_VERSION_NUM);
  740. if (atusb->err)
  741. return atusb->err;
  742. hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
  743. IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS;
  744. hw->phy->flags = WPAN_PHY_FLAG_TXPOWER | WPAN_PHY_FLAG_CCA_ED_LEVEL |
  745. WPAN_PHY_FLAG_CCA_MODE;
  746. hw->phy->supported.cca_modes = BIT(NL802154_CCA_ENERGY) |
  747. BIT(NL802154_CCA_CARRIER) |
  748. BIT(NL802154_CCA_ENERGY_CARRIER);
  749. hw->phy->supported.cca_opts = BIT(NL802154_CCA_OPT_ENERGY_CARRIER_AND) |
  750. BIT(NL802154_CCA_OPT_ENERGY_CARRIER_OR);
  751. hw->phy->cca.mode = NL802154_CCA_ENERGY;
  752. hw->phy->current_page = 0;
  753. if ((man_id_1 << 8 | man_id_0) != ATUSB_JEDEC_ATMEL) {
  754. dev_err(&usb_dev->dev,
  755. "non-Atmel transceiver xxxx%02x%02x\n",
  756. man_id_1, man_id_0);
  757. goto fail;
  758. }
  759. switch (part_num) {
  760. case 2:
  761. chip = "AT86RF230";
  762. atusb->hw->phy->supported.channels[0] = 0x7FFF800;
  763. atusb->hw->phy->current_channel = 11; /* reset default */
  764. atusb->hw->phy->symbol_duration = 16;
  765. atusb->hw->phy->supported.tx_powers = atusb_powers;
  766. atusb->hw->phy->supported.tx_powers_size = ARRAY_SIZE(atusb_powers);
  767. hw->phy->supported.cca_ed_levels = atusb_ed_levels;
  768. hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(atusb_ed_levels);
  769. break;
  770. case 3:
  771. chip = "AT86RF231";
  772. atusb->hw->phy->supported.channels[0] = 0x7FFF800;
  773. atusb->hw->phy->current_channel = 11; /* reset default */
  774. atusb->hw->phy->symbol_duration = 16;
  775. atusb->hw->phy->supported.tx_powers = atusb_powers;
  776. atusb->hw->phy->supported.tx_powers_size = ARRAY_SIZE(atusb_powers);
  777. hw->phy->supported.cca_ed_levels = atusb_ed_levels;
  778. hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(atusb_ed_levels);
  779. break;
  780. case 7:
  781. chip = "AT86RF212";
  782. atusb->hw->flags |= IEEE802154_HW_LBT;
  783. atusb->hw->phy->supported.channels[0] = 0x00007FF;
  784. atusb->hw->phy->supported.channels[2] = 0x00007FF;
  785. atusb->hw->phy->current_channel = 5;
  786. atusb->hw->phy->symbol_duration = 25;
  787. atusb->hw->phy->supported.lbt = NL802154_SUPPORTED_BOOL_BOTH;
  788. atusb->hw->phy->supported.tx_powers = at86rf212_powers;
  789. atusb->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf212_powers);
  790. atusb->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
  791. atusb->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
  792. break;
  793. default:
  794. dev_err(&usb_dev->dev,
  795. "unexpected transceiver, part 0x%02x version 0x%02x\n",
  796. part_num, version_num);
  797. goto fail;
  798. }
  799. hw->phy->transmit_power = hw->phy->supported.tx_powers[0];
  800. hw->phy->cca_ed_level = hw->phy->supported.cca_ed_levels[7];
  801. dev_info(&usb_dev->dev, "ATUSB: %s version %d\n", chip, version_num);
  802. return 0;
  803. fail:
  804. atusb->err = -ENODEV;
  805. return -ENODEV;
  806. }
  807. static int atusb_set_extended_addr(struct atusb *atusb)
  808. {
  809. struct usb_device *usb_dev = atusb->usb_dev;
  810. unsigned char *buffer;
  811. __le64 extended_addr;
  812. u64 addr;
  813. int ret;
  814. /* Firmware versions before 0.3 do not support the EUI64_READ command.
  815. * Just use a random address and be done.
  816. */
  817. if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 3) {
  818. ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
  819. return 0;
  820. }
  821. buffer = kmalloc(IEEE802154_EXTENDED_ADDR_LEN, GFP_KERNEL);
  822. if (!buffer)
  823. return -ENOMEM;
  824. /* Firmware is new enough so we fetch the address from EEPROM */
  825. ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
  826. ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0,
  827. buffer, IEEE802154_EXTENDED_ADDR_LEN, 1000);
  828. if (ret < 0) {
  829. dev_err(&usb_dev->dev, "failed to fetch extended address, random address set\n");
  830. ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
  831. kfree(buffer);
  832. return ret;
  833. }
  834. memcpy(&extended_addr, buffer, IEEE802154_EXTENDED_ADDR_LEN);
  835. /* Check if read address is not empty and the unicast bit is set correctly */
  836. if (!ieee802154_is_valid_extended_unicast_addr(extended_addr)) {
  837. dev_info(&usb_dev->dev, "no permanent extended address found, random address set\n");
  838. ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
  839. } else {
  840. atusb->hw->phy->perm_extended_addr = extended_addr;
  841. addr = swab64((__force u64)atusb->hw->phy->perm_extended_addr);
  842. dev_info(&usb_dev->dev, "Read permanent extended address %8phC from device\n",
  843. &addr);
  844. }
  845. kfree(buffer);
  846. return ret;
  847. }
  848. /* ----- Setup ------------------------------------------------------------- */
  849. static int atusb_probe(struct usb_interface *interface,
  850. const struct usb_device_id *id)
  851. {
  852. struct usb_device *usb_dev = interface_to_usbdev(interface);
  853. struct ieee802154_hw *hw;
  854. struct atusb *atusb = NULL;
  855. int ret = -ENOMEM;
  856. hw = ieee802154_alloc_hw(sizeof(struct atusb), &atusb_ops);
  857. if (!hw)
  858. return -ENOMEM;
  859. atusb = hw->priv;
  860. atusb->hw = hw;
  861. atusb->usb_dev = usb_get_dev(usb_dev);
  862. usb_set_intfdata(interface, atusb);
  863. atusb->shutdown = 0;
  864. atusb->err = 0;
  865. INIT_DELAYED_WORK(&atusb->work, atusb_work_urbs);
  866. init_usb_anchor(&atusb->idle_urbs);
  867. init_usb_anchor(&atusb->rx_urbs);
  868. if (atusb_alloc_urbs(atusb, ATUSB_NUM_RX_URBS))
  869. goto fail;
  870. atusb->tx_dr.bRequestType = ATUSB_REQ_TO_DEV;
  871. atusb->tx_dr.bRequest = ATUSB_TX;
  872. atusb->tx_dr.wValue = cpu_to_le16(0);
  873. atusb->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
  874. if (!atusb->tx_urb)
  875. goto fail;
  876. hw->parent = &usb_dev->dev;
  877. atusb_command(atusb, ATUSB_RF_RESET, 0);
  878. atusb_get_and_conf_chip(atusb);
  879. atusb_get_and_show_revision(atusb);
  880. atusb_get_and_show_build(atusb);
  881. atusb_set_extended_addr(atusb);
  882. if ((atusb->fw_ver_maj == 0 && atusb->fw_ver_min >= 3) || atusb->fw_ver_maj > 0)
  883. hw->flags |= IEEE802154_HW_FRAME_RETRIES;
  884. ret = atusb_get_and_clear_error(atusb);
  885. if (ret) {
  886. dev_err(&atusb->usb_dev->dev,
  887. "%s: initialization failed, error = %d\n",
  888. __func__, ret);
  889. goto fail;
  890. }
  891. ret = ieee802154_register_hw(hw);
  892. if (ret)
  893. goto fail;
  894. /* If we just powered on, we're now in P_ON and need to enter TRX_OFF
  895. * explicitly. Any resets after that will send us straight to TRX_OFF,
  896. * making the command below redundant.
  897. */
  898. atusb_write_reg(atusb, RG_TRX_STATE, STATE_FORCE_TRX_OFF);
  899. msleep(1); /* reset => TRX_OFF, tTR13 = 37 us */
  900. #if 0
  901. /* Calculating the maximum time available to empty the frame buffer
  902. * on reception:
  903. *
  904. * According to [1], the inter-frame gap is
  905. * R * 20 * 16 us + 128 us
  906. * where R is a random number from 0 to 7. Furthermore, we have 20 bit
  907. * times (80 us at 250 kbps) of SHR of the next frame before the
  908. * transceiver begins storing data in the frame buffer.
  909. *
  910. * This yields a minimum time of 208 us between the last data of a
  911. * frame and the first data of the next frame. This time is further
  912. * reduced by interrupt latency in the atusb firmware.
  913. *
  914. * atusb currently needs about 500 us to retrieve a maximum-sized
  915. * frame. We therefore have to allow reception of a new frame to begin
  916. * while we retrieve the previous frame.
  917. *
  918. * [1] "JN-AN-1035 Calculating data rates in an IEEE 802.15.4-based
  919. * network", Jennic 2006.
  920. * http://www.jennic.com/download_file.php?supportFile=JN-AN-1035%20Calculating%20802-15-4%20Data%20Rates-1v0.pdf
  921. */
  922. atusb_write_subreg(atusb, SR_RX_SAFE_MODE, 1);
  923. #endif
  924. atusb_write_reg(atusb, RG_IRQ_MASK, 0xff);
  925. ret = atusb_get_and_clear_error(atusb);
  926. if (!ret)
  927. return 0;
  928. dev_err(&atusb->usb_dev->dev,
  929. "%s: setup failed, error = %d\n",
  930. __func__, ret);
  931. ieee802154_unregister_hw(hw);
  932. fail:
  933. atusb_free_urbs(atusb);
  934. usb_kill_urb(atusb->tx_urb);
  935. usb_free_urb(atusb->tx_urb);
  936. usb_put_dev(usb_dev);
  937. ieee802154_free_hw(hw);
  938. return ret;
  939. }
  940. static void atusb_disconnect(struct usb_interface *interface)
  941. {
  942. struct atusb *atusb = usb_get_intfdata(interface);
  943. dev_dbg(&atusb->usb_dev->dev, "%s\n", __func__);
  944. atusb->shutdown = 1;
  945. cancel_delayed_work_sync(&atusb->work);
  946. usb_kill_anchored_urbs(&atusb->rx_urbs);
  947. atusb_free_urbs(atusb);
  948. usb_kill_urb(atusb->tx_urb);
  949. usb_free_urb(atusb->tx_urb);
  950. ieee802154_unregister_hw(atusb->hw);
  951. ieee802154_free_hw(atusb->hw);
  952. usb_set_intfdata(interface, NULL);
  953. usb_put_dev(atusb->usb_dev);
  954. pr_debug("%s done\n", __func__);
  955. }
  956. /* The devices we work with */
  957. static const struct usb_device_id atusb_device_table[] = {
  958. {
  959. .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
  960. USB_DEVICE_ID_MATCH_INT_INFO,
  961. .idVendor = ATUSB_VENDOR_ID,
  962. .idProduct = ATUSB_PRODUCT_ID,
  963. .bInterfaceClass = USB_CLASS_VENDOR_SPEC
  964. },
  965. /* end with null element */
  966. {}
  967. };
  968. MODULE_DEVICE_TABLE(usb, atusb_device_table);
  969. static struct usb_driver atusb_driver = {
  970. .name = "atusb",
  971. .probe = atusb_probe,
  972. .disconnect = atusb_disconnect,
  973. .id_table = atusb_device_table,
  974. };
  975. module_usb_driver(atusb_driver);
  976. MODULE_AUTHOR("Alexander Aring <alex.aring@gmail.com>");
  977. MODULE_AUTHOR("Richard Sharpe <realrichardsharpe@gmail.com>");
  978. MODULE_AUTHOR("Stefan Schmidt <stefan@datenfreihafen.org>");
  979. MODULE_AUTHOR("Werner Almesberger <werner@almesberger.net>");
  980. MODULE_AUTHOR("Josef Filzmaier <j.filzmaier@gmx.at>");
  981. MODULE_DESCRIPTION("ATUSB IEEE 802.15.4 Driver");
  982. MODULE_LICENSE("GPL");