[U-Boot] [PATCH u-boot sunxi 07/12] sunxi: Add i2c support

Hans de Goede hdegoede at redhat.com
Sat May 3 17:46:10 CEST 2014


Hi,

On 03/18/2014 08:54 AM, Heiko Schocher wrote:
> Hello Hans,
> 
> Am 18.03.2014 00:00, schrieb Hans de Goede:
>> From: Henrik Nordstrom<henrik at henriknordstrom.net>
>>
>> Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in
>> ldscripts" vs v2014.01.
>>
>> As well as the following signed-off-by the sunxi branch shows commits to
>> the sunxi_i2c.c file by:
>>
>> Stefan Roese<sr at denx.de>
>>
>> Signed-off-by: Henrik Nordstrom<henrik at henriknordstrom.net>
>> Signed-off-by: Oliver Schinagl<oliver at schinagl.nl>
>> Signed-off-by: Hans de Goede<hdegoede at redhat.com>
>> ---
>>   arch/arm/cpu/armv7/sunxi/board.c      |   6 +
>>   arch/arm/include/asm/arch-sunxi/i2c.h | 169 ++++++++++++++++++++++
>>   drivers/i2c/Makefile                  |   1 +
>>   drivers/i2c/sunxi_i2c.c               | 260 ++++++++++++++++++++++++++++++++++
>>   include/configs/sunxi-common.h        |   8 ++
>>   5 files changed, 444 insertions(+)
>>   create mode 100644 arch/arm/include/asm/arch-sunxi/i2c.h
>>   create mode 100644 drivers/i2c/sunxi_i2c.c
>>
> [...]
>> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
>> index fa3a875..2a44db4 100644
>> --- a/drivers/i2c/Makefile
>> +++ b/drivers/i2c/Makefile
>> @@ -15,6 +15,7 @@ obj-$(CONFIG_PCA9564_I2C) += pca9564_i2c.o
>>   obj-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
>>   obj-$(CONFIG_U8500_I2C) += u8500_i2c.o
>>   obj-$(CONFIG_SH_SH7734_I2C) += sh_sh7734_i2c.o
>> +obj-$(CONFIG_SUNXI_I2C) += sunxi_i2c.o
> 
> please use:
> 
> CONFIG_SYS_I2C_SUNXI

Ok.

> 
>>   obj-$(CONFIG_SYS_I2C) += i2c_core.o
>>   obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
>>   obj-$(CONFIG_SYS_I2C_FTI2C010) += fti2c010.o
>> diff --git a/drivers/i2c/sunxi_i2c.c b/drivers/i2c/sunxi_i2c.c
>> new file mode 100644
>> index 0000000..9a542f6
>> --- /dev/null
>> +++ b/drivers/i2c/sunxi_i2c.c
>> @@ -0,0 +1,260 @@
>> +/*
>> + * (C) Copyright 2012 Henrik Nordstrom<henrik at henriknordstrom.net>
>> + *
>> + * SPDX-License-Identifier:    GPL-2.0+
>> + */
>> +
>> +#include<common.h>
>> +#include<i2c.h>
>> +#include<asm/io.h>
>> +#include<asm/arch/clock.h>
>> +#include<asm/arch/cpu.h>
>> +#include<asm/arch/gpio.h>
>> +#include<asm/arch/i2c.h>
>> +
>> +static struct i2c __attribute__ ((section(".data"))) *i2c_base =
>> +    (struct i2c *)0x1c2ac00;
> 
> Please no magic numbers, use a define instead.
> 
>> +void i2c_init(int speed, int slaveaddr)
> [...]
>> +int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
>> +{
>> +    int rc = i2c_do_write(chip, addr, alen, buffer, len);
>> +
>> +    i2c_stop();
>> +
>> +    return rc;
>> +}
> 
> Please update to the new i2c multibus/multiadpater framework
> 
> Dummy question, there is another "twi" driver in drivers/i2c
> 
> bfin-twi_i2c.c
> 
> are they compatible?

No, but that is a good point, in the kernel we ended up using the
i2c-mv64xxx driver as that is the same controller. I should have thought
of doing the same for u-boot instead of just taking Allwinner's driver.

I've just completed writing a patch-set which uses the mvtwsi driver
instead of introducing a new driver. While working on this I found 2 issues
in the driver, for which I'll be sending patches shortly.

Regards,

Hans


More information about the U-Boot mailing list