atusb.c 31 KB

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