Skip to content

Commit f0596ec

Browse files
committed
arch: Add imx7d m4 soc support
The i.MX7 SoC is a Hybrid multi-core processor composed by Single/Dual Cortex A7 core and Single Cortex M4 core. Zephyr was ported to run on the M4 core. In a later release, it will also communicate with the A7 core (running Linux) via RPmsg. The low level drivers come from NXP FreeRTOS BSP and are located at ext/hal/nxp/imx. More details can be found at ext/hal/nxp/imx/README The A7 core is responsible to load the M4 binary application into the RAM, put the M4 in reset, set the M4 Program Counter and Stack Pointer, and get the M4 out of reset. The A7 can perform these steps at bootloader level after the Linux system has booted. The M4 can use up to 5 different RAMs. These are the memory mapping for A7 and M4: +---------------+-----------------+---------------------------+ | Memory Name | Start Address | Size | +===============+=================+===========================+ | TCML | 0x007F8000 | 32KB | +---------------+-----------------+---------------------------+ | TCMU | 0x20000000 | 32KB | +---------------+-----------------+---------------------------+ | OCRAM_S | 0x20180000 | 32KB | +---------------+-----------------+---------------------------+ | OCRAM | 0x00900000 | 128KB | +---------------+-----------------+---------------------------+ | DDR | 0x10000000 | 256MB | +---------------+-----------------+---------------------------+ Signed-off-by: Diego Sueiro <[email protected]>
1 parent 927e7d3 commit f0596ec

File tree

10 files changed

+456
-0
lines changed

10 files changed

