Home | History | Annotate | Line # | Download | only in rpi
vcprop.h revision 1.4
      1 /*	$NetBSD: vcprop.h,v 1.4 2013/01/07 22:32:24 jmcneill 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 struct vcprop_tag {
     40 	uint32_t vpt_tag;
     41 #define	VCPROPTAG_NULL			0x00000000
     42 #define	VCPROPTAG_GET_FIRMWAREREV	0x00000001
     43 #define	VCPROPTAG_GET_BOARDMODEL	0x00010001
     44 #define	VCPROPTAG_GET_BOARDREVISION	0x00010002
     45 #define	VCPROPTAG_GET_MACADDRESS	0x00010003
     46 #define	VCPROPTAG_GET_BOARDSERIAL	0x00010004
     47 #define	VCPROPTAG_GET_ARMMEMORY		0x00010005
     48 #define	VCPROPTAG_GET_VCMEMORY		0x00010006
     49 #define	VCPROPTAG_GET_CLOCKS		0x00010007
     50 
     51 #define VCPROPTAG_GET_POWERSTATE	0x00020001
     52 #define VCPROPTAG_GET_POWERTIMING	0x00020002
     53 #define VCPROPTAG_SET_POWERSTATE	0x00028001
     54 
     55 #define	VCPROPTAG_GET_CLOCKSTATE	0x00030001
     56 #define	VCPROPTAG_SET_CLOCKSTATE	0x00038001
     57 #define	VCPROPTAG_GET_CLOCKRATE		0x00030002
     58 #define	VCPROPTAG_SET_CLOCKRATE		0x00038002
     59 #define	VCPROPTAG_GET_MIN_CLOCKRATE	0x00030007
     60 #define	VCPROPTAG_GET_MAX_CLOCKRATE	0x00030004
     61 
     62 #define VCPROPTAG_GET_VOLTAGE		0x00030003
     63 #define VCPROPTAG_SET_VOLTAGE		0x00038003
     64 #define VCPROPTAG_GET_MIN_VOLTAGE	0x00030008
     65 #define VCPROPTAG_GET_MAX_VOLTAGE	0x00030005
     66 
     67 #define VCPROPTAG_GET_TEMPERATURE	0x00030006
     68 #define VCPROPTAG_GET_MAX_TEMPERATURE	0x0003000a
     69 
     70 #define	VCPROPTAG_GET_CMDLINE		0x00050001
     71 #define	VCPROPTAG_GET_DMACHAN		0x00060001
     72 	uint32_t vpt_len;
     73 	uint32_t vpt_rcode;
     74 #define	VCPROPTAG_REQUEST	(0U << 31)
     75 #define	VCPROPTAG_RESPONSE	(1U << 31)
     76 
     77 };
     78 
     79 #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
     80 
     81 struct vcprop_memory {
     82 	uint32_t base;
     83 	uint32_t size;
     84 };
     85 
     86 #define	VCPROP_MAXMEMBLOCKS 4
     87 struct vcprop_tag_memory {
     88 	struct vcprop_tag tag;
     89 	struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
     90 };
     91 
     92 struct vcprop_tag_fwrev {
     93 	struct vcprop_tag tag;
     94 	uint32_t rev;
     95 };
     96 
     97 struct vcprop_tag_boardmodel {
     98 	struct vcprop_tag tag;
     99 	uint32_t model;
    100 } ;
    101 
    102 struct vcprop_tag_boardrev {
    103 	struct vcprop_tag tag;
    104 	uint32_t rev;
    105 } ;
    106 
    107 struct vcprop_tag_macaddr {
    108 	struct vcprop_tag tag;
    109 	uint64_t addr;
    110 };
    111 
    112 struct vcprop_tag_boardserial {
    113 	struct vcprop_tag tag;
    114 	uint64_t sn;
    115 };
    116 
    117 #define	VCPROP_CLK_EMMC		1
    118 #define	VCPROP_CLK_UART		2
    119 #define	VCPROP_CLK_ARM		3
    120 #define	VCPROP_CLK_CORE		4
    121 #define	VCPROP_CLK_V3D		5
    122 #define	VCPROP_CLK_H264		6
    123 #define	VCPROP_CLK_ISP		7
    124 #define	VCPROP_CLK_SDRAM	8
    125 #define	VCPROP_CLK_PIXEL	9
    126 #define	VCPROP_CLK_PWM		10
    127 
    128 struct vcprop_clock {
    129 	uint32_t pclk;
    130 	uint32_t cclk;
    131 };
    132 
    133 #define	VCPROP_MAXCLOCKS 16
    134 struct vcprop_tag_clock {
    135 	struct vcprop_tag tag;
    136 	struct vcprop_clock clk[VCPROP_MAXCLOCKS];
    137 };
    138 
    139 #define	VCPROP_MAXCMDLINE 256
    140 struct vcprop_tag_cmdline {
    141 	struct vcprop_tag tag;
    142 	uint8_t cmdline[VCPROP_MAXCMDLINE];
    143 };
    144 
    145 struct vcprop_tag_dmachan {
    146 	struct vcprop_tag tag;
    147 	uint32_t mask;
    148 };
    149 
    150 struct vcprop_tag_clockstate {
    151 	struct vcprop_tag tag;
    152 	uint32_t id;
    153 	uint32_t state;
    154 };
    155 
    156 struct vcprop_tag_clockrate {
    157 	struct vcprop_tag tag;
    158 	uint32_t id;
    159 	uint32_t rate;
    160 };
    161 
    162 #define VCPROP_VOLTAGE_CORE	1
    163 #define VCPROP_VOLTAGE_SDRAM_C	2
    164 #define VCPROP_VOLTAGE_SDRAM_P	3
    165 #define VCPROP_VOLTAGE_SDRAM_I	4
    166 
    167 struct vcprop_tag_voltage {
    168 	struct vcprop_tag tag;
    169 	uint32_t id;
    170 	uint32_t value;
    171 };
    172 
    173 #define VCPROP_TEMP_SOC		0
    174 
    175 struct vcprop_tag_temperature {
    176 	struct vcprop_tag tag;
    177 	uint32_t id;
    178 	uint32_t value;
    179 };
    180 
    181 #define	VCPROP_POWER_SDCARD	0
    182 #define	VCPROP_POWER_UART0	1
    183 #define	VCPROP_POWER_UART1	2
    184 #define	VCPROP_POWER_USB	3
    185 #define	VCPROP_POWER_I2C0	4
    186 #define	VCPROP_POWER_I2C1	5
    187 #define	VCPROP_POWER_I2C2	6
    188 #define	VCPROP_POWER_SPI	7
    189 #define	VCPROP_POWER_CCP2TX	8
    190 
    191 struct vcprop_tag_powertiming {
    192 	struct vcprop_tag tag;
    193 	uint32_t id;
    194 	uint32_t waitusec;
    195 };
    196 
    197 struct vcprop_tag_powerstate {
    198 	struct vcprop_tag tag;
    199 	uint32_t id;
    200 	uint32_t state;
    201 };
    202 
    203 struct vcprop_buffer_hdr {
    204 	uint32_t vpb_len;
    205 	uint32_t vpb_rcode;
    206 #define	VCPROP_PROCESS_REQUEST 0
    207 #define VCPROP_REQ_SUCCESS	(1U << 31)
    208 #define VCPROP_REQ_EPARSE	(1U << 0)
    209 };
    210 
    211 static inline bool
    212 vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
    213 {
    214 
    215 	return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
    216 }
    217 
    218 static inline bool
    219 vcprop_tag_success_p(struct vcprop_tag *vpbt)
    220 {
    221 
    222 	return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
    223 }
    224 
    225 static inline size_t
    226 vcprop_tag_resplen(struct vcprop_tag *vpbt)
    227 {
    228 
    229 	return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
    230 }
    231 
    232 #endif	/* _EVBARM_RPI_VCPROP_H_ */
    233