2 * This file is part of Nokia H4P bluetooth driver
4 * Copyright (C) 2005-2008 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 void hci_h4p_bc4_parse_fw_event(struct hci_h4p_info
*info
, struct sk_buff
*skb
)
30 /* Check if this is fw packet */
31 if (skb
->data
[0] != 0xff) {
32 hci_recv_frame(info
->hdev
, skb
);
36 if (skb
->data
[11] || skb
->data
[12]) {
37 dev_err(info
->dev
, "Firmware sending command failed\n");
38 info
->fw_error
= -EPROTO
;
42 complete(&info
->fw_completion
);
45 int hci_h4p_bc4_send_fw(struct hci_h4p_info
*info
,
46 struct sk_buff_head
*fw_queue
)
48 static const u8 nokia_oui
[3] = {0x00, 0x19, 0x4F};
51 int retries
, count
, i
, not_valid
;
56 BT_DBG("Sending firmware");
57 skb
= skb_dequeue(fw_queue
);
62 /* Check if this is bd_address packet */
63 if (skb
->data
[15] == 0x01 && skb
->data
[16] == 0x00) {
65 skb
->data
[offset
+ 1] = 0x00;
66 skb
->data
[offset
+ 5] = 0x00;
69 for (i
= 0; i
< 6; i
++) {
70 if (info
->bd_addr
[i
] != 0x00) {
77 dev_info(info
->dev
, "Valid bluetooth address not found, setting some random\n");
78 /* When address is not valid, use some random */
79 memcpy(info
->bd_addr
, nokia_oui
, 3);
80 get_random_bytes(info
->bd_addr
+ 3, 3);
83 skb
->data
[offset
+ 7] = info
->bd_addr
[0];
84 skb
->data
[offset
+ 6] = info
->bd_addr
[1];
85 skb
->data
[offset
+ 4] = info
->bd_addr
[2];
86 skb
->data
[offset
+ 0] = info
->bd_addr
[3];
87 skb
->data
[offset
+ 3] = info
->bd_addr
[4];
88 skb
->data
[offset
+ 2] = info
->bd_addr
[5];
91 for (count
= 1; ; count
++) {
92 BT_DBG("Sending firmware command %d", count
);
93 init_completion(&info
->fw_completion
);
94 skb_queue_tail(&info
->txq
, skb
);
95 spin_lock_irqsave(&info
->lock
, flags
);
96 hci_h4p_outb(info
, UART_IER
, hci_h4p_inb(info
, UART_IER
) |
98 spin_unlock_irqrestore(&info
->lock
, flags
);
100 skb
= skb_dequeue(fw_queue
);
104 if (!wait_for_completion_timeout(&info
->fw_completion
,
105 msecs_to_jiffies(1000))) {
106 dev_err(info
->dev
, "No reply to fw command\n");
110 if (info
->fw_error
) {
111 dev_err(info
->dev
, "FW error\n");
116 /* Wait for chip warm reset */
118 while ((!skb_queue_empty(&info
->txq
) ||
119 !(hci_h4p_inb(info
, UART_LSR
) & UART_LSR_TEMT
)) &&
124 dev_err(info
->dev
, "Transmitter not empty\n");
128 hci_h4p_change_speed(info
, BC4_MAX_BAUD_RATE
);
130 if (hci_h4p_wait_for_cts(info
, 1, 100)) {
131 dev_err(info
->dev
, "cts didn't deassert after final speed\n");
137 init_completion(&info
->init_completion
);
138 hci_h4p_send_alive_packet(info
);
140 } while (!wait_for_completion_timeout(&info
->init_completion
, 100) &&
144 dev_err(info
->dev
, "No alive reply after speed change\n");
This page took 0.032803 seconds and 5 git commands to generate.