|
| 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 FW_NAME_TI1271_PRELE "ti1273_prele.bin" |
| 30 | +#define FW_NAME_TI1271_LE "ti1273_le.bin" |
| 31 | +#define FW_NAME_TI1271 "ti1273.bin" |
| 32 | +#define FW_NAME_BCM2048 "bcmfw.bin" |
| 33 | +#define FW_NAME_CSR "bc4fw.bin" |
| 34 | + |
| 35 | +#define UART_SYSC_OMAP_RESET 0x03 |
| 36 | +#define UART_SYSS_RESETDONE 0x01 |
| 37 | +#define UART_OMAP_SCR_EMPTY_THR 0x08 |
| 38 | +#define UART_OMAP_SCR_WAKEUP 0x10 |
| 39 | +#define UART_OMAP_SSR_WAKEUP 0x02 |
| 40 | +#define UART_OMAP_SSR_TXFULL 0x01 |
| 41 | + |
| 42 | +#define UART_OMAP_SYSC_IDLEMODE 0x03 |
| 43 | +#define UART_OMAP_SYSC_IDLEMASK (3 << UART_OMAP_SYSC_IDLEMODE) |
| 44 | + |
| 45 | +#define UART_OMAP_SYSC_FORCE_IDLE (0 << UART_OMAP_SYSC_IDLEMODE) |
| 46 | +#define UART_OMAP_SYSC_NO_IDLE (1 << UART_OMAP_SYSC_IDLEMODE) |
| 47 | +#define UART_OMAP_SYSC_SMART_IDLE (2 << UART_OMAP_SYSC_IDLEMODE) |
| 48 | + |
| 49 | +#define H4P_TRANSFER_MODE 1 |
| 50 | +#define H4P_SCHED_TRANSFER_MODE 2 |
| 51 | +#define H4P_ACTIVE_MODE 3 |
| 52 | + |
| 53 | +struct hci_h4p_info { |
| 54 | + struct timer_list lazy_release; |
| 55 | + struct hci_dev *hdev; |
| 56 | + spinlock_t lock; |
| 57 | + |
| 58 | + void __iomem *uart_base; |
| 59 | + unsigned long uart_phys_base; |
| 60 | + int irq; |
| 61 | + struct device *dev; |
| 62 | + u8 chip_type; |
| 63 | + u8 bt_wakeup_gpio; |
| 64 | + u8 host_wakeup_gpio; |
| 65 | + u8 reset_gpio; |
| 66 | + u8 reset_gpio_shared; |
| 67 | + u8 bt_sysclk; |
| 68 | + u8 man_id; |
| 69 | + u8 ver_id; |
| 70 | + |
| 71 | + struct sk_buff_head fw_queue; |
| 72 | + struct sk_buff *alive_cmd_skb; |
| 73 | + struct completion init_completion; |
| 74 | + struct completion fw_completion; |
| 75 | + struct completion test_completion; |
| 76 | + int fw_error; |
| 77 | + int init_error; |
| 78 | + |
| 79 | + struct sk_buff_head txq; |
| 80 | + |
| 81 | + struct sk_buff *rx_skb; |
| 82 | + long rx_count; |
| 83 | + unsigned long rx_state; |
| 84 | + unsigned long garbage_bytes; |
| 85 | + |
| 86 | + u8 bd_addr[6]; |
| 87 | + struct sk_buff_head *fw_q; |
| 88 | + |
| 89 | + int pm_enabled; |
| 90 | + int tx_enabled; |
| 91 | + int autorts; |
| 92 | + int rx_enabled; |
| 93 | + unsigned long pm_flags; |
| 94 | + |
| 95 | + int tx_clocks_en; |
| 96 | + int rx_clocks_en; |
| 97 | + spinlock_t clocks_lock; |
| 98 | + struct clk *uart_iclk; |
| 99 | + struct clk *uart_fclk; |
| 100 | + atomic_t clk_users; |
| 101 | + u16 dll; |
| 102 | + u16 dlh; |
| 103 | + u16 ier; |
| 104 | + u16 mdr1; |
| 105 | + u16 efr; |
| 106 | +}; |
| 107 | + |
| 108 | +struct hci_h4p_radio_hdr { |
| 109 | + __u8 evt; |
| 110 | + __u8 dlen; |
| 111 | +} __attribute__ ((packed)); |
| 112 | + |
| 113 | +struct hci_h4p_neg_hdr { |
| 114 | + __u8 dlen; |
| 115 | +} __attribute__ ((packed)); |
| 116 | +#define H4P_NEG_HDR_SIZE 1 |
| 117 | + |
| 118 | +#define H4P_NEG_REQ 0x00 |
| 119 | +#define H4P_NEG_ACK 0x20 |
| 120 | +#define H4P_NEG_NAK 0x40 |
| 121 | + |
| 122 | +#define H4P_PROTO_PKT 0x44 |
| 123 | +#define H4P_PROTO_BYTE 0x4c |
| 124 | + |
| 125 | +#define H4P_ID_CSR 0x02 |
| 126 | +#define H4P_ID_BCM2048 0x04 |
| 127 | +#define H4P_ID_TI1271 0x31 |
| 128 | + |
| 129 | +struct hci_h4p_neg_cmd { |
| 130 | + __u8 ack; |
| 131 | + __u16 baud; |
| 132 | + __u16 unused1; |
| 133 | + __u8 proto; |
| 134 | + __u16 sys_clk; |
| 135 | + __u16 unused2; |
| 136 | +} __attribute__ ((packed)); |
| 137 | + |
| 138 | +struct hci_h4p_neg_evt { |
| 139 | + __u8 ack; |
| 140 | + __u16 baud; |
| 141 | + __u16 unused1; |
| 142 | + __u8 proto; |
| 143 | + __u16 sys_clk; |
| 144 | + __u16 unused2; |
| 145 | + __u8 man_id; |
| 146 | + __u8 ver_id; |
| 147 | +} __attribute__ ((packed)); |
| 148 | + |
| 149 | +#define H4P_ALIVE_REQ 0x55 |
| 150 | +#define H4P_ALIVE_RESP 0xcc |
| 151 | + |
| 152 | +struct hci_h4p_alive_hdr { |
| 153 | + __u8 dlen; |
| 154 | +} __attribute__ ((packed)); |
| 155 | +#define H4P_ALIVE_HDR_SIZE 1 |
| 156 | + |
| 157 | +struct hci_h4p_alive_pkt { |
| 158 | + __u8 mid; |
| 159 | + __u8 unused; |
| 160 | +} __attribute__ ((packed)); |
| 161 | + |
| 162 | +#define MAX_BAUD_RATE 921600 |
| 163 | +#define BC4_MAX_BAUD_RATE 3692300 |
| 164 | +#define UART_CLOCK 48000000 |
| 165 | +#define BT_INIT_DIVIDER 320 |
| 166 | +#define BT_BAUDRATE_DIVIDER 384000000 |
| 167 | +#define BT_SYSCLK_DIV 1000 |
| 168 | +#define INIT_SPEED 120000 |
| 169 | + |
| 170 | +#define H4_TYPE_SIZE 1 |
| 171 | +#define H4_RADIO_HDR_SIZE 2 |
| 172 | + |
| 173 | +/* H4+ packet types */ |
| 174 | +#define H4_CMD_PKT 0x01 |
| 175 | +#define H4_ACL_PKT 0x02 |
| 176 | +#define H4_SCO_PKT 0x03 |
| 177 | +#define H4_EVT_PKT 0x04 |
| 178 | +#define H4_NEG_PKT 0x06 |
| 179 | +#define H4_ALIVE_PKT 0x07 |
| 180 | +#define H4_RADIO_PKT 0x08 |
| 181 | + |
| 182 | +/* TX states */ |
| 183 | +#define WAIT_FOR_PKT_TYPE 1 |
| 184 | +#define WAIT_FOR_HEADER 2 |
| 185 | +#define WAIT_FOR_DATA 3 |
| 186 | + |
| 187 | +struct hci_fw_event { |
| 188 | + struct hci_event_hdr hev; |
| 189 | + struct hci_ev_cmd_complete cmd; |
| 190 | + u8 status; |
| 191 | +} __attribute__ ((packed)); |
| 192 | + |
| 193 | +int hci_h4p_send_alive_packet(struct hci_h4p_info *info); |
| 194 | + |
| 195 | +void hci_h4p_bcm_parse_fw_event(struct hci_h4p_info *info, |
| 196 | + struct sk_buff *skb); |
| 197 | +int hci_h4p_bcm_send_fw(struct hci_h4p_info *info, |
| 198 | + struct sk_buff_head *fw_queue); |
| 199 | + |
| 200 | +void hci_h4p_bc4_parse_fw_event(struct hci_h4p_info *info, |
| 201 | + struct sk_buff *skb); |
| 202 | +int hci_h4p_bc4_send_fw(struct hci_h4p_info *info, |
| 203 | + struct sk_buff_head *fw_queue); |
| 204 | + |
| 205 | +void hci_h4p_ti1273_parse_fw_event(struct hci_h4p_info *info, |
| 206 | + struct sk_buff *skb); |
| 207 | +int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info, |
| 208 | + struct sk_buff_head *fw_queue); |
| 209 | + |
| 210 | +int hci_h4p_read_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue); |
| 211 | +int hci_h4p_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue); |
| 212 | +void hci_h4p_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb); |
| 213 | + |
| 214 | +void hci_h4p_outb(struct hci_h4p_info *info, unsigned int offset, u8 val); |
| 215 | +u8 hci_h4p_inb(struct hci_h4p_info *info, unsigned int offset); |
| 216 | +void hci_h4p_set_rts(struct hci_h4p_info *info, int active); |
| 217 | +int hci_h4p_wait_for_cts(struct hci_h4p_info *info, int active, int timeout_ms); |
| 218 | +void __hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which); |
| 219 | +void hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which); |
| 220 | +void hci_h4p_change_speed(struct hci_h4p_info *info, unsigned long speed); |
| 221 | +int hci_h4p_reset_uart(struct hci_h4p_info *info); |
| 222 | +void hci_h4p_init_uart(struct hci_h4p_info *info); |
| 223 | +void hci_h4p_enable_tx(struct hci_h4p_info *info); |
| 224 | +void hci_h4p_store_regs(struct hci_h4p_info *info); |
| 225 | +void hci_h4p_restore_regs(struct hci_h4p_info *info); |
| 226 | +void hci_h4p_smart_idle(struct hci_h4p_info *info, bool enable); |
| 227 | + |
| 228 | +#endif /* __DRIVERS_BLUETOOTH_HCI_H4P_H */ |
0 commit comments