1 //------------------------------------------------------------------------------
2 // <copyright file="wmix.h" company="Atheros">
3 //    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
4 //
5 //
6 // Permission to use, copy, modify, and/or distribute this software for any
7 // purpose with or without fee is hereby granted, provided that the above
8 // copyright notice and this permission notice appear in all copies.
9 //
10 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 //
18 //
19 //------------------------------------------------------------------------------
20 //==============================================================================
21 // Author(s): ="Atheros"
22 //==============================================================================
23 
24 /*
25  * This file contains extensions of the WMI protocol specified in the
26  * Wireless Module Interface (WMI).  It includes definitions of all
27  * extended commands and events.  Extensions include useful commands
28  * that are not directly related to wireless activities.  They may
29  * be hardware-specific, and they might not be supported on all
30  * implementations.
31  *
32  * Extended WMIX commands are encapsulated in a WMI message with
33  * cmd=WMI_EXTENSION_CMD.
34  */
35 
36 #ifndef _WMIX_H_
37 #define _WMIX_H_
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #ifndef ATH_TARGET
44 #include "athstartpack.h"
45 #endif
46 
47 #include "dbglog.h"
48 
49 /*
50  * Extended WMI commands are those that are needed during wireless
51  * operation, but which are not really wireless commands.  This allows,
52  * for instance, platform-specific commands.  Extended WMI commands are
53  * embedded in a WMI command message with WMI_COMMAND_ID=WMI_EXTENSION_CMDID.
54  * Extended WMI events are similarly embedded in a WMI event message with
55  * WMI_EVENT_ID=WMI_EXTENSION_EVENTID.
56  */
57 typedef PREPACK struct {
58     u32 commandId;
59 } POSTPACK WMIX_CMD_HDR;
60 
61 typedef enum {
62     WMIX_DSETOPEN_REPLY_CMDID           = 0x2001,
63     WMIX_DSETDATA_REPLY_CMDID,
64     WMIX_GPIO_OUTPUT_SET_CMDID,
65     WMIX_GPIO_INPUT_GET_CMDID,
66     WMIX_GPIO_REGISTER_SET_CMDID,
67     WMIX_GPIO_REGISTER_GET_CMDID,
68     WMIX_GPIO_INTR_ACK_CMDID,
69     WMIX_HB_CHALLENGE_RESP_CMDID,
70     WMIX_DBGLOG_CFG_MODULE_CMDID,
71     WMIX_PROF_CFG_CMDID,                 /* 0x200a */
72     WMIX_PROF_ADDR_SET_CMDID,
73     WMIX_PROF_START_CMDID,
74     WMIX_PROF_STOP_CMDID,
75     WMIX_PROF_COUNT_GET_CMDID,
76 } WMIX_COMMAND_ID;
77 
78 typedef enum {
79     WMIX_DSETOPENREQ_EVENTID            = 0x3001,
80     WMIX_DSETCLOSE_EVENTID,
81     WMIX_DSETDATAREQ_EVENTID,
82     WMIX_GPIO_INTR_EVENTID,
83     WMIX_GPIO_DATA_EVENTID,
84     WMIX_GPIO_ACK_EVENTID,
85     WMIX_HB_CHALLENGE_RESP_EVENTID,
86     WMIX_DBGLOG_EVENTID,
87     WMIX_PROF_COUNT_EVENTID,
88 } WMIX_EVENT_ID;
89 
90 /*
91  * =============DataSet support=================
92  */
93 
94 /*
95  * WMIX_DSETOPENREQ_EVENTID
96  * DataSet Open Request Event
97  */
98 typedef PREPACK struct {
99     u32 dset_id;
100     u32 targ_dset_handle;  /* echo'ed, not used by Host, */
101     u32 targ_reply_fn;     /* echo'ed, not used by Host, */
102     u32 targ_reply_arg;    /* echo'ed, not used by Host, */
103 } POSTPACK WMIX_DSETOPENREQ_EVENT;
104 
105 /*
106  * WMIX_DSETCLOSE_EVENTID
107  * DataSet Close Event
108  */
109 typedef PREPACK struct {
110     u32 access_cookie;
111 } POSTPACK WMIX_DSETCLOSE_EVENT;
112 
113 /*
114  * WMIX_DSETDATAREQ_EVENTID
115  * DataSet Data Request Event
116  */
117 typedef PREPACK struct {
118     u32 access_cookie;
119     u32 offset;
120     u32 length;
121     u32 targ_buf;         /* echo'ed, not used by Host, */
122     u32 targ_reply_fn;    /* echo'ed, not used by Host, */
123     u32 targ_reply_arg;   /* echo'ed, not used by Host, */
124 } POSTPACK WMIX_DSETDATAREQ_EVENT;
125 
126 typedef PREPACK struct {
127     u32 status;
128     u32 targ_dset_handle;
129     u32 targ_reply_fn;
130     u32 targ_reply_arg;
131     u32 access_cookie;
132     u32 size;
133     u32 version;
134 } POSTPACK WMIX_DSETOPEN_REPLY_CMD;
135 
136 typedef PREPACK struct {
137     u32 status;
138     u32 targ_buf;
139     u32 targ_reply_fn;
140     u32 targ_reply_arg;
141     u32 length;
142     u8 buf[1];
143 } POSTPACK WMIX_DSETDATA_REPLY_CMD;
144 
145 
146 /*
147  * =============GPIO support=================
148  * All masks are 18-bit masks with bit N operating on GPIO pin N.
149  */
150 
151 #include "gpio.h"
152 
153 /*
154  * Set GPIO pin output state.
155  * In order for output to be driven, a pin must be enabled for output.
156  * This can be done during initialization through the GPIO Configuration
157  * DataSet, or during operation with the enable_mask.
158  *
159  * If a request is made to simultaneously set/clear or set/disable or
160  * clear/disable or disable/enable, results are undefined.
161  */
162 typedef PREPACK struct {
163     u32 set_mask;             /* pins to set */
164     u32 clear_mask;           /* pins to clear */
165     u32 enable_mask;          /* pins to enable for output */
166     u32 disable_mask;         /* pins to disable/tristate */
167 } POSTPACK WMIX_GPIO_OUTPUT_SET_CMD;
168 
169 /*
170  * Set a GPIO register.  For debug/exceptional cases.
171  * Values for gpioreg_id are GPIO_REGISTER_IDs, defined in a
172  * platform-dependent header.
173  */
174 typedef PREPACK struct {
175     u32 gpioreg_id;           /* GPIO register ID */
176     u32 value;                /* value to write */
177 } POSTPACK WMIX_GPIO_REGISTER_SET_CMD;
178 
179 /* Get a GPIO register.  For debug/exceptional cases. */
180 typedef PREPACK struct {
181     u32 gpioreg_id;           /* GPIO register to read */
182 } POSTPACK WMIX_GPIO_REGISTER_GET_CMD;
183 
184 /*
185  * Host acknowledges and re-arms GPIO interrupts.  A single
186  * message should be used to acknowledge all interrupts that
187  * were delivered in an earlier WMIX_GPIO_INTR_EVENT message.
188  */
189 typedef PREPACK struct {
190     u32 ack_mask;             /* interrupts to acknowledge */
191 } POSTPACK WMIX_GPIO_INTR_ACK_CMD;
192 
193 /*
194  * Target informs Host of GPIO interrupts that have occurred since the
195  * last WMIX_GIPO_INTR_ACK_CMD was received.  Additional information --
196  * the current GPIO input values is provided -- in order to support
197  * use of a GPIO interrupt as a Data Valid signal for other GPIO pins.
198  */
199 typedef PREPACK struct {
200     u32 intr_mask;            /* pending GPIO interrupts */
201     u32 input_values;         /* recent GPIO input values */
202 } POSTPACK WMIX_GPIO_INTR_EVENT;
203 
204 /*
205  * Target responds to Host's earlier WMIX_GPIO_INPUT_GET_CMDID request
206  * using a GPIO_DATA_EVENT with
207  *   value set to the mask of GPIO pin inputs and
208  *   reg_id set to GPIO_ID_NONE
209  *
210  *
211  * Target responds to Hosts's earlier WMIX_GPIO_REGISTER_GET_CMDID request
212  * using a GPIO_DATA_EVENT with
213  *   value set to the value of the requested register and
214  *   reg_id identifying the register (reflects the original request)
215  * NB: reg_id supports the future possibility of unsolicited
216  * WMIX_GPIO_DATA_EVENTs (for polling GPIO input), and it may
217  * simplify Host GPIO support.
218  */
219 typedef PREPACK struct {
220     u32 value;
221     u32 reg_id;
222 } POSTPACK WMIX_GPIO_DATA_EVENT;
223 
224 /*
225  * =============Error Detection support=================
226  */
227 
228 /*
229  * WMIX_HB_CHALLENGE_RESP_CMDID
230  * Heartbeat Challenge Response command
231  */
232 typedef PREPACK struct {
233     u32 cookie;
234     u32 source;
235 } POSTPACK WMIX_HB_CHALLENGE_RESP_CMD;
236 
237 /*
238  * WMIX_HB_CHALLENGE_RESP_EVENTID
239  * Heartbeat Challenge Response Event
240  */
241 #define WMIX_HB_CHALLENGE_RESP_EVENT WMIX_HB_CHALLENGE_RESP_CMD
242 
243 typedef PREPACK struct {
244     struct dbglog_config_s config;
245 } POSTPACK WMIX_DBGLOG_CFG_MODULE_CMD;
246 
247 /*
248  * =============Target Profiling support=================
249  */
250 
251 typedef PREPACK struct {
252     u32 period; /* Time (in 30.5us ticks) between samples */
253     u32 nbins;
254 } POSTPACK WMIX_PROF_CFG_CMD;
255 
256 typedef PREPACK struct {
257     u32 addr;
258 } POSTPACK WMIX_PROF_ADDR_SET_CMD;
259 
260 /*
261  * Target responds to Hosts's earlier WMIX_PROF_COUNT_GET_CMDID request
262  * using a WMIX_PROF_COUNT_EVENT with
263  *   addr set to the next address
264  *   count set to the corresponding count
265  */
266 typedef PREPACK struct {
267     u32 addr;
268     u32 count;
269 } POSTPACK WMIX_PROF_COUNT_EVENT;
270 
271 #ifndef ATH_TARGET
272 #include "athendpack.h"
273 #endif
274 
275 #ifdef __cplusplus
276 }
277 #endif
278 
279 #endif /* _WMIX_H_ */
280