diff mbox

[U-Boot,v1,1/8] OMAP3: tam3517: add function to read MAC from EEPROM

Message ID 1346140007-9563-1-git-send-email-sbabic@denx.de
State Accepted
Commit 8103c6f0fa141f19bd6b623f3f9153d9aeb47076
Headers show

Commit Message

Stefano Babic Aug. 28, 2012, 7:46 a.m. UTC
The manufacturer delivers the TAM3517 SOM with 4 MAC address.
They are stored on the EEPROM of the SOM. The patch adds a
function to get their values and set the ethaddr variables.


Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 include/configs/tam3517-common.h |   66 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

Comments

Stefano Babic Aug. 28, 2012, 12:21 p.m. UTC | #1
The MAC address provided by the manufacturer can be
read from the EEPROM. Add also Video support to the
mt_ventoux (TAM3517) board.

Changes in v2:
- Set dispc_config before checking for framebuffer
- Use a common macro to set up the horizontal and vertical timing (Heiko Schocker)
to not break beagleboard (Jeroen Hofstee)

Stefano Babic (9):
  OMAP3: tam3517: add function to read MAC from EEPROM
  OMAP3: twister : get MAC address from EEPROM
  OMAP3: mt_ventoux: Correct board pinmux
  OMAP3: mt_ventoux: activate GPIO4
  OMAP3: mt_ventoux: read MAC address from EEPROM
  OMAP3: mt_ventoux: disable the buzzer at start-up
  video: drop duplicate set of DISPC_CONFIG register
  OMAP3: video: add macros to set display parameters
  OMAP3: mt_ventoux: added video support

 arch/arm/include/asm/arch-omap3/dss.h |    5 +-
 board/technexion/twister/twister.c    |   10 +++
 board/teejet/mt_ventoux/mt_ventoux.c  |  113 +++++++++++++++++++++++++++++++++
 board/teejet/mt_ventoux/mt_ventoux.h  |   80 ++++++++++-------------
 drivers/video/omap3_dss.c             |    3 +-
 include/configs/mt_ventoux.h          |   17 +++++
 include/configs/tam3517-common.h      |   66 +++++++++++++++++++
 7 files changed, 245 insertions(+), 49 deletions(-)
Stefano Babic Aug. 29, 2012, 11:21 a.m. UTC | #2
The MAC address provided by the manufacturer can be
read from the EEPROM. Add also Video support to the
mt_ventoux (TAM3517) board.

Changes in v2:
- Set dispc_config before checking for framebuffer
- Use a common macro to set up the horizontal and vertical timing (Heiko Schocker)
to not break beagleboard (Jeroen Hofstee)

Changes in v3:
- Add further macros to define the single fields (Jeroen Hofstee)

Stefano Babic (9):
  OMAP3: tam3517: add function to read MAC from EEPROM
  OMAP3: twister : get MAC address from EEPROM
  OMAP3: mt_ventoux: Correct board pinmux
  OMAP3: mt_ventoux: activate GPIO4
  OMAP3: mt_ventoux: read MAC address from EEPROM
  OMAP3: mt_ventoux: disable the buzzer at start-up
  video: drop duplicate set of DISPC_CONFIG register
  OMAP3: video: add macros to set display parameters
  OMAP3: mt_ventoux: added video support

 arch/arm/include/asm/arch-omap3/dss.h |   11 +++-
 board/technexion/twister/twister.c    |   10 +++
 board/teejet/mt_ventoux/mt_ventoux.c  |  113 +++++++++++++++++++++++++++++++++
 board/teejet/mt_ventoux/mt_ventoux.h  |   80 ++++++++++-------------
 drivers/video/omap3_dss.c             |    3 +-
 include/configs/mt_ventoux.h          |   17 +++++
 include/configs/tam3517-common.h      |   66 +++++++++++++++++++
 7 files changed, 251 insertions(+), 49 deletions(-)
Tom Rini Aug. 29, 2012, 3:13 p.m. UTC | #3
On 08/29/2012 04:21 AM, Stefano Babic wrote:
> The MAC address provided by the manufacturer can be
> read from the EEPROM. Add also Video support to the
> mt_ventoux (TAM3517) board.
> 
> Changes in v2:
> - Set dispc_config before checking for framebuffer
> - Use a common macro to set up the horizontal and vertical timing (Heiko Schocker)
> to not break beagleboard (Jeroen Hofstee)
> 
> Changes in v3:
> - Add further macros to define the single fields (Jeroen Hofstee)

Barring further comments, I plan to pick this up Friday for
u-boot-ti/master, thanks!
Tom Rini Aug. 29, 2012, 4:28 p.m. UTC | #4
On Wed, Aug 29, 2012 at 01:21:58PM +0200, Stefano Babic wrote:

> The MAC address provided by the manufacturer can be
> read from the EEPROM. Add also Video support to the
> mt_ventoux (TAM3517) board.
> 
> Changes in v2:
> - Set dispc_config before checking for framebuffer
> - Use a common macro to set up the horizontal and vertical timing (Heiko Schocker)
> to not break beagleboard (Jeroen Hofstee)
> 
> Changes in v3:
> - Add further macros to define the single fields (Jeroen Hofstee)

I gave this a quick spin on Beagleboard / Beagleboard xM due to the
video changes, and all is as good as before.

Tested-by: Tom Rini <trini@ti.com>
Tom Rini Aug. 31, 2012, 11:07 p.m. UTC | #5
On Wed, Aug 29, 2012 at 08:13:01AM -0700, Tom Rini wrote:
> On 08/29/2012 04:21 AM, Stefano Babic wrote:
> > The MAC address provided by the manufacturer can be
> > read from the EEPROM. Add also Video support to the
> > mt_ventoux (TAM3517) board.
> > 
> > Changes in v2:
> > - Set dispc_config before checking for framebuffer
> > - Use a common macro to set up the horizontal and vertical timing (Heiko Schocker)
> > to not break beagleboard (Jeroen Hofstee)
> > 
> > Changes in v3:
> > - Add further macros to define the single fields (Jeroen Hofstee)
> 
> Barring further comments, I plan to pick this up Friday for
> u-boot-ti/master, thanks!

Applied to u-boot-ti/master, thanks!
diff mbox

Patch

diff --git a/include/configs/tam3517-common.h b/include/configs/tam3517-common.h
index 24f6f7e..51503da 100644
--- a/include/configs/tam3517-common.h
+++ b/include/configs/tam3517-common.h
@@ -125,6 +125,7 @@ 
 #define CONFIG_CMD_NAND		/* NAND support			*/
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_USB
+#define CONFIG_CMD_EEPROM
 
 #undef CONFIG_CMD_FLASH		/* only NAND on the SOM */
 #undef CONFIG_CMD_IMLS
@@ -135,6 +136,9 @@ 
 #define CONFIG_SYS_I2C_SLAVE		1
 #define CONFIG_SYS_I2C_BUS		0
 #define CONFIG_SYS_I2C_BUS_SELECT	1
+#define CONFIG_SYS_I2C_EEPROM_ADDR	0x50		/* base address */
+#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1		/* bytes of address */
+#define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW	0x07
 #define CONFIG_DRIVER_OMAP34XX_I2C
 
 
@@ -354,4 +358,66 @@ 
 		"fi;"							\
 		"else echo U-Boot not downloaded..exiting;fi\0"		\
 
+
+/*
+ * this is common code for all TAM3517 boards.
+ * MAC address is stored from manufacturer in
+ * I2C EEPROM
+ */
+#if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
+
+/*
+ * The I2C EEPROM on the TAM3517 contains
+ * mac address and production data
+ */
+struct tam3517_module_info {
+	char customer[48];
+	char product[48];
+
+	/*
+	 * bit 0~47  : sequence number
+	 * bit 48~55 : week of year, from 0.
+	 * bit 56~63 : year
+	 */
+	unsigned long long sequence_number;
+
+	/*
+	 * bit 0~7   : revision fixed
+	 * bit 8~15  : revision major
+	 * bit 16~31 : TNxxx
+	 */
+	unsigned int revision;
+	unsigned char eth_addr[4][8];
+	unsigned char _rev[100];
+};
+
+#define TAM3517_READ_MAC_FROM_EEPROM	\
+do {					\
+	struct tam3517_module_info info;\
+	char buf[80], ethname[20];	\
+	int i;				\
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);	\
+	if (eeprom_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0,		\
+			(void *)&info, sizeof(info)))		\
+		break;						\
+	memset(buf, 0, sizeof(buf));				\
+	for (i = 0 ; i < ARRAY_SIZE(info.eth_addr); i++) {	\
+		sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",	\
+			info.eth_addr[i][5],			\
+			info.eth_addr[i][4],			\
+			info.eth_addr[i][3],			\
+			info.eth_addr[i][2],			\
+			info.eth_addr[i][1],			\
+			info.eth_addr[i][0]);			\
+								\
+		if (i)						\
+			sprintf(ethname, "eth%daddr", i);	\
+		else						\
+			sprintf(ethname, "ethaddr");		\
+		printf("Setting %s from EEPROM with %s\n", ethname, buf);\
+		setenv(ethname, buf);				\
+	}							\
+} while (0)
+#endif
+
 #endif /* __TAM3517_H */