diff mbox

[U-Boot,18/30] i2c: add i2c deblock sequence before and after every mux config

Message ID 6c7b05560c085450498f56f27c6a44d52f07f801.1302272395.git.valentin.longchamp@keymile.com
State Accepted
Commit c649dda537a1a585e51066169e6fdb67e2b8f59e
Headers show

Commit Message

Valentin Longchamp April 8, 2011, 2:24 p.m. UTC
From: Stefan Bigler <stefan.bigler@keymile.com>

To make sure that the mux can be configured a deblocking sequence
is done before the mux configuration. After the mux switch the new leaf
of, the i2c tree must be again deblocked.

Signed-off-by: Stefan Bigler <stefan.bigler@keymile.com>
Acked-by: Heiko Schocher <hs@denx.de>
cc: Wolfgang Denk <wd@denx.de>
cc: Detlev Zundel <dzu@denx.de>
cc: Prafulla Wadaskar <prafulla@marvell.com>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
cc: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
---
 common/cmd_i2c.c |   12 ++++++++++++
 include/i2c.h    |    2 --
 2 files changed, 12 insertions(+), 2 deletions(-)

Comments

Heiko Schocher April 28, 2011, 5:26 p.m. UTC | #1
Hello Valentin,

Valentin Longchamp wrote:
> From: Stefan Bigler <stefan.bigler@keymile.com>
> 
> To make sure that the mux can be configured a deblocking sequence
> is done before the mux configuration. After the mux switch the new leaf
> of, the i2c tree must be again deblocked.
> 
> Signed-off-by: Stefan Bigler <stefan.bigler@keymile.com>
> Acked-by: Heiko Schocher <hs@denx.de>
> cc: Wolfgang Denk <wd@denx.de>
> cc: Detlev Zundel <dzu@denx.de>
> cc: Prafulla Wadaskar <prafulla@marvell.com>
> cc: Valentin Longchamp <valentin.longchamp@keymile.com>
> cc: Holger Brunck <holger.brunck@keymile.com>
> Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
> ---
>  common/cmd_i2c.c |   12 ++++++++++++
>  include/i2c.h    |    2 --
>  2 files changed, 12 insertions(+), 2 deletions(-)

Thanks! Applied to u-boot-i2c. As this patch is independent, it
must not be in a patchseries, so I applied it directly to the
i2c-tree.

bye,
Heiko
diff mbox

Patch

diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index c272b0d..d913e13 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -132,6 +132,14 @@  DECLARE_GLOBAL_DATA_PTR;
 
 #define DISP_LINE_LEN	16
 
+/* implement possible board specific board init */
+void __def_i2c_init_board(void)
+{
+	return;
+}
+void i2c_init_board(void)
+	__attribute__((weak, alias("__def_i2c_init_board")));
+
 /* TODO: Implement architecture-specific get/set functions */
 unsigned int __def_i2c_get_bus_speed(void)
 {
@@ -1541,6 +1549,8 @@  int i2x_mux_select_mux(int bus)
 
 	mux = dev->mux;
 	while (mux != NULL) {
+		/* do deblocking on each level of mux, before mux config */
+		i2c_init_board();
 		if (i2c_write(mux->chip, 0, 0, &mux->channel, 1) != 0) {
 			printf ("Error setting Mux: chip:%x channel: \
 				%x\n", mux->chip, mux->channel);
@@ -1548,6 +1558,8 @@  int i2x_mux_select_mux(int bus)
 		}
 		mux = mux->next;
 	}
+	/* do deblocking on each level of mux and after mux config */
+	i2c_init_board();
 	return 0;
 }
 #endif /* CONFIG_I2C_MUX */
diff --git a/include/i2c.h b/include/i2c.h
index cd23c8a..8ceb4c8 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -108,9 +108,7 @@ 
  * repeatedly to change the speed and slave addresses.
  */
 void i2c_init(int speed, int slaveaddr);
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
 void i2c_init_board(void);
-#endif
 #ifdef CONFIG_SYS_I2C_BOARD_LATE_INIT
 void i2c_board_late_init(void);
 #endif