atusb.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  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. usb_free_urb(urb);
  307. n--;
  308. }
  309. return 0;
  310. }
  311. /* ----- IEEE 802.15.4 interface operations -------------------------------- */
  312. static void atusb_xmit_complete(struct urb *urb)
  313. {
  314. dev_dbg(&urb->dev->dev, "atusb_xmit urb completed");
  315. }
  316. static int atusb_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
  317. {
  318. struct atusb *atusb = hw->priv;
  319. struct usb_device *usb_dev = atusb->usb_dev;
  320. int ret;
  321. dev_dbg(&usb_dev->dev, "%s (%d)\n", __func__, skb->len);
  322. atusb->tx_skb = skb;
  323. atusb->tx_ack_seq++;
  324. atusb->tx_dr.wIndex = cpu_to_le16(atusb->tx_ack_seq);
  325. atusb->tx_dr.wLength = cpu_to_le16(skb->len);
  326. usb_fill_control_urb(atusb->tx_urb, usb_dev,
  327. usb_sndctrlpipe(usb_dev, 0),
  328. (unsigned char *)&atusb->tx_dr, skb->data,
  329. skb->len, atusb_xmit_complete, NULL);
  330. ret = usb_submit_urb(atusb->tx_urb, GFP_ATOMIC);
  331. dev_dbg(&usb_dev->dev, "%s done (%d)\n", __func__, ret);
  332. return ret;
  333. }
  334. static int atusb_ed(struct ieee802154_hw *hw, u8 *level)
  335. {
  336. WARN_ON(!level);
  337. *level = 0xbe;
  338. return 0;
  339. }
  340. static int atusb_set_hw_addr_filt(struct ieee802154_hw *hw,
  341. struct ieee802154_hw_addr_filt *filt,
  342. unsigned long changed)
  343. {
  344. struct atusb *atusb = hw->priv;
  345. struct device *dev = &atusb->usb_dev->dev;
  346. if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
  347. u16 addr = le16_to_cpu(filt->short_addr);
  348. dev_vdbg(dev, "%s called for saddr\n", __func__);
  349. atusb_write_reg(atusb, RG_SHORT_ADDR_0, addr);
  350. atusb_write_reg(atusb, RG_SHORT_ADDR_1, addr >> 8);
  351. }
  352. if (changed & IEEE802154_AFILT_PANID_CHANGED) {
  353. u16 pan = le16_to_cpu(filt->pan_id);
  354. dev_vdbg(dev, "%s called for pan id\n", __func__);
  355. atusb_write_reg(atusb, RG_PAN_ID_0, pan);
  356. atusb_write_reg(atusb, RG_PAN_ID_1, pan >> 8);
  357. }
  358. if (changed & IEEE802154_AFILT_IEEEADDR_CHANGED) {
  359. u8 i, addr[IEEE802154_EXTENDED_ADDR_LEN];
  360. memcpy(addr, &filt->ieee_addr, IEEE802154_EXTENDED_ADDR_LEN);
  361. dev_vdbg(dev, "%s called for IEEE addr\n", __func__);
  362. for (i = 0; i < 8; i++)
  363. atusb_write_reg(atusb, RG_IEEE_ADDR_0 + i, addr[i]);
  364. }
  365. if (changed & IEEE802154_AFILT_PANC_CHANGED) {
  366. dev_vdbg(dev, "%s called for panc change\n", __func__);
  367. if (filt->pan_coord)
  368. atusb_write_subreg(atusb, SR_AACK_I_AM_COORD, 1);
  369. else
  370. atusb_write_subreg(atusb, SR_AACK_I_AM_COORD, 0);
  371. }
  372. return atusb_get_and_clear_error(atusb);
  373. }
  374. static int atusb_start(struct ieee802154_hw *hw)
  375. {
  376. struct atusb *atusb = hw->priv;
  377. struct usb_device *usb_dev = atusb->usb_dev;
  378. int ret;
  379. dev_dbg(&usb_dev->dev, "%s\n", __func__);
  380. schedule_delayed_work(&atusb->work, 0);
  381. atusb_command(atusb, ATUSB_RX_MODE, 1);
  382. ret = atusb_get_and_clear_error(atusb);
  383. if (ret < 0)
  384. usb_kill_anchored_urbs(&atusb->idle_urbs);
  385. return ret;
  386. }
  387. static void atusb_stop(struct ieee802154_hw *hw)
  388. {
  389. struct atusb *atusb = hw->priv;
  390. struct usb_device *usb_dev = atusb->usb_dev;
  391. dev_dbg(&usb_dev->dev, "%s\n", __func__);
  392. usb_kill_anchored_urbs(&atusb->idle_urbs);
  393. atusb_command(atusb, ATUSB_RX_MODE, 0);
  394. atusb_get_and_clear_error(atusb);
  395. }
  396. #define ATUSB_MAX_TX_POWERS 0xF
  397. static const s32 atusb_powers[ATUSB_MAX_TX_POWERS + 1] = {
  398. 300, 280, 230, 180, 130, 70, 0, -100, -200, -300, -400, -500, -700,
  399. -900, -1200, -1700,
  400. };
  401. static int
  402. atusb_txpower(struct ieee802154_hw *hw, s32 mbm)
  403. {
  404. struct atusb *atusb = hw->priv;
  405. if (atusb->data)
  406. return atusb->data->set_txpower(hw, mbm);
  407. else
  408. return -ENOTSUPP;
  409. }
  410. static int
  411. atusb_set_txpower(struct ieee802154_hw *hw, s32 mbm)
  412. {
  413. struct atusb *atusb = hw->priv;
  414. u32 i;
  415. for (i = 0; i < hw->phy->supported.tx_powers_size; i++) {
  416. if (hw->phy->supported.tx_powers[i] == mbm)
  417. return atusb_write_subreg(atusb, SR_TX_PWR_23X, i);
  418. }
  419. return -EINVAL;
  420. }
  421. static int
  422. hulusb_set_txpower(struct ieee802154_hw *hw, s32 mbm)
  423. {
  424. u32 i;
  425. for (i = 0; i < hw->phy->supported.tx_powers_size; i++) {
  426. if (hw->phy->supported.tx_powers[i] == mbm)
  427. return atusb_write_subreg(hw->priv, SR_TX_PWR_212, i);
  428. }
  429. return -EINVAL;
  430. }
  431. #define ATUSB_MAX_ED_LEVELS 0xF
  432. static const s32 atusb_ed_levels[ATUSB_MAX_ED_LEVELS + 1] = {
  433. -9100, -8900, -8700, -8500, -8300, -8100, -7900, -7700, -7500, -7300,
  434. -7100, -6900, -6700, -6500, -6300, -6100,
  435. };
  436. #define AT86RF212_MAX_TX_POWERS 0x1F
  437. static const s32 at86rf212_powers[AT86RF212_MAX_TX_POWERS + 1] = {
  438. 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700,
  439. -800, -900, -1000, -1100, -1200, -1300, -1400, -1500, -1600, -1700,
  440. -1800, -1900, -2000, -2100, -2200, -2300, -2400, -2500, -2600,
  441. };
  442. #define AT86RF2XX_MAX_ED_LEVELS 0xF
  443. static const s32 at86rf212_ed_levels_100[AT86RF2XX_MAX_ED_LEVELS + 1] = {
  444. -10000, -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200,
  445. -8000, -7800, -7600, -7400, -7200, -7000,
  446. };
  447. static const s32 at86rf212_ed_levels_98[AT86RF2XX_MAX_ED_LEVELS + 1] = {
  448. -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200, -8000,
  449. -7800, -7600, -7400, -7200, -7000, -6800,
  450. };
  451. static int
  452. atusb_set_cca_mode(struct ieee802154_hw *hw, const struct wpan_phy_cca *cca)
  453. {
  454. struct atusb *atusb = hw->priv;
  455. u8 val;
  456. /* mapping 802.15.4 to driver spec */
  457. switch (cca->mode) {
  458. case NL802154_CCA_ENERGY:
  459. val = 1;
  460. break;
  461. case NL802154_CCA_CARRIER:
  462. val = 2;
  463. break;
  464. case NL802154_CCA_ENERGY_CARRIER:
  465. switch (cca->opt) {
  466. case NL802154_CCA_OPT_ENERGY_CARRIER_AND:
  467. val = 3;
  468. break;
  469. case NL802154_CCA_OPT_ENERGY_CARRIER_OR:
  470. val = 0;
  471. break;
  472. default:
  473. return -EINVAL;
  474. }
  475. break;
  476. default:
  477. return -EINVAL;
  478. }
  479. return atusb_write_subreg(atusb, SR_CCA_MODE, val);
  480. }
  481. static int hulusb_set_cca_ed_level(struct atusb *lp, int rssi_base_val)
  482. {
  483. unsigned int cca_ed_thres;
  484. cca_ed_thres = atusb_read_subreg(lp, SR_CCA_ED_THRES);
  485. switch (rssi_base_val) {
  486. case -98:
  487. lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_98;
  488. lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_98);
  489. lp->hw->phy->cca_ed_level = at86rf212_ed_levels_98[cca_ed_thres];
  490. break;
  491. case -100:
  492. lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
  493. lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
  494. lp->hw->phy->cca_ed_level = at86rf212_ed_levels_100[cca_ed_thres];
  495. break;
  496. default:
  497. WARN_ON(1);
  498. }
  499. return 0;
  500. }
  501. static int
  502. atusb_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
  503. {
  504. struct atusb *atusb = hw->priv;
  505. u32 i;
  506. for (i = 0; i < hw->phy->supported.cca_ed_levels_size; i++) {
  507. if (hw->phy->supported.cca_ed_levels[i] == mbm)
  508. return atusb_write_subreg(atusb, SR_CCA_ED_THRES, i);
  509. }
  510. return -EINVAL;
  511. }
  512. static int atusb_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
  513. {
  514. struct atusb *atusb = hw->priv;
  515. int ret = -ENOTSUPP;
  516. if (atusb->data) {
  517. ret = atusb->data->set_channel(hw, page, channel);
  518. /* @@@ ugly synchronization */
  519. msleep(atusb->data->t_channel_switch);
  520. }
  521. return ret;
  522. }
  523. static int atusb_set_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
  524. {
  525. struct atusb *atusb = hw->priv;
  526. int ret;
  527. ret = atusb_write_subreg(atusb, SR_CHANNEL, channel);
  528. if (ret < 0)
  529. return ret;
  530. return 0;
  531. }
  532. static int hulusb_set_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
  533. {
  534. int rc;
  535. int rssi_base_val;
  536. struct atusb *lp = hw->priv;
  537. if (channel == 0)
  538. rc = atusb_write_subreg(lp, SR_SUB_MODE, 0);
  539. else
  540. rc = atusb_write_subreg(lp, SR_SUB_MODE, 1);
  541. if (rc < 0)
  542. return rc;
  543. if (page == 0) {
  544. rc = atusb_write_subreg(lp, SR_BPSK_QPSK, 0);
  545. rssi_base_val = -100;
  546. } else {
  547. rc = atusb_write_subreg(lp, SR_BPSK_QPSK, 1);
  548. rssi_base_val = -98;
  549. }
  550. if (rc < 0)
  551. return rc;
  552. rc = hulusb_set_cca_ed_level(lp, rssi_base_val);
  553. if (rc < 0)
  554. return rc;
  555. /* This sets the symbol_duration according frequency on the 212.
  556. * TODO move this handling while set channel and page in cfg802154.
  557. * We can do that, this timings are according 802.15.4 standard.
  558. * If we do that in cfg802154, this is a more generic calculation.
  559. *
  560. * This should also protected from ifs_timer. Means cancel timer and
  561. * init with a new value. For now, this is okay.
  562. */
  563. if (channel == 0) {
  564. if (page == 0) {
  565. /* SUB:0 and BPSK:0 -> BPSK-20 */
  566. lp->hw->phy->symbol_duration = 50;
  567. } else {
  568. /* SUB:1 and BPSK:0 -> BPSK-40 */
  569. lp->hw->phy->symbol_duration = 25;
  570. }
  571. } else {
  572. if (page == 0)
  573. /* SUB:0 and BPSK:1 -> OQPSK-100/200/400 */
  574. lp->hw->phy->symbol_duration = 40;
  575. else
  576. /* SUB:1 and BPSK:1 -> OQPSK-250/500/1000 */
  577. lp->hw->phy->symbol_duration = 16;
  578. }
  579. lp->hw->phy->lifs_period = IEEE802154_LIFS_PERIOD *
  580. lp->hw->phy->symbol_duration;
  581. lp->hw->phy->sifs_period = IEEE802154_SIFS_PERIOD *
  582. lp->hw->phy->symbol_duration;
  583. return atusb_write_subreg(lp, SR_CHANNEL, channel);
  584. }
  585. static int
  586. atusb_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be, u8 retries)
  587. {
  588. struct atusb *atusb = hw->priv;
  589. int ret;
  590. ret = atusb_write_subreg(atusb, SR_MIN_BE, min_be);
  591. if (ret)
  592. return ret;
  593. ret = atusb_write_subreg(atusb, SR_MAX_BE, max_be);
  594. if (ret)
  595. return ret;
  596. return atusb_write_subreg(atusb, SR_MAX_CSMA_RETRIES, retries);
  597. }
  598. static int
  599. hulusb_set_lbt(struct ieee802154_hw *hw, bool on)
  600. {
  601. struct atusb *atusb = hw->priv;
  602. return atusb_write_subreg(atusb, SR_CSMA_LBT_MODE, on);
  603. }
  604. static int
  605. atusb_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
  606. {
  607. struct atusb *atusb = hw->priv;
  608. return atusb_write_subreg(atusb, SR_MAX_FRAME_RETRIES, retries);
  609. }
  610. static int
  611. atusb_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
  612. {
  613. struct atusb *atusb = hw->priv;
  614. int ret;
  615. if (on) {
  616. ret = atusb_write_subreg(atusb, SR_AACK_DIS_ACK, 1);
  617. if (ret < 0)
  618. return ret;
  619. ret = atusb_write_subreg(atusb, SR_AACK_PROM_MODE, 1);
  620. if (ret < 0)
  621. return ret;
  622. } else {
  623. ret = atusb_write_subreg(atusb, SR_AACK_PROM_MODE, 0);
  624. if (ret < 0)
  625. return ret;
  626. ret = atusb_write_subreg(atusb, SR_AACK_DIS_ACK, 0);
  627. if (ret < 0)
  628. return ret;
  629. }
  630. return 0;
  631. }
  632. static struct atusb_chip_data atusb_chip_data = {
  633. .t_channel_switch = 1,
  634. .rssi_base_val = -91,
  635. .set_txpower = atusb_set_txpower,
  636. .set_channel = atusb_set_channel,
  637. };
  638. static struct atusb_chip_data hulusb_chip_data = {
  639. .t_channel_switch = 11,
  640. .rssi_base_val = -100,
  641. .set_txpower = hulusb_set_txpower,
  642. .set_channel = hulusb_set_channel,
  643. };
  644. static const struct ieee802154_ops atusb_ops = {
  645. .owner = THIS_MODULE,
  646. .xmit_async = atusb_xmit,
  647. .ed = atusb_ed,
  648. .set_channel = atusb_channel,
  649. .start = atusb_start,
  650. .stop = atusb_stop,
  651. .set_hw_addr_filt = atusb_set_hw_addr_filt,
  652. .set_txpower = atusb_txpower,
  653. .set_lbt = hulusb_set_lbt,
  654. .set_cca_mode = atusb_set_cca_mode,
  655. .set_cca_ed_level = atusb_set_cca_ed_level,
  656. .set_csma_params = atusb_set_csma_params,
  657. .set_frame_retries = atusb_set_frame_retries,
  658. .set_promiscuous_mode = atusb_set_promiscuous_mode,
  659. };
  660. /* ----- Firmware and chip version information ----------------------------- */
  661. static int atusb_get_and_show_revision(struct atusb *atusb)
  662. {
  663. struct usb_device *usb_dev = atusb->usb_dev;
  664. char *hw_name;
  665. unsigned char *buffer;
  666. int ret;
  667. buffer = kmalloc(3, GFP_KERNEL);
  668. if (!buffer)
  669. return -ENOMEM;
  670. /* Get a couple of the ATMega Firmware values */
  671. ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
  672. ATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0,
  673. buffer, 3, 1000);
  674. if (ret >= 0) {
  675. atusb->fw_ver_maj = buffer[0];
  676. atusb->fw_ver_min = buffer[1];
  677. atusb->fw_hw_type = buffer[2];
  678. switch (atusb->fw_hw_type) {
  679. case ATUSB_HW_TYPE_100813:
  680. case ATUSB_HW_TYPE_101216:
  681. case ATUSB_HW_TYPE_110131:
  682. hw_name = "ATUSB";
  683. atusb->data = &atusb_chip_data;
  684. break;
  685. case ATUSB_HW_TYPE_RZUSB:
  686. hw_name = "RZUSB";
  687. atusb->data = &atusb_chip_data;
  688. break;
  689. case ATUSB_HW_TYPE_HULUSB:
  690. hw_name = "HULUSB";
  691. atusb->data = &hulusb_chip_data;
  692. break;
  693. default:
  694. hw_name = "UNKNOWN";
  695. atusb->err = -ENOTSUPP;
  696. ret = -ENOTSUPP;
  697. break;
  698. }
  699. dev_info(&usb_dev->dev,
  700. "Firmware: major: %u, minor: %u, hardware type: %s (%d)\n",
  701. atusb->fw_ver_maj, atusb->fw_ver_min, hw_name,
  702. atusb->fw_hw_type);
  703. }
  704. if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 2) {
  705. dev_info(&usb_dev->dev,
  706. "Firmware version (%u.%u) predates our first public release.",
  707. atusb->fw_ver_maj, atusb->fw_ver_min);
  708. dev_info(&usb_dev->dev, "Please update to version 0.2 or newer");
  709. }
  710. kfree(buffer);
  711. return ret;
  712. }
  713. static int atusb_get_and_show_build(struct atusb *atusb)
  714. {
  715. struct usb_device *usb_dev = atusb->usb_dev;
  716. char *build;
  717. int ret;
  718. build = kmalloc(ATUSB_BUILD_SIZE + 1, GFP_KERNEL);
  719. if (!build)
  720. return -ENOMEM;
  721. ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
  722. ATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0,
  723. build, ATUSB_BUILD_SIZE, 1000);
  724. if (ret >= 0) {
  725. build[ret] = 0;
  726. dev_info(&usb_dev->dev, "Firmware: build %s\n", build);
  727. }
  728. kfree(build);
  729. return ret;
  730. }
  731. static int atusb_get_and_conf_chip(struct atusb *atusb)
  732. {
  733. struct usb_device *usb_dev = atusb->usb_dev;
  734. u8 man_id_0, man_id_1, part_num, version_num;
  735. const char *chip;
  736. struct ieee802154_hw *hw = atusb->hw;
  737. man_id_0 = atusb_read_reg(atusb, RG_MAN_ID_0);
  738. man_id_1 = atusb_read_reg(atusb, RG_MAN_ID_1);
  739. part_num = atusb_read_reg(atusb, RG_PART_NUM);
  740. version_num = atusb_read_reg(atusb, RG_VERSION_NUM);
  741. if (atusb->err)
  742. return atusb->err;
  743. hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
  744. IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS;
  745. hw->phy->flags = WPAN_PHY_FLAG_TXPOWER | WPAN_PHY_FLAG_CCA_ED_LEVEL |
  746. WPAN_PHY_FLAG_CCA_MODE;
  747. hw->phy->supported.cca_modes = BIT(NL802154_CCA_ENERGY) |
  748. BIT(NL802154_CCA_CARRIER) |
  749. BIT(NL802154_CCA_ENERGY_CARRIER);
  750. hw->phy->supported.cca_opts = BIT(NL802154_CCA_OPT_ENERGY_CARRIER_AND) |
  751. BIT(NL802154_CCA_OPT_ENERGY_CARRIER_OR);
  752. hw->phy->cca.mode = NL802154_CCA_ENERGY;
  753. hw->phy->current_page = 0;
  754. if ((man_id_1 << 8 | man_id_0) != ATUSB_JEDEC_ATMEL) {
  755. dev_err(&usb_dev->dev,
  756. "non-Atmel transceiver xxxx%02x%02x\n",
  757. man_id_1, man_id_0);
  758. goto fail;
  759. }
  760. switch (part_num) {
  761. case 2:
  762. chip = "AT86RF230";
  763. atusb->hw->phy->supported.channels[0] = 0x7FFF800;
  764. atusb->hw->phy->current_channel = 11; /* reset default */
  765. atusb->hw->phy->symbol_duration = 16;
  766. atusb->hw->phy->supported.tx_powers = atusb_powers;
  767. atusb->hw->phy->supported.tx_powers_size = ARRAY_SIZE(atusb_powers);
  768. hw->phy->supported.cca_ed_levels = atusb_ed_levels;
  769. hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(atusb_ed_levels);
  770. break;
  771. case 3:
  772. chip = "AT86RF231";
  773. atusb->hw->phy->supported.channels[0] = 0x7FFF800;
  774. atusb->hw->phy->current_channel = 11; /* reset default */
  775. atusb->hw->phy->symbol_duration = 16;
  776. atusb->hw->phy->supported.tx_powers = atusb_powers;
  777. atusb->hw->phy->supported.tx_powers_size = ARRAY_SIZE(atusb_powers);
  778. hw->phy->supported.cca_ed_levels = atusb_ed_levels;
  779. hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(atusb_ed_levels);
  780. break;
  781. case 7:
  782. chip = "AT86RF212";
  783. atusb->hw->flags |= IEEE802154_HW_LBT;
  784. atusb->hw->phy->supported.channels[0] = 0x00007FF;
  785. atusb->hw->phy->supported.channels[2] = 0x00007FF;
  786. atusb->hw->phy->current_channel = 5;
  787. atusb->hw->phy->symbol_duration = 25;
  788. atusb->hw->phy->supported.lbt = NL802154_SUPPORTED_BOOL_BOTH;
  789. atusb->hw->phy->supported.tx_powers = at86rf212_powers;
  790. atusb->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf212_powers);
  791. atusb->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
  792. atusb->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
  793. break;
  794. default:
  795. dev_err(&usb_dev->dev,
  796. "unexpected transceiver, part 0x%02x version 0x%02x\n",
  797. part_num, version_num);
  798. goto fail;
  799. }
  800. hw->phy->transmit_power = hw->phy->supported.tx_powers[0];
  801. hw->phy->cca_ed_level = hw->phy->supported.cca_ed_levels[7];
  802. dev_info(&usb_dev->dev, "ATUSB: %s version %d\n", chip, version_num);
  803. return 0;
  804. fail:
  805. atusb->err = -ENODEV;
  806. return -ENODEV;
  807. }
  808. static int atusb_set_extended_addr(struct atusb *atusb)
  809. {
  810. struct usb_device *usb_dev = atusb->usb_dev;
  811. unsigned char *buffer;
  812. __le64 extended_addr;
  813. u64 addr;
  814. int ret;
  815. /* Firmware versions before 0.3 do not support the EUI64_READ command.
  816. * Just use a random address and be done.
  817. */
  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_KERNEL);
  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, "%s\n", __func__);
  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. usb_put_dev(atusb->usb_dev);
  953. ieee802154_free_hw(atusb->hw);
  954. usb_set_intfdata(interface, NULL);
  955. pr_debug("%s done\n", __func__);
  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");