Skip to content

Commit e0afd7e

Browse files
arnopogalak
authored andcommitted
soc: stm32: add initial soc support for stm32mp1 family
Add the initial SoC support for the STM32MP1 family. The code was tested on STM32MP157c, but should work on any STM32MP1XX currently available. Signed-off-by: Arnaud Pouliquen <[email protected]>
1 parent 498b494 commit e0afd7e

File tree

11 files changed

+309
-0
lines changed

11 files changed

+309
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2019 STMicroelectronics
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
zephyr_include_directories(${ZEPHYR_BASE}/drivers)
6+
zephyr_sources(
7+
soc.c
8+
)
9+
zephyr_sources_ifdef(CONFIG_RPROC_RSC_TABLE resource_table.c)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Kconfig - ST Microelectronics STM32MP1 MCU/MPU line
2+
#
3+
# Copyright (c) 2019 STMicroelectronics
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
if SOC_SERIES_STM32MP1X
9+
10+
source "soc/arm/st_stm32/stm32mp1/Kconfig.defconfig.stm32mp15_m4"
11+
12+
config SOC_SERIES
13+
default "stm32mp1"
14+
15+
config STM32_CORE_CM4
16+
bool "define stm32 core"
17+
default y
18+
19+
endif # SOC_SERIES_STM32MP1X
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Kconfig - ST Microelectronics STM32MP157C_M4 MCU
2+
#
3+
# Copyright (c) 2019 STMicroelectronics
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
if SOC_STM32MP15_M4
9+
10+
config SOC
11+
string
12+
default "stm32mp157cxx"
13+
14+
config NUM_IRQS
15+
int
16+
default 150
17+
endif # SOC_STM32MP15_M4
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Kconfig - ST Microelectronics STM32MP1 MPU series
2+
#
3+
# Copyright (c) 2019 STMicroelectronics
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
config SOC_SERIES_STM32MP1X
9+
bool "STM32MP15 Series MPU"
10+
select CPU_CORTEX_M4
11+
select SOC_FAMILY_STM32
12+
select HAS_STM32CUBE
13+
select CPU_HAS_ARM_MPU
14+
select CPU_HAS_SYSTICK
15+
help
16+
Enable support for STM32MP1 MPU series
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Kconfig - ST Microelectronics STM32MP1 MPU line
2+
#
3+
# Copyright (c) 2019 STMicroelectronics
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
choice
9+
prompt "STM32MP1 MPU Selection"
10+
depends on SOC_SERIES_STM32MP1X
11+
12+
config SOC_STM32MP15_M4
13+
bool "STM32MP15_M4"
14+
15+
endchoice
16+
17+
config RPROC_RSC_TABLE
18+
bool "coprocessor resource table"
19+
default y if RAM_CONSOLE || OPENAMP
20+
help
21+
add the resource table in the generated binary. This table is
22+
compatible with linux remote proc framework and OpenAMP library.
23+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright (c) 2019 STMicroelectronics
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* SoC level DTS fixup file */
8+
9+
#define DT_NUM_IRQ_PRIO_BITS DT_ARM_V7M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS
10+
11+
/* End of SoC Level DTS fixup file */
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* linker.ld - Linker command/script file */
2+
3+
/*
4+
* Copyright (c) 2019 STMicroelectronics
5+
*
6+
* SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
10+
#include <arch/arm/cortex_m/scripts/linker.ld>
11+
12+
SECTIONS
13+
{
14+
15+
#include <linker/rel-sections.ld>
16+
#ifdef CONFIG_RPROC_RSC_TABLE
17+
18+
SECTION_PROLOGUE(.resource_table,, SUBALIGN(4))
19+
{
20+
KEEP(*(.resource_table*))
21+
} GROUP_LINK_IN(ROMABLE_REGION)
22+
#endif
23+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2019 STMicroelectronics
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr.h>
8+
#include "resource_table.h"
9+
10+
extern char ram_console[];
11+
12+
#define __section_t(S) __attribute__((__section__(#S)))
13+
#define __resource __section_t(.resource_table)
14+
15+
#ifdef CONFIG_RAM_CONSOLE
16+
static volatile struct stm32_resource_table __resource resource_table = {
17+
.ver = 1,
18+
.num = 1,
19+
.offset = {
20+
offsetof(struct stm32_resource_table, cm_trace),
21+
},
22+
.cm_trace = {
23+
RSC_TRACE,
24+
(uint32_t)ram_console, CONFIG_RAM_CONSOLE_BUFFER_SIZE + 1, 0,
25+
"cm4_log",
26+
},
27+
};
28+
#endif
29+
30+
void resource_table_init(volatile void **table_ptr, int *length)
31+
{
32+
*table_ptr = &resource_table;
33+
*length = sizeof(resource_table);
34+
}
35+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2018 Nordic Semiconductor ASA
3+
* Copyright (c) 2019 STMicroelectronics
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#ifndef RESOURCE_TABLE_H__
9+
#define RESOURCE_TABLE_H__
10+
11+
#ifndef OPENAMP_PACKED_BEGIN
12+
#define OPENAMP_PACKED_BEGIN
13+
#endif
14+
15+
#ifndef OPENAMP_PACKED_END
16+
#define OPENAMP_PACKED_END __attribute__((__packed__))
17+
#endif
18+
19+
/* beginning of section: copied from OpenAMP */
20+
/**
21+
* struct fw_rsc_trace - trace buffer declaration
22+
* @da: device address
23+
* @len: length (in bytes)
24+
* @reserved: reserved (must be zero)
25+
* @name: human-readable name of the trace buffer
26+
*
27+
* This resource entry provides the host information about a trace buffer
28+
* into which the remote remote_proc will write log messages.
29+
*
30+
* @da specifies the device address of the buffer, @len specifies
31+
* its size, and @name may contain a human readable name of the trace buffer.
32+
*
33+
* After booting the remote remote_proc, the trace buffers are exposed to the
34+
* user via debugfs entries (called trace0, trace1, etc..).
35+
*/
36+
OPENAMP_PACKED_BEGIN
37+
struct fw_rsc_trace {
38+
u32_t type;
39+
u32_t da;
40+
u32_t len;
41+
u32_t reserved;
42+
u8_t name[32];
43+
} OPENAMP_PACKED_END;
44+
45+
OPENAMP_PACKED_BEGIN
46+
47+
enum fw_resource_type {
48+
RSC_CARVEOUT = 0,
49+
RSC_DEVMEM = 1,
50+
RSC_TRACE = 2,
51+
RSC_VDEV = 3,
52+
RSC_RPROC_MEM = 4,
53+
RSC_FW_CHKSUM = 5,
54+
RSC_LAST = 6,
55+
RSC_VENDOR_START = 128,
56+
RSC_VENDOR_END = 512,
57+
};
58+
59+
/* end of section: copied from OpenAMP */
60+
61+
struct stm32_resource_table {
62+
unsigned int ver;
63+
unsigned int num;
64+
unsigned int reserved[2];
65+
unsigned int offset[1];
66+
67+
/* rpmsg trace entry */
68+
struct fw_rsc_trace cm_trace;
69+
} OPENAMP_PACKED_END;
70+
71+
void resource_table_init(volatile void **table_ptr, int *length);
72+
73+
#endif
74+

