]> Pileus Git - ~andy/linux/blob - drivers/staging/ti-st/st_kim.h
d5685f4958e3a3574f8a02a9e98ed36d0a5319f1
[~andy/linux] / drivers / staging / ti-st / st_kim.h
1 /*
2  *  Shared Transport Line discipline driver Core
3  *      Init Manager Module header file
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_KIM_H
22 #define ST_KIM_H
23
24 #include <linux/types.h>
25 #include "st.h"
26 #include "st_core.h"
27 #include "st_ll.h"
28 #include <linux/rfkill.h>
29
30 /* time in msec to wait for
31  * line discipline to be installed
32  */
33 #define LDISC_TIME      500
34 #define CMD_RESP_TIME   500
35 #define MAKEWORD(a, b)  ((unsigned short)(((unsigned char)(a)) \
36         | ((unsigned short)((unsigned char)(b))) << 8))
37
38 #define GPIO_HIGH 1
39 #define GPIO_LOW  0
40
41 /* the Power-On-Reset logic, requires to attempt
42  * to download firmware onto chip more than once
43  * since the self-test for chip takes a while
44  */
45 #define POR_RETRY_COUNT 5
46 /*
47  * legacy rfkill support where-in 3 rfkill
48  * devices are created for the 3 gpios
49  * that ST has requested
50  */
51
52 /* chip version storage
53  */
54 struct chip_version {
55         unsigned short full;
56         unsigned short chip;
57         unsigned short min_ver;
58         unsigned short maj_ver;
59 };
60
61 /*
62  * header file for ST provided by KIM
63  */
64 struct kim_data_s {
65         long uim_pid;
66         struct platform_device *kim_pdev;
67         struct completion kim_rcvd, ldisc_installed;
68         /* MAX len of the .bts firmware script name */
69         char resp_buffer[30];
70         const struct firmware *fw_entry;
71         long gpios[ST_MAX];
72 /* used by kim_int_recv to validate fw response */
73         unsigned long rx_state;
74         unsigned long rx_count;
75         struct sk_buff *rx_skb;
76         struct rfkill *rfkill[ST_MAX];
77         enum proto_type rf_protos[ST_MAX];
78         struct st_data_s *core_data;
79         struct chip_version version;
80 };
81
82 long st_kim_start(void *);
83 long st_kim_stop(void *);
84 /*
85  * called from st_tty_receive to authenticate fw_download
86  */
87 void st_kim_recv(void *, const unsigned char *, long count);
88
89 void st_kim_chip_toggle(enum proto_type, enum kim_gpio_state);
90
91 void st_kim_complete(void *);
92
93 /* function called from ST KIM to ST Core, to
94  * list out the protocols registered
95  */
96 void kim_st_list_protocols(struct st_data_s *, char *);
97
98 /*
99  * BTS headers
100  */
101 #define ACTION_SEND_COMMAND     1
102 #define ACTION_WAIT_EVENT       2
103 #define ACTION_SERIAL           3
104 #define ACTION_DELAY            4
105 #define ACTION_RUN_SCRIPT       5
106 #define ACTION_REMARKS          6
107
108 /*
109  *  * BRF Firmware header
110  *   */
111 struct bts_header {
112         uint32_t magic;
113         uint32_t version;
114         uint8_t future[24];
115         uint8_t actions[0];
116 } __attribute__ ((packed));
117
118 /*
119  *  * BRF Actions structure
120  *   */
121 struct bts_action {
122         uint16_t type;
123         uint16_t size;
124         uint8_t data[0];
125 } __attribute__ ((packed));
126
127 struct bts_action_send {
128         uint8_t data[0];
129 } __attribute__ ((packed));
130
131 struct bts_action_wait {
132         uint32_t msec;
133         uint32_t size;
134         uint8_t data[0];
135 } __attribute__ ((packed));
136
137 struct bts_action_delay {
138         uint32_t msec;
139 } __attribute__ ((packed));
140
141 struct bts_action_serial {
142         uint32_t baud;
143         uint32_t flow_control;
144 } __attribute__ ((packed));
145
146 /* for identifying the change speed HCI VS
147  * command
148  */
149 struct hci_command {
150         uint8_t prefix;
151         uint16_t opcode;
152         uint8_t plen;
153         uint32_t speed;
154 } __attribute__ ((packed));
155
156
157 #endif /* ST_KIM_H */