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 <diego.sueiro@gmail.com>
This commit is contained in:
Diego Sueiro 2018-03-16 13:59:33 +00:00 committed by Maureen Helm
parent 346165b2e8
commit 816330239e
10 changed files with 456 additions and 0 deletions

View file

@ -0,0 +1,7 @@
#
# Copyright (c) 2017, NXP
#
# SPDX-License-Identifier: Apache-2.0
#
zephyr_sources(soc.c)

View file

@ -0,0 +1,40 @@
# Kconfig - iMX7 M4 core series
#
# Copyright (c) 2017, NXP
#
# SPDX-License-Identifier: Apache-2.0
#
if SOC_MCIMX7_M4
config SOC
string
default mcimx7d
config SYS_CLOCK_TICKS_PER_SEC
int
default 1000
config SYS_CLOCK_HW_CYCLES_PER_SEC
int
default 200000000
if CLOCK_CONTROL
config CLOCK_CONTROL_IMX_CCM
def_bool y
endif # CLOCK_CONTROL
if SERIAL
config UART_IMX
def_bool y
endif # SERIAL
config DOMAIN_ID
int
default 1
endif # SOC_MCIMX7_M4

View file

@ -0,0 +1,20 @@
# Kconfig - iMX7 M4 core series
#
# Copyright (c) 2017, NXP
#
# SPDX-License-Identifier: Apache-2.0
#
if SOC_SERIES_IMX7_M4
config SOC_SERIES
default mcimx7_m4
config NUM_IRQS
int
# must be >= the highest interrupt number used
default 127
source "arch/arm/soc/nxp_imx/mcimx7_m4/Kconfig.defconfig.mcimx7_m4"
endif # SOC_SERIES_IMX7_M4

View file

@ -0,0 +1,17 @@
# Kconfig - iMX7 M4 core series
#
# Copyright (c) 2017, NXP
#
# SPDX-License-Identifier: Apache-2.0
#
config SOC_SERIES_IMX7_M4
bool "i.MX7 M4 Core Series"
select CPU_CORTEX_M
select CPU_CORTEX_M4
select SOC_FAMILY_IMX
select CPU_HAS_SYSTICK
select CLOCK_CONTROL
select CPU_HAS_FPU
help
Enable support for i.MX7 M4 MCU series

View file

@ -0,0 +1,31 @@
# Kconfig - iMX7 M4 core series
#
# Copyright (c) 2017, NXP
#
# SPDX-License-Identifier: Apache-2.0
#
choice
prompt "i.MX7 M4 Selection"
depends on SOC_SERIES_IMX7_M4
config SOC_MCIMX7_M4
bool "SOC_MCIMX7_M4"
select HAS_IMX_HAL
endchoice
if SOC_MCIMX7_M4
config SOC_PART_NUMBER_MCIMX7D5EVM10SC
bool
config SOC_PART_NUMBER_IMX7_M4
string
default "MCIMX7D5EVM10SC" if SOC_PART_NUMBER_MCIMX7D5EVM10SC
help
This string holds the full part number of the SoC. It is a hidden option
that you should not set directly. The part number selection choice defines
the default value for this string.
endif # SOC_SERIES_IMX7_M4

View file

