2 * This file is part of hci_h4p bluetooth driver
4 * Copyright (C) 2005, 2006 Nokia Corporation.
6 * Contact: Ville Tervo <ville.tervo@nokia.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include <asm/arch/board.h>
26 #include <net/bluetooth/bluetooth.h>
27 #include <net/bluetooth/hci_core.h>
28 #include <net/bluetooth/hci.h>
30 #ifndef __DRIVERS_BLUETOOTH_HCI_H4P_H
31 #define __DRIVERS_BLUETOOTH_HCI_H4P_H
33 #define UART_SYSC_OMAP_RESET 0x03
34 #define UART_SYSS_RESETDONE 0x01
35 #define UART_OMAP_SCR_EMPTY_THR 0x08
36 #define UART_OMAP_SCR_WAKEUP 0x10
37 #define UART_OMAP_SSR_WAKEUP 0x02
38 #define UART_OMAP_SSR_TXFULL 0x01
41 #define NBT_DBG(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg)
47 #define NBT_DBG_FW(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg)
49 #define NBT_DBG_FW(...)
53 #define NBT_DBG_POWER(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg)
55 #define NBT_DBG_POWER(...)
59 #define NBT_DBG_TRANSFER(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg)
61 #define NBT_DBG_TRANSFER(...)
65 #define NBT_DBG_TRANSFER_NF(fmt, arg...) printk(fmt "" , ## arg)
67 #define NBT_DBG_TRANSFER_NF(...)
71 #define NBT_DBG_DMA(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg)
73 #define NBT_DBG_DMA(...)
80 void __iomem *uart_base;
81 unsigned long uart_phys_base;
92 struct sk_buff_head fw_queue;
93 struct sk_buff *alive_cmd_skb;
94 struct completion init_completion;
95 struct completion fw_completion;
99 struct sk_buff_head txq;
100 struct tasklet_struct tx_task;
102 struct sk_buff *rx_skb;
104 unsigned long rx_state;
105 unsigned long garbage_bytes;
106 struct tasklet_struct rx_task;
111 struct timer_list tx_pm_timer;
112 struct timer_list rx_pm_timer;
116 spinlock_t clocks_lock;
117 struct clk *uart_iclk;
118 struct clk *uart_fclk;
121 #define MAX_BAUD_RATE 921600
122 #define BC4_MAX_BAUD_RATE 3692300
123 #define UART_CLOCK 48000000
124 #define BT_INIT_DIVIDER 320
125 #define BT_BAUDRATE_DIVIDER 384000000
126 #define BT_SYSCLK_DIV 1000
127 #define INIT_SPEED 120000
129 #define H4_TYPE_SIZE 1
131 /* H4+ packet types */
132 #define H4_CMD_PKT 0x01
133 #define H4_ACL_PKT 0x02
134 #define H4_SCO_PKT 0x03
135 #define H4_EVT_PKT 0x04
136 #define H4_NEG_PKT 0x06
137 #define H4_ALIVE_PKT 0x07
140 #define WAIT_FOR_PKT_TYPE 1
141 #define WAIT_FOR_HEADER 2
142 #define WAIT_FOR_DATA 3
144 struct hci_fw_event {
145 struct hci_event_hdr hev;
146 struct hci_ev_cmd_complete cmd;
148 } __attribute__ ((packed));
150 struct hci_bc4_set_bdaddr {
152 struct hci_command_hdr cmd_hdr;
153 } __attribute__ ((packed));
155 int hci_h4p_send_alive_packet(struct hci_h4p_info *info);
157 void hci_h4p_bc4_parse_fw_event(struct hci_h4p_info *info,
158 struct sk_buff *skb);
159 int hci_h4p_bc4_send_fw(struct hci_h4p_info *info,
160 struct sk_buff_head *fw_queue);
162 void hci_h4p_brf6150_parse_fw_event(struct hci_h4p_info *info,
163 struct sk_buff *skb);
164 int hci_h4p_brf6150_send_fw(struct hci_h4p_info *info,
165 struct sk_buff_head *fw_queue);
167 int hci_h4p_read_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue);
168 int hci_h4p_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue);
169 void hci_h4p_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb);
171 int hci_h4p_sysfs_create_files(struct device *dev);
173 void hci_h4p_outb(struct hci_h4p_info *info, unsigned int offset, u8 val);
174 u8 hci_h4p_inb(struct hci_h4p_info *info, unsigned int offset);
175 void hci_h4p_set_rts(struct hci_h4p_info *info, int active);
176 int hci_h4p_wait_for_cts(struct hci_h4p_info *info, int active, int timeout_ms);
177 void hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which);
178 void hci_h4p_change_speed(struct hci_h4p_info *info, unsigned long speed);
179 int hci_h4p_reset_uart(struct hci_h4p_info *info);
180 int hci_h4p_init_uart(struct hci_h4p_info *info);
182 #endif /* __DRIVERS_BLUETOOTH_HCI_H4P_H */