Skip to content

Commit 67ea01c

Browse files
author
Sathish Kumar Kamishettigari
committed
lopper:assist: Generate xparameters and CMake variables from the misc_props node
Update Lopper to consume the misc_props node generated by SDT in pcw.dtsi and automatically propagate its properties into bare-metal xparameters.h macros and CMake metadata. This enables new user-defined properties added under misc_props to flow through to the BSP without requiring additional Lopper assist changes. Signed-off-by: Sathish Kumar Kamishettigari <sathishkumar.kamishettigari@amd.com>
1 parent c57d85f commit 67ea01c

4 files changed

Lines changed: 61 additions & 0 deletions

File tree

lopper/assists/baremetal_xparameters_xlnx.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ def xlnx_generate_xparams(tgt_node, sdt, options):
576576
val = sdt.tree[tgt_node].propval('semnpi-scan', list)[0]
577577
plat.buf(f'\n#define XSEM_NPISCAN_EN {val}\n')
578578

579+
#Define for new properties added under misc_props in pcw.dtsi
580+
utils.gen_misc_props_macros(plat, sdt)
581+
579582
if is_fpd_coherent:
580583
plat.buf("\n#define XPAR_FPD_IS_CACHE_COHERENT \n")
581584
if is_lpd_coherent:

lopper/assists/bmcmake_metadata_xlnx.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ def generate_hwtocmake_medata(sdt, node_list, src_path, repo_path_data, options,
319319
if sdt.tree['/'].propval('speed_grade') != ['']:
320320
val = sdt.tree['/'].propval('speed_grade', list)[0]
321321
fd.write(f'set(SPEED_GRADE "{val}" CACHE STRING "Speed Grade")\n')
322+
#Generate cmake variable for the properties added under misc_props in pcw.dtsi
323+
utils.gen_misc_props_cmake_vars(fd, sdt)
322324
if sdt.tree['/'].propval('board') != ['']:
323325
val = sdt.tree['/'].propval('board', list)[0]
324326
fd.write(f'set(BOARD "{val}" CACHE STRING "BOARD")\n')

lopper/assists/common_utils.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,56 @@ def run_exec(yaml_condition, proc_ip_name, family, variant=None, return_list="ex
222222
_warning(f"The condition in the {yaml_file} file has failed. -> {e}")
223223
finally:
224224
return local_scope[return_list]
225+
226+
def _iter_misc_props(sdt):
227+
"""Yield (prop_name, value) pairs from the misc_props node."""
228+
for node in sdt.tree['/'].subnodes():
229+
if node.name != "misc_props":
230+
continue
231+
for prop_name in node.__props__:
232+
prop_val = node.propval(prop_name)
233+
if prop_val == [''] or prop_val == []:
234+
yield prop_name, None
235+
elif len(prop_val) == 1:
236+
yield prop_name, prop_val[0]
237+
else:
238+
yield prop_name, prop_val
239+
return
240+
241+
def gen_misc_props_macros(plat, sdt):
242+
"""Generate xparameters macros for properties under misc_props."""
243+
for prop_name, val in _iter_misc_props(sdt):
244+
var_name = prop_name.replace('xlnx,', '').replace('-', '_').upper()
245+
plat.buf(f"\n/* {prop_name} */\n")
246+
if val is None:
247+
plat.buf(f"#define {var_name}\n")
248+
elif isinstance(val, bool):
249+
plat.buf(f"#define {var_name} {str(val).lower()}\n")
250+
elif isinstance(val, int):
251+
plat.buf(f"#define {var_name} {hex(val)}\n")
252+
elif isinstance(val, str):
253+
plat.buf(f"#define {var_name} {val}\n")
254+
elif isinstance(val, list):
255+
formatted = ' '.join(hex(v) if isinstance(v, int) else str(v) for v in val)
256+
plat.buf(f"#define {var_name} {formatted}\n")
257+
else:
258+
plat.buf(f"#define {var_name} {val}\n")
259+
260+
def gen_misc_props_cmake_vars(fd, sdt):
261+
"""Generate CMake variables for properties under misc_props."""
262+
for prop_name, val in _iter_misc_props(sdt):
263+
var_name = prop_name.replace('xlnx,', '').replace('-', '_').upper()
264+
if val is None:
265+
fd.write(f'set({var_name} "ON" CACHE STRING "{prop_name}")\n')
266+
elif isinstance(val, bool):
267+
cmake_val = "ON" if val else "OFF"
268+
fd.write(f'set({var_name} "{cmake_val}" CACHE STRING "{prop_name}")\n')
269+
elif isinstance(val, int):
270+
fd.write(f'set({var_name} {hex(val)} CACHE STRING "{prop_name}")\n')
271+
elif isinstance(val, str):
272+
fd.write(f'set({var_name} "{val}" CACHE STRING "{prop_name}")\n')
273+
elif isinstance(val, list):
274+
items = [hex(v) if isinstance(v, int) else str(v) for v in val]
275+
fd.write(f'set({var_name} {to_cmakelist(items)} CACHE STRING "{prop_name}")\n')
276+
else:
277+
fd.write(f'set({var_name} "{val}" CACHE STRING "{prop_name}")\n')

lopper/assists/gen_domain_dts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,9 @@ def xlnx_generate_domain_dts(tgt_node, sdt, options):
632632

633633
mapped_children_nodes = []
634634
for node in root_sub_nodes:
635+
if (linux_dt or zephyr_dt) and node.name == "misc_props":
636+
sdt.tree.delete(node)
637+
continue
635638
if linux_dt:
636639
if node.propval('xlnx,ip-name') != ['']:
637640
val = node.propval('xlnx,ip-name', list)[0]

0 commit comments

Comments
 (0)