ARM: uniphier: add EHCI nodes for PH1-LD11
[oweals/u-boot.git] / drivers / i2c / omap24xx_i2c.c
index 0f1e35c460ca375aa517dcb4a9d098927ef91d37..a7f3fb4a7996d5f6188494ca7f09b23662673d18 100644 (file)
@@ -33,7 +33,7 @@
  *   (except for OMAP243X and OMAP34XX).
  * - Driver now supports up to I2C5 (OMAP5).
  *
- * Copyright (c) 2014 Hannes Petermaier <oe5hpm@oevsv.at>, B&R
+ * Copyright (c) 2014 Hannes Schmelzer <oe5hpm@oevsv.at>, B&R
  * - Added support for set_speed
  *
  */
@@ -371,6 +371,23 @@ static int omap24_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
                return 1;
        }
 
+#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.
+        */
+       if (alen > 0)
+               chip |= ((addr >> (alen * 8)) &
+                        CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
+#endif
+
        /* Wait until bus not busy */
        if (wait_for_bb(adap))
                return 1;
@@ -501,6 +518,23 @@ static int omap24_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
                return 1;
        }
 
+#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.
+        */
+       if (alen > 0)
+               chip |= ((addr >> (alen * 8)) &
+                        CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
+#endif
+
        /* Wait until bus not busy */
        if (wait_for_bb(adap))
                return 1;