1 /*
2 * Copyright (c) 2014, Mentor Graphics Corporation
3 * All rights reserved.
4 * Copyright (c) 2015 Xilinx, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * 3. Neither the name of Mentor Graphics Corporation nor the names of its
15 * contributors may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
31 /**************************************************************************
32 * FILE NAME
33 *
34 * platform_info.c
35 *
36 * DESCRIPTION
37 *
38 * This file implements APIs to get platform specific
39 * information for OpenAMP.
40 *
41 **************************************************************************/
43 #include "openamp/hil.h"
45 /* IPC Device parameters */
46 #define SHM_ADDR (void *)0x3ED08000
47 #define SHM_SIZE 0x00200000
48 #define IPI_BASEADDR 0xff310000
49 #define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
50 #define VRING0_IPI_INTR_VECT 0xFFFFFFFF
51 #define VRING1_IPI_INTR_VECT 65
52 #define MASTER_CPU_ID 0
53 #define REMOTE_CPU_ID 1
55 /* -- FIX ME: ipi info is to be defined -- */
56 struct ipi_info {
57 uint32_t ipi_base_addr;
58 uint32_t ipi_chn_mask;
59 };
60 /* Reference implementation that show cases platform_get_cpu_info and
61 platform_get_for_firmware API implementation for Bare metal environment */
63 extern struct hil_platform_ops proc_ops;
65 static struct ipi_info chn_ipi_info = { IPI_BASEADDR, IPI_CHN_BITMASK };
67 /**
68 * This array provdes defnition of CPU nodes for master and remote
69 * context. It contains two nodes beacuse the same file is intended
70 * to use with both master and remote configurations. On zynq platform
71 * only one node defintion is required for master/remote as there
72 * are only two cores present in the platform.
73 *
74 * Only platform specific info is populated here. Rest of information
75 * is obtained during resource table parsing.The platform specific
76 * information includes;
77 *
78 * -CPU ID
79 * -Shared Memory
80 * -Interrupts
81 * -Channel info.
82 *
83 * Although the channel info is not platform specific information
84 * but it is conveneient to keep it in HIL so that user can easily
85 * provide it without modifying the generic part.
86 *
87 * It is good idea to define hil_proc structure with platform
88 * specific fields populated as this can be easily copied to hil_proc
89 * structure passed as parameter in platform_get_processor_info. The
90 * other option is to populate the required structures individually
91 * and copy them one by one to hil_proc structure in platform_get_processor_info
92 * function. The first option is adopted here.
93 *
94 *
95 * 1) First node in the array is intended for the remote contexts and it
96 * defines Master CPU ID, shared memory, interrupts info, number of channels
97 * and there names. This node defines only one channel
98 * "rpmsg-openamp-demo-channel".
99 *
100 * 2)Second node is required by the master and it defines remote CPU ID,
101 * shared memory and interrupts info. In general no channel info is required by the
102 * Master node, however in baremetal master and linux remote case the linux
103 * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
104 * channel info. This information is not required by the masters for baremetal
105 * remotes.
106 *
107 */
109 struct hil_proc proc_table[] = {
111 /* CPU node for remote context */
112 {
113 /* CPU ID of master */
114 MASTER_CPU_ID,
116 /* Shared memory info - Last field is not used currently */
117 {
118 SHM_ADDR, SHM_SIZE, 0x00},
120 /* VirtIO device info */
121 {
122 /* Leave these three fields empty as these are obtained from rsc
123 * table.
124 */
125 0, 0, 0,
127 /* Vring info */
128 {
130 {
131 /* Provide only vring interrupts info here. Other fields are
132 * obtained from the resource table so leave them empty.
133 */
134 NULL, NULL, 0, 0,
135 {
136 VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
137 }
138 },
139 {
140 NULL, NULL, 0, 0,
141 {
142 VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
143 }
144 }
145 }
146 },
148 /* Number of RPMSG channels */
149 1,
151 /* RPMSG channel info - Only channel name is expected currently */
152 {
153 {"rpmsg-openamp-demo-channel"}
154 },
156 /* HIL platform ops table. */
157 &proc_ops,
159 /* Next three fields are for future use only */
160 0,
161 0,
162 NULL},
164 /* CPU node for remote context */
165 {
166 /* CPU ID of remote */
167 REMOTE_CPU_ID,
169 /* Shared memory info - Last field is not used currently */
170 {
171 SHM_ADDR, SHM_SIZE, 0x00},
173 /* VirtIO device info */
174 {
175 0, 0, 0,
176 {
177 {
178 /* Provide vring interrupts info here. Other fields are obtained
179 * from the rsc table so leave them empty.
180 */
181 NULL, NULL, 0, 0,
182 {
183 VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
184 }
185 },
186 {
187 NULL, NULL, 0, 0,
188 {
189 VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
190 }
191 }
192 }
193 },
195 /* Number of RPMSG channels */
196 1,
198 /* RPMSG channel info - Only channel name is expected currently */
199 {
200 {"rpmsg-openamp-demo-channel"}
201 },
203 /* HIL platform ops table. */
204 &proc_ops,
206 /* Next three fields are for future use only */
207 0,
208 0,
209 NULL}
210 };
212 const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);