vcprop.h revision 1.3 1 1.3 jmcneill /* $NetBSD: vcprop.h,v 1.3 2013/01/07 20:18:28 jmcneill Exp $ */
2 1.1 skrll
3 1.1 skrll /*-
4 1.1 skrll * Copyright (c) 2012 The NetBSD Foundation, Inc.
5 1.1 skrll * All rights reserved.
6 1.1 skrll *
7 1.1 skrll * This code is derived from software contributed to The NetBSD Foundation
8 1.1 skrll * by Nick Hudson
9 1.1 skrll *
10 1.1 skrll * Redistribution and use in source and binary forms, with or without
11 1.1 skrll * modification, are permitted provided that the following conditions
12 1.1 skrll * are met:
13 1.1 skrll * 1. Redistributions of source code must retain the above copyright
14 1.1 skrll * notice, this list of conditions and the following disclaimer.
15 1.1 skrll * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 skrll * notice, this list of conditions and the following disclaimer in the
17 1.1 skrll * documentation and/or other materials provided with the distribution.
18 1.1 skrll *
19 1.1 skrll * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 skrll * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 skrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 skrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 skrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 skrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 skrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 skrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 skrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 skrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 skrll * POSSIBILITY OF SUCH DAMAGE.
30 1.1 skrll */
31 1.1 skrll
32 1.1 skrll /*
33 1.1 skrll * Mailbox property interface
34 1.1 skrll */
35 1.1 skrll
36 1.1 skrll #ifndef _EVBARM_RPI_VCPROP_H_
37 1.1 skrll #define _EVBARM_RPI_VCPROP_H_
38 1.1 skrll
39 1.1 skrll struct vcprop_tag {
40 1.1 skrll uint32_t vpt_tag;
41 1.1 skrll #define VCPROPTAG_NULL 0x00000000
42 1.1 skrll #define VCPROPTAG_GET_FIRMWAREREV 0x00000001
43 1.1 skrll #define VCPROPTAG_GET_BOARDMODEL 0x00010001
44 1.1 skrll #define VCPROPTAG_GET_BOARDREVISION 0x00010002
45 1.1 skrll #define VCPROPTAG_GET_MACADDRESS 0x00010003
46 1.1 skrll #define VCPROPTAG_GET_BOARDSERIAL 0x00010004
47 1.1 skrll #define VCPROPTAG_GET_ARMMEMORY 0x00010005
48 1.1 skrll #define VCPROPTAG_GET_VCMEMORY 0x00010006
49 1.1 skrll #define VCPROPTAG_GET_CLOCKS 0x00010007
50 1.2 skrll
51 1.3 jmcneill #define VCPROPTAG_GET_POWERSTATE 0x00020001
52 1.3 jmcneill #define VCPROPTAG_GET_POWERTIMING 0x00020002
53 1.3 jmcneill #define VCPROPTAG_SET_POWERSTATE 0x00028001
54 1.3 jmcneill
55 1.2 skrll #define VCPROPTAG_GET_CLOCKSTATE 0x00030001
56 1.2 skrll #define VCPROPTAG_SET_CLOCKSTATE 0x00038001
57 1.2 skrll #define VCPROPTAG_GET_CLOCKRATE 0x00030002
58 1.2 skrll #define VCPROPTAG_SET_CLOCKRATE 0x00038002
59 1.3 jmcneill
60 1.3 jmcneill #define VCPROPTAG_GET_VOLTAGE 0x00030003
61 1.3 jmcneill #define VCPROPTAG_SET_VOLTAGE 0x00038003
62 1.3 jmcneill #define VCPROPTAG_GET_MIN_VOLTAGE 0x00030008
63 1.3 jmcneill #define VCPROPTAG_GET_MAX_VOLTAGE 0x00030005
64 1.3 jmcneill
65 1.3 jmcneill #define VCPROPTAG_GET_TEMPERATURE 0x00030006
66 1.3 jmcneill #define VCPROPTAG_GET_MAX_TEMPERATURE 0x0003000a
67 1.3 jmcneill
68 1.1 skrll #define VCPROPTAG_GET_CMDLINE 0x00050001
69 1.1 skrll #define VCPROPTAG_GET_DMACHAN 0x00060001
70 1.1 skrll uint32_t vpt_len;
71 1.1 skrll uint32_t vpt_rcode;
72 1.1 skrll #define VCPROPTAG_REQUEST (0U << 31)
73 1.1 skrll #define VCPROPTAG_RESPONSE (1U << 31)
74 1.1 skrll
75 1.1 skrll };
76 1.1 skrll
77 1.1 skrll #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
78 1.1 skrll
79 1.1 skrll struct vcprop_memory {
80 1.1 skrll uint32_t base;
81 1.1 skrll uint32_t size;
82 1.1 skrll };
83 1.1 skrll
84 1.1 skrll #define VCPROP_MAXMEMBLOCKS 4
85 1.1 skrll struct vcprop_tag_memory {
86 1.1 skrll struct vcprop_tag tag;
87 1.1 skrll struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
88 1.1 skrll };
89 1.1 skrll
90 1.1 skrll struct vcprop_tag_fwrev {
91 1.1 skrll struct vcprop_tag tag;
92 1.1 skrll uint32_t rev;
93 1.1 skrll };
94 1.1 skrll
95 1.1 skrll struct vcprop_tag_boardmodel {
96 1.1 skrll struct vcprop_tag tag;
97 1.1 skrll uint32_t model;
98 1.1 skrll } ;
99 1.1 skrll
100 1.1 skrll struct vcprop_tag_boardrev {
101 1.1 skrll struct vcprop_tag tag;
102 1.1 skrll uint32_t rev;
103 1.1 skrll } ;
104 1.1 skrll
105 1.1 skrll struct vcprop_tag_macaddr {
106 1.1 skrll struct vcprop_tag tag;
107 1.1 skrll uint64_t addr;
108 1.1 skrll };
109 1.1 skrll
110 1.1 skrll struct vcprop_tag_boardserial {
111 1.1 skrll struct vcprop_tag tag;
112 1.1 skrll uint64_t sn;
113 1.1 skrll };
114 1.1 skrll
115 1.2 skrll #define VCPROP_CLK_EMMC 1
116 1.2 skrll #define VCPROP_CLK_UART 2
117 1.2 skrll #define VCPROP_CLK_ARM 3
118 1.2 skrll #define VCPROP_CLK_CORE 4
119 1.2 skrll #define VCPROP_CLK_V3D 5
120 1.2 skrll #define VCPROP_CLK_H264 6
121 1.2 skrll #define VCPROP_CLK_ISP 7
122 1.2 skrll #define VCPROP_CLK_SDRAM 8
123 1.2 skrll #define VCPROP_CLK_PIXEL 9
124 1.2 skrll #define VCPROP_CLK_PWM 10
125 1.2 skrll
126 1.1 skrll struct vcprop_clock {
127 1.1 skrll uint32_t pclk;
128 1.1 skrll uint32_t cclk;
129 1.1 skrll };
130 1.1 skrll
131 1.1 skrll #define VCPROP_MAXCLOCKS 16
132 1.1 skrll struct vcprop_tag_clock {
133 1.1 skrll struct vcprop_tag tag;
134 1.1 skrll struct vcprop_clock clk[VCPROP_MAXCLOCKS];
135 1.1 skrll };
136 1.1 skrll
137 1.1 skrll #define VCPROP_MAXCMDLINE 256
138 1.1 skrll struct vcprop_tag_cmdline {
139 1.1 skrll struct vcprop_tag tag;
140 1.1 skrll uint8_t cmdline[VCPROP_MAXCMDLINE];
141 1.1 skrll };
142 1.1 skrll
143 1.1 skrll struct vcprop_tag_dmachan {
144 1.1 skrll struct vcprop_tag tag;
145 1.1 skrll uint32_t mask;
146 1.1 skrll };
147 1.1 skrll
148 1.2 skrll struct vcprop_tag_clockstate {
149 1.2 skrll struct vcprop_tag tag;
150 1.2 skrll uint32_t id;
151 1.2 skrll uint32_t state;
152 1.2 skrll };
153 1.2 skrll
154 1.2 skrll struct vcprop_tag_clockrate {
155 1.2 skrll struct vcprop_tag tag;
156 1.2 skrll uint32_t id;
157 1.2 skrll uint32_t rate;
158 1.2 skrll };
159 1.2 skrll
160 1.3 jmcneill #define VCPROP_VOLTAGE_CORE 1
161 1.3 jmcneill #define VCPROP_VOLTAGE_SDRAM_C 2
162 1.3 jmcneill #define VCPROP_VOLTAGE_SDRAM_P 3
163 1.3 jmcneill #define VCPROP_VOLTAGE_SDRAM_I 4
164 1.3 jmcneill
165 1.3 jmcneill struct vcprop_tag_voltage {
166 1.3 jmcneill struct vcprop_tag tag;
167 1.3 jmcneill uint32_t id;
168 1.3 jmcneill uint32_t value;
169 1.3 jmcneill };
170 1.3 jmcneill
171 1.3 jmcneill #define VCPROP_TEMP_SOC 0
172 1.3 jmcneill
173 1.3 jmcneill struct vcprop_tag_temperature {
174 1.3 jmcneill struct vcprop_tag tag;
175 1.3 jmcneill uint32_t id;
176 1.3 jmcneill uint32_t value;
177 1.3 jmcneill };
178 1.3 jmcneill
179 1.3 jmcneill #define VCPROP_POWER_SDCARD 0
180 1.3 jmcneill #define VCPROP_POWER_UART0 1
181 1.3 jmcneill #define VCPROP_POWER_UART1 2
182 1.3 jmcneill #define VCPROP_POWER_USB 3
183 1.3 jmcneill #define VCPROP_POWER_I2C0 4
184 1.3 jmcneill #define VCPROP_POWER_I2C1 5
185 1.3 jmcneill #define VCPROP_POWER_I2C2 6
186 1.3 jmcneill #define VCPROP_POWER_SPI 7
187 1.3 jmcneill #define VCPROP_POWER_CCP2TX 8
188 1.3 jmcneill
189 1.3 jmcneill struct vcprop_tag_powertiming {
190 1.3 jmcneill struct vcprop_tag tag;
191 1.3 jmcneill uint32_t id;
192 1.3 jmcneill uint32_t waitusec;
193 1.3 jmcneill };
194 1.3 jmcneill
195 1.3 jmcneill struct vcprop_tag_powerstate {
196 1.3 jmcneill struct vcprop_tag tag;
197 1.3 jmcneill uint32_t id;
198 1.3 jmcneill uint32_t state;
199 1.3 jmcneill };
200 1.3 jmcneill
201 1.1 skrll struct vcprop_buffer_hdr {
202 1.1 skrll uint32_t vpb_len;
203 1.1 skrll uint32_t vpb_rcode;
204 1.1 skrll #define VCPROP_PROCESS_REQUEST 0
205 1.1 skrll #define VCPROP_REQ_SUCCESS (1U << 31)
206 1.1 skrll #define VCPROP_REQ_EPARSE (1U << 0)
207 1.1 skrll };
208 1.1 skrll
209 1.1 skrll static inline bool
210 1.1 skrll vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
211 1.1 skrll {
212 1.1 skrll
213 1.1 skrll return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
214 1.1 skrll }
215 1.1 skrll
216 1.1 skrll static inline bool
217 1.1 skrll vcprop_tag_success_p(struct vcprop_tag *vpbt)
218 1.1 skrll {
219 1.1 skrll
220 1.1 skrll return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
221 1.1 skrll }
222 1.1 skrll
223 1.1 skrll static inline size_t
224 1.1 skrll vcprop_tag_resplen(struct vcprop_tag *vpbt)
225 1.1 skrll {
226 1.1 skrll
227 1.1 skrll return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
228 1.1 skrll }
229 1.1 skrll
230 1.1 skrll #endif /* _EVBARM_RPI_VCPROP_H_ */
231