Message ID | 20220207234212.685316-12-sean.anderson@seco.com |
---|---|
State | Changes Requested |
Delegated to: | Simon Glass |
Headers | show |
Series | Add support for NVMEM API | expand |
On Mon, 7 Feb 2022 at 16:42, Sean Anderson <sean.anderson@seco.com> wrote: > > 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> > --- > > net/eth-uclass.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 58c308f332..211e88fbbe 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -13,6 +13,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> @@ -499,17 +500,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) + if (p) { + memcpy(mac, p, ARP_HLEN); + return true; + } + + if (nvmem_cell_get_by_name(dev, "mac-address", &mac_cell)) return false; - memcpy(mac, p, ARP_HLEN); - - return true; + return !nvmem_cell_read(&mac_cell, mac, ARP_HLEN); #else return false; #endif
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> --- net/eth-uclass.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)