Skip to content

Commit 1b1381f

Browse files
committed
feat(platform): add mps3 support
Signed-off-by: Jose Martins <[email protected]>
1 parent 0ea6045 commit 1b1381f

File tree

8 files changed

+141
-0
lines changed

8 files changed

+141
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright (c) Bao Project and Contributors. All rights reserved.
4+
*/
5+
6+
#include <bao.h>
7+
#include <drivers/cmsdk_uart.h>
8+
9+
10+
void uart_init(volatile struct cmsdk_uart_hw* ptr_uart)
11+
{
12+
ptr_uart->state = 0x3;
13+
ptr_uart->intstatus = 0xf;
14+
}
15+
16+
void uart_enable(volatile struct cmsdk_uart_hw* ptr_uart)
17+
{
18+
ptr_uart->ctrl = 0x1;
19+
}
20+
21+
void uart_putc(volatile struct cmsdk_uart_hw* ptr_uart, int8_t c)
22+
{
23+
while(ptr_uart->state & 0x1) { }
24+
ptr_uart->data = (uint32_t)c;
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright (c) Bao Project and Contributors. All rights reserved.
4+
*/
5+
6+
#ifndef __CMSDK_UART_H_
7+
#define __CMSDK_UART_H_
8+
9+
#include <stdint.h>
10+
11+
struct cmsdk_uart_hw {
12+
volatile uint32_t data;
13+
volatile uint32_t state;
14+
volatile uint32_t ctrl;
15+
volatile uint32_t intstatus;
16+
volatile uint32_t bauddiv;
17+
} __attribute__((packed));
18+
19+
typedef struct cmsdk_uart_hw bao_uart_t;
20+
21+
22+
void uart_enable(volatile struct cmsdk_uart_hw* ptr_uart);
23+
void uart_init(volatile struct cmsdk_uart_hw* ptr_uart);
24+
void uart_putc(volatile struct cmsdk_uart_hw* ptr_uart, int8_t c);
25+
26+
#endif /* __CMSDK_UART_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+
drivers-objs-y+=cmsdk_uart/cmsdk_uart.o
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
#include <drivers/cmsdk_uart.h>
10+
11+
#define PLAT_NUM_EL1_MPU_REGIONS (24)
12+
#define PLAT_NUM_EL2_MPU_REGIONS (32)
13+
14+
#endif
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 0x0000000 // TBD
10+
#define PSCI_POWER_STATE_LVL_1 0x1000000 // TBD
11+
#define PSCI_POWER_STATE_LVL_2 0x2000000 // TBD
12+
#define PSCI_STATE_TYPE_STANDBY 0x00000 // TBD
13+
#define PSCI_STATE_TYPE_POWERDOWN (0UL << 30) // TBD
14+
#define PSCI_STATE_TYPE_BIT (0UL << 30) // TBD
15+
16+
#endif // __PLAT_PSCI_H__
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
10+
.cpu_num = 2,
11+
.cpu_master_fixed = true,
12+
.cpu_master = 0,
13+
14+
.region_num = 1,
15+
.regions = (struct mem_region[]) {
16+
{
17+
.base = 0x20000000,
18+
.size = 0x80000000,
19+
}
20+
},
21+
22+
.console = {
23+
.base = 0xE0205000, // UART2
24+
},
25+
26+
.arch = {
27+
.gic = {
28+
.gicd_addr = 0xF0000000,
29+
.gicr_addr = 0xF0100000,
30+
.maintenance_id = 25,
31+
},
32+
},
33+
34+
};

src/platform/mps3-an536/objects.mk

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+=mps3_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+
5+
ARCH:=armv8
6+
ARCH_SUB:=aarch32
7+
ARCH_PROFILE:=armv8-r
8+
9+
GIC_VERSION:=GICV3
10+
11+
drivers = cmsdk_uart
12+
13+
platform_description:=mps3_desc.c
14+
15+
platform-cppflags =
16+
platform-cflags = -gdwarf-4
17+
platform-asflags =
18+
platform-ldflags =

0 commit comments

Comments
 (0)