dm: Add functions to access a device's children

Devices can have childen that can be addressed by a simple index, the
sequence number or a device tree offset. Add functions to access a child
in each of these ways.

The index is typically used as a fallback when the sequence number is not
available. For example we may use a serial UART with sequence number 0 as
the console, but if no UART has sequence number 0, then we can fall back
to just using the first UART (index 0).

The device tree offset function is useful for buses, where they want to
locate one of their children. The device tree can be scanned to find the
offset of each child, and that offset can then find the device.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2014-07-23 06:55:19 -06:00
parent 1ca7e2062b
commit 997c87bb0b
4 changed files with 199 additions and 1 deletions

View File

@@ -95,13 +95,14 @@ are provided in test/dm. To run them, try:
You should see something like this:
<...U-Boot banner...>
Running 18 driver model tests
Running 19 driver model tests
Test: dm_test_autobind
Test: dm_test_autoprobe
Test: dm_test_bus_children
Device 'd-test': seq 3 is in use by 'b-test'
Device 'c-test@0': seq 0 is in use by 'a-test'
Device 'c-test@1': seq 1 is in use by 'd-test'
Test: dm_test_bus_children_funcs
Test: dm_test_children
Test: dm_test_fdt
Device 'd-test': seq 3 is in use by 'b-test'