summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 426d12f)
raw | patch | inline | side by side (parent: 426d12f)
author | Simon Glass <sjg@chromium.org> | |
Wed, 3 Feb 2021 13:01:15 +0000 (06:01 -0700) | ||
committer | Simon Glass <sjg@chromium.org> | |
Mon, 22 Mar 2021 06:23:27 +0000 (19:23 +1300) |
This file is not used when instantiating devices. Update dtoc to skip
generating its contents and just add a comment instead.
Also it is useful to see the driver name and parent for each device.
Update the file to show that information, to avoid updating the same
tests twice.
Signed-off-by: Simon Glass <sjg@chromium.org>
generating its contents and just add a comment instead.
Also it is useful to see the driver name and parent for each device.
Update the file to show that information, to avoid updating the same
tests twice.
Signed-off-by: Simon Glass <sjg@chromium.org>
tools/dtoc/dtb_platdata.py | patch | blob | history | |
tools/dtoc/test_dtoc.py | patch | blob | history |
index 040b7246787566c144682784c6f296a427208114..befe7c1490110384f7ea29ac808905bf8c1f81a9 100644 (file)
uclass.node_refs[-1] = ref
uclass.node_refs[len(uclass.devs)] = ref
- def output_node(self, node):
+ def output_node_plat(self, node):
"""Output the C code for a node
Args:
node (fdt.Node): node to output
"""
- self.buf('/* Node %s index %d */\n' % (node.path, node.idx))
+ driver = node.driver
+ parent_driver = node.parent_driver
+
+ line1 = 'Node %s index %d' % (node.path, node.idx)
+ if driver:
+ self.buf('/*\n')
+ self.buf(' * %s\n' % line1)
+ self.buf(' * driver %s parent %s\n' % (driver.name,
+ parent_driver.name if parent_driver else 'None'))
+ self.buf(' */\n')
+ else:
+ self.buf('/* %s */\n' % line1)
self._output_values(node)
self._declare_device(node)
self.out(''.join(self.get_buf()))
+ def check_instantiate(self, require):
+ """Check if self._instantiate is set to the required value
+
+ If not, this outputs a message into the current file
+
+ Args:
+ require: True to require --instantiate, False to require that it not
+ be enabled
+ """
+ if require != self._instantiate:
+ self.out(
+ '/* This file is not used: --instantiate was %senabled */\n' %
+ ('not ' if require else ''))
+ return False
+ return True
+
def generate_plat(self):
"""Generate device defintions for the platform data
See the documentation in doc/driver-model/of-plat.rst for more
information.
"""
+ if not self.check_instantiate(False):
+ return
self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n')
self.out('#define DT_PLAT_C\n')
self.out('\n')
self.out('\n')
for node in self._valid_nodes:
- self.output_node(node)
+ self.output_node_plat(node)
self.out(''.join(self.get_buf()))
index a51a7f301ce9b180cfd54299595e1b096bf8a6c5..c6e33d3422784d38461a0511344b50a72b2d31cf 100755 (executable)
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
*/
'''
-C_HEADER = '''/*
+C_HEADER_PRE = '''/*
* DO NOT MODIFY
*
* Declares the U_BOOT_DRIVER() records and platform data.
* This was generated by dtoc from a .dtb (device tree binary) file.
*/
+'''
+C_HEADER = C_HEADER_PRE + '''
/* Allow use of U_BOOT_DRVINFO() in this file */
#define DT_PLAT_C
\tconst char *\tstringval;
};
'''
-
platdata_text = C_HEADER + '''
-/* Node /i2c@0 index 0 */
+/*
+ * Node /i2c@0 index 0
+ * driver sandbox_i2c parent None
+ */
static struct dtd_sandbox_i2c dtv_i2c_at_0 = {
};
U_BOOT_DRVINFO(i2c_at_0) = {
\t.parent_idx\t= -1,
};
-/* Node /i2c@0/pmic@9 index 1 */
+/*
+ * Node /i2c@0/pmic@9 index 1
+ * driver sandbox_pmic parent sandbox_i2c
+ */
static struct dtd_sandbox_pmic dtv_pmic_at_9 = {
\t.low_power\t\t= true,
\t.reg\t\t\t= {0x9, 0x0},
\t.parent_idx\t= 0,
};
-/* Node /spl-test index 2 */
+/*
+ * Node /spl-test index 2
+ * driver sandbox_spl_test parent None
+ */
static struct dtd_sandbox_spl_test dtv_spl_test = {
\t.boolval\t\t= true,
\t.bytearray\t\t= {0x6, 0x0, 0x0},
\t.parent_idx\t= -1,
};
-/* Node /spl-test2 index 3 */
+/*
+ * Node /spl-test2 index 3
+ * driver sandbox_spl_test parent None
+ */
static struct dtd_sandbox_spl_test dtv_spl_test2 = {
\t.acpi_name\t\t= "\\\\_SB.GPO0",
\t.bytearray\t\t= {0x1, 0x23, 0x34},
\t.parent_idx\t= -1,
};
-/* Node /spl-test3 index 4 */
+/*
+ * Node /spl-test3 index 4
+ * driver sandbox_spl_test parent None
+ */
static struct dtd_sandbox_spl_test dtv_spl_test3 = {
\t.longbytearray\t\t= {0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10,
\t\t0x0},
with open(output) as infile:
data = infile.read()
self._check_strings(C_HEADER + '''
-/* Node /gpios@0 index 0 */
+/*
+ * Node /gpios@0 index 0
+ * driver sandbox_gpio parent None
+ */
static struct dtd_sandbox_gpio dtv_gpios_at_0 = {
\t.gpio_bank_name\t\t= "a",
\t.gpio_controller\t= true,
with open(output) as infile:
data = infile.read()
self._check_strings(C_HEADER + '''
-/* Node /spl-test index 0 */
+/*
+ * Node /spl-test index 0
+ * driver sandbox_spl_test parent None
+ */
static struct dtd_sandbox_spl_test dtv_spl_test = {
\t.intval\t\t\t= 0x1,
};
\t.parent_idx\t= -1,
};
-/* Node /spl-test2 index 1 */
+/*
+ * Node /spl-test2 index 1
+ * driver sandbox_spl_test parent None
+ */
static struct dtd_sandbox_spl_test dtv_spl_test2 = {
\t.intarray\t\t= 0x5,
};
data = infile.read()
self._check_strings(self.decl_text_inst, data)
+
+ self.run_test(['platdata'], dtb_file, output, True)
+ with open(output) as infile:
+ data = infile.read()
+
+ self._check_strings(C_HEADER_PRE + '''
+/* This file is not used: --instantiate was enabled */
+''', data)