+456
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Copyright (c) 2017, NXP
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
zephyr_sources(soc.c)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Kconfig - iMX7 M4 core series
2+
#
3+
# Copyright (c) 2017, NXP
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
if SOC_MCIMX7_M4
9+
10+
config SOC
11+
string
12+
default mcimx7d
13+
14+
config SYS_CLOCK_TICKS_PER_SEC
15+
int
16+
default 1000
17+
18+
config SYS_CLOCK_HW_CYCLES_PER_SEC
19+
int
20+
default 200000000
21+
22+
if CLOCK_CONTROL
23+
24+
config CLOCK_CONTROL_IMX_CCM
25+
def_bool y
26+
27+
endif # CLOCK_CONTROL
28+
29+
if SERIAL
30+
31+
config UART_IMX
32+
def_bool y
33+
34+
endif # SERIAL
35+
36+
config DOMAIN_ID
37+
int
38+
default 1
39+
40+
endif # SOC_MCIMX7_M4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Kconfig - iMX7 M4 core series
2+
#
3+
# Copyright (c) 2017, NXP
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
if SOC_SERIES_IMX7_M4
9+
10+
config SOC_SERIES
11+
default mcimx7_m4
12+
13+
config NUM_IRQS
14+
int
15+
# must be >= the highest interrupt number used
16+
default 127
17+
18+
source "arch/arm/soc/nxp_imx/mcimx7_m4/Kconfig.defconfig.mcimx7_m4"
19+
20+
endif # SOC_SERIES_IMX7_M4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Kconfig - iMX7 M4 core series
2+
#
3+
# Copyright (c) 2017, NXP
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
config SOC_SERIES_IMX7_M4
9+
bool "i.MX7 M4 Core Series"
10+
select CPU_CORTEX_M
11+
select CPU_CORTEX_M4
12+
select SOC_FAMILY_IMX
13+
select CPU_HAS_SYSTICK
14+
select CLOCK_CONTROL
15+
select CPU_HAS_FPU
16+
help
17+
Enable support for i.MX7 M4 MCU series
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Kconfig - iMX7 M4 core series
2+
#
3+
# Copyright (c) 2017, NXP
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
choice
9+
prompt "i.MX7 M4 Selection"
10+
depends on SOC_SERIES_IMX7_M4
11+
12+
config SOC_MCIMX7_M4
13+
bool "SOC_MCIMX7_M4"
14+
select HAS_IMX_HAL
15+
16+
endchoice
17+
18+
if SOC_MCIMX7_M4
19+
20+
config SOC_PART_NUMBER_MCIMX7D5EVM10SC
21+
bool
22+
23+
config SOC_PART_NUMBER_IMX7_M4
24+
string
25+
default "MCIMX7D5EVM10SC" if SOC_PART_NUMBER_MCIMX7D5EVM10SC
26+
help
27+
This string holds the full part number of the SoC. It is a hidden option
28+
that you should not set directly. The part number selection choice defines
29+
the default value for this string.
30+
31+
endif # SOC_SERIES_IMX7_M4
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2018, Diego Sueiro <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* SoC level DTS fixup file */
8+
9+
#define CONFIG_NUM_IRQ_PRIO_BITS ARM_V7M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS
10+
11+
#define CONFIG_UART_IMX_UART_1_NAME NXP_IMX_UART_30860000_LABEL
12+
#define CONFIG_UART_IMX_UART_1_BASE_ADDRESS NXP_IMX_UART_30860000_BASE_ADDRESS
13+
#define CONFIG_UART_IMX_UART_1_BAUD_RATE NXP_IMX_UART_30860000_CURRENT_SPEED
14+
#define CONFIG_UART_IMX_UART_1_IRQ_NUM NXP_IMX_UART_30860000_IRQ_0
15+
#define CONFIG_UART_IMX_UART_1_IRQ_PRI NXP_IMX_UART_30860000_IRQ_0_PRIORITY
16+
#define CONFIG_UART_IMX_UART_1_MODEM_MODE NXP_IMX_UART_30860000_MODEM_MODE
17+
18+
#define CONFIG_UART_IMX_UART_2_NAME NXP_IMX_UART_30890000_LABEL
19+
#define CONFIG_UART_IMX_UART_2_BASE_ADDRESS NXP_IMX_UART_30890000_BASE_ADDRESS
20+
#define CONFIG_UART_IMX_UART_2_BAUD_RATE NXP_IMX_UART_30890000_CURRENT_SPEED
21+
#define CONFIG_UART_IMX_UART_2_IRQ_NUM NXP_IMX_UART_30890000_IRQ_0
22+
#define CONFIG_UART_IMX_UART_2_IRQ_PRI NXP_IMX_UART_30890000_IRQ_0_PRIORITY
23+
#define CONFIG_UART_IMX_UART_2_MODEM_MODE NXP_IMX_UART_30890000_MODEM_MODE
24+
25+
#define CONFIG_UART_IMX_UART_3_NAME NXP_IMX_UART_30880000_LABEL
26+
#define CONFIG_UART_IMX_UART_3_BASE_ADDRESS NXP_IMX_UART_30880000_BASE_ADDRESS
27+
#define CONFIG_UART_IMX_UART_3_BAUD_RATE NXP_IMX_UART_30880000_CURRENT_SPEED
28+
#define CONFIG_UART_IMX_UART_3_IRQ_NUM NXP_IMX_UART_30880000_IRQ_0
29+
#define CONFIG_UART_IMX_UART_3_IRQ_PRI NXP_IMX_UART_30880000_IRQ_0_PRIORITY
30+
#define CONFIG_UART_IMX_UART_3_MODEM_MODE NXP_IMX_UART_30880000_MODEM_MODE
31+
32+
#define CONFIG_UART_IMX_UART_4_NAME NXP_IMX_UART_30A60000_LABEL
33+
#define CONFIG_UART_IMX_UART_4_BASE_ADDRESS NXP_IMX_UART_30A60000_BASE_ADDRESS
34+
#define CONFIG_UART_IMX_UART_4_BAUD_RATE NXP_IMX_UART_30A60000_CURRENT_SPEED
35+
#define CONFIG_UART_IMX_UART_4_IRQ_NUM NXP_IMX_UART_30A60000_IRQ_0
36+
#define CONFIG_UART_IMX_UART_4_IRQ_PRI NXP_IMX_UART_30A60000_IRQ_0_PRIORITY
37+
#define CONFIG_UART_IMX_UART_4_MODEM_MODE NXP_IMX_UART_30A60000_MODEM_MODE
38+
39+
#define CONFIG_UART_IMX_UART_5_NAME NXP_IMX_UART_30A70000_LABEL
40+
#define CONFIG_UART_IMX_UART_5_BASE_ADDRESS NXP_IMX_UART_30A70000_BASE_ADDRESS
41+
#define CONFIG_UART_IMX_UART_5_BAUD_RATE NXP_IMX_UART_30A70000_CURRENT_SPEED
42+
#define CONFIG_UART_IMX_UART_5_IRQ_NUM NXP_IMX_UART_30A70000_IRQ_0
43+
#define CONFIG_UART_IMX_UART_5_IRQ_PRI NXP_IMX_UART_30A70000_IRQ_0_PRIORITY
44+
#define CONFIG_UART_IMX_UART_5_MODEM_MODE NXP_IMX_UART_30A70000_MODEM_MODE
45+
46+
#define CONFIG_UART_IMX_UART_6_NAME NXP_IMX_UART_30A80000_LABEL
47+
#define CONFIG_UART_IMX_UART_6_BASE_ADDRESS NXP_IMX_UART_30A80000_BASE_ADDRESS
48+
#define CONFIG_UART_IMX_UART_6_BAUD_RATE NXP_IMX_UART_30A80000_CURRENT_SPEED
49+
#define CONFIG_UART_IMX_UART_6_IRQ_NUM NXP_IMX_UART_30A80000_IRQ_0
50+
#define CONFIG_UART_IMX_UART_6_IRQ_PRI NXP_IMX_UART_30A80000_IRQ_0_PRIORITY
51+
#define CONFIG_UART_IMX_UART_6_MODEM_MODE NXP_IMX_UART_30A80000_MODEM_MODE
52+
53+
#define CONFIG_UART_IMX_UART_7_NAME NXP_IMX_UART_30A90000_LABEL
54+
#define CONFIG_UART_IMX_UART_7_BASE_ADDRESS NXP_IMX_UART_30A90000_BASE_ADDRESS
55+
#define CONFIG_UART_IMX_UART_7_BAUD_RATE NXP_IMX_UART_30A90000_CURRENT_SPEED
56+
#define CONFIG_UART_IMX_UART_7_IRQ_NUM NXP_IMX_UART_30A90000_IRQ_0
57+
#define CONFIG_UART_IMX_UART_7_IRQ_PRI NXP_IMX_UART_30A90000_IRQ_0_PRIORITY
58+
#define CONFIG_UART_IMX_UART_7_MODEM_MODE NXP_IMX_UART_30A90000_MODEM_MODE
59+
60+
/* End of SoC Level DTS fixup file */
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright (c) 2014 Wind River Systems, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <arch/arm/cortex_m/scripts/linker.ld>

