Skip to contentSkip to conversation

Reset interrupted i2c slaves (galaxy5200)

PATCH New Eric Millbrandt 2 participants 3 messages Aug 25, 2009 – Aug 26, 2009

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/3 Reset interrupted i2c slaves (galaxy5200)

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.

---

Changes since v1:
- Remove non-related modifications to a different patch per Peter's suggestion

 board/galaxy5200/galaxy5200.c |   41 +++++++++++++++++++++++++++++++++++++++++
 include/configs/galaxy5200.h  |    1 +
 2 files changed, 42 insertions(+), 0 deletions(-)
board/galaxy5200/galaxy5200.c +41 -0
index 5aa9d3a..c38e7de 100644
@@ -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");
include/configs/galaxy5200.h +1 -0
index 8d530d8..eb2cae6 100644
@@ -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
Signature · 1 line
1.6.3.1
#1 lore raw

PATCH v2 2/3 Reset interrupted i2c slaves (galaxy5200)

Hello Eric,

Quoted 7 lines · Eric Millbrandt

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.

Quoted 5 lines

---

Changes since v1:
- Remove non-related modifications to a different patch per Peter's suggestion

one common comment:

Can you please use in_*/out_* accessors for accessing mpc52xx registers.

Quoted 12 lines
 board/galaxy5200/galaxy5200.c |   41 +++++++++++++++++++++++++++++++++++++++++
 include/configs/galaxy5200.h  |    1 +
 2 files changed, 42 insertions(+), 0 deletions(-)
board/galaxy5200/galaxy5200.c +0 -0
index 5aa9d3a..c38e7de 100644
@@ -155,6 +155,47 @@ phys_size_t initdram(int board_type)
 	return dramsize + dramsize2;
 }

board/galaxy5200/galaxy5200.c phys_size_t initdram(int board_type) · line 166

Quoted 10 lines
board/galaxy5200/galaxy5200.c +9 -0
 
+/*
+ * 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)

Hmm.. why in misc_init_f? Can you move this function to the mpc52xx i2c driver, and add this in a manner like the send_reset() function in drivers/i2c/soft_i2c.c? And call this send_reset() in the i2c_init() from the mpc52xx i2c driver. As I don;t know, if this is valid for all mpc52xx boards, it should be then also per CONFIG_SYS_* define selectable.

thanks.

bye
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#2 lore raw

PATCH v2 2/3 Reset interrupted i2c slaves (galaxy5200)

Hi Heiko,

On Wed, 26 Aug 2009 08:57:46 +0200, Heiko Schocher wrote

Quoted 13 lines

Hello Eric,

Quoted 10 lines · Eric Millbrandt

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.

---

Quoted 6 lines
Quoted 2 lines

Changes since v1:
- Remove non-related modifications to a different patch per Peter's suggestion

one common comment:

Can you please use in_*/out_* accessors for accessing mpc52xx registers.

Ok. I will do that.

Quoted 2 lines
Quoted 2 lines
 board/galaxy5200/galaxy5200.c |   41

+++++++++++++++++++++++++++++++++++++++++

Quoted 11 lines
Quoted 11 lines
 include/configs/galaxy5200.h  |    1 +
 2 files changed, 42 insertions(+), 0 deletions(-)
board/galaxy5200/galaxy5200.c +0 -0
index 5aa9d3a..c38e7de 100644
@@ -155,6 +155,47 @@ phys_size_t initdram(int board_type)
 	return dramsize + dramsize2;
 }
 
Quoted 6 lines

board/galaxy5200/galaxy5200.c phys_size_t initdram(int board_type)

Quoted 6 lines
board/galaxy5200/galaxy5200.c +6 -0
+/*
+ * 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

Quoted 10 lines

board/galaxy5200/galaxy5200.c phys_size_t initdram(int board_type) · line 166

Quoted 3 lines
board/galaxy5200/galaxy5200.c +3 -0
+ * bits the slave is attempting to transmit.
+ */
+int misc_init_f(void)

Hmm.. why in misc_init_f? Can you move this function to the mpc52xx i2c driver, and add this in a manner like the send_reset() function in drivers/i2c/soft_i2c.c? And call this send_reset() in the i2c_init() from the mpc52xx i2c driver. As I don;t know, if this is valid for all mpc52xx boards, it should be then also per CONFIG_SYS_* define selectable.

The i2c registers that I used are only on the MPC5200B, not the MPC5200. I put the reset function under misc_init_f for that reason. Is adding a single cpu dependent function appropriate for the entire cpu/5xxx family branch? If it is then I will move the reset function to the mpc5xxx i2c driver.

Thanks

http://openwebmail.org - eem