Skip to content
Permalink
Browse files

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>
  • Loading branch information...
galak authored and carlescufi committed Jun 21, 2019
1 parent a52df69 commit bf0f6d911db1a0357215ff6a7bd712edf63b754c
@@ -19,6 +19,21 @@ inherits:
# parent and child should share same bus-type value.
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:

# A typical property entry looks like this:
@@ -10,17 +10,22 @@ version: 0.1
description: >
This is a representation of the GPIO KEYS nodes
inherits:
!include base.yaml

properties:
compatible:
constraint: "gpio-keys"

gpios:
type: compound
type: string-array
category: required
description: compatible strings
generation: define

label:
category: required
sub-node:
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: >
This is a representation of the LED GPIO nodes
inherits:
!include base.yaml

properties:
compatible:
constraint: "gpio-leds"

gpios:
type: compound
type: string-array
category: required
description: compatible strings
generation: define

label:
category: required
sub-node:
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: >
This is a representation of the PWM GPIO nodes
inherits:
!include base.yaml

properties:
compatible:
constraint: "pwm-leds"

pwms:
type: compound
type: string-array
category: required
description: compatible strings
generation: define

label:
category: required
sub-node:
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: >
This binding gives a base FLASH partition description
inherits:
!include base.yaml

properties:
compatible:
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

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_compat = get_compat(parent_path)

if parent_compat in bindings:
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']:
bus = parent_binding['child']['bus']
return bus_bindings[bus][compat]

# No bus-specific binding found, look in the main dict.
return bindings[compat]
if compat:
return bindings[compat]
return None

def get_binding_compats():
return binding_compats
@@ -105,6 +105,9 @@ def generate_node_defines(node_path):
flash.extract_partition(node_path)
return

if get_binding(node_path) is None:
return

generate_bus_defines(node_path)

# Generate per-property ('foo = <1 2 3>', etc.) #defines

0 comments on commit bf0f6d9

Please sign in to comment.
You can’t perform that action at this time.