diff mbox

[U-Boot,V5,4/6] I2C: add i2c support for Pantheon platform

Message ID 1301295228-12752-5-git-send-email-leiwen@marvell.com
State Superseded
Headers show

Commit Message

Lei Wen March 28, 2011, 6:53 a.m. UTC
Add i2c support to dkb board with pantheon soc.

Signed-off-by: Lei Wen <leiwen@marvell.com>
---
Changelog:
V2:
NO CHANGE

V3:
clean code sytle issue
Add i2c clock enable code include in I2C configure define block

V4:
make i2c definition included in the ifdef

V5:
NO CHANGE

 arch/arm/cpu/arm926ejs/pantheon/cpu.c    |   12 ++++++++++++
 arch/arm/include/asm/arch-pantheon/cpu.h |    4 +++-
 arch/arm/include/asm/arch-pantheon/mfp.h |    6 ++++--
 board/Marvell/dkb/dkb.c                  |    4 ++++
 include/configs/dkb.h                    |   13 +++++++++++++
 5 files changed, 36 insertions(+), 3 deletions(-)

Comments

Prafulla Wadaskar March 29, 2011, 1:07 p.m. UTC | #1
> -----Original Message-----
> From: Lei Wen [mailto:leiwen@marvell.com]
> Sent: Monday, March 28, 2011 12:24 PM
> To: Heiko Schocher; Prafulla Wadaskar; Wolfgang Denk; u-
> boot@lists.denx.de; Marek Vasut; Ashish Karkare; Prabhanjan Sarnaik; Yu
> Tang; adrian.wenl@gmail.com
> Subject: [PATCH V5 4/6] I2C: add i2c support for Pantheon platform
> 
> Add i2c support to dkb board with pantheon soc.
> 
> Signed-off-by: Lei Wen <leiwen@marvell.com>
> ---
> Changelog:
> V2:
> NO CHANGE
> 
> V3:
> clean code sytle issue
> Add i2c clock enable code include in I2C configure define block
> 
> V4:
> make i2c definition included in the ifdef
> 
> V5:
> NO CHANGE
> 
>  arch/arm/cpu/arm926ejs/pantheon/cpu.c    |   12 ++++++++++++
>  arch/arm/include/asm/arch-pantheon/cpu.h |    4 +++-
>  arch/arm/include/asm/arch-pantheon/mfp.h |    6 ++++--
>  board/Marvell/dkb/dkb.c                  |    4 ++++
>  include/configs/dkb.h                    |   13 +++++++++++++
>  5 files changed, 36 insertions(+), 3 deletions(-)
> 
...snip...

> diff --git a/include/configs/dkb.h b/include/configs/dkb.h
> index 638af5e..599c8b8 100644
> --- a/include/configs/dkb.h
> +++ b/include/configs/dkb.h
> @@ -56,6 +56,19 @@
>  #include "mv-common.h"
> 
>  #undef CONFIG_ARCH_MISC_INIT
> +
> +/*
> + * I2C definition
> + */
> +#define CONFIG_CMD_I2C

