Skip to content

Commit beb43bd

Browse files
danieldegrassefabiobaltieri
authored andcommitted
soc: arm: nxp: add MK22F12 definition
Add SOC definition for MK22F12 series, larger LQFP-144 K22 series parts that feature additional peripheral instances. Additionally, these parts differ from the standard MK22 in the following ways: - SYSMPU peripheral is present, so an MPU definition is required - No external oscillator divider is present This commit also updates the NXP HAL to include pin control files for these SOCs. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 66a06d9 commit beb43bd

8 files changed

+159
-3
lines changed

dts/arm/nxp/nxp_k22fx512.dtsi

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2023 Daniel DeGrasse
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <nxp/nxp_k2x.dtsi>
8+
9+
/ {
10+
soc {
11+
i2c2: i2c@400e6000 {
12+
compatible = "nxp,kinetis-i2c";
13+
clock-frequency = <I2C_BITRATE_STANDARD>;
14+
#address-cells = <1>;
15+
#size-cells = <0>;
16+
reg = <0x400e6000 0x1000>;
17+
interrupts = <74 0>;
18+
clocks = <&sim KINETIS_SIM_BUS_CLK 0x1028 6>;
19+
status = "disabled";
20+
};
21+
22+
spi2: spi@400ac000 {
23+
reg = <0x400ac000 0x88>;
24+
interrupts = <65 3>;
25+
clocks = <&sim KINETIS_SIM_BUS_CLK 0x1030 12>;
26+
#address-cells = <1>;
27+
#size-cells = <0>;
28+
status = "disabled";
29+
};
30+
31+
uart4: uart@400ea000 {
32+
compatible = "nxp,kinetis-uart";
33+
reg = <0x400ea000 0x1000>;
34+
interrupts = <66 0>, <67 0>;
35+
interrupt-names = "status", "error";
36+
clocks = <&sim KINETIS_SIM_BUS_CLK 0x1028 10>;
37+
38+
status = "disabled";
39+
};
40+
41+
uart5: uart@400eb000 {
42+
compatible = "nxp,kinetis-uart";
43+
reg = <0x400eb000 0x1000>;
44+
interrupts = <68 0>, <69 0>;
45+
interrupt-names = "status", "error";
46+
clocks = <&sim KINETIS_SIM_BUS_CLK 0x1028 11>;
47+
48+
status = "disabled";
49+
};
50+
};
51+
};

soc/arm/nxp_kinetis/k2x/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ zephyr_sources(
99
soc.c
1010
)
1111

12+
if(DEFINED CONFIG_ARM_MPU AND DEFINED CONFIG_CPU_HAS_NXP_MPU)
13+
# MK22F12 series MCUs have NXP MPU
14+
zephyr_sources(nxp_mpu_regions.c)
15+
endif()
16+
1217
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")

soc/arm/nxp_kinetis/k2x/Kconfig.defconfig.mk22f12

+3
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ config SOC
1111
config GPIO
1212
default y
1313

14+
config NUM_IRQS
15+
default 74
16+
1417
endif # SOC_MK22F12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2023 Daniel DeGrasse
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Kinetis MK22FX12 configuration options
5+
6+
if SOC_MK22F12
7+
8+
config SOC
9+
default "mk22f12"
10+
11+
config NUM_IRQS
12+
default 81
13+
14+
config CPU_HAS_CUSTOM_FIXED_SOC_MPU_REGIONS
15+
default y
16+
17+
endif # SOC_MK22F12

soc/arm/nxp_kinetis/k2x/Kconfig.defconfig.series

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ if SOC_SERIES_KINETIS_K2X
1212
config SOC_SERIES
1313
default "k2x"
1414

15-
config NUM_IRQS
16-
default 74
17-
1815
source "soc/arm/nxp_kinetis/k2x/Kconfig.defconfig.mk*"
1916

2017
endif # SOC_SERIES_KINETIS_K2X

soc/arm/nxp_kinetis/k2x/Kconfig.soc

+22
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ config SOC_MK22F51212
2626
select HAS_MCUX_DAC
2727
select HAS_MCUX_RCM
2828

