]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
compulab: eeprom: add support for defining eeprom i2c bus
authorNikita Kiryanov <nikita@compulab.co.il>
Wed, 20 Aug 2014 12:08:52 +0000 (15:08 +0300)
committerStefano Babic <sbabic@denx.de>
Tue, 9 Sep 2014 13:32:32 +0000 (15:32 +0200)
Create CONFIG_SYS_I2C_EEPROM_BUS #define to tell the EEPROM
module what I2C bus the EEPROM is located at. Make cl_eeprom_read()
switch to that bus when reading EEPROM.

Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Dmitry Lifshitz <lifshitz@compulab.co.il>
Cc: Tom Rini <trini@ti.com>
Cc: Marek Vasut <marex@denx.de>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
Acked-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
board/compulab/common/eeprom.c
include/configs/cm_t335.h
include/configs/cm_t35.h
include/configs/cm_t54.h

index 20fe3e19602dc427d0e550208e80815bd18d86b0..85442cd10314ae3be4bc10e0a33caf35106f32d5 100644 (file)
@@ -31,8 +31,19 @@ static int cl_eeprom_layout; /* Implicitly LAYOUT_INVALID */
 
 static int cl_eeprom_read(uint offset, uchar *buf, int len)
 {
-       return i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, offset,
+       int res;
+       unsigned int current_i2c_bus = i2c_get_bus_num();
+
+       res = i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
+       if (res < 0)
+               return res;
+
+       res = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, offset,
                        CONFIG_SYS_I2C_EEPROM_ADDR_LEN, buf, len);
+
+       i2c_set_bus_num(current_i2c_bus);
+
+       return res;
 }
 
 static int cl_eeprom_setup_layout(void)
index a3e6452ec1d5142d26c13b2f6f6351e9cdf31b95..767ef3a266be96d372ee4cf8bc14d10d25ca8fab 100644 (file)
 /* I2C Configuration */
 #define CONFIG_SYS_I2C_EEPROM_ADDR     0x50    /* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
+#define CONFIG_SYS_I2C_EEPROM_BUS      0
 
 /* SPL */
 #define CONFIG_SPL_LDSCRIPT            "$(CPUDIR)/am33xx/u-boot-spl.lds"
index 70df1ebc67752ed0dc5c342ce612188387cab934..6f4d97f2fd06094bf10e1e1939c3749e7a06c296 100644 (file)
 #define CONFIG_SYS_I2C_OMAP34XX
 #define CONFIG_SYS_I2C_EEPROM_ADDR     0x50
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
+#define CONFIG_SYS_I2C_EEPROM_BUS      0
 #define CONFIG_I2C_MULTI_BUS
 
 /*
index df93a59c1bde2ca3d25cde363976eb06acff46a4..641ab48c2c81d5fd7203905d18c6efec619d05d5 100644 (file)
@@ -30,6 +30,7 @@
 #define CONFIG_SYS_I2C_OMAP34XX
 #define CONFIG_SYS_I2C_EEPROM_ADDR     0x50
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
+#define CONFIG_SYS_I2C_EEPROM_BUS      0
 
 /* Enable SD/MMC CD and WP GPIOs */
 #define OMAP_HSMMC_USE_GPIO