ath3k.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. /*
  2. * Copyright (c) 2008-2009 Atheros Communications Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *
  18. */
  19. #include <linux/module.h>
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/slab.h>
  23. #include <linux/types.h>
  24. #include <linux/errno.h>
  25. #include <linux/device.h>
  26. #include <linux/firmware.h>
  27. #include <linux/usb.h>
  28. #include <asm/unaligned.h>
  29. #include <net/bluetooth/bluetooth.h>
  30. #define VERSION "1.0"
  31. #define ATH3K_FIRMWARE "ath3k-1.fw"
  32. #define ATH3K_DNLOAD 0x01
  33. #define ATH3K_GETSTATE 0x05
  34. #define ATH3K_SET_NORMAL_MODE 0x07
  35. #define ATH3K_GETVERSION 0x09
  36. #define USB_REG_SWITCH_VID_PID 0x0a
  37. #define ATH3K_MODE_MASK 0x3F
  38. #define ATH3K_NORMAL_MODE 0x0E
  39. #define ATH3K_PATCH_UPDATE 0x80
  40. #define ATH3K_SYSCFG_UPDATE 0x40
  41. #define ATH3K_XTAL_FREQ_26M 0x00
  42. #define ATH3K_XTAL_FREQ_40M 0x01
  43. #define ATH3K_XTAL_FREQ_19P2 0x02
  44. #define ATH3K_NAME_LEN 0xFF
  45. struct ath3k_version {
  46. __le32 rom_version;
  47. __le32 build_version;
  48. __le32 ram_version;
  49. __u8 ref_clock;
  50. __u8 reserved[7];
  51. } __packed;
  52. static const struct usb_device_id ath3k_table[] = {
  53. /* Atheros AR3011 */
  54. { USB_DEVICE(0x0CF3, 0x3000) },
  55. /* Atheros AR3011 with sflash firmware*/
  56. { USB_DEVICE(0x0489, 0xE027) },
  57. { USB_DEVICE(0x0489, 0xE03D) },
  58. { USB_DEVICE(0x04F2, 0xAFF1) },
  59. { USB_DEVICE(0x0930, 0x0215) },
  60. { USB_DEVICE(0x0CF3, 0x3002) },
  61. { USB_DEVICE(0x0CF3, 0xE019) },
  62. { USB_DEVICE(0x13d3, 0x3304) },
  63. /* Atheros AR9285 Malbec with sflash firmware */
  64. { USB_DEVICE(0x03F0, 0x311D) },
  65. /* Atheros AR3012 with sflash firmware*/
  66. { USB_DEVICE(0x0489, 0xe04d) },
  67. { USB_DEVICE(0x0489, 0xe04e) },
  68. { USB_DEVICE(0x0489, 0xe057) },
  69. { USB_DEVICE(0x0489, 0xe056) },
  70. { USB_DEVICE(0x0489, 0xe05f) },
  71. { USB_DEVICE(0x0489, 0xe076) },
  72. { USB_DEVICE(0x0489, 0xe078) },
  73. { USB_DEVICE(0x0489, 0xe095) },
  74. { USB_DEVICE(0x04c5, 0x1330) },
  75. { USB_DEVICE(0x04CA, 0x3004) },
  76. { USB_DEVICE(0x04CA, 0x3005) },
  77. { USB_DEVICE(0x04CA, 0x3006) },
  78. { USB_DEVICE(0x04CA, 0x3007) },
  79. { USB_DEVICE(0x04CA, 0x3008) },
  80. { USB_DEVICE(0x04CA, 0x300b) },
  81. { USB_DEVICE(0x04CA, 0x300d) },
  82. { USB_DEVICE(0x04CA, 0x300f) },
  83. { USB_DEVICE(0x04CA, 0x3010) },
  84. { USB_DEVICE(0x04CA, 0x3014) },
  85. { USB_DEVICE(0x04CA, 0x3018) },
  86. { USB_DEVICE(0x0930, 0x0219) },
  87. { USB_DEVICE(0x0930, 0x021c) },
  88. { USB_DEVICE(0x0930, 0x0220) },
  89. { USB_DEVICE(0x0930, 0x0227) },
  90. { USB_DEVICE(0x0b05, 0x17d0) },
  91. { USB_DEVICE(0x0CF3, 0x0036) },
  92. { USB_DEVICE(0x0CF3, 0x3004) },
  93. { USB_DEVICE(0x0CF3, 0x3008) },
  94. { USB_DEVICE(0x0CF3, 0x311D) },
  95. { USB_DEVICE(0x0CF3, 0x311E) },
  96. { USB_DEVICE(0x0CF3, 0x311F) },
  97. { USB_DEVICE(0x0cf3, 0x3121) },
  98. { USB_DEVICE(0x0CF3, 0x817a) },
  99. { USB_DEVICE(0x0CF3, 0x817b) },
  100. { USB_DEVICE(0x0cf3, 0xe003) },
  101. { USB_DEVICE(0x0CF3, 0xE004) },
  102. { USB_DEVICE(0x0CF3, 0xE005) },
  103. { USB_DEVICE(0x0CF3, 0xE006) },
  104. { USB_DEVICE(0x13d3, 0x3362) },
  105. { USB_DEVICE(0x13d3, 0x3375) },
  106. { USB_DEVICE(0x13d3, 0x3393) },
  107. { USB_DEVICE(0x13d3, 0x3395) },
  108. { USB_DEVICE(0x13d3, 0x3402) },
  109. { USB_DEVICE(0x13d3, 0x3408) },
  110. { USB_DEVICE(0x13d3, 0x3423) },
  111. { USB_DEVICE(0x13d3, 0x3432) },
  112. { USB_DEVICE(0x13d3, 0x3472) },
  113. { USB_DEVICE(0x13d3, 0x3474) },
  114. /* Atheros AR5BBU12 with sflash firmware */
  115. { USB_DEVICE(0x0489, 0xE02C) },
  116. /* Atheros AR5BBU22 with sflash firmware */
  117. { USB_DEVICE(0x0489, 0xE036) },
  118. { USB_DEVICE(0x0489, 0xE03C) },
  119. { } /* Terminating entry */
  120. };
  121. MODULE_DEVICE_TABLE(usb, ath3k_table);
  122. #define BTUSB_ATH3012 0x80
  123. /* This table is to load patch and sysconfig files
  124. * for AR3012 */
  125. static const struct usb_device_id ath3k_blist_tbl[] = {
  126. /* Atheros AR3012 with sflash firmware*/
  127. { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
  128. { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 },
  129. { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
  130. { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
  131. { USB_DEVICE(0x0489, 0xe05f), .driver_info = BTUSB_ATH3012 },
  132. { USB_DEVICE(0x0489, 0xe076), .driver_info = BTUSB_ATH3012 },
  133. { USB_DEVICE(0x0489, 0xe078), .driver_info = BTUSB_ATH3012 },
  134. { USB_DEVICE(0x0489, 0xe095), .driver_info = BTUSB_ATH3012 },
  135. { USB_DEVICE(0x04c5, 0x1330), .driver_info = BTUSB_ATH3012 },
  136. { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
  137. { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
  138. { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
  139. { USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 },
  140. { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
  141. { USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 },
  142. { USB_DEVICE(0x04ca, 0x300d), .driver_info = BTUSB_ATH3012 },
  143. { USB_DEVICE(0x04ca, 0x300f), .driver_info = BTUSB_ATH3012 },
  144. { USB_DEVICE(0x04ca, 0x3010), .driver_info = BTUSB_ATH3012 },
  145. { USB_DEVICE(0x04ca, 0x3014), .driver_info = BTUSB_ATH3012 },
  146. { USB_DEVICE(0x04ca, 0x3018), .driver_info = BTUSB_ATH3012 },
  147. { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
  148. { USB_DEVICE(0x0930, 0x021c), .driver_info = BTUSB_ATH3012 },
  149. { USB_DEVICE(0x0930, 0x0220), .driver_info = BTUSB_ATH3012 },
  150. { USB_DEVICE(0x0930, 0x0227), .driver_info = BTUSB_ATH3012 },
  151. { USB_DEVICE(0x0b05, 0x17d0), .driver_info = BTUSB_ATH3012 },
  152. { USB_DEVICE(0x0CF3, 0x0036), .driver_info = BTUSB_ATH3012 },
  153. { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
  154. { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
  155. { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
  156. { USB_DEVICE(0x0cf3, 0x311E), .driver_info = BTUSB_ATH3012 },
  157. { USB_DEVICE(0x0cf3, 0x311F), .driver_info = BTUSB_ATH3012 },
  158. { USB_DEVICE(0x0cf3, 0x3121), .driver_info = BTUSB_ATH3012 },
  159. { USB_DEVICE(0x0CF3, 0x817a), .driver_info = BTUSB_ATH3012 },
  160. { USB_DEVICE(0x0CF3, 0x817b), .driver_info = BTUSB_ATH3012 },
  161. { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
  162. { USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
  163. { USB_DEVICE(0x0cf3, 0xe006), .driver_info = BTUSB_ATH3012 },
  164. { USB_DEVICE(0x0cf3, 0xe003), .driver_info = BTUSB_ATH3012 },
  165. { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
  166. { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
  167. { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
  168. { USB_DEVICE(0x13d3, 0x3395), .driver_info = BTUSB_ATH3012 },
  169. { USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 },
  170. { USB_DEVICE(0x13d3, 0x3408), .driver_info = BTUSB_ATH3012 },
  171. { USB_DEVICE(0x13d3, 0x3423), .driver_info = BTUSB_ATH3012 },
  172. { USB_DEVICE(0x13d3, 0x3432), .driver_info = BTUSB_ATH3012 },
  173. { USB_DEVICE(0x13d3, 0x3472), .driver_info = BTUSB_ATH3012 },
  174. { USB_DEVICE(0x13d3, 0x3474), .driver_info = BTUSB_ATH3012 },
  175. /* Atheros AR5BBU22 with sflash firmware */
  176. { USB_DEVICE(0x0489, 0xE036), .driver_info = BTUSB_ATH3012 },
  177. { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 },
  178. { } /* Terminating entry */
  179. };
  180. #define USB_REQ_DFU_DNLOAD 1
  181. #define BULK_SIZE 4096
  182. #define FW_HDR_SIZE 20
  183. #define TIMEGAP_USEC_MIN 50
  184. #define TIMEGAP_USEC_MAX 100
  185. static int ath3k_load_firmware(struct usb_device *udev,
  186. const struct firmware *firmware)
  187. {
  188. u8 *send_buf;
  189. int err, pipe, len, size, sent = 0;
  190. int count = firmware->size;
  191. BT_DBG("udev %p", udev);
  192. pipe = usb_sndctrlpipe(udev, 0);
  193. send_buf = kmalloc(BULK_SIZE, GFP_KERNEL);
  194. if (!send_buf) {
  195. BT_ERR("Can't allocate memory chunk for firmware");
  196. return -ENOMEM;
  197. }
  198. memcpy(send_buf, firmware->data, 20);
  199. err = usb_control_msg(udev, pipe, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR,
  200. 0, 0, send_buf, 20, USB_CTRL_SET_TIMEOUT);
  201. if (err < 0) {
  202. BT_ERR("Can't change to loading configuration err");
  203. goto error;
  204. }
  205. sent += 20;
  206. count -= 20;
  207. pipe = usb_sndbulkpipe(udev, 0x02);
  208. while (count) {
  209. /* workaround the compatibility issue with xHCI controller*/
  210. usleep_range(TIMEGAP_USEC_MIN, TIMEGAP_USEC_MAX);
  211. size = min_t(uint, count, BULK_SIZE);
  212. memcpy(send_buf, firmware->data + sent, size);
  213. err = usb_bulk_msg(udev, pipe, send_buf, size,
  214. &len, 3000);
  215. if (err || (len != size)) {
  216. BT_ERR("Error in firmware loading err = %d,"
  217. "len = %d, size = %d", err, len, size);
  218. goto error;
  219. }
  220. sent += size;
  221. count -= size;
  222. }
  223. error:
  224. kfree(send_buf);
  225. return err;
  226. }
  227. static int ath3k_get_state(struct usb_device *udev, unsigned char *state)
  228. {
  229. int ret, pipe = 0;
  230. char *buf;
  231. buf = kmalloc(sizeof(*buf), GFP_KERNEL);
  232. if (!buf)
  233. return -ENOMEM;
  234. pipe = usb_rcvctrlpipe(udev, 0);
  235. ret = usb_control_msg(udev, pipe, ATH3K_GETSTATE,
  236. USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
  237. buf, sizeof(*buf), USB_CTRL_SET_TIMEOUT);
  238. *state = *buf;
  239. kfree(buf);
  240. return ret;
  241. }
  242. static int ath3k_get_version(struct usb_device *udev,
  243. struct ath3k_version *version)
  244. {
  245. int ret, pipe = 0;
  246. struct ath3k_version *buf;
  247. const int size = sizeof(*buf);
  248. buf = kmalloc(size, GFP_KERNEL);
  249. if (!buf)
  250. return -ENOMEM;
  251. pipe = usb_rcvctrlpipe(udev, 0);
  252. ret = usb_control_msg(udev, pipe, ATH3K_GETVERSION,
  253. USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
  254. buf, size, USB_CTRL_SET_TIMEOUT);
  255. memcpy(version, buf, size);
  256. kfree(buf);
  257. return ret;
  258. }
  259. static int ath3k_load_fwfile(struct usb_device *udev,
  260. const struct firmware *firmware)
  261. {
  262. u8 *send_buf;
  263. int err, pipe, len, size, count, sent = 0;
  264. int ret;
  265. count = firmware->size;
  266. send_buf = kmalloc(BULK_SIZE, GFP_KERNEL);
  267. if (!send_buf) {
  268. BT_ERR("Can't allocate memory chunk for firmware");
  269. return -ENOMEM;
  270. }
  271. size = min_t(uint, count, FW_HDR_SIZE);
  272. memcpy(send_buf, firmware->data, size);
  273. pipe = usb_sndctrlpipe(udev, 0);
  274. ret = usb_control_msg(udev, pipe, ATH3K_DNLOAD,
  275. USB_TYPE_VENDOR, 0, 0, send_buf,
  276. size, USB_CTRL_SET_TIMEOUT);
  277. if (ret < 0) {
  278. BT_ERR("Can't change to loading configuration err");
  279. kfree(send_buf);
  280. return ret;
  281. }
  282. sent += size;
  283. count -= size;
  284. pipe = usb_sndbulkpipe(udev, 0x02);
  285. while (count) {
  286. /* workaround the compatibility issue with xHCI controller*/
  287. usleep_range(TIMEGAP_USEC_MIN, TIMEGAP_USEC_MAX);
  288. size = min_t(uint, count, BULK_SIZE);
  289. memcpy(send_buf, firmware->data + sent, size);
  290. err = usb_bulk_msg(udev, pipe, send_buf, size,
  291. &len, 3000);
  292. if (err || (len != size)) {
  293. BT_ERR("Error in firmware loading err = %d,"
  294. "len = %d, size = %d", err, len, size);
  295. kfree(send_buf);
  296. return err;
  297. }
  298. sent += size;
  299. count -= size;
  300. }
  301. kfree(send_buf);
  302. return 0;
  303. }
  304. static int ath3k_switch_pid(struct usb_device *udev)
  305. {
  306. int pipe = 0;
  307. pipe = usb_sndctrlpipe(udev, 0);
  308. return usb_control_msg(udev, pipe, USB_REG_SWITCH_VID_PID,
  309. USB_TYPE_VENDOR, 0, 0,
  310. NULL, 0, USB_CTRL_SET_TIMEOUT);
  311. }
  312. static int ath3k_set_normal_mode(struct usb_device *udev)
  313. {
  314. unsigned char fw_state;
  315. int pipe = 0, ret;
  316. ret = ath3k_get_state(udev, &fw_state);
  317. if (ret < 0) {
  318. BT_ERR("Can't get state to change to normal mode err");
  319. return ret;
  320. }
  321. if ((fw_state & ATH3K_MODE_MASK) == ATH3K_NORMAL_MODE) {
  322. BT_DBG("firmware was already in normal mode");
  323. return 0;
  324. }
  325. pipe = usb_sndctrlpipe(udev, 0);
  326. return usb_control_msg(udev, pipe, ATH3K_SET_NORMAL_MODE,
  327. USB_TYPE_VENDOR, 0, 0,
  328. NULL, 0, USB_CTRL_SET_TIMEOUT);
  329. }
  330. static int ath3k_load_patch(struct usb_device *udev)
  331. {
  332. unsigned char fw_state;
  333. char filename[ATH3K_NAME_LEN] = {0};
  334. const struct firmware *firmware;
  335. struct ath3k_version fw_version;
  336. __u32 pt_rom_version, pt_build_version;
  337. int ret;
  338. ret = ath3k_get_state(udev, &fw_state);
  339. if (ret < 0) {
  340. BT_ERR("Can't get state to change to load ram patch err");
  341. return ret;
  342. }
  343. if (fw_state & ATH3K_PATCH_UPDATE) {
  344. BT_DBG("Patch was already downloaded");
  345. return 0;
  346. }
  347. ret = ath3k_get_version(udev, &fw_version);
  348. if (ret < 0) {
  349. BT_ERR("Can't get version to change to load ram patch err");
  350. return ret;
  351. }
  352. snprintf(filename, ATH3K_NAME_LEN, "ar3k/AthrBT_0x%08x.dfu",
  353. le32_to_cpu(fw_version.rom_version));
  354. ret = request_firmware(&firmware, filename, &udev->dev);
  355. if (ret < 0) {
  356. BT_ERR("Patch file not found %s", filename);
  357. return ret;
  358. }
  359. pt_rom_version = get_unaligned_le32(firmware->data +
  360. firmware->size - 8);
  361. pt_build_version = get_unaligned_le32(firmware->data +
  362. firmware->size - 4);
  363. if (pt_rom_version != le32_to_cpu(fw_version.rom_version) ||
  364. pt_build_version <= le32_to_cpu(fw_version.build_version)) {
  365. BT_ERR("Patch file version did not match with firmware");
  366. release_firmware(firmware);
  367. return -EINVAL;
  368. }
  369. ret = ath3k_load_fwfile(udev, firmware);
  370. release_firmware(firmware);
  371. return ret;
  372. }
  373. static int ath3k_load_syscfg(struct usb_device *udev)
  374. {
  375. unsigned char fw_state;
  376. char filename[ATH3K_NAME_LEN] = {0};
  377. const struct firmware *firmware;
  378. struct ath3k_version fw_version;
  379. int clk_value, ret;
  380. ret = ath3k_get_state(udev, &fw_state);
  381. if (ret < 0) {
  382. BT_ERR("Can't get state to change to load configuration err");
  383. return -EBUSY;
  384. }
  385. ret = ath3k_get_version(udev, &fw_version);
  386. if (ret < 0) {
  387. BT_ERR("Can't get version to change to load ram patch err");
  388. return ret;
  389. }
  390. switch (fw_version.ref_clock) {
  391. case ATH3K_XTAL_FREQ_26M:
  392. clk_value = 26;
  393. break;
  394. case ATH3K_XTAL_FREQ_40M:
  395. clk_value = 40;
  396. break;
  397. case ATH3K_XTAL_FREQ_19P2:
  398. clk_value = 19;
  399. break;
  400. default:
  401. clk_value = 0;
  402. break;
  403. }
  404. snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
  405. le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
  406. ret = request_firmware(&firmware, filename, &udev->dev);
  407. if (ret < 0) {
  408. BT_ERR("Configuration file not found %s", filename);
  409. return ret;
  410. }
  411. ret = ath3k_load_fwfile(udev, firmware);
  412. release_firmware(firmware);
  413. return ret;
  414. }
  415. static int ath3k_probe(struct usb_interface *intf,
  416. const struct usb_device_id *id)
  417. {
  418. const struct firmware *firmware;
  419. struct usb_device *udev = interface_to_usbdev(intf);
  420. int ret;
  421. BT_DBG("intf %p id %p", intf, id);
  422. if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
  423. return -ENODEV;
  424. /* match device ID in ath3k blacklist table */
  425. if (!id->driver_info) {
  426. const struct usb_device_id *match;
  427. match = usb_match_id(intf, ath3k_blist_tbl);
  428. if (match)
  429. id = match;
  430. }
  431. /* load patch and sysconfig files for AR3012 */
  432. if (id->driver_info & BTUSB_ATH3012) {
  433. /* New firmware with patch and sysconfig files already loaded */
  434. if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x0001)
  435. return -ENODEV;
  436. ret = ath3k_load_patch(udev);
  437. if (ret < 0) {
  438. BT_ERR("Loading patch file failed");
  439. return ret;
  440. }
  441. ret = ath3k_load_syscfg(udev);
  442. if (ret < 0) {
  443. BT_ERR("Loading sysconfig file failed");
  444. return ret;
  445. }
  446. ret = ath3k_set_normal_mode(udev);
  447. if (ret < 0) {
  448. BT_ERR("Set normal mode failed");
  449. return ret;
  450. }
  451. ath3k_switch_pid(udev);
  452. return 0;
  453. }
  454. ret = request_firmware(&firmware, ATH3K_FIRMWARE, &udev->dev);
  455. if (ret < 0) {
  456. if (ret == -ENOENT)
  457. BT_ERR("Firmware file \"%s\" not found",
  458. ATH3K_FIRMWARE);
  459. else
  460. BT_ERR("Firmware file \"%s\" request failed (err=%d)",
  461. ATH3K_FIRMWARE, ret);
  462. return ret;
  463. }
  464. ret = ath3k_load_firmware(udev, firmware);
  465. release_firmware(firmware);
  466. return ret;
  467. }
  468. static void ath3k_disconnect(struct usb_interface *intf)
  469. {
  470. BT_DBG("ath3k_disconnect intf %p", intf);
  471. }
  472. static struct usb_driver ath3k_driver = {
  473. .name = "ath3k",
  474. .probe = ath3k_probe,
  475. .disconnect = ath3k_disconnect,
  476. .id_table = ath3k_table,
  477. .disable_hub_initiated_lpm = 1,
  478. };
  479. module_usb_driver(ath3k_driver);
  480. MODULE_AUTHOR("Atheros Communications");
  481. MODULE_DESCRIPTION("Atheros AR30xx firmware driver");
  482. MODULE_VERSION(VERSION);
  483. MODULE_LICENSE("GPL");
  484. MODULE_FIRMWARE(ATH3K_FIRMWARE);