aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2010-07-29 14:47:07 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-07-29 14:47:07 -0400
commitae3568adf42d5d3bb3cfa505b94351c5d1ce4924 (patch)
tree112865a6e6b1e4ddf70362f3efb295c495ec85b9 /drivers/bluetooth
parent7f3e01fee41a322747db2d7574516d9fbd3785c0 (diff)
parentb7753c8cd51dce67a0b152efb456a21ff1cc241b (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6 into for-davem
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/Kconfig12
-rw-r--r--drivers/bluetooth/Makefile1
-rw-r--r--drivers/bluetooth/bcm203x.c3
-rw-r--r--drivers/bluetooth/bpa10x.c2
-rw-r--r--drivers/bluetooth/btmrvl_debugfs.c2
-rw-r--r--drivers/bluetooth/btmrvl_drv.h5
-rw-r--r--drivers/bluetooth/btmrvl_main.c5
-rw-r--r--drivers/bluetooth/btmrvl_sdio.c111
-rw-r--r--drivers/bluetooth/btusb.c13
-rw-r--r--drivers/bluetooth/dtl1_cs.c2
-rw-r--r--drivers/bluetooth/hci_ath.c235
-rw-r--r--drivers/bluetooth/hci_bcsp.c4
-rw-r--r--drivers/bluetooth/hci_h4.c107
-rw-r--r--drivers/bluetooth/hci_ldisc.c20
-rw-r--r--drivers/bluetooth/hci_ll.c6
-rw-r--r--drivers/bluetooth/hci_uart.h15
16 files changed, 361 insertions, 182 deletions
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 058fbccf2f52..02deef424926 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -58,6 +58,18 @@ config BT_HCIUART_BCSP
58 58
59 Say Y here to compile support for HCI BCSP protocol. 59 Say Y here to compile support for HCI BCSP protocol.
60 60
61config BT_HCIUART_ATH3K
62 bool "Atheros AR300x serial support"
63 depends on BT_HCIUART
64 help
65 HCIATH3K (HCI Atheros AR300x) is a serial protocol for
66 communication between host and Atheros AR300x Bluetooth devices.
67 This protocol enables AR300x chips to be enabled with
68 power management support.
69 Enable this if you have Atheros AR300x serial Bluetooth device.
70
71 Say Y here to compile support for HCI UART ATH3K protocol.
72
61config BT_HCIUART_LL 73config BT_HCIUART_LL
62 bool "HCILL protocol support" 74 bool "HCILL protocol support"
63 depends on BT_HCIUART 75 depends on BT_HCIUART
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index 7e5aed598121..71bdf13287c4 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -26,4 +26,5 @@ hci_uart-y := hci_ldisc.o
26hci_uart-$(CONFIG_BT_HCIUART_H4) += hci_h4.o 26hci_uart-$(CONFIG_BT_HCIUART_H4) += hci_h4.o
27hci_uart-$(CONFIG_BT_HCIUART_BCSP) += hci_bcsp.o 27hci_uart-$(CONFIG_BT_HCIUART_BCSP) += hci_bcsp.o
28hci_uart-$(CONFIG_BT_HCIUART_LL) += hci_ll.o 28hci_uart-$(CONFIG_BT_HCIUART_LL) += hci_ll.o
29hci_uart-$(CONFIG_BT_HCIUART_ATH3K) += hci_ath.o
29hci_uart-objs := $(hci_uart-y) 30hci_uart-objs := $(hci_uart-y)
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index b0c84c19f442..8b1b643a519b 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -224,7 +224,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
224 224
225 BT_DBG("firmware data %p size %zu", firmware->data, firmware->size); 225 BT_DBG("firmware data %p size %zu", firmware->data, firmware->size);
226 226
227 data->fw_data = kmalloc(firmware->size, GFP_KERNEL); 227 data->fw_data = kmemdup(firmware->data, firmware->size, GFP_KERNEL);
228 if (!data->fw_data) { 228 if (!data->fw_data) {
229 BT_ERR("Can't allocate memory for firmware image"); 229 BT_ERR("Can't allocate memory for firmware image");
230 release_firmware(firmware); 230 release_firmware(firmware);
@@ -234,7 +234,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
234 return -ENOMEM; 234 return -ENOMEM;
235 } 235 }
236 236
237 memcpy(data->fw_data, firmware->data, firmware->size);
238 data->fw_size = firmware->size; 237 data->fw_size = firmware->size;
239 data->fw_sent = 0; 238 data->fw_sent = 0;
240 239
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index d945cd12433a..751b338d904a 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -62,7 +62,7 @@ struct hci_vendor_hdr {
62 __u8 type; 62 __u8 type;
63 __le16 snum; 63 __le16 snum;
64 __le16 dlen; 64 __le16 dlen;
65} __attribute__ ((packed)); 65} __packed;
66 66
67static int bpa10x_recv(struct hci_dev *hdev, int queue, void *buf, int count) 67static int bpa10x_recv(struct hci_dev *hdev, int queue, void *buf, int count)
68{ 68{
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index b50b41d97a7f..54739b08c308 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -216,7 +216,7 @@ static const struct file_operations btmrvl_gpiogap_fops = {
216static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf, 216static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
217 size_t count, loff_t *ppos) 217 size_t count, loff_t *ppos)
218{ 218{
219 struct btmrvl_private *priv = (struct btmrvl_private *) file->private_data; 219 struct btmrvl_private *priv = file->private_data;
220 char buf[16]; 220 char buf[16];
221 long result, ret; 221 long result, ret;
222 222
diff --git a/drivers/bluetooth/btmrvl_drv.h b/drivers/bluetooth/btmrvl_drv.h
index bed0ba630235..90bda50dc446 100644
--- a/drivers/bluetooth/btmrvl_drv.h
+++ b/drivers/bluetooth/btmrvl_drv.h
@@ -76,6 +76,7 @@ struct btmrvl_private {
76 int (*hw_host_to_card) (struct btmrvl_private *priv, 76 int (*hw_host_to_card) (struct btmrvl_private *priv,
77 u8 *payload, u16 nb); 77 u8 *payload, u16 nb);
78 int (*hw_wakeup_firmware) (struct btmrvl_private *priv); 78 int (*hw_wakeup_firmware) (struct btmrvl_private *priv);
79 int (*hw_process_int_status) (struct btmrvl_private *priv);
79 spinlock_t driver_lock; /* spinlock used by driver */ 80 spinlock_t driver_lock; /* spinlock used by driver */
80#ifdef CONFIG_DEBUG_FS 81#ifdef CONFIG_DEBUG_FS
81 void *debugfs_data; 82 void *debugfs_data;
@@ -118,13 +119,13 @@ struct btmrvl_cmd {
118 __le16 ocf_ogf; 119 __le16 ocf_ogf;
119 u8 length; 120 u8 length;
120 u8 data[4]; 121 u8 data[4];
121} __attribute__ ((packed)); 122} __packed;
122 123
123struct btmrvl_event { 124struct btmrvl_event {
124 u8 ec; /* event counter */ 125 u8 ec; /* event counter */
125 u8 length; 126 u8 length;
126 u8 data[4]; 127 u8 data[4];
127} __attribute__ ((packed)); 128} __packed;
128 129
129/* Prototype of global function */ 130/* Prototype of global function */
130 131
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index ee37ef0caee2..0d32ec82e9bf 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -502,14 +502,17 @@ static int btmrvl_service_main_thread(void *data)
502 spin_lock_irqsave(&priv->driver_lock, flags); 502 spin_lock_irqsave(&priv->driver_lock, flags);
503 if (adapter->int_count) { 503 if (adapter->int_count) {
504 adapter->int_count = 0; 504 adapter->int_count = 0;
505 spin_unlock_irqrestore(&priv->driver_lock, flags);
506 priv->hw_process_int_status(priv);
505 } else if (adapter->ps_state == PS_SLEEP && 507 } else if (adapter->ps_state == PS_SLEEP &&
506 !skb_queue_empty(&adapter->tx_queue)) { 508 !skb_queue_empty(&adapter->tx_queue)) {
507 spin_unlock_irqrestore(&priv->driver_lock, flags); 509 spin_unlock_irqrestore(&priv->driver_lock, flags);
508 adapter->wakeup_tries++; 510 adapter->wakeup_tries++;
509 priv->hw_wakeup_firmware(priv); 511 priv->hw_wakeup_firmware(priv);
510 continue; 512 continue;
513 } else {
514 spin_unlock_irqrestore(&priv->driver_lock, flags);
511 } 515 }
512 spin_unlock_irqrestore(&priv->driver_lock, flags);
513 516
514 if (adapter->ps_state == PS_SLEEP) 517 if (adapter->ps_state == PS_SLEEP)
515 continue; 518 continue;
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index df0773ebd9e4..dcc2a6ec23f0 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -47,6 +47,7 @@
47 * module_exit function is called. 47 * module_exit function is called.
48 */ 48 */
49static u8 user_rmmod; 49static u8 user_rmmod;
50static u8 sdio_ireg;
50 51
51static const struct btmrvl_sdio_device btmrvl_sdio_sd6888 = { 52static const struct btmrvl_sdio_device btmrvl_sdio_sd6888 = {
52 .helper = "sd8688_helper.bin", 53 .helper = "sd8688_helper.bin",
@@ -83,10 +84,10 @@ static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_card *card, u16 *dat)
83 *dat = 0; 84 *dat = 0;
84 85
85 fws0 = sdio_readb(card->func, CARD_FW_STATUS0_REG, &ret); 86 fws0 = sdio_readb(card->func, CARD_FW_STATUS0_REG, &ret);
87 if (ret)
88 return -EIO;
86 89
87 if (!ret) 90 fws1 = sdio_readb(card->func, CARD_FW_STATUS1_REG, &ret);
88 fws1 = sdio_readb(card->func, CARD_FW_STATUS1_REG, &ret);
89
90 if (ret) 91 if (ret)
91 return -EIO; 92 return -EIO;
92 93
@@ -216,7 +217,7 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
216 217
217 tmphlprbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN); 218 tmphlprbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN);
218 219
219 tmphlprbuf = kmalloc(tmphlprbufsz, GFP_KERNEL); 220 tmphlprbuf = kzalloc(tmphlprbufsz, GFP_KERNEL);
220 if (!tmphlprbuf) { 221 if (!tmphlprbuf) {
221 BT_ERR("Unable to allocate buffer for helper." 222 BT_ERR("Unable to allocate buffer for helper."
222 " Terminating download"); 223 " Terminating download");
@@ -224,8 +225,6 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
224 goto done; 225 goto done;
225 } 226 }
226 227
227 memset(tmphlprbuf, 0, tmphlprbufsz);
228
229 helperbuf = (u8 *) ALIGN_ADDR(tmphlprbuf, BTSDIO_DMA_ALIGN); 228 helperbuf = (u8 *) ALIGN_ADDR(tmphlprbuf, BTSDIO_DMA_ALIGN);
230 229
231 /* Perform helper data transfer */ 230 /* Perform helper data transfer */
@@ -318,7 +317,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
318 BT_DBG("Downloading FW image (%d bytes)", firmwarelen); 317 BT_DBG("Downloading FW image (%d bytes)", firmwarelen);
319 318
320 tmpfwbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN); 319 tmpfwbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN);
321 tmpfwbuf = kmalloc(tmpfwbufsz, GFP_KERNEL); 320 tmpfwbuf = kzalloc(tmpfwbufsz, GFP_KERNEL);
322 if (!tmpfwbuf) { 321 if (!tmpfwbuf) {
323 BT_ERR("Unable to allocate buffer for firmware." 322 BT_ERR("Unable to allocate buffer for firmware."
324 " Terminating download"); 323 " Terminating download");
@@ -326,8 +325,6 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
326 goto done; 325 goto done;
327 } 326 }
328 327
329 memset(tmpfwbuf, 0, tmpfwbufsz);
330
331 /* Ensure aligned firmware buffer */ 328 /* Ensure aligned firmware buffer */
332 fwbuf = (u8 *) ALIGN_ADDR(tmpfwbuf, BTSDIO_DMA_ALIGN); 329 fwbuf = (u8 *) ALIGN_ADDR(tmpfwbuf, BTSDIO_DMA_ALIGN);
333 330
@@ -555,78 +552,79 @@ exit:
555 return ret; 552 return ret;
556} 553}
557 554
558static int btmrvl_sdio_get_int_status(struct btmrvl_private *priv, u8 * ireg) 555static int btmrvl_sdio_process_int_status(struct btmrvl_private *priv)
559{ 556{
560 int ret; 557 ulong flags;
561 u8 sdio_ireg = 0; 558 u8 ireg;
562 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; 559 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
563 560
564 *ireg = 0; 561 spin_lock_irqsave(&priv->driver_lock, flags);
565 562 ireg = sdio_ireg;
566 sdio_ireg = sdio_readb(card->func, HOST_INTSTATUS_REG, &ret); 563 sdio_ireg = 0;
567 if (ret) { 564 spin_unlock_irqrestore(&priv->driver_lock, flags);
568 BT_ERR("sdio_readb: read int status register failed");
569 ret = -EIO;
570 goto done;
571 }
572
573 if (sdio_ireg != 0) {
574 /*
575 * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
576 * Clear the interrupt status register and re-enable the
577 * interrupt.
578 */
579 BT_DBG("sdio_ireg = 0x%x", sdio_ireg);
580
581 sdio_writeb(card->func, ~(sdio_ireg) & (DN_LD_HOST_INT_STATUS |
582 UP_LD_HOST_INT_STATUS),
583 HOST_INTSTATUS_REG, &ret);
584 if (ret) {
585 BT_ERR("sdio_writeb: clear int status register "
586 "failed");
587 ret = -EIO;
588 goto done;
589 }
590 }
591 565
592 if (sdio_ireg & DN_LD_HOST_INT_STATUS) { 566 sdio_claim_host(card->func);
567 if (ireg & DN_LD_HOST_INT_STATUS) {
593 if (priv->btmrvl_dev.tx_dnld_rdy) 568 if (priv->btmrvl_dev.tx_dnld_rdy)
594 BT_DBG("tx_done already received: " 569 BT_DBG("tx_done already received: "
595 " int_status=0x%x", sdio_ireg); 570 " int_status=0x%x", ireg);
596 else 571 else
597 priv->btmrvl_dev.tx_dnld_rdy = true; 572 priv->btmrvl_dev.tx_dnld_rdy = true;
598 } 573 }
599 574
600 if (sdio_ireg & UP_LD_HOST_INT_STATUS) 575 if (ireg & UP_LD_HOST_INT_STATUS)
601 btmrvl_sdio_card_to_host(priv); 576 btmrvl_sdio_card_to_host(priv);
602 577
603 *ireg = sdio_ireg; 578 sdio_release_host(card->func);
604
605 ret = 0;
606 579
607done: 580 return 0;
608 return ret;
609} 581}
610 582
611static void btmrvl_sdio_interrupt(struct sdio_func *func) 583static void btmrvl_sdio_interrupt(struct sdio_func *func)
612{ 584{
613 struct btmrvl_private *priv; 585 struct btmrvl_private *priv;
614 struct hci_dev *hcidev;
615 struct btmrvl_sdio_card *card; 586 struct btmrvl_sdio_card *card;
587 ulong flags;
616 u8 ireg = 0; 588 u8 ireg = 0;
589 int ret;
617 590
618 card = sdio_get_drvdata(func); 591 card = sdio_get_drvdata(func);
619 if (card && card->priv) { 592 if (!card || !card->priv) {
620 priv = card->priv; 593 BT_ERR("sbi_interrupt(%p) card or priv is "
621 hcidev = priv->btmrvl_dev.hcidev; 594 "NULL, card=%p\n", func, card);
595 return;
596 }
622 597
623 if (btmrvl_sdio_get_int_status(priv, &ireg)) 598 priv = card->priv;
624 BT_ERR("reading HOST_INT_STATUS_REG failed"); 599
625 else 600 ireg = sdio_readb(card->func, HOST_INTSTATUS_REG, &ret);
626 BT_DBG("HOST_INT_STATUS_REG %#x", ireg); 601 if (ret) {
602 BT_ERR("sdio_readb: read int status register failed");
603 return;
604 }
605
606 if (ireg != 0) {
607 /*
608 * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
609 * Clear the interrupt status register and re-enable the
610 * interrupt.
611 */
612 BT_DBG("ireg = 0x%x", ireg);
627 613
628 btmrvl_interrupt(priv); 614 sdio_writeb(card->func, ~(ireg) & (DN_LD_HOST_INT_STATUS |
615 UP_LD_HOST_INT_STATUS),
616 HOST_INTSTATUS_REG, &ret);
617 if (ret) {
618 BT_ERR("sdio_writeb: clear int status register failed");
619 return;
620 }
629 } 621 }
622
623 spin_lock_irqsave(&priv->driver_lock, flags);
624 sdio_ireg |= ireg;
625 spin_unlock_irqrestore(&priv->driver_lock, flags);
626
627 btmrvl_interrupt(priv);
630} 628}
631 629
632static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card) 630static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
@@ -930,6 +928,7 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
930 /* Initialize the interface specific function pointers */ 928 /* Initialize the interface specific function pointers */
931 priv->hw_host_to_card = btmrvl_sdio_host_to_card; 929 priv->hw_host_to_card = btmrvl_sdio_host_to_card;
932 priv->hw_wakeup_firmware = btmrvl_sdio_wakeup_fw; 930 priv->hw_wakeup_firmware = btmrvl_sdio_wakeup_fw;
931 priv->hw_process_int_status = btmrvl_sdio_process_int_status;
933 932
934 if (btmrvl_register_hdev(priv)) { 933 if (btmrvl_register_hdev(priv)) {
935 BT_ERR("Register hdev failed!"); 934 BT_ERR("Register hdev failed!");
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 5d9cc53bd643..d22ce3cc611e 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -59,6 +59,9 @@ static struct usb_device_id btusb_table[] = {
59 /* Generic Bluetooth USB device */ 59 /* Generic Bluetooth USB device */
60 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, 60 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
61 61
62 /* Apple iMac11,1 */
63 { USB_DEVICE(0x05ac, 0x8215) },
64
62 /* AVM BlueFRITZ! USB v2.0 */ 65 /* AVM BlueFRITZ! USB v2.0 */
63 { USB_DEVICE(0x057c, 0x3800) }, 66 { USB_DEVICE(0x057c, 0x3800) },
64 67
@@ -146,6 +149,7 @@ static struct usb_device_id blacklist_table[] = {
146#define BTUSB_BULK_RUNNING 1 149#define BTUSB_BULK_RUNNING 1
147#define BTUSB_ISOC_RUNNING 2 150#define BTUSB_ISOC_RUNNING 2
148#define BTUSB_SUSPENDING 3 151#define BTUSB_SUSPENDING 3
152#define BTUSB_DID_ISO_RESUME 4
149 153
150struct btusb_data { 154struct btusb_data {
151 struct hci_dev *hdev; 155 struct hci_dev *hdev;
@@ -179,7 +183,6 @@ struct btusb_data {
179 unsigned int sco_num; 183 unsigned int sco_num;
180 int isoc_altsetting; 184 int isoc_altsetting;
181 int suspend_count; 185 int suspend_count;
182 int did_iso_resume:1;
183}; 186};
184 187
185static int inc_tx(struct btusb_data *data) 188static int inc_tx(struct btusb_data *data)
@@ -807,7 +810,7 @@ static void btusb_work(struct work_struct *work)
807 int err; 810 int err;
808 811
809 if (hdev->conn_hash.sco_num > 0) { 812 if (hdev->conn_hash.sco_num > 0) {
810 if (!data->did_iso_resume) { 813 if (!test_bit(BTUSB_DID_ISO_RESUME, &data->flags)) {
811 err = usb_autopm_get_interface(data->isoc); 814 err = usb_autopm_get_interface(data->isoc);
812 if (err < 0) { 815 if (err < 0) {
813 clear_bit(BTUSB_ISOC_RUNNING, &data->flags); 816 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
@@ -815,7 +818,7 @@ static void btusb_work(struct work_struct *work)
815 return; 818 return;
816 } 819 }
817 820
818 data->did_iso_resume = 1; 821 set_bit(BTUSB_DID_ISO_RESUME, &data->flags);
819 } 822 }
820 if (data->isoc_altsetting != 2) { 823 if (data->isoc_altsetting != 2) {
821 clear_bit(BTUSB_ISOC_RUNNING, &data->flags); 824 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
@@ -836,10 +839,8 @@ static void btusb_work(struct work_struct *work)
836 usb_kill_anchored_urbs(&data->isoc_anchor); 839 usb_kill_anchored_urbs(&data->isoc_anchor);
837 840
838 __set_isoc_interface(hdev, 0); 841 __set_isoc_interface(hdev, 0);
839 if (data->did_iso_resume) { 842 if (test_and_clear_bit(BTUSB_DID_ISO_RESUME, &data->flags))
840 data->did_iso_resume = 0;
841 usb_autopm_put_interface(data->isoc); 843 usb_autopm_put_interface(data->isoc);
842 }
843 } 844 }
844} 845}
845 846
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index ef044d55cb25..cbe9e44a42e9 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -104,7 +104,7 @@ typedef struct {
104 u8 type; 104 u8 type;
105 u8 zero; 105 u8 zero;
106 u16 len; 106 u16 len;
107} __attribute__ ((packed)) nsh_t; /* Nokia Specific Header */ 107} __packed nsh_t; /* Nokia Specific Header */
108 108
109#define NSHL 4 /* Nokia Specific Header Length */ 109#define NSHL 4 /* Nokia Specific Header Length */
110 110
diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c
new file mode 100644
index 000000000000..6a160c17ea94
--- /dev/null
+++ b/drivers/bluetooth/hci_ath.c
@@ -0,0 +1,235 @@
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 *
9 * Acknowledgements:
10 * This file is based on hci_h4.c, which was written
11 * by Maxim Krasnyansky and Marcel Holtmann.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29#include <linux/module.h>
30#include <linux/kernel.h>
31
32#include <linux/init.h>
33#include <linux/slab.h>
34#include <linux/tty.h>
35#include <linux/errno.h>
36#include <linux/ioctl.h>
37#include <linux/skbuff.h>
38
39#include <net/bluetooth/bluetooth.h>
40#include <net/bluetooth/hci_core.h>
41
42#include "hci_uart.h"
43
44struct ath_struct {
45 struct hci_uart *hu;
46 unsigned int cur_sleep;
47
48 struct sk_buff_head txq;
49 struct work_struct ctxtsw;
50};
51
52static int ath_wakeup_ar3k(struct tty_struct *tty)
53{
54 struct termios settings;
55 int status = tty->driver->ops->tiocmget(tty, NULL);
56
57 if (status & TIOCM_CTS)
58 return status;
59
60 /* Disable Automatic RTSCTS */
61 n_tty_ioctl_helper(tty, NULL, TCGETS, (unsigned long)&settings);
62 settings.c_cflag &= ~CRTSCTS;
63 n_tty_ioctl_helper(tty, NULL, TCSETS, (unsigned long)&settings);
64
65 /* Clear RTS first */
66 status = tty->driver->ops->tiocmget(tty, NULL);
67 tty->driver->ops->tiocmset(tty, NULL, 0x00, TIOCM_RTS);
68 mdelay(20);
69
70 /* Set RTS, wake up board */
71 status = tty->driver->ops->tiocmget(tty, NULL);
72 tty->driver->ops->tiocmset(tty, NULL, TIOCM_RTS, 0x00);
73 mdelay(20);
74
75 status = tty->driver->ops->tiocmget(tty, NULL);
76
77 n_tty_ioctl_helper(tty, NULL, TCGETS, (unsigned long)&settings);
78 settings.c_cflag |= CRTSCTS;
79 n_tty_ioctl_helper(tty, NULL, TCSETS, (unsigned long)&settings);
80
81 return status;
82}
83
84static void ath_hci_uart_work(struct work_struct *work)
85{
86 int status;
87 struct ath_struct *ath;
88 struct hci_uart *hu;
89 struct tty_struct *tty;
90
91 ath = container_of(work, struct ath_struct, ctxtsw);
92
93 hu = ath->hu;
94 tty = hu->tty;
95
96 /* verify and wake up controller */
97 if (ath->cur_sleep) {
98 status = ath_wakeup_ar3k(tty);
99 if (!(status & TIOCM_CTS))
100 return;
101 }
102
103 /* Ready to send Data */
104 clear_bit(HCI_UART_SENDING, &hu->tx_state);
105 hci_uart_tx_wakeup(hu);
106}
107
108/* Initialize protocol */
109static int ath_open(struct hci_uart *hu)
110{
111 struct ath_struct *ath;
112
113 BT_DBG("hu %p", hu);
114
115 ath = kzalloc(sizeof(*ath), GFP_ATOMIC);
116 if (!ath)
117 return -ENOMEM;
118
119 skb_queue_head_init(&ath->txq);
120
121 hu->priv = ath;
122 ath->hu = hu;
123
124 INIT_WORK(&ath->ctxtsw, ath_hci_uart_work);
125
126 return 0;
127}
128
129/* Flush protocol data */
130static int ath_flush(struct hci_uart *hu)
131{
132 struct ath_struct *ath = hu->priv;
133
134 BT_DBG("hu %p", hu);
135
136 skb_queue_purge(&ath->txq);
137
138 return 0;
139}
140
141/* Close protocol */
142static int ath_close(struct hci_uart *hu)
143{
144 struct ath_struct *ath = hu->priv;
145
146 BT_DBG("hu %p", hu);
147
148 skb_queue_purge(&ath->txq);
149
150 cancel_work_sync(&ath->ctxtsw);
151
152 hu->priv = NULL;
153 kfree(ath);
154
155 return 0;
156}
157
158#define HCI_OP_ATH_SLEEP 0xFC04
159
160/* Enqueue frame for transmittion */
161static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb)
162{
163 struct ath_struct *ath = hu->priv;
164
165 if (bt_cb(skb)->pkt_type == HCI_SCODATA_PKT) {
166 kfree_skb(skb);
167 return 0;
168 }
169
170 /*
171 * Update power management enable flag with parameters of
172 * HCI sleep enable vendor specific HCI command.
173 */
174 if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {
175 struct hci_command_hdr *hdr = (void *)skb->data;
176
177 if (__le16_to_cpu(hdr->opcode) == HCI_OP_ATH_SLEEP)
178 ath->cur_sleep = skb->data[HCI_COMMAND_HDR_SIZE];
179 }
180
181 BT_DBG("hu %p skb %p", hu, skb);
182
183 /* Prepend skb with frame type */
184 memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
185
186 skb_queue_tail(&ath->txq, skb);
187 set_bit(HCI_UART_SENDING, &hu->tx_state);
188
189 schedule_work(&ath->ctxtsw);
190
191 return 0;
192}
193
194static struct sk_buff *ath_dequeue(struct hci_uart *hu)
195{
196 struct ath_struct *ath = hu->priv;
197
198 return skb_dequeue(&ath->txq);
199}
200
201/* Recv data */
202static int ath_recv(struct hci_uart *hu, void *data, int count)
203{
204 if (hci_recv_stream_fragment(hu->hdev, data, count) < 0)
205 BT_ERR("Frame Reassembly Failed");
206
207 return count;
208}
209
210static struct hci_uart_proto athp = {
211 .id = HCI_UART_ATH3K,
212 .open = ath_open,
213 .close = ath_close,
214 .recv = ath_recv,
215 .enqueue = ath_enqueue,
216 .dequeue = ath_dequeue,
217 .flush = ath_flush,
218};
219
220int __init ath_init(void)
221{
222 int err = hci_uart_register_proto(&athp);
223
224 if (!err)
225 BT_INFO("HCIATH3K protocol initialized");
226 else
227 BT_ERR("HCIATH3K protocol registration failed");
228
229 return err;
230}
231
232int __exit ath_deinit(void)
233{
234 return hci_uart_unregister_proto(&athp);
235}
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index 42d69d4de05c..9c5b2dc38e29 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -739,7 +739,7 @@ static struct hci_uart_proto bcsp = {
739 .flush = bcsp_flush 739 .flush = bcsp_flush
740}; 740};
741 741
742int bcsp_init(void) 742int __init bcsp_init(void)
743{ 743{
744 int err = hci_uart_register_proto(&bcsp); 744 int err = hci_uart_register_proto(&bcsp);
745 745
@@ -751,7 +751,7 @@ int bcsp_init(void)
751 return err; 751 return err;
752} 752}
753 753
754int bcsp_deinit(void) 754int __exit bcsp_deinit(void)
755{ 755{
756 return hci_uart_unregister_proto(&bcsp); 756 return hci_uart_unregister_proto(&bcsp);
757} 757}
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index 3f038f5308a4..7b8ad93e2c36 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -151,107 +151,8 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len)
151/* Recv data */ 151/* Recv data */
152static int h4_recv(struct hci_uart *hu, void *data, int count) 152static int h4_recv(struct hci_uart *hu, void *data, int count)
153{ 153{
154 struct h4_struct *h4 = hu->priv; 154 if (hci_recv_stream_fragment(hu->hdev, data, count) < 0)
155 register char *ptr; 155 BT_ERR("Frame Reassembly Failed");
156 struct hci_event_hdr *eh;
157 struct hci_acl_hdr *ah;
158 struct hci_sco_hdr *sh;
159 register int len, type, dlen;
160
161 BT_DBG("hu %p count %d rx_state %ld rx_count %ld",
162 hu, count, h4->rx_state, h4->rx_count);
163
164 ptr = data;
165 while (count) {
166 if (h4->rx_count) {
167 len = min_t(unsigned int, h4->rx_count, count);
168 memcpy(skb_put(h4->rx_skb, len), ptr, len);
169 h4->rx_count -= len; count -= len; ptr += len;
170
171 if (h4->rx_count)
172 continue;
173
174 switch (h4->rx_state) {
175 case H4_W4_DATA:
176 BT_DBG("Complete data");
177
178 hci_recv_frame(h4->rx_skb);
179
180 h4->rx_state = H4_W4_PACKET_TYPE;
181 h4->rx_skb = NULL;
182 continue;
183
184 case H4_W4_EVENT_HDR:
185 eh = hci_event_hdr(h4->rx_skb);
186
187 BT_DBG("Event header: evt 0x%2.2x plen %d", eh->evt, eh->plen);
188
189 h4_check_data_len(h4, eh->plen);
190 continue;
191
192 case H4_W4_ACL_HDR:
193 ah = hci_acl_hdr(h4->rx_skb);
194 dlen = __le16_to_cpu(ah->dlen);
195
196 BT_DBG("ACL header: dlen %d", dlen);
197
198 h4_check_data_len(h4, dlen);
199 continue;
200
201 case H4_W4_SCO_HDR:
202 sh = hci_sco_hdr(h4->rx_skb);
203
204 BT_DBG("SCO header: dlen %d", sh->dlen);
205
206 h4_check_data_len(h4, sh->dlen);
207 continue;
208 }
209 }
210
211 /* H4_W4_PACKET_TYPE */
212 switch (*ptr) {
213 case HCI_EVENT_PKT:
214 BT_DBG("Event packet");
215 h4->rx_state = H4_W4_EVENT_HDR;
216 h4->rx_count = HCI_EVENT_HDR_SIZE;
217 type = HCI_EVENT_PKT;
218 break;
219
220 case HCI_ACLDATA_PKT:
221 BT_DBG("ACL packet");
222 h4->rx_state = H4_W4_ACL_HDR;
223 h4->rx_count = HCI_ACL_HDR_SIZE;
224 type = HCI_ACLDATA_PKT;
225 break;
226
227 case HCI_SCODATA_PKT:
228 BT_DBG("SCO packet");
229 h4->rx_state = H4_W4_SCO_HDR;
230 h4->rx_count = HCI_SCO_HDR_SIZE;
231 type = HCI_SCODATA_PKT;
232 break;
233
234 default:
235 BT_ERR("Unknown HCI packet type %2.2x", (__u8)*ptr);
236 hu->hdev->stat.err_rx++;
237 ptr++; count--;
238 continue;
239 };
240
241 ptr++; count--;
242
243 /* Allocate packet */
244 h4->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
245 if (!h4->rx_skb) {
246 BT_ERR("Can't allocate mem for new packet");
247 h4->rx_state = H4_W4_PACKET_TYPE;
248 h4->rx_count = 0;
249 return -ENOMEM;
250 }
251
252 h4->rx_skb->dev = (void *) hu->hdev;
253 bt_cb(h4->rx_skb)->pkt_type = type;
254 }
255 156
256 return count; 157 return count;
257} 158}
@@ -272,7 +173,7 @@ static struct hci_uart_proto h4p = {
272 .flush = h4_flush, 173 .flush = h4_flush,
273}; 174};
274 175
275int h4_init(void) 176int __init h4_init(void)
276{ 177{
277 int err = hci_uart_register_proto(&h4p); 178 int err = hci_uart_register_proto(&h4p);
278 179
@@ -284,7 +185,7 @@ int h4_init(void)
284 return err; 185 return err;
285} 186}
286 187
287int h4_deinit(void) 188int __exit h4_deinit(void)
288{ 189{
289 return hci_uart_unregister_proto(&h4p); 190 return hci_uart_unregister_proto(&h4p);
290} 191}
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 76a1abb8f214..998833d93c13 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -210,7 +210,6 @@ static int hci_uart_close(struct hci_dev *hdev)
210static int hci_uart_send_frame(struct sk_buff *skb) 210static int hci_uart_send_frame(struct sk_buff *skb)
211{ 211{
212 struct hci_dev* hdev = (struct hci_dev *) skb->dev; 212 struct hci_dev* hdev = (struct hci_dev *) skb->dev;
213 struct tty_struct *tty;
214 struct hci_uart *hu; 213 struct hci_uart *hu;
215 214
216 if (!hdev) { 215 if (!hdev) {
@@ -222,7 +221,6 @@ static int hci_uart_send_frame(struct sk_buff *skb)
222 return -EBUSY; 221 return -EBUSY;
223 222
224 hu = (struct hci_uart *) hdev->driver_data; 223 hu = (struct hci_uart *) hdev->driver_data;
225 tty = hu->tty;
226 224
227 BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len); 225 BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
228 226
@@ -397,6 +395,9 @@ static int hci_uart_register_dev(struct hci_uart *hu)
397 if (!reset) 395 if (!reset)
398 set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); 396 set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
399 397
398 if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags))
399 set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
400
400 if (hci_register_dev(hdev) < 0) { 401 if (hci_register_dev(hdev) < 0) {
401 BT_ERR("Can't register HCI device"); 402 BT_ERR("Can't register HCI device");
402 hci_free_dev(hdev); 403 hci_free_dev(hdev);
@@ -477,6 +478,15 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
477 return hu->hdev->id; 478 return hu->hdev->id;
478 return -EUNATCH; 479 return -EUNATCH;
479 480
481 case HCIUARTSETFLAGS:
482 if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
483 return -EBUSY;
484 hu->hdev_flags = arg;
485 break;
486
487 case HCIUARTGETFLAGS:
488 return hu->hdev_flags;
489
480 default: 490 default:
481 err = n_tty_ioctl_helper(tty, file, cmd, arg); 491 err = n_tty_ioctl_helper(tty, file, cmd, arg);
482 break; 492 break;
@@ -542,6 +552,9 @@ static int __init hci_uart_init(void)
542#ifdef CONFIG_BT_HCIUART_LL 552#ifdef CONFIG_BT_HCIUART_LL
543 ll_init(); 553 ll_init();
544#endif 554#endif
555#ifdef CONFIG_BT_HCIUART_ATH3K
556 ath_init();
557#endif
545 558
546 return 0; 559 return 0;
547} 560}
@@ -559,6 +572,9 @@ static void __exit hci_uart_exit(void)
559#ifdef CONFIG_BT_HCIUART_LL 572#ifdef CONFIG_BT_HCIUART_LL
560 ll_deinit(); 573 ll_deinit();
561#endif 574#endif
575#ifdef CONFIG_BT_HCIUART_ATH3K
576 ath_deinit();
577#endif
562 578
563 /* Release tty registration of line discipline */ 579 /* Release tty registration of line discipline */
564 if ((err = tty_unregister_ldisc(N_HCI))) 580 if ((err = tty_unregister_ldisc(N_HCI)))
diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c
index fb8445c7365e..38595e782d02 100644
--- a/drivers/bluetooth/hci_ll.c
+++ b/drivers/bluetooth/hci_ll.c
@@ -74,7 +74,7 @@ enum hcill_states_e {
74 74
75struct hcill_cmd { 75struct hcill_cmd {
76 u8 cmd; 76 u8 cmd;
77} __attribute__((packed)); 77} __packed;
78 78
79struct ll_struct { 79struct ll_struct {
80 unsigned long rx_state; 80 unsigned long rx_state;
@@ -517,7 +517,7 @@ static struct hci_uart_proto llp = {
517 .flush = ll_flush, 517 .flush = ll_flush,
518}; 518};
519 519
520int ll_init(void) 520int __init ll_init(void)
521{ 521{
522 int err = hci_uart_register_proto(&llp); 522 int err = hci_uart_register_proto(&llp);
523 523
@@ -529,7 +529,7 @@ int ll_init(void)
529 return err; 529 return err;
530} 530}
531 531
532int ll_deinit(void) 532int __exit ll_deinit(void)
533{ 533{
534 return hci_uart_unregister_proto(&llp); 534 return hci_uart_unregister_proto(&llp);
535} 535}
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 50113db06b9f..99fb35239d1f 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -31,15 +31,20 @@
31#define HCIUARTSETPROTO _IOW('U', 200, int) 31#define HCIUARTSETPROTO _IOW('U', 200, int)
32#define HCIUARTGETPROTO _IOR('U', 201, int) 32#define HCIUARTGETPROTO _IOR('U', 201, int)
33#define HCIUARTGETDEVICE _IOR('U', 202, int) 33#define HCIUARTGETDEVICE _IOR('U', 202, int)
34#define HCIUARTSETFLAGS _IOW('U', 203, int)
35#define HCIUARTGETFLAGS _IOR('U', 204, int)
34 36
35/* UART protocols */ 37/* UART protocols */
36#define HCI_UART_MAX_PROTO 5 38#define HCI_UART_MAX_PROTO 6
37 39
38#define HCI_UART_H4 0 40#define HCI_UART_H4 0
39#define HCI_UART_BCSP 1 41#define HCI_UART_BCSP 1
40#define HCI_UART_3WIRE 2 42#define HCI_UART_3WIRE 2
41#define HCI_UART_H4DS 3 43#define HCI_UART_H4DS 3
42#define HCI_UART_LL 4 44#define HCI_UART_LL 4
45#define HCI_UART_ATH3K 5
46
47#define HCI_UART_RAW_DEVICE 0
43 48
44struct hci_uart; 49struct hci_uart;
45 50
@@ -57,6 +62,7 @@ struct hci_uart {
57 struct tty_struct *tty; 62 struct tty_struct *tty;
58 struct hci_dev *hdev; 63 struct hci_dev *hdev;
59 unsigned long flags; 64 unsigned long flags;
65 unsigned long hdev_flags;
60 66
61 struct hci_uart_proto *proto; 67 struct hci_uart_proto *proto;
62 void *priv; 68 void *priv;
@@ -66,7 +72,7 @@ struct hci_uart {
66 spinlock_t rx_lock; 72 spinlock_t rx_lock;
67}; 73};
68 74
69/* HCI_UART flag bits */ 75/* HCI_UART proto flag bits */
70#define HCI_UART_PROTO_SET 0 76#define HCI_UART_PROTO_SET 0
71 77
72/* TX states */ 78/* TX states */
@@ -91,3 +97,8 @@ int bcsp_deinit(void);
91int ll_init(void); 97int ll_init(void);
92int ll_deinit(void); 98int ll_deinit(void);
93#endif 99#endif
100
101#ifdef CONFIG_BT_HCIUART_ATH3K
102int ath_init(void);
103int ath_deinit(void);
104#endif