dm: core: Add a flag to control sequence numbering
At present we try to use the 'reg' property and device tree aliases to give devices a sequence number. The 'reg' property is often actually a memory address, so the sequence numbers thus-obtained are not useful. It would be better if the devices were just sequentially numbered in that case. In fact neither I2C nor SPI use this feature, so drop it. Some devices need us to look up an alias to number them within the uclass. Add a flag to control this, so it is not done unless it is needed. Adjust the tests to test this new behaviour. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
This commit is contained in:
@@ -88,12 +88,13 @@ U_BOOT_DRIVER(testbus_drv) = {
|
||||
UCLASS_DRIVER(testbus) = {
|
||||
.name = "testbus",
|
||||
.id = UCLASS_TEST_BUS,
|
||||
.flags = DM_UC_FLAG_SEQ_ALIAS,
|
||||
};
|
||||
|
||||
/* Test that we can probe for children */
|
||||
static int dm_test_bus_children(struct dm_test_state *dms)
|
||||
{
|
||||
int num_devices = 4;
|
||||
int num_devices = 6;
|
||||
struct udevice *bus;
|
||||
struct uclass *uc;
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ int testfdt_ping(struct udevice *dev, int pingval, int *pingret)
|
||||
UCLASS_DRIVER(testfdt) = {
|
||||
.name = "testfdt",
|
||||
.id = UCLASS_TEST_FDT,
|
||||
.flags = DM_UC_FLAG_SEQ_ALIAS,
|
||||
};
|
||||
|
||||
int dm_check_devices(struct dm_test_state *dms, int num_devices)
|
||||
@@ -128,7 +129,7 @@ int dm_check_devices(struct dm_test_state *dms, int num_devices)
|
||||
/* Test that FDT-based binding works correctly */
|
||||
static int dm_test_fdt(struct dm_test_state *dms)
|
||||
{
|
||||
const int num_devices = 4;
|
||||
const int num_devices = 6;
|
||||
struct udevice *dev;
|
||||
struct uclass *uc;
|
||||
int ret;
|
||||
@@ -184,7 +185,7 @@ static int dm_test_fdt_uclass_seq(struct dm_test_state *dms)
|
||||
ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 3, true, &dev));
|
||||
ut_asserteq_str("b-test", dev->name);
|
||||
|
||||
ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 0, true, &dev));
|
||||
ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 8, true, &dev));
|
||||
ut_asserteq_str("a-test", dev->name);
|
||||
|
||||
ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 5,
|
||||
@@ -220,11 +221,11 @@ static int dm_test_fdt_uclass_seq(struct dm_test_state *dms)
|
||||
ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 1,
|
||||
&dev));
|
||||
ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
|
||||
ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 1, &dev));
|
||||
ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 4, &dev));
|
||||
|
||||
/* But now that it is probed, we can find it */
|
||||
ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, &dev));
|
||||
ut_asserteq_str("a-test", dev->name);
|
||||
ut_asserteq_str("f-test", dev->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,15 @@
|
||||
|
||||
aliases {
|
||||
console = &uart0;
|
||||
i2c0 = "/i2c@0";
|
||||
spi0 = "/spi@0";
|
||||
testfdt6 = "/e-test";
|
||||
testbus3 = "/some-bus";
|
||||
testfdt0 = "/some-bus/c-test@0";
|
||||
testfdt1 = "/some-bus/c-test@1";
|
||||
testfdt3 = "/b-test";
|
||||
testfdt5 = "/some-bus/c-test@5";
|
||||
testfdt8 = "/a-test";
|
||||
};
|
||||
|
||||
uart0: serial {
|
||||
@@ -86,6 +94,14 @@
|
||||
compatible = "google,another-fdt-test";
|
||||
};
|
||||
|
||||
f-test {
|
||||
compatible = "denx,u-boot-fdt-test";
|
||||
};
|
||||
|
||||
g-test {
|
||||
compatible = "denx,u-boot-fdt-test";
|
||||
};
|
||||
|
||||
gpio_a: base-gpios {
|
||||
compatible = "sandbox,gpio";
|
||||
gpio-controller;
|
||||
|
||||
Reference in New Issue
Block a user