arch/arm/soc/nxp_imx/mcimx7_m4/soc.c

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright (c) 2017, NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <init.h>
8+
#include <soc.h>
9+
#include "wdog_imx.h"
10+
11+
/* Initialize clock. */
12+
void SOC_ClockInit(void)
13+
{
14+
/* OSC/PLL is already initialized by Cortex-A7 (u-boot) */
15+
16+
/*
17+
* Disable WDOG3
18+
* Note : The WDOG clock Root is shared by all the 4 WDOGs,
19+
* so Zephyr code should avoid closing it
20+
*/
21+
CCM_UpdateRoot(CCM, ccmRootWdog, ccmRootmuxWdogOsc24m, 0, 0);
22+
CCM_EnableRoot(CCM, ccmRootWdog);
23+
CCM_ControlGate(CCM, ccmCcgrGateWdog3, ccmClockNeededRun);
24+
25+
RDC_SetPdapAccess(RDC, rdcPdapWdog3,
26+
RDC_DOMAIN_PERM(CONFIG_DOMAIN_ID, RDC_DOMAIN_PERM_RW),
27+
false, false);
28+
29+
WDOG_DisablePowerdown(WDOG3);
30+
31+
CCM_ControlGate(CCM, ccmCcgrGateWdog3, ccmClockNotNeeded);
32+
33+
/* We need system PLL Div2 to run M4 core */
34+
CCM_ControlGate(CCM, ccmPllGateSys, ccmClockNeededRun);
35+
CCM_ControlGate(CCM, ccmPllGateSysDiv2, ccmClockNeededRun);
36+
37+
/* Enable clock gate for IP bridge and IO mux */
38+
CCM_ControlGate(CCM, ccmCcgrGateIpmux1, ccmClockNeededRun);
39+
CCM_ControlGate(CCM, ccmCcgrGateIpmux2, ccmClockNeededRun);
40+
CCM_ControlGate(CCM, ccmCcgrGateIpmux3, ccmClockNeededRun);
41+
CCM_ControlGate(CCM, ccmCcgrGateIomux, ccmClockNeededRun);
42+
CCM_ControlGate(CCM, ccmCcgrGateIomuxLpsr, ccmClockNeededRun);
43+
44+
/* Enable clock gate for RDC */
45+
CCM_ControlGate(CCM, ccmCcgrGateRdc, ccmClockNeededRun);
46+
}
47+
48+
void SOC_RdcInit(void)
49+
{
50+
/* Move M4 core to specific RDC domain */
51+
RDC_SetDomainID(RDC, rdcMdaM4, CONFIG_DOMAIN_ID, false);
52+
}
53+
54+
#ifdef CONFIG_UART_IMX
55+
static void nxp_mcimx7_uart_config(void)
56+
{
57+
58+
#ifdef CONFIG_UART_IMX_UART_2
59+
/* We need to grasp board uart exclusively */
60+
RDC_SetPdapAccess(RDC, rdcPdapUart2,
61+
RDC_DOMAIN_PERM(CONFIG_DOMAIN_ID, RDC_DOMAIN_PERM_RW),
62+
false, false);
63+
/* Select clock derived from OSC clock(24M) */
64+
CCM_UpdateRoot(CCM, ccmRootUart2, ccmRootmuxUartOsc24m, 0, 0);
65+
/* Enable uart clock */
66+
CCM_EnableRoot(CCM, ccmRootUart2);
67+
/*
68+
* IC Limitation
69+
* M4 stop will cause A7 UART lose functionality
70+
* So we need UART clock all the time
71+
*/
72+
CCM_ControlGate(CCM, ccmCcgrGateUart2, ccmClockNeededAll);
73+
#endif /* #ifdef CONFIG_UART_IMX_UART_2 */
74+
75+
}
76+
#endif /* CONFIG_UART_IMX */
77+
78+
static int nxp_mcimx7_init(struct device *arg)
79+
{
80+
ARG_UNUSED(arg);
81+
82+
/* SoC specific RDC settings */
83+
SOC_RdcInit();
84+
85+
/* BoC specific clock settings */
86+
SOC_ClockInit();
87+
88+
#ifdef CONFIG_UART_IMX
89+
nxp_mcimx7_uart_config();
90+
#endif /* CONFIG_UART_IMX */
91+
92+
return 0;
93+
}
94+
95+
SYS_INIT(nxp_mcimx7_init, PRE_KERNEL_1, 0);

arch/arm/soc/nxp_imx/mcimx7_m4/soc.h

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2017, NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef _SOC__H_
8+
#define _SOC__H_
9+
10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
13+
14+
#ifndef _ASMLANGUAGE
15+
16+
#include "rdc.h"
17+
#include "rdc_defs_imx7d.h"
18+
#include "ccm_imx7d.h"
19+
#include "clock_freq.h"
20+
21+
#define RDC_DOMAIN_PERM_NONE (0x0)
22+
#define RDC_DOMAIN_PERM_W (0x1)
23+
#define RDC_DOMAIN_PERM_R (0x2)
24+
#define RDC_DOMAIN_PERM_RW (RDC_DOMAIN_PERM_W|RDC_DOMAIN_PERM_R)
25+
26+
#define RDC_DOMAIN_PERM(domain, perm) (perm << (domain * 2))
27+
28+
#endif /* !_ASMLANGUAGE */
29+
30+
#ifdef __cplusplus
31+
}
32+
#endif
33+
34+
#endif /* _SOC__H_ */

0 commit comments

Comments
 (0)