vcprop.h revision 1.1.2.3 1 1.1.2.3 yamt /* $NetBSD: vcprop.h,v 1.1.2.3 2013/01/16 05:32:55 yamt Exp $ */
2 1.1.2.2 yamt
3 1.1.2.2 yamt /*-
4 1.1.2.2 yamt * Copyright (c) 2012 The NetBSD Foundation, Inc.
5 1.1.2.2 yamt * All rights reserved.
6 1.1.2.2 yamt *
7 1.1.2.2 yamt * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.2 yamt * by Nick Hudson
9 1.1.2.2 yamt *
10 1.1.2.2 yamt * Redistribution and use in source and binary forms, with or without
11 1.1.2.2 yamt * modification, are permitted provided that the following conditions
12 1.1.2.2 yamt * are met:
13 1.1.2.2 yamt * 1. Redistributions of source code must retain the above copyright
14 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer.
15 1.1.2.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer in the
17 1.1.2.2 yamt * documentation and/or other materials provided with the distribution.
18 1.1.2.2 yamt *
19 1.1.2.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1.2.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1.2.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1.2.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1.2.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1.2.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1.2.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1.2.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1.2.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1.2.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1.2.2 yamt * POSSIBILITY OF SUCH DAMAGE.
30 1.1.2.2 yamt */
31 1.1.2.2 yamt
32 1.1.2.2 yamt /*
33 1.1.2.2 yamt * Mailbox property interface
34 1.1.2.2 yamt */
35 1.1.2.2 yamt
36 1.1.2.2 yamt #ifndef _EVBARM_RPI_VCPROP_H_
37 1.1.2.2 yamt #define _EVBARM_RPI_VCPROP_H_
38 1.1.2.2 yamt
39 1.1.2.2 yamt struct vcprop_tag {
40 1.1.2.2 yamt uint32_t vpt_tag;
41 1.1.2.2 yamt #define VCPROPTAG_NULL 0x00000000
42 1.1.2.2 yamt #define VCPROPTAG_GET_FIRMWAREREV 0x00000001
43 1.1.2.2 yamt #define VCPROPTAG_GET_BOARDMODEL 0x00010001
44 1.1.2.2 yamt #define VCPROPTAG_GET_BOARDREVISION 0x00010002
45 1.1.2.2 yamt #define VCPROPTAG_GET_MACADDRESS 0x00010003
46 1.1.2.2 yamt #define VCPROPTAG_GET_BOARDSERIAL 0x00010004
47 1.1.2.2 yamt #define VCPROPTAG_GET_ARMMEMORY 0x00010005
48 1.1.2.2 yamt #define VCPROPTAG_GET_VCMEMORY 0x00010006
49 1.1.2.2 yamt #define VCPROPTAG_GET_CLOCKS 0x00010007
50 1.1.2.3 yamt
51 1.1.2.3 yamt #define VCPROPTAG_GET_CLOCKSTATE 0x00030001
52 1.1.2.3 yamt #define VCPROPTAG_SET_CLOCKSTATE 0x00038001
53 1.1.2.3 yamt #define VCPROPTAG_GET_CLOCKRATE 0x00030002
54 1.1.2.3 yamt #define VCPROPTAG_SET_CLOCKRATE 0x00038002
55 1.1.2.2 yamt
56 1.1.2.2 yamt #define VCPROPTAG_GET_CMDLINE 0x00050001
57 1.1.2.2 yamt #define VCPROPTAG_GET_DMACHAN 0x00060001
58 1.1.2.2 yamt uint32_t vpt_len;
59 1.1.2.2 yamt uint32_t vpt_rcode;
60 1.1.2.2 yamt #define VCPROPTAG_REQUEST (0U << 31)
61 1.1.2.2 yamt #define VCPROPTAG_RESPONSE (1U << 31)
62 1.1.2.2 yamt
63 1.1.2.2 yamt };
64 1.1.2.2 yamt
65 1.1.2.2 yamt #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
66 1.1.2.2 yamt
67 1.1.2.2 yamt struct vcprop_memory {
68 1.1.2.2 yamt uint32_t base;
69 1.1.2.2 yamt uint32_t size;
70 1.1.2.2 yamt };
71 1.1.2.2 yamt
72 1.1.2.2 yamt #define VCPROP_MAXMEMBLOCKS 4
73 1.1.2.2 yamt struct vcprop_tag_memory {
74 1.1.2.2 yamt struct vcprop_tag tag;
75 1.1.2.2 yamt struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
76 1.1.2.2 yamt };
77 1.1.2.2 yamt
78 1.1.2.2 yamt struct vcprop_tag_fwrev {
79 1.1.2.2 yamt struct vcprop_tag tag;
80 1.1.2.2 yamt uint32_t rev;
81 1.1.2.2 yamt };
82 1.1.2.2 yamt
83 1.1.2.2 yamt struct vcprop_tag_boardmodel {
84 1.1.2.2 yamt struct vcprop_tag tag;
85 1.1.2.2 yamt uint32_t model;
86 1.1.2.2 yamt } ;
87 1.1.2.2 yamt
88 1.1.2.2 yamt struct vcprop_tag_boardrev {
89 1.1.2.2 yamt struct vcprop_tag tag;
90 1.1.2.2 yamt uint32_t rev;
91 1.1.2.2 yamt } ;
92 1.1.2.2 yamt
93 1.1.2.2 yamt struct vcprop_tag_macaddr {
94 1.1.2.2 yamt struct vcprop_tag tag;
95 1.1.2.2 yamt uint64_t addr;
96 1.1.2.2 yamt };
97 1.1.2.2 yamt
98 1.1.2.2 yamt struct vcprop_tag_boardserial {
99 1.1.2.2 yamt struct vcprop_tag tag;
100 1.1.2.2 yamt uint64_t sn;
101 1.1.2.2 yamt };
102 1.1.2.2 yamt
103 1.1.2.3 yamt
104 1.1.2.3 yamt #define VCPROP_CLK_EMMC 1
105 1.1.2.3 yamt #define VCPROP_CLK_UART 2
106 1.1.2.3 yamt #define VCPROP_CLK_ARM 3
107 1.1.2.3 yamt #define VCPROP_CLK_CORE 4
108 1.1.2.3 yamt #define VCPROP_CLK_V3D 5
109 1.1.2.3 yamt #define VCPROP_CLK_H264 6
110 1.1.2.3 yamt #define VCPROP_CLK_ISP 7
111 1.1.2.3 yamt #define VCPROP_CLK_SDRAM 8
112 1.1.2.3 yamt #define VCPROP_CLK_PIXEL 9
113 1.1.2.3 yamt #define VCPROP_CLK_PWM 10
114 1.1.2.3 yamt
115 1.1.2.2 yamt struct vcprop_clock {
116 1.1.2.2 yamt uint32_t pclk;
117 1.1.2.2 yamt uint32_t cclk;
118 1.1.2.2 yamt };
119 1.1.2.2 yamt
120 1.1.2.2 yamt #define VCPROP_MAXCLOCKS 16
121 1.1.2.2 yamt struct vcprop_tag_clock {
122 1.1.2.2 yamt struct vcprop_tag tag;
123 1.1.2.2 yamt struct vcprop_clock clk[VCPROP_MAXCLOCKS];
124 1.1.2.2 yamt };
125 1.1.2.2 yamt
126 1.1.2.2 yamt #define VCPROP_MAXCMDLINE 256
127 1.1.2.2 yamt struct vcprop_tag_cmdline {
128 1.1.2.2 yamt struct vcprop_tag tag;
129 1.1.2.2 yamt uint8_t cmdline[VCPROP_MAXCMDLINE];
130 1.1.2.2 yamt };
131 1.1.2.2 yamt
132 1.1.2.2 yamt struct vcprop_tag_dmachan {
133 1.1.2.2 yamt struct vcprop_tag tag;
134 1.1.2.2 yamt uint32_t mask;
135 1.1.2.2 yamt };
136 1.1.2.2 yamt
137 1.1.2.3 yamt struct vcprop_tag_clockstate {
138 1.1.2.3 yamt struct vcprop_tag tag;
139 1.1.2.3 yamt uint32_t id;
140 1.1.2.3 yamt uint32_t state;
141 1.1.2.3 yamt };
142 1.1.2.3 yamt
143 1.1.2.3 yamt struct vcprop_tag_clockrate {
144 1.1.2.3 yamt struct vcprop_tag tag;
145 1.1.2.3 yamt uint32_t id;
146 1.1.2.3 yamt uint32_t rate;
147 1.1.2.3 yamt };
148 1.1.2.3 yamt
149 1.1.2.2 yamt struct vcprop_buffer_hdr {
150 1.1.2.2 yamt uint32_t vpb_len;
151 1.1.2.2 yamt uint32_t vpb_rcode;
152 1.1.2.2 yamt #define VCPROP_PROCESS_REQUEST 0
153 1.1.2.2 yamt #define VCPROP_REQ_SUCCESS (1U << 31)
154 1.1.2.2 yamt #define VCPROP_REQ_EPARSE (1U << 0)
155 1.1.2.2 yamt };
156 1.1.2.2 yamt
157 1.1.2.2 yamt static inline bool
158 1.1.2.2 yamt vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
159 1.1.2.2 yamt {
160 1.1.2.2 yamt
161 1.1.2.2 yamt return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
162 1.1.2.2 yamt }
163 1.1.2.2 yamt
164 1.1.2.2 yamt static inline bool
165 1.1.2.2 yamt vcprop_tag_success_p(struct vcprop_tag *vpbt)
166 1.1.2.2 yamt {
167 1.1.2.2 yamt
168 1.1.2.2 yamt return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
169 1.1.2.2 yamt }
170 1.1.2.2 yamt
171 1.1.2.2 yamt static inline size_t
172 1.1.2.2 yamt vcprop_tag_resplen(struct vcprop_tag *vpbt)
173 1.1.2.2 yamt {
174 1.1.2.2 yamt
175 1.1.2.2 yamt return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
176 1.1.2.2 yamt }
177 1.1.2.2 yamt
178 1.1.2.2 yamt #endif /* _EVBARM_RPI_VCPROP_H_ */
179