[U-Boot] [PATCH 2/3] Reset interrupted i2c slaves (galaxy5200)

Eric Millbrandt emillbrandt at coldhaus.com
Tue Aug 25 15:57:14 CEST 2009


Reset any i2c devices that may have been interrupted by a system reset.
Normally this would be accomplished by clocking the line until SCL and SDA
are released and then sending a start condtiion (From an Atmel datasheet).
But since there is only write access to these lines on the MPC5200 we can
only attempt to reset any slave devices by sending more start commands than
bits the slave is attempting to transmit.

Signed-off-by: Eric Millbrandt <emillbrandt at dekaresearch.com>
---
 Some whitespace cleanup and typos are included in this patch

 board/galaxy5200/galaxy5200.c |   41 +++++++++++++++++++++++++++++++++++++++++
 include/configs/galaxy5200.h  |    9 +++++----
 2 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/board/galaxy5200/galaxy5200.c b/board/galaxy5200/galaxy5200.c
index 5aa9d3a..c38e7de 100644
--- a/board/galaxy5200/galaxy5200.c
+++ b/board/galaxy5200/galaxy5200.c
@@ -155,6 +155,47 @@ phys_size_t initdram(int board_type)
 	return dramsize + dramsize2;
 }
 
+/*
+ * Reset any i2c devices that may have been interrupted by a system reset.
+ * Normally this would be accomplished by clocking the line until SCL and SDA
+ * are released and then sending a start condtiion (From an Atmel datasheet).
+ * But since there is only write access to these lines on the MPC5200 we can
+ * only attempt to reset any slave devices by sending more start commands than
+ * bits the slave is attempting to transmit.
+ */
+int misc_init_f(void)
+{
+	volatile struct mpc5xxx_gpio *gpio =
+		(struct mpc5xxx_gpio *)MPC5XXX_GPIO;
+	int i;
+	u16 state;
+
+	state = gpio->outo_gpioe;
+
+	/* Enable gpio on i2c1 and i2c2 */
+	gpio->outo_gpioe |= 0xf;
+
+	/*
+	 * Send an i2c start command 16 times to reset the state machines on
+	 * any slave devices transmitting on the bus.
+	 */
+	for (i = 0; i < 16; i++) {
+		gpio->outo_dvo = 0x5;
+		udelay(5);
+		gpio->outo_dvo |= 0xa;
+		udelay(5);
+		gpio->outo_dvo &= 0xa;
+		udelay(5);
+		gpio->outo_dvo = 0x0;
+		udelay(5);
+	}
+
+	/* Return control of i2c1 and i2c2 */
+	gpio->outo_gpioe = state;
+
+	return 0;
+}
+
 int checkboard(void)
 {
 	puts("Board: galaxy5200\n");
diff --git a/include/configs/galaxy5200.h b/include/configs/galaxy5200.h
index e9a4569..eb2cae6 100644
--- a/include/configs/galaxy5200.h
+++ b/include/configs/galaxy5200.h
@@ -81,8 +81,8 @@
 #endif
 /* RAMBOOT will be defined automatically in memory section */
 
-#define MTDIDS_DEFAULT 		"nor0=physmap-flash.0"
-#define MTDPARTS_DEFAULT   	"mtdparts=physmap-flash.0:256k(ubootl)," \
+#define MTDIDS_DEFAULT		"nor0=physmap-flash.0"
+#define MTDPARTS_DEFAULT	"mtdparts=physmap-flash.0:256k(ubootl)," \
 	"1792k(kernel),13312k(jffs2),256k(uboot)ro,256k(oftree),-(space)"
 
 /*
@@ -94,7 +94,7 @@
 #undef	CONFIG_BOOTARGS
 
 #define CONFIG_PREBOOT	"echo;"	\
-	"echo Welcome to U-Boot"\
+	"echo Welcome to U-Boot;"\
 	"echo"
 
 /*
@@ -110,6 +110,7 @@
 #define CONFIG_SYS_I2C_MODULE 2		/* Select I2C module #1 or #2 */
 #define CONFIG_SYS_I2C_SPEED 100000	/* 100 kHz */
 #define CONFIG_SYS_I2C_SLAVE 0x7F
+#define CONFIG_MISC_INIT_F 1           /* Reset i2c busses */
 
 /*
  * EEPROM CAT24WC32 configuration
@@ -376,7 +377,7 @@
 #define CONFIG_SYS_BOOTCS_START		CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_BOOTCS_SIZE		CONFIG_SYS_FLASH_SIZE
 
-#define CONFIG_SYS_RESET_ADDRESS 	0xff000000
+#define CONFIG_SYS_RESET_ADDRESS	0xff000000
 
 /*
  * USB settings
-- 
1.6.3.1



More information about the U-Boot mailing list