From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 19/31] i2c, mpc83xx: add CONFIG_SYS_I2C_INIT_BOARD for fsl_i2c
Date: Wed, 28 Jan 2009 10:40:11 +0100 [thread overview]
Message-ID: <498027FB.9060709@denx.de> (raw)
This patch adds the possibility to call a board specific
i2c bus reset routine for the fsl_i2c bus driver, and adds
this option for the keymile kmeter1 board.
Signed-off-by: Heiko Schocher <hs@denx.de>
---
board/keymile/common/common.c | 14 ++++++++++++++
drivers/i2c/fsl_i2c.c | 6 ++++++
include/configs/kmeter1.h | 1 +
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index 17312b5..a282421 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -421,6 +421,7 @@ static int get_scl (void)
#endif
+#if !defined(CONFIG_KMETER1)
static void writeStartSeq (void)
{
set_sda (1);
@@ -471,6 +472,7 @@ static int i2c_make_abort (void)
get_sda ();
return ret;
}
+#endif
/**
* i2c_init_board - reset i2c bus. When the board is powercycled during a
@@ -478,6 +480,17 @@ static int i2c_make_abort (void)
*/
void i2c_init_board(void)
{
+#if defined(CONFIG_KMETER1)
+ struct fsl_i2c *dev;
+ dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
+ uchar dummy;
+
+ out_8 (&dev->cr, (I2C_CR_MSTA));
+ out_8 (&dev->cr, (I2C_CR_MEN | I2C_CR_MSTA));
+ dummy = in_8(&dev->dr);
+ out_8 (&dev->cr, (I2C_CR_MEN));
+
+#else
#if defined(CONFIG_HARD_I2C)
volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR ;
volatile i2c8260_t *i2c = (i2c8260_t *)&immap->im_i2c;
@@ -497,6 +510,7 @@ void i2c_init_board(void)
/* Set the PortPins back to use for I2C */
setports (0);
#endif
+#endif
}
#endif
#endif
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index 5242884..7ba5ab1 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -176,6 +176,12 @@ i2c_init(int speed, int slaveadd)
struct fsl_i2c *dev;
unsigned int temp;
+#ifdef CONFIG_SYS_I2C_INIT_BOARD
+ /* call board specific i2c bus reset routine before accessing the */
+ /* environment, which might be in a chip on that bus. For details */
+ /* about this problem see doc/I2C_Edge_Conditions. */
+ i2c_init_board();
+#endif
dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
writeb(0, &dev->cr); /* stop I2C controller */
diff --git a/include/configs/kmeter1.h b/include/configs/kmeter1.h
index 17ddcec..31e5cd6 100644
--- a/include/configs/kmeter1.h
+++ b/include/configs/kmeter1.h
@@ -316,6 +316,7 @@
#define CONFIG_SYS_I2C_OFFSET 0x3000
#define CONFIG_SYS_MAX_I2C_BUS 2
+#define CONFIG_SYS_I2C_INIT_BOARD 1
#define CONFIG_I2C_MUX 1
/* EEprom support */
--
1.6.0.6
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next reply other threads:[~2009-01-28 9:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-28 9:40 Heiko Schocher [this message]
2009-01-28 10:15 ` [U-Boot] [PATCH 19/31] i2c, mpc83xx: add CONFIG_SYS_I2C_INIT_BOARD for fsl_i2c Joakim Tjernlund
2009-01-28 10:54 ` Heiko Schocher
2009-01-28 11:28 ` Joakim Tjernlund
2009-01-28 12:04 ` Heiko Schocher
2009-01-28 13:14 ` Joakim Tjernlund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=498027FB.9060709@denx.de \
--to=hs@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.