hci_ath.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. /*
  2. * Atheros Communication Bluetooth HCIATH3K UART protocol
  3. *
  4. * HCIATH3K (HCI Atheros AR300x Protocol) is a Atheros Communication's
  5. * power management protocol extension to H4 to support AR300x Bluetooth Chip.
  6. *
  7. * Copyright (c) 2009-2010 Atheros Communications Inc.
  8. * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
  9. *
  10. * Acknowledgements:
  11. * This file is based on hci_h4.c, which was written
  12. * by Maxim Krasnyansky and Marcel Holtmann.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. *
  28. */
  29. #include <linux/module.h>
  30. #include <linux/kernel.h>
  31. #include <linux/init.h>
  32. #include <linux/slab.h>
  33. #include <linux/tty.h>
  34. #include <linux/errno.h>
  35. #include <linux/ioctl.h>
  36. #include <linux/skbuff.h>
  37. #include <linux/platform_device.h>
  38. #include <linux/gpio.h>
  39. #include <linux/of_gpio.h>
  40. #include <linux/proc_fs.h>
  41. #include <linux/jiffies.h>
  42. #include <net/bluetooth/bluetooth.h>
  43. #include <net/bluetooth/hci_core.h>
  44. #include "hci_uart.h"
  45. #ifdef CONFIG_SERIAL_MSM_HS
  46. #include <mach/msm_serial_hs.h>
  47. #endif
  48. static int enableuartsleep = 1;
  49. module_param(enableuartsleep, int, 0644);
  50. MODULE_PARM_DESC(enableuartsleep, "Enable Atheros Sleep Protocol");
  51. /*
  52. * Global variables
  53. */
  54. /** Device table */
  55. static struct of_device_id bluesleep_match_table[] = {
  56. { .compatible = "qca,ar3002_bluesleep" },
  57. {}
  58. };
  59. /** Global state flags */
  60. static unsigned long flags;
  61. /** To Check LPM is enabled */
  62. static bool is_lpm_enabled;
  63. /** Workqueue to respond to change in hostwake line */
  64. static void wakeup_host_work(struct work_struct *work);
  65. /** Transmission timer */
  66. static void bluesleep_tx_timer_expire(unsigned long data);
  67. static DEFINE_TIMER(tx_timer, bluesleep_tx_timer_expire, 0, 0);
  68. /** Lock for state transitions */
  69. static spinlock_t rw_lock;
  70. #define PROC_DIR "bluetooth/sleep"
  71. #define POLARITY_LOW 0
  72. #define POLARITY_HIGH 1
  73. struct bluesleep_info {
  74. unsigned host_wake; /* wake up host */
  75. unsigned ext_wake; /* wake up device */
  76. unsigned host_wake_irq;
  77. int irq_polarity;
  78. struct uart_port *uport;
  79. };
  80. struct work_struct ws_sleep;
  81. /* 1 second timeout */
  82. #define TX_TIMER_INTERVAL 1
  83. /* state variable names and bit positions */
  84. #define BT_TXEXPIRED 0x01
  85. #define BT_SLEEPENABLE 0x02
  86. #define BT_SLEEPCMD 0x03
  87. /* global pointer to a single hci device. */
  88. static struct bluesleep_info *bsi;
  89. struct ath_struct {
  90. struct hci_uart *hu;
  91. unsigned int cur_sleep;
  92. struct sk_buff_head txq;
  93. struct work_struct ctxtsw;
  94. };
  95. static void hsuart_serial_clock_on(struct uart_port *port)
  96. {
  97. BT_DBG("");
  98. if (port)
  99. msm_hs_request_clock_on(port);
  100. else
  101. BT_INFO("Uart has not voted for Clock ON");
  102. }
  103. static void hsuart_serial_clock_off(struct uart_port *port)
  104. {
  105. BT_DBG("");
  106. if (port)
  107. msm_hs_request_clock_off(port);
  108. else
  109. BT_INFO("Uart has not voted for Clock OFF");
  110. }
  111. static void modify_timer_task(void)
  112. {
  113. spin_lock(&rw_lock);
  114. mod_timer(&tx_timer, jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
  115. clear_bit(BT_TXEXPIRED, &flags);
  116. spin_unlock(&rw_lock);
  117. }
  118. static int ath_wakeup_ar3k(void)
  119. {
  120. int status = 0;
  121. if (test_bit(BT_TXEXPIRED, &flags)) {
  122. hsuart_serial_clock_on(bsi->uport);
  123. BT_DBG("wakeup device\n");
  124. gpio_set_value(bsi->ext_wake, 0);
  125. msleep(20);
  126. gpio_set_value(bsi->ext_wake, 1);
  127. }
  128. if (!is_lpm_enabled)
  129. modify_timer_task();
  130. return status;
  131. }
  132. static void wakeup_host_work(struct work_struct *work)
  133. {
  134. BT_DBG("wake up host");
  135. if (test_bit(BT_SLEEPENABLE, &flags)) {
  136. if (test_bit(BT_TXEXPIRED, &flags))
  137. hsuart_serial_clock_on(bsi->uport);
  138. }
  139. if (!is_lpm_enabled)
  140. modify_timer_task();
  141. }
  142. static void ath_hci_uart_work(struct work_struct *work)
  143. {
  144. int status;
  145. struct ath_struct *ath;
  146. struct hci_uart *hu;
  147. ath = container_of(work, struct ath_struct, ctxtsw);
  148. hu = ath->hu;
  149. /* verify and wake up controller */
  150. if (test_bit(BT_SLEEPENABLE, &flags))
  151. status = ath_wakeup_ar3k();
  152. /* Ready to send Data */
  153. clear_bit(HCI_UART_SENDING, &hu->tx_state);
  154. hci_uart_tx_wakeup(hu);
  155. }
  156. static irqreturn_t bluesleep_hostwake_isr(int irq, void *dev_id)
  157. {
  158. /* schedule a work to global shared workqueue to handle
  159. * the change in the host wake line
  160. */
  161. schedule_work(&ws_sleep);
  162. return IRQ_HANDLED;
  163. }
  164. static int ath_bluesleep_gpio_config(int on)
  165. {
  166. int ret = 0;
  167. BT_INFO("%s config: %d", __func__, on);
  168. if (!on) {
  169. if (disable_irq_wake(bsi->host_wake_irq))
  170. BT_ERR("Couldn't disable hostwake IRQ wakeup mode\n");
  171. goto free_host_wake_irq;
  172. }
  173. ret = gpio_request(bsi->host_wake, "bt_host_wake");
  174. if (ret < 0) {
  175. BT_ERR("failed to request gpio pin %d, error %d\n",
  176. bsi->host_wake, ret);
  177. goto gpio_config_failed;
  178. }
  179. /* configure host_wake as input */
  180. ret = gpio_direction_input(bsi->host_wake);
  181. if (ret < 0) {
  182. BT_ERR("failed to config GPIO %d as input pin, err %d\n",
  183. bsi->host_wake, ret);
  184. goto gpio_host_wake;
  185. }
  186. ret = gpio_request(bsi->ext_wake, "bt_ext_wake");
  187. if (ret < 0) {
  188. BT_ERR("failed to request gpio pin %d, error %d\n",
  189. bsi->ext_wake, ret);
  190. goto gpio_host_wake;
  191. }
  192. ret = gpio_direction_output(bsi->ext_wake, 1);
  193. if (ret < 0) {
  194. BT_ERR("failed to config GPIO %d as output pin, err %d\n",
  195. bsi->ext_wake, ret);
  196. goto gpio_ext_wake;
  197. }
  198. gpio_set_value(bsi->ext_wake, 1);
  199. /* Initialize spinlock. */
  200. spin_lock_init(&rw_lock);
  201. /* Initialize timer */
  202. init_timer(&tx_timer);
  203. tx_timer.function = bluesleep_tx_timer_expire;
  204. tx_timer.data = 0;
  205. if (bsi->irq_polarity == POLARITY_LOW) {
  206. ret = request_irq(bsi->host_wake_irq, bluesleep_hostwake_isr,
  207. IRQF_DISABLED | IRQF_TRIGGER_FALLING,
  208. "bluetooth hostwake", NULL);
  209. } else {
  210. ret = request_irq(bsi->host_wake_irq, bluesleep_hostwake_isr,
  211. IRQF_DISABLED | IRQF_TRIGGER_RISING,
  212. "bluetooth hostwake", NULL);
  213. }
  214. if (ret < 0) {
  215. BT_ERR("Couldn't acquire BT_HOST_WAKE IRQ");
  216. goto delete_timer;
  217. }
  218. ret = enable_irq_wake(bsi->host_wake_irq);
  219. if (ret < 0) {
  220. BT_ERR("Couldn't enable BT_HOST_WAKE as wakeup interrupt");
  221. goto free_host_wake_irq;
  222. }
  223. return 0;
  224. free_host_wake_irq:
  225. free_irq(bsi->host_wake_irq, NULL);
  226. delete_timer:
  227. del_timer(&tx_timer);
  228. gpio_ext_wake:
  229. gpio_free(bsi->ext_wake);
  230. gpio_host_wake:
  231. gpio_free(bsi->host_wake);
  232. gpio_config_failed:
  233. return ret;
  234. }
  235. static int ath_lpm_start(void)
  236. {
  237. BT_DBG("Start LPM mode");
  238. if (!bsi) {
  239. BT_ERR("HCIATH3K bluesleep info does not exist");
  240. return -EIO;
  241. }
  242. bsi->uport = msm_hs_get_uart_port(0);
  243. if (!bsi->uport) {
  244. BT_ERR("UART Port is not available");
  245. return -ENODEV;
  246. }
  247. INIT_WORK(&ws_sleep, wakeup_host_work);
  248. if (ath_bluesleep_gpio_config(1) < 0) {
  249. BT_ERR("HCIATH3K GPIO Config failed");
  250. return -EIO;
  251. }
  252. return 0;
  253. }
  254. static int ath_lpm_stop(void)
  255. {
  256. BT_DBG("Stop LPM mode");
  257. cancel_work_sync(&ws_sleep);
  258. if (bsi) {
  259. bsi->uport = NULL;
  260. ath_bluesleep_gpio_config(0);
  261. }
  262. return 0;
  263. }
  264. /* Initialize protocol */
  265. static int ath_open(struct hci_uart *hu)
  266. {
  267. struct ath_struct *ath;
  268. struct uart_state *state;
  269. BT_DBG("hu %p, bsi %p", hu, bsi);
  270. if (!bsi) {
  271. BT_ERR("HCIATH3K bluesleep info does not exist");
  272. return -EIO;
  273. }
  274. ath = kzalloc(sizeof(*ath), GFP_ATOMIC);
  275. if (!ath) {
  276. BT_ERR("HCIATH3K Memory not enough to init driver");
  277. return -ENOMEM;
  278. }
  279. skb_queue_head_init(&ath->txq);
  280. hu->priv = ath;
  281. ath->hu = hu;
  282. state = hu->tty->driver_data;
  283. if (!state) {
  284. BT_ERR("HCIATH3K tty driver data does not exist");
  285. return -ENXIO;
  286. }
  287. bsi->uport = state->uart_port;
  288. if (ath_bluesleep_gpio_config(1) < 0) {
  289. BT_ERR("HCIATH3K GPIO Config failed");
  290. hu->priv = NULL;
  291. kfree(ath);
  292. return -EIO;
  293. }
  294. ath->cur_sleep = enableuartsleep;
  295. if (ath->cur_sleep == 1) {
  296. set_bit(BT_SLEEPENABLE, &flags);
  297. modify_timer_task();
  298. }
  299. INIT_WORK(&ath->ctxtsw, ath_hci_uart_work);
  300. INIT_WORK(&ws_sleep, wakeup_host_work);
  301. return 0;
  302. }
  303. /* Flush protocol data */
  304. static int ath_flush(struct hci_uart *hu)
  305. {
  306. struct ath_struct *ath = hu->priv;
  307. BT_DBG("hu %p", hu);
  308. skb_queue_purge(&ath->txq);
  309. return 0;
  310. }
  311. /* Close protocol */
  312. static int ath_close(struct hci_uart *hu)
  313. {
  314. struct ath_struct *ath = hu->priv;
  315. BT_DBG("hu %p", hu);
  316. skb_queue_purge(&ath->txq);
  317. cancel_work_sync(&ath->ctxtsw);
  318. cancel_work_sync(&ws_sleep);
  319. if (bsi)
  320. ath_bluesleep_gpio_config(0);
  321. hu->priv = NULL;
  322. bsi->uport = NULL;
  323. kfree(ath);
  324. return 0;
  325. }
  326. #define HCI_OP_ATH_SLEEP 0xFC04
  327. /* Enqueue frame for transmittion */
  328. static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb)
  329. {
  330. struct ath_struct *ath = hu->priv;
  331. BT_DBG("");
  332. if (bt_cb(skb)->pkt_type == HCI_SCODATA_PKT) {
  333. kfree_skb(skb);
  334. return 0;
  335. }
  336. /*
  337. * Update power management enable flag with parameters of
  338. * HCI sleep enable vendor specific HCI command.
  339. */
  340. if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {
  341. struct hci_command_hdr *hdr = (void *)skb->data;
  342. if (__le16_to_cpu(hdr->opcode) == HCI_OP_ATH_SLEEP) {
  343. set_bit(BT_SLEEPCMD, &flags);
  344. ath->cur_sleep = skb->data[HCI_COMMAND_HDR_SIZE];
  345. }
  346. }
  347. BT_DBG("hu %p skb %p", hu, skb);
  348. /* Prepend skb with frame type */
  349. memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
  350. skb_queue_tail(&ath->txq, skb);
  351. set_bit(HCI_UART_SENDING, &hu->tx_state);
  352. schedule_work(&ath->ctxtsw);
  353. return 0;
  354. }
  355. static struct sk_buff *ath_dequeue(struct hci_uart *hu)
  356. {
  357. struct ath_struct *ath = hu->priv;
  358. return skb_dequeue(&ath->txq);
  359. }
  360. /* Recv data */
  361. static int ath_recv(struct hci_uart *hu, void *data, int count)
  362. {
  363. struct ath_struct *ath = hu->priv;
  364. unsigned int type;
  365. BT_DBG("");
  366. if (hci_recv_stream_fragment(hu->hdev, data, count) < 0)
  367. BT_ERR("Frame Reassembly Failed");
  368. if (count & test_bit(BT_SLEEPCMD, &flags)) {
  369. struct sk_buff *skb = hu->hdev->reassembly[0];
  370. if (!skb) {
  371. struct { char type; } *pkt;
  372. /* Start of the frame */
  373. pkt = data;
  374. type = pkt->type;
  375. } else
  376. type = bt_cb(skb)->pkt_type;
  377. if (type == HCI_EVENT_PKT) {
  378. clear_bit(BT_SLEEPCMD, &flags);
  379. BT_INFO("cur_sleep:%d\n", ath->cur_sleep);
  380. if (ath->cur_sleep == 1)
  381. set_bit(BT_SLEEPENABLE, &flags);
  382. else
  383. clear_bit(BT_SLEEPENABLE, &flags);
  384. }
  385. if (test_bit(BT_SLEEPENABLE, &flags))
  386. modify_timer_task();
  387. }
  388. return count;
  389. }
  390. static void bluesleep_tx_timer_expire(unsigned long data)
  391. {
  392. if (!test_bit(BT_SLEEPENABLE, &flags))
  393. return;
  394. BT_INFO("Tx timer expired\n");
  395. set_bit(BT_TXEXPIRED, &flags);
  396. hsuart_serial_clock_off(bsi->uport);
  397. }
  398. static struct hci_uart_proto athp = {
  399. .id = HCI_UART_ATH3K,
  400. .open = ath_open,
  401. .close = ath_close,
  402. .recv = ath_recv,
  403. .enqueue = ath_enqueue,
  404. .dequeue = ath_dequeue,
  405. .flush = ath_flush,
  406. };
  407. static int lpm_enabled;
  408. static int bluesleep_lpm_set(const char *val, const struct kernel_param *kp)
  409. {
  410. int ret;
  411. ret = param_set_int(val, kp);
  412. if (ret) {
  413. BT_ERR("HCIATH3K: lpm enable parameter set failed");
  414. return ret;
  415. }
  416. BT_DBG("lpm : %d", lpm_enabled);
  417. if ((lpm_enabled == 0) && is_lpm_enabled) {
  418. ath_lpm_stop();
  419. clear_bit(BT_SLEEPENABLE, &flags);
  420. is_lpm_enabled = false;
  421. } else if ((lpm_enabled == 1) && !is_lpm_enabled) {
  422. if (ath_lpm_start() < 0) {
  423. BT_ERR("HCIATH3K LPM mode failed");
  424. return -EIO;
  425. }
  426. set_bit(BT_SLEEPENABLE, &flags);
  427. is_lpm_enabled = true;
  428. } else {
  429. BT_ERR("HCIATH3K invalid lpm value");
  430. return -EINVAL;
  431. }
  432. return 0;
  433. }
  434. static struct kernel_param_ops bluesleep_lpm_ops = {
  435. .set = bluesleep_lpm_set,
  436. .get = param_get_int,
  437. };
  438. module_param_cb(ath_lpm, &bluesleep_lpm_ops,
  439. &lpm_enabled, S_IRUGO | S_IWUSR);
  440. MODULE_PARM_DESC(ath_lpm, "Enable Atheros LPM sleep Protocol");
  441. static int lpm_btwrite;
  442. static int bluesleep_lpm_btwrite(const char *val, const struct kernel_param *kp)
  443. {
  444. int ret;
  445. ret = param_set_int(val, kp);
  446. if (ret) {
  447. BT_ERR("HCIATH3K: lpm btwrite parameter set failed");
  448. return ret;
  449. }
  450. BT_DBG("btwrite : %d", lpm_btwrite);
  451. if (is_lpm_enabled) {
  452. if (lpm_btwrite == 0) {
  453. /*Setting TXEXPIRED bit to make it
  454. compatible with current solution*/
  455. set_bit(BT_TXEXPIRED, &flags);
  456. hsuart_serial_clock_off(bsi->uport);
  457. } else if (lpm_btwrite == 1) {
  458. ath_wakeup_ar3k();
  459. clear_bit(BT_TXEXPIRED, &flags);
  460. } else {
  461. BT_ERR("HCIATH3K invalid btwrite value");
  462. return -EINVAL;
  463. }
  464. }
  465. return 0;
  466. }
  467. static struct kernel_param_ops bluesleep_lpm_btwrite_ops = {
  468. .set = bluesleep_lpm_btwrite,
  469. .get = param_get_int,
  470. };
  471. module_param_cb(ath_btwrite, &bluesleep_lpm_btwrite_ops,
  472. &lpm_btwrite, S_IRUGO | S_IWUSR);
  473. MODULE_PARM_DESC(ath_lpm, "Assert/Deassert the sleep");
  474. static int bluesleep_populate_dt_pinfo(struct platform_device *pdev)
  475. {
  476. BT_DBG("");
  477. if (!bsi)
  478. return -ENOMEM;
  479. bsi->host_wake = of_get_named_gpio(pdev->dev.of_node,
  480. "host-wake-gpio", 0);
  481. if (bsi->host_wake < 0) {
  482. BT_ERR("couldn't find host_wake gpio\n");
  483. return -ENODEV;
  484. }
  485. bsi->ext_wake = of_get_named_gpio(pdev->dev.of_node,
  486. "ext-wake-gpio", 0);
  487. if (bsi->ext_wake < 0) {
  488. BT_ERR("couldn't find ext_wake gpio\n");
  489. return -ENODEV;
  490. }
  491. return 0;
  492. }
  493. static int bluesleep_populate_pinfo(struct platform_device *pdev)
  494. {
  495. struct resource *res;
  496. BT_DBG("");
  497. res = platform_get_resource_byname(pdev, IORESOURCE_IO,
  498. "gpio_host_wake");
  499. if (!res) {
  500. BT_ERR("couldn't find host_wake gpio\n");
  501. return -ENODEV;
  502. }
  503. bsi->host_wake = res->start;
  504. res = platform_get_resource_byname(pdev, IORESOURCE_IO,
  505. "gpio_ext_wake");
  506. if (!res) {
  507. BT_ERR("couldn't find ext_wake gpio\n");
  508. return -ENODEV;
  509. }
  510. bsi->ext_wake = res->start;
  511. return 0;
  512. }
  513. static int __devinit bluesleep_probe(struct platform_device *pdev)
  514. {
  515. int ret;
  516. BT_DBG("");
  517. bsi = kzalloc(sizeof(struct bluesleep_info), GFP_KERNEL);
  518. if (!bsi) {
  519. ret = -ENOMEM;
  520. goto failed;
  521. }
  522. if (pdev->dev.of_node) {
  523. ret = bluesleep_populate_dt_pinfo(pdev);
  524. if (ret < 0) {
  525. BT_ERR("Failed to populate device tree info");
  526. goto free_bsi;
  527. }
  528. } else {
  529. ret = bluesleep_populate_pinfo(pdev);
  530. if (ret < 0) {
  531. BT_ERR("Failed to populate device info");
  532. goto free_bsi;
  533. }
  534. }
  535. BT_DBG("host_wake_gpio: %d ext_wake_gpio: %d",
  536. bsi->host_wake, bsi->ext_wake);
  537. bsi->host_wake_irq = platform_get_irq_byname(pdev, "host_wake");
  538. if (bsi->host_wake_irq < 0) {
  539. BT_ERR("couldn't find host_wake irq\n");
  540. ret = -ENODEV;
  541. goto free_bsi;
  542. }
  543. bsi->irq_polarity = POLARITY_LOW; /* low edge (falling edge) */
  544. return 0;
  545. free_bsi:
  546. kfree(bsi);
  547. bsi = NULL;
  548. failed:
  549. return ret;
  550. }
  551. static int bluesleep_remove(struct platform_device *pdev)
  552. {
  553. kfree(bsi);
  554. return 0;
  555. }
  556. static struct platform_driver bluesleep_driver = {
  557. .probe = bluesleep_probe,
  558. .remove = bluesleep_remove,
  559. .driver = {
  560. .name = "bluesleep",
  561. .owner = THIS_MODULE,
  562. .of_match_table = bluesleep_match_table,
  563. },
  564. };
  565. int __init ath_init(void)
  566. {
  567. int ret;
  568. ret = hci_uart_register_proto(&athp);
  569. if (!ret)
  570. BT_INFO("HCIATH3K protocol initialized");
  571. else {
  572. BT_ERR("HCIATH3K protocol registration failed");
  573. return ret;
  574. }
  575. ret = platform_driver_register(&bluesleep_driver);
  576. if (ret) {
  577. BT_ERR("Failed to register bluesleep driver");
  578. return ret;
  579. }
  580. return 0;
  581. }
  582. int __exit ath_deinit(void)
  583. {
  584. platform_driver_unregister(&bluesleep_driver);
  585. return hci_uart_unregister_proto(&athp);
  586. }