29+
# Note- the MK22F12 SKU is a legacy SOC, no longer officially supported by
30+
# NXP's MCUX SDK, and not recommended for new designs.
31+
config SOC_MK22F12
32+
bool "SOC_MK22F12"
33+
select HAS_MCUX
34+
select HAS_MCUX_SMC
35+
select HAS_MCUX_ADC16
36+
select HAS_MCUX_FTFX
37+
select HAS_MCUX_FTM
38+
select HAS_MCUX_RNGA
39+
select HAS_MCUX_SIM
40+
select HAS_OSC
41+
select HAS_MCG
42+
select CPU_HAS_FPU
43+
select HAS_MCUX_DAC
44+
select HAS_MCUX_RCM
45+
select CPU_HAS_NXP_MPU
46+
2947
endchoice
3048

3149
if SOC_SERIES_KINETIS_K2X
@@ -36,9 +54,13 @@ config SOC_PART_NUMBER_MK22FN512VLH12
3654
config SOC_PART_NUMBER_MK22FX512AVLK12
3755
bool
3856

57+
config SOC_PART_NUMBER_MK22FX512VLQ12
58+
bool
59+
3960
config SOC_PART_NUMBER_KINETIS_K2X
4061
string
4162
default "MK22FN512VLH12" if SOC_PART_NUMBER_MK22FN512VLH12
63+
default "MK22FX512VLQ12" if SOC_PART_NUMBER_MK22FX512VLQ12
4264
help
4365
This string holds the full part number of the SoC. It is a hidden option
4466
that you should not set directly. The part number selection choice defines
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2023 Daniel DeGrasse
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <soc.h>
7+
#include <zephyr/arch/arm/mpu/nxp_mpu.h>
8+
9+
static const struct nxp_mpu_region mpu_regions[] = {
10+
/* Region 0 */
11+
/* Debugger access can't be disabled; ENET and USB devices will not be able
12+
* to access RAM when their regions are dynamically disabled in NXP MPU.
13+
*/
14+
MPU_REGION_ENTRY("DEBUGGER_0",
15+
0,
16+
0xFFFFFFFF,
17+
REGION_DEBUGGER_AND_DEVICE_ATTR),
18+
19+
/* The NXP MPU does not give precedence to memory regions like the ARM
20+
* MPU, which means that if one region grants access then another
21+
* region cannot revoke access. If an application enables hardware
22+
* stack protection, we need to disable supervisor writes from the core
23+
* to the stack guard region. As a result, we cannot have a single
24+
* background region that enables supervisor read/write access from the
25+
* core to the entire address space, and instead define two background
26+
* regions that together cover the entire address space except for
27+
* SRAM.
28+
*/
29+
30+
/* Region 1 */
31+
MPU_REGION_ENTRY("BACKGROUND_0",
32+
0,
33+
CONFIG_SRAM_BASE_ADDRESS-1,
34+
REGION_BACKGROUND_ATTR),
35+
/* Region 2 */
36+
MPU_REGION_ENTRY("BACKGROUND_1",
37+
CONFIG_SRAM_BASE_ADDRESS +
38+
(CONFIG_SRAM_SIZE * 1024),
39+
0xFFFFFFFF,
40+
REGION_BACKGROUND_ATTR),
41+
/* Region 3 */
42+
MPU_REGION_ENTRY("FLASH_0",
43+
CONFIG_FLASH_BASE_ADDRESS,
44+
(CONFIG_FLASH_BASE_ADDRESS +
45+
(CONFIG_FLASH_SIZE * 1024) - 1),
46+
REGION_FLASH_ATTR),
47+
/* Region 4 */
48+
MPU_REGION_ENTRY("RAM_U_0",
49+
CONFIG_SRAM_BASE_ADDRESS,
50+
(CONFIG_SRAM_BASE_ADDRESS +
51+
(CONFIG_SRAM_SIZE * 1024) - 1),
52+
REGION_RAM_ATTR),
53+
};
54+
55+
const struct nxp_mpu_config mpu_config = {
56+
.num_regions = ARRAY_SIZE(mpu_regions),
57+
.mpu_regions = mpu_regions,
58+
.sram_region = 4,
59+
};

soc/arm/nxp_kinetis/k2x/soc.c

+2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ static const osc_config_t oscConfig = {
4949

5050
.oscerConfig = {
5151
.enableMode = 0U, /* Disable external reference clock */
52+
#if FSL_FEATURE_OSC_HAS_EXT_REF_CLOCK_DIVIDER
5253
.erclkDiv = 0U,
54+
#endif
5355
},
5456
};
5557

0 commit comments

Comments
 (0)