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

login
register
mail settings
Submitter Stefano Babic
Date Jan. 14, 2011, 1:35 p.m.
Message ID <1295012124-15551-3-git-send-email-sbabic@denx.de>
Download mbox | patch
Permalink /patch/78901/
State Superseded
Delegated to: Stefano Babic
Headers show

Comments

Stefano Babic - Jan. 14, 2011, 1:35 p.m.
Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 drivers/i2c/mxc_i2c.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
Wolfgang Denk - Jan. 19, 2011, 7:37 a.m.
Dear Stefano Babic,

In message <1295012124-15551-3-git-send-email-sbabic@denx.de> you wrote:
> Signed-off-by: Stefano Babic <sbabic@denx.de>

Add a "Cc: Heiko Schocher <hs@denx.de>" here so the responsible
custodian is on Cc:

> -#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"

Please make this "CONFIG_SYS_I2C_MXxx_PORTx" or similar; text
containing "XXX" triggers some spam filters.  Yes, really!


Best regards,

Wolfgang Denk
Stefano Babic - Jan. 19, 2011, 9:46 a.m.
On 01/19/2011 08:37 AM, Wolfgang Denk wrote:
> Dear Stefano Babic,
> 
> In message <1295012124-15551-3-git-send-email-sbabic@denx.de> you wrote:
>> Signed-off-by: Stefano Babic <sbabic@denx.de>
> 
> Add a "Cc: Heiko Schocher <hs@denx.de>" here so the responsible
> custodian is on Cc:
> 
>> -#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"
> 
> Please make this "CONFIG_SYS_I2C_MXxx_PORTx" or similar; text
> containing "XXX" triggers some spam filters.  Yes, really!

I admit I never thought to this kind of problem. Of course, I will
change the name !

Best regards,
Stefano Babic

Patch

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)