1 /*
2 * Copyright (c) 2014, Mentor Graphics Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. Neither the name of Mentor Graphics Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
30 /**************************************************************************
31 * FILE NAME
32 *
33 * platform_info.c
34 *
35 * DESCRIPTION
36 *
37 * This file implements APIs to get platform specific
38 * information for OpenAMP.
39 *
40 **************************************************************************/
42 #include <string.h>
43 #include "openamp/hil.h"
45 /* Reference implementation that show cases platform_get_cpu_info and
46 platform_get_for_firmware API implementation for Bare metal environment */
48 extern struct hil_platform_ops zynq_a9_proc_ops;
50 /* IPC Device parameters */
51 #define SHM_ADDR (void *)0x08008000
52 #define SHM_SIZE 0x00200000
53 #define VRING0_IPI_VECT 6
54 #define VRING1_IPI_VECT 3
55 #define MASTER_CPU_ID 0
56 #define REMOTE_CPU_ID 1
58 /**
59 * This array provdes defnition of CPU nodes for master and remote
60 * context. It contains two nodes beacuse the same file is intended
61 * to use with both master and remote configurations. On zynq platform
62 * only one node defintion is required for master/remote as there
63 * are only two cores present in the platform.
64 *
65 * Only platform specific info is populated here. Rest of information
66 * is obtained during resource table parsing.The platform specific
67 * information includes;
68 *
69 * -CPU ID
70 * -Shared Memory
71 * -Interrupts
72 * -Channel info.
73 *
74 * Although the channel info is not platform specific information
75 * but it is conveneient to keep it in HIL so that user can easily
76 * provide it without modifying the generic part.
77 *
78 * It is good idea to define hil_proc structure with platform
79 * specific fields populated as this can be easily copied to hil_proc
80 * structure passed as parameter in platform_get_processor_info. The
81 * other option is to populate the required structures individually
82 * and copy them one by one to hil_proc structure in platform_get_processor_info
83 * function. The first option is adopted here.
84 *
85 *
86 * 1) First node in the array is intended for the remote contexts and it
87 * defines Master CPU ID, shared memory, interrupts info, number of channels
88 * and there names. This node defines only one channel
89 * "rpmsg-openamp-demo-channel".
90 *
91 * 2)Second node is required by the master and it defines remote CPU ID,
92 * shared memory and interrupts info. In general no channel info is required by the
93 * Master node, however in baremetal master and linux remote case the linux
94 * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
95 * channel info. This information is not required by the masters for baremetal
96 * remotes.
97 *
98 */
99 struct hil_proc proc_table []=
100 {
101 {
102 /* CPU ID of remote */
103 REMOTE_CPU_ID,
105 /* Shared memory info - Last field is not used currently */
106 {
107 SHM_ADDR, SHM_SIZE, 0x00
108 },
110 /* VirtIO device info */
111 {
112 0, 0, 0,
113 {
114 {
115 /* Provide vring interrupts info here. Other fields are obtained
116 * from the rsc table so leave them empty.
117 */
118 NULL, NULL, 0, 0,
119 {
120 VRING0_IPI_VECT,0x1006,1
121 }
122 },
123 {
124 NULL, NULL, 0, 0,
125 {
126 VRING1_IPI_VECT,0x1006,1
127 }
128 }
129 }
130 },
132 /* Number of RPMSG channels */
133 1,
135 /* RPMSG channel info - Only channel name is expected currently */
136 {
137 {"rpmsg-openamp-demo-channel"}
138 },
140 /* HIL platform ops table. */
141 &zynq_a9_proc_ops,
143 /* Next three fields are for future use only */
144 0,
145 0,
146 NULL
147 }
148 };