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:
Ulf Magnusson 2019-09-26 20:34:13 +02:00 committed by Kumar Gala
commit 567c348167
78 changed files with 182 additions and 127 deletions

View file

@ -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 # 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 # 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 # (&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, # phandle. The binding for each controller must also have a *-cells key
# giving names to data values. See below for an explanation of #cells. # (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, # 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, # 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 # If the binding describes an interrupt controller, GPIO controller, pinmux
# device, or any other node referenced by other nodes via 'phandle-array' # 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 # The <1 2> part of the property value is called a *specifier* (this
# terminology is from the devicetree specification), and contains additional # terminology is from the devicetree specification), and contains additional
# data associated with the GPIO. Here, the specifier has two cells, and the # 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 # *-cells gives a name to each cell in the specifier. These names are used when
# when generating identifiers. # generating identifiers.
# #
# In this example, assume that 1 refers to a pin and that 2 is a flag value. # In this example, assume that 1 refers to a pin and that 2 is a flag value.
# This gives a #cells assignment like below. # This gives a *-cells assignment like below.
"#cells": pwm-cells:
- pin # name of first cell - channel # name of first cell
- flag # name of second cell - period # name of second cell
# If the specifier is empty (e.g. '#clock-cells = <0>'), then #cells can either # If the specifier is empty (e.g. '#clock-cells = <0>'), then *-cells can
# be omitted (recommended) or set to an empty array. Note that an empty array # either be omitted (recommended) or set to an empty array. Note that an empty
# is specified as '"#cells": []' in YAML. # 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

View file

@ -20,5 +20,5 @@ properties:
"#clock-cells": "#clock-cells":
const: 1 const: 1
"#cells": clock-cells:
- name - name

View file

@ -20,5 +20,5 @@ properties:
"#clock-cells": "#clock-cells":
const: 1 const: 1
"#cells": clock-cells:
- name - name

View file

@ -120,5 +120,5 @@ properties:
"#clock-cells": "#clock-cells":
const: 1 const: 1
"#cells": clock-cells:
- name - name

View file

@ -32,7 +32,7 @@ properties:
required: false required: false
const: 3 const: 3
"#cells": clock-cells:
- name - name
- offset - offset
- bits - bits

View file

@ -20,7 +20,7 @@ properties:
"#clock-cells": "#clock-cells":
const: 3 const: 3
"#cells": clock-cells:
- name - name
- offset - offset
- bits - bits

View file

@ -14,6 +14,6 @@ properties:
"#clock-cells": "#clock-cells":
const: 2 const: 2
"#cells": clock-cells:
- bus - bus
- bits - bits

View file

@ -17,6 +17,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -25,6 +25,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -17,6 +17,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -18,6 +18,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -14,6 +14,6 @@ properties:
label: label:
required: true required: true
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -23,6 +23,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -23,6 +23,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -20,6 +20,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -28,6 +28,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -17,6 +17,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -20,6 +20,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -17,6 +17,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -23,6 +23,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -17,6 +17,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -17,6 +17,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -17,6 +17,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -28,6 +28,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -23,6 +23,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -23,6 +23,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -21,6 +21,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -21,6 +21,6 @@ properties:
"#gpio-cells": "#gpio-cells":
const: 2 const: 2
"#cells": gpio-cells:
- pin - pin
- flags - flags

View file

@ -22,5 +22,5 @@ properties:
"#io-channel-cells": "#io-channel-cells":
const: 1 const: 1
"#cells": io-channel-cells:
- input - input

View file

@ -30,5 +30,5 @@ properties:
"#io-channel-cells": "#io-channel-cells":
const: 1 const: 1
"#cells": io-channel-cells:
- input - input

View file

@ -23,5 +23,5 @@ properties:
"#io-channel-cells": "#io-channel-cells":
const: 1 const: 1
"#cells": io-channel-cells:
- input - input

View file

@ -20,5 +20,5 @@ properties:
"#io-channel-cells": "#io-channel-cells":
const: 1 const: 1
"#cells": io-channel-cells:
- input - input

View file

@ -20,5 +20,5 @@ properties:
"#io-channel-cells": "#io-channel-cells":
const: 1 const: 1
"#cells": io-channel-cells:
- input - input

View file

@ -40,5 +40,5 @@ properties:
"#io-channel-cells": "#io-channel-cells":
const: 1 const: 1
"#cells": io-channel-cells:
- input - input

View file

@ -20,5 +20,5 @@ properties:
"#io-channel-cells": "#io-channel-cells":
const: 1 const: 1
"#cells": io-channel-cells:
- input - input

View file

@ -24,5 +24,5 @@ properties:
"#io-channel-cells": "#io-channel-cells":
const: 1 const: 1
"#cells": io-channel-cells:
- input - input

View file

@ -17,7 +17,7 @@ properties:
label: label:
required: true required: true
"#cells": interrupt-cells:
- irq - irq
- priority - priority
- flags - flags

View file

@ -19,6 +19,6 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 2 const: 2
"#cells": interrupt-cells:
- irq - irq
- priority - priority

View file

@ -19,6 +19,6 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 2 const: 2
"#cells": interrupt-cells:
- irq - irq
- priority - priority

View file

@ -19,6 +19,6 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 2 const: 2
"#cells": interrupt-cells:
- irq - irq
- priority - priority

View file

@ -5,7 +5,7 @@ description: >
compatible: "intel,cavs-intc" compatible: "intel,cavs-intc"
include: base.yaml include: [interrupt-controller.yaml, base.yaml]
properties: properties:
reg: reg:
@ -17,7 +17,7 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 3 const: 3
"#cells": interrupt-cells:
- irq - irq
- sense - sense
- priority - priority

View file

@ -15,7 +15,7 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 3 const: 3
"#cells": interrupt-cells:
- irq - irq
- sense - sense
- priority - priority

View file

@ -18,5 +18,5 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 1 const: 1
"#cells": interrupt-cells:
- irq - irq

View file

@ -20,5 +20,5 @@ properties:
interrupts: interrupts:
required: true required: true
"#cells": interrupt-cells:
- irq - irq

View file

@ -14,5 +14,5 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 1 const: 1
"#cells": interrupt-cells:
- irq - irq

View file

@ -17,5 +17,5 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 1 const: 1
"#cells": interrupt-cells:
- irq - irq

View file

@ -12,6 +12,6 @@ compatible: "snps,archs-idu-intc"
include: [interrupt-controller.yaml, base.yaml] include: [interrupt-controller.yaml, base.yaml]
"#cells": interrupt-cells:
- irq - irq
- priority - priority

View file

@ -14,6 +14,6 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 2 const: 2
"#cells": interrupt-cells:
- irq - irq
- priority - priority

View file

@ -17,7 +17,7 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 3 const: 3
"#cells": interrupt-cells:
- irq - irq
- sense - sense
- priority - priority

View file

@ -22,6 +22,6 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 2 const: 2
"#cells": interrupt-cells:
- irq - irq
- priority - priority

View file

@ -14,7 +14,7 @@ properties:
"#interrupt-cells": "#interrupt-cells":
const: 3 const: 3
"#cells": interrupt-cells:
- irq - irq
- sense - sense
- priority - priority

View file

@ -14,6 +14,6 @@ properties:
label: label:
required: true required: true
"#cells": pinmux-cells:
- pin - pin
- function - function

View file

@ -12,6 +12,6 @@ properties:
reg: reg:
required: true required: true
"#cells": pinmux-cells:
- pin - pin
- function - function

View file

@ -14,6 +14,6 @@ properties:
clocks: clocks:
required: true required: true
"#cells": pinmux-cells:
- pin - pin
- function - function

View file

@ -14,6 +14,6 @@ properties:
clocks: clocks:
required: true required: true
"#cells": pinmux-cells:
- pin - pin
- function - function

View file

@ -11,6 +11,6 @@ properties:
reg: reg:
required: true required: true
"#cells": pinmux-cells:
- pin - pin
- function - function

View file

@ -12,6 +12,6 @@ properties:
reg: reg:
required: true required: true
"#cells": pinmux-cells:
- pin - pin
- function - function

View file

@ -35,7 +35,7 @@ properties:
"#pwm-cells": "#pwm-cells":
const: 2 const: 2
"#cells": pwm-cells:
- channel - channel
# period in terms of nanoseconds # period in terms of nanoseconds
- period - period

View file

@ -30,7 +30,7 @@ properties:
"#pwm-cells": "#pwm-cells":
const: 2 const: 2
"#cells": pwm-cells:
- channel - channel
# period in terms of nanoseconds # period in terms of nanoseconds
- period - period

View file

@ -25,5 +25,5 @@ properties:
"#pwm-cells": "#pwm-cells":
const: 1 const: 1
"#cells": pwm-cells:
- channel - channel

View file

