mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-10-02 11:11:40 +02:00
dtoc: Tidy up the list of supported phandle properties
For now dtoc only supports a hard-coded list of phandle properties, to avoid any situation where it makes a mistake in its determination. Make this into a constant dict, recording both the phandle property name and the associated #cells property in the target node. This makes it easier to find and modify. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
c4085d733b
commit
8840bc56fb
@ -52,6 +52,20 @@ TYPE_NAMES = {
|
|||||||
STRUCT_PREFIX = 'dtd_'
|
STRUCT_PREFIX = 'dtd_'
|
||||||
VAL_PREFIX = 'dtv_'
|
VAL_PREFIX = 'dtv_'
|
||||||
|
|
||||||
|
# Properties which are considered to be phandles
|
||||||
|
# key: property name
|
||||||
|
# value: name of associated #cells property in the target node
|
||||||
|
#
|
||||||
|
# New phandle properties must be added here; otherwise they will come through as
|
||||||
|
# simple integers and finding devices by phandle will not work.
|
||||||
|
# Any property that ends with one of these (e.g. 'cd-gpios') will be considered
|
||||||
|
# a phandle property.
|
||||||
|
PHANDLE_PROPS = {
|
||||||
|
'clocks': '#clock-cells',
|
||||||
|
'gpios': '#gpio-cells',
|
||||||
|
'sandbox,emul': '#emul-cells',
|
||||||
|
}
|
||||||
|
|
||||||
class Ftype(IntEnum):
|
class Ftype(IntEnum):
|
||||||
SOURCE, HEADER = range(2)
|
SOURCE, HEADER = range(2)
|
||||||
|
|
||||||
@ -290,7 +304,11 @@ class DtbPlatdata():
|
|||||||
ValueError: if the phandle cannot be parsed or the required property
|
ValueError: if the phandle cannot be parsed or the required property
|
||||||
is not present
|
is not present
|
||||||
"""
|
"""
|
||||||
if prop.name in ['clocks', 'cd-gpios']:
|
cells_prop = None
|
||||||
|
for name, cprop in PHANDLE_PROPS.items():
|
||||||
|
if prop.name.endswith(name):
|
||||||
|
cells_prop = cprop
|
||||||
|
if cells_prop:
|
||||||
if not isinstance(prop.value, list):
|
if not isinstance(prop.value, list):
|
||||||
prop.value = [prop.value]
|
prop.value = [prop.value]
|
||||||
val = prop.value
|
val = prop.value
|
||||||
@ -310,14 +328,10 @@ class DtbPlatdata():
|
|||||||
if not target:
|
if not target:
|
||||||
raise ValueError("Cannot parse '%s' in node '%s'" %
|
raise ValueError("Cannot parse '%s' in node '%s'" %
|
||||||
(prop.name, node_name))
|
(prop.name, node_name))
|
||||||
cells = None
|
cells = target.props.get(cells_prop)
|
||||||
for prop_name in ['#clock-cells', '#gpio-cells']:
|
|
||||||
cells = target.props.get(prop_name)
|
|
||||||
if cells:
|
|
||||||
break
|
|
||||||
if not cells:
|
if not cells:
|
||||||
raise ValueError("Node '%s' has no cells property" %
|
raise ValueError("Node '%s' has no cells property" %
|
||||||
(target.name))
|
target.name)
|
||||||
num_args = fdt_util.fdt32_to_cpu(cells.value)
|
num_args = fdt_util.fdt32_to_cpu(cells.value)
|
||||||
max_args = max(max_args, num_args)
|
max_args = max(max_args, num_args)
|
||||||
args.append(num_args)
|
args.append(num_args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user