drm/cma: Cocci spatch "ptr_ret.spatch"
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / bluetooth / hci_uart_bcm.h
1 /*
2  *
3  *  Bluetooth HCI UART driver
4  *
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>
8  *
9  *
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.
14  *
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.
19  *
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
23  *
24  */
25
26 #ifndef N_HCI
27 #define N_HCI   15
28 #endif
29
30 #if defined(CONFIG_RADIO_BCM4343S) || defined(CONFIG_RADIO_SC2331)
31 #include <linux/skbuff.h>
32
33 /*******************************************************************************
34 **  Constants
35 *******************************************************************************/
36
37 /*
38  * enum proto-type - The protocol on chips which share a
39  *      common physical interface like UART.
40  */
41 enum proto_type {
42     PROTO_SH_BT,
43     PROTO_SH_FM,
44     PROTO_SH_GPS,
45     PROTO_SH_MAX,
46 };
47
48 #define sh_ldisc_cb(skb) ((struct sh_ldisc_skb_cb *)((skb)->cb))
49
50 /*******************************************************************************
51 **  Type definitions
52 *******************************************************************************/
53
54 /*
55  * Skb helpers
56  */
57 struct sh_ldisc_skb_cb {
58     __u8 pkt_type;
59     __u32 lparam;
60 };
61
62 /**
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
68  *      relevant data.
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.
79  */
80 struct sh_proto_s {
81     enum proto_type type;
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);
86     void *priv_data;
87 };
88
89 /*******************************************************************************
90 **  Extern variables and functions
91 *******************************************************************************/
92
93 extern long hci_ldisc_register(struct sh_proto_s *);
94 extern long hci_ldisc_unregister(enum proto_type);
95 #endif
96 /* Ioctls */
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)
102
103 /* UART protocols */
104 #define HCI_UART_MAX_PROTO      6
105
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
112
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
118
119 struct hci_uart;
120
121 struct hci_uart_proto {
122         unsigned int id;
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);
129 };
130
131 struct hci_uart {
132         struct tty_struct       *tty;
133         struct hci_dev          *hdev;
134         unsigned long           flags;
135         unsigned long           hdev_flags;
136
137         struct work_struct      init_ready;
138         struct work_struct      write_work;
139
140         struct hci_uart_proto   *proto;
141         void                    *priv;
142
143         struct sk_buff          *tx_skb;
144         unsigned long           tx_state;
145         spinlock_t              rx_lock;
146 #if defined(CONFIG_RADIO_BCM4343S) || defined(CONFIG_RADIO_SC2331)
147    struct sh_proto_s *list[PROTO_SH_MAX];
148    unsigned char    protos_registered;
149    spinlock_t lock;
150 #endif
151
152 };
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
157
158 /* BT driver operation structure */
159 struct hci_st {
160
161     /* hci device pointer which binds to bt driver */
162     struct hci_dev *hdev;
163
164     /* used locally,to maintain various BT driver status */
165     unsigned long flags;
166
167     /* to hold ST registration callback  status */
168     char streg_cbdata;
169
170     /* write function pointer of ST driver */
171     long (*st_write) (struct sk_buff *);
172
173     /* Wait on comepletion handler needed to synchronize
174     * hci_st_open() and hci_st_registration_completion_cb()
175     * functions.*/
176     struct completion wait_for_btdrv_reg_completion;
177 };
178 #endif
179
180 /* HCI_UART proto flag bits */
181 #define HCI_UART_PROTO_SET      0
182 #define HCI_UART_REGISTERED     1
183
184 /* TX states  */
185 #define HCI_UART_SENDING        1
186 #define HCI_UART_TX_WAKEUP      2
187
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 *);
195
196
197 #endif
198 #ifdef CONFIG_BT_HCI_BCM_UART
199 int h4_init(void);
200 int h4_deinit(void);
201 #endif
202
203 #ifdef CONFIG_BT_HCIUART_BCSP
204 int bcsp_init(void);
205 int bcsp_deinit(void);
206 #endif
207
208 #ifdef CONFIG_BT_HCIUART_LL
209 int ll_init(void);
210 int ll_deinit(void);
211 #endif
212
213 #ifdef CONFIG_BT_HCIUART_ATH3K
214 int ath_init(void);
215 int ath_deinit(void);
216 #endif
217
218 #ifdef CONFIG_BT_HCIUART_3WIRE
219 int h5_init(void);
220 int h5_deinit(void);
221 #endif