[U-Boot] [PATCH 09/13 v5] ARM: OMAP3: Add I2C support

Subject: [PATCH 09/13 v5] ARM: OMAP3: Add I2C support
From: Dirk Behme dirk.behme@gmail.com
Add I2C support
Signed-off-by: Dirk Behme dirk.behme@gmail.com
--- Changes in version v5:
- Split functional changes and coding style clean up as proposed by Jean-Christophe PLAGNIOL-VILLARD.
Changes in version v2:
- Remove SMC911X network init as proposed by Ben Warren. Thanks!
drivers/i2c/Makefile | 1 + drivers/i2c/omap24xx_i2c.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)
Index: u-boot-main/drivers/i2c/Makefile =================================================================== --- u-boot-main.orig/drivers/i2c/Makefile +++ u-boot-main/drivers/i2c/Makefile @@ -29,6 +29,7 @@ COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o +COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
Index: u-boot-main/drivers/i2c/omap24xx_i2c.c =================================================================== --- u-boot-main.orig/drivers/i2c/omap24xx_i2c.c +++ u-boot-main/drivers/i2c/omap24xx_i2c.c @@ -25,6 +25,8 @@ #include <asm/arch/i2c.h> #include <asm/io.h>
+#define inb(a) __raw_readb(a) +#define outb(a, v) __raw_writeb(a, v) #define inw(a) __raw_readw(a) #define outw(a,v) __raw_writew(a,v)
@@ -112,7 +114,11 @@ static int i2c_read_byte (u8 devaddr, u8
status = wait_for_pin (); if (status & I2C_STAT_RRDY) { +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) + *value = inb(I2C_DATA); +#else *value = inw (I2C_DATA); +#endif udelay (20000); } else { i2c_error = 1; @@ -153,8 +159,22 @@ static int i2c_write_byte (u8 devaddr, u status = wait_for_pin ();
if (status & I2C_STAT_XRDY) { +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) + /* send out 1 byte */ + outb(regoffset, I2C_DATA); + outw(I2C_STAT_XRDY, I2C_STAT); + status = wait_for_pin(); + if ((status & I2C_STAT_XRDY)) { + /* send out next 1 byte */ + outb(value, I2C_DATA); + outw(I2C_STAT_XRDY, I2C_STAT); + } else { + i2c_error = 1; + } +#else /* send out two bytes */ outw ((value << 8) + regoffset, I2C_DATA); +#endif /* must have enough delay to allow BB bit to go low */ udelay (50000); if (inw (I2C_STAT) & I2C_STAT_NACK) { @@ -191,7 +211,11 @@ static void flush_fifo(void) while(1){ stat = inw(I2C_STAT); if(stat == I2C_STAT_RRDY){ +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) + inb(I2C_DATA); +#else inw(I2C_DATA); +#endif outw(I2C_STAT_RRDY,I2C_STAT); udelay(1000); }else

On 19:38 Sun 02 Nov , dirk.behme@googlemail.com wrote:
Subject: [PATCH 09/13 v5] ARM: OMAP3: Add I2C support
From: Dirk Behme dirk.behme@gmail.com
Add I2C support
Signed-off-by: Dirk Behme dirk.behme@gmail.com
Changes in version v5:
- Split functional changes and coding style clean up as proposed by Jean-Christophe PLAGNIOL-VILLARD.
Changes in version v2:
- Remove SMC911X network init as proposed by Ben Warren. Thanks!
drivers/i2c/Makefile | 1 + drivers/i2c/omap24xx_i2c.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)
Index: u-boot-main/drivers/i2c/Makefile
--- u-boot-main.orig/drivers/i2c/Makefile +++ u-boot-main/drivers/i2c/Makefile @@ -29,6 +29,7 @@ COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o +COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
Index: u-boot-main/drivers/i2c/omap24xx_i2c.c
--- u-boot-main.orig/drivers/i2c/omap24xx_i2c.c +++ u-boot-main/drivers/i2c/omap24xx_i2c.c @@ -25,6 +25,8 @@ #include <asm/arch/i2c.h> #include <asm/io.h>
+#define inb(a) __raw_readb(a) +#define outb(a, v) __raw_writeb(a, v) #define inw(a) __raw_readw(a) #define outw(a,v) __raw_writew(a,v)
This 4 macro is supposed to be defined in io.h
@@ -112,7 +114,11 @@ static int i2c_read_byte (u8 devaddr, u8
status = wait_for_pin (); if (status & I2C_STAT_RRDY) {
+#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
*value = inb(I2C_DATA);
please respect the file style, add a space before '(' and so on
+#else *value = inw (I2C_DATA); +#endif udelay (20000);
Best Regards, J.

Jean-Christophe PLAGNIOL-VILLARD wrote:
On 19:38 Sun 02 Nov , dirk.behme@googlemail.com wrote:
Subject: [PATCH 09/13 v5] ARM: OMAP3: Add I2C support
From: Dirk Behme dirk.behme@gmail.com
Add I2C support
Signed-off-by: Dirk Behme dirk.behme@gmail.com
Changes in version v5:
- Split functional changes and coding style clean up as proposed by Jean-Christophe PLAGNIOL-VILLARD.
Changes in version v2:
- Remove SMC911X network init as proposed by Ben Warren. Thanks!
drivers/i2c/Makefile | 1 + drivers/i2c/omap24xx_i2c.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)
Index: u-boot-main/drivers/i2c/Makefile
--- u-boot-main.orig/drivers/i2c/Makefile +++ u-boot-main/drivers/i2c/Makefile @@ -29,6 +29,7 @@ COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o +COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
Index: u-boot-main/drivers/i2c/omap24xx_i2c.c
--- u-boot-main.orig/drivers/i2c/omap24xx_i2c.c +++ u-boot-main/drivers/i2c/omap24xx_i2c.c @@ -25,6 +25,8 @@ #include <asm/arch/i2c.h> #include <asm/io.h>
+#define inb(a) __raw_readb(a) +#define outb(a, v) __raw_writeb(a, v) #define inw(a) __raw_readw(a) #define outw(a,v) __raw_writew(a,v)
This 4 macro is supposed to be defined in io.h
Even if I have to touch a global/common file for this?
@@ -112,7 +114,11 @@ static int i2c_read_byte (u8 devaddr, u8
status = wait_for_pin (); if (status & I2C_STAT_RRDY) {
+#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
*value = inb(I2C_DATA);
please respect the file style, add a space before '(' and so on
You prefer file style over global coding style? As I understand it "inb(" is global coding style, and I tried to be in sync with global coding style at least with code I add.
+#else *value = inw (I2C_DATA); +#endif udelay (20000);
Best Regards, J.

Dear Dirk Behme,
In message 490F5EBF.9080102@googlemail.com you wrote:
+#define inb(a) __raw_readb(a) +#define outb(a, v) __raw_writeb(a, v) #define inw(a) __raw_readw(a) #define outw(a,v) __raw_writew(a,v)
This 4 macro is supposed to be defined in io.h
Even if I have to touch a global/common file for this?
If they are missing in io.h, this should be fixed, indeed.
status = wait_for_pin (); if (status & I2C_STAT_RRDY) {
+#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
*value = inb(I2C_DATA);
please respect the file style, add a space before '(' and so on
You prefer file style over global coding style? As I understand it "inb(" is global coding style, and I tried to be in sync with global coding style at least with code I add.
It is more important to use a consistent style in a single source file, indeed.
Best regards,
Wolfgang Denk
participants (4)
-
Dirk Behme
-
dirk.behmeï¼ googlemail.com
-
Jean-Christophe PLAGNIOL-VILLARD
-
Wolfgang Denk