@ -0,0 +1,60 @@
/*
* Copyright (c) 2018, Diego Sueiro <diego.sueiro@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
/* SoC level DTS fixup file */
#define CONFIG_NUM_IRQ_PRIO_BITS ARM_V7M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS
#define CONFIG_UART_IMX_UART_1_NAME NXP_IMX_UART_30860000_LABEL
#define CONFIG_UART_IMX_UART_1_BASE_ADDRESS NXP_IMX_UART_30860000_BASE_ADDRESS
#define CONFIG_UART_IMX_UART_1_BAUD_RATE NXP_IMX_UART_30860000_CURRENT_SPEED
#define CONFIG_UART_IMX_UART_1_IRQ_NUM NXP_IMX_UART_30860000_IRQ_0
#define CONFIG_UART_IMX_UART_1_IRQ_PRI NXP_IMX_UART_30860000_IRQ_0_PRIORITY
#define CONFIG_UART_IMX_UART_1_MODEM_MODE NXP_IMX_UART_30860000_MODEM_MODE
#define CONFIG_UART_IMX_UART_2_NAME NXP_IMX_UART_30890000_LABEL
#define CONFIG_UART_IMX_UART_2_BASE_ADDRESS NXP_IMX_UART_30890000_BASE_ADDRESS
#define CONFIG_UART_IMX_UART_2_BAUD_RATE NXP_IMX_UART_30890000_CURRENT_SPEED
#define CONFIG_UART_IMX_UART_2_IRQ_NUM NXP_IMX_UART_30890000_IRQ_0
#define CONFIG_UART_IMX_UART_2_IRQ_PRI NXP_IMX_UART_30890000_IRQ_0_PRIORITY
#define CONFIG_UART_IMX_UART_2_MODEM_MODE NXP_IMX_UART_30890000_MODEM_MODE
#define CONFIG_UART_IMX_UART_3_NAME NXP_IMX_UART_30880000_LABEL
#define CONFIG_UART_IMX_UART_3_BASE_ADDRESS NXP_IMX_UART_30880000_BASE_ADDRESS
#define CONFIG_UART_IMX_UART_3_BAUD_RATE NXP_IMX_UART_30880000_CURRENT_SPEED
#define CONFIG_UART_IMX_UART_3_IRQ_NUM NXP_IMX_UART_30880000_IRQ_0
#define CONFIG_UART_IMX_UART_3_IRQ_PRI NXP_IMX_UART_30880000_IRQ_0_PRIORITY
#define CONFIG_UART_IMX_UART_3_MODEM_MODE NXP_IMX_UART_30880000_MODEM_MODE
#define CONFIG_UART_IMX_UART_4_NAME NXP_IMX_UART_30A60000_LABEL
#define CONFIG_UART_IMX_UART_4_BASE_ADDRESS NXP_IMX_UART_30A60000_BASE_ADDRESS
#define CONFIG_UART_IMX_UART_4_BAUD_RATE NXP_IMX_UART_30A60000_CURRENT_SPEED
#define CONFIG_UART_IMX_UART_4_IRQ_NUM NXP_IMX_UART_30A60000_IRQ_0
#define CONFIG_UART_IMX_UART_4_IRQ_PRI NXP_IMX_UART_30A60000_IRQ_0_PRIORITY
#define CONFIG_UART_IMX_UART_4_MODEM_MODE NXP_IMX_UART_30A60000_MODEM_MODE
#define CONFIG_UART_IMX_UART_5_NAME NXP_IMX_UART_30A70000_LABEL
#define CONFIG_UART_IMX_UART_5_BASE_ADDRESS NXP_IMX_UART_30A70000_BASE_ADDRESS
#define CONFIG_UART_IMX_UART_5_BAUD_RATE NXP_IMX_UART_30A70000_CURRENT_SPEED
#define CONFIG_UART_IMX_UART_5_IRQ_NUM NXP_IMX_UART_30A70000_IRQ_0
#define CONFIG_UART_IMX_UART_5_IRQ_PRI NXP_IMX_UART_30A70000_IRQ_0_PRIORITY
#define CONFIG_UART_IMX_UART_5_MODEM_MODE NXP_IMX_UART_30A70000_MODEM_MODE
#define CONFIG_UART_IMX_UART_6_NAME NXP_IMX_UART_30A80000_LABEL
#define CONFIG_UART_IMX_UART_6_BASE_ADDRESS NXP_IMX_UART_30A80000_BASE_ADDRESS
#define CONFIG_UART_IMX_UART_6_BAUD_RATE NXP_IMX_UART_30A80000_CURRENT_SPEED
#define CONFIG_UART_IMX_UART_6_IRQ_NUM NXP_IMX_UART_30A80000_IRQ_0
#define CONFIG_UART_IMX_UART_6_IRQ_PRI NXP_IMX_UART_30A80000_IRQ_0_PRIORITY
#define CONFIG_UART_IMX_UART_6_MODEM_MODE NXP_IMX_UART_30A80000_MODEM_MODE
#define CONFIG_UART_IMX_UART_7_NAME NXP_IMX_UART_30A90000_LABEL
#define CONFIG_UART_IMX_UART_7_BASE_ADDRESS NXP_IMX_UART_30A90000_BASE_ADDRESS
#define CONFIG_UART_IMX_UART_7_BAUD_RATE NXP_IMX_UART_30A90000_CURRENT_SPEED
#define CONFIG_UART_IMX_UART_7_IRQ_NUM NXP_IMX_UART_30A90000_IRQ_0
#define CONFIG_UART_IMX_UART_7_IRQ_PRI NXP_IMX_UART_30A90000_IRQ_0_PRIORITY
#define CONFIG_UART_IMX_UART_7_MODEM_MODE NXP_IMX_UART_30A90000_MODEM_MODE
/* End of SoC Level DTS fixup file */

