2 * Copyright (C) 2013-2014 Daisuke Aoyama <aoyama@peach.ne.jp>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #ifndef _BCM2835_MBOX_PROP_H_
28 #define _BCM2835_MBOX_PROP_H_
30 #include <sys/types.h>
33 * Mailbox property interface:
34 * https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
36 #define BCM2835_MBOX_CODE_REQ 0
37 #define BCM2835_MBOX_CODE_RESP_SUCCESS 0x80000000
38 #define BCM2835_MBOX_CODE_RESP_ERROR 0x80000001
39 #define BCM2835_MBOX_TAG_VAL_LEN_RESPONSE 0x80000000
41 struct bcm2835_mbox_hdr
{
46 struct bcm2835_mbox_tag_hdr
{
48 uint32_t val_buf_size
;
52 #define BCM2835_MBOX_INIT_TAG(tag_, tagid_) do { \
53 (tag_)->tag_hdr.tag = BCM2835_MBOX_TAG_##tagid_; \
54 (tag_)->tag_hdr.val_buf_size = sizeof((tag_)->body); \
55 (tag_)->tag_hdr.val_len = sizeof((tag_)->body.req); \
58 #define BCM2835_MBOX_TAG_FIRMWARE_REVISION 0x00000001
60 #define BCM2835_MBOX_POWER_ID_EMMC 0x00000000
61 #define BCM2835_MBOX_POWER_ID_UART0 0x00000001
62 #define BCM2835_MBOX_POWER_ID_UART1 0x00000002
63 #define BCM2835_MBOX_POWER_ID_USB_HCD 0x00000003
64 #define BCM2835_MBOX_POWER_ID_I2C0 0x00000004
65 #define BCM2835_MBOX_POWER_ID_I2C1 0x00000005
66 #define BCM2835_MBOX_POWER_ID_I2C2 0x00000006
67 #define BCM2835_MBOX_POWER_ID_SPI 0x00000007
68 #define BCM2835_MBOX_POWER_ID_CCP2TX 0x00000008
70 #define BCM2835_MBOX_POWER_ON (1 << 0)
71 #define BCM2835_MBOX_POWER_WAIT (1 << 1)
73 #define BCM2835_MBOX_TAG_GET_POWER_STATE 0x00020001
74 #define BCM2835_MBOX_TAG_SET_POWER_STATE 0x00028001
76 struct msg_get_power_state
{
77 struct bcm2835_mbox_hdr hdr
;
78 struct bcm2835_mbox_tag_hdr tag_hdr
;
91 struct msg_set_power_state
{
92 struct bcm2835_mbox_hdr hdr
;
93 struct bcm2835_mbox_tag_hdr tag_hdr
;
107 /* Sets the power state for a given device */
108 int bcm2835_mbox_set_power_state(uint32_t, boolean_t
);
110 #define BCM2835_MBOX_TAG_NOTIFY_XHCI_RESET 0x00030058
112 struct msg_notify_xhci_reset
{
113 struct bcm2835_mbox_hdr hdr
;
114 struct bcm2835_mbox_tag_hdr tag_hdr
;
117 uint32_t pci_device_addr
;
125 /* Prompts the VideoCore processor to reload the xhci firmware. */
126 int bcm2835_mbox_notify_xhci_reset(uint32_t);
128 #define BCM2835_MBOX_CLOCK_ID_EMMC 0x00000001
129 #define BCM2838_MBOX_CLOCK_ID_EMMC2 0x0000000c
131 #define BCM2835_MBOX_TAG_GET_CLOCK_RATE 0x00030002
133 struct msg_get_clock_rate
{
134 struct bcm2835_mbox_hdr hdr
;
135 struct bcm2835_mbox_tag_hdr tag_hdr
;
148 int bcm2835_mbox_get_clock_rate(uint32_t, uint32_t *);
150 #define BCM2835_MBOX_TURBO_ON 1
151 #define BCM2835_MBOX_TURBO_OFF 0
153 #define BCM2835_MBOX_TAG_GET_TURBO 0x00030009
154 #define BCM2835_MBOX_TAG_SET_TURBO 0x00038009
156 struct msg_get_turbo
{
157 struct bcm2835_mbox_hdr hdr
;
158 struct bcm2835_mbox_tag_hdr tag_hdr
;
171 struct msg_set_turbo
{
172 struct bcm2835_mbox_hdr hdr
;
173 struct bcm2835_mbox_tag_hdr tag_hdr
;
187 #define BCM2835_MBOX_VOLTAGE_ID_CORE 0x00000001
188 #define BCM2835_MBOX_VOLTAGE_ID_SDRAM_C 0x00000002
189 #define BCM2835_MBOX_VOLTAGE_ID_SDRAM_P 0x00000003
190 #define BCM2835_MBOX_VOLTAGE_ID_SDRAM_I 0x00000004
192 #define BCM2835_MBOX_TAG_GET_VOLTAGE 0x00030003
193 #define BCM2835_MBOX_TAG_SET_VOLTAGE 0x00038003
194 #define BCM2835_MBOX_TAG_GET_MAX_VOLTAGE 0x00030005
195 #define BCM2835_MBOX_TAG_GET_MIN_VOLTAGE 0x00030008
197 struct msg_get_voltage
{
198 struct bcm2835_mbox_hdr hdr
;
199 struct bcm2835_mbox_tag_hdr tag_hdr
;
212 struct msg_set_voltage
{
213 struct bcm2835_mbox_hdr hdr
;
214 struct bcm2835_mbox_tag_hdr tag_hdr
;
228 struct msg_get_max_voltage
{
229 struct bcm2835_mbox_hdr hdr
;
230 struct bcm2835_mbox_tag_hdr tag_hdr
;
243 struct msg_get_min_voltage
{
244 struct bcm2835_mbox_hdr hdr
;
245 struct bcm2835_mbox_tag_hdr tag_hdr
;
258 #define BCM2835_MBOX_TAG_GET_TEMPERATURE 0x00030006
259 #define BCM2835_MBOX_TAG_GET_MAX_TEMPERATURE 0x0003000a
261 struct msg_get_temperature
{
262 struct bcm2835_mbox_hdr hdr
;
263 struct bcm2835_mbox_tag_hdr tag_hdr
;
266 uint32_t temperature_id
;
269 uint32_t temperature_id
;
276 struct msg_get_max_temperature
{
277 struct bcm2835_mbox_hdr hdr
;
278 struct bcm2835_mbox_tag_hdr tag_hdr
;
281 uint32_t temperature_id
;
284 uint32_t temperature_id
;
291 #define BCM2835_MBOX_TAG_GET_PHYSICAL_W_H 0x00040003
292 #define BCM2835_MBOX_TAG_SET_PHYSICAL_W_H 0x00048003
293 #define BCM2835_MBOX_TAG_GET_VIRTUAL_W_H 0x00040004
294 #define BCM2835_MBOX_TAG_SET_VIRTUAL_W_H 0x00048004
296 struct bcm2835_mbox_tag_fb_w_h
{
297 struct bcm2835_mbox_tag_hdr tag_hdr
;
310 #define BCM2835_MBOX_TAG_GET_DEPTH 0x00040005
311 #define BCM2835_MBOX_TAG_SET_DEPTH 0x00048005
313 struct bcm2835_mbox_tag_depth
{
314 struct bcm2835_mbox_tag_hdr tag_hdr
;
325 #define BCM2835_MBOX_TAG_GET_ALPHA_MODE 0x00040007
326 #define BCM2835_MBOX_TAG_SET_ALPHA_MODE 0x00048007
328 #define BCM2835_MBOX_ALPHA_MODE_0_OPAQUE 0
329 #define BCM2835_MBOX_ALPHA_MODE_0_TRANSPARENT 1
330 #define BCM2835_MBOX_ALPHA_MODE_IGNORED 2
332 struct bcm2835_mbox_tag_alpha_mode
{
333 struct bcm2835_mbox_tag_hdr tag_hdr
;
344 #define BCM2835_MBOX_TAG_GET_VIRTUAL_OFFSET 0x00040009
345 #define BCM2835_MBOX_TAG_SET_VIRTUAL_OFFSET 0x00048009
347 struct bcm2835_mbox_tag_virtual_offset
{
348 struct bcm2835_mbox_tag_hdr tag_hdr
;
361 #define BCM2835_MBOX_TAG_GET_PITCH 0x00040008
363 struct bcm2835_mbox_tag_pitch
{
364 struct bcm2835_mbox_tag_hdr tag_hdr
;
374 #define BCM2835_MBOX_TAG_ALLOCATE_BUFFER 0x00040001
376 struct bcm2835_mbox_tag_allocate_buffer
{
377 struct bcm2835_mbox_tag_hdr tag_hdr
;
389 #define BCM2835_MBOX_TAG_RELEASE_BUFFER 0x00048001
391 struct bcm2835_mbox_tag_release_buffer
{
392 struct bcm2835_mbox_tag_hdr tag_hdr
;
401 #define BCM2835_MBOX_TAG_GET_TOUCHBUF 0x0004000f
403 struct bcm2835_mbox_tag_touchbuf
{
404 struct bcm2835_mbox_hdr hdr
;
405 struct bcm2835_mbox_tag_hdr tag_hdr
;
416 struct bcm2835_fb_config
{
429 struct msg_fb_get_w_h
{
430 struct bcm2835_mbox_hdr hdr
;
431 struct bcm2835_mbox_tag_fb_w_h physical_w_h
;
435 int bcm2835_mbox_fb_get_w_h(struct bcm2835_fb_config
*);
437 struct msg_fb_get_bpp
{
438 struct bcm2835_mbox_hdr hdr
;
439 struct bcm2835_mbox_tag_depth bpp
;
443 int bcm2835_mbox_fb_get_bpp(struct bcm2835_fb_config
*);
445 struct msg_fb_setup
{
446 struct bcm2835_mbox_hdr hdr
;
447 struct bcm2835_mbox_tag_fb_w_h physical_w_h
;
448 struct bcm2835_mbox_tag_fb_w_h virtual_w_h
;
449 struct bcm2835_mbox_tag_virtual_offset offset
;
450 struct bcm2835_mbox_tag_depth depth
;
451 struct bcm2835_mbox_tag_alpha_mode alpha
;
452 struct bcm2835_mbox_tag_allocate_buffer buffer
;
453 struct bcm2835_mbox_tag_pitch pitch
;
457 int bcm2835_mbox_fb_init(struct bcm2835_fb_config
*);
459 int bcm2835_mbox_property(void *, size_t);
461 #endif /* _BCM2835_MBOX_PROP_H_ */