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