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 #ifndef __DRIVERS_BLUETOOTH_HCI_H4P_H
23 #define __DRIVERS_BLUETOOTH_HCI_H4P_H
25 #include <net/bluetooth/bluetooth.h>
26 #include <net/bluetooth/hci_core.h>
27 #include <net/bluetooth/hci.h>
29 #define UART_SYSC_OMAP_RESET 0x03
30 #define UART_SYSS_RESETDONE 0x01
31 #define UART_OMAP_SCR_EMPTY_THR 0x08
32 #define UART_OMAP_SCR_WAKEUP 0x10
33 #define UART_OMAP_SSR_WAKEUP 0x02
34 #define UART_OMAP_SSR_TXFULL 0x01
36 #define UART_OMAP_SYSC_IDLEMODE 0x03
37 #define UART_OMAP_SYSC_IDLEMASK (3 << UART_OMAP_SYSC_IDLEMODE)
39 #define UART_OMAP_SYSC_FORCE_IDLE (0 << UART_OMAP_SYSC_IDLEMODE)
40 #define UART_OMAP_SYSC_NO_IDLE (1 << UART_OMAP_SYSC_IDLEMODE)
41 #define UART_OMAP_SYSC_SMART_IDLE (2 << UART_OMAP_SYSC_IDLEMODE)
43 #define H4P_TRANSFER_MODE 1
44 #define H4P_SCHED_TRANSFER_MODE 2
45 #define H4P_ACTIVE_MODE 3
48 struct timer_list lazy_release
;
52 void __iomem
*uart_base
;
53 unsigned long uart_phys_base
;
65 struct sk_buff_head fw_queue
;
66 struct sk_buff
*alive_cmd_skb
;
67 struct completion init_completion
;
68 struct completion fw_completion
;
69 struct completion test_completion
;
73 struct sk_buff_head txq
;
75 struct sk_buff
*rx_skb
;
77 unsigned long rx_state
;
78 unsigned long garbage_bytes
;
81 struct sk_buff_head
*fw_q
;
87 unsigned long pm_flags
;
91 spinlock_t clocks_lock
;
92 struct clk
*uart_iclk
;
93 struct clk
*uart_fclk
;
102 struct hci_h4p_radio_hdr
{
107 struct hci_h4p_neg_hdr
{
110 #define H4P_NEG_HDR_SIZE 1
112 #define H4P_NEG_REQ 0x00
113 #define H4P_NEG_ACK 0x20
114 #define H4P_NEG_NAK 0x40
116 #define H4P_PROTO_PKT 0x44
117 #define H4P_PROTO_BYTE 0x4c
119 #define H4P_ID_CSR 0x02
120 #define H4P_ID_BCM2048 0x04
121 #define H4P_ID_TI1271 0x31
123 struct hci_h4p_neg_cmd
{
132 struct hci_h4p_neg_evt
{
143 #define H4P_ALIVE_REQ 0x55
144 #define H4P_ALIVE_RESP 0xcc
146 struct hci_h4p_alive_hdr
{
149 #define H4P_ALIVE_HDR_SIZE 1
151 struct hci_h4p_alive_pkt
{
156 #define MAX_BAUD_RATE 921600
157 #define BC4_MAX_BAUD_RATE 3692300
158 #define UART_CLOCK 48000000
159 #define BT_INIT_DIVIDER 320
160 #define BT_BAUDRATE_DIVIDER 384000000
161 #define BT_SYSCLK_DIV 1000
162 #define INIT_SPEED 120000
164 #define H4_TYPE_SIZE 1
165 #define H4_RADIO_HDR_SIZE 2
167 /* H4+ packet types */
168 #define H4_CMD_PKT 0x01
169 #define H4_ACL_PKT 0x02
170 #define H4_SCO_PKT 0x03
171 #define H4_EVT_PKT 0x04
172 #define H4_NEG_PKT 0x06
173 #define H4_ALIVE_PKT 0x07
174 #define H4_RADIO_PKT 0x08
177 #define WAIT_FOR_PKT_TYPE 1
178 #define WAIT_FOR_HEADER 2
179 #define WAIT_FOR_DATA 3
181 struct hci_fw_event
{
182 struct hci_event_hdr hev
;
183 struct hci_ev_cmd_complete cmd
;
187 int hci_h4p_send_alive_packet(struct hci_h4p_info
*info
);
189 void hci_h4p_bcm_parse_fw_event(struct hci_h4p_info
*info
,
190 struct sk_buff
*skb
);
191 int hci_h4p_bcm_send_fw(struct hci_h4p_info
*info
,
192 struct sk_buff_head
*fw_queue
);
194 void hci_h4p_bc4_parse_fw_event(struct hci_h4p_info
*info
,
195 struct sk_buff
*skb
);
196 int hci_h4p_bc4_send_fw(struct hci_h4p_info
*info
,
197 struct sk_buff_head
*fw_queue
);
199 void hci_h4p_ti1273_parse_fw_event(struct hci_h4p_info
*info
,
200 struct sk_buff
*skb
);
201 int hci_h4p_ti1273_send_fw(struct hci_h4p_info
*info
,
202 struct sk_buff_head
*fw_queue
);
204 int hci_h4p_read_fw(struct hci_h4p_info
*info
, struct sk_buff_head
*fw_queue
);
205 int hci_h4p_send_fw(struct hci_h4p_info
*info
, struct sk_buff_head
*fw_queue
);
206 void hci_h4p_parse_fw_event(struct hci_h4p_info
*info
, struct sk_buff
*skb
);
208 void hci_h4p_outb(struct hci_h4p_info
*info
, unsigned int offset
, u8 val
);
209 u8
hci_h4p_inb(struct hci_h4p_info
*info
, unsigned int offset
);
210 void hci_h4p_set_rts(struct hci_h4p_info
*info
, int active
);
211 int hci_h4p_wait_for_cts(struct hci_h4p_info
*info
, int active
, int timeout_ms
);
212 void __hci_h4p_set_auto_ctsrts(struct hci_h4p_info
*info
, int on
, u8 which
);
213 void hci_h4p_set_auto_ctsrts(struct hci_h4p_info
*info
, int on
, u8 which
);
214 void hci_h4p_change_speed(struct hci_h4p_info
*info
, unsigned long speed
);
215 int hci_h4p_reset_uart(struct hci_h4p_info
*info
);
216 void hci_h4p_init_uart(struct hci_h4p_info
*info
);
217 void hci_h4p_enable_tx(struct hci_h4p_info
*info
);
218 void hci_h4p_store_regs(struct hci_h4p_info
*info
);
219 void hci_h4p_restore_regs(struct hci_h4p_info
*info
);
220 void hci_h4p_smart_idle(struct hci_h4p_info
*info
, bool enable
);
222 #endif /* __DRIVERS_BLUETOOTH_HCI_H4P_H */