Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[pandora-kernel.git] / drivers / staging / ti-st / st_core.h
1 /*
2  *  Shared Transport Core header file
3  *
4  *  Copyright (C) 2009 Texas Instruments
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License version 2 as
8  *  published by the Free Software Foundation.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 #ifndef ST_CORE_H
22 #define ST_CORE_H
23
24 #include <linux/skbuff.h>
25 #include "st.h"
26
27 /* states of protocol list */
28 #define ST_NOTEMPTY     1
29 #define ST_EMPTY        0
30
31 /*
32  * possible st_states
33  */
34 #define ST_INITIALIZING         1
35 #define ST_REG_IN_PROGRESS      2
36 #define ST_REG_PENDING          3
37 #define ST_WAITING_FOR_RESP     4
38
39 /*
40  * local data required for ST/KIM/ST-HCI-LL
41  */
42 struct st_data_s {
43         unsigned long st_state;
44 /*
45  * an instance of tty_struct & ldisc ops to move around
46  */
47         struct tty_struct *tty;
48         struct tty_ldisc_ops *ldisc_ops;
49 /*
50  * the tx skb -
51  * if the skb is already dequeued and the tty failed to write the same
52  * maintain the skb to write in the next transaction
53  */
54         struct sk_buff *tx_skb;
55 #define ST_TX_SENDING   1
56 #define ST_TX_WAKEUP    2
57         unsigned long tx_state;
58 /*
59  * list of protocol registered
60  */
61         struct st_proto_s *list[ST_MAX];
62 /*
63  * lock
64  */
65         unsigned long rx_state;
66         unsigned long rx_count;
67         struct sk_buff *rx_skb;
68         struct sk_buff_head txq, tx_waitq;
69         spinlock_t lock;        /* ST LL state lock  */
70         unsigned char   protos_registered;
71         unsigned long ll_state; /* ST LL power state */
72 };
73
74 /* point this to tty->driver->write or tty->ops->write
75  * depending upon the kernel version
76  */
77 int st_int_write(struct st_data_s*, const unsigned char*, int);
78 /* internal write function, passed onto protocol drivers
79  * via the write function ptr of protocol struct
80  */
81 long st_write(struct sk_buff *);
82 /* function to be called from ST-LL
83  */
84 void st_ll_send_frame(enum proto_type, struct sk_buff *);
85 /* internal wake up function */
86 void st_tx_wakeup(struct st_data_s *st_data);
87
88 int st_core_init(struct st_data_s **);
89 void st_core_exit(struct st_data_s *);
90 void st_kim_ref(struct st_data_s **);
91
92 #define GPS_STUB_TEST
93 #ifdef GPS_STUB_TEST
94 int gps_chrdrv_stub_write(const unsigned char*, int);
95 void gps_chrdrv_stub_init(void);
96 #endif
97
98 #endif /*ST_CORE_H */