diff mbox

[U-Boot,V2,17/18] arm: mx6: cm_fx6: use eeprom

Message ID 1407690780-19645-9-git-send-email-nikita@compulab.co.il
State Superseded
Headers show

Commit Message

Nikita Kiryanov Aug. 10, 2014, 5:12 p.m. UTC
Use Compulab eeprom module to obtain revision number, serial number, and
mac address from the EEPROM.

Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@ti.com>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
---
Changes in V2:
	- No changes

 board/compulab/cm_fx6/cm_fx6.c | 26 +++++++++++++++++++++++++-
 include/configs/cm_fx6.h       |  2 ++
 2 files changed, 27 insertions(+), 1 deletion(-)

Comments

Igor Grinberg Aug. 14, 2014, 6:59 a.m. UTC | #1
On 08/10/14 20:12, Nikita Kiryanov wrote:
> Use Compulab eeprom module to obtain revision number, serial number, and
> mac address from the EEPROM.
> 
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Tom Rini <trini@ti.com>
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> ---
> Changes in V2:
> 	- No changes
> 
>  board/compulab/cm_fx6/cm_fx6.c | 26 +++++++++++++++++++++++++-
>  include/configs/cm_fx6.h       |  2 ++
>  2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
> index 1b967e5..76d7430 100644
> --- a/board/compulab/cm_fx6/cm_fx6.c
> +++ b/board/compulab/cm_fx6/cm_fx6.c

[...]

> @@ -348,5 +372,5 @@ int dram_init(void)
>  
>  u32 get_board_rev(void)
>  {
> -	return 100;
> +	return cl_eeprom_get_board_rev();
>  }

I would expect this function to be introduced here and
not before this patch - along with I2C support and CONFIG_REVISION_TAG.

> diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
> index 0aa88fd..adfd55e 100644
> --- a/include/configs/cm_fx6.h
> +++ b/include/configs/cm_fx6.h
> @@ -236,6 +236,8 @@
>  #define CONFIG_SYS_BOOTMAPSZ	        (8 << 20)
>  #define CONFIG_SETUP_MEMORY_TAGS
>  #define CONFIG_INITRD_TAG
> +#define CONFIG_REVISION_TAG
> +#define CONFIG_SERIAL_TAG
>  
>  /* misc */
>  #define CONFIG_SYS_GENERIC_BOARD
>
diff mbox

Patch

diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index 1b967e5..76d7430 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -19,6 +19,7 @@ 
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include "common.h"
+#include "../common/eeprom.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -207,8 +208,31 @@  static iomux_v3_cfg_t const enet_pads[] = {
 						MUX_PAD_CTRL(ENET_PAD_CTRL)),
 };
 
+static int handle_mac_address(void)
+{
+	unsigned char enetaddr[6];
+	int rc;
+
+	rc = eth_getenv_enetaddr("ethaddr", enetaddr);
+	if (rc)
+		return 0;
+
+	rc = cl_eeprom_read_mac_addr(enetaddr);
+	if (rc)
+		return rc;
+
+	if (!is_valid_ether_addr(enetaddr))
+		return -1;
+
+	return eth_setenv_enetaddr("ethaddr", enetaddr);
+}
+
 int board_eth_init(bd_t *bis)
 {
+	int res = handle_mac_address();
+	if (res)
+		puts("No MAC address found\n");
+
 	SETUP_IOMUX_PADS(enet_pads);
 	/* phy reset */
 	gpio_direction_output(CM_FX6_ENET_NRST, 0);
@@ -348,5 +372,5 @@  int dram_init(void)
 
 u32 get_board_rev(void)
 {
-	return 100;
+	return cl_eeprom_get_board_rev();
 }
diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
index 0aa88fd..adfd55e 100644
--- a/include/configs/cm_fx6.h
+++ b/include/configs/cm_fx6.h
@@ -236,6 +236,8 @@ 
 #define CONFIG_SYS_BOOTMAPSZ	        (8 << 20)
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_INITRD_TAG
+#define CONFIG_REVISION_TAG
+#define CONFIG_SERIAL_TAG
 
 /* misc */
 #define CONFIG_SYS_GENERIC_BOARD