[U-Boot] [PATCH] sh: r0p7734: Add support I2C and set MAC address

Nobuhiro Iwamatsu nobuhiro.iwamatsu.yj at renesas.com
Fri Feb 3 08:30:49 CET 2012


r0p7734 board stores away MAC address in EEPROM.
This sets an MAC address to reading, environment variable
from an EEPROM by supporting I2C.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj at renesas.com>
---
 board/renesas/r0p7734/r0p7734.c |   19 ++++++++++++++++++-
 include/configs/r0p7734.h       |   16 ++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/board/renesas/r0p7734/r0p7734.c b/board/renesas/r0p7734/r0p7734.c
index 80f4329..656b9ee 100644
--- a/board/renesas/r0p7734/r0p7734.c
+++ b/board/renesas/r0p7734/r0p7734.c
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/processor.h>
+#include <i2c.h>
 #include <netdev.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -50,11 +51,28 @@ int checkboard(void)
 
 int board_init(void)
 {
+	u8 mac[6];
+	char env_mac[17];
+	int i;
+
 #if defined(CONFIG_SH_ETHER)
 	u32 r = readl(MSTPSR1);
 	if (r & MSTPSR1_GETHER)
 		writel((r & ~MSTPSR1_GETHER), MSTPCR1);
 #endif
+
+	/* Read MAC address */
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_set_bus_num(CONFIG_SYS_I2C_MODULE); /* Use I2C 0 */
+
+	i2c_read(0x50, 0x10, 0, mac, 6);
+
+	/* Set MAC address */
+	printf("%02X:%02X:%02X:%02X:%02X:%02X\n",
+		mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+	sprintf(env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
+		mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
 	return 0;
 }
 
@@ -75,4 +93,3 @@ int board_eth_init(bd_t *bis)
 	return rc;
 }
 #endif
-
diff --git a/include/configs/r0p7734.h b/include/configs/r0p7734.h
index d73cc4d..22c1ef7 100644
--- a/include/configs/r0p7734.h
+++ b/include/configs/r0p7734.h
@@ -34,6 +34,7 @@
 #define CONFIG_400MHZ_MODE	1
 /* #define CONFIG_533MHZ_MODE	1 */
 
+#define BOARD_LATE_INIT		1
 #define CONFIG_SYS_TEXT_BASE 0x8FFC0000
 
 #define CONFIG_CMD_FLASH
@@ -53,6 +54,21 @@
 #define CONFIG_VERSION_VARIABLE
 #undef  CONFIG_SHOW_BOOT_PROGRESS
 
+/* I2C */
+#define CONFIG_CMD_I2C
+#define CONFIG_SH_SH7734_I2C 1
+#define CONFIG_HARD_I2C     1
+#define CONFIG_I2C_MULTI_BUS    1  
+#define CONFIG_SYS_MAX_I2C_BUS  2
+#define CONFIG_SYS_I2C_MODULE   0
+#define CONFIG_SYS_I2C_SPEED    100000 /* 100 kHz */
+#define CONFIG_SYS_I2C_SLAVE    0x50
+#define CONFIG_SH_I2C_DATA_HIGH 4
+#define CONFIG_SH_I2C_DATA_LOW  5
+#define CONFIG_SH_I2C_CLOCK     500000000
+#define CONFIG_SH_I2C_BASE0     0xFFC70000
+#define CONFIG_SH_I2C_BASE1     0xFFC71000
+
 /* Ether */
 #define CONFIG_SH_ETHER 1
 #define CONFIG_SH_ETHER_USE_PORT (0)
-- 
1.7.7.3



More information about the U-Boot mailing list