omap4-var-som: extract MAC address from EEPROM
cover omap4-var-som: extract MAC address from EEPROM
Hi all,
The MAC address of the OMAP4-VAR-SOM is located in the SOM's EEPROM under a Variscite-specific format.
This series add support for extracting this MAC address and fowarding it to Linux through the device-tree.
---
Bastien Curutchet (2):
omap4_var_som: extract MAC address from EEPROM
omap4-var-som: forward MAC address to Linux
arch/arm/dts/omap4-var-stk-om44-u-boot.dtsi | 7 ++++ board/variscite/omap4_var_som/omap4_var_som.c | 44 +++++++++++++++++++++++ board/variscite/omap4_var_som/omap4_var_som_mux.h | 2 ++ configs/omap4_var_som_defconfig | 5 +++ 4 files changed, 58 insertions(+)
---
base-commit: ed869863c7e2aca50d57a05d843830dd843138c4
change-id: 20261023-mac-eeprom-20ed76dd0fba
Best regards,
Signature · 1 line
Bastien Curutchet <[email protected]>
PATCH 1/2 omap4_var_som: extract MAC address from EEPROM
The board's MAC address is stored in a Variscite custom blob in the EEPROM.
Enable the I2C bus hosting the EEPROM in the device-tree / pinmux. Enable EEPROM support in the defconfig.
Extract the MAC address at initialization to populate the ethaddr environment variable.
--- arch/arm/dts/omap4-var-stk-om44-u-boot.dtsi | 7 +++++ board/variscite/omap4_var_som/omap4_var_som.c | 37 +++++++++++++++++++++++ board/variscite/omap4_var_som/omap4_var_som_mux.h | 2 ++ configs/omap4_var_som_defconfig | 4 +++ 4 files changed, 50 insertions(+)
arch/arm/dts/omap4-var-stk-om44-u-boot.dtsi +7 -0
@@ -41,6 +41,13 @@ status = "disabled"; }; }; + + /* I2C3 (eeprom) */ + target-module@60000 { + i2c@0 { + status = "okay"; + }; + }; }; };
board/variscite/omap4_var_som/omap4_var_som.c +37 -0
@@ -7,10 +7,13 @@#include <asm/global_data.h> #include <asm/mach-types.h> #include <asm-generic/gpio.h> +#include <dm/uclass.h> #include <env.h> +#include <i2c_eeprom.h> #include <init.h> #include <linux/delay.h> #include <log.h> +#include <net.h> #include <serial.h> #include "omap4_var_som_mux.h"
@@ -113,6 +116,37 @@ void emif_get_device_timings(u32 emif_nr, *cs1_device_timings =NULL ; } +#define VARISCRITE_BLOB_OFFSET 0x600 +#define VARISCITE_BLOB_MAGIC 0x43535256/* VRSC */ +struct variscite_eeprom_blob { +u32 magic; +u32 rev; +u8 eth_mac[ETH_ALEN ]; +}; + +static int extract_mac_from_eeprom (void ) +{ +struct variscite_eeprom_blob blob; +struct udevice *dev; +int ret; + + ret =uclass_first_device_err (UCLASS_I2C_EEPROM , &dev); +if (ret) +return ret; + + ret =i2c_eeprom_read (dev,VARISCRITE_BLOB_OFFSET , (u8 *)&blob,sizeof (blob)); +if (ret) +return ret; + +if (blob.magic !=VARISCITE_BLOB_MAGIC ) +return -EINVAL ; + +if (is_valid_ethaddr (blob.eth_mac)) +eth_env_set_enetaddr ("ethaddr" , blob.eth_mac); + +return 0 ; +} +/** * @brief misc_init_r() - VAR-SOM configuration *
@@ -147,6 +181,9 @@ int misc_init_r(void)writel (altclksrc, &scrm->altclksrc); +/* A failure in the MAC extraction must not prevent from booting */ + (void )extract_mac_from_eeprom (); +return 0 ; }
board/variscite/omap4_var_som/omap4_var_som_mux.h +2 -0
@@ -14,6 +14,8 @@ const struct pad_conf_entry core_padconf_array_essential[] = { {GPMC_NWE, (PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1)}, /* sdmmc2_cmd */ {I2C1_SCL, (PTU | IEN | M0)}, /* i2c1_scl */ {I2C1_SDA, (PTU | IEN | M0)}, /* i2c1_sda */ +{I2C3_SDA, (PTU | IEN | M0)}, /* i2c3_sda */ +{I2C3_SCL, (PTU | IEN | M0)}, /* i2c3_scl */ {UART3_RX_IRRX, (IEN | M0)}, /* uart3_rx */ {UART3_TX_IRTX, (M0)}, /* uart3_tx */ };
configs/omap4_var_som_defconfig +4 -0
@@ -34,6 +34,7 @@ CONFIG_CMD_BOOTZ=y # CONFIG_CMD_ELF is not set CONFIG_CMD_SPL=y CONFIG_CMD_ASKENV=y +CONFIG_CMD_EEPROM=y CONFIG_CMD_BIND=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y
@@ -65,6 +66,9 @@ CONFIG_GPIO_HOG=y CONFIG_DM_I2C=y CONFIG_SPL_SYS_I2C_LEGACY=y # CONFIG_INPUT is not set +CONFIG_MISC=y +CONFIG_I2C_EEPROM=y +CONFIG_SYS_I2C_EEPROM_ADDR=0x50 CONFIG_MMC_OMAP_HS=y CONFIG_DM_PMIC=y CONFIG_DM_REGULATOR=y
Signature · 1 line
2.56.0
PATCH 2/2 omap4-var-som: forward MAC address to Linux
In reply to Bastien CurutchetThe SOM's MAC address is extracted from the EEPROM during initialization. Linux can expose an ethernet node allowing us to forward it through the device-tree.
Enable CONFIG_OF_BOARD_SETUP to patch the Linux device-tree with the MAC address previously extracted from the EEPROM.
--- board/variscite/omap4_var_som/omap4_var_som.c | 7 +++++++ configs/omap4_var_som_defconfig | 1 + 2 files changed, 8 insertions(+)
board/variscite/omap4_var_som/omap4_var_som.c +7 -0
@@ -9,6 +9,7 @@#include <asm-generic/gpio.h> #include <dm/uclass.h> #include <env.h> +#include <fdt_support.h> #include <i2c_eeprom.h> #include <init.h> #include <linux/delay.h>
@@ -207,3 +208,9 @@ int board_mmc_init(struct bd_info *bis)if (IS_ENABLED (CONFIG_MMC ))return omap_mmc_init (0 ,0 ,0 ,-1 ,-1 ); } + +int ft_board_setup (void *blob,struct bd_info *bd) +{ +fdt_fixup_ethernet (blob); +return 0 ; +}
configs/omap4_var_som_defconfig +1 -0
@@ -18,6 +18,7 @@ CONFIG_ENV_VARS_UBOOT_CONFIG=y # CONFIG_BOOTMETH_EFI_BOOTMGR is not set # CONFIG_BOOTMETH_VBE is not set CONFIG_SUPPORT_RAW_INITRD=y +CONFIG_OF_BOARD_SETUP=y CONFIG_DEFAULT_FDT_FILE="omap4-var-stk-om44" CONFIG_SYS_CONSOLE_IS_IN_ENV=y CONFIG_SYS_CONSOLE_INFO_QUIET=y
Signature · 1 line
2.56.0
Quoted 8 lines · Bastien Curutchet
The MAC address of the OMAP4-VAR-SOM is located in the SOM's EEPROM under a Variscite-specific format.
This series add support for extracting this MAC address and fowarding it to Linux through the device-tree.
[...]
Applied to u-boot/main, thanks!
[1/2] omap4_var_som: extract MAC address from EEPROM
commit: f4feca283c3992461702dbb4fb166b44396252dd
[2/2] omap4-var-som: forward MAC address to Linux
commit: f5df14cb949cfca5c6b175abb8d1ac9210b911f5Signature · 1 line
Tom