Skip to content

Commit 6bcec8a

Browse files
committed
feat(platform): add support for beaglebone ai-64
Signed-off-by: puranikvinit <kvp933.vinit@gmail.com>
1 parent 61a7466 commit 6bcec8a

8 files changed

Lines changed: 217 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ platforms is presented below:
4747
- [x] Arm Fixed Virtual Platforms
4848
- [x] Toradex Verdin iMX8M Plus (w/ Dahlia Carrier Board)
4949
- [ ] NXP S32G
50+
- [x] BeagleBone AI-64
5051

5152
**Armv7-A / Armv8-A AArch32**
5253
- [x] Arm Fixed Virtual Platforms
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/**
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright (c) Bao Project and Contributors. All rights reserved.
4+
*/
5+
6+
#include <platform.h>
7+
8+
struct platform platform = {
9+
.cpu_num = 2,
10+
.region_num = 2,
11+
.regions =
12+
(struct mem_region[]){
13+
{
14+
.base = 0x80000000,
15+
.size = 0x80000000,
16+
},
17+
{
18+
.base = 0x880000000,
19+
.size = 0x80000000,
20+
},
21+
},
22+
.console =
23+
{
24+
.base = 0x02800000,
25+
},
26+
.arch =
27+
{
28+
.gic =
29+
{
30+
.gicd_addr = 0x01800000,
31+
.gicr_addr = 0x01900000,
32+
.gicc_addr = 0x6f000000,
33+
.gich_addr = 0x6f010000,
34+
.gicv_addr = 0x6f020000,
35+
.maintenance_id = 25,
36+
},
37+
},
38+
};
39+
40+
#ifndef GENERATING_DEFS
41+
42+
static mbox_k3_sec_proxy_thread_desc sec_proxy_thread_desc[] = {
43+
MBOX_K3_SEC_PROXY_THREAD_DESC_ENTRY(J721E_HOST_ID_MAIN_A72_CONTEXT_0_SECURE, 0, 2, 30, 10, 20),
44+
MBOX_K3_SEC_PROXY_THREAD_DESC_ENTRY(J721E_HOST_ID_MAIN_A72_CONTEXT_1_SECURE, 5, 2, 30, 10, 20),
45+
MBOX_K3_SEC_PROXY_THREAD_DESC_ENTRY(J721E_HOST_ID_MAIN_A72_CONTEXT_2_NON_SECURE, 10, 2, 22, 2,
46+
20),
47+
MBOX_K3_SEC_PROXY_THREAD_DESC_ENTRY(J721E_HOST_ID_MAIN_A72_CONTEXT_3_NON_SECURE, 15, 2, 7, 2, 5),
48+
MBOX_K3_SEC_PROXY_THREAD_DESC_ENTRY(J721E_HOST_ID_MAIN_A72_CONTEXT_4_NON_SECURE, 20, 2, 7, 2, 5),
49+
MBOX_K3_SEC_PROXY_THREAD_DESC_ENTRY(J721E_HOST_ID_MAIN_A72_CONTEXT_5_NON_SECURE, 55, 2, 7, 2, 5),
50+
};
51+
52+
static mbox_k3_sec_proxy_desc k3_sec_proxy = {
53+
.thread_inst =
54+
{
55+
.id = 0U,
56+
.rt_base = 0x0032400000U,
57+
.rt_size = 0x100000U,
58+
.scfg_base = 0x0032800000U,
59+
.scfg_size = 0x100000U,
60+
.data_base = 0x0032C00000,
61+
.data_size = 0x100000,
62+
.max_msg_size = TISCI_MSG_MAX_SIZE,
63+
},
64+
.read_timeout_us = TISCI_MSG_TXN_TIMEOUT,
65+
.sec_proxy_thread_desc = sec_proxy_thread_desc,
66+
.num_threads = sizeof(sec_proxy_thread_desc) / sizeof(sec_proxy_thread_desc[0]),
67+
};
68+
69+
static int32_t platform_tisci_send(uint8_t chan_id, void* buffer, size_t len)
70+
{
71+
return mbox_k3_sec_proxy_write(&k3_sec_proxy, chan_id, buffer, len);
72+
}
73+
74+
static int32_t platform_tisci_recv(uint8_t chan_id, void* buffer, size_t len)
75+
{
76+
return mbox_k3_sec_proxy_read(&k3_sec_proxy, chan_id, buffer, len);
77+
}
78+
79+
static tisci_ctx tisci_context = {
80+
.ops =
81+
{
82+
.send = platform_tisci_send,
83+
.recv = platform_tisci_recv,
84+
},
85+
.seq_id_lock = {0, 0},
86+
.seq_id = 0U,
87+
};
88+
89+
void platform_default_init(void)
90+
{
91+
if (cpu_is_master()) {
92+
cpu_sync_init(&cpu_glb_sync, platform.cpu_num);
93+
}
94+
95+
mbox_k3_sec_proxy_init(&k3_sec_proxy);
96+
cpu_sync_barrier(&cpu_glb_sync);
97+
98+
uint8_t cur_host_id = cpu_is_master() ? J721E_HOST_ID_MAIN_A72_CONTEXT_2_NON_SECURE :
99+
J721E_HOST_ID_MAIN_A72_CONTEXT_3_NON_SECURE;
100+
101+
mbox_k3_sec_proxy_thread_desc* host_threads =
102+
mbox_k3_sec_proxy_get_thread_by_host_func(&k3_sec_proxy, cur_host_id, 0U);
103+
if (NULL == host_threads) {
104+
ERROR("platform init failed, no secure proxy threads found");
105+
return;
106+
}
107+
108+
/* probe all secure proxy threads owned by this host */
109+
for (uint8_t func_iterator = 0U; func_iterator < MBOX_K3_SEC_PROXY_NUM_HOST_FUNCTIONS;
110+
func_iterator++) {
111+
int32_t probe_status =
112+
mbox_k3_sec_proxy_probe(&k3_sec_proxy, host_threads[func_iterator].sec_proxy_thread_id);
113+
if (MBOX_K3_SEC_PROXY_STATUS_CODE_NO_ERROR != probe_status) {
114+
ERROR("platform init failed, k3 secure_proxy_thread_%d probe status=%d",
115+
host_threads[func_iterator].sec_proxy_thread_id, probe_status);
116+
return;
117+
}
118+
}
119+
120+
/* ping test to ensure that host<->sysfw pipeline is clean */
121+
tisci_msg_version_rsp ping_rsp = { 0 };
122+
int32_t ping_status = tisci_get_revision(&tisci_context, cur_host_id,
123+
host_threads[MBOX_K3_SEC_PROXY_HOST_FUNCTION_LOW_PRIORITY].sec_proxy_thread_id,
124+
host_threads[MBOX_K3_SEC_PROXY_HOST_FUNCTION_RESPONSE].sec_proxy_thread_id, &ping_rsp);
125+
if (TISCI_STATUS_CODE_NO_ERROR != ping_status) {
126+
ERROR("platform init failed, ping to sysfw failed, ping_status=%d", ping_status);
127+
}
128+
}
129+
130+
#endif /* ifndef GENERATING_DEFS */
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright (c) Bao Project and Contributors. All rights reserved
4+
*/
5+
6+
#ifndef __PLAT_PLATFORM_H__
7+
#define __PLAT_PLATFORM_H__
8+
9+
#define UART8250_REG_WIDTH (4U)
10+
11+
#include <drivers/8250_uart.h>
12+
#include <drivers/k3_sec_proxy.h>
13+
#include <drivers/tisci.h>
14+
15+
/* j721e host id enumeration */
16+
#define J721E_HOST_ID_MAIN_A72_CONTEXT_0_SECURE (10)
17+
#define J721E_HOST_ID_MAIN_A72_CONTEXT_1_SECURE (11)
18+
#define J721E_HOST_ID_MAIN_A72_CONTEXT_2_NON_SECURE (12)
19+
#define J721E_HOST_ID_MAIN_A72_CONTEXT_3_NON_SECURE (13)
20+
#define J721E_HOST_ID_MAIN_A72_CONTEXT_4_NON_SECURE (14)
21+
#define J721E_HOST_ID_MAIN_A72_CONTEXT_5_NON_SECURE (30)
22+
23+
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright (c) Bao Project and Contributors. All rights reserved.
4+
*/
5+
6+
#ifndef __PLAT_PSCI_H__
7+
#define __PLAT_PSCI_H__
8+
9+
#define PSCI_POWER_STATE_LVL_0 (0x0U)
10+
11+
#define PSCI_STATE_TYPE_STANDBY (0x0U)
12+
#define PSCI_STATE_TYPE_BIT (1UL << 16)
13+
14+
#define PSCI_STATE_ID_RUN (0x0U)
15+
#define PSCI_STATE_ID_RETENTION (0x1U)
16+
#define PSCI_STATE_ID_POWERDOWN (0x2U)
17+
18+
#define PSCI_STATE_TYPE_POWERDOWN PSCI_STATE_TYPE_BIT | PSCI_STATE_ID_POWERDOWN
19+
20+
#endif // __PLAT_PSCI_H__
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## SPDX-License-Identifier: Apache-2.0
2+
## Copyright (c) Bao Project and Contributors. All rights reserved.
3+
4+
boards-objs-y+=bb-ai64_desc.o
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## SPDX-License-Identifier: Apache-2.0
2+
## Copyright (c) Bao Project and Contributors. All rights reserved.
3+
4+
# Architecture definition
5+
ARCH:=armv8
6+
# CPU definition
7+
CPU:=cortex-a72
8+
9+
#needs to be checked
10+
GIC_VERSION:=GICV3
11+
12+
drivers = 8250_uart mailbox firmware
13+
14+
platform_description:=bb-ai64_desc.c
15+
16+
platform-cflags = -mtune=$(CPU)
17+
platform-asflags =
18+
platform-ldflags =

