[U-Boot] [PATCH 3/7] mxc_i2c: Add support for the i.MX35 processor

Stefano Babic
2011-01-14T13:35:20Z

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
drivers/i2c/mxc_i2c.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 8e10fbb..74a984d 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -26,8 +26,13 @@

#if defined(CONFIG_HARD_I2C)

+#if defined(CONFIG_MX31)
#include <asm/arch/mx31.h>
#include <asm/arch/mx31-regs.h>
+#else
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/clock.h>
+#endif

#define IADR 0x00
#define IFDR 0x04
@@ -56,8 +61,10 @@
#elif defined (CONFIG_SYS_I2C_MX31_PORT3)
#define I2C_BASE 0x43f84000
#define I2C_CLK_OFFSET 30
+#elif defined (CONFIG_SYS_I2C_MX35_PORT1)
+#define I2C_BASE I2C_BASE_ADDR
#else
-#error "define CONFIG_SYS_I2C_MX31_PORTx to use the mx31 I2C driver"
+#error "define CONFIG_SYS_I2C_MXXX_PORTx to use the mx I2C driver"
#endif

#ifdef DEBUG
@@ -72,11 +79,16 @@ static u16 div[] = { 30, 32, 36, 42, 48, 52, 60, 72, 80, 88, 104, 128, 144,

void i2c_init(int speed, int unused)
{
- int freq = mx31_get_ipg_clk();
+ int freq;
int i;

+#ifdef CONFIG_MX31
+ freq = mx31_get_ipg_clk();
/* start the required I2C clock */
__REG(CCM_CGR0) = __REG(CCM_CGR0) | (3 << I2C_CLK_OFFSET);
+#else
+ freq = mxc_get_clock(MXC_IPG_PERCLK);
+#endif

for (i = 0; i < 0x1f; i++)
if (freq / div[i] <= speed)
--
1.7.1