[fdt] Use phandle as device location

Consumption of phandles will be in the form of locating a functional
device (e.g. a GPIO device, or an I2C device, or a reset controller)
by phandle, rather than locating the device tree node to which the
phandle refers.

Repurpose fdt_phandle() to obtain the phandle value (instead of
searching by phandle), and record this value as the bus location
within the generic device structure.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-08-04 14:52:00 +01:00
parent f7a1e9ef8e
commit 5f10b74555
4 changed files with 34 additions and 62 deletions

View File

@@ -237,6 +237,16 @@ static void fdt_test_exec ( void ) {
ok ( fdt_path ( &fdt, "/soc/ethernet@10090000", &offset ) == 0 );
ok ( fdt_u32 ( &fdt, offset, "max-speed", &u32 ) != 0 );
/* Verify phandle properties */
ok ( fdt_path ( &fdt, "/cpus/cpu@0/interrupt-controller",
&offset ) == 0 );
ok ( fdt_phandle ( &fdt, offset ) == 0x03 );
ok ( fdt_path ( &fdt, "/soc/ethernet@10090000/ethernet-phy@0",
&offset ) == 0 );
ok ( fdt_phandle ( &fdt, offset ) == 0x08 );
ok ( fdt_path ( &fdt, "/soc/serial@10010000", &offset ) == 0 );
ok ( fdt_phandle ( &fdt, offset ) == 0 );
/* Verify cell properties */
ok ( fdt_path ( &fdt, "/soc/ethernet@10090000", &offset ) == 0 );
ok ( fdt_cells ( &fdt, offset, "reg", 4, 2, &u64 ) == 0 );
@@ -261,15 +271,6 @@ static void fdt_test_exec ( void ) {
ok ( ( string = fdt_string ( &fdt, offset, "phy-mode" ) ) != NULL );
ok ( strcmp ( string, "gmii" ) == 0 );
/* Verify phandle lookup */
ok ( fdt_phandle ( &fdt, 0x03, &offset ) == 0 );
ok ( fdt_describe ( &fdt, offset, &desc ) == 0 );
ok ( strcmp ( desc.name, "interrupt-controller" ) == 0 );
ok ( fdt_phandle ( &fdt, 0x08, &offset ) == 0 );
ok ( fdt_describe ( &fdt, offset, &desc ) == 0 );
ok ( strcmp ( desc.name, "ethernet-phy@0" ) == 0 );
ok ( fdt_phandle ( &fdt, 0x2a, &offset ) != 0 );
/* Verify node description */
ok ( fdt_path ( &fdt, "/memory@80000000", &offset ) == 0 );
ok ( fdt_describe ( &fdt, offset, &desc ) == 0 );