Home | History | Annotate | Line # | Download | only in rpi
vcprop.h revision 1.1.2.3
      1 /*	$NetBSD: vcprop.h,v 1.1.2.3 2013/01/16 05:32:55 yamt 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_CLOCKSTATE	0x00030001
     52 #define	VCPROPTAG_SET_CLOCKSTATE	0x00038001
     53 #define	VCPROPTAG_GET_CLOCKRATE		0x00030002
     54 #define	VCPROPTAG_SET_CLOCKRATE		0x00038002
     55 
     56 #define	VCPROPTAG_GET_CMDLINE		0x00050001
     57 #define	VCPROPTAG_GET_DMACHAN		0x00060001
     58 	uint32_t vpt_len;
     59 	uint32_t vpt_rcode;
     60 #define	VCPROPTAG_REQUEST	(0U << 31)
     61 #define	VCPROPTAG_RESPONSE	(1U << 31)
     62 
     63 };
     64 
     65 #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
     66 
     67 struct vcprop_memory {
     68 	uint32_t base;
     69 	uint32_t size;
     70 };
     71 
     72 #define	VCPROP_MAXMEMBLOCKS 4
     73 struct vcprop_tag_memory {
     74 	struct vcprop_tag tag;
     75 	struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
     76 };
     77 
     78 struct vcprop_tag_fwrev {
     79 	struct vcprop_tag tag;
     80 	uint32_t rev;
     81 };
     82 
     83 struct vcprop_tag_boardmodel {
     84 	struct vcprop_tag tag;
     85 	uint32_t model;
     86 } ;
     87 
     88 struct vcprop_tag_boardrev {
     89 	struct vcprop_tag tag;
     90 	uint32_t rev;
     91 } ;
     92 
     93 struct vcprop_tag_macaddr {
     94 	struct vcprop_tag tag;
     95 	uint64_t addr;
     96 };
     97 
     98 struct vcprop_tag_boardserial {
     99 	struct vcprop_tag tag;
    100 	uint64_t sn;
    101 };
    102 
    103 
    104 #define	VCPROP_CLK_EMMC		1
    105 #define	VCPROP_CLK_UART		2
    106 #define	VCPROP_CLK_ARM		3
    107 #define	VCPROP_CLK_CORE		4
    108 #define	VCPROP_CLK_V3D		5
    109 #define	VCPROP_CLK_H264		6
    110 #define	VCPROP_CLK_ISP		7
    111 #define	VCPROP_CLK_SDRAM	8
    112 #define	VCPROP_CLK_PIXEL	9
    113 #define	VCPROP_CLK_PWM		10
    114 
    115 struct vcprop_clock {
    116 	uint32_t pclk;
    117 	uint32_t cclk;
    118 };
    119 
    120 #define	VCPROP_MAXCLOCKS 16
    121 struct vcprop_tag_clock {
    122 	struct vcprop_tag tag;
    123 	struct vcprop_clock clk[VCPROP_MAXCLOCKS];
    124 };
    125 
    126 #define	VCPROP_MAXCMDLINE 256
    127 struct vcprop_tag_cmdline {
    128 	struct vcprop_tag tag;
    129 	uint8_t cmdline[VCPROP_MAXCMDLINE];
    130 };
    131 
    132 struct vcprop_tag_dmachan {
    133 	struct vcprop_tag tag;
    134 	uint32_t mask;
    135 };
    136 
    137 struct vcprop_tag_clockstate {
    138 	struct vcprop_tag tag;
    139 	uint32_t id;
    140 	uint32_t state;
    141 };
    142 
    143 struct vcprop_tag_clockrate {
    144 	struct vcprop_tag tag;
    145 	uint32_t id;
    146 	uint32_t rate;
    147 };
    148 
    149 struct vcprop_buffer_hdr {
    150 	uint32_t vpb_len;
    151 	uint32_t vpb_rcode;
    152 #define	VCPROP_PROCESS_REQUEST 0
    153 #define VCPROP_REQ_SUCCESS	(1U << 31)
    154 #define VCPROP_REQ_EPARSE	(1U << 0)
    155 };
    156 
    157 static inline bool
    158 vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
    159 {
    160 
    161 	return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
    162 }
    163 
    164 static inline bool
    165 vcprop_tag_success_p(struct vcprop_tag *vpbt)
    166 {
    167 
    168 	return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
    169 }
    170 
    171 static inline size_t
    172 vcprop_tag_resplen(struct vcprop_tag *vpbt)
    173 {
    174 
    175 	return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
    176 }
    177 
    178 #endif	/* _EVBARM_RPI_VCPROP_H_ */
    179