Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions scripts/dts/extract_dts_includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
from extract.default import default


def extract_bus_name(node_path, def_label):
label = def_label + '_BUS_NAME'
def extract_parent_label(node_path, def_label, def_label_postfix):
label = def_label + '_' + def_label_postfix
prop_alias = {}

add_compat_alias(node_path, 'BUS_NAME', label, prop_alias)
add_compat_alias(node_path, def_label_postfix, label, prop_alias)

# Generate defines for node aliases
if node_path in aliases:
add_prop_aliases(
node_path,
lambda alias: str_to_label(alias) + '_BUS_NAME',
lambda alias: str_to_label(alias) + '_' + def_label_postfix,
label,
prop_alias)

Expand All @@ -61,16 +61,21 @@ def generate_prop_defines(node_path, prop):
# Generates #defines (and .conf file values) from the prop
# named 'prop' on the device tree node at 'node_path'

parent_path = get_parent_path(node_path)
binding = get_binding(node_path)
if 'parent' in binding and 'bus' in binding['parent']:
# If the binding specifies a parent for the node, then include the
# parent in the #define's generated for the properties
parent_path = get_parent_path(node_path)
def_label = 'DT_' + node_label(parent_path) + '_' \
+ node_label(node_path)
else:
def_label = 'DT_' + node_label(node_path)

if prop == 'label' and 'label' in reduced[parent_path]['props']:
# If both the node and its parent have the 'label' property,
# generate *_PARENT_LABEL #define
extract_parent_label(node_path, def_label, 'PARENT_LABEL')

names = prop_names(reduced[node_path], prop)

if prop == 'reg':
Expand Down Expand Up @@ -172,9 +177,10 @@ def generate_bus_defines(node_path):
aliases[node_path].append(node_alias)

# Generate *_BUS_NAME #define
extract_bus_name(
extract_parent_label(
node_path,
'DT_' + node_label(parent_path) + '_' + node_label(node_path))
'DT_' + node_label(parent_path) + '_' + node_label(node_path),
'BUS_NAME')


def prop_names(node, prop_name):
Expand Down