This command definition should be moved up (below #include <config_cmd_default.h>

Otherwise ack for rest of the code

Regards..
Prafulla . .

> +#ifdef CONFIG_CMD_I2C
> +#define CONFIG_I2C_MV			1
> +#define CONFIG_PXA_I2C_REG		0xd4011000
> +#define CONFIG_HARD_I2C			1
> +#define CONFIG_SYS_I2C_SPEED		0
> +#define CONFIG_SYS_I2C_SLAVE		0xfe
> +#endif
> +
>  /*
>   * Environment variables configurations
>   */
> --
> 1.7.0.4
Lei Wen March 30, 2011, 2:05 p.m. UTC | #2
Hi Prafulla,

On Tue, Mar 29, 2011 at 9:07 PM, Prafulla Wadaskar <prafulla@marvell.com> wrote:
>
>
>> -----Original Message-----
>> From: Lei Wen [mailto:leiwen@marvell.com]
>> Sent: Monday, March 28, 2011 12:24 PM
>> To: Heiko Schocher; Prafulla Wadaskar; Wolfgang Denk; u-
>> boot@lists.denx.de; Marek Vasut; Ashish Karkare; Prabhanjan Sarnaik; Yu
>> Tang; adrian.wenl@gmail.com
>> Subject: [PATCH V5 4/6] I2C: add i2c support for Pantheon platform
>>
>> Add i2c support to dkb board with pantheon soc.
>>
>> Signed-off-by: Lei Wen <leiwen@marvell.com>
>> ---
>> Changelog:
>> V2:
>> NO CHANGE
>>
>> V3:
>> clean code sytle issue
>> Add i2c clock enable code include in I2C configure define block
>>
>> V4:
>> make i2c definition included in the ifdef
>>
>> V5:
>> NO CHANGE
>>
>>  arch/arm/cpu/arm926ejs/pantheon/cpu.c    |   12 ++++++++++++
>>  arch/arm/include/asm/arch-pantheon/cpu.h |    4 +++-
>>  arch/arm/include/asm/arch-pantheon/mfp.h |    6 ++++--
>>  board/Marvell/dkb/dkb.c                  |    4 ++++
>>  include/configs/dkb.h                    |   13 +++++++++++++
>>  5 files changed, 36 insertions(+), 3 deletions(-)
>>
> ...snip...
>
>> diff --git a/include/configs/dkb.h b/include/configs/dkb.h
>> index 638af5e..599c8b8 100644
>> --- a/include/configs/dkb.h
>> +++ b/include/configs/dkb.h
>> @@ -56,6 +56,19 @@
>>  #include "mv-common.h"
>>
>>  #undef CONFIG_ARCH_MISC_INIT
>> +
>> +/*
>> + * I2C definition
>> + */
>> +#define CONFIG_CMD_I2C
>
> This command definition should be moved up (below #include <config_cmd_default.h>

I'm ok to put this define to the config_cmd_default.h, but this mean
many other platform need
which didn't not need the i2c but include the <config_cmd_default.h>,
need to undef the i2c now.
Does that worth the change?

Best regards,
Lei
Prafulla Wadaskar March 30, 2011, 6:56 p.m. UTC | #3
> -----Original Message-----
> From: Lei Wen [mailto:adrian.wenl@gmail.com]
> Sent: Wednesday, March 30, 2011 7:36 PM
> To: Prafulla Wadaskar
> Cc: Lei Wen; Heiko Schocher; Wolfgang Denk; u-boot@lists.denx.de; Marek
> Vasut; Ashish Karkare; Prabhanjan Sarnaik; Yu Tang
> Subject: Re: [PATCH V5 4/6] I2C: add i2c support for Pantheon platform
> 
> Hi Prafulla,
> 
> On Tue, Mar 29, 2011 at 9:07 PM, Prafulla Wadaskar
> <prafulla@marvell.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Lei Wen [mailto:leiwen@marvell.com]
> >> Sent: Monday, March 28, 2011 12:24 PM
> >> To: Heiko Schocher; Prafulla Wadaskar; Wolfgang Denk; u-
> >> boot@lists.denx.de; Marek Vasut; Ashish Karkare; Prabhanjan Sarnaik;
> Yu
> >> Tang; adrian.wenl@gmail.com
> >> Subject: [PATCH V5 4/6] I2C: add i2c support for Pantheon platform
> >>
> >> Add i2c support to dkb board with pantheon soc.
> >>
> >> Signed-off-by: Lei Wen <leiwen@marvell.com>
> >> ---
> >> Changelog:
> >> V2:
> >> NO CHANGE
> >>
> >> V3:
> >> clean code sytle issue
> >> Add i2c clock enable code include in I2C configure define block
> >>
> >> V4:
> >> make i2c definition included in the ifdef
> >>
> >> V5:
> >> NO CHANGE
> >>
> >>  arch/arm/cpu/arm926ejs/pantheon/cpu.c    |   12 ++++++++++++
> >>  arch/arm/include/asm/arch-pantheon/cpu.h |    4 +++-
> >>  arch/arm/include/asm/arch-pantheon/mfp.h |    6 ++++--
> >>  board/Marvell/dkb/dkb.c                  |    4 ++++
> >>  include/configs/dkb.h                    |   13 +++++++++++++
> >>  5 files changed, 36 insertions(+), 3 deletions(-)
> >>
> > ...snip...
> >
> >> diff --git a/include/configs/dkb.h b/include/configs/dkb.h
> >> index 638af5e..599c8b8 100644
> >> --- a/include/configs/dkb.h
> >> +++ b/include/configs/dkb.h
> >> @@ -56,6 +56,19 @@
> >>  #include "mv-common.h"
> >>
> >>  #undef CONFIG_ARCH_MISC_INIT
> >> +
> >> +/*
> >> + * I2C definition
> >> + */
> >> +#define CONFIG_CMD_I2C
> >
> > This command definition should be moved up (below #include
> <config_cmd_default.h>
> 
> I'm ok to put this define to the config_cmd_default.h, but this mean
> many other platform need
> which didn't not need the i2c but include the <config_cmd_default.h>,
> need to undef the i2c now.
> Does that worth the change?

I don't mean here to put it in to the config_cmd_default.h
I means put it below #include <config_cmd_default.h> line where other commands are defined/undefed.

Regards..
Prafulla . .

> 
> Best regards,
> Lei
Lei Wen March 31, 2011, 7:49 a.m. UTC | #4
Hi Prafulla,

On Thu, Mar 31, 2011 at 2:56 AM, Prafulla Wadaskar <prafulla@marvell.com> wrote:
>
>
>> -----Original Message-----
>> From: Lei Wen [mailto:adrian.wenl@gmail.com]
>> Sent: Wednesday, March 30, 2011 7:36 PM
>> To: Prafulla Wadaskar
>> Cc: Lei Wen; Heiko Schocher; Wolfgang Denk; u-boot@lists.denx.de; Marek
>> Vasut; Ashish Karkare; Prabhanjan Sarnaik; Yu Tang
>> Subject: Re: [PATCH V5 4/6] I2C: add i2c support for Pantheon platform
>>
>> Hi Prafulla,
>>
>> On Tue, Mar 29, 2011 at 9:07 PM, Prafulla Wadaskar
>> <prafulla@marvell.com> wrote:
>> >
>> >
>> >> -----Original Message-----
>> >> From: Lei Wen [mailto:leiwen@marvell.com]
>> >> Sent: Monday, March 28, 2011 12:24 PM
>> >> To: Heiko Schocher; Prafulla Wadaskar; Wolfgang Denk; u-
>> >> boot@lists.denx.de; Marek Vasut; Ashish Karkare; Prabhanjan Sarnaik;
>> Yu
>> >> Tang; adrian.wenl@gmail.com
>> >> Subject: [PATCH V5 4/6] I2C: add i2c support for Pantheon platform
>> >>
>> >> Add i2c support to dkb board with pantheon soc.
>> >>
>> >> Signed-off-by: Lei Wen <leiwen@marvell.com>
>> >> ---
>> >> Changelog:
>> >> V2:
>> >> NO CHANGE
>> >>
>> >> V3:
>> >> clean code sytle issue
>> >> Add i2c clock enable code include in I2C configure define block
>> >>
>> >> V4:
>> >> make i2c definition included in the ifdef
>> >>
>> >> V5:
>> >> NO CHANGE
>> >>
>> >>  arch/arm/cpu/arm926ejs/pantheon/cpu.c    |   12 ++++++++++++
>> >>  arch/arm/include/asm/arch-pantheon/cpu.h |    4 +++-
>> >>  arch/arm/include/asm/arch-pantheon/mfp.h |    6 ++++--
>> >>  board/Marvell/dkb/dkb.c                  |    4 ++++
>> >>  include/configs/dkb.h                    |   13 +++++++++++++
>> >>  5 files changed, 36 insertions(+), 3 deletions(-)
>> >>
>> > ...snip...
>> >
>> >> diff --git a/include/configs/dkb.h b/include/configs/dkb.h
>> >> index 638af5e..599c8b8 100644
>> >> --- a/include/configs/dkb.h
>> >> +++ b/include/configs/dkb.h
>> >> @@ -56,6 +56,19 @@
>> >>  #include "mv-common.h"
>> >>
>> >>  #undef CONFIG_ARCH_MISC_INIT
>> >> +
>> >> +/*
>> >> + * I2C definition
>> >> + */
>> >> +#define CONFIG_CMD_I2C
>> >
>> > This command definition should be moved up (below #include
>> <config_cmd_default.h>
>>
>> I'm ok to put this define to the config_cmd_default.h, but this mean
>> many other platform need
>> which didn't not need the i2c but include the <config_cmd_default.h>,
>> need to undef the i2c now.
>> Does that worth the change?
>
> I don't mean here to put it in to the config_cmd_default.h
> I means put it below #include <config_cmd_default.h> line where other commands are defined/undefed.
>

Understand...
Patch to come...

Best regards,
Lei
diff mbox

Patch

diff --git a/arch/arm/cpu/arm926ejs/pantheon/cpu.c b/arch/arm/cpu/arm926ejs/pantheon/cpu.c
index 9ddc77c..8b2eafa 100644
--- a/arch/arm/cpu/arm926ejs/pantheon/cpu.c
+++ b/arch/arm/cpu/arm926ejs/pantheon/cpu.c
@@ -59,6 +59,12 @@  int arch_cpu_init(void)
 	/* Enable GPIO clock */
 	writel(APBC_APBCLK, &apbclkres->gpio);
 
+#ifdef CONFIG_I2C_MV
+	/* Enable I2C clock */
+	writel(APBC_RST | APBC_FNCLK | APBC_APBCLK, &apbclkres->twsi);
+	writel(APBC_FNCLK | APBC_APBCLK, &apbclkres->twsi);
+#endif
+
 	icache_enable();
 
 	return 0;
@@ -76,3 +82,9 @@  int print_cpuinfo(void)
 	return 0;
 }
 #endif
+
+#ifdef CONFIG_I2C_MV
+void i2c_clk_enable(void)
+{
+}
+#endif
diff --git a/arch/arm/include/asm/arch-pantheon/cpu.h b/arch/arm/include/asm/arch-pantheon/cpu.h
index 30f4393..60955c5 100644
--- a/arch/arm/include/asm/arch-pantheon/cpu.h
+++ b/arch/arm/include/asm/arch-pantheon/cpu.h
@@ -50,7 +50,9 @@  struct panthapb_registers {
 	u32 uart0;	/*0x000*/
 	u32 uart1;	/*0x004*/
 	u32 gpio;	/*0x008*/
-	u8 pad0[0x034 - 0x08 - 4];
+	u8 pad0[0x02c - 0x08 - 4];
+	u32 twsi;	/*0x02c*/
+	u8 pad1[0x034 - 0x2c - 4];
 	u32 timers;	/*0x034*/
 };
 
diff --git a/arch/arm/include/asm/arch-pantheon/mfp.h b/arch/arm/include/asm/arch-pantheon/mfp.h
index fb291cf..e939196 100644
--- a/arch/arm/include/asm/arch-pantheon/mfp.h
+++ b/arch/arm/include/asm/arch-pantheon/mfp.h
@@ -32,8 +32,10 @@ 
  * offset, pull,pF, drv,dF, edge,eF ,afn,aF
  */
 /* UART2 */
-#define MFP47_UART2_RXD		MFP_REG(0x198) | MFP_AF6 | MFP_DRIVE_MEDIUM
-#define MFP48_UART2_TXD		MFP_REG(0x19c) | MFP_AF6 | MFP_DRIVE_MEDIUM
+#define MFP47_UART2_RXD		(MFP_REG(0x198) | MFP_AF6 | MFP_DRIVE_MEDIUM)
+#define MFP48_UART2_TXD		(MFP_REG(0x19c) | MFP_AF6 | MFP_DRIVE_MEDIUM)
+#define MFP53_CI2C_SCL		(MFP_REG(0x1b0) | MFP_AF2 | MFP_DRIVE_MEDIUM)
+#define MFP54_CI2C_SDA		(MFP_REG(0x1b4) | MFP_AF2 | MFP_DRIVE_MEDIUM)
 
 /* More macros can be defined here... */
 
diff --git a/board/Marvell/dkb/dkb.c b/board/Marvell/dkb/dkb.c
index 72a2d2a..00f73e7 100644
--- a/board/Marvell/dkb/dkb.c
+++ b/board/Marvell/dkb/dkb.c
@@ -36,6 +36,10 @@  int board_early_init_f(void)
 		MFP47_UART2_RXD,
 		MFP48_UART2_TXD,
 
+		/* I2C */
+		MFP53_CI2C_SCL,
+		MFP54_CI2C_SDA,
+
 		MFP_EOC		/*End of configureation*/
 	};
 	/* configure MFP's */
diff --git a/include/configs/dkb.h b/include/configs/dkb.h
index 638af5e..599c8b8 100644
--- a/include/configs/dkb.h
+++ b/include/configs/dkb.h
@@ -56,6 +56,19 @@ 
 #include "mv-common.h"
 
 #undef CONFIG_ARCH_MISC_INIT
+
+/*
+ * I2C definition
+ */
+#define CONFIG_CMD_I2C
+#ifdef CONFIG_CMD_I2C
+#define CONFIG_I2C_MV			1
+#define CONFIG_PXA_I2C_REG		0xd4011000
+#define CONFIG_HARD_I2C			1
+#define CONFIG_SYS_I2C_SPEED		0
+#define CONFIG_SYS_I2C_SLAVE		0xfe
+#endif
+
 /*
  * Environment variables configurations
  */