|
@@ -420,9 +420,14 @@ U_BOOT_DRVINFO(spl_test3) = {
|
|
|
#include <dt-structs.h>
|
|
|
|
|
|
/*
|
|
|
- * uclass declarations
|
|
|
+ * uclass declarations, ordered by 'struct uclass' linker_list idx:
|
|
|
+ * 0: i2c
|
|
|
+ * 1: misc
|
|
|
+ * 2: root
|
|
|
+ * 3: testbus
|
|
|
+ * 4: testfdt
|
|
|
*
|
|
|
- * Sequence numbers:
|
|
|
+ * Sequence numbers allocated in each uclass:
|
|
|
* i2c: UCLASS_I2C
|
|
|
* 4: /i2c
|
|
|
* misc: UCLASS_MISC
|
|
@@ -506,6 +511,300 @@ DM_UCLASS_INST(testfdt) = {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
+'''
|
|
|
+ device_text = '''/*
|
|
|
+ * DO NOT MODIFY
|
|
|
+ *
|
|
|
+ * Declares the DM_DEVICE_INST() records.
|
|
|
+ * This was generated by dtoc from a .dtb (device tree binary) file.
|
|
|
+ */
|
|
|
+
|
|
|
+/* This file is not used: --instantiate was not enabled */
|
|
|
+'''
|
|
|
+ device_text_inst = '''/*
|
|
|
+ * DO NOT MODIFY
|
|
|
+ *
|
|
|
+ * Declares the DM_DEVICE_INST() records.
|
|
|
+ * This was generated by dtoc from a .dtb (device tree binary) file.
|
|
|
+ */
|
|
|
+
|
|
|
+#include <common.h>
|
|
|
+#include <dm.h>
|
|
|
+#include <dt-structs.h>
|
|
|
+
|
|
|
+/*
|
|
|
+ * udevice declarations, ordered by 'struct udevice' linker_list position:
|
|
|
+ *
|
|
|
+ * idx udevice driver
|
|
|
+ * --- -------------------- --------------------
|
|
|
+ * 0: i2c sandbox_i2c
|
|
|
+ * 1: root root_driver
|
|
|
+ * 2: some_bus denx_u_boot_test_bus
|
|
|
+ * 3: spl_test sandbox_spl_test
|
|
|
+ * 4: spl_test3 sandbox_spl_test
|
|
|
+ * 5: test denx_u_boot_fdt_test
|
|
|
+ * 6: test0 denx_u_boot_fdt_test
|
|
|
+ * --- -------------------- --------------------
|
|
|
+ */
|
|
|
+
|
|
|
+/*
|
|
|
+ * Node /i2c index 0
|
|
|
+ * driver sandbox_i2c parent root_driver
|
|
|
+*/
|
|
|
+static struct dtd_sandbox_i2c dtv_i2c = {
|
|
|
+\t.intval\t\t\t= 0x3,
|
|
|
+};
|
|
|
+
|
|
|
+#include <asm/i2c.h>
|
|
|
+u8 _sandbox_i2c_priv_i2c[sizeof(struct sandbox_i2c_priv)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+#include <i2c.h>
|
|
|
+u8 _sandbox_i2c_uc_priv_i2c[sizeof(struct dm_i2c_bus)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+
|
|
|
+DM_DEVICE_INST(i2c) = {
|
|
|
+\t.driver\t\t= DM_DRIVER_REF(sandbox_i2c),
|
|
|
+\t.name\t\t= "sandbox_i2c",
|
|
|
+\t.plat_\t\t= &dtv_i2c,
|
|
|
+\t.priv_\t\t= _sandbox_i2c_priv_i2c,
|
|
|
+\t.uclass\t\t= DM_UCLASS_REF(i2c),
|
|
|
+\t.uclass_priv_ = _sandbox_i2c_uc_priv_i2c,
|
|
|
+\t.uclass_node\t= {
|
|
|
+\t\t.prev = &DM_UCLASS_REF(i2c)->dev_head,
|
|
|
+\t\t.next = &DM_UCLASS_REF(i2c)->dev_head,
|
|
|
+\t},
|
|
|
+\t.child_head\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(i2c)->child_head,
|
|
|
+\t\t.next = &DM_DEVICE_REF(i2c)->child_head,
|
|
|
+\t},
|
|
|
+\t.sibling_node\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(root)->child_head,
|
|
|
+\t\t.next = &DM_DEVICE_REF(some_bus)->sibling_node,
|
|
|
+\t},
|
|
|
+\t.seq_ = 4,
|
|
|
+};
|
|
|
+
|
|
|
+/*
|
|
|
+ * Node / index 1
|
|
|
+ * driver root_driver parent None
|
|
|
+*/
|
|
|
+static struct dtd_root_driver dtv_root = {
|
|
|
+};
|
|
|
+
|
|
|
+DM_DEVICE_INST(root) = {
|
|
|
+\t.driver\t\t= DM_DRIVER_REF(root_driver),
|
|
|
+\t.name\t\t= "root_driver",
|
|
|
+\t.plat_\t\t= &dtv_root,
|
|
|
+\t.uclass\t\t= DM_UCLASS_REF(root),
|
|
|
+\t.uclass_node\t= {
|
|
|
+\t\t.prev = &DM_UCLASS_REF(root)->dev_head,
|
|
|
+\t\t.next = &DM_UCLASS_REF(root)->dev_head,
|
|
|
+\t},
|
|
|
+\t.child_head\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(spl_test3)->sibling_node,
|
|
|
+\t\t.next = &DM_DEVICE_REF(i2c)->sibling_node,
|
|
|
+\t},
|
|
|
+\t.seq_ = 0,
|
|
|
+};
|
|
|
+
|
|
|
+/*
|
|
|
+ * Node /some-bus index 2
|
|
|
+ * driver denx_u_boot_test_bus parent root_driver
|
|
|
+*/
|
|
|
+
|
|
|
+#include <dm/test.h>
|
|
|
+struct dm_test_pdata __attribute__ ((section (".priv_data")))
|
|
|
+\t_denx_u_boot_test_bus_plat_some_bus = {
|
|
|
+\t.dtplat = {
|
|
|
+\t\t.ping_add\t\t= 0x4,
|
|
|
+\t\t.ping_expect\t\t= 0x4,
|
|
|
+\t\t.reg\t\t\t= {0x3, 0x1},
|
|
|
+\t},
|
|
|
+};
|
|
|
+#include <dm/test.h>
|
|
|
+u8 _denx_u_boot_test_bus_priv_some_bus[sizeof(struct dm_test_priv)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+#include <dm/test.h>
|
|
|
+u8 _denx_u_boot_test_bus_ucplat_some_bus[sizeof(struct dm_test_uclass_priv)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+#include <test.h>
|
|
|
+
|
|
|
+DM_DEVICE_INST(some_bus) = {
|
|
|
+\t.driver\t\t= DM_DRIVER_REF(denx_u_boot_test_bus),
|
|
|
+\t.name\t\t= "denx_u_boot_test_bus",
|
|
|
+\t.plat_\t\t= &_denx_u_boot_test_bus_plat_some_bus,
|
|
|
+\t.uclass_plat_\t= _denx_u_boot_test_bus_ucplat_some_bus,
|
|
|
+\t.driver_data\t= DM_TEST_TYPE_FIRST,
|
|
|
+\t.priv_\t\t= _denx_u_boot_test_bus_priv_some_bus,
|
|
|
+\t.uclass\t\t= DM_UCLASS_REF(testbus),
|
|
|
+\t.uclass_node\t= {
|
|
|
+\t\t.prev = &DM_UCLASS_REF(testbus)->dev_head,
|
|
|
+\t\t.next = &DM_UCLASS_REF(testbus)->dev_head,
|
|
|
+\t},
|
|
|
+\t.child_head\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(test0)->sibling_node,
|
|
|
+\t\t.next = &DM_DEVICE_REF(test)->sibling_node,
|
|
|
+\t},
|
|
|
+\t.sibling_node\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(i2c)->sibling_node,
|
|
|
+\t\t.next = &DM_DEVICE_REF(spl_test)->sibling_node,
|
|
|
+\t},
|
|
|
+\t.seq_ = 2,
|
|
|
+};
|
|
|
+
|
|
|
+/*
|
|
|
+ * Node /spl-test index 3
|
|
|
+ * driver sandbox_spl_test parent root_driver
|
|
|
+*/
|
|
|
+static struct dtd_sandbox_spl_test dtv_spl_test = {
|
|
|
+\t.boolval\t\t= true,
|
|
|
+\t.intval\t\t\t= 0x1,
|
|
|
+};
|
|
|
+
|
|
|
+DM_DEVICE_INST(spl_test) = {
|
|
|
+\t.driver\t\t= DM_DRIVER_REF(sandbox_spl_test),
|
|
|
+\t.name\t\t= "sandbox_spl_test",
|
|
|
+\t.plat_\t\t= &dtv_spl_test,
|
|
|
+\t.uclass\t\t= DM_UCLASS_REF(misc),
|
|
|
+\t.uclass_node\t= {
|
|
|
+\t\t.prev = &DM_UCLASS_REF(misc)->dev_head,
|
|
|
+\t\t.next = &DM_DEVICE_REF(spl_test3)->uclass_node,
|
|
|
+\t},
|
|
|
+\t.child_head\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(spl_test)->child_head,
|
|
|
+\t\t.next = &DM_DEVICE_REF(spl_test)->child_head,
|
|
|
+\t},
|
|
|
+\t.sibling_node\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(some_bus)->sibling_node,
|
|
|
+\t\t.next = &DM_DEVICE_REF(spl_test3)->sibling_node,
|
|
|
+\t},
|
|
|
+\t.seq_ = 0,
|
|
|
+};
|
|
|
+
|
|
|
+/*
|
|
|
+ * Node /spl-test3 index 4
|
|
|
+ * driver sandbox_spl_test parent root_driver
|
|
|
+*/
|
|
|
+static struct dtd_sandbox_spl_test dtv_spl_test3 = {
|
|
|
+\t.longbytearray\t\t= {0x90a0b0c, 0xd0e0f10},
|
|
|
+\t.stringarray\t\t= "one",
|
|
|
+};
|
|
|
+
|
|
|
+DM_DEVICE_INST(spl_test3) = {
|
|
|
+\t.driver\t\t= DM_DRIVER_REF(sandbox_spl_test),
|
|
|
+\t.name\t\t= "sandbox_spl_test",
|
|
|
+\t.plat_\t\t= &dtv_spl_test3,
|
|
|
+\t.uclass\t\t= DM_UCLASS_REF(misc),
|
|
|
+\t.uclass_node\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(spl_test)->uclass_node,
|
|
|
+\t\t.next = &DM_UCLASS_REF(misc)->dev_head,
|
|
|
+\t},
|
|
|
+\t.child_head\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(spl_test3)->child_head,
|
|
|
+\t\t.next = &DM_DEVICE_REF(spl_test3)->child_head,
|
|
|
+\t},
|
|
|
+\t.sibling_node\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(spl_test)->sibling_node,
|
|
|
+\t\t.next = &DM_DEVICE_REF(root)->child_head,
|
|
|
+\t},
|
|
|
+\t.seq_ = 1,
|
|
|
+};
|
|
|
+
|
|
|
+/*
|
|
|
+ * Node /some-bus/test index 5
|
|
|
+ * driver denx_u_boot_fdt_test parent denx_u_boot_test_bus
|
|
|
+*/
|
|
|
+
|
|
|
+#include <dm/test.h>
|
|
|
+struct dm_test_pdata __attribute__ ((section (".priv_data")))
|
|
|
+\t_denx_u_boot_fdt_test_plat_test = {
|
|
|
+\t.dtplat = {
|
|
|
+\t\t.ping_add\t\t= 0x5,
|
|
|
+\t\t.ping_expect\t\t= 0x5,
|
|
|
+\t\t.reg\t\t\t= {0x5, 0x0},
|
|
|
+\t},
|
|
|
+};
|
|
|
+#include <dm/test.h>
|
|
|
+u8 _denx_u_boot_fdt_test_priv_test[sizeof(struct dm_test_priv)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+#include <dm/test.h>
|
|
|
+u8 _denx_u_boot_fdt_test_parent_plat_test[sizeof(struct dm_test_parent_plat)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+#include <dm/test.h>
|
|
|
+u8 _denx_u_boot_fdt_test_parent_priv_test[sizeof(struct dm_test_parent_data)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+
|
|
|
+DM_DEVICE_INST(test) = {
|
|
|
+\t.driver\t\t= DM_DRIVER_REF(denx_u_boot_fdt_test),
|
|
|
+\t.name\t\t= "denx_u_boot_fdt_test",
|
|
|
+\t.plat_\t\t= &_denx_u_boot_fdt_test_plat_test,
|
|
|
+\t.parent_plat_\t= _denx_u_boot_fdt_test_parent_plat_test,
|
|
|
+\t.driver_data\t= DM_TEST_TYPE_FIRST,
|
|
|
+\t.parent\t\t= DM_DEVICE_REF(some_bus),
|
|
|
+\t.priv_\t\t= _denx_u_boot_fdt_test_priv_test,
|
|
|
+\t.uclass\t\t= DM_UCLASS_REF(testfdt),
|
|
|
+\t.parent_priv_\t= _denx_u_boot_fdt_test_parent_priv_test,
|
|
|
+\t.uclass_node\t= {
|
|
|
+\t\t.prev = &DM_UCLASS_REF(testfdt)->dev_head,
|
|
|
+\t\t.next = &DM_DEVICE_REF(test0)->uclass_node,
|
|
|
+\t},
|
|
|
+\t.child_head\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(test)->child_head,
|
|
|
+\t\t.next = &DM_DEVICE_REF(test)->child_head,
|
|
|
+\t},
|
|
|
+\t.sibling_node\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(some_bus)->child_head,
|
|
|
+\t\t.next = &DM_DEVICE_REF(test0)->sibling_node,
|
|
|
+\t},
|
|
|
+\t.seq_ = 1,
|
|
|
+};
|
|
|
+
|
|
|
+/*
|
|
|
+ * Node /some-bus/test0 index 6
|
|
|
+ * driver denx_u_boot_fdt_test parent denx_u_boot_test_bus
|
|
|
+*/
|
|
|
+
|
|
|
+#include <dm/test.h>
|
|
|
+struct dm_test_pdata __attribute__ ((section (".priv_data")))
|
|
|
+\t_denx_u_boot_fdt_test_plat_test0 = {
|
|
|
+\t.dtplat = {
|
|
|
+\t},
|
|
|
+};
|
|
|
+#include <dm/test.h>
|
|
|
+u8 _denx_u_boot_fdt_test_priv_test0[sizeof(struct dm_test_priv)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+#include <dm/test.h>
|
|
|
+u8 _denx_u_boot_fdt_test_parent_plat_test0[sizeof(struct dm_test_parent_plat)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+#include <dm/test.h>
|
|
|
+u8 _denx_u_boot_fdt_test_parent_priv_test0[sizeof(struct dm_test_parent_data)]
|
|
|
+\t__attribute__ ((section (".priv_data")));
|
|
|
+
|
|
|
+DM_DEVICE_INST(test0) = {
|
|
|
+\t.driver\t\t= DM_DRIVER_REF(denx_u_boot_fdt_test),
|
|
|
+\t.name\t\t= "denx_u_boot_fdt_test",
|
|
|
+\t.plat_\t\t= &_denx_u_boot_fdt_test_plat_test0,
|
|
|
+\t.parent_plat_\t= _denx_u_boot_fdt_test_parent_plat_test0,
|
|
|
+\t.driver_data\t= DM_TEST_TYPE_SECOND,
|
|
|
+\t.parent\t\t= DM_DEVICE_REF(some_bus),
|
|
|
+\t.priv_\t\t= _denx_u_boot_fdt_test_priv_test0,
|
|
|
+\t.uclass\t\t= DM_UCLASS_REF(testfdt),
|
|
|
+\t.parent_priv_\t= _denx_u_boot_fdt_test_parent_priv_test0,
|
|
|
+\t.uclass_node\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(test)->uclass_node,
|
|
|
+\t\t.next = &DM_UCLASS_REF(testfdt)->dev_head,
|
|
|
+\t},
|
|
|
+\t.child_head\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(test0)->child_head,
|
|
|
+\t\t.next = &DM_DEVICE_REF(test0)->child_head,
|
|
|
+\t},
|
|
|
+\t.sibling_node\t= {
|
|
|
+\t\t.prev = &DM_DEVICE_REF(test)->sibling_node,
|
|
|
+\t\t.next = &DM_DEVICE_REF(some_bus)->child_head,
|
|
|
+\t},
|
|
|
+\t.seq_ = 2,
|
|
|
+};
|
|
|
+
|
|
|
'''
|
|
|
|
|
|
def test_simple(self):
|
|
@@ -533,8 +832,9 @@ DM_UCLASS_INST(testfdt) = {
|
|
|
# Try the 'all' command
|
|
|
self.run_test(['all'], dtb_file, output)
|
|
|
data = tools.ReadFile(output, binary=False)
|
|
|
- self._check_strings(self.decl_text + self.platdata_text +
|
|
|
- self.struct_text + self.uclass_text, data)
|
|
|
+ self._check_strings(
|
|
|
+ self.decl_text + self.device_text + self.platdata_text +
|
|
|
+ self.struct_text + self.uclass_text, data)
|
|
|
|
|
|
def test_driver_alias(self):
|
|
|
"""Test output from a device tree file with a driver alias"""
|
|
@@ -1236,8 +1536,9 @@ U_BOOT_DRVINFO(spl_test2) = {
|
|
|
output = tools.GetOutputFilename('output')
|
|
|
self.run_test(['all'], dtb_file, output)
|
|
|
data = tools.ReadFile(output, binary=False)
|
|
|
- self._check_strings(self.decl_text + self.platdata_text +
|
|
|
- self.struct_text + self.uclass_text, data)
|
|
|
+ self._check_strings(
|
|
|
+ self.decl_text + self.device_text + self.platdata_text +
|
|
|
+ self.struct_text + self.uclass_text, data)
|
|
|
|
|
|
def test_no_command(self):
|
|
|
"""Test running dtoc without a command"""
|
|
@@ -1253,7 +1554,7 @@ U_BOOT_DRVINFO(spl_test2) = {
|
|
|
with self.assertRaises(ValueError) as exc:
|
|
|
self.run_test(['invalid-cmd'], dtb_file, output)
|
|
|
self.assertIn(
|
|
|
- "Unknown command 'invalid-cmd': (use: decl, platdata, struct, uclass)",
|
|
|
+ "Unknown command 'invalid-cmd': (use: decl, device, platdata, struct, uclass)",
|
|
|
str(exc.exception))
|
|
|
|
|
|
def test_output_conflict(self):
|
|
@@ -1281,12 +1582,12 @@ U_BOOT_DRVINFO(spl_test2) = {
|
|
|
['all'], dtb_file, False, None, [outdir], None, False,
|
|
|
warning_disabled=True, scan=copy_scan())
|
|
|
fnames = glob.glob(outdir + '/*')
|
|
|
- self.assertEqual(6, len(fnames))
|
|
|
+ self.assertEqual(7, len(fnames))
|
|
|
|
|
|
leafs = set(os.path.basename(fname) for fname in fnames)
|
|
|
self.assertEqual(
|
|
|
{'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb',
|
|
|
- 'dt-uclass.c', 'dt-decl.h'},
|
|
|
+ 'dt-uclass.c', 'dt-decl.h', 'dt-device.c'},
|
|
|
leafs)
|
|
|
|
|
|
def setup_process_test(self):
|
|
@@ -1498,8 +1799,14 @@ U_BOOT_DRVINFO(spl_test2) = {
|
|
|
|
|
|
self._check_strings(UCLASS_HEADER_COMMON + self.uclass_text_inst, data)
|
|
|
|
|
|
+ self.run_test(['device'], dtb_file, output, True)
|
|
|
+ with open(output) as infile:
|
|
|
+ data = infile.read()
|
|
|
+
|
|
|
+ self._check_strings(self.device_text_inst, data)
|
|
|
+
|
|
|
def test_inst_no_hdr(self):
|
|
|
- """Test dealing with a struct that has no header"""
|
|
|
+ """Test dealing with a struct tsssshat has no header"""
|
|
|
dtb_file = get_dtb_file('dtoc_test_inst.dts')
|
|
|
output = tools.GetOutputFilename('output')
|
|
|
|