Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: extract_dts_includes: Add simple defines for i2c/spi children #11886

Closed
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions dts/bindings/i2c/i2c-device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ properties:
category: required
description: Human readable string describing the device (used by Zephyr for API name)
generation: define
zephyr,index:
type: int
category: optional
description: Instance ID (Start at 0, used if system has more than one)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess starting at 0 is not mandatory, is it?

...
4 changes: 4 additions & 0 deletions dts/bindings/spi/spi-device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ properties:
category: required
description: Human readable string describing the device (used by Zephyr for API name)
generation: define
zephyr,index:
type: int
category: optional
description: Instance ID (Start at 0, used if system has more than one)
...
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
4 changes: 3 additions & 1 deletion tests/drivers/i2c/i2c_slave_api/nucleo_f091rc.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
reg = <0x54>;
label = "EEPROM_SLAVE_0";
size = <1>;
zephyr,index = <0>;
};
};

Expand All @@ -21,5 +22,6 @@
reg = <0x56>;
label = "EEPROM_SLAVE_1";
size = <1>;
zephyr,index = <1>;
};
};
};
4 changes: 3 additions & 1 deletion tests/drivers/i2c/i2c_slave_api/stm32f072b_disco.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
reg = <0x54>;
label = "EEPROM_SLAVE_0";
size = <1>;
zephyr,index = <0>;
};
};

Expand All @@ -21,5 +22,6 @@
reg = <0x56>;
label = "EEPROM_SLAVE_1";
size = <1>;
zephyr,index = <1>;
};
};
};