soc/arm/st_stm32/stm32mp1/soc.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2019 STMicroelectronics
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @file
9+
* @brief System/hardware module for STM32L4 processor
10+
*/
11+
12+
#include <kernel.h>
13+
#include <device.h>
14+
#include <init.h>
15+
#include <soc.h>
16+
#include <arch/cpu.h>
17+
#include <cortex_m/exc.h>
18+
19+
/**
20+
* @brief Perform basic hardware initialization at boot.
21+
*
22+
* This needs to be run from the very beginning.
23+
* So the init priority has to be 0 (zero).
24+
*
25+
* @return 0
26+
*/
27+
static int stm32m4_init(struct device *arg)
28+
{
29+
u32_t key;
30+
31+
ARG_UNUSED(arg);
32+
33+
key = irq_lock();
34+
35+
z_clearfaults();
36+
37+
/* Install default handler that simply resets the CPU
38+
* if configured in the kernel, NOP otherwise
39+
*/
40+
NMI_INIT();
41+
42+
irq_unlock(key);
43+
44+
/* Update CMSIS SystemCoreClock variable (HCLK) */
45+
SystemCoreClock = 209000000;
46+
47+
return 0;
48+
}
49+
50+
SYS_INIT(stm32m4_init, PRE_KERNEL_1, 0);

0 commit comments

Comments
 (0)