scripts: dts: Generalize '#cells' to allow multiple sources
Implement a nice generalization suggested by Bobby Noelte. Instead of having a generic #cells key in bindings, have source-specific *-cells keys. Some examples: interrupt-cells: - irq - priority - flags gpio-cells: - pin - flags pwm-cells: - channel - period This makes bindings a bit easier to read, and allows a node to be a controller for many different 'phandle-array' properties. The prefix before *-cells is derived from the property name, meaning there's no fixed set of *-cells keys. This is possible because of the earlier 'phandle-array' generalization. The older #cells key is supported for backwards compatibility, but generates a deprecation warning. Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This commit is contained in:
parent
4f3b0cb28c
commit
567c348167
78 changed files with 182 additions and 127 deletions
|
@ -126,8 +126,9 @@ parent-bus: <string describing bus type, e.g. "i2c">
|
|||
# Taking 'pwms' as an example, the final -s is stripped from the property
|
||||
# name, and #pwm-cells is looked up in the node for the controller
|
||||
# (&ctrl-1/&ctrl-2) to determine the number of data values after the
|
||||
# phandle. The binding for each controller must also have a #cells key,
|
||||
# giving names to data values. See below for an explanation of #cells.
|
||||
# phandle. The binding for each controller must also have a *-cells key
|
||||
# (e.g. pwm-cells), giving names to data values. See below for an
|
||||
# explanation of *-cells.
|
||||
#
|
||||
# A *-names (e.g. pwm-names) property can appear on the node as well,
|
||||
# giving a name to each entry (the 'pwms' example above has two entries,
|
||||
|
@ -286,28 +287,41 @@ child-binding:
|
|||
|
||||
# If the binding describes an interrupt controller, GPIO controller, pinmux
|
||||
# device, or any other node referenced by other nodes via 'phandle-array'
|
||||
# properties, then #cells should be given.
|
||||
# properties, then *-cells should be given.
|
||||
#
|
||||
# To understand the purpose of #cells, assume that some node has
|
||||
# To understand the purpose of *-cells, assume that some node has
|
||||
#
|
||||
# foo-gpios = <&gpio-ctrl 1 2>;
|
||||
# pwms = <&pwm-ctrl 1 2>;
|
||||
#
|
||||
# , where &gpio-ctrl refers to a node whose binding is this file.
|
||||
# , where &pwm-ctrl refers to a node whose binding is this file.
|
||||
#
|
||||
# The <1 2> part of the property value is called a *specifier* (this
|
||||
# terminology is from the devicetree specification), and contains additional
|
||||
# data associated with the GPIO. Here, the specifier has two cells, and the
|
||||
# node pointed at by &gpio-ctrl is expected to have '#gpio-cells = <2>'.
|
||||
# node pointed at by &gpio-ctrl is expected to have '#pwm-cells = <2>'.
|
||||
#
|
||||
# #cells gives a name to each cell in the specifier. These names are used
|
||||
# when generating identifiers.
|
||||
# *-cells gives a name to each cell in the specifier. These names are used when
|
||||
# generating identifiers.
|
||||
#
|
||||
# In this example, assume that 1 refers to a pin and that 2 is a flag value.
|
||||
# This gives a #cells assignment like below.
|
||||
"#cells":
|
||||
- pin # name of first cell
|
||||
- flag # name of second cell
|
||||
# This gives a *-cells assignment like below.
|
||||
pwm-cells:
|
||||
- channel # name of first cell
|
||||
- period # name of second cell
|
||||
|
||||
# If the specifier is empty (e.g. '#clock-cells = <0>'), then #cells can either
|
||||
# be omitted (recommended) or set to an empty array. Note that an empty array
|
||||
# is specified as '"#cells": []' in YAML.
|
||||
# If the specifier is empty (e.g. '#clock-cells = <0>'), then *-cells can
|
||||
# either be omitted (recommended) or set to an empty array. Note that an empty
|
||||
# array is specified as e.g. 'clock-cells: []' in YAML.
|
||||
|
||||
# As a special case, all *-gpio properties map to the key 'gpio-cells',
|
||||
# regardless of prefix
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
||||
# This older syntax is deprecated and will generate a warning when used. It
|
||||
# works as a catch-all, where the name of the referencing 'phandle-array'
|
||||
# property doesn't matter.
|
||||
"#cells":
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -20,5 +20,5 @@ properties:
|
|||
"#clock-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
clock-cells:
|
||||
- name
|
||||
|
|
|
@ -20,5 +20,5 @@ properties:
|
|||
"#clock-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
clock-cells:
|
||||
- name
|
||||
|
|
|
@ -120,5 +120,5 @@ properties:
|
|||
"#clock-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
clock-cells:
|
||||
- name
|
||||
|
|
|
@ -32,7 +32,7 @@ properties:
|
|||
required: false
|
||||
const: 3
|
||||
|
||||
"#cells":
|
||||
clock-cells:
|
||||
- name
|
||||
- offset
|
||||
- bits
|
||||
|
|
|
@ -20,7 +20,7 @@ properties:
|
|||
"#clock-cells":
|
||||
const: 3
|
||||
|
||||
"#cells":
|
||||
clock-cells:
|
||||
- name
|
||||
- offset
|
||||
- bits
|
||||
|
|
|
@ -14,6 +14,6 @@ properties:
|
|||
"#clock-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
clock-cells:
|
||||
- bus
|
||||
- bits
|
||||
|
|
|
@ -17,6 +17,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -25,6 +25,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -17,6 +17,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -18,6 +18,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -14,6 +14,6 @@ properties:
|
|||
label:
|
||||
required: true
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -23,6 +23,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -23,6 +23,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -20,6 +20,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -28,6 +28,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -17,6 +17,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -20,6 +20,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -17,6 +17,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -23,6 +23,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -17,6 +17,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -17,6 +17,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -17,6 +17,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -28,6 +28,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -23,6 +23,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -23,6 +23,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -21,6 +21,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -21,6 +21,6 @@ properties:
|
|||
"#gpio-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- pin
|
||||
- flags
|
||||
|
|
|
@ -22,5 +22,5 @@ properties:
|
|||
"#io-channel-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
io-channel-cells:
|
||||
- input
|
||||
|
|
|
@ -30,5 +30,5 @@ properties:
|
|||
"#io-channel-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
io-channel-cells:
|
||||
- input
|
||||
|
|
|
@ -23,5 +23,5 @@ properties:
|
|||
"#io-channel-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
io-channel-cells:
|
||||
- input
|
||||
|
|
|
@ -20,5 +20,5 @@ properties:
|
|||
"#io-channel-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
io-channel-cells:
|
||||
- input
|
||||
|
|
|
@ -20,5 +20,5 @@ properties:
|
|||
"#io-channel-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
io-channel-cells:
|
||||
- input
|
||||
|
|
|
@ -40,5 +40,5 @@ properties:
|
|||
"#io-channel-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
io-channel-cells:
|
||||
- input
|
||||
|
|
|
@ -20,5 +20,5 @@ properties:
|
|||
"#io-channel-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
io-channel-cells:
|
||||
- input
|
||||
|
|
|
@ -24,5 +24,5 @@ properties:
|
|||
"#io-channel-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
io-channel-cells:
|
||||
- input
|
||||
|
|
|
@ -17,7 +17,7 @@ properties:
|
|||
label:
|
||||
required: true
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- priority
|
||||
- flags
|
||||
|
|
|
@ -19,6 +19,6 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- priority
|
||||
|
|
|
@ -19,6 +19,6 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- priority
|
||||
|
|
|
@ -19,6 +19,6 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- priority
|
||||
|
|
|
@ -5,7 +5,7 @@ description: >
|
|||
|
||||
compatible: "intel,cavs-intc"
|
||||
|
||||
include: base.yaml
|
||||
include: [interrupt-controller.yaml, base.yaml]
|
||||
|
||||
properties:
|
||||
reg:
|
||||
|
@ -17,7 +17,7 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 3
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- sense
|
||||
- priority
|
||||
|
|
|
@ -15,7 +15,7 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 3
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- sense
|
||||
- priority
|
||||
|
|
|
@ -18,5 +18,5 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
|
|
|
@ -20,5 +20,5 @@ properties:
|
|||
interrupts:
|
||||
required: true
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
|
|
|
@ -14,5 +14,5 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
|
|
|
@ -17,5 +17,5 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
|
|
|
@ -12,6 +12,6 @@ compatible: "snps,archs-idu-intc"
|
|||
|
||||
include: [interrupt-controller.yaml, base.yaml]
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- priority
|
||||
|
|
|
@ -14,6 +14,6 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- priority
|
||||
|
|
|
@ -17,7 +17,7 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 3
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- sense
|
||||
- priority
|
||||
|
|
|
@ -22,6 +22,6 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- priority
|
||||
|
|
|
@ -14,7 +14,7 @@ properties:
|
|||
"#interrupt-cells":
|
||||
const: 3
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- irq
|
||||
- sense
|
||||
- priority
|
||||
|
|
|
@ -14,6 +14,6 @@ properties:
|
|||
label:
|
||||
required: true
|
||||
|
||||
"#cells":
|
||||
pinmux-cells:
|
||||
- pin
|
||||
- function
|
||||
|
|
|
@ -12,6 +12,6 @@ properties:
|
|||
reg:
|
||||
required: true
|
||||
|
||||
"#cells":
|
||||
pinmux-cells:
|
||||
- pin
|
||||
- function
|
||||
|
|
|
@ -14,6 +14,6 @@ properties:
|
|||
clocks:
|
||||
required: true
|
||||
|
||||
"#cells":
|
||||
pinmux-cells:
|
||||
- pin
|
||||
- function
|
||||
|
|
|
@ -14,6 +14,6 @@ properties:
|
|||
clocks:
|
||||
required: true
|
||||
|
||||
"#cells":
|
||||
pinmux-cells:
|
||||
- pin
|
||||
- function
|
||||
|
|
|
@ -11,6 +11,6 @@ properties:
|
|||
reg:
|
||||
required: true
|
||||
|
||||
"#cells":
|
||||
pinmux-cells:
|
||||
- pin
|
||||
- function
|
||||
|
|
|
@ -12,6 +12,6 @@ properties:
|
|||
reg:
|
||||
required: true
|
||||
|
||||
"#cells":
|
||||
pinmux-cells:
|
||||
- pin
|
||||
- function
|
||||
|
|
|
@ -35,7 +35,7 @@ properties:
|
|||
"#pwm-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
pwm-cells:
|
||||
- channel
|
||||
# period in terms of nanoseconds
|
||||
- period
|
||||
|
|
|
@ -30,7 +30,7 @@ properties:
|
|||
"#pwm-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
pwm-cells:
|
||||
- channel
|
||||
# period in terms of nanoseconds
|
||||
- period
|
||||
|
|
|
@ -25,5 +25,5 @@ properties:
|
|||
"#pwm-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
pwm-cells:
|
||||
- channel
|
||||
|
|
|
@ -20,7 +20,7 @@ properties:
|
|||
"#pwm-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
pwm-cells:
|
||||
- channel
|
||||
# period in terms of nanoseconds
|
||||
- period
|
||||
|
|
|
@ -30,7 +30,7 @@ properties:
|
|||
"#pwm-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
pwm-cells:
|
||||
- channel
|
||||
# period in terms of nanoseconds
|
||||
- period
|
||||
|
|
|
@ -19,7 +19,7 @@ properties:
|
|||
"#pwm-cells":
|
||||
const: 2
|
||||
|
||||
"#cells":
|
||||
pwm-cells:
|
||||
- channel
|
||||
# period in terms of nanoseconds
|
||||
- period
|
||||
|
|
|
@ -20,5 +20,5 @@ properties:
|
|||
"#clock-cells":
|
||||
const: 1
|
||||
|
||||
"#cells":
|
||||
clock-cells:
|
||||
- name
|
||||
|
|
|
@ -844,7 +844,7 @@ class Node:
|
|||
# #<name>-cells = <size>
|
||||
#
|
||||
# property that gives the number of cells in the value after the
|
||||
# phandle. These values are given names in #cells in the binding for
|
||||
# phandle. These values are given names in *-cells in the binding for
|
||||
# the controller.
|
||||
#
|
||||
# Also parses any
|
||||
|
@ -882,31 +882,31 @@ class Node:
|
|||
|
||||
return res
|
||||
|
||||
def _named_cells(self, controller, data, controller_s):
|
||||
# Returns a dictionary that maps #cells names given in the binding for
|
||||
# 'controller' to cell values. 'data' is the raw data, as a byte array,
|
||||
# and 'controller_s' a string that gives the context (for error
|
||||
# messages).
|
||||
def _named_cells(self, controller, data, basename):
|
||||
# Returns a dictionary that maps <basename>-cells names given in the
|
||||
# binding for 'controller' to cell values. 'data' is the raw data, as a
|
||||
# byte array.
|
||||
|
||||
if not controller._binding:
|
||||
_err("{} controller {!r} for {!r} lacks binding"
|
||||
.format(controller_s, controller._node, self._node))
|
||||
.format(basename, controller._node, self._node))
|
||||
|
||||
if "#cells" in controller._binding:
|
||||
if basename + "-cells" in controller._binding:
|
||||
cell_names = controller._binding[basename + "-cells"]
|
||||
elif "#cells" in controller._binding:
|
||||
# Backwards compatibility
|
||||
cell_names = controller._binding["#cells"]
|
||||
if not isinstance(cell_names, list):
|
||||
_err("binding for {} controller {!r} has malformed #cells array"
|
||||
.format(controller_s, controller._node))
|
||||
else:
|
||||
# Treat no #cells in the binding the same as an empty #cells, so
|
||||
# that bindings don't have to have an empty #cells for e.g.
|
||||
# Treat no *-cells in the binding the same as an empty *-cells, so
|
||||
# that bindings don't have to have e.g. an empty 'clock-cells:' for
|
||||
# '#clock-cells = <0>'.
|
||||
cell_names = []
|
||||
|
||||
data_list = to_nums(data)
|
||||
if len(data_list) != len(cell_names):
|
||||
_err("unexpected #cells length in binding for {!r} - {} instead "
|
||||
"of {}".format(controller._node, len(cell_names),
|
||||
_err("unexpected '{}-cells:' length in binding for {!r} - {} "
|
||||
"instead of {}"
|
||||
.format(basename, controller._node, len(cell_names),
|
||||
len(data_list)))
|
||||
|
||||
return dict(zip(cell_names, data_list))
|
||||
|
@ -971,9 +971,9 @@ class ControllerAndData:
|
|||
gets sent to for interrupts)
|
||||
|
||||
data:
|
||||
A dictionary that maps names from the #cells key in the binding for
|
||||
the controller to data values, e.g. {"pin": 4, "flags": 0} for the
|
||||
example above.
|
||||
A dictionary that maps names from the *-cells key in the binding for the
|
||||
controller to data values, e.g. {"pin": 4, "flags": 0} for the example
|
||||
above.
|
||||
|
||||
'interrupts = <1 2>' might give {"irq": 1, "level": 2}.
|
||||
|
||||
|
@ -1291,8 +1291,8 @@ def _check_binding(binding, binding_path):
|
|||
"sub-node"}
|
||||
|
||||
for prop in binding:
|
||||
if prop not in ok_top:
|
||||
_err("unknown key '{}' in {}, expected one of {}"
|
||||
if prop not in ok_top and not prop.endswith("-cells"):
|
||||
_err("unknown key '{}' in {}, expected one of {}, or *-cells"
|
||||
.format(prop, binding_path, ", ".join(ok_top)))
|
||||
|
||||
for pc in "parent", "child":
|
||||
|
@ -1339,6 +1339,26 @@ def _check_binding(binding, binding_path):
|
|||
|
||||
_check_binding_properties(binding["sub-node"], binding_path)
|
||||
|
||||
if "#cells" in binding:
|
||||
_warn('"#cells:" in {} is deprecated and will be removed - please put '
|
||||
"'interrupt-cells:', 'pwm-cells:', 'gpio-cells:', etc., "
|
||||
"instead. The name should match the name of the corresponding "
|
||||
"phandle-array property (see binding-template.yaml)"
|
||||
.format(binding_path))
|
||||
|
||||
def ok_cells_val(val):
|
||||
# Returns True if 'val' is an okay value for '*-cells:' (or the legacy
|
||||
# '#cells:')
|
||||
|
||||
return isinstance(val, list) and \
|
||||
all(isinstance(elm, str) for elm in val)
|
||||
|
||||
for key, val in binding.items():
|
||||
if key.endswith("-cells") or key == "#cells":
|
||||
if not ok_cells_val(val):
|
||||
_err("malformed '{}:' in {}, expected a list of strings"
|
||||
.format(key, binding_path))
|
||||
|
||||
|
||||
def _check_binding_properties(binding, binding_path):
|
||||
# _check_binding() helper for checking the contents of 'properties:'
|
||||
|
|
|
@ -46,8 +46,14 @@ class DTClocks(DTDirective):
|
|||
'#clock-cells', 0))
|
||||
clock_cells_string = clock_provider_bindings.get(
|
||||
'cell_string', 'CLOCK')
|
||||
clock_cells_names = clock_provider_bindings.get(
|
||||
'#cells', ['ID', 'CELL1', "CELL2", "CELL3"])
|
||||
|
||||
if "clock-cells" in clock_provider_bindings:
|
||||
clock_cells_names = clock_provider_bindings["clock-cells"]
|
||||
elif "#cells" in clock_provider_bindings:
|
||||
clock_cells_names = clock_provider_bindings["#cells"]
|
||||
else:
|
||||
clock_cells_names = ["ID", "CELL1", "CELL2", "CELL3"]
|
||||
|
||||
clock_cells = []
|
||||
else:
|
||||
clock_cells.append(cell)
|
||||
|
|
|
@ -538,8 +538,8 @@ def extract_cells(node_path, prop, prop_values, names, index,
|
|||
# Get number of cells per element of current property
|
||||
for props in reduced[cell_parent]['props']:
|
||||
if props[0] == '#' and '-cells' in props:
|
||||
if props in cell_yaml:
|
||||
cell_yaml_names = props
|
||||
if props[1:] in cell_yaml:
|
||||
cell_yaml_names = props[1:] # #foo-cells -> foo-cells
|
||||
else:
|
||||
cell_yaml_names = '#cells'
|
||||
|
||||
|
|
|
@ -55,7 +55,12 @@ class DTInterrupts(DTDirective):
|
|||
l_cell_prefix = ['IRQ']
|
||||
|
||||
for i in range(reduced[irq_parent]['props']['#interrupt-cells']):
|
||||
l_cell_name = [cell_yaml['#cells'][i].upper()]
|
||||
if "interrupt-cells" in cell_yaml:
|
||||
cell_yaml_name = "interrupt-cells"
|
||||
else:
|
||||
cell_yaml_name = "#cells"
|
||||
|
||||
l_cell_name = [cell_yaml[cell_yaml_name][i].upper()]
|
||||
if l_cell_name == l_cell_prefix:
|
||||
l_cell_name = []
|
||||
|
||||
|
|
|
@ -433,8 +433,8 @@ def write_irqs(node):
|
|||
while irq_ctrl.interrupts:
|
||||
irq_num = (irq_num + 1) << 8
|
||||
if "irq" not in irq_ctrl.interrupts[0].data:
|
||||
err("Expected binding for {!r} to have 'irq' "
|
||||
"in '#cells'".format(irq_ctrl))
|
||||
err("Expected binding for {!r} to have 'irq' in *-cells"
|
||||
.format(irq_ctrl))
|
||||
irq_num |= irq_ctrl.interrupts[0].data["irq"]
|
||||
irq_ctrl = irq_ctrl.interrupts[0].controller
|
||||
return irq_num
|
||||
|
@ -476,7 +476,7 @@ def write_phandle_val_list(prop):
|
|||
# generates output like this:
|
||||
#
|
||||
# #define <device prefix>_PWMS_CONTROLLER_0 "PWM_0" (name taken from 'label = ...')
|
||||
# #define <device prefix>_PWMS_CHANNEL_0 123 (name taken from #cells in binding)
|
||||
# #define <device prefix>_PWMS_CHANNEL_0 123 (name taken from *-cells in binding)
|
||||
# #define <device prefix>_PWMS_0 {"PWM_0", 123}
|
||||
# #define <device prefix>_PWMS_CONTROLLER_1 "PWM_1"
|
||||
# #define <device prefix>_PWMS_CHANNEL_1 456
|
||||
|
|
|
@ -26,6 +26,11 @@ properties:
|
|||
# Deprecated older 'child-binding'-alike
|
||||
sub-node:
|
||||
properties:
|
||||
child-prop:
|
||||
type: int
|
||||
foos:
|
||||
type: phandle-array
|
||||
required: true
|
||||
|
||||
# Deprecated older catch-all version of *-cells
|
||||
"#cells":
|
||||
- foo
|
||||
- bar
|
||||
|
|
|
@ -5,5 +5,5 @@ description: GPIO destination for mapping test
|
|||
|
||||
compatible: "gpio-dst"
|
||||
|
||||
"#cells":
|
||||
gpio-cells:
|
||||
- val
|
||||
|
|
|
@ -5,5 +5,5 @@ description: Interrupt controller with one cell
|
|||
|
||||
compatible: "interrupt-one-cell"
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- one
|
||||
|
|
|
@ -5,6 +5,6 @@ description: Interrupt controller with two cells
|
|||
|
||||
compatible: "interrupt-two-cell"
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- one
|
||||
- two
|
||||
|
|
|
@ -5,7 +5,7 @@ description: Interrupt controller with three cells
|
|||
|
||||
compatible: "interrupt-three-cell"
|
||||
|
||||
"#cells":
|
||||
interrupt-cells:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
|
|
|
@ -5,5 +5,8 @@ description: Controller with one data value
|
|||
|
||||
compatible: "phandle-array-controller-1"
|
||||
|
||||
"#cells":
|
||||
phandle-array-foo-cells:
|
||||
- one
|
||||
|
||||
gpio-cells:
|
||||
- gpio-one
|
||||
|
|
|
@ -5,6 +5,6 @@ description: Controller with two data values
|
|||
|
||||
compatible: "phandle-array-controller-2"
|
||||
|
||||
"#cells":
|
||||
phandle-array-foo-cells:
|
||||
- one
|
||||
- two
|
||||
|
|
|
@ -337,8 +337,9 @@
|
|||
compatible = "deprecated";
|
||||
required = <1>;
|
||||
required-2 = <2>;
|
||||
#foo-cells = <2>;
|
||||
sub-node {
|
||||
child-prop = <3>;
|
||||
foos = <&{/deprecated} 1 2>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -129,11 +129,12 @@ def run():
|
|||
verify_streq(grandchild.props, "{'grandchild-prop': <Property, name: grandchild-prop, type: int, value: 2>}")
|
||||
|
||||
#
|
||||
# Test deprecated 'sub-node:' key (replaced with 'child-binding:')
|
||||
# Test deprecated 'sub-node' key (replaced with 'child-binding') and
|
||||
# deprecated '#cells' key (replaced with '*-cells')
|
||||
#
|
||||
|
||||
verify_streq(edt.get_node("/deprecated/sub-node").props,
|
||||
"{'child-prop': <Property, name: child-prop, type: int, value: 3>}")
|
||||
"{'foos': <Property, name: foos, type: phandle-array, value: [<ControllerAndData, controller: <Node /deprecated in 'test.dts', binding test-bindings/deprecated.yaml>, data: {'foo': 1, 'bar': 2}>]>}")
|
||||
|
||||
#
|
||||
# Test Node.props (derived from DT and 'properties:' in the binding)
|
||||
|
@ -170,7 +171,7 @@ def run():
|
|||
"<Property, name: phandle-array-foos, type: phandle-array, value: [<ControllerAndData, controller: <Node /props/ctrl-1 in 'test.dts', binding test-bindings/phandle-array-controller-1.yaml>, data: {'one': 1}>, <ControllerAndData, controller: <Node /props/ctrl-2 in 'test.dts', binding test-bindings/phandle-array-controller-2.yaml>, data: {'one': 2, 'two': 3}>]>")
|
||||
|
||||
verify_streq(edt.get_node("/props").props["foo-gpios"],
|
||||
"<Property, name: foo-gpios, type: phandle-array, value: [<ControllerAndData, controller: <Node /props/ctrl-1 in 'test.dts', binding test-bindings/phandle-array-controller-1.yaml>, data: {'one': 1}>]>")
|
||||
"<Property, name: foo-gpios, type: phandle-array, value: [<ControllerAndData, controller: <Node /props/ctrl-1 in 'test.dts', binding test-bindings/phandle-array-controller-1.yaml>, data: {'gpio-one': 1}>]>")
|
||||
|
||||
#
|
||||
# Test <prefix>-map, via gpio-map (the most common case)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue