dts: Add concept of sub-nodes to YAML and generator
Several bindings have an expectation of sub-nodes that describe the actual infomation. The sub-nodes don't have any compatiable so we can't key on that. So we can add the concept of a sub-node to the YAML to handle cases like 'gpio-keys', 'gpio-leds', 'pwm-leds', etc.. The sub-node in the YAML is effective the "binding" params that describe what properties should exist in the sub-node. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
a52df691d1
commit
bf0f6d911d
7 changed files with 93 additions and 30 deletions
|
@ -19,6 +19,21 @@ inherits:
|
||||||
# parent and child should share same bus-type value.
|
# parent and child should share same bus-type value.
|
||||||
bus: <bus-type>
|
bus: <bus-type>
|
||||||
|
|
||||||
|
sub-node:
|
||||||
|
# Used for cases in which a dts node has children, and the children dont
|
||||||
|
# require/specify a 'compatible' property. The sub-node is effective the
|
||||||
|
# binding for the child.
|
||||||
|
#
|
||||||
|
# Here's an example for a pwm-leds binding in which the child nodes
|
||||||
|
# would be required to have 'pwms' properties.
|
||||||
|
|
||||||
|
sub-node:
|
||||||
|
properties:
|
||||||
|
pwms:
|
||||||
|
type: compound
|
||||||
|
category: required
|
||||||
|
generation: define
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
|
|
||||||
# A typical property entry looks like this:
|
# A typical property entry looks like this:
|
||||||
|
|
|
@ -10,17 +10,22 @@ version: 0.1
|
||||||
description: >
|
description: >
|
||||||
This is a representation of the GPIO KEYS nodes
|
This is a representation of the GPIO KEYS nodes
|
||||||
|
|
||||||
inherits:
|
|
||||||
!include base.yaml
|
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
compatible:
|
compatible:
|
||||||
constraint: "gpio-keys"
|
constraint: "gpio-keys"
|
||||||
|
type: string-array
|
||||||
gpios:
|
|
||||||
type: compound
|
|
||||||
category: required
|
category: required
|
||||||
|
description: compatible strings
|
||||||
generation: define
|
generation: define
|
||||||
|
|
||||||
label:
|
sub-node:
|
||||||
category: required
|
properties:
|
||||||
|
gpios:
|
||||||
|
type: compound
|
||||||
|
category: required
|
||||||
|
generation: define
|
||||||
|
label:
|
||||||
|
category: required
|
||||||
|
type: string
|
||||||
|
description: Human readable string describing the device (used by Zephyr for API name)
|
||||||
|
generation: define
|
||||||
|
|
|
@ -10,17 +10,22 @@ version: 0.1
|
||||||
description: >
|
description: >
|
||||||
This is a representation of the LED GPIO nodes
|
This is a representation of the LED GPIO nodes
|
||||||
|
|
||||||
inherits:
|
|
||||||
!include base.yaml
|
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
compatible:
|
compatible:
|
||||||
constraint: "gpio-leds"
|
constraint: "gpio-leds"
|
||||||
|
type: string-array
|
||||||
gpios:
|
|
||||||
type: compound
|
|
||||||
category: required
|
category: required
|
||||||
|
description: compatible strings
|
||||||
generation: define
|
generation: define
|
||||||
|
|
||||||
label:
|
sub-node:
|
||||||
category: required
|
properties:
|
||||||
|
gpios:
|
||||||
|
type: compound
|
||||||
|
category: required
|
||||||
|
generation: define
|
||||||
|
label:
|
||||||
|
category: required
|
||||||
|
type: string
|
||||||
|
description: Human readable string describing the device (used by Zephyr for API name)
|
||||||
|
generation: define
|
||||||
|
|
|
@ -10,17 +10,23 @@ version: 0.1
|
||||||
description: >
|
description: >
|
||||||
This is a representation of the PWM GPIO nodes
|
This is a representation of the PWM GPIO nodes
|
||||||
|
|
||||||
inherits:
|
|
||||||
!include base.yaml
|
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
compatible:
|
compatible:
|
||||||
constraint: "pwm-leds"
|
constraint: "pwm-leds"
|
||||||
|
type: string-array
|
||||||
pwms:
|
|
||||||
type: compound
|
|
||||||
category: required
|
category: required
|
||||||
|
description: compatible strings
|
||||||
generation: define
|
generation: define
|
||||||
|
|
||||||
label:
|
sub-node:
|
||||||
category: required
|
properties:
|
||||||
|
pwms:
|
||||||
|
type: compound
|
||||||
|
category: required
|
||||||
|
generation: define
|
||||||
|
|
||||||
|
label:
|
||||||
|
category: required
|
||||||
|
type: string
|
||||||
|
description: Human readable string describing the device (used by Zephyr for API name)
|
||||||
|
generation: define
|
||||||
|
|
|
@ -5,9 +5,29 @@ version: 0.1
|
||||||
description: >
|
description: >
|
||||||
This binding gives a base FLASH partition description
|
This binding gives a base FLASH partition description
|
||||||
|
|
||||||
inherits:
|
|
||||||
!include base.yaml
|
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
compatible:
|
compatible:
|
||||||
constraint: "fixed-partitions"
|
constraint: "fixed-partitions"
|
||||||
|
type: string-array
|
||||||
|
category: required
|
||||||
|
description: compatible strings
|
||||||
|
generation: define
|
||||||
|
|
||||||
|
sub-node:
|
||||||
|
properties:
|
||||||
|
label:
|
||||||
|
category: required
|
||||||
|
type: string
|
||||||
|
category: optional
|
||||||
|
description: Human readable string describing the device (used by Zephyr for API name)
|
||||||
|
generation: define
|
||||||
|
read-only:
|
||||||
|
type: boolean
|
||||||
|
category: optional
|
||||||
|
description: if the partition is read-only or not
|
||||||
|
generation: define
|
||||||
|
reg:
|
||||||
|
type: array
|
||||||
|
description: register space
|
||||||
|
generation: define
|
||||||
|
category: required
|
||||||
|
|
|
@ -292,19 +292,28 @@ def add_prop_aliases(node_path,
|
||||||
prop_aliases[old_alias_label] = prop_label
|
prop_aliases[old_alias_label] = prop_label
|
||||||
|
|
||||||
def get_binding(node_path):
|
def get_binding(node_path):
|
||||||
compat = get_compat(node_path)
|
compat = reduced[node_path]['props'].get('compatible')
|
||||||
|
if isinstance(compat, list):
|
||||||
|
compat = compat[0]
|
||||||
|
|
||||||
# First look for a bus-specific binding
|
|
||||||
parent_path = get_parent_path(node_path)
|
parent_path = get_parent_path(node_path)
|
||||||
parent_compat = get_compat(parent_path)
|
parent_compat = get_compat(parent_path)
|
||||||
|
|
||||||
if parent_compat in bindings:
|
if parent_compat in bindings:
|
||||||
parent_binding = bindings[parent_compat]
|
parent_binding = bindings[parent_compat]
|
||||||
|
# see if we're a sub-node
|
||||||
|
if compat is None and 'sub-node' in parent_binding:
|
||||||
|
return parent_binding['sub-node']
|
||||||
|
|
||||||
|
# look for a bus-specific binding
|
||||||
if 'child' in parent_binding and 'bus' in parent_binding['child']:
|
if 'child' in parent_binding and 'bus' in parent_binding['child']:
|
||||||
bus = parent_binding['child']['bus']
|
bus = parent_binding['child']['bus']
|
||||||
return bus_bindings[bus][compat]
|
return bus_bindings[bus][compat]
|
||||||
|
|
||||||
# No bus-specific binding found, look in the main dict.
|
# No bus-specific binding found, look in the main dict.
|
||||||
return bindings[compat]
|
if compat:
|
||||||
|
return bindings[compat]
|
||||||
|
return None
|
||||||
|
|
||||||
def get_binding_compats():
|
def get_binding_compats():
|
||||||
return binding_compats
|
return binding_compats
|
||||||
|
|
|
@ -105,6 +105,9 @@ def generate_node_defines(node_path):
|
||||||
flash.extract_partition(node_path)
|
flash.extract_partition(node_path)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if get_binding(node_path) is None:
|
||||||
|
return
|
||||||
|
|
||||||
generate_bus_defines(node_path)
|
generate_bus_defines(node_path)
|
||||||
|
|
||||||
# Generate per-property ('foo = <1 2 3>', etc.) #defines
|
# Generate per-property ('foo = <1 2 3>', etc.) #defines
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue