scripts: gen_defines: emit pinctrl helper macros
We need to be able to access pinctrl-<index> property contents by name, convert names to indexes, convert indexes to names, and perform existence checks by name and by index. This is currently not possible because we don't track these properties the same way we do other named properties. That in turn is because they are different then the usual named properties. The usual case looks like this, picking DMAs just for the sake of example: dmas = <&dma0 ...>, <&dma1 ...>; dma-names = "tx", "rx"; So "tx" is the name for the <&dma0 ...> element, and "rx" is the name for the <&dma1 ...> element, all in a single "dmas" property. By contrast, pinctrl properties look like this: pinctrl-0 = <&foo &bar ...>; pinctrl-1 = <&baz &blub ...>; pinctrl-names = "default", "sleep"; Here, "default" is the name for the entire pinctrl-0 property. Similarly, "sleep" is the name of the pinctrl-1 property. It's a strange situation where the node itself is kind of a container for an array of pin control properties, which Zephyr's bindings language can't really capture and has some special case handling in edtlib. This is easiest to handle with ad-hoc code. Add special case macros for pinctrls. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
7f69a03f72
commit
9df0493dc3
1 changed files with 31 additions and 0 deletions
|
@ -361,6 +361,7 @@ def write_special_props(node):
|
||||||
|
|
||||||
# Macros that are special to bindings inherited from Linux, which
|
# Macros that are special to bindings inherited from Linux, which
|
||||||
# we can't capture with the current bindings language.
|
# we can't capture with the current bindings language.
|
||||||
|
write_pinctrls(node)
|
||||||
write_fixed_partitions(node)
|
write_fixed_partitions(node)
|
||||||
|
|
||||||
def write_regs(node):
|
def write_regs(node):
|
||||||
|
@ -509,6 +510,36 @@ def write_status(node):
|
||||||
out_dt_define(f"{node.z_path_id}_STATUS_{str2ident(node.status)}", 1)
|
out_dt_define(f"{node.z_path_id}_STATUS_{str2ident(node.status)}", 1)
|
||||||
|
|
||||||
|
|
||||||
|
def write_pinctrls(node):
|
||||||
|
# Write special macros for pinctrl-<index> and pinctrl-names properties.
|
||||||
|
|
||||||
|
out_comment("Pin control (pinctrl-<i>, pinctrl-names) properties:")
|
||||||
|
|
||||||
|
out_dt_define(f"{node.z_path_id}_PINCTRL_NUM", len(node.pinctrls))
|
||||||
|
|
||||||
|
if not node.pinctrls:
|
||||||
|
return
|
||||||
|
|
||||||
|
for pc_idx, pinctrl in enumerate(node.pinctrls):
|
||||||
|
out_dt_define(f"{node.z_path_id}_PINCTRL_IDX_{pc_idx}_EXISTS", 1)
|
||||||
|
|
||||||
|
if not pinctrl.name:
|
||||||
|
continue
|
||||||
|
|
||||||
|
name = pinctrl.name_as_token
|
||||||
|
|
||||||
|
# Below we rely on the fact that edtlib ensures the
|
||||||
|
# pinctrl-<pc_idx> properties are contiguous, start from 0,
|
||||||
|
# and contain only phandles.
|
||||||
|
out_dt_define(f"{node.z_path_id}_PINCTRL_IDX_{pc_idx}_TOKEN", name)
|
||||||
|
out_dt_define(f"{node.z_path_id}_PINCTRL_IDX_{pc_idx}_UPPER_TOKEN", name.upper())
|
||||||
|
out_dt_define(f"{node.z_path_id}_PINCTRL_NAME_{name}_EXISTS", 1)
|
||||||
|
out_dt_define(f"{node.z_path_id}_PINCTRL_NAME_{name}_IDX", pc_idx)
|
||||||
|
for idx, ph in enumerate(pinctrl.conf_nodes):
|
||||||
|
out_dt_define(f"{node.z_path_id}_PINCTRL_NAME_{name}_IDX_{idx}_PH",
|
||||||
|
f"DT_{ph.z_path_id}")
|
||||||
|
|
||||||
|
|
||||||
def write_fixed_partitions(node):
|
def write_fixed_partitions(node):
|
||||||
# Macros for child nodes of each fixed-partitions node.
|
# Macros for child nodes of each fixed-partitions node.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue