Skip to content

Commit ffbfdf7

Browse files
soc: nordic: activate uicr generation and use correct dt reg check
- Activate the UICR file generation and PeriphConf for nRF92 application. - Add condition in reg dt check file to use the correct uicr node name for nRF92X. - Generation of preriphconf entries filters on device names to match the first 5 characters to nrf92 or the 6 first characters to nrf54h, this information is also used to determine the device SOC_SERIES to be either SOC_SERIES_NRF54HX or SOC_SERIES_NRF92X allowing possible extension of usage. Still in case of an unknown device of a certain family it will use existing configuration while generating periphconf entries. Signed-off-by: Aymen LAOUINI <[email protected]>
1 parent 69ad052 commit ffbfdf7

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

soc/nordic/common/uicr/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
config NRF_PERIPHCONF_SECTION
55
bool "Populate global peripheral initialization section"
6-
default y if SOC_NRF54H20_CPUAPP || SOC_NRF54H20_CPURAD
6+
default y if SOC_NRF54H20_CPUAPP || SOC_NRF54H20_CPURAD || SOC_NRF9280_CPUAPP
77
depends on LINKER_DEVNULL_SUPPORT
88
imply LINKER_DEVNULL_MEMORY
99
help
@@ -12,7 +12,7 @@ config NRF_PERIPHCONF_SECTION
1212

1313
config NRF_PERIPHCONF_GENERATE_ENTRIES
1414
bool "Generate PERIPHCONF entries source file"
15-
default y if SOC_NRF54H20_CPUAPP || SOC_NRF54H20_CPURAD
15+
default y if SOC_NRF54H20_CPUAPP || SOC_NRF54H20_CPURAD || SOC_NRF9280_CPUAPP
1616
depends on NRF_PERIPHCONF_SECTION
1717
depends on NRF_PLATFORM_HALTIUM
1818
help

soc/nordic/common/uicr/Kconfig.sysbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
config NRF_HALTIUM_GENERATE_UICR
55
bool "Generate UICR file"
6-
depends on SOC_SERIES_NRF54HX
6+
depends on SOC_SERIES_NRF54HX || SOC_SERIES_NRF92X
77
default y
88
help
99
Generate UICR HEX file.

soc/nordic/common/uicr/gen_periphconf_entries.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,50 @@ def get_additional_node_kwargs(node: Node) -> dict[str, Any]:
5555
return additional_kwargs
5656

5757

58+
class Family(enum.Enum):
59+
"""Families of SoCs supported by this script"""
60+
61+
SERIES_NRF54HX = "nrf54h"
62+
SERIES_NRF92X = "nrf92"
63+
SERIES_UNKNOWN = "unknown"
64+
65+
@classmethod
66+
def family(cls, soc):
67+
if soc.startswith("nrf54h") and len(soc) == 8:
68+
return cls.SERIES_NRF54HX
69+
elif soc.startswith("nrf92") and len(soc) == 7:
70+
return cls.SERIES_NRF92X
71+
else:
72+
return cls.SERIES_UNKNOWN
73+
74+
5875
class Soc(enum.Enum):
5976
"""Names of SoCs supported by this script"""
6077

6178
NRF54H20 = "nrf54h20"
6279
NRF9280 = "nrf9280"
80+
UNKNOWN = "unknown"
81+
82+
@classmethod
83+
def soc(cls, soc):
84+
if soc.startswith("nrf54h20") and len(soc) == 8:
85+
return cls.NRF54H20
86+
elif soc.startswith("nrf9280") and len(soc) == 7:
87+
return cls.NRF9280
88+
else:
89+
return cls.UNKNOWN
90+
91+
92+
def validate_soc_choice(soc):
93+
"""Helper for argparse to validate soc parameter type"""
94+
95+
if (soc.startswith("nrf54h") and soc[6:].isdigit() and len(soc) == 8) or \
96+
(soc.startswith("nrf92") and soc[5:].isdigit() and len(soc) == 7):
97+
return soc
98+
else:
99+
raise argparse.ArgumentTypeError(
100+
f"Invalid soc '{soc}'. Must start with 'nrf54h' or 'nrf92' followed by 2 digits."
101+
)
63102

64103

65104
def parse_args() -> argparse.Namespace:
@@ -79,8 +118,8 @@ def parse_args() -> argparse.Namespace:
79118
)
80119
parser.add_argument(
81120
"--soc",
121+
type=validate_soc_choice,
82122
required=True,
83-
choices=[soc.value for soc in Soc],
84123
help=(
85124
"SoC to generate PERIPHCONF macros for. "
86125
"Used to look up soc specific hardware information"
@@ -105,7 +144,7 @@ def main() -> None:
105144
args = parse_args()
106145
dt = pickle.load(args.in_edt_pickle)
107146
processor = dt_processor_id(dt)
108-
lookup_tables = lookup_tables_get(Soc(args.soc))
147+
lookup_tables = lookup_tables_get(Soc.soc(args.soc), Family.family(args.soc))
109148
builder = PeriphconfBuilder(dt, lookup_tables)
110149

111150
# Application local peripherals
@@ -135,7 +174,7 @@ def main() -> None:
135174
args.out_periphconf_source.write(generated_source)
136175

137176

138-
def lookup_tables_get(soc: Soc) -> SocLookupTables:
177+
def lookup_tables_get(soc: Soc, family : Family) -> SocLookupTables:
139178
if soc == Soc.NRF54H20:
140179
ctrlsel_lookup = {
141180
# CAN120
@@ -427,7 +466,7 @@ def lookup_tables_get(soc: Soc) -> SocLookupTables:
427466
NrfPsel(fun=NrfFun.IGNORE, port=2, pin=11): Ctrlsel.CAN,
428467
},
429468
}
430-
elif soc == Soc.NRF9280:
469+
elif soc == Soc.NRF9280 or (soc == Soc.UNKNOWN and family == Family.SERIES_NRF92X) :
431470
ctrlsel_lookup = {
432471
# PWM120
433472
0x5F8E_4000: {

soc/nordic/validate_base_addresses.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ CHECK_DT_REG(uart134, NRF_UARTE134);
346346
CHECK_DT_REG(uart135, NRF_UARTE135);
347347
CHECK_DT_REG(uart136, NRF_UARTE136);
348348
CHECK_DT_REG(uart137, NRF_UARTE137);
349-
#if !defined(CONFIG_SOC_SERIES_NRF54HX)
349+
#if !defined(CONFIG_SOC_SERIES_NRF54HX) && !defined(CONFIG_SOC_SERIES_NRF92X)
350350
CHECK_DT_REG(uicr, NRF_UICR);
351351
#else
352352
CHECK_DT_REG(uicr, NRF_APPLICATION_UICR);

0 commit comments

Comments
 (0)