diff options
author | Simon Glass <sjg@chromium.org> | 2015-01-25 08:27:08 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-01-29 17:09:56 -0700 |
commit | 081f2fcbd9a95ba10677065359791f8fea3f8c58 (patch) | |
tree | ed8312d3d54e07e659a64f5b59657a147317130f /test/dm | |
parent | 19a25f672c6aa1a9a9b94c0ffbfda3e8246d1a19 (diff) | |
download | u-boot-imx-081f2fcbd9a95ba10677065359791f8fea3f8c58.zip u-boot-imx-081f2fcbd9a95ba10677065359791f8fea3f8c58.tar.gz u-boot-imx-081f2fcbd9a95ba10677065359791f8fea3f8c58.tar.bz2 |
dm: core: Allow the uclass to set up a device's child after binding
For buses, after a child is bound, allow the uclass to perform some
processing. This can be used to figure out the address of the child (e.g.
the chip select for SPI slaves) so that it is ready to be probed.
This avoids bus drivers having to repeat the same process, which really
should be done by the uclass, since it is common.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Diffstat (limited to 'test/dm')
-rw-r--r-- | test/dm/bus.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/dm/bus.c b/test/dm/bus.c index e909697..c123ed7 100644 --- a/test/dm/bus.c +++ b/test/dm/bus.c @@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR; struct dm_test_parent_platdata { int count; int bind_flag; + int uclass_bind_flag; }; enum { @@ -38,6 +39,7 @@ static int testbus_child_post_bind(struct udevice *dev) plat = dev_get_parent_platdata(dev); plat->bind_flag = 1; + plat->uclass_bind_flag = 2; return 0; } @@ -443,3 +445,27 @@ static int dm_test_bus_child_post_bind(struct dm_test_state *dms) return 0; } DM_TEST(dm_test_bus_child_post_bind, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test that the child post_bind method is called */ +static int dm_test_bus_child_post_bind_uclass(struct dm_test_state *dms) +{ + struct dm_test_parent_platdata *plat; + struct udevice *bus, *dev; + int child_count; + + ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus)); + for (device_find_first_child(bus, &dev), child_count = 0; + dev; + device_find_next_child(&dev)) { + /* Check that platform data is allocated */ + plat = dev_get_parent_platdata(dev); + ut_assert(plat != NULL); + ut_asserteq(2, plat->uclass_bind_flag); + child_count++; + } + ut_asserteq(3, child_count); + + return 0; +} +DM_TEST(dm_test_bus_child_post_bind_uclass, + DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |