diff options
author | Sean Anderson <sean.anderson@seco.com> | 2022-05-05 13:11:41 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-06-08 14:00:22 -0400 |
commit | 97d0f9bfdd025f0e7db8ff09238fe88d039c2a70 (patch) | |
tree | cb9e7872a83658078a9defdb4761257a84787941 /net | |
parent | 185d3db7bea048bc2257c57fdc3a2edb79d7b36f (diff) | |
download | u-boot-97d0f9bfdd025f0e7db8ff09238fe88d039c2a70.tar.gz u-boot-97d0f9bfdd025f0e7db8ff09238fe88d039c2a70.tar.bz2 u-boot-97d0f9bfdd025f0e7db8ff09238fe88d039c2a70.zip |
net: Add support for reading mac addresses from nvmem cells
This adds support for reading mac addresses from the "mac-address" nvmem
cell. If there is no (local-)mac-address property, then we will try
reading from an nvmem cell.
For some existing examples of this property, refer to imx8mn.dtsi and
imx8mp.dtsi. Unfortunately, fuse drivers have not yet been converted
to DM.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/eth-uclass.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/net/eth-uclass.c b/net/eth-uclass.c index bcefc54ded..0f6b45b002 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -14,6 +14,7 @@ #include <env.h> #include <log.h> #include <net.h> +#include <nvmem.h> #include <asm/global_data.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h> @@ -507,17 +508,21 @@ static bool eth_dev_get_mac_address(struct udevice *dev, u8 mac[ARP_HLEN]) { #if CONFIG_IS_ENABLED(OF_CONTROL) const uint8_t *p; + struct nvmem_cell mac_cell; p = dev_read_u8_array_ptr(dev, "mac-address", ARP_HLEN); if (!p) p = dev_read_u8_array_ptr(dev, "local-mac-address", ARP_HLEN); - if (!p) - return false; + if (p) { + memcpy(mac, p, ARP_HLEN); + return true; + } - memcpy(mac, p, ARP_HLEN); + if (nvmem_cell_get_by_name(dev, "mac-address", &mac_cell)) + return false; - return true; + return !nvmem_cell_read(&mac_cell, mac, ARP_HLEN); #else return false; #endif |