goldfish: R.I.P.
[openwrt.git] / target / linux / s3c24xx / files-2.6.30 / drivers / ar6000 / include / bmi_msg.h
1 #ifndef __BMI_MSG_H__
2 #define __BMI_MSG_H__
3 /*
4  *
5  * Copyright (c) 2004-2007 Atheros Communications Inc.
6  * All rights reserved.
7  *
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License version 2 as
11  *  published by the Free Software Foundation;
12  *
13  *  Software distributed under the License is distributed on an "AS
14  *  IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15  *  implied. See the License for the specific language governing
16  *  rights and limitations under the License.
17  *
18  *
19  *
20  */
21
22 /*
23  * Bootloader Messaging Interface (BMI)
24  *
25  * BMI is a very simple messaging interface used during initialization
26  * to read memory, write memory, execute code, and to define an
27  * application entry PC.
28  *
29  * It is used to download an application to AR6K, to provide
30  * patches to code that is already resident on AR6K, and generally
31  * to examine and modify state.  The Host has an opportunity to use
32  * BMI only once during bootup.  Once the Host issues a BMI_DONE
33  * command, this opportunity ends.
34  *
35  * The Host writes BMI requests to mailbox0, and reads BMI responses
36  * from mailbox0.   BMI requests all begin with a command
37  * (see below for specific commands), and are followed by
38  * command-specific data.
39  *
40  * Flow control:
41  * The Host can only issue a command once the Target gives it a
42  * "BMI Command Credit", using AR6K Counter #4.  As soon as the
43  * Target has completed a command, it issues another BMI Command
44  * Credit (so the Host can issue the next command).
45  *
46  * BMI handles all required Target-side cache flushing.
47  */
48
49
50 /* Maximum data size used for BMI transfers */
51 #define BMI_DATASZ_MAX                     32
52
53 /* BMI Commands */
54
55 #define BMI_NO_COMMAND                      0
56
57 #define BMI_DONE                            1
58         /*
59          * Semantics: Host is done using BMI
60          * Request format:
61          *    A_UINT32      command (BMI_DONE)
62          * Response format: none
63          */
64
65 #define BMI_READ_MEMORY                     2
66         /*
67          * Semantics: Host reads AR6K memory
68          * Request format:
69          *    A_UINT32      command (BMI_READ_MEMORY)
70          *    A_UINT32      address
71          *    A_UINT32      length, at most BMI_DATASZ_MAX
72          * Response format:
73          *    A_UINT8       data[length]
74          */
75
76 #define BMI_WRITE_MEMORY                    3
77         /*
78          * Semantics: Host writes AR6K memory
79          * Request format:
80          *    A_UINT32       command (BMI_WRITE_MEMORY)
81          *    A_UINT32      address
82          *    A_UINT32      length, at most BMI_DATASZ_MAX
83          *    A_UINT8       data[length]
84          * Response format: none
85          */
86
87 #define BMI_EXECUTE                         4
88         /*
89          * Semantics: Causes AR6K to execute code
90          * Request format:
91          *    A_UINT32      command (BMI_EXECUTE)
92          *    A_UINT32      address
93          *    A_UINT32      parameter
94          * Response format:
95          *    A_UINT32      return value
96          */
97
98 #define BMI_SET_APP_START                   5
99         /*
100          * Semantics: Set Target application starting address
101          * Request format:
102          *    A_UINT32      command (BMI_SET_APP_START)
103          *    A_UINT32      address
104          * Response format: none
105          */
106
107 #define BMI_READ_SOC_REGISTER               6
108         /*
109          * Semantics: Read a 32-bit Target SOC register.
110          * Request format:
111          *    A_UINT32      command (BMI_READ_REGISTER)
112          *    A_UINT32      address
113          * Response format:
114          *    A_UINT32      value
115          */
116
117 #define BMI_WRITE_SOC_REGISTER              7
118         /*
119          * Semantics: Write a 32-bit Target SOC register.
120          * Request format:
121          *    A_UINT32      command (BMI_WRITE_REGISTER)
122          *    A_UINT32      address
123          *    A_UINT32      value
124          *
125          * Response format: none
126          */
127
128 #define BMI_GET_TARGET_ID                  8
129 #define BMI_GET_TARGET_INFO                8
130         /*
131          * Semantics: Fetch the 4-byte Target information
132          * Request format:
133          *    A_UINT32      command (BMI_GET_TARGET_ID/INFO)
134          * Response format1 (old firmware):
135          *    A_UINT32      TargetVersionID
136          * Response format2 (newer firmware):
137          *    A_UINT32      TARGET_VERSION_SENTINAL
138          *    struct bmi_target_info;
139          */
140
141 struct bmi_target_info {
142     A_UINT32 target_info_byte_count; /* size of this structure */
143     A_UINT32 target_ver;             /* Target Version ID */
144     A_UINT32 target_type;            /* Target type */
145 };
146 #define TARGET_VERSION_SENTINAL 0xffffffff
147 #define TARGET_TYPE_AR6001 1
148 #define TARGET_TYPE_AR6002 2
149
150
151 #define BMI_ROMPATCH_INSTALL               9
152         /*
153          * Semantics: Install a ROM Patch.
154          * Request format:
155          *    A_UINT32      command (BMI_ROMPATCH_INSTALL)
156          *    A_UINT32      Target ROM Address
157          *    A_UINT32      Target RAM Address
158          *    A_UINT32      Size, in bytes
159          *    A_UINT32      Activate? 1-->activate;
160          *                            0-->install but do not activate
161          * Response format:
162          *    A_UINT32      PatchID
163          */
164
165 #define BMI_ROMPATCH_UNINSTALL             10
166         /*
167          * Semantics: Uninstall a previously-installed ROM Patch,
168          * automatically deactivating, if necessary.
169          * Request format:
170          *    A_UINT32      command (BMI_ROMPATCH_UNINSTALL)
171          *    A_UINT32      PatchID
172          *
173          * Response format: none
174          */
175
176 #define BMI_ROMPATCH_ACTIVATE              11
177         /*
178          * Semantics: Activate a list of previously-installed ROM Patches.
179          * Request format:
180          *    A_UINT32      command (BMI_ROMPATCH_ACTIVATE)
181          *    A_UINT32      rompatch_count
182          *    A_UINT32      PatchID[rompatch_count]
183          *
184          * Response format: none
185          */
186
187 #define BMI_ROMPATCH_DEACTIVATE            12
188         /*
189          * Semantics: Deactivate a list of active ROM Patches.
190          * Request format:
191          *    A_UINT32      command (BMI_ROMPATCH_DEACTIVATE)
192          *    A_UINT32      rompatch_count
193          *    A_UINT32      PatchID[rompatch_count]
194          *
195          * Response format: none
196          */
197
198
199 #endif /* __BMI_MSG_H__ */