Home | History | Annotate | Line # | Download | only in rpi
vcprop.h revision 1.9.2.1
      1  1.9.2.1       snj /*	$NetBSD: vcprop.h,v 1.9.2.1 2017/07/26 15:22:37 snj 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.9  jmcneill #include "opt_vcprop.h"
     40      1.9  jmcneill 
     41      1.1     skrll struct vcprop_tag {
     42      1.1     skrll 	uint32_t vpt_tag;
     43      1.1     skrll #define	VCPROPTAG_NULL			0x00000000
     44      1.1     skrll #define	VCPROPTAG_GET_FIRMWAREREV	0x00000001
     45      1.1     skrll #define	VCPROPTAG_GET_BOARDMODEL	0x00010001
     46      1.1     skrll #define	VCPROPTAG_GET_BOARDREVISION	0x00010002
     47      1.1     skrll #define	VCPROPTAG_GET_MACADDRESS	0x00010003
     48      1.1     skrll #define	VCPROPTAG_GET_BOARDSERIAL	0x00010004
     49      1.1     skrll #define	VCPROPTAG_GET_ARMMEMORY		0x00010005
     50      1.1     skrll #define	VCPROPTAG_GET_VCMEMORY		0x00010006
     51      1.1     skrll #define	VCPROPTAG_GET_CLOCKS		0x00010007
     52      1.2     skrll 
     53      1.3  jmcneill #define VCPROPTAG_GET_POWERSTATE	0x00020001
     54      1.3  jmcneill #define VCPROPTAG_GET_POWERTIMING	0x00020002
     55      1.3  jmcneill #define VCPROPTAG_SET_POWERSTATE	0x00028001
     56      1.3  jmcneill 
     57      1.2     skrll #define	VCPROPTAG_GET_CLOCKSTATE	0x00030001
     58      1.2     skrll #define	VCPROPTAG_SET_CLOCKSTATE	0x00038001
     59      1.2     skrll #define	VCPROPTAG_GET_CLOCKRATE		0x00030002
     60      1.2     skrll #define	VCPROPTAG_SET_CLOCKRATE		0x00038002
     61      1.4  jmcneill #define	VCPROPTAG_GET_MIN_CLOCKRATE	0x00030007
     62      1.4  jmcneill #define	VCPROPTAG_GET_MAX_CLOCKRATE	0x00030004
     63      1.3  jmcneill 
     64      1.3  jmcneill #define VCPROPTAG_GET_VOLTAGE		0x00030003
     65      1.3  jmcneill #define VCPROPTAG_SET_VOLTAGE		0x00038003
     66      1.3  jmcneill #define VCPROPTAG_GET_MIN_VOLTAGE	0x00030008
     67      1.3  jmcneill #define VCPROPTAG_GET_MAX_VOLTAGE	0x00030005
     68      1.3  jmcneill 
     69      1.3  jmcneill #define VCPROPTAG_GET_TEMPERATURE	0x00030006
     70      1.3  jmcneill #define VCPROPTAG_GET_MAX_TEMPERATURE	0x0003000a
     71      1.3  jmcneill 
     72      1.1     skrll #define	VCPROPTAG_GET_CMDLINE		0x00050001
     73      1.1     skrll #define	VCPROPTAG_GET_DMACHAN		0x00060001
     74      1.5  jmcneill 
     75      1.5  jmcneill #define	VCPROPTAG_ALLOCATE_BUFFER	0x00040001
     76      1.7  jmcneill #define	VCPROPTAG_BLANK_SCREEN		0x00040002
     77      1.5  jmcneill #define	VCPROPTAG_GET_FB_RES		0x00040003
     78      1.6  jmcneill #define	VCPROPTAG_SET_FB_RES		0x00048003
     79      1.7  jmcneill #define	VCPROPTAG_GET_FB_VRES		0x00040004
     80      1.7  jmcneill #define	VCPROPTAG_SET_FB_VRES		0x00048004
     81      1.5  jmcneill #define	VCPROPTAG_GET_FB_DEPTH		0x00040005
     82      1.6  jmcneill #define	VCPROPTAG_SET_FB_DEPTH		0x00048005
     83      1.5  jmcneill #define	VCPROPTAG_GET_FB_PIXEL_ORDER	0x00040006
     84      1.6  jmcneill #define	VCPROPTAG_SET_FB_PIXEL_ORDER	0x00048006
     85      1.7  jmcneill #define	VCPROPTAG_GET_FB_ALPHA_MODE	0x00040007
     86      1.7  jmcneill #define	VCPROPTAG_SET_FB_ALPHA_MODE	0x00048007
     87      1.5  jmcneill #define	VCPROPTAG_GET_FB_PITCH		0x00040008
     88      1.5  jmcneill 
     89      1.5  jmcneill #define	VCPROPTAG_GET_EDID_BLOCK	0x00030020
     90      1.5  jmcneill 
     91      1.5  jmcneill 
     92      1.1     skrll 	uint32_t vpt_len;
     93      1.1     skrll 	uint32_t vpt_rcode;
     94      1.1     skrll #define	VCPROPTAG_REQUEST	(0U << 31)
     95      1.1     skrll #define	VCPROPTAG_RESPONSE	(1U << 31)
     96      1.1     skrll 
     97      1.1     skrll };
     98      1.1     skrll 
     99      1.1     skrll #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
    100      1.1     skrll 
    101      1.1     skrll struct vcprop_memory {
    102      1.1     skrll 	uint32_t base;
    103      1.1     skrll 	uint32_t size;
    104      1.1     skrll };
    105      1.1     skrll 
    106      1.1     skrll #define	VCPROP_MAXMEMBLOCKS 4
    107      1.1     skrll struct vcprop_tag_memory {
    108      1.1     skrll 	struct vcprop_tag tag;
    109      1.1     skrll 	struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
    110      1.1     skrll };
    111      1.1     skrll 
    112      1.1     skrll struct vcprop_tag_fwrev {
    113      1.1     skrll 	struct vcprop_tag tag;
    114      1.1     skrll 	uint32_t rev;
    115      1.1     skrll };
    116      1.1     skrll 
    117      1.1     skrll struct vcprop_tag_boardmodel {
    118      1.1     skrll 	struct vcprop_tag tag;
    119      1.1     skrll 	uint32_t model;
    120      1.1     skrll } ;
    121      1.1     skrll 
    122      1.1     skrll struct vcprop_tag_boardrev {
    123      1.1     skrll 	struct vcprop_tag tag;
    124      1.1     skrll 	uint32_t rev;
    125      1.1     skrll } ;
    126      1.1     skrll 
    127  1.9.2.1       snj #define	VCPROP_REV_PCBREV	__BITS(3,0)
    128  1.9.2.1       snj #define	VCPROP_REV_MODEL	__BITS(11,4)
    129  1.9.2.1       snj #define	 RPI_MODEL_A		0
    130  1.9.2.1       snj #define	 RPI_MODEL_B		1
    131  1.9.2.1       snj #define	 RPI_MODEL_A_PLUS	2
    132  1.9.2.1       snj #define	 RPI_MODEL_B_PLUS	3
    133  1.9.2.1       snj #define	 RPI_MODEL_B_PI2	4
    134  1.9.2.1       snj #define	 RPI_MODEL_ALPHA	5
    135  1.9.2.1       snj #define	 RPI_MODEL_COMPUTE	6
    136  1.9.2.1       snj #define	 RPI_MODEL_ZERO		7
    137  1.9.2.1       snj #define	 RPI_MODEL_B_PI3	8
    138  1.9.2.1       snj #define	 RPI_MODEL_COMPUTE_PI3	9
    139  1.9.2.1       snj #define	 RPI_MODEL_ZERO_W	10
    140  1.9.2.1       snj #define	VCPROP_REV_PROCESSOR	__BITS(15,12)
    141  1.9.2.1       snj #define	 RPI_PROCESSOR_BCM2835	0
    142  1.9.2.1       snj #define	 RPI_PROCESSOR_BCM2836	1
    143  1.9.2.1       snj #define	 RPI_PROCESSOR_BCM2837	2
    144  1.9.2.1       snj #define	VCPROP_REV_MANUF	__BITS(19,16)
    145  1.9.2.1       snj #define	VCPROP_REV_MEMSIZE	__BITS(22,20)
    146  1.9.2.1       snj #define	VCPROP_REV_ENCFLAG	__BIT(23)
    147  1.9.2.1       snj #define	VCPROP_REV_WARRANTY	__BITS(25,24)
    148  1.9.2.1       snj 
    149      1.1     skrll struct vcprop_tag_macaddr {
    150      1.1     skrll 	struct vcprop_tag tag;
    151      1.1     skrll 	uint64_t addr;
    152      1.8     skrll } __packed;
    153      1.1     skrll 
    154      1.1     skrll struct vcprop_tag_boardserial {
    155      1.1     skrll 	struct vcprop_tag tag;
    156      1.1     skrll 	uint64_t sn;
    157      1.8     skrll } __packed;
    158      1.1     skrll 
    159      1.2     skrll #define	VCPROP_CLK_EMMC		1
    160      1.2     skrll #define	VCPROP_CLK_UART		2
    161      1.2     skrll #define	VCPROP_CLK_ARM		3
    162      1.2     skrll #define	VCPROP_CLK_CORE		4
    163      1.2     skrll #define	VCPROP_CLK_V3D		5
    164      1.2     skrll #define	VCPROP_CLK_H264		6
    165      1.2     skrll #define	VCPROP_CLK_ISP		7
    166      1.2     skrll #define	VCPROP_CLK_SDRAM	8
    167      1.2     skrll #define	VCPROP_CLK_PIXEL	9
    168      1.2     skrll #define	VCPROP_CLK_PWM		10
    169      1.2     skrll 
    170      1.1     skrll struct vcprop_clock {
    171      1.1     skrll 	uint32_t pclk;
    172      1.1     skrll 	uint32_t cclk;
    173      1.1     skrll };
    174      1.1     skrll 
    175      1.1     skrll #define	VCPROP_MAXCLOCKS 16
    176      1.1     skrll struct vcprop_tag_clock {
    177      1.1     skrll 	struct vcprop_tag tag;
    178      1.1     skrll 	struct vcprop_clock clk[VCPROP_MAXCLOCKS];
    179      1.1     skrll };
    180      1.1     skrll 
    181      1.9  jmcneill #ifndef	VCPROP_MAXCMDLINE
    182      1.9  jmcneill #define	VCPROP_MAXCMDLINE 1024
    183      1.9  jmcneill #endif
    184      1.1     skrll struct vcprop_tag_cmdline {
    185      1.1     skrll 	struct vcprop_tag tag;
    186      1.1     skrll 	uint8_t cmdline[VCPROP_MAXCMDLINE];
    187      1.1     skrll };
    188      1.1     skrll 
    189      1.1     skrll struct vcprop_tag_dmachan {
    190      1.1     skrll 	struct vcprop_tag tag;
    191      1.1     skrll 	uint32_t mask;
    192      1.1     skrll };
    193      1.1     skrll 
    194      1.2     skrll struct vcprop_tag_clockstate {
    195      1.2     skrll 	struct vcprop_tag tag;
    196      1.2     skrll 	uint32_t id;
    197      1.2     skrll 	uint32_t state;
    198      1.2     skrll };
    199      1.2     skrll 
    200      1.2     skrll struct vcprop_tag_clockrate {
    201      1.2     skrll 	struct vcprop_tag tag;
    202      1.2     skrll 	uint32_t id;
    203      1.2     skrll 	uint32_t rate;
    204      1.2     skrll };
    205      1.2     skrll 
    206      1.3  jmcneill #define VCPROP_VOLTAGE_CORE	1
    207      1.3  jmcneill #define VCPROP_VOLTAGE_SDRAM_C	2
    208      1.3  jmcneill #define VCPROP_VOLTAGE_SDRAM_P	3
    209      1.3  jmcneill #define VCPROP_VOLTAGE_SDRAM_I	4
    210      1.3  jmcneill 
    211      1.3  jmcneill struct vcprop_tag_voltage {
    212      1.3  jmcneill 	struct vcprop_tag tag;
    213      1.3  jmcneill 	uint32_t id;
    214      1.3  jmcneill 	uint32_t value;
    215      1.3  jmcneill };
    216      1.3  jmcneill 
    217      1.3  jmcneill #define VCPROP_TEMP_SOC		0
    218      1.3  jmcneill 
    219      1.3  jmcneill struct vcprop_tag_temperature {
    220      1.3  jmcneill 	struct vcprop_tag tag;
    221      1.3  jmcneill 	uint32_t id;
    222      1.3  jmcneill 	uint32_t value;
    223      1.3  jmcneill };
    224      1.3  jmcneill 
    225      1.3  jmcneill #define	VCPROP_POWER_SDCARD	0
    226      1.3  jmcneill #define	VCPROP_POWER_UART0	1
    227      1.3  jmcneill #define	VCPROP_POWER_UART1	2
    228      1.3  jmcneill #define	VCPROP_POWER_USB	3
    229      1.3  jmcneill #define	VCPROP_POWER_I2C0	4
    230      1.3  jmcneill #define	VCPROP_POWER_I2C1	5
    231      1.3  jmcneill #define	VCPROP_POWER_I2C2	6
    232      1.3  jmcneill #define	VCPROP_POWER_SPI	7
    233      1.3  jmcneill #define	VCPROP_POWER_CCP2TX	8
    234      1.3  jmcneill 
    235      1.3  jmcneill struct vcprop_tag_powertiming {
    236      1.3  jmcneill 	struct vcprop_tag tag;
    237      1.3  jmcneill 	uint32_t id;
    238      1.3  jmcneill 	uint32_t waitusec;
    239      1.3  jmcneill };
    240      1.3  jmcneill 
    241      1.3  jmcneill struct vcprop_tag_powerstate {
    242      1.3  jmcneill 	struct vcprop_tag tag;
    243      1.3  jmcneill 	uint32_t id;
    244      1.3  jmcneill 	uint32_t state;
    245      1.3  jmcneill };
    246      1.3  jmcneill 
    247      1.5  jmcneill struct vcprop_tag_allocbuf {
    248      1.5  jmcneill 	struct vcprop_tag tag;
    249      1.5  jmcneill 	uint32_t address;	/* alignment for request */
    250      1.5  jmcneill 	uint32_t size;
    251      1.5  jmcneill };
    252      1.5  jmcneill 
    253      1.7  jmcneill #define VCPROP_BLANK_OFF	0
    254      1.7  jmcneill #define VCPROP_BLANK_ON		1
    255      1.7  jmcneill 
    256      1.7  jmcneill struct vcprop_tag_blankscreen {
    257      1.7  jmcneill 	struct vcprop_tag tag;
    258      1.7  jmcneill 	uint32_t state;
    259      1.7  jmcneill };
    260      1.7  jmcneill 
    261      1.5  jmcneill struct vcprop_tag_fbres {
    262      1.5  jmcneill 	struct vcprop_tag tag;
    263      1.5  jmcneill 	uint32_t width;
    264      1.5  jmcneill 	uint32_t height;
    265      1.5  jmcneill };
    266      1.5  jmcneill 
    267      1.5  jmcneill struct vcprop_tag_fbdepth {
    268      1.5  jmcneill 	struct vcprop_tag tag;
    269      1.5  jmcneill 	uint32_t bpp;
    270      1.5  jmcneill };
    271      1.5  jmcneill 
    272      1.5  jmcneill #define VCPROP_PIXEL_BGR	0
    273      1.5  jmcneill #define VCPROP_PIXEL_RGB	1
    274      1.5  jmcneill 
    275      1.5  jmcneill struct vcprop_tag_fbpixelorder {
    276      1.5  jmcneill 	struct vcprop_tag tag;
    277      1.5  jmcneill 	uint32_t state;
    278      1.5  jmcneill };
    279      1.5  jmcneill 
    280      1.5  jmcneill struct vcprop_tag_fbpitch {
    281      1.5  jmcneill 	struct vcprop_tag tag;
    282      1.5  jmcneill 	uint32_t linebytes;
    283      1.5  jmcneill };
    284      1.5  jmcneill 
    285      1.7  jmcneill #define VCPROP_ALPHA_ENABLED	0
    286      1.7  jmcneill #define VCPROP_ALPHA_REVERSED	1
    287      1.7  jmcneill #define VCPROP_ALPHA_IGNORED	2
    288      1.7  jmcneill 
    289      1.7  jmcneill struct vcprop_tag_fbalpha {
    290      1.7  jmcneill 	struct vcprop_tag tag;
    291      1.7  jmcneill 	uint32_t state;
    292      1.7  jmcneill };
    293      1.7  jmcneill 
    294      1.5  jmcneill struct vcprop_tag_edidblock {
    295      1.5  jmcneill 	struct vcprop_tag tag;
    296      1.5  jmcneill 	uint32_t blockno;
    297      1.5  jmcneill 	uint32_t status;
    298      1.5  jmcneill 	uint8_t data[128];
    299      1.5  jmcneill };
    300      1.5  jmcneill 
    301      1.1     skrll struct vcprop_buffer_hdr {
    302      1.1     skrll 	uint32_t vpb_len;
    303      1.1     skrll 	uint32_t vpb_rcode;
    304      1.1     skrll #define	VCPROP_PROCESS_REQUEST 0
    305      1.1     skrll #define VCPROP_REQ_SUCCESS	(1U << 31)
    306      1.1     skrll #define VCPROP_REQ_EPARSE	(1U << 0)
    307      1.1     skrll };
    308      1.1     skrll 
    309      1.1     skrll static inline bool
    310      1.1     skrll vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
    311      1.1     skrll {
    312      1.1     skrll 
    313      1.1     skrll 	return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
    314      1.1     skrll }
    315      1.1     skrll 
    316      1.1     skrll static inline bool
    317      1.1     skrll vcprop_tag_success_p(struct vcprop_tag *vpbt)
    318      1.1     skrll {
    319      1.1     skrll 
    320      1.1     skrll 	return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
    321      1.1     skrll }
    322      1.1     skrll 
    323      1.1     skrll static inline size_t
    324      1.1     skrll vcprop_tag_resplen(struct vcprop_tag *vpbt)
    325      1.1     skrll {
    326      1.1     skrll 
    327      1.1     skrll 	return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
    328      1.1     skrll }
    329      1.1     skrll 
    330      1.1     skrll #endif	/* _EVBARM_RPI_VCPROP_H_ */
    331