mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 00:32:04 +02:00
fdtdec: Add fdtdec_set_ethernet_mac_address()
This function can be used to set the local MAC address for the default Ethernet interface in its device tree node. The default interface is identified by the "ethernet" alias. One case where this is useful is for devices that store their MAC address in a custom location. Once extracted, board code can store the MAC address in U-Boot's control DTB so that it will automatically be used by the Ethernet uclass. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Tom Warren <twarren@nvidia.com>
This commit is contained in:
committed by
Tom Warren
parent
6d93d245c1
commit
ebf30e8451
29
lib/fdtdec.c
29
lib/fdtdec.c
@@ -1261,6 +1261,35 @@ __weak void *board_fdt_blob_setup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
int fdtdec_set_ethernet_mac_address(void *fdt, const u8 *mac, size_t size)
|
||||
{
|
||||
const char *path;
|
||||
int offset, err;
|
||||
|
||||
if (!is_valid_ethaddr(mac))
|
||||
return -EINVAL;
|
||||
|
||||
path = fdt_get_alias(fdt, "ethernet");
|
||||
if (!path)
|
||||
return 0;
|
||||
|
||||
debug("ethernet alias found: %s\n", path);
|
||||
|
||||
offset = fdt_path_offset(fdt, path);
|
||||
if (offset < 0) {
|
||||
debug("ethernet alias points to absent node %s\n", path);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
err = fdt_setprop_inplace(fdt, offset, "local-mac-address", mac, size);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
debug("MAC address: %pM\n", mac);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fdtdec_init_reserved_memory(void *blob)
|
||||
{
|
||||
int na, ns, node, err;
|
||||
|
Reference in New Issue
Block a user