View file

@ -0,0 +1,7 @@
/*
* Copyright (c) 2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <arch/arm/cortex_m/scripts/linker.ld>

View file

@ -0,0 +1,95 @@
/*
* Copyright (c) 2017, NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <soc.h>
#include "wdog_imx.h"
/* Initialize clock. */
void SOC_ClockInit(void)
{
/* OSC/PLL is already initialized by Cortex-A7 (u-boot) */
/*
* Disable WDOG3
* Note : The WDOG clock Root is shared by all the 4 WDOGs,
* so Zephyr code should avoid closing it
*/
CCM_UpdateRoot(CCM, ccmRootWdog, ccmRootmuxWdogOsc24m, 0, 0);
CCM_EnableRoot(CCM, ccmRootWdog);
CCM_ControlGate(CCM, ccmCcgrGateWdog3, ccmClockNeededRun);
RDC_SetPdapAccess(RDC, rdcPdapWdog3,
RDC_DOMAIN_PERM(CONFIG_DOMAIN_ID, RDC_DOMAIN_PERM_RW),
false, false);
WDOG_DisablePowerdown(WDOG3);
CCM_ControlGate(CCM, ccmCcgrGateWdog3, ccmClockNotNeeded);
/* We need system PLL Div2 to run M4 core */
CCM_ControlGate(CCM, ccmPllGateSys, ccmClockNeededRun);
CCM_ControlGate(CCM, ccmPllGateSysDiv2, ccmClockNeededRun);
/* Enable clock gate for IP bridge and IO mux */
CCM_ControlGate(CCM, ccmCcgrGateIpmux1, ccmClockNeededRun);
CCM_ControlGate(CCM, ccmCcgrGateIpmux2, ccmClockNeededRun);
CCM_ControlGate(CCM, ccmCcgrGateIpmux3, ccmClockNeededRun);
CCM_ControlGate(CCM, ccmCcgrGateIomux, ccmClockNeededRun);
CCM_ControlGate(CCM, ccmCcgrGateIomuxLpsr, ccmClockNeededRun);
/* Enable clock gate for RDC */
CCM_ControlGate(CCM, ccmCcgrGateRdc, ccmClockNeededRun);
}
void SOC_RdcInit(void)
{
/* Move M4 core to specific RDC domain */
RDC_SetDomainID(RDC, rdcMdaM4, CONFIG_DOMAIN_ID, false);
}
#ifdef CONFIG_UART_IMX
static void nxp_mcimx7_uart_config(void)
{
#ifdef CONFIG_UART_IMX_UART_2
/* We need to grasp board uart exclusively */
RDC_SetPdapAccess(RDC, rdcPdapUart2,
RDC_DOMAIN_PERM(CONFIG_DOMAIN_ID, RDC_DOMAIN_PERM_RW),
false, false);
/* Select clock derived from OSC clock(24M) */
CCM_UpdateRoot(CCM, ccmRootUart2, ccmRootmuxUartOsc24m, 0, 0);
/* Enable uart clock */
CCM_EnableRoot(CCM, ccmRootUart2);
/*
* IC Limitation
* M4 stop will cause A7 UART lose functionality
* So we need UART clock all the time
*/
CCM_ControlGate(CCM, ccmCcgrGateUart2, ccmClockNeededAll);
#endif /* #ifdef CONFIG_UART_IMX_UART_2 */
}
#endif /* CONFIG_UART_IMX */
static int nxp_mcimx7_init(struct device *arg)
{
ARG_UNUSED(arg);
/* SoC specific RDC settings */
SOC_RdcInit();
/* BoC specific clock settings */
SOC_ClockInit();
#ifdef CONFIG_UART_IMX
nxp_mcimx7_uart_config();
#endif /* CONFIG_UART_IMX */
return 0;
}
SYS_INIT(nxp_mcimx7_init, PRE_KERNEL_1, 0);

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2017, NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _SOC__H_
#define _SOC__H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ASMLANGUAGE
#include "rdc.h"
#include "rdc_defs_imx7d.h"
#include "ccm_imx7d.h"
#include "clock_freq.h"
#define RDC_DOMAIN_PERM_NONE (0x0)
#define RDC_DOMAIN_PERM_W (0x1)
#define RDC_DOMAIN_PERM_R (0x2)
#define RDC_DOMAIN_PERM_RW (RDC_DOMAIN_PERM_W|RDC_DOMAIN_PERM_R)
#define RDC_DOMAIN_PERM(domain, perm) (perm << (domain * 2))
#endif /* !_ASMLANGUAGE */
#ifdef __cplusplus
}
#endif
#endif /* _SOC__H_ */