@ -20,7 +20,7 @@ properties:
"#pwm-cells": "#pwm-cells":
const: 2 const: 2
"#cells": pwm-cells:
- channel - channel
# period in terms of nanoseconds # period in terms of nanoseconds
- period - period

View file

@ -30,7 +30,7 @@ properties:
"#pwm-cells": "#pwm-cells":
const: 2 const: 2
"#cells": pwm-cells:
- channel - channel
# period in terms of nanoseconds # period in terms of nanoseconds
- period - period

View file

@ -19,7 +19,7 @@ properties:
"#pwm-cells": "#pwm-cells":
const: 2 const: 2
"#cells": pwm-cells:
- channel - channel
# period in terms of nanoseconds # period in terms of nanoseconds
- period - period

View file

@ -20,5 +20,5 @@ properties:
"#clock-cells": "#clock-cells":
const: 1 const: 1
"#cells": clock-cells:
- name - name

View file

@ -844,7 +844,7 @@ class Node:
# #<name>-cells = <size> # #<name>-cells = <size>
# #
# property that gives the number of cells in the value after the # 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. # the controller.
# #
# Also parses any # Also parses any
@ -882,32 +882,32 @@ class Node:
return res return res
def _named_cells(self, controller, data, controller_s): def _named_cells(self, controller, data, basename):
# Returns a dictionary that maps #cells names given in the binding for # Returns a dictionary that maps <basename>-cells names given in the
# 'controller' to cell values. 'data' is the raw data, as a byte array, # binding for 'controller' to cell values. 'data' is the raw data, as a
# and 'controller_s' a string that gives the context (for error # byte array.
# messages).
if not controller._binding: if not controller._binding:
_err("{} controller {!r} for {!r} lacks 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"] 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: else:
# Treat no #cells in the binding the same as an empty #cells, so # 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. # that bindings don't have to have e.g. an empty 'clock-cells:' for
# '#clock-cells = <0>'. # '#clock-cells = <0>'.
cell_names = [] cell_names = []
data_list = to_nums(data) data_list = to_nums(data)
if len(data_list) != len(cell_names): if len(data_list) != len(cell_names):
_err("unexpected #cells length in binding for {!r} - {} instead " _err("unexpected '{}-cells:' length in binding for {!r} - {} "
"of {}".format(controller._node, len(cell_names), "instead of {}"
len(data_list))) .format(basename, controller._node, len(cell_names),
len(data_list)))
return dict(zip(cell_names, data_list)) return dict(zip(cell_names, data_list))
@ -971,9 +971,9 @@ class ControllerAndData:
gets sent to for interrupts) gets sent to for interrupts)
data: data:
A dictionary that maps names from the #cells key in the binding for A dictionary that maps names from the *-cells key in the binding for the
the controller to data values, e.g. {"pin": 4, "flags": 0} for the controller to data values, e.g. {"pin": 4, "flags": 0} for the example
example above. above.
'interrupts = <1 2>' might give {"irq": 1, "level": 2}. 'interrupts = <1 2>' might give {"irq": 1, "level": 2}.
@ -1291,8 +1291,8 @@ def _check_binding(binding, binding_path):
"sub-node"} "sub-node"}
for prop in binding: for prop in binding:
if prop not in ok_top: if prop not in ok_top and not prop.endswith("-cells"):
_err("unknown key '{}' in {}, expected one of {}" _err("unknown key '{}' in {}, expected one of {}, or *-cells"
.format(prop, binding_path, ", ".join(ok_top))) .format(prop, binding_path, ", ".join(ok_top)))
for pc in "parent", "child": for pc in "parent", "child":
@ -1339,6 +1339,26 @@ def _check_binding(binding, binding_path):
_check_binding_properties(binding["sub-node"], 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): def _check_binding_properties(binding, binding_path):
# _check_binding() helper for checking the contents of 'properties:' # _check_binding() helper for checking the contents of 'properties:'

View file

