Home | History | Annotate | Line # | Download | only in rpi
vcprop.h revision 1.9.2.1
      1 /*	$NetBSD: vcprop.h,v 1.9.2.1 2017/07/26 15:22:37 snj Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2012 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Nick Hudson
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Mailbox property interface
     34  */
     35 
     36 #ifndef	_EVBARM_RPI_VCPROP_H_
     37 #define	_EVBARM_RPI_VCPROP_H_
     38 
     39 #include "opt_vcprop.h"
     40 
     41 struct vcprop_tag {
     42 	uint32_t vpt_tag;
     43 #define	VCPROPTAG_NULL			0x00000000
     44 #define	VCPROPTAG_GET_FIRMWAREREV	0x00000001
     45 #define	VCPROPTAG_GET_BOARDMODEL	0x00010001
     46 #define	VCPROPTAG_GET_BOARDREVISION	0x00010002
     47 #define	VCPROPTAG_GET_MACADDRESS	0x00010003
     48 #define	VCPROPTAG_GET_BOARDSERIAL	0x00010004
     49 #define	VCPROPTAG_GET_ARMMEMORY		0x00010005
     50 #define	VCPROPTAG_GET_VCMEMORY		0x00010006
     51 #define	VCPROPTAG_GET_CLOCKS		0x00010007
     52 
     53 #define VCPROPTAG_GET_POWERSTATE	0x00020001
     54 #define VCPROPTAG_GET_POWERTIMING	0x00020002
     55 #define VCPROPTAG_SET_POWERSTATE	0x00028001
     56 
     57 #define	VCPROPTAG_GET_CLOCKSTATE	0x00030001
     58 #define	VCPROPTAG_SET_CLOCKSTATE	0x00038001
     59 #define	VCPROPTAG_GET_CLOCKRATE		0x00030002
     60 #define	VCPROPTAG_SET_CLOCKRATE		0x00038002
     61 #define	VCPROPTAG_GET_MIN_CLOCKRATE	0x00030007
     62 #define	VCPROPTAG_GET_MAX_CLOCKRATE	0x00030004
     63 
     64 #define VCPROPTAG_GET_VOLTAGE		0x00030003
     65 #define VCPROPTAG_SET_VOLTAGE		0x00038003
     66 #define VCPROPTAG_GET_MIN_VOLTAGE	0x00030008
     67 #define VCPROPTAG_GET_MAX_VOLTAGE	0x00030005
     68 
     69 #define VCPROPTAG_GET_TEMPERATURE	0x00030006
     70 #define VCPROPTAG_GET_MAX_TEMPERATURE	0x0003000a
     71 
     72 #define	VCPROPTAG_GET_CMDLINE		0x00050001
     73 #define	VCPROPTAG_GET_DMACHAN		0x00060001
     74 
     75 #define	VCPROPTAG_ALLOCATE_BUFFER	0x00040001
     76 #define	VCPROPTAG_BLANK_SCREEN		0x00040002
     77 #define	VCPROPTAG_GET_FB_RES		0x00040003
     78 #define	VCPROPTAG_SET_FB_RES		0x00048003
     79 #define	VCPROPTAG_GET_FB_VRES		0x00040004
     80 #define	VCPROPTAG_SET_FB_VRES		0x00048004
     81 #define	VCPROPTAG_GET_FB_DEPTH		0x00040005
     82 #define	VCPROPTAG_SET_FB_DEPTH		0x00048005
     83 #define	VCPROPTAG_GET_FB_PIXEL_ORDER	0x00040006
     84 #define	VCPROPTAG_SET_FB_PIXEL_ORDER	0x00048006
     85 #define	VCPROPTAG_GET_FB_ALPHA_MODE	0x00040007
     86 #define	VCPROPTAG_SET_FB_ALPHA_MODE	0x00048007
     87 #define	VCPROPTAG_GET_FB_PITCH		0x00040008
     88 
     89 #define	VCPROPTAG_GET_EDID_BLOCK	0x00030020
     90 
     91 
     92 	uint32_t vpt_len;
     93 	uint32_t vpt_rcode;
     94 #define	VCPROPTAG_REQUEST	(0U << 31)
     95 #define	VCPROPTAG_RESPONSE	(1U << 31)
     96 
     97 };
     98 
     99 #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
    100 
    101 struct vcprop_memory {
    102 	uint32_t base;
    103 	uint32_t size;
    104 };
    105 
    106 #define	VCPROP_MAXMEMBLOCKS 4
    107 struct vcprop_tag_memory {
    108 	struct vcprop_tag tag;
    109 	struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
    110 };
    111 
    112 struct vcprop_tag_fwrev {
    113 	struct vcprop_tag tag;
    114 	uint32_t rev;
    115 };
    116 
    117 struct vcprop_tag_boardmodel {
    118 	struct vcprop_tag tag;
    119 	uint32_t model;
    120 } ;
    121 
    122 struct vcprop_tag_boardrev {
    123 	struct vcprop_tag tag;
    124 	uint32_t rev;
    125 } ;
    126 
    127 #define	VCPROP_REV_PCBREV	__BITS(3,0)
    128 #define	VCPROP_REV_MODEL	__BITS(11,4)
    129 #define	 RPI_MODEL_A		0
    130 #define	 RPI_MODEL_B		1
    131 #define	 RPI_MODEL_A_PLUS	2
    132 #define	 RPI_MODEL_B_PLUS	3
    133 #define	 RPI_MODEL_B_PI2	4
    134 #define	 RPI_MODEL_ALPHA	5
    135 #define	 RPI_MODEL_COMPUTE	6
    136 #define	 RPI_MODEL_ZERO		7
    137 #define	 RPI_MODEL_B_PI3	8
    138 #define	 RPI_MODEL_COMPUTE_PI3	9
    139 #define	 RPI_MODEL_ZERO_W	10
    140 #define	VCPROP_REV_PROCESSOR	__BITS(15,12)
    141 #define	 RPI_PROCESSOR_BCM2835	0
    142 #define	 RPI_PROCESSOR_BCM2836	1
    143 #define	 RPI_PROCESSOR_BCM2837	2
    144 #define	VCPROP_REV_MANUF	__BITS(19,16)
    145 #define	VCPROP_REV_MEMSIZE	__BITS(22,20)
    146 #define	VCPROP_REV_ENCFLAG	__BIT(23)
    147 #define	VCPROP_REV_WARRANTY	__BITS(25,24)
    148 
    149 struct vcprop_tag_macaddr {
    150 	struct vcprop_tag tag;
    151 	uint64_t addr;
    152 } __packed;
    153 
    154 struct vcprop_tag_boardserial {
    155 	struct vcprop_tag tag;
    156 	uint64_t sn;
    157 } __packed;
    158 
    159 #define	VCPROP_CLK_EMMC		1
    160 #define	VCPROP_CLK_UART		2
    161 #define	VCPROP_CLK_ARM		3
    162 #define	VCPROP_CLK_CORE		4
    163 #define	VCPROP_CLK_V3D		5
    164 #define	VCPROP_CLK_H264		6
    165 #define	VCPROP_CLK_ISP		7
    166 #define	VCPROP_CLK_SDRAM	8
    167 #define	VCPROP_CLK_PIXEL	9
    168 #define	VCPROP_CLK_PWM		10
    169 
    170 struct vcprop_clock {
    171 	uint32_t pclk;
    172 	uint32_t cclk;
    173 };
    174 
    175 #define	VCPROP_MAXCLOCKS 16
    176 struct vcprop_tag_clock {
    177 	struct vcprop_tag tag;
    178 	struct vcprop_clock clk[VCPROP_MAXCLOCKS];
    179 };
    180 
    181 #ifndef	VCPROP_MAXCMDLINE
    182 #define	VCPROP_MAXCMDLINE 1024
    183 #endif
    184 struct vcprop_tag_cmdline {
    185 	struct vcprop_tag tag;
    186 	uint8_t cmdline[VCPROP_MAXCMDLINE];
    187 };
    188 
    189 struct vcprop_tag_dmachan {
    190 	struct vcprop_tag tag;
    191 	uint32_t mask;
    192 };
    193 
    194 struct vcprop_tag_clockstate {
    195 	struct vcprop_tag tag;
    196 	uint32_t id;
    197 	uint32_t state;
    198 };
    199 
    200 struct vcprop_tag_clockrate {
    201 	struct vcprop_tag tag;
    202 	uint32_t id;
    203 	uint32_t rate;
    204 };
    205 
    206 #define VCPROP_VOLTAGE_CORE	1
    207 #define VCPROP_VOLTAGE_SDRAM_C	2
    208 #define VCPROP_VOLTAGE_SDRAM_P	3
    209 #define VCPROP_VOLTAGE_SDRAM_I	4
    210 
    211 struct vcprop_tag_voltage {
    212 	struct vcprop_tag tag;
    213 	uint32_t id;
    214 	uint32_t value;
    215 };
    216 
    217 #define VCPROP_TEMP_SOC		0
    218 
    219 struct vcprop_tag_temperature {
    220 	struct vcprop_tag tag;
    221 	uint32_t id;
    222 	uint32_t value;
    223 };
    224 
    225 #define	VCPROP_POWER_SDCARD	0
    226 #define	VCPROP_POWER_UART0	1
    227 #define	VCPROP_POWER_UART1	2
    228 #define	VCPROP_POWER_USB	3
    229 #define	VCPROP_POWER_I2C0	4
    230 #define	VCPROP_POWER_I2C1	5
    231 #define	VCPROP_POWER_I2C2	6
    232 #define	VCPROP_POWER_SPI	7
    233 #define	VCPROP_POWER_CCP2TX	8
    234 
    235 struct vcprop_tag_powertiming {
    236 	struct vcprop_tag tag;
    237 	uint32_t id;
    238 	uint32_t waitusec;
    239 };
    240 
    241 struct vcprop_tag_powerstate {
    242 	struct vcprop_tag tag;
    243 	uint32_t id;
    244 	uint32_t state;
    245 };
    246 
    247 struct vcprop_tag_allocbuf {
    248 	struct vcprop_tag tag;
    249 	uint32_t address;	/* alignment for request */
    250 	uint32_t size;
    251 };
    252 
    253 #define VCPROP_BLANK_OFF	0
    254 #define VCPROP_BLANK_ON		1
    255 
    256 struct vcprop_tag_blankscreen {
    257 	struct vcprop_tag tag;
    258 	uint32_t state;
    259 };
    260 
    261 struct vcprop_tag_fbres {
    262 	struct vcprop_tag tag;
    263 	uint32_t width;
    264 	uint32_t height;
    265 };
    266 
    267 struct vcprop_tag_fbdepth {
    268 	struct vcprop_tag tag;
    269 	uint32_t bpp;
    270 };
    271 
    272 #define VCPROP_PIXEL_BGR	0
    273 #define VCPROP_PIXEL_RGB	1
    274 
    275 struct vcprop_tag_fbpixelorder {
    276 	struct vcprop_tag tag;
    277 	uint32_t state;
    278 };
    279 
    280 struct vcprop_tag_fbpitch {
    281 	struct vcprop_tag tag;
    282 	uint32_t linebytes;
    283 };
    284 
    285 #define VCPROP_ALPHA_ENABLED	0
    286 #define VCPROP_ALPHA_REVERSED	1
    287 #define VCPROP_ALPHA_IGNORED	2
    288 
    289 struct vcprop_tag_fbalpha {
    290 	struct vcprop_tag tag;
    291 	uint32_t state;
    292 };
    293 
    294 struct vcprop_tag_edidblock {
    295 	struct vcprop_tag tag;
    296 	uint32_t blockno;
    297 	uint32_t status;
    298 	uint8_t data[128];
    299 };
    300 
    301 struct vcprop_buffer_hdr {
    302 	uint32_t vpb_len;
    303 	uint32_t vpb_rcode;
    304 #define	VCPROP_PROCESS_REQUEST 0
    305 #define VCPROP_REQ_SUCCESS	(1U << 31)
    306 #define VCPROP_REQ_EPARSE	(1U << 0)
    307 };
    308 
    309 static inline bool
    310 vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
    311 {
    312 
    313 	return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
    314 }
    315 
    316 static inline bool
    317 vcprop_tag_success_p(struct vcprop_tag *vpbt)
    318 {
    319 
    320 	return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
    321 }
    322 
    323 static inline size_t
    324 vcprop_tag_resplen(struct vcprop_tag *vpbt)
    325 {
    326 
    327 	return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
    328 }
    329 
    330 #endif	/* _EVBARM_RPI_VCPROP_H_ */
    331