2 * This file is part of Nokia H4P bluetooth driver
4 * Copyright (C) 2009 Nokia Corporation.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 #include <linux/skbuff.h>
23 #include <linux/delay.h>
24 #include <linux/serial_reg.h>
28 static struct sk_buff_head *fw_q;
30 void hci_h4p_ti1273_parse_fw_event(struct hci_h4p_info *info,
33 struct sk_buff *fw_skb;
36 if (skb->data[5] != 0x00) {
37 dev_err(info->dev, "Firmware sending command failed 0x%.2x\n",
39 info->fw_error = -EPROTO;
44 fw_skb = skb_dequeue(fw_q);
45 if (fw_skb == NULL || info->fw_error) {
46 complete(&info->fw_completion);
50 skb_queue_tail(&info->txq, fw_skb);
51 spin_lock_irqsave(&info->lock, flags);
52 hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) |
54 spin_unlock_irqrestore(&info->lock, flags);
58 int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info,
59 struct sk_buff_head *fw_queue)
62 unsigned long flags, time;
66 BT_DBG("Sending firmware");
71 skb = skb_dequeue(fw_queue);
75 BT_DBG("Sending commands");
76 /* Check if this is bd_address packet */
77 init_completion(&info->fw_completion);
78 hci_h4p_smart_idle(info, 0);
79 skb_queue_tail(&info->txq, skb);
80 spin_lock_irqsave(&info->lock, flags);
81 hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) |
83 spin_unlock_irqrestore(&info->lock, flags);
85 if (!wait_for_completion_timeout(&info->fw_completion,
86 msecs_to_jiffies(2000))) {
87 dev_err(info->dev, "No reply to fw command\n");
92 dev_err(info->dev, "FW error\n");
96 BT_DBG("Firmware sent in %d msecs",
97 jiffies_to_msecs(jiffies-time));
99 hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS);
100 hci_h4p_set_rts(info, 0);
101 hci_h4p_change_speed(info, BC4_MAX_BAUD_RATE);
102 if (hci_h4p_wait_for_cts(info, 1, 100)) {
104 "cts didn't go down after final speed change\n");
107 hci_h4p_set_auto_ctsrts(info, 1, UART_EFR_RTS);