src/platform/drivers/mailbox/inc/drivers/k3_sec_proxy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define __MBOX_K3_SEC_PROXY_H_
88

99
#include <bao.h>
10+
#include <cpu.h>
1011
#include <plat/platform.h>
1112
#include <stddef.h>
1213
#include <stdint.h>
@@ -254,4 +255,6 @@ mbox_k3_sec_proxy_thread_desc*
254255
mbox_k3_sec_proxy_get_thread_by_host_func(mbox_k3_sec_proxy_desc* sec_proxy_desc, uint8_t host_id,
255256
MBOX_K3_SEC_PROXY_HOST_FUNCTION host_function);
256257

258+
void mbox_k3_sec_proxy_init(mbox_k3_sec_proxy_desc* sec_proxy_desc);
259+
257260
#endif /* __MBOX_K3_SEC_PROXY_H_ */

src/platform/drivers/mailbox/k3_sec_proxy.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include <drivers/k3_sec_proxy.h>
7+
#include <stdint.h>
78

89
/**
910
* @brief Reads a 32-bit value from a memory-mapped register.
@@ -318,3 +319,20 @@ mbox_k3_sec_proxy_get_thread_by_host_func(mbox_k3_sec_proxy_desc* sec_proxy_desc
318319
}
319320
return NULL;
320321
}
322+
323+
void mbox_k3_sec_proxy_init(mbox_k3_sec_proxy_desc* sec_proxy_desc)
324+
{
325+
if (cpu_is_master()) {
326+
sec_proxy_desc->thread_inst.rt_base = (vaddr_t)mem_alloc_map_dev(&cpu()->as, SEC_HYP_GLOBAL,
327+
INVALID_VA, sec_proxy_desc->thread_inst.rt_base,
328+
NUM_PAGES(sec_proxy_desc->thread_inst.rt_size));
329+
330+
sec_proxy_desc->thread_inst.scfg_base = (vaddr_t)mem_alloc_map_dev(&cpu()->as,
331+
SEC_HYP_GLOBAL, INVALID_VA, sec_proxy_desc->thread_inst.scfg_base,
332+
NUM_PAGES(sec_proxy_desc->thread_inst.scfg_size));
333+
334+
sec_proxy_desc->thread_inst.data_base = (vaddr_t)mem_alloc_map_dev(&cpu()->as,
335+
SEC_HYP_GLOBAL, INVALID_VA, sec_proxy_desc->thread_inst.data_base,
336+
NUM_PAGES(sec_proxy_desc->thread_inst.data_size));
337+
}
338+
}

0 commit comments

Comments
 (0)