From 6681f8d342b1e05d5f726d23023ca82212c1c051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Arg=C3=BCelles?= Date: Fri, 30 May 2025 19:50:19 +0700 Subject: [PATCH] soc: nxp: s32k3: configure missing mpu regions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a regression introduced in c31640239c7 where all regions except Flash and RAM where left unmapped. Before introducing region 0 that prevents speculative access to the entire memory space, we were relying on the architectural background map to access them. Signed-off-by: Manuel Argüelles --- dts/arm/nxp/nxp_s32k344_m7.dtsi | 5 ++++- soc/nxp/s32/s32k3/mpu_regions.c | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/dts/arm/nxp/nxp_s32k344_m7.dtsi b/dts/arm/nxp/nxp_s32k344_m7.dtsi index 91628a3dad4..a98c379bb42 100644 --- a/dts/arm/nxp/nxp_s32k344_m7.dtsi +++ b/dts/arm/nxp/nxp_s32k344_m7.dtsi @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 NXP + * Copyright 2023-2025 NXP * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,6 +8,7 @@ #include #include #include +#include / { cpus { @@ -45,12 +46,14 @@ compatible = "zephyr,memory-region", "arm,itcm"; reg = <0x00000000 DT_SIZE_K(64)>; zephyr,memory-region = "ITCM"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_FLASH) )>; }; dtcm: memory@20000000 { compatible = "zephyr,memory-region", "arm,dtcm"; reg = <0x20000000 DT_SIZE_K(128)>; zephyr,memory-region = "DTCM"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_RAM) )>; }; sram0_1: sram0_1@20400000 { diff --git a/soc/nxp/s32/s32k3/mpu_regions.c b/soc/nxp/s32/s32k3/mpu_regions.c index ce6e5fcfd20..a410948f1b2 100644 --- a/soc/nxp/s32/s32k3/mpu_regions.c +++ b/soc/nxp/s32/s32k3/mpu_regions.c @@ -12,11 +12,16 @@ extern char _rom_attr[]; #endif +#define REGION_PERIPHERAL_BASE_ADDRESS 0x40000000 +#define REGION_PERIPHERAL_SIZE REGION_512M +#define REGION_PPB_BASE_ADDRESS 0xE0000000 +#define REGION_PPB_SIZE REGION_1M + static struct arm_mpu_region mpu_regions[] = { /* ERR011573: use first region to prevent speculative access in entire memory space */ { - .name = "BACKGROUND", + .name = "UNMAPPED", .base = 0, .attr = {REGION_4G | MPU_RASR_XN_Msk | P_NA_U_NA_Msk}, }, @@ -42,6 +47,18 @@ static struct arm_mpu_region mpu_regions[] = { .attr = {(uint32_t)_rom_attr}, }, #endif + + { + .name = "PERIPHERALS", + .base = REGION_PERIPHERAL_BASE_ADDRESS, + .attr = REGION_IO_ATTR(REGION_PERIPHERAL_SIZE), + }, + + { + .name = "PPB", + .base = REGION_PPB_BASE_ADDRESS, + .attr = REGION_PPB_ATTR(REGION_PPB_SIZE), + }, }; const struct arm_mpu_config mpu_config = {