Hi Troy,
On Mon, 11 Feb 2008 18:59:47 -0700, Troy Kisky wrote:
> From: Vladimir Barinov <[EMAIL PROTECTED]>
>
> ARM: DaVinci: I2C: enable zero-length transfer hack
>
> Signed-off-by: Vladimir Barinov <[EMAIL PROTECTED]>
> Signed-off-by: Kevin Hilman <[EMAIL PROTECTED]>
> ---
> drivers/i2c/busses/i2c-davinci.c | 24 ++++++++++++++++++++++++
> 1 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-davinci.c
> b/drivers/i2c/busses/i2c-davinci.c
> index 6767988..f348ee0 100644
> --- a/drivers/i2c/busses/i2c-davinci.c
> +++ b/drivers/i2c/busses/i2c-davinci.c
> @@ -41,6 +41,11 @@
>
> #include <asm/arch/i2c.h>
>
> +/* Hack to enable zero length transfers and smbus quick until clean fix
> + * is available
> + */
> +#define DAVINCI_HACK
> +
> /* ----- global defines ----------------------------------------------- */
>
> #define DAVINCI_I2C_TIMEOUT (1*HZ)
> @@ -236,9 +241,14 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct
> i2c_msg *msg, int stop)
> u32 stat;
> u16 w;
> int r;
> +#ifdef DAVINCI_HACK
> + u8 zero_byte = 0;
> +#endif
>
> +#ifndef DAVINCI_HACK
> if (msg->len == 0)
> return -EINVAL;
> +#endif
>
> if (!pdata)
> pdata = &davinci_i2c_platform_data_default;
> @@ -249,8 +259,18 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct
> i2c_msg *msg, int stop)
> /* set the slave address */
> davinci_i2c_write_reg(dev, DAVINCI_I2C_SAR_REG, msg->addr);
>
> +#ifndef DAVINCI_HACK
> dev->buf = msg->buf;
> dev->buf_len = msg->len;
> +#else
> + if (msg->len == 0) {
> + dev->buf = &zero_byte;
> + dev->buf_len = 1;
> + } else {
> + dev->buf = msg->buf;
> + dev->buf_len = msg->len;
> + }
> +#endif
>
> davinci_i2c_write_reg(dev, DAVINCI_I2C_CNT_REG, dev->buf_len);
>
> @@ -349,7 +369,11 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct
> i2c_msg msgs[], int num)
>
> static u32 i2c_davinci_func(struct i2c_adapter *adap)
> {
> +#ifndef DAVINCI_HACK
> return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
> +#else
> + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
> +#endif
> }
>
> /*
Nack. If the hardware doesn't support zero-byte transactions, it
doesn't support them, period. The new i2c framework makes it very easy
to live without these transactions anyway.
--
Jean Delvare
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c