3 * Bluetooth HCI UART driver
5 * Copyright (C) 2000-2001 Qualcomm Incorporated
6 * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
7 * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #if defined(CONFIG_RADIO_BCM4343S) || defined(CONFIG_RADIO_SC2331)
31 #include <linux/skbuff.h>
33 /*******************************************************************************
35 *******************************************************************************/
38 * enum proto-type - The protocol on chips which share a
39 * common physical interface like UART.
48 #define sh_ldisc_cb(skb) ((struct sh_ldisc_skb_cb *)((skb)->cb))
50 /*******************************************************************************
52 *******************************************************************************/
57 struct sh_ldisc_skb_cb {
63 * struct sh_proto_s - Per Protocol structure from BT/FM/GPS to shared ldisc
64 * @type: type of the protocol being registered among the
65 * available proto_type(BT, FM, GPS the protocol which share TTY).
66 * @recv: the receiver callback pointing to a function in the
67 * protocol drivers called by the shared ldisc driver upon receiving
69 * @match_packet: reserved for future use, to make ST more generic
70 * @reg_complete_cb: callback handler pointing to a function in protocol
71 * handler called by shared ldisc when the pending registrations are complete.
72 * The registrations are marked pending, in situations when fw
73 * download is in progress.
74 * @write: pointer to function in shared ldisc provided to protocol drivers,
75 * to be made use when protocol drivers have data to send to TTY.
76 * @priv_data: privdate data holder for the protocol drivers, sent
77 * from the protocol drivers during registration, and sent back on
78 * reg_complete_cb and recv.
82 long (*recv) (void *, struct sk_buff *);
83 unsigned char (*match_packet) (const unsigned char *data);
84 void (*reg_complete_cb) (void *, char data);
85 long (*write) (struct sk_buff *skb);
89 /*******************************************************************************
90 ** Extern variables and functions
91 *******************************************************************************/
93 extern long hci_ldisc_register(struct sh_proto_s *);
94 extern long hci_ldisc_unregister(enum proto_type);
97 #define HCIUARTSETPROTO _IOW('U', 200, int)
98 #define HCIUARTGETPROTO _IOR('U', 201, int)
99 #define HCIUARTGETDEVICE _IOR('U', 202, int)
100 #define HCIUARTSETFLAGS _IOW('U', 203, int)
101 #define HCIUARTGETFLAGS _IOR('U', 204, int)
104 #define HCI_UART_MAX_PROTO 6
106 #define HCI_UART_H4 0
107 #define HCI_UART_BCSP 1
108 #define HCI_UART_3WIRE 2
109 #define HCI_UART_H4DS 3
110 #define HCI_UART_LL 4
111 #define HCI_UART_ATH3K 5
113 #define HCI_UART_RAW_DEVICE 0
114 #define HCI_UART_RESET_ON_INIT 1
115 #define HCI_UART_CREATE_AMP 2
116 #define HCI_UART_INIT_PENDING 3
117 #define HCI_UART_EXT_CONFIG 4
121 struct hci_uart_proto {
123 int (*open)(struct hci_uart *hu);
124 int (*close)(struct hci_uart *hu);
125 int (*flush)(struct hci_uart *hu);
126 int (*recv)(struct hci_uart *hu, void *data, int len);
127 int (*enqueue)(struct hci_uart *hu, struct sk_buff *skb);
128 struct sk_buff *(*dequeue)(struct hci_uart *hu);
132 struct tty_struct *tty;
133 struct hci_dev *hdev;
135 unsigned long hdev_flags;
137 struct work_struct init_ready;
138 struct work_struct write_work;
140 struct hci_uart_proto *proto;
143 struct sk_buff *tx_skb;
144 unsigned long tx_state;
146 #if defined(CONFIG_RADIO_BCM4343S) || defined(CONFIG_RADIO_SC2331)
147 struct sh_proto_s *list[PROTO_SH_MAX];
148 unsigned char protos_registered;
153 #if defined(CONFIG_RADIO_BCM4343S) || defined(CONFIG_RADIO_SC2331)
154 /* BT driver's local status */
155 #define BT_DRV_RUNNING 0
156 #define BT_ST_REGISTERED 1
158 /* BT driver operation structure */
161 /* hci device pointer which binds to bt driver */
162 struct hci_dev *hdev;
164 /* used locally,to maintain various BT driver status */
167 /* to hold ST registration callback status */
170 /* write function pointer of ST driver */
171 long (*st_write) (struct sk_buff *);
173 /* Wait on comepletion handler needed to synchronize
174 * hci_st_open() and hci_st_registration_completion_cb()
176 struct completion wait_for_btdrv_reg_completion;
180 /* HCI_UART proto flag bits */
181 #define HCI_UART_PROTO_SET 0
182 #define HCI_UART_REGISTERED 1
185 #define HCI_UART_SENDING 1
186 #define HCI_UART_TX_WAKEUP 2
188 int hci_uart_register_proto(struct hci_uart_proto *p);
189 int hci_uart_unregister_proto(struct hci_uart_proto *p);
190 int hci_uart_tx_wakeup(struct hci_uart *hu);
191 int hci_uart_init_ready(struct hci_uart *hu);
192 #if defined(CONFIG_RADIO_BCM4343S) || defined(CONFIG_RADIO_SC2331)
193 void hci_uart_route_frame(enum proto_type protoid, struct hci_uart *hu, struct sk_buff *skb);
194 long hci_ldisc_write(struct sk_buff *);
198 #ifdef CONFIG_BT_HCI_BCM_UART
203 #ifdef CONFIG_BT_HCIUART_BCSP
205 int bcsp_deinit(void);
208 #ifdef CONFIG_BT_HCIUART_LL
213 #ifdef CONFIG_BT_HCIUART_ATH3K
215 int ath_deinit(void);
218 #ifdef CONFIG_BT_HCIUART_3WIRE