From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hans de Goede Date: Sat, 03 May 2014 17:46:10 +0200 Subject: [U-Boot] [PATCH u-boot sunxi 07/12] sunxi: Add i2c support In-Reply-To: <5327FBC1.70206@denx.de> References: <1395097256-7593-1-git-send-email-hdegoede@redhat.com> <1395097256-7593-8-git-send-email-hdegoede@redhat.com> <5327FBC1.70206@denx.de> Message-ID: <53650F42.904@redhat.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 >> >> 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 >> >> Signed-off-by: Henrik Nordstrom >> Signed-off-by: Oliver Schinagl >> Signed-off-by: Hans de Goede >> --- >> 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 >> + * >> + * SPDX-License-Identifier: GPL-2.0+ >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +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