_basedir (str): Base directory of source tree
_valid_uclasses (list of src_scan.Uclass): List of uclasses needed for
the selected devices (see _valid_node), in alphabetical order
+ _instantiate: Instantiate devices so they don't need to be bound at
+ run-time
"""
- def __init__(self, scan, dtb_fname, include_disabled):
+ def __init__(self, scan, dtb_fname, include_disabled, instantiate=False):
self._scan = scan
self._fdt = None
self._dtb_fname = dtb_fname
self._struct_data = collections.OrderedDict()
self._basedir = None
self._valid_uclasses = None
+ self._instantiate = instantiate
def setup_output_dirs(self, output_dirs):
"""Set up the output directories
def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase,
- warning_disabled=False, drivers_additional=None, basedir=None,
- scan=None):
+ instantiate, warning_disabled=False, drivers_additional=None,
+ basedir=None, scan=None):
"""Run all the steps of the dtoc tool
Args:
Directory to put H output files
phase: The phase of U-Boot that we are generating data for, e.g. 'spl'
or 'tpl'. None if not known
+ instantiate: Instantiate devices so they don't need to be bound at
+ run-time
warning_disabled (bool): True to avoid showing warnings about missing
drivers
drivers_additional (list): List of additional drivers to use during
do_process = True
else:
do_process = False
- plat = DtbPlatdata(scan, dtb_file, include_disabled)
+ plat = DtbPlatdata(scan, dtb_file, include_disabled, instantiate)
plat.scan_dtb()
- plat.scan_tree(add_root=False)
+ plat.scan_tree(add_root=instantiate)
plat.prepare_nodes()
plat.scan_reg_sizes()
plat.setup_output_dirs(output_dirs)
plat.scan_structs()
plat.scan_phandles()
- plat.process_nodes(False)
+ plat.process_nodes(instantiate)
plat.read_aliases()
plat.assign_seqs()
self.assertEqual(expected, actual)
@staticmethod
- def run_test(args, dtb_file, output):
+ def run_test(args, dtb_file, output, instantiate=False):
"""Run a test using dtoc
Args:
"""
# Make a copy of the 'scan' object, since it includes uclasses and
# drivers, which get updated during execution.
- return dtb_platdata.run_steps(args, dtb_file, False, output, [], None,
- warning_disabled=True, scan=copy_scan())
+ return dtb_platdata.run_steps(
+ args, dtb_file, False, output, [], None, instantiate,
+ warning_disabled=True, scan=copy_scan())
def test_name(self):
"""Test conversion of device tree names to C identifiers"""
output = tools.GetOutputFilename('output')
# Run this one without saved_scan to complete test coverage
- dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], True)
+ dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], None,
+ False)
with open(output) as infile:
lines = infile.read().splitlines()
self.assertEqual(HEADER.splitlines(), lines)
dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts')
output = tools.GetOutputFilename('output')
with test_util.capture_sys_output() as _:
- dtb_platdata.run_steps(['struct'], dtb_file, False, output, [],
- None, scan=copy_scan())
+ dtb_platdata.run_steps(
+ ['struct'], dtb_file, False, output, [], None, False,
+ scan=copy_scan())
with open(output) as infile:
data = infile.read()
self._check_strings(HEADER + '''
''', data)
with test_util.capture_sys_output() as _:
- dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [],
- None, scan=copy_scan())
+ dtb_platdata.run_steps(
+ ['platdata'], dtb_file, False, output, [], None, False,
+ scan=copy_scan())
with open(output) as infile:
data = infile.read()
self._check_strings(C_HEADER + '''
"""Test that phandle targets are generated when unsing cd-gpios"""
dtb_file = get_dtb_file('dtoc_test_phandle_cd_gpios.dts')
output = tools.GetOutputFilename('output')
- dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], True,
- scan=copy_scan())
+ dtb_platdata.run_steps(
+ ['platdata'], dtb_file, False, output, [], None, False,
+ warning_disabled=True, scan=copy_scan())
with open(output) as infile:
data = infile.read()
self._check_strings(C_HEADER + '''
dtb_file = get_dtb_file('dtoc_test_simple.dts')
output = tools.GetOutputFilename('output')
with self.assertRaises(ValueError) as exc:
- self.run_test(['invalid-cmd'], dtb_file, output)
+ self.run_test(['invalid-cmd'], dtb_file, output, False)
self.assertIn("Unknown command 'invalid-cmd': (use: platdata, struct)",
str(exc.exception))
def test_output_conflict(self):
"""Test a conflict between and output dirs and output file"""
with self.assertRaises(ValueError) as exc:
- dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], None,
- warning_disabled=True, scan=copy_scan())
+ dtb_platdata.run_steps(
+ ['all'], None, False, 'out', ['cdir'], None, False,
+ warning_disabled=True, scan=copy_scan())
self.assertIn("Must specify either output or output_dirs, not both",
str(exc.exception))
fnames = glob.glob(outdir + '/*')
self.assertEqual(2, len(fnames))
- dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], None,
- warning_disabled=True, scan=copy_scan())
+ dtb_platdata.run_steps(
+ ['all'], dtb_file, False, None, [outdir], None, False,
+ warning_disabled=True, scan=copy_scan())
fnames = glob.glob(outdir + '/*')
self.assertEqual(4, len(fnames))