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