xref: /netbsd-src/sys/arch/evbarm/rpi/vcprop.h (revision fd9b697d9c834c84bcd0e32d1c314b466a1cd21a)
1*fd9b697dSmlelstv /*	$NetBSD: vcprop.h,v 1.20 2021/03/08 13:53:08 mlelstv Exp $	*/
2697a2ce9Sskrll 
3697a2ce9Sskrll /*-
4697a2ce9Sskrll  * Copyright (c) 2012 The NetBSD Foundation, Inc.
5697a2ce9Sskrll  * All rights reserved.
6697a2ce9Sskrll  *
7697a2ce9Sskrll  * This code is derived from software contributed to The NetBSD Foundation
8697a2ce9Sskrll  * by Nick Hudson
9697a2ce9Sskrll  *
10697a2ce9Sskrll  * Redistribution and use in source and binary forms, with or without
11697a2ce9Sskrll  * modification, are permitted provided that the following conditions
12697a2ce9Sskrll  * are met:
13697a2ce9Sskrll  * 1. Redistributions of source code must retain the above copyright
14697a2ce9Sskrll  *    notice, this list of conditions and the following disclaimer.
15697a2ce9Sskrll  * 2. Redistributions in binary form must reproduce the above copyright
16697a2ce9Sskrll  *    notice, this list of conditions and the following disclaimer in the
17697a2ce9Sskrll  *    documentation and/or other materials provided with the distribution.
18697a2ce9Sskrll  *
19697a2ce9Sskrll  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20697a2ce9Sskrll  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21697a2ce9Sskrll  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22697a2ce9Sskrll  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23697a2ce9Sskrll  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24697a2ce9Sskrll  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25697a2ce9Sskrll  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26697a2ce9Sskrll  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27697a2ce9Sskrll  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28697a2ce9Sskrll  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29697a2ce9Sskrll  * POSSIBILITY OF SUCH DAMAGE.
30697a2ce9Sskrll  */
31697a2ce9Sskrll 
32697a2ce9Sskrll /*
33697a2ce9Sskrll  * Mailbox property interface
34697a2ce9Sskrll  */
35697a2ce9Sskrll 
36697a2ce9Sskrll #ifndef	_EVBARM_RPI_VCPROP_H_
37697a2ce9Sskrll #define	_EVBARM_RPI_VCPROP_H_
38697a2ce9Sskrll 
399e5ab4baSjmcneill #include "opt_vcprop.h"
409e5ab4baSjmcneill 
414a4535adSrin #include <sys/endian.h>
424a4535adSrin 
43697a2ce9Sskrll struct vcprop_tag {
44697a2ce9Sskrll 	uint32_t vpt_tag;
45697a2ce9Sskrll #define	VCPROPTAG_NULL			0x00000000
46697a2ce9Sskrll #define	VCPROPTAG_GET_FIRMWAREREV	0x00000001
47*fd9b697dSmlelstv #define	VCPROPTAG_GET_FIRMWAREVARIANT	0x00000002
48*fd9b697dSmlelstv #define	VCPROPTAG_GET_FIRMWAREHASH	0x00000003
49697a2ce9Sskrll #define	VCPROPTAG_GET_BOARDMODEL	0x00010001
50697a2ce9Sskrll #define	VCPROPTAG_GET_BOARDREVISION	0x00010002
51697a2ce9Sskrll #define	VCPROPTAG_GET_MACADDRESS	0x00010003
52697a2ce9Sskrll #define	VCPROPTAG_GET_BOARDSERIAL	0x00010004
53697a2ce9Sskrll #define	VCPROPTAG_GET_ARMMEMORY		0x00010005
54697a2ce9Sskrll #define	VCPROPTAG_GET_VCMEMORY		0x00010006
55697a2ce9Sskrll #define	VCPROPTAG_GET_CLOCKS		0x00010007
56697a2ce9Sskrll 
57a7ba2688Sjmcneill #define VCPROPTAG_GET_POWERSTATE	0x00020001
58a7ba2688Sjmcneill #define VCPROPTAG_GET_POWERTIMING	0x00020002
59a7ba2688Sjmcneill #define VCPROPTAG_SET_POWERSTATE	0x00028001
60a7ba2688Sjmcneill 
6196090e53Sskrll #define	VCPROPTAG_GET_CLOCKSTATE	0x00030001
6296090e53Sskrll #define	VCPROPTAG_SET_CLOCKSTATE	0x00038001
6396090e53Sskrll #define	VCPROPTAG_GET_CLOCKRATE		0x00030002
6496090e53Sskrll #define	VCPROPTAG_SET_CLOCKRATE		0x00038002
65254e9949Sjmcneill #define	VCPROPTAG_GET_MIN_CLOCKRATE	0x00030007
66254e9949Sjmcneill #define	VCPROPTAG_GET_MAX_CLOCKRATE	0x00030004
677b1a3089Smlelstv #define	VCPROPTAG_GET_TURBO		0x00030009
687b1a3089Smlelstv #define	VCPROPTAG_SET_TURBO		0x00038009
6996090e53Sskrll 
70*fd9b697dSmlelstv #define VCPROPTAG_GET_STC		0x0003000b
71*fd9b697dSmlelstv #define	VCPROPTAG_GET_THROTTLED		0x00030046
72*fd9b697dSmlelstv #define	VCPROPTAG_GET_CLOCK_MEASURED	0x00030047
73*fd9b697dSmlelstv #define	VCPROPTAG_NOTIFY_REBOOT		0x00030048
74*fd9b697dSmlelstv 
75a7ba2688Sjmcneill #define VCPROPTAG_GET_VOLTAGE		0x00030003
76a7ba2688Sjmcneill #define VCPROPTAG_SET_VOLTAGE		0x00038003
77a7ba2688Sjmcneill #define VCPROPTAG_GET_MIN_VOLTAGE	0x00030008
78a7ba2688Sjmcneill #define VCPROPTAG_GET_MAX_VOLTAGE	0x00030005
79a7ba2688Sjmcneill 
80a7ba2688Sjmcneill #define VCPROPTAG_GET_TEMPERATURE	0x00030006
81a7ba2688Sjmcneill #define VCPROPTAG_GET_MAX_TEMPERATURE	0x0003000a
82a7ba2688Sjmcneill 
83*fd9b697dSmlelstv #define VCPROPTAG_GET_DOMAIN_STATE	0x00030030
84*fd9b697dSmlelstv #define VCPROPTAG_SET_DOMAIN_STATE	0x00038030
85*fd9b697dSmlelstv 
86*fd9b697dSmlelstv #define VCPROPTAG_GET_GPIO_STATE	0x00030041
87*fd9b697dSmlelstv #define VCPROPTAG_SET_GPIO_STATE	0x00038041
88*fd9b697dSmlelstv #define VCPROPTAG_GET_GPIO_CONFIG	0x00030041
89*fd9b697dSmlelstv #define VCPROPTAG_SET_GPIO_CONFIG	0x00038041
90*fd9b697dSmlelstv #define VCPROPTAG_GET_PERIPH_REG	0x00030045
91*fd9b697dSmlelstv #define VCPROPTAG_SET_PERIPH_REG	0x00038045
92*fd9b697dSmlelstv 
93*fd9b697dSmlelstv #define VCPROPTAG_GET_OTP		0x00030021
94*fd9b697dSmlelstv #define VCPROPTAG_SET_OTP		0x00038021
95*fd9b697dSmlelstv 
96*fd9b697dSmlelstv #define VCPROPTAG_SET_SDHOST_CLOCK	0x00038042
97*fd9b697dSmlelstv 
98*fd9b697dSmlelstv #define VCPROPTAG_GET_POE_HAT_VAL	0x00030049
99*fd9b697dSmlelstv #define VCPROPTAG_SET_POE_HAT_VAL	0x00030050
100*fd9b697dSmlelstv 
101*fd9b697dSmlelstv #define VCPROPTAG_NOTIFY_XHCI_RESET	0x00030058
102*fd9b697dSmlelstv 
103697a2ce9Sskrll #define	VCPROPTAG_GET_CMDLINE		0x00050001
104697a2ce9Sskrll #define	VCPROPTAG_GET_DMACHAN		0x00060001
10512fa968bSjmcneill 
10612fa968bSjmcneill #define	VCPROPTAG_ALLOCATE_BUFFER	0x00040001
107*fd9b697dSmlelstv #define	VCPROPTAG_RELEASE_BUFFER	0x00048001
108255b7065Sjmcneill #define	VCPROPTAG_BLANK_SCREEN		0x00040002
10912fa968bSjmcneill #define	VCPROPTAG_GET_FB_RES		0x00040003
110*fd9b697dSmlelstv #define	VCPROPTAG_TST_FB_RES		0x00044003
11154a1d20bSjmcneill #define	VCPROPTAG_SET_FB_RES		0x00048003
112255b7065Sjmcneill #define	VCPROPTAG_GET_FB_VRES		0x00040004
113*fd9b697dSmlelstv #define	VCPROPTAG_TST_FB_VRES		0x00044004
114255b7065Sjmcneill #define	VCPROPTAG_SET_FB_VRES		0x00048004
11512fa968bSjmcneill #define	VCPROPTAG_GET_FB_DEPTH		0x00040005
116*fd9b697dSmlelstv #define	VCPROPTAG_TST_FB_DEPTH		0x00044005
11754a1d20bSjmcneill #define	VCPROPTAG_SET_FB_DEPTH		0x00048005
11812fa968bSjmcneill #define	VCPROPTAG_GET_FB_PIXEL_ORDER	0x00040006
119*fd9b697dSmlelstv #define	VCPROPTAG_TST_FB_PIXEL_ORDER	0x00044006
12054a1d20bSjmcneill #define	VCPROPTAG_SET_FB_PIXEL_ORDER	0x00048006
121255b7065Sjmcneill #define	VCPROPTAG_GET_FB_ALPHA_MODE	0x00040007
122*fd9b697dSmlelstv #define	VCPROPTAG_TST_FB_ALPHA_MODE	0x00044007
123255b7065Sjmcneill #define	VCPROPTAG_SET_FB_ALPHA_MODE	0x00048007
12412fa968bSjmcneill #define	VCPROPTAG_GET_FB_PITCH		0x00040008
125*fd9b697dSmlelstv #define	VCPROPTAG_GET_VIRTUAL_OFFSET	0x00040009
126*fd9b697dSmlelstv #define	VCPROPTAG_TST_VIRTUAL_OFFSET	0x00044009
127*fd9b697dSmlelstv #define	VCPROPTAG_SET_VIRTUAL_OFFSET	0x00048009
128*fd9b697dSmlelstv #define	VCPROPTAG_GET_OVERSCAN		0x0004000a
129*fd9b697dSmlelstv #define	VCPROPTAG_TST_OVERSCAN		0x0004400a
130*fd9b697dSmlelstv #define	VCPROPTAG_SET_OVERSCAN		0x0004800a
131*fd9b697dSmlelstv #define	VCPROPTAG_GET_PALETTE		0x0004000b
132*fd9b697dSmlelstv #define	VCPROPTAG_TST_PALETTE		0x0004400b
133*fd9b697dSmlelstv #define	VCPROPTAG_SET_PALETTE		0x0004800b
134*fd9b697dSmlelstv #define	VCPROPTAG_GET_FB_LAYER		0x0004000c
135*fd9b697dSmlelstv #define	VCPROPTAG_TST_FB_LAYER		0x0004400c
136*fd9b697dSmlelstv #define	VCPROPTAG_SET_FB_LAYER		0x0004800c
137*fd9b697dSmlelstv #define	VCPROPTAG_GET_TRANSFORM		0x0004000d
138*fd9b697dSmlelstv #define	VCPROPTAG_TST_TRANSFORM		0x0004400d
139*fd9b697dSmlelstv #define	VCPROPTAG_SET_TRANSFORM		0x0004800d
140*fd9b697dSmlelstv #define	VCPROPTAG_GET_VSYNC		0x0004000e
141*fd9b697dSmlelstv #define	VCPROPTAG_TST_VSYNC		0x0004400e
142*fd9b697dSmlelstv #define	VCPROPTAG_SET_VSYNC		0x0004800e
143*fd9b697dSmlelstv #define	VCPROPTAG_GET_TOUCHBUF		0x0004000f
144*fd9b697dSmlelstv #define	VCPROPTAG_GET_SET_BACKLIGHT	0x0004800f
145*fd9b697dSmlelstv #define	VCPROPTAG_GET_GPIOVIRTBUF	0x00040010
146*fd9b697dSmlelstv #define	VCPROPTAG_SET_GPIOVIRTBUF	0x00048020
147*fd9b697dSmlelstv #define	VCPROPTAG_GET_NUM_DISPLAYS	0x00040013
148*fd9b697dSmlelstv #define	VCPROPTAG_SET_DISPLAYNUM	0x00048013
149*fd9b697dSmlelstv #define	VCPROPTAG_GET_DISPLAY_SETTINGS	0x00040014
150*fd9b697dSmlelstv #define	VCPROPTAG_GET_DISPLAYID		0x00040016
151*fd9b697dSmlelstv 
152*fd9b697dSmlelstv #define	VCPROPTAG_VCHIQ_INIT		0x00048010
153*fd9b697dSmlelstv 
154*fd9b697dSmlelstv #define	VCPROPTAG_SET_PLANE		0x00048015
155*fd9b697dSmlelstv #define	VCPROPTAG_GET_TIMING		0x00040017
156*fd9b697dSmlelstv #define	VCPROPTAG_SET_TIMING		0x00048017
157*fd9b697dSmlelstv #define	VCPROPTAG_GET_DISPLAY_CFG	0x00048018
15812fa968bSjmcneill 
15912fa968bSjmcneill #define	VCPROPTAG_GET_EDID_BLOCK	0x00030020
160*fd9b697dSmlelstv #define	VCPROPTAG_GET_EDID_BLOCK_DISP	0x00030021
16112fa968bSjmcneill 
1626a85f858Smacallan #define	VCPROPTAG_ALLOCMEM		0x0003000c
1636a85f858Smacallan #define	VCPROPTAG_LOCKMEM		0x0003000d
1646a85f858Smacallan #define	VCPROPTAG_UNLOCKMEM		0x0003000e
1656a85f858Smacallan #define	VCPROPTAG_RELEASEMEM		0x0003000f
1667b1a3089Smlelstv #define	VCPROPTAG_EXECUTE_CODE		0x00030010
1677b1a3089Smlelstv #define	VCPROPTAG_EXECUTE_QPU		0x00030011
1687b1a3089Smlelstv #define	VCPROPTAG_SET_ENABLE_QPU	0x00030012
1697b1a3089Smlelstv #define	VCPROPTAG_GET_DISPMANX_HANDLE	0x00030014
1706a85f858Smacallan 
171cb844c75Smacallan #define	VCPROPTAG_SET_CURSOR_INFO	0x00008010
172cb844c75Smacallan #define	VCPROPTAG_SET_CURSOR_STATE	0x00008011
17312fa968bSjmcneill 
174697a2ce9Sskrll 	uint32_t vpt_len;
175697a2ce9Sskrll 	uint32_t vpt_rcode;
176697a2ce9Sskrll #define	VCPROPTAG_REQUEST	(0U << 31)
177697a2ce9Sskrll #define	VCPROPTAG_RESPONSE	(1U << 31)
178697a2ce9Sskrll 
179697a2ce9Sskrll };
180697a2ce9Sskrll 
181697a2ce9Sskrll #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
182697a2ce9Sskrll 
183*fd9b697dSmlelstv #define VCPROP_INIT_REQUEST(req)					\
184*fd9b697dSmlelstv 	do {								\
185*fd9b697dSmlelstv 		memset(&(req), 0, sizeof((req)));			\
186*fd9b697dSmlelstv 		(req).vb_hdr.vpb_len = htole32(sizeof((req)));		\
187*fd9b697dSmlelstv 		(req).vb_hdr.vpb_rcode = htole32(VCPROP_PROCESS_REQUEST);\
188*fd9b697dSmlelstv 		(req).end.vpt_tag = htole32(VCPROPTAG_NULL);			\
189*fd9b697dSmlelstv 	} while (0)
190*fd9b697dSmlelstv #define VCPROP_INIT_TAG(s, t)						\
191*fd9b697dSmlelstv 	do {								\
192*fd9b697dSmlelstv 		(s).tag.vpt_tag = htole32(t);				\
193*fd9b697dSmlelstv 		(s).tag.vpt_rcode = htole32(VCPROPTAG_REQUEST);		\
194*fd9b697dSmlelstv 		(s).tag.vpt_len = htole32(VCPROPTAG_LEN(s));		\
195*fd9b697dSmlelstv 	} while (0)
196*fd9b697dSmlelstv 
197697a2ce9Sskrll struct vcprop_memory {
198697a2ce9Sskrll 	uint32_t base;
199697a2ce9Sskrll 	uint32_t size;
200697a2ce9Sskrll };
201697a2ce9Sskrll 
202697a2ce9Sskrll #define	VCPROP_MAXMEMBLOCKS 4
203697a2ce9Sskrll struct vcprop_tag_memory {
204697a2ce9Sskrll 	struct vcprop_tag tag;
205697a2ce9Sskrll 	struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
206697a2ce9Sskrll };
207697a2ce9Sskrll 
208697a2ce9Sskrll struct vcprop_tag_fwrev {
209697a2ce9Sskrll 	struct vcprop_tag tag;
210697a2ce9Sskrll 	uint32_t rev;
211697a2ce9Sskrll };
212697a2ce9Sskrll 
213697a2ce9Sskrll struct vcprop_tag_boardmodel {
214697a2ce9Sskrll 	struct vcprop_tag tag;
215697a2ce9Sskrll 	uint32_t model;
216697a2ce9Sskrll };
217697a2ce9Sskrll 
218697a2ce9Sskrll struct vcprop_tag_boardrev {
219697a2ce9Sskrll 	struct vcprop_tag tag;
220697a2ce9Sskrll 	uint32_t rev;
221697a2ce9Sskrll };
222697a2ce9Sskrll 
223db54ab35Sjmcneill #define	VCPROP_REV_PCBREV	__BITS(3,0)
224db54ab35Sjmcneill #define	VCPROP_REV_MODEL	__BITS(11,4)
225db54ab35Sjmcneill #define	 RPI_MODEL_A		0
226db54ab35Sjmcneill #define	 RPI_MODEL_B		1
227db54ab35Sjmcneill #define	 RPI_MODEL_A_PLUS	2
228db54ab35Sjmcneill #define	 RPI_MODEL_B_PLUS	3
229db54ab35Sjmcneill #define	 RPI_MODEL_B_PI2	4
230db54ab35Sjmcneill #define	 RPI_MODEL_ALPHA	5
231db54ab35Sjmcneill #define	 RPI_MODEL_COMPUTE	6
232db54ab35Sjmcneill #define	 RPI_MODEL_B_PI3	8
233*fd9b697dSmlelstv #define	 RPI_MODEL_ZERO		9
234*fd9b697dSmlelstv #define	 RPI_MODEL_COMPUTE_PI3	10
235*fd9b697dSmlelstv #define	 RPI_MODEL_ZERO_W	12
236*fd9b697dSmlelstv #define	 RPI_MODEL_B_PLUS_PI3	13
237*fd9b697dSmlelstv #define	 RPI_MODEL_A_PLUS_PI3	14
238*fd9b697dSmlelstv #define	 RPI_MODEL_CM_PLUS_PI3	16
239*fd9b697dSmlelstv #define	 RPI_MODEL_B_PI4	17
240db54ab35Sjmcneill #define	VCPROP_REV_PROCESSOR	__BITS(15,12)
241db54ab35Sjmcneill #define	 RPI_PROCESSOR_BCM2835	0
242db54ab35Sjmcneill #define	 RPI_PROCESSOR_BCM2836	1
243db54ab35Sjmcneill #define	 RPI_PROCESSOR_BCM2837	2
244*fd9b697dSmlelstv #define	 RPI_PROCESSOR_BCM2711	3
245db54ab35Sjmcneill #define	VCPROP_REV_MANUF	__BITS(19,16)
246*fd9b697dSmlelstv #define	 RPI_MANUF_SONY         0
247*fd9b697dSmlelstv #define	 RPI_MANUF_EGOMAN       1
248*fd9b697dSmlelstv #define	 RPI_MANUF_QISDA        16
249*fd9b697dSmlelstv #define	 RPI_MANUF_EMBEST       2
250*fd9b697dSmlelstv #define	 RPI_MANUF_SONYJAPAN    3
251db54ab35Sjmcneill #define	VCPROP_REV_MEMSIZE	__BITS(22,20)
252*fd9b697dSmlelstv #define	 RPI_MEMSIZE_256	0
253*fd9b697dSmlelstv #define	 RPI_MEMSIZE_512	1
254*fd9b697dSmlelstv #define	 RPI_MEMSIZE_1024	2
255*fd9b697dSmlelstv #define	 RPI_MEMSIZE_2048	3
256*fd9b697dSmlelstv #define	 RPI_MEMSIZE_4096	4
257db54ab35Sjmcneill #define	VCPROP_REV_ENCFLAG	__BIT(23)
258db54ab35Sjmcneill #define	VCPROP_REV_WARRANTY	__BITS(25,24)
259db54ab35Sjmcneill 
260697a2ce9Sskrll struct vcprop_tag_macaddr {
261697a2ce9Sskrll 	struct vcprop_tag tag;
262697a2ce9Sskrll 	uint64_t addr;
263a73abb63Sskrll } __packed;
264697a2ce9Sskrll 
265697a2ce9Sskrll struct vcprop_tag_boardserial {
266697a2ce9Sskrll 	struct vcprop_tag tag;
267697a2ce9Sskrll 	uint64_t sn;
268a73abb63Sskrll } __packed;
269697a2ce9Sskrll 
27096090e53Sskrll #define	VCPROP_CLK_EMMC		1
27196090e53Sskrll #define	VCPROP_CLK_UART		2
27296090e53Sskrll #define	VCPROP_CLK_ARM		3
27396090e53Sskrll #define	VCPROP_CLK_CORE		4
27496090e53Sskrll #define	VCPROP_CLK_V3D		5
27596090e53Sskrll #define	VCPROP_CLK_H264		6
27696090e53Sskrll #define	VCPROP_CLK_ISP		7
27796090e53Sskrll #define	VCPROP_CLK_SDRAM	8
27896090e53Sskrll #define	VCPROP_CLK_PIXEL	9
27996090e53Sskrll #define	VCPROP_CLK_PWM		10
280a3be5579Sskrll #define	VCPROP_CLK_EMMC2	12
28196090e53Sskrll 
282697a2ce9Sskrll struct vcprop_clock {
283697a2ce9Sskrll 	uint32_t pclk;
284697a2ce9Sskrll 	uint32_t cclk;
285697a2ce9Sskrll };
286697a2ce9Sskrll 
287697a2ce9Sskrll #define	VCPROP_MAXCLOCKS 16
288697a2ce9Sskrll struct vcprop_tag_clock {
289697a2ce9Sskrll 	struct vcprop_tag tag;
290697a2ce9Sskrll 	struct vcprop_clock clk[VCPROP_MAXCLOCKS];
291697a2ce9Sskrll };
292697a2ce9Sskrll 
2939e5ab4baSjmcneill #ifndef	VCPROP_MAXCMDLINE
2949e5ab4baSjmcneill #define	VCPROP_MAXCMDLINE 1024
2959e5ab4baSjmcneill #endif
296697a2ce9Sskrll struct vcprop_tag_cmdline {
297697a2ce9Sskrll 	struct vcprop_tag tag;
298697a2ce9Sskrll 	uint8_t cmdline[VCPROP_MAXCMDLINE];
299697a2ce9Sskrll };
300697a2ce9Sskrll 
301697a2ce9Sskrll struct vcprop_tag_dmachan {
302697a2ce9Sskrll 	struct vcprop_tag tag;
303697a2ce9Sskrll 	uint32_t mask;
304697a2ce9Sskrll };
305697a2ce9Sskrll 
30696090e53Sskrll struct vcprop_tag_clockstate {
30796090e53Sskrll 	struct vcprop_tag tag;
30896090e53Sskrll 	uint32_t id;
30996090e53Sskrll 	uint32_t state;
31096090e53Sskrll };
31196090e53Sskrll 
31296090e53Sskrll struct vcprop_tag_clockrate {
31396090e53Sskrll 	struct vcprop_tag tag;
31496090e53Sskrll 	uint32_t id;
31596090e53Sskrll 	uint32_t rate;
316b4740b2aSskrll 	uint32_t noturbo;
31796090e53Sskrll };
31896090e53Sskrll 
319*fd9b697dSmlelstv struct vcprop_tag_sdhostclock {
320*fd9b697dSmlelstv 	struct vcprop_tag tag;
321*fd9b697dSmlelstv 	uint32_t clock;
322*fd9b697dSmlelstv 	uint32_t clock1;
323*fd9b697dSmlelstv 	uint32_t clock2;
324*fd9b697dSmlelstv };
325*fd9b697dSmlelstv 
326a7ba2688Sjmcneill #define VCPROP_VOLTAGE_CORE	1
327a7ba2688Sjmcneill #define VCPROP_VOLTAGE_SDRAM_C	2
328a7ba2688Sjmcneill #define VCPROP_VOLTAGE_SDRAM_P	3
329a7ba2688Sjmcneill #define VCPROP_VOLTAGE_SDRAM_I	4
330a7ba2688Sjmcneill 
331a7ba2688Sjmcneill struct vcprop_tag_voltage {
332a7ba2688Sjmcneill 	struct vcprop_tag tag;
333a7ba2688Sjmcneill 	uint32_t id;
334a7ba2688Sjmcneill 	uint32_t value;
335a7ba2688Sjmcneill };
336a7ba2688Sjmcneill 
337a7ba2688Sjmcneill #define VCPROP_TEMP_SOC		0
338a7ba2688Sjmcneill 
339a7ba2688Sjmcneill struct vcprop_tag_temperature {
340a7ba2688Sjmcneill 	struct vcprop_tag tag;
341a7ba2688Sjmcneill 	uint32_t id;
342a7ba2688Sjmcneill 	uint32_t value;
343a7ba2688Sjmcneill };
344a7ba2688Sjmcneill 
345a7ba2688Sjmcneill #define	VCPROP_POWER_SDCARD	0
346a7ba2688Sjmcneill #define	VCPROP_POWER_UART0	1
347a7ba2688Sjmcneill #define	VCPROP_POWER_UART1	2
348a7ba2688Sjmcneill #define	VCPROP_POWER_USB	3
349a7ba2688Sjmcneill #define	VCPROP_POWER_I2C0	4
350a7ba2688Sjmcneill #define	VCPROP_POWER_I2C1	5
351a7ba2688Sjmcneill #define	VCPROP_POWER_I2C2	6
352a7ba2688Sjmcneill #define	VCPROP_POWER_SPI	7
353a7ba2688Sjmcneill #define	VCPROP_POWER_CCP2TX	8
354a7ba2688Sjmcneill 
355*fd9b697dSmlelstv #define VCPROP_DOMAIN_I2C0           1
356*fd9b697dSmlelstv #define VCPROP_DOMAIN_I2C1           2
357*fd9b697dSmlelstv #define VCPROP_DOMAIN_I2C2           3
358*fd9b697dSmlelstv #define VCPROP_DOMAIN_VIDEO_SCALER   4
359*fd9b697dSmlelstv #define VCPROP_DOMAIN_VPU1           5
360*fd9b697dSmlelstv #define VCPROP_DOMAIN_HDMI           6
361*fd9b697dSmlelstv #define VCPROP_DOMAIN_USB            7
362*fd9b697dSmlelstv #define VCPROP_DOMAIN_VEC            8
363*fd9b697dSmlelstv #define VCPROP_DOMAIN_JPEG           9
364*fd9b697dSmlelstv #define VCPROP_DOMAIN_H264           10
365*fd9b697dSmlelstv #define VCPROP_DOMAIN_V3D            11
366*fd9b697dSmlelstv #define VCPROP_DOMAIN_ISP            12
367*fd9b697dSmlelstv #define VCPROP_DOMAIN_UNICAM0        13
368*fd9b697dSmlelstv #define VCPROP_DOMAIN_UNICAM1        14
369*fd9b697dSmlelstv #define VCPROP_DOMAIN_CCP2RX         15
370*fd9b697dSmlelstv #define VCPROP_DOMAIN_CSI2           16
371*fd9b697dSmlelstv #define VCPROP_DOMAIN_CPI            17
372*fd9b697dSmlelstv #define VCPROP_DOMAIN_DSI0           18
373*fd9b697dSmlelstv #define VCPROP_DOMAIN_DSI1           19
374*fd9b697dSmlelstv #define VCPROP_DOMAIN_TRANSPOSER     20
375*fd9b697dSmlelstv #define VCPROP_DOMAIN_CCP2TX         21
376*fd9b697dSmlelstv #define VCPROP_DOMAIN_CDP            22
377*fd9b697dSmlelstv #define VCPROP_DOMAIN_ARM            23
378*fd9b697dSmlelstv 
379a7ba2688Sjmcneill struct vcprop_tag_powertiming {
380a7ba2688Sjmcneill 	struct vcprop_tag tag;
381a7ba2688Sjmcneill 	uint32_t id;
382a7ba2688Sjmcneill 	uint32_t waitusec;
383a7ba2688Sjmcneill };
384a7ba2688Sjmcneill 
385a7ba2688Sjmcneill struct vcprop_tag_powerstate {
386a7ba2688Sjmcneill 	struct vcprop_tag tag;
387a7ba2688Sjmcneill 	uint32_t id;
388a7ba2688Sjmcneill 	uint32_t state;
389a7ba2688Sjmcneill };
390a7ba2688Sjmcneill 
39112fa968bSjmcneill struct vcprop_tag_allocbuf {
39212fa968bSjmcneill 	struct vcprop_tag tag;
39312fa968bSjmcneill 	uint32_t address;	/* alignment for request */
39412fa968bSjmcneill 	uint32_t size;
39512fa968bSjmcneill };
39612fa968bSjmcneill 
397255b7065Sjmcneill #define VCPROP_BLANK_OFF	0
398255b7065Sjmcneill #define VCPROP_BLANK_ON		1
399255b7065Sjmcneill 
400255b7065Sjmcneill struct vcprop_tag_blankscreen {
401255b7065Sjmcneill 	struct vcprop_tag tag;
402255b7065Sjmcneill 	uint32_t state;
403255b7065Sjmcneill };
404255b7065Sjmcneill 
40512fa968bSjmcneill struct vcprop_tag_fbres {
40612fa968bSjmcneill 	struct vcprop_tag tag;
40712fa968bSjmcneill 	uint32_t width;
40812fa968bSjmcneill 	uint32_t height;
40912fa968bSjmcneill };
41012fa968bSjmcneill 
41112fa968bSjmcneill struct vcprop_tag_fbdepth {
41212fa968bSjmcneill 	struct vcprop_tag tag;
41312fa968bSjmcneill 	uint32_t bpp;
41412fa968bSjmcneill };
41512fa968bSjmcneill 
41612fa968bSjmcneill #define VCPROP_PIXEL_BGR	0
41712fa968bSjmcneill #define VCPROP_PIXEL_RGB	1
41812fa968bSjmcneill 
41912fa968bSjmcneill struct vcprop_tag_fbpixelorder {
42012fa968bSjmcneill 	struct vcprop_tag tag;
421*fd9b697dSmlelstv 	uint32_t order;
42212fa968bSjmcneill };
42312fa968bSjmcneill 
42412fa968bSjmcneill struct vcprop_tag_fbpitch {
42512fa968bSjmcneill 	struct vcprop_tag tag;
42612fa968bSjmcneill 	uint32_t linebytes;
42712fa968bSjmcneill };
42812fa968bSjmcneill 
429255b7065Sjmcneill #define VCPROP_ALPHA_ENABLED	0
430255b7065Sjmcneill #define VCPROP_ALPHA_REVERSED	1
431255b7065Sjmcneill #define VCPROP_ALPHA_IGNORED	2
432255b7065Sjmcneill 
433255b7065Sjmcneill struct vcprop_tag_fbalpha {
434255b7065Sjmcneill 	struct vcprop_tag tag;
435255b7065Sjmcneill 	uint32_t state;
436255b7065Sjmcneill };
437255b7065Sjmcneill 
43812fa968bSjmcneill struct vcprop_tag_edidblock {
43912fa968bSjmcneill 	struct vcprop_tag tag;
44012fa968bSjmcneill 	uint32_t blockno;
44112fa968bSjmcneill 	uint32_t status;
44212fa968bSjmcneill 	uint8_t data[128];
44312fa968bSjmcneill };
44412fa968bSjmcneill 
445*fd9b697dSmlelstv struct vcprop_tag_numdpy {
446*fd9b697dSmlelstv 	struct vcprop_tag tag;
447*fd9b697dSmlelstv 	uint32_t count;
448*fd9b697dSmlelstv };
449*fd9b697dSmlelstv 
450*fd9b697dSmlelstv struct vcprop_tag_setdpy {
451*fd9b697dSmlelstv 	struct vcprop_tag tag;
452*fd9b697dSmlelstv 	uint32_t display_num;
453*fd9b697dSmlelstv };
454*fd9b697dSmlelstv 
4558ae37694Smacallan struct vcprop_tag_cursorinfo {
4568ae37694Smacallan 	struct vcprop_tag tag;
4578ae37694Smacallan 	uint32_t width;
4588ae37694Smacallan 	uint32_t height;
459b149c9dcSmacallan 	uint32_t format;
4606a85f858Smacallan 	uint32_t pixels;	/* bus address in VC memory */
4618ae37694Smacallan 	uint32_t hotspot_x;
4628ae37694Smacallan 	uint32_t hotspot_y;
4638ae37694Smacallan };
4648ae37694Smacallan 
4658ae37694Smacallan struct vcprop_tag_cursorstate {
4668ae37694Smacallan 	struct vcprop_tag tag;
4678ae37694Smacallan 	uint32_t enable;	/* 1 - visible */
4688ae37694Smacallan 	uint32_t x;
4698ae37694Smacallan 	uint32_t y;
4708ae37694Smacallan 	uint32_t flags;		/* 0 - display coord. 1 - fb coord. */
4718ae37694Smacallan };
4728ae37694Smacallan 
4736a85f858Smacallan struct vcprop_tag_allocmem {
4746a85f858Smacallan 	struct vcprop_tag tag;
4756a85f858Smacallan 	uint32_t size;	/* handle returned here */
4766a85f858Smacallan 	uint32_t align;
4776a85f858Smacallan 	uint32_t flags;
4786a85f858Smacallan /*
4796a85f858Smacallan  * flag definitions from
4806a85f858Smacallan  * https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
4816a85f858Smacallan  */
4826a85f858Smacallan #define MEM_FLAG_DISCARDABLE	(1 << 0) /* can be resized to 0 at any time. Use for cached data */
4836a85f858Smacallan #define MEM_FLAG_NORMAL		(0 << 2) /* normal allocating alias. Don't use from ARM */
4846a85f858Smacallan #define MEM_FLAG_DIRECT		(1 << 2) /* 0xC alias uncached */
4856a85f858Smacallan #define MEM_FLAG_COHERENT	(2 << 2) /* 0x8 alias. Non-allocating in L2 but coherent */
4866a85f858Smacallan #define MEM_FLAG_L1_NONALLOCATING (MEM_FLAG_DIRECT | MEM_FLAG_COHERENT) /* Allocating in L2 */
4876a85f858Smacallan #define MEM_FLAG_ZERO		(1 << 4)  /* initialise buffer to all zeros */
4886a85f858Smacallan #define MEM_FLAG_NO_INIT	(1 << 5) /* don't initialise (default is initialise to all ones */
4896a85f858Smacallan #define MEM_FLAG_HINT_PERMALOCK	(1 << 6) /* Likely to be locked for long periods of time. */
4906a85f858Smacallan };
4916a85f858Smacallan 
4926a85f858Smacallan /* also for unlock and release */
4936a85f858Smacallan struct vcprop_tag_lockmem {
4946a85f858Smacallan 	struct vcprop_tag tag;
4956a85f858Smacallan 	uint32_t handle;	/* bus address returned here */
4966a85f858Smacallan };
4976a85f858Smacallan 
498*fd9b697dSmlelstv struct vcprop_tag_vchiqinit {
499*fd9b697dSmlelstv 	struct vcprop_tag tag;
500*fd9b697dSmlelstv 	uint32_t base;
501*fd9b697dSmlelstv };
502*fd9b697dSmlelstv 
503*fd9b697dSmlelstv struct vcprop_tag_notifyxhcireset {
504*fd9b697dSmlelstv 	struct vcprop_tag tag;
505*fd9b697dSmlelstv 	uint32_t deviceaddress;
506*fd9b697dSmlelstv };
507*fd9b697dSmlelstv 
508697a2ce9Sskrll struct vcprop_buffer_hdr {
509697a2ce9Sskrll 	uint32_t vpb_len;
510697a2ce9Sskrll 	uint32_t vpb_rcode;
511697a2ce9Sskrll #define	VCPROP_PROCESS_REQUEST 0
512697a2ce9Sskrll #define VCPROP_REQ_SUCCESS	(1U << 31)
513697a2ce9Sskrll #define VCPROP_REQ_EPARSE	(1U << 0)
514697a2ce9Sskrll };
515697a2ce9Sskrll 
516697a2ce9Sskrll static inline bool
vcprop_buffer_success_p(struct vcprop_buffer_hdr * vpbh)517697a2ce9Sskrll vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
518697a2ce9Sskrll {
519697a2ce9Sskrll 
5204a4535adSrin 	return le32toh(vpbh->vpb_rcode) & VCPROP_REQ_SUCCESS;
521697a2ce9Sskrll }
522697a2ce9Sskrll 
523697a2ce9Sskrll static inline bool
vcprop_tag_success_p(struct vcprop_tag * vpbt)524697a2ce9Sskrll vcprop_tag_success_p(struct vcprop_tag *vpbt)
525697a2ce9Sskrll {
526697a2ce9Sskrll 
5274a4535adSrin 	return le32toh(vpbt->vpt_rcode) & VCPROPTAG_RESPONSE;
528697a2ce9Sskrll }
529697a2ce9Sskrll 
530697a2ce9Sskrll static inline size_t
vcprop_tag_resplen(struct vcprop_tag * vpbt)531697a2ce9Sskrll vcprop_tag_resplen(struct vcprop_tag *vpbt)
532697a2ce9Sskrll {
533697a2ce9Sskrll 
5344a4535adSrin 	return le32toh(vpbt->vpt_rcode) & ~VCPROPTAG_RESPONSE;
535697a2ce9Sskrll }
536697a2ce9Sskrll 
537b149c9dcSmacallan uint32_t rpi_alloc_mem(uint32_t, uint32_t, uint32_t);
538b149c9dcSmacallan bus_addr_t rpi_lock_mem(uint32_t);
539b149c9dcSmacallan int rpi_unlock_mem(uint32_t);
540b149c9dcSmacallan int rpi_release_mem(uint32_t);
541b149c9dcSmacallan 
542b149c9dcSmacallan int rpi_fb_set_video(int);
543b149c9dcSmacallan 
544b149c9dcSmacallan int rpi_fb_movecursor(int, int, int);
545b149c9dcSmacallan int rpi_fb_initcursor(bus_addr_t, int, int);
546*fd9b697dSmlelstv 
547*fd9b697dSmlelstv int rpi_fb_set_pixelorder(uint32_t);
548*fd9b697dSmlelstv int rpi_fb_get_pixelorder(uint32_t *);
549*fd9b697dSmlelstv 
550*fd9b697dSmlelstv int rpi_set_domain(uint32_t, uint32_t);
551*fd9b697dSmlelstv int rpi_get_domain(uint32_t, uint32_t *);
552*fd9b697dSmlelstv 
553*fd9b697dSmlelstv int rpi_vchiq_init(uint32_t *);
554*fd9b697dSmlelstv 
555*fd9b697dSmlelstv int rpi_notify_xhci_reset(uint32_t);
556*fd9b697dSmlelstv 
557*fd9b697dSmlelstv #endif	/* _EVBARM_RPI_VCPROP_H_ */
558*fd9b697dSmlelstv 
559