mgsuvd: fix compiler warning when using soft_i2c driver
PATCH v2 1/1 mgsuvd: fix compiler warning when using soft_i2c driver
---
This Patch replaces the Patch:
http://lists.denx.de/pipermail/u-boot/2008-October/041890.html
[U-Boot] [POWERPC] mgsuvd: fix compiler warning when using soft_i2c driver
board/keymile/common/common.c | 3 ++- board/keymile/mgsuvd/mgsuvd.c | 12 +----------- drivers/i2c/soft_i2c.c | 4 ++++ include/configs/mgsuvd.h | 26 +++++++++++++++++--------- 4 files changed, 24 insertions(+), 21 deletions(-)
board/keymile/common/common.c +2 -1
@@ -34,6 +34,7 @@#if defined(CONFIG_HARD_I2C ) || defined(CONFIG_SOFT_I2C )#include <i2c.h> #endif +#include <asm/io.h> extern int i2c_soft_read_pin (void );
@@ -400,7 +401,7 @@ static void set_scl (int state)static int get_sda (void ) { -return i2c_soft_read_pin (); +return I2C_READ ; }static int get_scl (void )
board/keymile/mgsuvd/mgsuvd.c +1 -11
@@ -22,6 +22,7 @@*/ #include <common.h> #include <mpc8xx.h> +#include <asm/io.h> #if defined(CONFIG_OF_BOARD_SETUP ) && defined(CONFIG_OF_LIBFDT )#include <libfdt.h>
@@ -226,14 +227,3 @@ void ft_board_setup(void *blob, bd_t *bd) ft_blob_update (blob, bd); }#endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */ - -int i2c_soft_read_pin (void ) -{ -int val; - - *(unsigned short *)(I2C_BASE_DIR ) &= ~SDA_CONF ; -udelay (1 ); - val = *(unsigned char *)(I2C_BASE_PORT ); - -return ((val &SDA_BIT ) ==SDA_BIT ); -}
drivers/i2c/soft_i2c.c +4 -0
@@ -28,6 +28,7 @@#include <common.h> #ifdef CONFIG_MPC8260 /* only valid for MPC8260 */ #include <ioports.h> +#include <asm/io.h> #endif #ifdef CONFIG_AT91RM9200 /* need this for the at91rm9200 */ #include <asm/io.h>
@@ -39,6 +40,9 @@#ifdef CONFIG_LPC2292 #include <asm/arch/hardware.h> #endif +#ifdef CONFIG_MPC866 /* only valid for MPC866 */ +#include <asm/io.h> +#endif #include <i2c.h> /* #define DEBUG_I2C */
include/configs/mgsuvd.h +17 -9
@@ -346,8 +346,10 @@/* * Software (bit-bang) I2C driver configuration */ -#define I2C_BASE_DIR (CONFIG_SYS_PIGGY_BASE + 0x04) -#define I2C_BASE_PORT (CONFIG_SYS_PIGGY_BASE + 0x09) +#define I2C_BASE_DIR (volatile unsigned short __iomem *) \ + (CONFIG_SYS_PIGGY_BASE + 0x04) +#define I2C_BASE_PORT (volatile unsigned char __iomem *) \ + (CONFIG_SYS_PIGGY_BASE + 0x09)#define SDA_BIT 0x40#define SCL_BIT 0x80
@@ -356,20 +358,26 @@#define I2C_ACTIVE do {} while (0)#define I2C_TRISTATE do {} while (0) -#define I2C_READ i2c_soft_read_pin () +#define I2C_READ ((in_8(I2C_BASE_PORT) & SDA_BIT) == SDA_BIT)#define I2C_SDA (bit) if(bit) { \ - *(unsigned short *)(I2C_BASE_DIR) &= ~SDA_CONF; \ + out_be16(I2C_BASE_DIR, \ + in_be16(I2C_BASE_DIR) & ~SDA_CONF); \ } \ else { \ - *(unsigned char *)(I2C_BASE_PORT) &= ~SDA_BIT; \ - *(unsigned short *)(I2C_BASE_DIR) |= SDA_CONF; \ + out_8(I2C_BASE_PORT, \ + in_8(I2C_BASE_PORT) & ~SDA_BIT); \ + out_be16(I2C_BASE_DIR, \ + in_be16(I2C_BASE_DIR) | SDA_CONF); \ }#define I2C_SCL (bit) if(bit) { \ - *(unsigned short *)(I2C_BASE_DIR) &= ~SCL_CONF; \ + out_be16(I2C_BASE_DIR, \ + in_be16(I2C_BASE_DIR) & ~SCL_CONF); \ } \ else { \ - *(unsigned char *)(I2C_BASE_PORT) &= ~SCL_BIT; \ - *(unsigned short *)(I2C_BASE_DIR) |= SCL_CONF; \ + out_8(I2C_BASE_PORT, \ + in_8(I2C_BASE_PORT) & ~SCL_BIT); \ + out_be16(I2C_BASE_DIR, \ + in_be16(I2C_BASE_DIR) | SCL_CONF); \ }#define I2C_DELAY udelay(50)/* 1/4 I2C clock duration */
Signature · 5 lines
1.5.6.1 -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v2 1/1 mgsuvd: fix compiler warning when using soft_i2c driver
Dear Heiko Schocher,
Quoted 12 lines · In message <[email protected]> you wrote:
Signed-off-by Heiko Schocher <[email protected]>---
This Patch replaces the Patch:http://lists.denx.de/pipermail/u-boot/2008-October/041890.html
[U-Boot] [POWERPC] mgsuvd: fix compiler warning when usingsoft_i2cdriverboard/keymile/common/common.c | 3 ++- board/keymile/mgsuvd/mgsuvd.c | 12 +----------- drivers/i2c/soft_i2c.c | 4 ++++ include/configs/mgsuvd.h | 26 +++++++++++++++++--------- 4 files changed, 24 insertions(+), 21 deletions(-)
...
board/keymile/common/common.c static void set_scl (int state) · line 404
Quoted 6 lines
board/keymile/common/common.c +1
-1@@ -400,7 +401,7 @@ static void set_scl (int state)static int get_sda (void ) { -return i2c_soft_read_pin (); +return I2C_READ ;
Only single space needed here.
include/configs/mgsuvd.h line 352
Quoted 13 lines
index 7a80dad..32b636f 100644
include/configs/mgsuvd.h +4
-2@@ -346,8 +346,10 @@/* * Software (bit-bang) I2C driver configuration */ -#define I2C_BASE_DIR (CONFIG_SYS_PIGGY_BASE + 0x04) -#define I2C_BASE_PORT (CONFIG_SYS_PIGGY_BASE + 0x09) +#define I2C_BASE_DIR (volatile unsigned short __iomem *) \ + (CONFIG_SYS_PIGGY_BASE + 0x04) +#define I2C_BASE_PORT (volatile unsigned char __iomem *) \ + (CONFIG_SYS_PIGGY_BASE + 0x09)
Why do you add the funny casts here? These ar enot needed when using the accessor functions.
Also, if you need them, you must place a pair of "(...)" around the whole expression.
include/configs/mgsuvd.h line 361
Quoted 2 lines
include/configs/mgsuvd.h +1
-1-#define I2C_READ i2c_soft_read_pin () +#define I2C_READ ((in_8(I2C_BASE_PORT) & SDA_BIT) == SDA_BIT)
For this, no such cast as above is needed.
include/configs/mgsuvd.h line 364
Quoted 4 lines
include/configs/mgsuvd.h +2
-1#define I2C_SDA (bit) if(bit) { \ - *(unsigned short *)(I2C_BASE_DIR) &= ~SDA_CONF; \ + out_be16(I2C_BASE_DIR, \ + in_be16(I2C_BASE_DIR) & ~SDA_CONF); \
Ditto.
include/configs/mgsuvd.h
Quoted 2 lines
include/configs/mgsuvd.h +0
-0} \else { \
Make this
} else {please.
include/configs/mgsuvd.h
Quoted 2 lines
include/configs/mgsuvd.h +0
-0} \else { \
Ditto.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Don't hit a man when he's down - kick him; it's easier.