summaryrefslogtreecommitdiff
path: root/tools/dtoc/src_scan.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-03 06:01:02 -0700
committerSimon Glass <sjg@chromium.org>2021-03-22 19:23:27 +1300
commitb00f0066e52413e0f8fd4a84681e6e27c4270c26 (patch)
treede41f3fc135501b607ad5790b03dc27c63e32e5d /tools/dtoc/src_scan.py
parentb9319c4f9b103b6c5b10e8592471a29bd9645caf (diff)
dtoc: Support tracking the phase of U-Boot
U-Boot operates in several phases, typically TPL, SPL and U-Boot proper. The latter does not use dtoc. In some rare cases different drivers are used for two phases. For example, in TPL it may not be necessary to use the full PCI subsystem, so a simple driver can be used instead. This works in the build system simply by compiling in one driver or the other (e.g. PCI driver + uclass for SPL; simple_bus for TPL). But dtoc has no way of knowing which code is compiled in for which phase, since it does not inspect Makefiles or dependency graphs. So to make this work for dtoc, we need to be able to explicitly mark drivers with their phase. This is done by adding an empty macro to the driver. Add support for this in dtoc. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/src_scan.py')
-rw-r--r--tools/dtoc/src_scan.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py
index 1a02d41063f..2699153016c 100644
--- a/tools/dtoc/src_scan.py
+++ b/tools/dtoc/src_scan.py
@@ -67,6 +67,7 @@ class Driver:
child_plat (str): struct name of the per_child_plat_auto member,
e.g. 'pci_child_plat'
used (bool): True if the driver is used by the structs being output
+ phase (str): Which phase of U-Boot to use this driver
"""
def __init__(self, name, fname):
self.name = name
@@ -78,6 +79,7 @@ class Driver:
self.child_priv = ''
self.child_plat = ''
self.used = False
+ self.phase = ''
def __eq__(self, other):
return (self.name == other.name and
@@ -173,8 +175,10 @@ class Scanner:
_structs: Dict of all structs found in U-Boot:
key: Name of struct
value: Struct object
+ _phase: The phase of U-Boot that we are generating data for, e.g. 'spl'
+ or 'tpl'. None if not known
"""
- def __init__(self, basedir, warning_disabled, drivers_additional):
+ def __init__(self, basedir, warning_disabled, drivers_additional, phase=''):
"""Set up a new Scanner
"""
if not basedir:
@@ -190,6 +194,7 @@ class Scanner:
self._compat_to_driver = {}
self._uclass = {}
self._structs = {}
+ self._phase = phase
def get_driver(self, name):
"""Get a driver given its name
@@ -428,6 +433,8 @@ class Scanner:
re_of_match = re.compile(
r'\.of_match\s*=\s*(of_match_ptr\()?([a-z0-9_]+)(\))?,')
+ re_phase = re.compile('^\s*DM_PHASE\((.*)\).*$')
+
# Matches the struct name for priv, plat
re_priv = self._get_re_for_member('priv_auto')
re_plat = self._get_re_for_member('plat_auto')
@@ -454,6 +461,7 @@ class Scanner:
m_plat = re_plat.match(line)
m_cplat = re_child_plat.match(line)
m_cpriv = re_child_priv.match(line)
+ m_phase = re_phase.match(line)
if m_priv:
driver.priv = m_priv.group(1)
elif m_plat:
@@ -466,6 +474,8 @@ class Scanner:
driver.uclass_id = m_id.group(1)
elif m_of_match:
compat = m_of_match.group(2)
+ elif m_phase:
+ driver.phase = m_phase.group(1)
elif '};' in line:
if driver.uclass_id and compat:
if compat not in of_match: