vcprop.h revision 1.7 1 /* $NetBSD: vcprop.h,v 1.7 2013/01/08 15:07:32 jmcneill Exp $ */
2
3 /*-
4 * Copyright (c) 2012 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Nick Hudson
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * Mailbox property interface
34 */
35
36 #ifndef _EVBARM_RPI_VCPROP_H_
37 #define _EVBARM_RPI_VCPROP_H_
38
39 struct vcprop_tag {
40 uint32_t vpt_tag;
41 #define VCPROPTAG_NULL 0x00000000
42 #define VCPROPTAG_GET_FIRMWAREREV 0x00000001
43 #define VCPROPTAG_GET_BOARDMODEL 0x00010001
44 #define VCPROPTAG_GET_BOARDREVISION 0x00010002
45 #define VCPROPTAG_GET_MACADDRESS 0x00010003
46 #define VCPROPTAG_GET_BOARDSERIAL 0x00010004
47 #define VCPROPTAG_GET_ARMMEMORY 0x00010005
48 #define VCPROPTAG_GET_VCMEMORY 0x00010006
49 #define VCPROPTAG_GET_CLOCKS 0x00010007
50
51 #define VCPROPTAG_GET_POWERSTATE 0x00020001
52 #define VCPROPTAG_GET_POWERTIMING 0x00020002
53 #define VCPROPTAG_SET_POWERSTATE 0x00028001
54
55 #define VCPROPTAG_GET_CLOCKSTATE 0x00030001
56 #define VCPROPTAG_SET_CLOCKSTATE 0x00038001
57 #define VCPROPTAG_GET_CLOCKRATE 0x00030002
58 #define VCPROPTAG_SET_CLOCKRATE 0x00038002
59 #define VCPROPTAG_GET_MIN_CLOCKRATE 0x00030007
60 #define VCPROPTAG_GET_MAX_CLOCKRATE 0x00030004
61
62 #define VCPROPTAG_GET_VOLTAGE 0x00030003
63 #define VCPROPTAG_SET_VOLTAGE 0x00038003
64 #define VCPROPTAG_GET_MIN_VOLTAGE 0x00030008
65 #define VCPROPTAG_GET_MAX_VOLTAGE 0x00030005
66
67 #define VCPROPTAG_GET_TEMPERATURE 0x00030006
68 #define VCPROPTAG_GET_MAX_TEMPERATURE 0x0003000a
69
70 #define VCPROPTAG_GET_CMDLINE 0x00050001
71 #define VCPROPTAG_GET_DMACHAN 0x00060001
72
73 #define VCPROPTAG_ALLOCATE_BUFFER 0x00040001
74 #define VCPROPTAG_BLANK_SCREEN 0x00040002
75 #define VCPROPTAG_GET_FB_RES 0x00040003
76 #define VCPROPTAG_SET_FB_RES 0x00048003
77 #define VCPROPTAG_GET_FB_VRES 0x00040004
78 #define VCPROPTAG_SET_FB_VRES 0x00048004
79 #define VCPROPTAG_GET_FB_DEPTH 0x00040005
80 #define VCPROPTAG_SET_FB_DEPTH 0x00048005
81 #define VCPROPTAG_GET_FB_PIXEL_ORDER 0x00040006
82 #define VCPROPTAG_SET_FB_PIXEL_ORDER 0x00048006
83 #define VCPROPTAG_GET_FB_ALPHA_MODE 0x00040007
84 #define VCPROPTAG_SET_FB_ALPHA_MODE 0x00048007
85 #define VCPROPTAG_GET_FB_PITCH 0x00040008
86
87 #define VCPROPTAG_GET_EDID_BLOCK 0x00030020
88
89
90 uint32_t vpt_len;
91 uint32_t vpt_rcode;
92 #define VCPROPTAG_REQUEST (0U << 31)
93 #define VCPROPTAG_RESPONSE (1U << 31)
94
95 };
96
97 #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
98
99 struct vcprop_memory {
100 uint32_t base;
101 uint32_t size;
102 };
103
104 #define VCPROP_MAXMEMBLOCKS 4
105 struct vcprop_tag_memory {
106 struct vcprop_tag tag;
107 struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
108 };
109
110 struct vcprop_tag_fwrev {
111 struct vcprop_tag tag;
112 uint32_t rev;
113 };
114
115 struct vcprop_tag_boardmodel {
116 struct vcprop_tag tag;
117 uint32_t model;
118 } ;
119
120 struct vcprop_tag_boardrev {
121 struct vcprop_tag tag;
122 uint32_t rev;
123 } ;
124
125 struct vcprop_tag_macaddr {
126 struct vcprop_tag tag;
127 uint64_t addr;
128 };
129
130 struct vcprop_tag_boardserial {
131 struct vcprop_tag tag;
132 uint64_t sn;
133 };
134
135 #define VCPROP_CLK_EMMC 1
136 #define VCPROP_CLK_UART 2
137 #define VCPROP_CLK_ARM 3
138 #define VCPROP_CLK_CORE 4
139 #define VCPROP_CLK_V3D 5
140 #define VCPROP_CLK_H264 6
141 #define VCPROP_CLK_ISP 7
142 #define VCPROP_CLK_SDRAM 8
143 #define VCPROP_CLK_PIXEL 9
144 #define VCPROP_CLK_PWM 10
145
146 struct vcprop_clock {
147 uint32_t pclk;
148 uint32_t cclk;
149 };
150
151 #define VCPROP_MAXCLOCKS 16
152 struct vcprop_tag_clock {
153 struct vcprop_tag tag;
154 struct vcprop_clock clk[VCPROP_MAXCLOCKS];
155 };
156
157 #define VCPROP_MAXCMDLINE 256
158 struct vcprop_tag_cmdline {
159 struct vcprop_tag tag;
160 uint8_t cmdline[VCPROP_MAXCMDLINE];
161 };
162
163 struct vcprop_tag_dmachan {
164 struct vcprop_tag tag;
165 uint32_t mask;
166 };
167
168 struct vcprop_tag_clockstate {
169 struct vcprop_tag tag;
170 uint32_t id;
171 uint32_t state;
172 };
173
174 struct vcprop_tag_clockrate {
175 struct vcprop_tag tag;
176 uint32_t id;
177 uint32_t rate;
178 };
179
180 #define VCPROP_VOLTAGE_CORE 1
181 #define VCPROP_VOLTAGE_SDRAM_C 2
182 #define VCPROP_VOLTAGE_SDRAM_P 3
183 #define VCPROP_VOLTAGE_SDRAM_I 4
184
185 struct vcprop_tag_voltage {
186 struct vcprop_tag tag;
187 uint32_t id;
188 uint32_t value;
189 };
190
191 #define VCPROP_TEMP_SOC 0
192
193 struct vcprop_tag_temperature {
194 struct vcprop_tag tag;
195 uint32_t id;
196 uint32_t value;
197 };
198
199 #define VCPROP_POWER_SDCARD 0
200 #define VCPROP_POWER_UART0 1
201 #define VCPROP_POWER_UART1 2
202 #define VCPROP_POWER_USB 3
203 #define VCPROP_POWER_I2C0 4
204 #define VCPROP_POWER_I2C1 5
205 #define VCPROP_POWER_I2C2 6
206 #define VCPROP_POWER_SPI 7
207 #define VCPROP_POWER_CCP2TX 8
208
209 struct vcprop_tag_powertiming {
210 struct vcprop_tag tag;
211 uint32_t id;
212 uint32_t waitusec;
213 };
214
215 struct vcprop_tag_powerstate {
216 struct vcprop_tag tag;
217 uint32_t id;
218 uint32_t state;
219 };
220
221 struct vcprop_tag_allocbuf {
222 struct vcprop_tag tag;
223 uint32_t address; /* alignment for request */
224 uint32_t size;
225 };
226
227 #define VCPROP_BLANK_OFF 0
228 #define VCPROP_BLANK_ON 1
229
230 struct vcprop_tag_blankscreen {
231 struct vcprop_tag tag;
232 uint32_t state;
233 };
234
235 struct vcprop_tag_fbres {
236 struct vcprop_tag tag;
237 uint32_t width;
238 uint32_t height;
239 };
240
241 struct vcprop_tag_fbdepth {
242 struct vcprop_tag tag;
243 uint32_t bpp;
244 };
245
246 #define VCPROP_PIXEL_BGR 0
247 #define VCPROP_PIXEL_RGB 1
248
249 struct vcprop_tag_fbpixelorder {
250 struct vcprop_tag tag;
251 uint32_t state;
252 };
253
254 struct vcprop_tag_fbpitch {
255 struct vcprop_tag tag;
256 uint32_t linebytes;
257 };
258
259 #define VCPROP_ALPHA_ENABLED 0
260 #define VCPROP_ALPHA_REVERSED 1
261 #define VCPROP_ALPHA_IGNORED 2
262
263 struct vcprop_tag_fbalpha {
264 struct vcprop_tag tag;
265 uint32_t state;
266 };
267
268 struct vcprop_tag_edidblock {
269 struct vcprop_tag tag;
270 uint32_t blockno;
271 uint32_t status;
272 uint8_t data[128];
273 };
274
275 struct vcprop_buffer_hdr {
276 uint32_t vpb_len;
277 uint32_t vpb_rcode;
278 #define VCPROP_PROCESS_REQUEST 0
279 #define VCPROP_REQ_SUCCESS (1U << 31)
280 #define VCPROP_REQ_EPARSE (1U << 0)
281 };
282
283 static inline bool
284 vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
285 {
286
287 return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
288 }
289
290 static inline bool
291 vcprop_tag_success_p(struct vcprop_tag *vpbt)
292 {
293
294 return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
295 }
296
297 static inline size_t
298 vcprop_tag_resplen(struct vcprop_tag *vpbt)
299 {
300
301 return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
302 }
303
304 #endif /* _EVBARM_RPI_VCPROP_H_ */
305