bcm2835_mbox_prop.h revision 275963
1/*-
2 * Copyright (C) 2013-2014 Daisuke Aoyama <aoyama@peach.ne.jp>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
13 *
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
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h 275963 2014-12-20 19:15:10Z rpaulo $
27 */
28
29#ifndef _BCM2835_MBOX_PROP_H_
30#define _BCM2835_MBOX_PROP_H_
31
32#include <sys/cdefs.h>
33#include <sys/types.h>
34
35/*
36 * Mailbox property interface:
37 * https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
38 */
39#define BCM2835_MBOX_CODE_REQ			0
40#define BCM2835_MBOX_CODE_RESP_SUCCESS		0x80000000
41#define BCM2835_MBOX_CODE_RESP_ERROR		0x80000001
42#define BCM2835_MBOX_TAG_VAL_LEN_RESPONSE	0x80000000
43
44struct bcm2835_mbox_hdr {
45	uint32_t	buf_size;
46	uint32_t	code;
47};
48
49struct bcm2835_mbox_tag_hdr {
50	uint32_t	tag;
51	uint32_t	val_buf_size;
52	uint32_t	val_len;
53};
54
55#define BCM2835_MBOX_CLOCK_ID_EMMC		0x00000001
56#define BCM2835_MBOX_CLOCK_ID_UART		0x00000002
57#define BCM2835_MBOX_CLOCK_ID_ARM		0x00000003
58#define BCM2835_MBOX_CLOCK_ID_CORE		0x00000004
59#define BCM2835_MBOX_CLOCK_ID_V3D		0x00000005
60#define BCM2835_MBOX_CLOCK_ID_H264		0x00000006
61#define BCM2835_MBOX_CLOCK_ID_ISP		0x00000007
62#define BCM2835_MBOX_CLOCK_ID_SDRAM		0x00000008
63#define BCM2835_MBOX_CLOCK_ID_PIXEL		0x00000009
64#define BCM2835_MBOX_CLOCK_ID_PWM		0x0000000a
65
66#define BCM2835_MBOX_TAG_GET_CLOCK_RATE		0x00030002
67#define BCM2835_MBOX_TAG_SET_CLOCK_RATE		0x00038002
68#define BCM2835_MBOX_TAG_GET_MAX_CLOCK_RATE	0x00030004
69#define BCM2835_MBOX_TAG_GET_MIN_CLOCK_RATE	0x00030007
70
71struct msg_get_clock_rate {
72	struct bcm2835_mbox_hdr hdr;
73	struct bcm2835_mbox_tag_hdr tag_hdr;
74	union {
75		struct {
76			uint32_t clock_id;
77		} req;
78		struct {
79			uint32_t clock_id;
80			uint32_t rate_hz;
81		} resp;
82	} body;
83	uint32_t end_tag;
84};
85
86struct msg_set_clock_rate {
87	struct bcm2835_mbox_hdr hdr;
88	struct bcm2835_mbox_tag_hdr tag_hdr;
89	union {
90		struct {
91			uint32_t clock_id;
92			uint32_t rate_hz;
93		} req;
94		struct {
95			uint32_t clock_id;
96			uint32_t rate_hz;
97		} resp;
98	} body;
99	uint32_t end_tag;
100};
101
102struct msg_get_max_clock_rate {
103	struct bcm2835_mbox_hdr hdr;
104	struct bcm2835_mbox_tag_hdr tag_hdr;
105	union {
106		struct {
107			uint32_t clock_id;
108		} req;
109		struct {
110			uint32_t clock_id;
111			uint32_t rate_hz;
112		} resp;
113	} body;
114	uint32_t end_tag;
115};
116
117struct msg_get_min_clock_rate {
118	struct bcm2835_mbox_hdr hdr;
119	struct bcm2835_mbox_tag_hdr tag_hdr;
120	union {
121		struct {
122			uint32_t clock_id;
123		} req;
124		struct {
125			uint32_t clock_id;
126			uint32_t rate_hz;
127		} resp;
128	} body;
129	uint32_t end_tag;
130};
131
132#define BCM2835_MBOX_TURBO_ON			1
133#define BCM2835_MBOX_TURBO_OFF			0
134
135#define BCM2835_MBOX_TAG_GET_TURBO		0x00030009
136#define BCM2835_MBOX_TAG_SET_TURBO		0x00038009
137
138struct msg_get_turbo {
139	struct bcm2835_mbox_hdr hdr;
140	struct bcm2835_mbox_tag_hdr tag_hdr;
141	union {
142		struct {
143			uint32_t id;
144		} req;
145		struct {
146			uint32_t id;
147			uint32_t level;
148		} resp;
149	} body;
150	uint32_t end_tag;
151};
152
153struct msg_set_turbo {
154	struct bcm2835_mbox_hdr hdr;
155	struct bcm2835_mbox_tag_hdr tag_hdr;
156	union {
157		struct {
158			uint32_t id;
159			uint32_t level;
160		} req;
161		struct {
162			uint32_t id;
163			uint32_t level;
164		} resp;
165	} body;
166	uint32_t end_tag;
167};
168
169#define BCM2835_MBOX_VOLTAGE_ID_CORE		0x00000001
170#define BCM2835_MBOX_VOLTAGE_ID_SDRAM_C		0x00000002
171#define BCM2835_MBOX_VOLTAGE_ID_SDRAM_P		0x00000003
172#define BCM2835_MBOX_VOLTAGE_ID_SDRAM_I		0x00000004
173
174#define BCM2835_MBOX_TAG_GET_VOLTAGE		0x00030003
175#define BCM2835_MBOX_TAG_SET_VOLTAGE		0x00038003
176#define BCM2835_MBOX_TAG_GET_MAX_VOLTAGE	0x00030005
177#define BCM2835_MBOX_TAG_GET_MIN_VOLTAGE	0x00030008
178
179struct msg_get_voltage {
180	struct bcm2835_mbox_hdr hdr;
181	struct bcm2835_mbox_tag_hdr tag_hdr;
182	union {
183		struct {
184			uint32_t voltage_id;
185		} req;
186		struct {
187			uint32_t voltage_id;
188			uint32_t value;
189		} resp;
190	} body;
191	uint32_t end_tag;
192};
193
194struct msg_set_voltage {
195	struct bcm2835_mbox_hdr hdr;
196	struct bcm2835_mbox_tag_hdr tag_hdr;
197	union {
198		struct {
199			uint32_t voltage_id;
200			uint32_t value;
201		} req;
202		struct {
203			uint32_t voltage_id;
204			uint32_t value;
205		} resp;
206	} body;
207	uint32_t end_tag;
208};
209
210struct msg_get_max_voltage {
211	struct bcm2835_mbox_hdr hdr;
212	struct bcm2835_mbox_tag_hdr tag_hdr;
213	union {
214		struct {
215			uint32_t voltage_id;
216		} req;
217		struct {
218			uint32_t voltage_id;
219			uint32_t value;
220		} resp;
221	} body;
222	uint32_t end_tag;
223};
224
225struct msg_get_min_voltage {
226	struct bcm2835_mbox_hdr hdr;
227	struct bcm2835_mbox_tag_hdr tag_hdr;
228	union {
229		struct {
230			uint32_t voltage_id;
231		} req;
232		struct {
233			uint32_t voltage_id;
234			uint32_t value;
235		} resp;
236	} body;
237	uint32_t end_tag;
238};
239
240#define BCM2835_MBOX_TAG_GET_TEMPERATURE	0x00030006
241#define BCM2835_MBOX_TAG_GET_MAX_TEMPERATURE	0x0003000a
242
243struct msg_get_temperature {
244	struct bcm2835_mbox_hdr hdr;
245	struct bcm2835_mbox_tag_hdr tag_hdr;
246	union {
247		struct {
248			uint32_t temperature_id;
249		} req;
250		struct {
251			uint32_t temperature_id;
252			uint32_t value;
253		} resp;
254	} body;
255	uint32_t end_tag;
256};
257
258struct msg_get_max_temperature {
259	struct bcm2835_mbox_hdr hdr;
260	struct bcm2835_mbox_tag_hdr tag_hdr;
261	union {
262		struct {
263			uint32_t temperature_id;
264		} req;
265		struct {
266			uint32_t temperature_id;
267			uint32_t value;
268		} resp;
269	} body;
270	uint32_t end_tag;
271};
272
273#endif /* _BCM2835_MBOX_PROP_H_ */
274