Home | History | Annotate | Line # | Download | only in rpi
vcprop.h revision 1.5
      1  1.5  jmcneill /*	$NetBSD: vcprop.h,v 1.5 2013/01/08 10:23:50 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.4  jmcneill #define	VCPROPTAG_GET_MIN_CLOCKRATE	0x00030007
     60  1.4  jmcneill #define	VCPROPTAG_GET_MAX_CLOCKRATE	0x00030004
     61  1.3  jmcneill 
     62  1.3  jmcneill #define VCPROPTAG_GET_VOLTAGE		0x00030003
     63  1.3  jmcneill #define VCPROPTAG_SET_VOLTAGE		0x00038003
     64  1.3  jmcneill #define VCPROPTAG_GET_MIN_VOLTAGE	0x00030008
     65  1.3  jmcneill #define VCPROPTAG_GET_MAX_VOLTAGE	0x00030005
     66  1.3  jmcneill 
     67  1.3  jmcneill #define VCPROPTAG_GET_TEMPERATURE	0x00030006
     68  1.3  jmcneill #define VCPROPTAG_GET_MAX_TEMPERATURE	0x0003000a
     69  1.3  jmcneill 
     70  1.1     skrll #define	VCPROPTAG_GET_CMDLINE		0x00050001
     71  1.1     skrll #define	VCPROPTAG_GET_DMACHAN		0x00060001
     72  1.5  jmcneill 
     73  1.5  jmcneill #define	VCPROPTAG_ALLOCATE_BUFFER	0x00040001
     74  1.5  jmcneill #define	VCPROPTAG_GET_FB_RES		0x00040003
     75  1.5  jmcneill #define	VCPROPTAG_GET_FB_DEPTH		0x00040005
     76  1.5  jmcneill #define	VCPROPTAG_GET_FB_PIXEL_ORDER	0x00040006
     77  1.5  jmcneill #define	VCPROPTAG_GET_FB_PITCH		0x00040008
     78  1.5  jmcneill 
     79  1.5  jmcneill #define	VCPROPTAG_GET_EDID_BLOCK	0x00030020
     80  1.5  jmcneill 
     81  1.5  jmcneill 
     82  1.1     skrll 	uint32_t vpt_len;
     83  1.1     skrll 	uint32_t vpt_rcode;
     84  1.1     skrll #define	VCPROPTAG_REQUEST	(0U << 31)
     85  1.1     skrll #define	VCPROPTAG_RESPONSE	(1U << 31)
     86  1.1     skrll 
     87  1.1     skrll };
     88  1.1     skrll 
     89  1.1     skrll #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
     90  1.1     skrll 
     91  1.1     skrll struct vcprop_memory {
     92  1.1     skrll 	uint32_t base;
     93  1.1     skrll 	uint32_t size;
     94  1.1     skrll };
     95  1.1     skrll 
     96  1.1     skrll #define	VCPROP_MAXMEMBLOCKS 4
     97  1.1     skrll struct vcprop_tag_memory {
     98  1.1     skrll 	struct vcprop_tag tag;
     99  1.1     skrll 	struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
    100  1.1     skrll };
    101  1.1     skrll 
    102  1.1     skrll struct vcprop_tag_fwrev {
    103  1.1     skrll 	struct vcprop_tag tag;
    104  1.1     skrll 	uint32_t rev;
    105  1.1     skrll };
    106  1.1     skrll 
    107  1.1     skrll struct vcprop_tag_boardmodel {
    108  1.1     skrll 	struct vcprop_tag tag;
    109  1.1     skrll 	uint32_t model;
    110  1.1     skrll } ;
    111  1.1     skrll 
    112  1.1     skrll struct vcprop_tag_boardrev {
    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_macaddr {
    118  1.1     skrll 	struct vcprop_tag tag;
    119  1.1     skrll 	uint64_t addr;
    120  1.1     skrll };
    121  1.1     skrll 
    122  1.1     skrll struct vcprop_tag_boardserial {
    123  1.1     skrll 	struct vcprop_tag tag;
    124  1.1     skrll 	uint64_t sn;
    125  1.1     skrll };
    126  1.1     skrll 
    127  1.2     skrll #define	VCPROP_CLK_EMMC		1
    128  1.2     skrll #define	VCPROP_CLK_UART		2
    129  1.2     skrll #define	VCPROP_CLK_ARM		3
    130  1.2     skrll #define	VCPROP_CLK_CORE		4
    131  1.2     skrll #define	VCPROP_CLK_V3D		5
    132  1.2     skrll #define	VCPROP_CLK_H264		6
    133  1.2     skrll #define	VCPROP_CLK_ISP		7
    134  1.2     skrll #define	VCPROP_CLK_SDRAM	8
    135  1.2     skrll #define	VCPROP_CLK_PIXEL	9
    136  1.2     skrll #define	VCPROP_CLK_PWM		10
    137  1.2     skrll 
    138  1.1     skrll struct vcprop_clock {
    139  1.1     skrll 	uint32_t pclk;
    140  1.1     skrll 	uint32_t cclk;
    141  1.1     skrll };
    142  1.1     skrll 
    143  1.1     skrll #define	VCPROP_MAXCLOCKS 16
    144  1.1     skrll struct vcprop_tag_clock {
    145  1.1     skrll 	struct vcprop_tag tag;
    146  1.1     skrll 	struct vcprop_clock clk[VCPROP_MAXCLOCKS];
    147  1.1     skrll };
    148  1.1     skrll 
    149  1.1     skrll #define	VCPROP_MAXCMDLINE 256
    150  1.1     skrll struct vcprop_tag_cmdline {
    151  1.1     skrll 	struct vcprop_tag tag;
    152  1.1     skrll 	uint8_t cmdline[VCPROP_MAXCMDLINE];
    153  1.1     skrll };
    154  1.1     skrll 
    155  1.1     skrll struct vcprop_tag_dmachan {
    156  1.1     skrll 	struct vcprop_tag tag;
    157  1.1     skrll 	uint32_t mask;
    158  1.1     skrll };
    159  1.1     skrll 
    160  1.2     skrll struct vcprop_tag_clockstate {
    161  1.2     skrll 	struct vcprop_tag tag;
    162  1.2     skrll 	uint32_t id;
    163  1.2     skrll 	uint32_t state;
    164  1.2     skrll };
    165  1.2     skrll 
    166  1.2     skrll struct vcprop_tag_clockrate {
    167  1.2     skrll 	struct vcprop_tag tag;
    168  1.2     skrll 	uint32_t id;
    169  1.2     skrll 	uint32_t rate;
    170  1.2     skrll };
    171  1.2     skrll 
    172  1.3  jmcneill #define VCPROP_VOLTAGE_CORE	1
    173  1.3  jmcneill #define VCPROP_VOLTAGE_SDRAM_C	2
    174  1.3  jmcneill #define VCPROP_VOLTAGE_SDRAM_P	3
    175  1.3  jmcneill #define VCPROP_VOLTAGE_SDRAM_I	4
    176  1.3  jmcneill 
    177  1.3  jmcneill struct vcprop_tag_voltage {
    178  1.3  jmcneill 	struct vcprop_tag tag;
    179  1.3  jmcneill 	uint32_t id;
    180  1.3  jmcneill 	uint32_t value;
    181  1.3  jmcneill };
    182  1.3  jmcneill 
    183  1.3  jmcneill #define VCPROP_TEMP_SOC		0
    184  1.3  jmcneill 
    185  1.3  jmcneill struct vcprop_tag_temperature {
    186  1.3  jmcneill 	struct vcprop_tag tag;
    187  1.3  jmcneill 	uint32_t id;
    188  1.3  jmcneill 	uint32_t value;
    189  1.3  jmcneill };
    190  1.3  jmcneill 
    191  1.3  jmcneill #define	VCPROP_POWER_SDCARD	0
    192  1.3  jmcneill #define	VCPROP_POWER_UART0	1
    193  1.3  jmcneill #define	VCPROP_POWER_UART1	2
    194  1.3  jmcneill #define	VCPROP_POWER_USB	3
    195  1.3  jmcneill #define	VCPROP_POWER_I2C0	4
    196  1.3  jmcneill #define	VCPROP_POWER_I2C1	5
    197  1.3  jmcneill #define	VCPROP_POWER_I2C2	6
    198  1.3  jmcneill #define	VCPROP_POWER_SPI	7
    199  1.3  jmcneill #define	VCPROP_POWER_CCP2TX	8
    200  1.3  jmcneill 
    201  1.3  jmcneill struct vcprop_tag_powertiming {
    202  1.3  jmcneill 	struct vcprop_tag tag;
    203  1.3  jmcneill 	uint32_t id;
    204  1.3  jmcneill 	uint32_t waitusec;
    205  1.3  jmcneill };
    206  1.3  jmcneill 
    207  1.3  jmcneill struct vcprop_tag_powerstate {
    208  1.3  jmcneill 	struct vcprop_tag tag;
    209  1.3  jmcneill 	uint32_t id;
    210  1.3  jmcneill 	uint32_t state;
    211  1.3  jmcneill };
    212  1.3  jmcneill 
    213  1.5  jmcneill struct vcprop_tag_allocbuf {
    214  1.5  jmcneill 	struct vcprop_tag tag;
    215  1.5  jmcneill 	uint32_t address;	/* alignment for request */
    216  1.5  jmcneill 	uint32_t size;
    217  1.5  jmcneill };
    218  1.5  jmcneill 
    219  1.5  jmcneill struct vcprop_tag_fbres {
    220  1.5  jmcneill 	struct vcprop_tag tag;
    221  1.5  jmcneill 	uint32_t width;
    222  1.5  jmcneill 	uint32_t height;
    223  1.5  jmcneill };
    224  1.5  jmcneill 
    225  1.5  jmcneill struct vcprop_tag_fbdepth {
    226  1.5  jmcneill 	struct vcprop_tag tag;
    227  1.5  jmcneill 	uint32_t bpp;
    228  1.5  jmcneill };
    229  1.5  jmcneill 
    230  1.5  jmcneill #define VCPROP_PIXEL_BGR	0
    231  1.5  jmcneill #define VCPROP_PIXEL_RGB	1
    232  1.5  jmcneill 
    233  1.5  jmcneill struct vcprop_tag_fbpixelorder {
    234  1.5  jmcneill 	struct vcprop_tag tag;
    235  1.5  jmcneill 	uint32_t state;
    236  1.5  jmcneill };
    237  1.5  jmcneill 
    238  1.5  jmcneill struct vcprop_tag_fbpitch {
    239  1.5  jmcneill 	struct vcprop_tag tag;
    240  1.5  jmcneill 	uint32_t linebytes;
    241  1.5  jmcneill };
    242  1.5  jmcneill 
    243  1.5  jmcneill struct vcprop_tag_edidblock {
    244  1.5  jmcneill 	struct vcprop_tag tag;
    245  1.5  jmcneill 	uint32_t blockno;
    246  1.5  jmcneill 	uint32_t status;
    247  1.5  jmcneill 	uint8_t data[128];
    248  1.5  jmcneill };
    249  1.5  jmcneill 
    250  1.1     skrll struct vcprop_buffer_hdr {
    251  1.1     skrll 	uint32_t vpb_len;
    252  1.1     skrll 	uint32_t vpb_rcode;
    253  1.1     skrll #define	VCPROP_PROCESS_REQUEST 0
    254  1.1     skrll #define VCPROP_REQ_SUCCESS	(1U << 31)
    255  1.1     skrll #define VCPROP_REQ_EPARSE	(1U << 0)
    256  1.1     skrll };
    257  1.1     skrll 
    258  1.1     skrll static inline bool
    259  1.1     skrll vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
    260  1.1     skrll {
    261  1.1     skrll 
    262  1.1     skrll 	return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
    263  1.1     skrll }
    264  1.1     skrll 
    265  1.1     skrll static inline bool
    266  1.1     skrll vcprop_tag_success_p(struct vcprop_tag *vpbt)
    267  1.1     skrll {
    268  1.1     skrll 
    269  1.1     skrll 	return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
    270  1.1     skrll }
    271  1.1     skrll 
    272  1.1     skrll static inline size_t
    273  1.1     skrll vcprop_tag_resplen(struct vcprop_tag *vpbt)
    274  1.1     skrll {
    275  1.1     skrll 
    276  1.1     skrll 	return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
    277  1.1     skrll }
    278  1.1     skrll 
    279  1.1     skrll #endif	/* _EVBARM_RPI_VCPROP_H_ */
    280