Skip to content

Commit 9f500d0

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

File tree

8 files changed

+141
-0
lines changed

8 files changed

+141
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
#define CMSDK_STATE_TX_BUF_FULL (1UL << 0)
10+
#define CMSDK_STATE_TX_BUF_OVERRUN (1UL << 2)
11+
#define CMSDK_STATE_RX_BUF_OVERRUN (1UL << 3)
12+
#define CMSDK_CTRL_TXEN (1UL << 0)
13+
14+
void uart_init(volatile struct cmsdk_uart_hw* ptr_uart)
15+
{
16+
ptr_uart->state = CMSDK_STATE_TX_BUF_OVERRUN | CMSDK_STATE_RX_BUF_OVERRUN;
17+
ptr_uart->intstatus = 0xf;
18+
}
19+
20+
void uart_enable(volatile struct cmsdk_uart_hw* ptr_uart)
21+
{
22+
ptr_uart->ctrl = CMSDK_CTRL_TXEN;
23+
}
24+
25+
void uart_putc(volatile struct cmsdk_uart_hw* ptr_uart, int8_t c)
26+
{
27+
while (ptr_uart->state & CMSDK_STATE_TX_BUF_FULL) { }
28+
ptr_uart->data = (uint32_t)c;
29+
}
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+
#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+
void uart_enable(volatile struct cmsdk_uart_hw* ptr_uart);
22+
void uart_init(volatile struct cmsdk_uart_hw* ptr_uart);
23+
void uart_putc(volatile struct cmsdk_uart_hw* ptr_uart, int8_t c);
24+
25+
#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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
#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)