[U-Boot] [PATCH] sh: i2c: Add support I2C controller of SH7734

Heiko Schocher hs at denx.de
Mon Feb 6 07:52:00 CET 2012


Hello Nobuhiro,

Nobuhiro Iwamatsu wrote:
> Renesas SH7734 has two I2C interfaceis.
> This supports these I2C.
> 
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj at renesas.com>
> ---
>  drivers/i2c/Makefile        |    1 +
>  drivers/i2c/sh_sh7734_i2c.c |  468 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 469 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/i2c/sh_sh7734_i2c.c

[...]
> diff --git a/drivers/i2c/sh_sh7734_i2c.c b/drivers/i2c/sh_sh7734_i2c.c
> new file mode 100644
> index 0000000..6c514b4
> --- /dev/null
> +++ b/drivers/i2c/sh_sh7734_i2c.c
> @@ -0,0 +1,468 @@

[...]
> +static void sh_i2c_send_stop(struct sh_i2c *base)
> +{
> +	writeb(readb(&base->iccr2) & ~(SH_I2C_ICCR2_BBSY | SH_I2C_ICCR2_SCP),
> +		&base->iccr2);

Please use clrbits_*

[...]
> +static int check_tend(struct sh_i2c *base, int stop)
> +{
> +	int i, ret = 1;
> +
> +	for (i = 0 ; i < IRQ_WAIT ; i++) {
> +		if (SH_I2C_ICSR_TEND & readb(&base->icsr)) {
> +			ret = 0;
> +			break;
> +		}
> +		udelay(10);
> +	}
> +
> +	if (stop) {
> +		u8 data;
> +
> +		writeb(readb(&base->icsr) & ~SH_I2C_ICSR_STOP, &base->icsr);
> +
> +		sh_i2c_send_stop(base);
> +	}
> +
> +	writeb(readb(&base->icsr) & ~SH_I2C_ICSR_TEND, &base->icsr);

here too... please check globally.

[...]
> +#ifdef CONFIG_I2C_MULTI_BUS
> +static unsigned int current_bus;
> +
> +/**

wrong comment style.

[...]
> +/**

here too.

> + * i2c_get_bus_num - returns index of active I2C bus
> + */
> +unsigned int i2c_get_bus_num(void)
[...]
> +int i2c_read(u8 chip, u32 addr, int alen, u8 *buffer, int len)
> +{
> +	int i = 0;

new line please.

> +	for (i = 0 ; i < len ; i++)
> +		buffer[i] = i2c_raw_read(base, chip, addr + i);
[...]

Beside of this minor comments patch looks good, thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


More information about the U-Boot mailing list