Skip to content

Commit

Permalink
scripts: extract_dts_includes.py: generate 'compatible' CONFIG flags
Browse files Browse the repository at this point in the history
Generate CONFIG_DT_COMPAT flags using available nodes
'compatible' property.
Store them in a bogus node_address key of defs dict so
duplicates could be removed.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
  • Loading branch information
erwango authored and galak committed Sep 14, 2018
1 parent 1755cf6 commit c5ada39
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
50 changes: 50 additions & 0 deletions scripts/dts/extract/compatible.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Copyright (c) 2018 Bobby Noelte
#
# SPDX-License-Identifier: Apache-2.0
#

from extract.globals import *
from extract.directive import DTDirective

##
# @brief Manage compatible directives.
#
# Handles:
# - compatible
#
class DTCompatible(DTDirective):

def __init__(self):
pass

##
# @brief Extract compatible
#
# @param node_address Address of node owning the
# compatible definition.
# @param yaml YAML definition for the owning node.
# @param prop compatible property name
# @param names (unused)
# @param def_label Define label string of node owning the
# compatible definition.
#
def extract(self, node_address, yaml, prop, names, def_label):

# compatible definition
compatible = reduced[node_address]['props'][prop]
if not isinstance(compatible, list):
compatible = [compatible, ]

for i, comp in enumerate(compatible):
# Generate #define's
compat_label = convert_string_to_label(str(comp))
compat_defs = 'CONFIG_DT_COMPAT_' + compat_label
load_defs = {
compat_defs: "",
}
insert_defs(node_address, load_defs, {})

##
# @brief Management information for compatible.
compatible = DTCompatible()
5 changes: 5 additions & 0 deletions scripts/dts/extract/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ def get_phandles(root, name, handles):


def insert_defs(node_address, new_defs, new_aliases):

for key in new_defs.keys():
if key.startswith('CONFIG_DT_COMPAT_'):
node_address = 'Compatibles'

if node_address in defs:
if 'aliases' in defs[node_address]:
defs[node_address]['aliases'].update(new_aliases)
Expand Down
3 changes: 3 additions & 0 deletions scripts/dts/extract_dts_includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from extract.globals import *

from extract.clocks import clocks
from extract.compatible import compatible
from extract.interrupts import interrupts
from extract.reg import reg
from extract.flash import flash
Expand Down Expand Up @@ -443,6 +444,8 @@ def extract_property(node_compat, yaml, node_address, prop, prop_val, names,
reg.extract(node_address, yaml, prop, names, def_label)
elif prop == 'interrupts' or prop == 'interrupts-extended':
interrupts.extract(node_address, yaml, prop, names, def_label)
elif prop == 'compatible':
compatible.extract(node_address, yaml, prop, names, def_label)
elif 'pinctrl-' in prop:
pinctrl.extract(node_address, yaml, prop, names, def_label)
elif 'clocks' in prop:
Expand Down

0 comments on commit c5ada39

Please sign in to comment.