[U-Boot-Users] [PATCH] I2C register access functions for omap1510_i2c driver

Ben Warren biggerbadderben at gmail.com
Sat Feb 9 01:17:30 CET 2008


On Feb 8, 2008 6:25 PM, Ladislav Michl <ladis at linux-mips.org> wrote:
> drivers/i2c/omap1510_i2c.c does not implement i2c_reg_read and
> i2c_reg_write which leads to unresolved symbols when using ds1307
> driver. While there, enable CONFIG_CMD_DATE for Voiceblue board to have
> nice test case :-)
>
> Signed-off-by: Ladislav Michl <ladis at linux-mips.org>
>
> diff --git a/drivers/i2c/omap1510_i2c.c b/drivers/i2c/omap1510_i2c.c
> index 04400fb..f0fc15e 100644
> --- a/drivers/i2c/omap1510_i2c.c
> +++ b/drivers/i2c/omap1510_i2c.c
> @@ -240,6 +240,19 @@ int i2c_write (uchar chip, uint addr, int alen, uchar * buffer, int len)
>         return 0;
>  }
>
> +uchar i2c_reg_read (uchar chip, uchar reg)
> +{
> +       uchar val;
> +
> +       i2c_read_byte(chip, reg, &val);
> +       return val;
> +}
> +
> +void i2c_reg_write(uchar chip, uchar reg, uchar val)
> +{
> +       i2c_write_byte(chip, reg, val);
> +}
> +

While your fix is technically correct, I looked into this last week
and found that this exact code is duplicated in EVERY I2C controller,
except one (MPC8xx), where there are calls to i2c_init() in each of
the functions.  I posted a request for information about why the
i2c_init() call is necessary in MPC8xx and nobody has responded yet.
Maybe somebody has an MPC8xx-based board and could experiment a bit to
make it the same???

I'd prefer to see these functions as static inlines in i2c.h in order
to cut down on duplication.

Just my $0.02

regards,
Ben




More information about the U-Boot mailing list