Skip to content

Commit

Permalink
scripts: extract_dts_includes: Add simple defines for i2c/spi children
Browse files Browse the repository at this point in the history
To simply and reduce what one has to do in a fixup file for i2c & spi
devices, we generate aliased defines based on just the compatible name.

For the rare case that a driver supports more than one instance, than
the 'zephyr,index' property should be utilized to tell the instances
apart.

Signed-off-by: Kumar Gala <[email protected]>
  • Loading branch information
galak committed Jan 9, 2019
1 parent 831b1fb commit 651eb8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scripts/dts/extract/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,19 @@ def add_prop_aliases(node_address,

for alias in aliases[node_address]:
old_alias_label = alias_label_function(alias)
new_alias_label = new_alias_prefix + '_' + old_alias_label
dash = '_'
if alias == '':
dash = ''
new_alias_label = new_alias_prefix + dash + old_alias_label
cell_index = reduced[node_address]['props'].get('zephyr,index')
# If the node has a zephyr,index, use it since it means there might be
# multiple instances we need to tell apart
if (cell_index != None):
new_alias_label = new_alias_prefix + '_' + str(cell_index) + dash + old_alias_label

if (new_alias_label != prop_label):
prop_aliases[new_alias_label] = prop_label
if (old_alias_names and old_alias_label != prop_label):
if (old_alias_names and old_alias_label != prop_label and alias != ''):
prop_aliases[old_alias_label] = prop_label

def get_binding(node_address):
Expand Down
3 changes: 3 additions & 0 deletions scripts/dts/extract_dts_includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ def extract_property(node_compat, node_address, prop, prop_val, names):
# Need to generate alias name for this node:
aliases[node_address].append(node_alias)

# Add an alias for simple spi/i2c cases
aliases[node_address].append('')

# Use parent label to generate label
parent_label = get_node_label(parent_address)
def_label = parent_label + '_' + def_label
Expand Down

0 comments on commit 651eb8e

Please sign in to comment.