The MinnowBoard UEFI firmware exports Eg20tMacAddress2 and contains the MAC address provisioned during manufacturing. Create a callback in the platform driver for reading this address.
Signed-off-by: Darren Hart <[email protected]> --- drivers/platform/x86/Kconfig | 1 + drivers/platform/x86/minnowboard.c | 32 ++++++++++++++++++++++++++++++++ include/linux/minnowboard.h | 2 ++ 3 files changed, 35 insertions(+) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 89d1065..23321b4 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -21,6 +21,7 @@ config MINNOWBOARD depends on GPIO_SCH depends on GPIO_PCH depends on LEDS_GPIO + depends on EFI default n ---help--- This driver configures the MinnowBoard fixed functionality GPIO lines. diff --git a/drivers/platform/x86/minnowboard.c b/drivers/platform/x86/minnowboard.c index c0d93a9..8512516 100644 --- a/drivers/platform/x86/minnowboard.c +++ b/drivers/platform/x86/minnowboard.c @@ -28,12 +28,23 @@ #include <linux/gpio.h> #include <linux/leds.h> #include <linux/gpio-sch.h> +#include <linux/random.h> #include <linux/delay.h> +#include <linux/efi.h> +#include <uapi/linux/if_ether.h> #include <linux/minnowboard.h> #include "minnowboard-gpio.h" static int minnow_hwid_val = -1; +#define EFI_VENDOR_GUID \ + EFI_GUID(0x9ad0b0fd, 0xf325, 0x425c, \ + 0x81, 0xdc, 0xa1, 0xc7, 0xa6, 0x27, 0x55, 0x1b) + +static efi_char16_t eth_addr_efivar_name[] = { + 'E', 'g', '2', '0', 't', 'M', 'a', 'c', 'A', 'd', 'd', 'r', 'e', 's', 's', '2', 0 +}; + /* leds-gpio platform device structures */ static const struct gpio_led minnow_leds[] = { { .name = "minnow_led0", .gpio = GPIO_LED0, .active_low = 0, @@ -102,6 +113,27 @@ void minnow_phy_reset(void) } EXPORT_SYMBOL_GPL(minnow_phy_reset); +void minnow_eth_addr(u8 *addr) +{ + unsigned long data_len = ETH_ALEN; + u32 efi_attrib = 0; + u8 efi_data[data_len]; + efi_status_t ret; + + ret = (&efi)->get_variable(eth_addr_efivar_name, &EFI_VENDOR_GUID, + &efi_attrib, &data_len, &efi_data); + + if (ret != EFI_SUCCESS || data_len != ETH_ALEN) + goto out_err; + + memcpy(addr, &efi_data, data_len); + return; + + out_err: + pr_warn("Failed to read Ethernet address from EFI variable\n"); +} +EXPORT_SYMBOL_GPL(minnow_eth_addr); + static int __init minnow_module_init(void) { int err, val, i; diff --git a/include/linux/minnowboard.h b/include/linux/minnowboard.h index d3608b8..12c0288 100644 --- a/include/linux/minnowboard.h +++ b/include/linux/minnowboard.h @@ -27,11 +27,13 @@ bool minnow_detect(void); bool minnow_lvds_detect(void); int minnow_hwid(void); void minnow_phy_reset(void); +void minnow_eth_addr(u8 *addr); #else #define minnow_detect() (false) #define minnow_lvds_detect() (false) #define minnow_hwid() (-1) #define minnow_phy_reset() do { } while (0) +#define minnow_eth_addr(a) do { } while (0) #endif /* MINNOWBOARD */ #endif /* _LINUX_MINNOWBOARD_H */ -- 1.8.1.2 _______________________________________________ linux-yocto mailing list [email protected] https://lists.yoctoproject.org/listinfo/linux-yocto
