From ad5e14ecdd098cb1441b53862cb22e1c4ef05838 Mon Sep 17 00:00:00 2001 From: Hisashi Nakamura Date: Wed, 11 Dec 2013 15:49:27 +0900 Subject: rcar_i2c: Fix receiving wait condition Signed-off-by: Hisashi Nakamura Signed-off-by: Nobuhiro Iwamatsu --- drivers/i2c/rcar_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c index ba2cadb17e..01c98d4e16 100644 --- a/drivers/i2c/rcar_i2c.c +++ b/drivers/i2c/rcar_i2c.c @@ -122,8 +122,8 @@ rcar_i2c_raw_read(struct rcar_i2c *dev, u8 chip, uint addr) /* start master receive */ writel(MCR_MDBS | MCR_MIE | MCR_ESG, &dev->icmcr); - while ((readl(&dev->icmsr) & (MSR_MAT | MSR_MDE)) - != (MSR_MAT | MSR_MDE)) + while ((readl(&dev->icmsr) & (MSR_MAT | MSR_MDR)) + != (MSR_MAT | MSR_MDR)) udelay(10); /* clear ESG */ -- cgit v1.2.3 From da1ed0d20e992296aaafb75e545890bce933d340 Mon Sep 17 00:00:00 2001 From: Nobuhiro Iwamatsu Date: Wed, 11 Dec 2013 15:49:28 +0900 Subject: rcar_i2c: Clear status before start master receive Signed-off-by: Hisashi Nakamura Signed-off-by: Nobuhiro Iwamatsu --- drivers/i2c/rcar_i2c.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c index 01c98d4e16..50cebd622b 100644 --- a/drivers/i2c/rcar_i2c.c +++ b/drivers/i2c/rcar_i2c.c @@ -119,6 +119,8 @@ rcar_i2c_raw_read(struct rcar_i2c *dev, u8 chip, uint addr) /* set slave address, receive */ writel((chip << 1) | 1, &dev->icmar); + /* clear status */ + writel(0, &dev->icmsr); /* start master receive */ writel(MCR_MDBS | MCR_MIE | MCR_ESG, &dev->icmcr); -- cgit v1.2.3 From 7cc1b02f8f73fc0b5e1531a1e16b1c00819d5222 Mon Sep 17 00:00:00 2001 From: Darwin Rambo Date: Fri, 13 Dec 2013 12:57:26 -0800 Subject: i2c: Fix i2c speed command This corrects i2c core to interpret the value returned by i2c_set_bus_speed as a success indicator rather than the actual speed that was set. When i2c_set_bus_speed returns a failure code, the speed is unknown so the adapter speed is set to zero. Signed-off-by: Darwin Rambo Reviewed-by: Tim Kryger Reviewed-by: Steve Rae Acked-by: Jagannadha Sutradharudu Teki --- drivers/i2c/i2c_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c index e1767f4bd4..18d6736601 100644 --- a/drivers/i2c/i2c_core.c +++ b/drivers/i2c/i2c_core.c @@ -349,7 +349,7 @@ unsigned int i2c_set_bus_speed(unsigned int speed) return 0; ret = I2C_ADAP->set_bus_speed(I2C_ADAP, speed); if (gd->flags & GD_FLG_RELOC) - I2C_ADAP->speed = ret; + I2C_ADAP->speed = (ret == 0) ? speed : 0; return ret; } -- cgit v1.2.3 From 32d041e218c6a22e92d91629902fd03a90934b6a Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Mon, 16 Dec 2013 15:30:35 +0400 Subject: drivers/designware_i2c - add suppor of CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW Since we agreed on legacy implementation of "eeprom_{read|write}" (http://patchwork.ozlabs.org/patch/295825/) I had to fix/make it work again DesignWare I2C driver for cases when 1 EEPROM IC fake I2C with anumber of "built-in" ICs with different chip addresses. Signed-off-by: Alexey Brodkin Cc: Tom Rini cc: Armando Visconti Cc: Stefan Roese Cc: Albert ARIBAUD Cc: Heiko Schocher Cc: Vipin KUMAR Cc: Tom Rix Cc: Mischa Jonker Cc: Kuo-Jung Su --- drivers/i2c/designware_i2c.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'drivers') diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index cb2ac04b60..9ed929521a 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -266,6 +266,25 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) { unsigned long start_time_rx; +#ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW + /* + * EEPROM chips that implement "address overflow" are ones + * like Catalyst 24WC04/08/16 which has 9/10/11 bits of + * address and the extra bits end up in the "chip address" + * bit slots. This makes a 24WC08 (1Kbyte) chip look like + * four 256 byte chips. + * + * Note that we consider the length of the address field to + * still be one byte because the extra address bits are + * hidden in the chip address. + */ + chip |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW); + addr &= ~(CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW << (alen * 8)); + + debug("%s: fix addr_overflow: chip %02x addr %02x\n", __func__, chip, + addr); +#endif + if (check_params(addr, alen, buffer, len)) return 1; @@ -307,6 +326,25 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) int nb = len; unsigned long start_time_tx; +#ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW + /* + * EEPROM chips that implement "address overflow" are ones + * like Catalyst 24WC04/08/16 which has 9/10/11 bits of + * address and the extra bits end up in the "chip address" + * bit slots. This makes a 24WC08 (1Kbyte) chip look like + * four 256 byte chips. + * + * Note that we consider the length of the address field to + * still be one byte because the extra address bits are + * hidden in the chip address. + */ + chip |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW); + addr &= ~(CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW << (alen * 8)); + + debug("%s: fix addr_overflow: chip %02x addr %02x\n", __func__, chip, + addr); +#endif + if (check_params(addr, alen, buffer, len)) return 1; -- cgit v1.2.3 From dccacbe01968f9e682cb1dc9b7d43c831897cbec Mon Sep 17 00:00:00 2001 From: Kuo-Jung Su Date: Mon, 30 Dec 2013 17:20:57 +0800 Subject: i2c: fti2c010: fix compiler warning on paddr[] This fixes the following compiler warnings: fti2c010.c: In function 'fti2c010_read': fti2c010.c:204:8: warning: 'paddr' may be used uninitialized in this function [-Wuninitialized] fti2c010.c: In function 'fti2c010_write': fti2c010.c:266:8: warning: 'paddr' may be used uninitialized in this function [-Wuninitialized] Signed-off-by: Kuo-Jung Su Cc: Heiko Schocher --- drivers/i2c/fti2c010.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/i2c/fti2c010.c b/drivers/i2c/fti2c010.c index fb9fa353d1..68d9a42912 100644 --- a/drivers/i2c/fti2c010.c +++ b/drivers/i2c/fti2c010.c @@ -201,7 +201,7 @@ static int fti2c010_read(struct i2c_adapter *adap, struct fti2c010_chip *chip = chip_list + adap->hwadapnr; struct fti2c010_regs *regs = chip->regs; int ret, pos; - uchar paddr[4]; + uchar paddr[4] = { 0 }; to_i2c_addr(paddr, addr, alen); @@ -263,7 +263,7 @@ static int fti2c010_write(struct i2c_adapter *adap, struct fti2c010_chip *chip = chip_list + adap->hwadapnr; struct fti2c010_regs *regs = chip->regs; int ret, pos; - uchar paddr[4]; + uchar paddr[4] = { 0 }; to_i2c_addr(paddr, addr, alen); -- cgit v1.2.3