Merge tag 'trace-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux...
[deliverable/linux.git] / drivers / staging / nokia_h4p / hci_h4p.h
1 /*
2 * This file is part of Nokia H4P bluetooth driver
3 *
4 * Copyright (C) 2005-2008 Nokia Corporation.
5 *
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.
9 *
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.
14 *
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
18 * 02110-1301 USA
19 *
20 */
21
22 #ifndef __DRIVERS_BLUETOOTH_HCI_H4P_H
23 #define __DRIVERS_BLUETOOTH_HCI_H4P_H
24
25 #include <net/bluetooth/bluetooth.h>
26 #include <net/bluetooth/hci_core.h>
27 #include <net/bluetooth/hci.h>
28
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
35
36 #define UART_OMAP_SYSC_IDLEMODE 0x03
37 #define UART_OMAP_SYSC_IDLEMASK (3 << UART_OMAP_SYSC_IDLEMODE)
38
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)
42
43 #define H4P_TRANSFER_MODE 1
44 #define H4P_SCHED_TRANSFER_MODE 2
45 #define H4P_ACTIVE_MODE 3
46
47 struct hci_h4p_info {
48 struct timer_list lazy_release;
49 struct hci_dev *hdev;
50 spinlock_t lock;
51
52 void __iomem *uart_base;
53 unsigned long uart_phys_base;
54 int irq;
55 struct device *dev;
56 u8 chip_type;
57 u8 bt_wakeup_gpio;
58 u8 host_wakeup_gpio;
59 u8 reset_gpio;
60 u8 reset_gpio_shared;
61 u8 bt_sysclk;
62 u8 man_id;
63 u8 ver_id;
64
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;
70 int fw_error;
71 int init_error;
72
73 struct sk_buff_head txq;
74
75 struct sk_buff *rx_skb;
76 long rx_count;
77 unsigned long rx_state;
78 unsigned long garbage_bytes;
79
80 u8 bd_addr[6];
81 struct sk_buff_head *fw_q;
82
83 int pm_enabled;
84 int tx_enabled;
85 int autorts;
86 int rx_enabled;
87 unsigned long pm_flags;
88
89 int tx_clocks_en;
90 int rx_clocks_en;
91 spinlock_t clocks_lock;
92 struct clk *uart_iclk;
93 struct clk *uart_fclk;
94 atomic_t clk_users;
95 u16 dll;
96 u16 dlh;
97 u16 ier;
98 u16 mdr1;
99 u16 efr;
100 };
101
102 struct hci_h4p_radio_hdr {
103 __u8 evt;
104 __u8 dlen;
105 } __packed;
106
107 struct hci_h4p_neg_hdr {
108 __u8 dlen;
109 } __packed;
110 #define H4P_NEG_HDR_SIZE 1
111
112 #define H4P_NEG_REQ 0x00
113 #define H4P_NEG_ACK 0x20
114 #define H4P_NEG_NAK 0x40
115
116 #define H4P_PROTO_PKT 0x44
117 #define H4P_PROTO_BYTE 0x4c
118
119 #define H4P_ID_CSR 0x02
120 #define H4P_ID_BCM2048 0x04
121 #define H4P_ID_TI1271 0x31
122
123 struct hci_h4p_neg_cmd {
124 __u8 ack;
125 __u16 baud;
126 __u16 unused1;
127 __u8 proto;
128 __u16 sys_clk;
129 __u16 unused2;
130 } __packed;
131
132 struct hci_h4p_neg_evt {
133 __u8 ack;
134 __u16 baud;
135 __u16 unused1;
136 __u8 proto;
137 __u16 sys_clk;
138 __u16 unused2;
139 __u8 man_id;
140 __u8 ver_id;
141 } __packed;
142
143 #define H4P_ALIVE_REQ 0x55
144 #define H4P_ALIVE_RESP 0xcc
145
146 struct hci_h4p_alive_hdr {
147 __u8 dlen;
148 } __packed;
149 #define H4P_ALIVE_HDR_SIZE 1
150
151 struct hci_h4p_alive_pkt {
152 __u8 mid;
153 __u8 unused;
154 } __packed;
155
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
163
164 #define H4_TYPE_SIZE 1
165 #define H4_RADIO_HDR_SIZE 2
166
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
175
176 /* TX states */
177 #define WAIT_FOR_PKT_TYPE 1
178 #define WAIT_FOR_HEADER 2
179 #define WAIT_FOR_DATA 3
180
181 struct hci_fw_event {
182 struct hci_event_hdr hev;
183 struct hci_ev_cmd_complete cmd;
184 u8 status;
185 } __packed;
186
187 int hci_h4p_send_alive_packet(struct hci_h4p_info *info);
188
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);
193
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);
198
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);
203
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);
207
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);
221
222 #endif /* __DRIVERS_BLUETOOTH_HCI_H4P_H */
This page took 0.034275 seconds and 5 git commands to generate.