View file

@ -0,0 +1,145 @@
/*
* Copyright (c) 2017, NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <arm/armv7-m.dtsi>
/ {
cpus {
#address-cells = <1>;
#size-cells = <0>;
cpu@0 {
device_type = "cpu";
compatible = "arm,cortex-m4";
reg = <0>;
};
};
soc {
ddr_code: code@10000000 {
compatible = "nxp,imx-code-bus";
reg = <0x10000000 0xfff0000>;
label = "DDR CODE";
};
ddr_sys: memory@80000000 {
device_type = "memory";
compatible = "nxp,imx-sys-bus";
reg = <0x80000000 0x60000000>;
label = "DDR SYSTEM";
};
tcml_code: code@1fff8000 {
compatible = "nxp,imx-code-bus";
reg = <0x1fff8000 0x8000>;
label = "TCML CODE";
};
tcmu_sys: memory@20000000 {
device_type = "memory";
compatible = "nxp,imx-sys-bus";
reg = <0x20000000 0x8000>;
label = "TCMU SYSTEM";
};
ocram_code: code@00900000 {
compatible = "nxp,imx-code-bus";
reg = <0x00900000 0x20000>;
label = "OCRAM CODE";
};
ocram_sys: memory@20200000 {
device_type = "memory";
compatible = "nxp,imx-sys-bus";
reg = <0x20200000 0x20000>;
label = "OCRAM SYSTEM";
};
ocram_s_code: code@20180000 {
compatible = "nxp,imx-code-bus";
reg = <0x20180000 0x8000>;
label = "OCRAM_S CODE";
};
ocram_s_sys: memory@00180000 {
device_type = "memory";
compatible = "nxp,imx-sys-bus";
reg = <0x00180000 0x8000>;
label = "OCRAM_S SYSTEM";
};
gpio1: gpio@30200000 {
compatible = "nxp,imx-gpio";
reg = <0x30200000 0x10000>;
interrupts = <62 0>, <63 0>;
label = "GPIO_1";
};
/* For now only uart2 is supported and
* tested with the serial driver
*/
uart1: uart@30860000 {
compatible = "nxp,imx-uart";
reg = <0x30860000 0x10000>;
interrupts = <26 3>;
label = "UART_1";
status = "disabled";
};
uart2: uart@30890000 {
compatible = "nxp,imx-uart";
reg = <0x30890000 0x10000>;
interrupts = <27 3>;
label = "UART_2";
status = "disabled";
};
uart3: uart@30880000 {
compatible = "nxp,imx-uart";
reg = <0x30880000 0x10000>;
interrupts = <28 3>;
label = "UART_3";
status = "disabled";
};
uart4: uart@30A60000 {
compatible = "nxp,imx-uart";
reg = <0x30A60000 0x10000>;
interrupts = <29 3>;
label = "UART_4";
status = "disabled";
};
uart5: uart@30A70000 {
compatible = "nxp,imx-uart";
reg = <0x30A70000 0x10000>;
interrupts = <30 3>;
label = "UART_5";
status = "disabled";
};
uart6: uart@30A80000 {
compatible = "nxp,imx-uart";
reg = <0x30A80000 0x10000>;
interrupts = <16 3>;
label = "UART_6";
status = "disabled";
};
uart7: uart@30A90000 {
compatible = "nxp,imx-uart";
reg = <0x30A90000 0x10000>;
interrupts = <126 3>;
label = "UART_7";
status = "disabled";
};
};
};
&nvic {
arm,num-irq-priority-bits = <4>;
};