Add support for phandle arrays in DevicetreeCompiler

This commit is contained in:
Ken Van Hoeylandt 2026-06-20 22:30:46 +02:00
parent f93c04e016
commit 019a8ee026
3 changed files with 9 additions and 1 deletions

View File

@ -88,6 +88,7 @@ def property_to_string(property: DeviceProperty, devices: list[Device]) -> str:
value_list.append(property_to_string(DeviceProperty(name="", type=item.type, value=item.value), devices))
else:
value_list.append(str(item))
value_list.append("{ 0 }")
return "{ " + ",".join(value_list) + " }"
elif isinstance(property.value, str):
# If it's a string, assume it's a #define and show it as-is

View File

@ -37,7 +37,10 @@ value: VALUE
values: VALUE+
array: NUMBER+
property_value: quoted_text_array | QUOTED_TEXT | "<" value ">" | "<" values ">" | "[" array "]" | PHANDLE
phandle_array_entry: "<" values ">"
phandle_array: phandle_array_entry ("," phandle_array_entry)+
property_value: quoted_text_array | QUOTED_TEXT | phandle_array | "<" value ">" | "<" values ">" | "[" array "]" | PHANDLE
device_property: PROPERTY_NAME ["=" property_value] ";"
NODE_ALIAS: /[a-zA-Z0-9_\-\/]+/

View File

@ -70,6 +70,10 @@ class DtsTransformer(Transformer):
if isinstance(object[0], PropertyValue):
return object[0]
return PropertyValue(type="value", value=object[0])
def phandle_array_entry(self, tokens: list):
return tokens[0]
def phandle_array(self, tokens: list):
return PropertyValue(type="phandle-array", value=tokens)
def array(self, object):
return PropertyValue(type="array", value=object)
def VALUE(self, token: Token):