scripts: devicetree.py: get alternate labels from dt

Allow use of new element of dtc grammar called overriding nodes:
i2cexp: &i2c2  {};

It allows a node to assign an alternate label to a node that
could be generic and used for adapter boards.
This commit is a derivative of a dtc commit from dtc v1.4.2 [1]

[1] https://bit.ly/2GFLLOa

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
Erwan Gouriou 2018-03-29 09:35:28 +02:00 committed by Kumar Gala
parent 7e2f6ebc7b
commit fa5d6ec363

View file

@ -48,15 +48,23 @@ def parse_node_name(line):
addr = None
if ':' in line:
label, name = line.split(':')
if len(line.split(':')) == 3:
alt_label, label, name = line.split(':')
else:
label, name = line.split(':')
alt_label = None
else:
name = line
label = None
alt_label = None
if addr is None:
return label, name.strip(), None, None
return label, name.strip(), None, None, None
return label, name.strip(), addr, int(addr, 16)
if alt_label is None:
return label, name.strip(), addr, int(addr, 16), None
return label, name.strip(), addr, int(addr, 16), alt_label
def parse_values_internal(value, start, end, separator):
out = []
@ -142,7 +150,7 @@ def build_node_name(name, addr):
return '%s@%s' % (name, addr.strip())
def parse_node(line, fd):
label, name, addr, numeric_addr = parse_node_name(line)
label, name, addr, numeric_addr, alt_label = parse_node_name(line)
node = {
'label': label,
@ -152,6 +160,9 @@ def parse_node(line, fd):
'props': {},
'name': build_node_name(name, addr)
}
if alt_label:
node['alt_name'] = alt_label
while True:
line = fd.readline()
if not line: