Merge branch 'sh-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal...
[pandora-kernel.git] / drivers / staging / ath6kl / include / common / bmi_msg.h
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
3 //
4 //
5 // Permission to use, copy, modify, and/or distribute this software for any
6 // purpose with or without fee is hereby granted, provided that the above
7 // copyright notice and this permission notice appear in all copies.
8 //
9 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 //
17 //
18 //
19 // Author(s): ="Atheros"
20 //------------------------------------------------------------------------------
21
22 #ifndef __BMI_MSG_H__
23 #define __BMI_MSG_H__
24
25 /*
26  * Bootloader Messaging Interface (BMI)
27  *
28  * BMI is a very simple messaging interface used during initialization
29  * to read memory, write memory, execute code, and to define an
30  * application entry PC.
31  *
32  * It is used to download an application to AR6K, to provide
33  * patches to code that is already resident on AR6K, and generally
34  * to examine and modify state.  The Host has an opportunity to use
35  * BMI only once during bootup.  Once the Host issues a BMI_DONE
36  * command, this opportunity ends.
37  *
38  * The Host writes BMI requests to mailbox0, and reads BMI responses
39  * from mailbox0.   BMI requests all begin with a command
40  * (see below for specific commands), and are followed by
41  * command-specific data.
42  *
43  * Flow control:
44  * The Host can only issue a command once the Target gives it a
45  * "BMI Command Credit", using AR6K Counter #4.  As soon as the
46  * Target has completed a command, it issues another BMI Command
47  * Credit (so the Host can issue the next command).
48  *
49  * BMI handles all required Target-side cache flushing.
50  */
51
52
53 /* Maximum data size used for BMI transfers */
54 #define BMI_DATASZ_MAX                      256
55
56 /* BMI Commands */
57
58 #define BMI_NO_COMMAND                      0
59
60 #define BMI_DONE                            1
61         /*
62          * Semantics: Host is done using BMI
63          * Request format:
64          *    u32 command (BMI_DONE)
65          * Response format: none
66          */
67
68 #define BMI_READ_MEMORY                     2
69         /*
70          * Semantics: Host reads AR6K memory
71          * Request format:
72          *    u32 command (BMI_READ_MEMORY)
73          *    u32 address
74          *    u32 length, at most BMI_DATASZ_MAX
75          * Response format:
76          *    u8 data[length]
77          */
78
79 #define BMI_WRITE_MEMORY                    3
80         /*
81          * Semantics: Host writes AR6K memory
82          * Request format:
83          *    u32 command (BMI_WRITE_MEMORY)
84          *    u32 address
85          *    u32 length, at most BMI_DATASZ_MAX
86          *    u8 data[length]
87          * Response format: none
88          */
89
90 #define BMI_EXECUTE                         4
91         /*
92          * Semantics: Causes AR6K to execute code
93          * Request format:
94          *    u32 command (BMI_EXECUTE)
95          *    u32 address
96          *    u32 parameter
97          * Response format:
98          *    u32 return value
99          */
100
101 #define BMI_SET_APP_START                   5
102         /*
103          * Semantics: Set Target application starting address
104          * Request format:
105          *    u32 command (BMI_SET_APP_START)
106          *    u32 address
107          * Response format: none
108          */
109
110 #define BMI_READ_SOC_REGISTER               6
111         /*
112          * Semantics: Read a 32-bit Target SOC register.
113          * Request format:
114          *    u32 command (BMI_READ_REGISTER)
115          *    u32 address
116          * Response format: 
117          *    u32 value
118          */
119
120 #define BMI_WRITE_SOC_REGISTER              7
121         /*
122          * Semantics: Write a 32-bit Target SOC register.
123          * Request format:
124          *    u32 command (BMI_WRITE_REGISTER)
125          *    u32 address
126          *    u32 value
127          *
128          * Response format: none
129          */
130
131 #define BMI_GET_TARGET_ID                  8
132 #define BMI_GET_TARGET_INFO                8
133         /*
134          * Semantics: Fetch the 4-byte Target information
135          * Request format:
136          *    u32 command (BMI_GET_TARGET_ID/INFO)
137          * Response format1 (old firmware):
138          *    u32 TargetVersionID
139          * Response format2 (newer firmware):
140          *    u32 TARGET_VERSION_SENTINAL
141          *    struct bmi_target_info;
142          */
143
144 PREPACK struct bmi_target_info {
145     u32 target_info_byte_count; /* size of this structure */
146     u32 target_ver;             /* Target Version ID */
147     u32 target_type;            /* Target type */
148 } POSTPACK;
149 #define TARGET_VERSION_SENTINAL 0xffffffff
150 #define TARGET_TYPE_AR6001 1
151 #define TARGET_TYPE_AR6002 2
152 #define TARGET_TYPE_AR6003 3
153
154
155 #define BMI_ROMPATCH_INSTALL               9
156         /*
157          * Semantics: Install a ROM Patch.
158          * Request format:
159          *    u32 command (BMI_ROMPATCH_INSTALL)
160          *    u32 Target ROM Address
161          *    u32 Target RAM Address or Value (depending on Target Type)
162          *    u32 Size, in bytes
163          *    u32 Activate? 1-->activate;
164          *                            0-->install but do not activate
165          * Response format:
166          *    u32 PatchID
167          */
168
169 #define BMI_ROMPATCH_UNINSTALL             10
170         /*
171          * Semantics: Uninstall a previously-installed ROM Patch,
172          * automatically deactivating, if necessary.
173          * Request format:
174          *    u32 command (BMI_ROMPATCH_UNINSTALL)
175          *    u32 PatchID
176          *
177          * Response format: none
178          */
179
180 #define BMI_ROMPATCH_ACTIVATE              11
181         /*
182          * Semantics: Activate a list of previously-installed ROM Patches.
183          * Request format:
184          *    u32 command (BMI_ROMPATCH_ACTIVATE)
185          *    u32 rompatch_count
186          *    u32 PatchID[rompatch_count]
187          *
188          * Response format: none
189          */
190
191 #define BMI_ROMPATCH_DEACTIVATE            12
192         /*
193          * Semantics: Deactivate a list of active ROM Patches.
194          * Request format:
195          *    u32 command (BMI_ROMPATCH_DEACTIVATE)
196          *    u32 rompatch_count
197          *    u32 PatchID[rompatch_count]
198          *
199          * Response format: none
200          */
201
202
203 #define BMI_LZ_STREAM_START                13
204         /*
205          * Semantics: Begin an LZ-compressed stream of input
206          * which is to be uncompressed by the Target to an
207          * output buffer at address.  The output buffer must
208          * be sufficiently large to hold the uncompressed
209          * output from the compressed input stream.  This BMI
210          * command should be followed by a series of 1 or more
211          * BMI_LZ_DATA commands.
212          *    u32 command (BMI_LZ_STREAM_START)
213          *    u32 address
214          * Note: Not supported on all versions of ROM firmware.
215          */
216
217 #define BMI_LZ_DATA                        14
218         /*
219          * Semantics: Host writes AR6K memory with LZ-compressed
220          * data which is uncompressed by the Target.  This command
221          * must be preceded by a BMI_LZ_STREAM_START command. A series
222          * of BMI_LZ_DATA commands are considered part of a single
223          * input stream until another BMI_LZ_STREAM_START is issued.
224          * Request format:
225          *    u32 command (BMI_LZ_DATA)
226          *    u32 length (of compressed data),
227          *                  at most BMI_DATASZ_MAX
228          *    u8 CompressedData[length]
229          * Response format: none
230          * Note: Not supported on all versions of ROM firmware.
231          */
232
233 #endif /* __BMI_MSG_H__ */