@ -46,8 +46,14 @@ class DTClocks(DTDirective):
'#clock-cells', 0)) '#clock-cells', 0))
clock_cells_string = clock_provider_bindings.get( clock_cells_string = clock_provider_bindings.get(
'cell_string', 'CLOCK') '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 = [] clock_cells = []
else: else:
clock_cells.append(cell) clock_cells.append(cell)

View file

@ -538,8 +538,8 @@ def extract_cells(node_path, prop, prop_values, names, index,
# Get number of cells per element of current property # Get number of cells per element of current property
for props in reduced[cell_parent]['props']: for props in reduced[cell_parent]['props']:
if props[0] == '#' and '-cells' in props: if props[0] == '#' and '-cells' in props:
if props in cell_yaml: if props[1:] in cell_yaml:
cell_yaml_names = props cell_yaml_names = props[1:] # #foo-cells -> foo-cells
else: else:
cell_yaml_names = '#cells' cell_yaml_names = '#cells'

View file

@ -55,7 +55,12 @@ class DTInterrupts(DTDirective):
l_cell_prefix = ['IRQ'] l_cell_prefix = ['IRQ']
for i in range(reduced[irq_parent]['props']['#interrupt-cells']): 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: if l_cell_name == l_cell_prefix:
l_cell_name = [] l_cell_name = []

View file

@ -433,8 +433,8 @@ def write_irqs(node):
while irq_ctrl.interrupts: while irq_ctrl.interrupts:
irq_num = (irq_num + 1) << 8 irq_num = (irq_num + 1) << 8
if "irq" not in irq_ctrl.interrupts[0].data: if "irq" not in irq_ctrl.interrupts[0].data:
err("Expected binding for {!r} to have 'irq' " err("Expected binding for {!r} to have 'irq' in *-cells"
"in '#cells'".format(irq_ctrl)) .format(irq_ctrl))
irq_num |= irq_ctrl.interrupts[0].data["irq"] irq_num |= irq_ctrl.interrupts[0].data["irq"]
irq_ctrl = irq_ctrl.interrupts[0].controller irq_ctrl = irq_ctrl.interrupts[0].controller
return irq_num return irq_num
@ -476,7 +476,7 @@ def write_phandle_val_list(prop):
# generates output like this: # generates output like this:
# #
# #define <device prefix>_PWMS_CONTROLLER_0 "PWM_0" (name taken from 'label = ...') # #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_0 {"PWM_0", 123}
# #define <device prefix>_PWMS_CONTROLLER_1 "PWM_1" # #define <device prefix>_PWMS_CONTROLLER_1 "PWM_1"
# #define <device prefix>_PWMS_CHANNEL_1 456 # #define <device prefix>_PWMS_CHANNEL_1 456

View file

@ -26,6 +26,11 @@ properties:
# Deprecated older 'child-binding'-alike # Deprecated older 'child-binding'-alike
sub-node: sub-node:
properties: properties:
child-prop: foos:
type: int type: phandle-array
required: true required: true
# Deprecated older catch-all version of *-cells
"#cells":
- foo
- bar

View file

@ -5,5 +5,5 @@ description: GPIO destination for mapping test
compatible: "gpio-dst" compatible: "gpio-dst"
"#cells": gpio-cells:
- val - val

View file

@ -5,5 +5,5 @@ description: Interrupt controller with one cell
compatible: "interrupt-one-cell" compatible: "interrupt-one-cell"
"#cells": interrupt-cells:
- one - one

View file

@ -5,6 +5,6 @@ description: Interrupt controller with two cells
compatible: "interrupt-two-cell" compatible: "interrupt-two-cell"
"#cells": interrupt-cells:
- one - one
- two - two

View file

@ -5,7 +5,7 @@ description: Interrupt controller with three cells
compatible: "interrupt-three-cell" compatible: "interrupt-three-cell"
"#cells": interrupt-cells:
- one - one
- two - two
- three - three

View file

@ -5,5 +5,8 @@ description: Controller with one data value
compatible: "phandle-array-controller-1" compatible: "phandle-array-controller-1"
"#cells": phandle-array-foo-cells:
- one - one
gpio-cells:
- gpio-one

View file

@ -5,6 +5,6 @@ description: Controller with two data values
compatible: "phandle-array-controller-2" compatible: "phandle-array-controller-2"
"#cells": phandle-array-foo-cells:
- one - one
- two - two

View file

@ -337,8 +337,9 @@
compatible = "deprecated"; compatible = "deprecated";
required = <1>; required = <1>;
required-2 = <2>; required-2 = <2>;
#foo-cells = <2>;
sub-node { sub-node {
child-prop = <3>; foos = <&{/deprecated} 1 2>;
}; };
}; };
}; };

View file

@ -129,11 +129,12 @@ def run():
verify_streq(grandchild.props, "{'grandchild-prop': <Property, name: grandchild-prop, type: int, value: 2>}") 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, 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) # 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}>]>") "<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"], 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) # Test <prefix>-map, via gpio-map (the most common case)