From 5062c51c496c7cfeeebf268ad2c14635f4c86731 Mon Sep 17 00:00:00 2001 From: Hou Zhiqiang Date: Sun, 21 Jan 2024 21:58:31 +0800 Subject: [PATCH] soc: mimx8m: set the UART devices RDC permission Add SoC initialization to set the UART RDC permission in the early phase, so that the it can be used by Zephyr on Cortex-A cores. Signed-off-by: Hou Zhiqiang --- soc/nxp/imx/imx8m/CMakeLists.txt | 1 + soc/nxp/imx/imx8m/Kconfig | 3 +++ soc/nxp/imx/imx8m/a53/soc.c | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 soc/nxp/imx/imx8m/a53/soc.c diff --git a/soc/nxp/imx/imx8m/CMakeLists.txt b/soc/nxp/imx/imx8m/CMakeLists.txt index 8f319c6827..8fdeaa518f 100644 --- a/soc/nxp/imx/imx8m/CMakeLists.txt +++ b/soc/nxp/imx/imx8m/CMakeLists.txt @@ -32,6 +32,7 @@ if(CONFIG_SOC_MIMX8ML8_A53 OR CONFIG_SOC_MIMX8MM6_A53 OR CONFIG_SOC_MIMX8MN6_A53 zephyr_sources( a53/pinctrl_soc.h + a53/soc.c ) zephyr_sources_ifdef(CONFIG_ARM_MMU a53/mmu_regions.c) diff --git a/soc/nxp/imx/imx8m/Kconfig b/soc/nxp/imx/imx8m/Kconfig index 41b6dc6abd..4020862a92 100644 --- a/soc/nxp/imx/imx8m/Kconfig +++ b/soc/nxp/imx/imx8m/Kconfig @@ -8,6 +8,7 @@ config SOC_MIMX8MM6_A53 select HAS_MCUX if CLOCK_CONTROL select HAS_MCUX_CCM if CLOCK_CONTROL select HAS_MCUX_IOMUXC if PINCTRL + select HAS_MCUX_RDC config SOC_MIMX8MM6_M4 select ARM @@ -27,6 +28,7 @@ config SOC_MIMX8ML8_A53 select HAS_MCUX if CLOCK_CONTROL select HAS_MCUX_CCM if CLOCK_CONTROL select HAS_MCUX_IOMUXC if PINCTRL + select HAS_MCUX_RDC config SOC_MIMX8MN6_A53 select ARM64 @@ -35,6 +37,7 @@ config SOC_MIMX8MN6_A53 select HAS_MCUX if CLOCK_CONTROL select HAS_MCUX_CCM if CLOCK_CONTROL select HAS_MCUX_IOMUXC if PINCTRL + select HAS_MCUX_RDC config SOC_MIMX8MP_ADSP select XTENSA diff --git a/soc/nxp/imx/imx8m/a53/soc.c b/soc/nxp/imx/imx8m/a53/soc.c new file mode 100644 index 0000000000..412880e402 --- /dev/null +++ b/soc/nxp/imx/imx8m/a53/soc.c @@ -0,0 +1,46 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include + +/* set RDC permission for peripherals */ +static void soc_rdc_init(void) +{ + rdc_domain_assignment_t assignment = {0}; + rdc_periph_access_config_t periphConfig; + + RDC_Init(RDC); + assignment.domainId = A53_DOMAIN_ID; + RDC_SetMasterDomainAssignment(RDC, kRDC_Master_A53, &assignment); + + RDC_GetDefaultPeriphAccessConfig(&periphConfig); + +#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay) && DT_NODE_HAS_PROP(DT_NODELABEL(uart2), rdc) + periphConfig.periph = kRDC_Periph_UART2; + periphConfig.policy = RDC_DT_VAL(uart2); + RDC_SetPeriphAccessConfig(RDC, &periphConfig); +#endif + +#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart4), okay) && DT_NODE_HAS_PROP(DT_NODELABEL(uart4), rdc) + periphConfig.periph = kRDC_Periph_UART4; + periphConfig.policy = RDC_DT_VAL(uart4); + RDC_SetPeriphAccessConfig(RDC, &periphConfig); +#endif +} + +static int soc_init(void) +{ + soc_rdc_init(); + return 0; +} + +SYS_INIT(soc_init, EARLY, 1);