xref: /OK3568_Linux_fs/kernel/include/linux/ti_wilink_st.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *  Shared Transport Header file
4*4882a593Smuzhiyun  *	To be included by the protocol stack drivers for
5*4882a593Smuzhiyun  *	Texas Instruments BT,FM and GPS combo chip drivers
6*4882a593Smuzhiyun  *	and also serves the sub-modules of the shared transport driver.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  *  Copyright (C) 2009-2010 Texas Instruments
9*4882a593Smuzhiyun  *  Author: Pavan Savoy <pavan_savoy@ti.com>
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #ifndef TI_WILINK_ST_H
13*4882a593Smuzhiyun #define TI_WILINK_ST_H
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <linux/skbuff.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /**
18*4882a593Smuzhiyun  * enum proto-type - The protocol on WiLink chips which share a
19*4882a593Smuzhiyun  *	common physical interface like UART.
20*4882a593Smuzhiyun  */
21*4882a593Smuzhiyun enum proto_type {
22*4882a593Smuzhiyun 	ST_BT,
23*4882a593Smuzhiyun 	ST_FM,
24*4882a593Smuzhiyun 	ST_GPS,
25*4882a593Smuzhiyun 	ST_MAX_CHANNELS = 16,
26*4882a593Smuzhiyun };
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun /**
29*4882a593Smuzhiyun  * struct st_proto_s - Per Protocol structure from BT/FM/GPS to ST
30*4882a593Smuzhiyun  * @type: type of the protocol being registered among the
31*4882a593Smuzhiyun  *	available proto_type(BT, FM, GPS the protocol which share TTY).
32*4882a593Smuzhiyun  * @recv: the receiver callback pointing to a function in the
33*4882a593Smuzhiyun  *	protocol drivers called by the ST driver upon receiving
34*4882a593Smuzhiyun  *	relevant data.
35*4882a593Smuzhiyun  * @match_packet: reserved for future use, to make ST more generic
36*4882a593Smuzhiyun  * @reg_complete_cb: callback handler pointing to a function in protocol
37*4882a593Smuzhiyun  *	handler called by ST when the pending registrations are complete.
38*4882a593Smuzhiyun  *	The registrations are marked pending, in situations when fw
39*4882a593Smuzhiyun  *	download is in progress.
40*4882a593Smuzhiyun  * @write: pointer to function in ST provided to protocol drivers from ST,
41*4882a593Smuzhiyun  *	to be made use when protocol drivers have data to send to TTY.
42*4882a593Smuzhiyun  * @priv_data: privdate data holder for the protocol drivers, sent
43*4882a593Smuzhiyun  *	from the protocol drivers during registration, and sent back on
44*4882a593Smuzhiyun  *	reg_complete_cb and recv.
45*4882a593Smuzhiyun  * @chnl_id: channel id the protocol driver is interested in, the channel
46*4882a593Smuzhiyun  *	id is nothing but the 1st byte of the packet in UART frame.
47*4882a593Smuzhiyun  * @max_frame_size: size of the largest frame the protocol can receive.
48*4882a593Smuzhiyun  * @hdr_len: length of the header structure of the protocol.
49*4882a593Smuzhiyun  * @offset_len_in_hdr: this provides the offset of the length field in the
50*4882a593Smuzhiyun  *	header structure of the protocol header, to assist ST to know
51*4882a593Smuzhiyun  *	how much to receive, if the data is split across UART frames.
52*4882a593Smuzhiyun  * @len_size: whether the length field inside the header is 2 bytes
53*4882a593Smuzhiyun  *	or 1 byte.
54*4882a593Smuzhiyun  * @reserve: the number of bytes ST needs to reserve in the skb being
55*4882a593Smuzhiyun  *	prepared for the protocol driver.
56*4882a593Smuzhiyun  */
57*4882a593Smuzhiyun struct st_proto_s {
58*4882a593Smuzhiyun 	enum proto_type type;
59*4882a593Smuzhiyun 	long (*recv) (void *, struct sk_buff *);
60*4882a593Smuzhiyun 	unsigned char (*match_packet) (const unsigned char *data);
61*4882a593Smuzhiyun 	void (*reg_complete_cb) (void *, int data);
62*4882a593Smuzhiyun 	long (*write) (struct sk_buff *skb);
63*4882a593Smuzhiyun 	void *priv_data;
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun 	unsigned char chnl_id;
66*4882a593Smuzhiyun 	unsigned short max_frame_size;
67*4882a593Smuzhiyun 	unsigned char hdr_len;
68*4882a593Smuzhiyun 	unsigned char offset_len_in_hdr;
69*4882a593Smuzhiyun 	unsigned char len_size;
70*4882a593Smuzhiyun 	unsigned char reserve;
71*4882a593Smuzhiyun };
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun extern long st_register(struct st_proto_s *);
74*4882a593Smuzhiyun extern long st_unregister(struct st_proto_s *);
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun /*
78*4882a593Smuzhiyun  * header information used by st_core.c
79*4882a593Smuzhiyun  */
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun /* states of protocol list */
82*4882a593Smuzhiyun #define ST_NOTEMPTY	1
83*4882a593Smuzhiyun #define ST_EMPTY	0
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun /*
86*4882a593Smuzhiyun  * possible st_states
87*4882a593Smuzhiyun  */
88*4882a593Smuzhiyun #define ST_INITIALIZING		1
89*4882a593Smuzhiyun #define ST_REG_IN_PROGRESS	2
90*4882a593Smuzhiyun #define ST_REG_PENDING		3
91*4882a593Smuzhiyun #define ST_WAITING_FOR_RESP	4
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun /**
94*4882a593Smuzhiyun  * struct st_data_s - ST core internal structure
95*4882a593Smuzhiyun  * @st_state: different states of ST like initializing, registration
96*4882a593Smuzhiyun  *	in progress, this is mainly used to return relevant err codes
97*4882a593Smuzhiyun  *	when protocol drivers are registering. It is also used to track
98*4882a593Smuzhiyun  *	the recv function, as in during fw download only HCI events
99*4882a593Smuzhiyun  *	can occur , where as during other times other events CH8, CH9
100*4882a593Smuzhiyun  *	can occur.
101*4882a593Smuzhiyun  * @tty: tty provided by the TTY core for line disciplines.
102*4882a593Smuzhiyun  * @tx_skb: If for some reason the tty's write returns lesser bytes written
103*4882a593Smuzhiyun  *	then to maintain the rest of data to be written on next instance.
104*4882a593Smuzhiyun  *	This needs to be protected, hence the lock inside wakeup func.
105*4882a593Smuzhiyun  * @tx_state: if the data is being written onto the TTY and protocol driver
106*4882a593Smuzhiyun  *	wants to send more, queue up data and mark that there is
107*4882a593Smuzhiyun  *	more data to send.
108*4882a593Smuzhiyun  * @list: the list of protocols registered, only MAX can exist, one protocol
109*4882a593Smuzhiyun  *	can register only once.
110*4882a593Smuzhiyun  * @rx_state: states to be maintained inside st's tty receive
111*4882a593Smuzhiyun  * @rx_count: count to be maintained inside st's tty receieve
112*4882a593Smuzhiyun  * @rx_skb: the skb where all data for a protocol gets accumulated,
113*4882a593Smuzhiyun  *	since tty might not call receive when a complete event packet
114*4882a593Smuzhiyun  *	is received, the states, count and the skb needs to be maintained.
115*4882a593Smuzhiyun  * @rx_chnl: the channel ID for which the data is getting accumalated for.
116*4882a593Smuzhiyun  * @txq: the list of skbs which needs to be sent onto the TTY.
117*4882a593Smuzhiyun  * @tx_waitq: if the chip is not in AWAKE state, the skbs needs to be queued
118*4882a593Smuzhiyun  *	up in here, PM(WAKEUP_IND) data needs to be sent and then the skbs
119*4882a593Smuzhiyun  *	from waitq can be moved onto the txq.
120*4882a593Smuzhiyun  *	Needs locking too.
121*4882a593Smuzhiyun  * @lock: the lock to protect skbs, queues, and ST states.
122*4882a593Smuzhiyun  * @protos_registered: count of the protocols registered, also when 0 the
123*4882a593Smuzhiyun  *	chip enable gpio can be toggled, and when it changes to 1 the fw
124*4882a593Smuzhiyun  *	needs to be downloaded to initialize chip side ST.
125*4882a593Smuzhiyun  * @ll_state: the various PM states the chip can be, the states are notified
126*4882a593Smuzhiyun  *	to us, when the chip sends relevant PM packets(SLEEP_IND, WAKE_IND).
127*4882a593Smuzhiyun  * @kim_data: reference to the parent encapsulating structure.
128*4882a593Smuzhiyun  *
129*4882a593Smuzhiyun  */
130*4882a593Smuzhiyun struct st_data_s {
131*4882a593Smuzhiyun 	unsigned long st_state;
132*4882a593Smuzhiyun 	struct sk_buff *tx_skb;
133*4882a593Smuzhiyun #define ST_TX_SENDING	1
134*4882a593Smuzhiyun #define ST_TX_WAKEUP	2
135*4882a593Smuzhiyun 	unsigned long tx_state;
136*4882a593Smuzhiyun 	struct st_proto_s *list[ST_MAX_CHANNELS];
137*4882a593Smuzhiyun 	bool is_registered[ST_MAX_CHANNELS];
138*4882a593Smuzhiyun 	unsigned long rx_state;
139*4882a593Smuzhiyun 	unsigned long rx_count;
140*4882a593Smuzhiyun 	struct sk_buff *rx_skb;
141*4882a593Smuzhiyun 	unsigned char rx_chnl;
142*4882a593Smuzhiyun 	struct sk_buff_head txq, tx_waitq;
143*4882a593Smuzhiyun 	spinlock_t lock;
144*4882a593Smuzhiyun 	unsigned char	protos_registered;
145*4882a593Smuzhiyun 	unsigned long ll_state;
146*4882a593Smuzhiyun 	void *kim_data;
147*4882a593Smuzhiyun 	struct tty_struct *tty;
148*4882a593Smuzhiyun 	struct work_struct work_write_wakeup;
149*4882a593Smuzhiyun };
150*4882a593Smuzhiyun 
151*4882a593Smuzhiyun /*
152*4882a593Smuzhiyun  * wrapper around tty->ops->write_room to check
153*4882a593Smuzhiyun  * availability during firmware download
154*4882a593Smuzhiyun  */
155*4882a593Smuzhiyun int st_get_uart_wr_room(struct st_data_s *st_gdata);
156*4882a593Smuzhiyun /**
157*4882a593Smuzhiyun  * st_int_write -
158*4882a593Smuzhiyun  * point this to tty->driver->write or tty->ops->write
159*4882a593Smuzhiyun  * depending upon the kernel version
160*4882a593Smuzhiyun  */
161*4882a593Smuzhiyun int st_int_write(struct st_data_s*, const unsigned char*, int);
162*4882a593Smuzhiyun 
163*4882a593Smuzhiyun /**
164*4882a593Smuzhiyun  * st_write -
165*4882a593Smuzhiyun  * internal write function, passed onto protocol drivers
166*4882a593Smuzhiyun  * via the write function ptr of protocol struct
167*4882a593Smuzhiyun  */
168*4882a593Smuzhiyun long st_write(struct sk_buff *);
169*4882a593Smuzhiyun 
170*4882a593Smuzhiyun /* function to be called from ST-LL */
171*4882a593Smuzhiyun void st_ll_send_frame(enum proto_type, struct sk_buff *);
172*4882a593Smuzhiyun 
173*4882a593Smuzhiyun /* internal wake up function */
174*4882a593Smuzhiyun void st_tx_wakeup(struct st_data_s *st_data);
175*4882a593Smuzhiyun 
176*4882a593Smuzhiyun /* init, exit entry funcs called from KIM */
177*4882a593Smuzhiyun int st_core_init(struct st_data_s **);
178*4882a593Smuzhiyun void st_core_exit(struct st_data_s *);
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun /* ask for reference from KIM */
181*4882a593Smuzhiyun void st_kim_ref(struct st_data_s **, int);
182*4882a593Smuzhiyun 
183*4882a593Smuzhiyun #define GPS_STUB_TEST
184*4882a593Smuzhiyun #ifdef GPS_STUB_TEST
185*4882a593Smuzhiyun int gps_chrdrv_stub_write(const unsigned char*, int);
186*4882a593Smuzhiyun void gps_chrdrv_stub_init(void);
187*4882a593Smuzhiyun #endif
188*4882a593Smuzhiyun 
189*4882a593Smuzhiyun /*
190*4882a593Smuzhiyun  * header information used by st_kim.c
191*4882a593Smuzhiyun  */
192*4882a593Smuzhiyun 
193*4882a593Smuzhiyun /* time in msec to wait for
194*4882a593Smuzhiyun  * line discipline to be installed
195*4882a593Smuzhiyun  */
196*4882a593Smuzhiyun #define LDISC_TIME	1000
197*4882a593Smuzhiyun #define CMD_RESP_TIME	800
198*4882a593Smuzhiyun #define CMD_WR_TIME	5000
199*4882a593Smuzhiyun #define MAKEWORD(a, b)  ((unsigned short)(((unsigned char)(a)) \
200*4882a593Smuzhiyun 	| ((unsigned short)((unsigned char)(b))) << 8))
201*4882a593Smuzhiyun 
202*4882a593Smuzhiyun #define GPIO_HIGH 1
203*4882a593Smuzhiyun #define GPIO_LOW  0
204*4882a593Smuzhiyun 
205*4882a593Smuzhiyun /* the Power-On-Reset logic, requires to attempt
206*4882a593Smuzhiyun  * to download firmware onto chip more than once
207*4882a593Smuzhiyun  * since the self-test for chip takes a while
208*4882a593Smuzhiyun  */
209*4882a593Smuzhiyun #define POR_RETRY_COUNT 5
210*4882a593Smuzhiyun 
211*4882a593Smuzhiyun /**
212*4882a593Smuzhiyun  * struct chip_version - save the chip version
213*4882a593Smuzhiyun  */
214*4882a593Smuzhiyun struct chip_version {
215*4882a593Smuzhiyun 	unsigned short full;
216*4882a593Smuzhiyun 	unsigned short chip;
217*4882a593Smuzhiyun 	unsigned short min_ver;
218*4882a593Smuzhiyun 	unsigned short maj_ver;
219*4882a593Smuzhiyun };
220*4882a593Smuzhiyun 
221*4882a593Smuzhiyun #define UART_DEV_NAME_LEN 32
222*4882a593Smuzhiyun /**
223*4882a593Smuzhiyun  * struct kim_data_s - the KIM internal data, embedded as the
224*4882a593Smuzhiyun  *	platform's drv data. One for each ST device in the system.
225*4882a593Smuzhiyun  * @uim_pid: KIM needs to communicate with UIM to request to install
226*4882a593Smuzhiyun  *	the ldisc by opening UART when protocol drivers register.
227*4882a593Smuzhiyun  * @kim_pdev: the platform device added in one of the board-XX.c file
228*4882a593Smuzhiyun  *	in arch/XX/ directory, 1 for each ST device.
229*4882a593Smuzhiyun  * @kim_rcvd: completion handler to notify when data was received,
230*4882a593Smuzhiyun  *	mainly used during fw download, which involves multiple send/wait
231*4882a593Smuzhiyun  *	for each of the HCI-VS commands.
232*4882a593Smuzhiyun  * @ldisc_installed: completion handler to notify that the UIM accepted
233*4882a593Smuzhiyun  *	the request to install ldisc, notify from tty_open which suggests
234*4882a593Smuzhiyun  *	the ldisc was properly installed.
235*4882a593Smuzhiyun  * @resp_buffer: data buffer for the .bts fw file name.
236*4882a593Smuzhiyun  * @fw_entry: firmware class struct to request/release the fw.
237*4882a593Smuzhiyun  * @rx_state: the rx state for kim's receive func during fw download.
238*4882a593Smuzhiyun  * @rx_count: the rx count for the kim's receive func during fw download.
239*4882a593Smuzhiyun  * @rx_skb: all of fw data might not come at once, and hence data storage for
240*4882a593Smuzhiyun  *	whole of the fw response, only HCI_EVENTs and hence diff from ST's
241*4882a593Smuzhiyun  *	response.
242*4882a593Smuzhiyun  * @core_data: ST core's data, which mainly is the tty's disc_data
243*4882a593Smuzhiyun  * @version: chip version available via a sysfs entry.
244*4882a593Smuzhiyun  *
245*4882a593Smuzhiyun  */
246*4882a593Smuzhiyun struct kim_data_s {
247*4882a593Smuzhiyun 	long uim_pid;
248*4882a593Smuzhiyun 	struct platform_device *kim_pdev;
249*4882a593Smuzhiyun 	struct completion kim_rcvd, ldisc_installed;
250*4882a593Smuzhiyun 	char resp_buffer[30];
251*4882a593Smuzhiyun 	const struct firmware *fw_entry;
252*4882a593Smuzhiyun 	unsigned nshutdown;
253*4882a593Smuzhiyun 	unsigned long rx_state;
254*4882a593Smuzhiyun 	unsigned long rx_count;
255*4882a593Smuzhiyun 	struct sk_buff *rx_skb;
256*4882a593Smuzhiyun 	struct st_data_s *core_data;
257*4882a593Smuzhiyun 	struct chip_version version;
258*4882a593Smuzhiyun 	unsigned char ldisc_install;
259*4882a593Smuzhiyun 	unsigned char dev_name[UART_DEV_NAME_LEN + 1];
260*4882a593Smuzhiyun 	unsigned flow_cntrl;
261*4882a593Smuzhiyun 	unsigned baud_rate;
262*4882a593Smuzhiyun };
263*4882a593Smuzhiyun 
264*4882a593Smuzhiyun /**
265*4882a593Smuzhiyun  * functions called when 1 of the protocol drivers gets
266*4882a593Smuzhiyun  * registered, these need to communicate with UIM to request
267*4882a593Smuzhiyun  * ldisc installed, read chip_version, download relevant fw
268*4882a593Smuzhiyun  */
269*4882a593Smuzhiyun long st_kim_start(void *);
270*4882a593Smuzhiyun long st_kim_stop(void *);
271*4882a593Smuzhiyun 
272*4882a593Smuzhiyun void st_kim_complete(void *);
273*4882a593Smuzhiyun void kim_st_list_protocols(struct st_data_s *, void *);
274*4882a593Smuzhiyun void st_kim_recv(void *, const unsigned char *, long);
275*4882a593Smuzhiyun 
276*4882a593Smuzhiyun 
277*4882a593Smuzhiyun /*
278*4882a593Smuzhiyun  * BTS headers
279*4882a593Smuzhiyun  */
280*4882a593Smuzhiyun #define ACTION_SEND_COMMAND     1
281*4882a593Smuzhiyun #define ACTION_WAIT_EVENT       2
282*4882a593Smuzhiyun #define ACTION_SERIAL           3
283*4882a593Smuzhiyun #define ACTION_DELAY            4
284*4882a593Smuzhiyun #define ACTION_RUN_SCRIPT       5
285*4882a593Smuzhiyun #define ACTION_REMARKS          6
286*4882a593Smuzhiyun 
287*4882a593Smuzhiyun /**
288*4882a593Smuzhiyun  * struct bts_header - the fw file is NOT binary which can
289*4882a593Smuzhiyun  *	be sent onto TTY as is. The .bts is more a script
290*4882a593Smuzhiyun  *	file which has different types of actions.
291*4882a593Smuzhiyun  *	Each such action needs to be parsed by the KIM and
292*4882a593Smuzhiyun  *	relevant procedure to be called.
293*4882a593Smuzhiyun  */
294*4882a593Smuzhiyun struct bts_header {
295*4882a593Smuzhiyun 	u32 magic;
296*4882a593Smuzhiyun 	u32 version;
297*4882a593Smuzhiyun 	u8 future[24];
298*4882a593Smuzhiyun 	u8 actions[];
299*4882a593Smuzhiyun } __attribute__ ((packed));
300*4882a593Smuzhiyun 
301*4882a593Smuzhiyun /**
302*4882a593Smuzhiyun  * struct bts_action - Each .bts action has its own type of
303*4882a593Smuzhiyun  *	data.
304*4882a593Smuzhiyun  */
305*4882a593Smuzhiyun struct bts_action {
306*4882a593Smuzhiyun 	u16 type;
307*4882a593Smuzhiyun 	u16 size;
308*4882a593Smuzhiyun 	u8 data[];
309*4882a593Smuzhiyun } __attribute__ ((packed));
310*4882a593Smuzhiyun 
311*4882a593Smuzhiyun struct bts_action_send {
312*4882a593Smuzhiyun 	u8 data[0];
313*4882a593Smuzhiyun } __attribute__ ((packed));
314*4882a593Smuzhiyun 
315*4882a593Smuzhiyun struct bts_action_wait {
316*4882a593Smuzhiyun 	u32 msec;
317*4882a593Smuzhiyun 	u32 size;
318*4882a593Smuzhiyun 	u8 data[];
319*4882a593Smuzhiyun } __attribute__ ((packed));
320*4882a593Smuzhiyun 
321*4882a593Smuzhiyun struct bts_action_delay {
322*4882a593Smuzhiyun 	u32 msec;
323*4882a593Smuzhiyun } __attribute__ ((packed));
324*4882a593Smuzhiyun 
325*4882a593Smuzhiyun struct bts_action_serial {
326*4882a593Smuzhiyun 	u32 baud;
327*4882a593Smuzhiyun 	u32 flow_control;
328*4882a593Smuzhiyun } __attribute__ ((packed));
329*4882a593Smuzhiyun 
330*4882a593Smuzhiyun /**
331*4882a593Smuzhiyun  * struct hci_command - the HCI-VS for intrepreting
332*4882a593Smuzhiyun  *	the change baud rate of host-side UART, which
333*4882a593Smuzhiyun  *	needs to be ignored, since UIM would do that
334*4882a593Smuzhiyun  *	when it receives request from KIM for ldisc installation.
335*4882a593Smuzhiyun  */
336*4882a593Smuzhiyun struct hci_command {
337*4882a593Smuzhiyun 	u8 prefix;
338*4882a593Smuzhiyun 	u16 opcode;
339*4882a593Smuzhiyun 	u8 plen;
340*4882a593Smuzhiyun 	u32 speed;
341*4882a593Smuzhiyun } __attribute__ ((packed));
342*4882a593Smuzhiyun 
343*4882a593Smuzhiyun /*
344*4882a593Smuzhiyun  * header information used by st_ll.c
345*4882a593Smuzhiyun  */
346*4882a593Smuzhiyun 
347*4882a593Smuzhiyun /* ST LL receiver states */
348*4882a593Smuzhiyun #define ST_W4_PACKET_TYPE       0
349*4882a593Smuzhiyun #define ST_W4_HEADER		1
350*4882a593Smuzhiyun #define ST_W4_DATA		2
351*4882a593Smuzhiyun 
352*4882a593Smuzhiyun /* ST LL state machines */
353*4882a593Smuzhiyun #define ST_LL_ASLEEP               0
354*4882a593Smuzhiyun #define ST_LL_ASLEEP_TO_AWAKE      1
355*4882a593Smuzhiyun #define ST_LL_AWAKE                2
356*4882a593Smuzhiyun #define ST_LL_AWAKE_TO_ASLEEP      3
357*4882a593Smuzhiyun #define ST_LL_INVALID		   4
358*4882a593Smuzhiyun 
359*4882a593Smuzhiyun /* different PM notifications coming from chip */
360*4882a593Smuzhiyun #define LL_SLEEP_IND	0x30
361*4882a593Smuzhiyun #define LL_SLEEP_ACK	0x31
362*4882a593Smuzhiyun #define LL_WAKE_UP_IND	0x32
363*4882a593Smuzhiyun #define LL_WAKE_UP_ACK	0x33
364*4882a593Smuzhiyun 
365*4882a593Smuzhiyun /* initialize and de-init ST LL */
366*4882a593Smuzhiyun long st_ll_init(struct st_data_s *);
367*4882a593Smuzhiyun long st_ll_deinit(struct st_data_s *);
368*4882a593Smuzhiyun 
369*4882a593Smuzhiyun /**
370*4882a593Smuzhiyun  * enable/disable ST LL along with KIM start/stop
371*4882a593Smuzhiyun  * called by ST Core
372*4882a593Smuzhiyun  */
373*4882a593Smuzhiyun void st_ll_enable(struct st_data_s *);
374*4882a593Smuzhiyun void st_ll_disable(struct st_data_s *);
375*4882a593Smuzhiyun 
376*4882a593Smuzhiyun /**
377*4882a593Smuzhiyun  * various funcs used by ST core to set/get the various PM states
378*4882a593Smuzhiyun  * of the chip.
379*4882a593Smuzhiyun  */
380*4882a593Smuzhiyun unsigned long st_ll_getstate(struct st_data_s *);
381*4882a593Smuzhiyun unsigned long st_ll_sleep_state(struct st_data_s *, unsigned char);
382*4882a593Smuzhiyun void st_ll_wakeup(struct st_data_s *);
383*4882a593Smuzhiyun 
384*4882a593Smuzhiyun /*
385*4882a593Smuzhiyun  * header information used by st_core.c for FM and GPS
386*4882a593Smuzhiyun  * packet parsing, the bluetooth headers are already available
387*4882a593Smuzhiyun  * at net/bluetooth/
388*4882a593Smuzhiyun  */
389*4882a593Smuzhiyun 
390*4882a593Smuzhiyun struct fm_event_hdr {
391*4882a593Smuzhiyun 	u8 plen;
392*4882a593Smuzhiyun } __attribute__ ((packed));
393*4882a593Smuzhiyun 
394*4882a593Smuzhiyun #define FM_MAX_FRAME_SIZE 0xFF	/* TODO: */
395*4882a593Smuzhiyun #define FM_EVENT_HDR_SIZE 1	/* size of fm_event_hdr */
396*4882a593Smuzhiyun #define ST_FM_CH8_PKT 0x8
397*4882a593Smuzhiyun 
398*4882a593Smuzhiyun /* gps stuff */
399*4882a593Smuzhiyun struct gps_event_hdr {
400*4882a593Smuzhiyun 	u8 opcode;
401*4882a593Smuzhiyun 	u16 plen;
402*4882a593Smuzhiyun } __attribute__ ((packed));
403*4882a593Smuzhiyun 
404*4882a593Smuzhiyun /**
405*4882a593Smuzhiyun  * struct ti_st_plat_data - platform data shared between ST driver and
406*4882a593Smuzhiyun  *	platform specific board file which adds the ST device.
407*4882a593Smuzhiyun  * @nshutdown_gpio: Host's GPIO line to which chip's BT_EN is connected.
408*4882a593Smuzhiyun  * @dev_name: The UART/TTY name to which chip is interfaced. (eg: /dev/ttyS1)
409*4882a593Smuzhiyun  * @flow_cntrl: Should always be 1, since UART's CTS/RTS is used for PM
410*4882a593Smuzhiyun  *	purposes.
411*4882a593Smuzhiyun  * @baud_rate: The baud rate supported by the Host UART controller, this will
412*4882a593Smuzhiyun  *	be shared across with the chip via a HCI VS command from User-Space Init
413*4882a593Smuzhiyun  *	Mgr application.
414*4882a593Smuzhiyun  * @suspend:
415*4882a593Smuzhiyun  * @resume: legacy PM routines hooked to platform specific board file, so as
416*4882a593Smuzhiyun  *	to take chip-host interface specific action.
417*4882a593Smuzhiyun  * @chip_enable:
418*4882a593Smuzhiyun  * @chip_disable: Platform/Interface specific mux mode setting, GPIO
419*4882a593Smuzhiyun  *	configuring, Host side PM disabling etc.. can be done here.
420*4882a593Smuzhiyun  * @chip_asleep:
421*4882a593Smuzhiyun  * @chip_awake: Chip specific deep sleep states is communicated to Host
422*4882a593Smuzhiyun  *	specific board-xx.c to take actions such as cut UART clocks when chip
423*4882a593Smuzhiyun  *	asleep or run host faster when chip awake etc..
424*4882a593Smuzhiyun  *
425*4882a593Smuzhiyun  */
426*4882a593Smuzhiyun struct ti_st_plat_data {
427*4882a593Smuzhiyun 	u32 nshutdown_gpio;
428*4882a593Smuzhiyun 	unsigned char dev_name[UART_DEV_NAME_LEN]; /* uart name */
429*4882a593Smuzhiyun 	u32 flow_cntrl; /* flow control flag */
430*4882a593Smuzhiyun 	u32 baud_rate;
431*4882a593Smuzhiyun 	int (*suspend)(struct platform_device *, pm_message_t);
432*4882a593Smuzhiyun 	int (*resume)(struct platform_device *);
433*4882a593Smuzhiyun 	int (*chip_enable) (struct kim_data_s *);
434*4882a593Smuzhiyun 	int (*chip_disable) (struct kim_data_s *);
435*4882a593Smuzhiyun 	int (*chip_asleep) (struct kim_data_s *);
436*4882a593Smuzhiyun 	int (*chip_awake) (struct kim_data_s *);
437*4882a593Smuzhiyun };
438*4882a593Smuzhiyun 
439*4882a593Smuzhiyun #endif /* TI_WILINK_ST_H */
440