1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
|
/* $OpenBSD: bcm2835_vcprop.h,v 1.1 2020/04/19 14:51:52 tobhe Exp $ */
/*
* Copyright (c) 2020 Tobias Heider <tobhe@openbsd.org>
* Copyright (c) 2019 Neil Ashford <ashfordneil0@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Mailbox property interface
*/
#ifndef BCM2835_VCPROP_H
#define BCM2835_VCPROP_H
struct vcprop_tag {
uint32_t vpt_tag;
#define VCPROPTAG_NULL 0x00000000
#define VCPROPTAG_GET_FIRMWAREREV 0x00000001
#define VCPROPTAG_GET_BOARDMODEL 0x00010001
#define VCPROPTAG_GET_BOARDREVISION 0x00010002
#define VCPROPTAG_GET_MACADDRESS 0x00010003
#define VCPROPTAG_GET_BOARDSERIAL 0x00010004
#define VCPROPTAG_GET_ARMMEMORY 0x00010005
#define VCPROPTAG_GET_VCMEMORY 0x00010006
#define VCPROPTAG_GET_CLOCKS 0x00010007
#define VCPROPTAG_GET_POWERSTATE 0x00020001
#define VCPROPTAG_GET_POWERTIMING 0x00020002
#define VCPROPTAG_SET_POWERSTATE 0x00028001
#define VCPROPTAG_GET_CLOCKSTATE 0x00030001
#define VCPROPTAG_SET_CLOCKSTATE 0x00038001
#define VCPROPTAG_GET_CLOCKRATE 0x00030002
#define VCPROPTAG_SET_CLOCKRATE 0x00038002
#define VCPROPTAG_GET_MIN_CLOCKRATE 0x00030007
#define VCPROPTAG_GET_MAX_CLOCKRATE 0x00030004
#define VCPROPTAG_GET_TURBO 0x00030009
#define VCPROPTAG_SET_TURBO 0x00038009
#define VCPROPTAG_GET_VOLTAGE 0x00030003
#define VCPROPTAG_SET_VOLTAGE 0x00038003
#define VCPROPTAG_GET_MIN_VOLTAGE 0x00030008
#define VCPROPTAG_GET_MAX_VOLTAGE 0x00030005
#define VCPROPTAG_GET_TEMPERATURE 0x00030006
#define VCPROPTAG_GET_MAX_TEMPERATURE 0x0003000a
#define VCPROPTAG_GET_CMDLINE 0x00050001
#define VCPROPTAG_GET_DMACHAN 0x00060001
#define VCPROPTAG_ALLOCATE_BUFFER 0x00040001
#define VCPROPTAG_BLANK_SCREEN 0x00040002
#define VCPROPTAG_GET_FB_RES 0x00040003
#define VCPROPTAG_SET_FB_RES 0x00048003
#define VCPROPTAG_GET_FB_VRES 0x00040004
#define VCPROPTAG_SET_FB_VRES 0x00048004
#define VCPROPTAG_GET_FB_DEPTH 0x00040005
#define VCPROPTAG_SET_FB_DEPTH 0x00048005
#define VCPROPTAG_GET_FB_PIXEL_ORDER 0x00040006
#define VCPROPTAG_SET_FB_PIXEL_ORDER 0x00048006
#define VCPROPTAG_GET_FB_ALPHA_MODE 0x00040007
#define VCPROPTAG_SET_FB_ALPHA_MODE 0x00048007
#define VCPROPTAG_GET_FB_PITCH 0x00040008
#define VCPROPTAG_GET_EDID_BLOCK 0x00030020
#define VCPROPTAG_ALLOCMEM 0x0003000c
#define VCPROPTAG_LOCKMEM 0x0003000d
#define VCPROPTAG_UNLOCKMEM 0x0003000e
#define VCPROPTAG_RELEASEMEM 0x0003000f
#define VCPROPTAG_EXECUTE_CODE 0x00030010
#define VCPROPTAG_EXECUTE_QPU 0x00030011
#define VCPROPTAG_SET_ENABLE_QPU 0x00030012
#define VCPROPTAG_GET_DISPMANX_HANDLE 0x00030014
#define VCPROPTAG_SET_CURSOR_INFO 0x00008010
#define VCPROPTAG_SET_CURSOR_STATE 0x00008011
uint32_t vpt_len;
uint32_t vpt_rcode;
#define VCPROPTAG_REQUEST (0U << 31)
#define VCPROPTAG_RESPONSE (1U << 31)
} __packed;
#define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
struct vcprop_memory {
uint32_t base;
uint32_t size;
};
#define VCPROP_MAXMEMBLOCKS 4
struct vcprop_tag_memory {
struct vcprop_tag tag;
struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
};
struct vcprop_tag_fwrev {
struct vcprop_tag tag;
uint32_t rev;
};
struct vcprop_tag_boardmodel {
struct vcprop_tag tag;
uint32_t model;
};
struct vcprop_tag_boardrev {
struct vcprop_tag tag;
uint32_t rev;
};
#define VCPROP_REV_PCBREV 15
#define VCPROP_REV_MODEL (255 << 4)
#define RPI_MODEL_A 0
#define RPI_MODEL_B 1
#define RPI_MODEL_A_PLUS 2
#define RPI_MODEL_B_PLUS 3
#define RPI_MODEL_B_PI2 4
#define RPI_MODEL_ALPHA 5
#define RPI_MODEL_COMPUTE 6
#define RPI_MODEL_ZERO 7
#define RPI_MODEL_B_PI3 8
#define RPI_MODEL_COMPUTE_PI3 9
#define RPI_MODEL_ZERO_W 10
#define VCPROP_REV_PROCESSOR (15 << 12)
#define RPI_PROCESSOR_BCM2835 0
#define RPI_PROCESSOR_BCM2836 1
#define RPI_PROCESSOR_BCM2837 2
#define VCPROP_REV_MANUF (15 << 16)
#define VCPROP_REV_MEMSIZE (7 << 20)
#define VCPROP_REV_ENCFLAG (1 << 23)
#define VCPROP_REV_WARRANTY (3 << 24)
struct vcprop_tag_macaddr {
struct vcprop_tag tag;
uint64_t addr;
} __packed;
struct vcprop_tag_boardserial {
struct vcprop_tag tag;
uint64_t sn;
} __packed;
#define VCPROP_CLK_EMMC 1
#define VCPROP_CLK_UART 2
#define VCPROP_CLK_ARM 3
#define VCPROP_CLK_CORE 4
#define VCPROP_CLK_V3D 5
#define VCPROP_CLK_H264 6
#define VCPROP_CLK_ISP 7
#define VCPROP_CLK_SDRAM 8
#define VCPROP_CLK_PIXEL 9
#define VCPROP_CLK_PWM 10
#define VCPROP_CLK_EMMC2 12
struct vcprop_clock {
uint32_t pclk;
uint32_t cclk;
};
#define VCPROP_MAXCLOCKS 16
struct vcprop_tag_clock {
struct vcprop_tag tag;
struct vcprop_clock clk[VCPROP_MAXCLOCKS];
};
#ifndef VCPROP_MAXCMDLINE
#define VCPROP_MAXCMDLINE 1024
#endif
struct vcprop_tag_cmdline {
struct vcprop_tag tag;
uint8_t cmdline[VCPROP_MAXCMDLINE];
};
struct vcprop_tag_dmachan {
struct vcprop_tag tag;
uint32_t mask;
};
struct vcprop_tag_clockstate {
struct vcprop_tag tag;
uint32_t id;
uint32_t state;
};
struct vcprop_tag_clockrate {
struct vcprop_tag tag;
uint32_t id;
uint32_t rate;
uint32_t noturbo;
} __packed;
#define VCPROP_VOLTAGE_CORE 1
#define VCPROP_VOLTAGE_SDRAM_C 2
#define VCPROP_VOLTAGE_SDRAM_P 3
#define VCPROP_VOLTAGE_SDRAM_I 4
struct vcprop_tag_voltage {
struct vcprop_tag tag;
uint32_t id;
uint32_t value;
};
#define VCPROP_TEMP_SOC 0
struct vcprop_tag_temperature {
struct vcprop_tag tag;
uint32_t id;
uint32_t value;
};
#define VCPROP_POWER_SDCARD 0
#define VCPROP_POWER_UART0 1
#define VCPROP_POWER_UART1 2
#define VCPROP_POWER_USB 3
#define VCPROP_POWER_I2C0 4
#define VCPROP_POWER_I2C1 5
#define VCPROP_POWER_I2C2 6
#define VCPROP_POWER_SPI 7
#define VCPROP_POWER_CCP2TX 8
struct vcprop_tag_powertiming {
struct vcprop_tag tag;
uint32_t id;
uint32_t waitusec;
};
struct vcprop_tag_powerstate {
struct vcprop_tag tag;
uint32_t id;
uint32_t state;
};
struct vcprop_tag_allocbuf {
struct vcprop_tag tag;
uint32_t address; /* alignment for request */
uint32_t size;
};
#define VCPROP_BLANK_OFF 0
#define VCPROP_BLANK_ON 1
struct vcprop_tag_blankscreen {
struct vcprop_tag tag;
uint32_t state;
};
struct vcprop_tag_fbres {
struct vcprop_tag tag;
uint32_t width;
uint32_t height;
};
struct vcprop_tag_fbdepth {
struct vcprop_tag tag;
uint32_t bpp;
};
#define VCPROP_PIXEL_BGR 0
#define VCPROP_PIXEL_RGB 1
struct vcprop_tag_fbpixelorder {
struct vcprop_tag tag;
uint32_t state;
};
struct vcprop_tag_fbpitch {
struct vcprop_tag tag;
uint32_t linebytes;
};
#define VCPROP_ALPHA_ENABLED 0
#define VCPROP_ALPHA_REVERSED 1
#define VCPROP_ALPHA_IGNORED 2
struct vcprop_tag_fbalpha {
struct vcprop_tag tag;
uint32_t state;
};
struct vcprop_tag_edidblock {
struct vcprop_tag tag;
uint32_t blockno;
uint32_t status;
uint8_t data[128];
};
struct vcprop_tag_cursorinfo {
struct vcprop_tag tag;
uint32_t width;
uint32_t height;
uint32_t format;
uint32_t pixels; /* bus address in VC memory */
uint32_t hotspot_x;
uint32_t hotspot_y;
};
struct vcprop_tag_cursorstate {
struct vcprop_tag tag;
uint32_t enable; /* 1 - visible */
uint32_t x;
uint32_t y;
uint32_t flags; /* 0 - display coord. 1 - fb coord. */
};
struct vcprop_tag_allocmem {
struct vcprop_tag tag;
uint32_t size; /* handle returned here */
uint32_t align;
uint32_t flags;
/*
* flag definitions from
* https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
*/
#define MEM_FLAG_DISCARDABLE (1 << 0) /* can be resized to 0 at any time. Use for cached data */
#define MEM_FLAG_NORMAL (0 << 2) /* normal allocating alias. Don't use from ARM */
#define MEM_FLAG_DIRECT (1 << 2) /* 0xC alias uncached */
#define MEM_FLAG_COHERENT (2 << 2) /* 0x8 alias. Non-allocating in L2 but coherent */
#define MEM_FLAG_L1_NONALLOCATING (MEM_FLAG_DIRECT | MEM_FLAG_COHERENT) /* Allocating in L2 */
#define MEM_FLAG_ZERO (1 << 4) /* initialise buffer to all zeros */
#define MEM_FLAG_NO_INIT (1 << 5) /* don't initialise (default is initialise to all ones */
#define MEM_FLAG_HINT_PERMALOCK (1 << 6) /* Likely to be locked for long periods of time. */
};
/* also for unlock and release */
struct vcprop_tag_lockmem {
struct vcprop_tag tag;
uint32_t handle; /* bus address returned here */
};
struct vcprop_buffer_hdr {
uint32_t vpb_len;
uint32_t vpb_rcode;
#define VCPROP_PROCESS_REQUEST 0
#define VCPROP_REQ_SUCCESS (1U << 31)
#define VCPROP_REQ_EPARSE (1U << 0)
} __packed;
static inline bool
vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
{
return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
}
static inline bool
vcprop_tag_success_p(struct vcprop_tag *vpbt)
{
return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
}
static inline size_t
vcprop_tag_resplen(struct vcprop_tag *vpbt)
{
return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
}
#define BCMMBOX_CHANPM 0
#define BCMMBOX_CHANFB 1 /* will be deprecated */
#define BCMMBOX_CHANVUART 2
#define BCMMBOX_CHANVCHIQ 3
#define BCMMBOX_CHANLEDS 4
#define BCMMBOX_CHANBUTTONS 5
#define BCMMBOX_CHANTOUCHSCR 6
#define BCMMBOX_CHANARM2VC 8
#define BCMMBOX_CHANVC2ARM 9
#endif /* BCM2835_VCPROP_H */
|