diff mbox

[U-Boot,V2,5/9] compulab: eeprom: add support for defining eeprom i2c bus

Message ID 1407416736-14639-6-git-send-email-nikita@compulab.co.il
State Changes Requested
Delegated to: Stefano Babic
Headers show

Commit Message

Nikita Kiryanov Aug. 7, 2014, 1:05 p.m. UTC
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>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
---
Changes in V2:
	- Check return value of i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS)

 board/compulab/common/eeprom.c | 13 ++++++++++++-
 include/configs/cm_t335.h      |  1 +
 include/configs/cm_t35.h       |  1 +
 include/configs/cm_t54.h       |  1 +
 4 files changed, 15 insertions(+), 1 deletion(-)

Comments

Marek Vasut Aug. 7, 2014, 1:53 p.m. UTC | #1
On Thursday, August 07, 2014 at 03:05:32 PM, Nikita Kiryanov wrote:
> 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>
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>

Reviewed-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c
index 20fe3e1..85442cd 100644
--- a/board/compulab/common/eeprom.c
+++ b/board/compulab/common/eeprom.c
@@ -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)
diff --git a/include/configs/cm_t335.h b/include/configs/cm_t335.h
index a3e6452..767ef3a 100644
--- a/include/configs/cm_t335.h
+++ b/include/configs/cm_t335.h
@@ -107,6 +107,7 @@ 
 /* 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"
diff --git a/include/configs/cm_t35.h b/include/configs/cm_t35.h
index d8d71a9..b5702e3 100644
--- a/include/configs/cm_t35.h
+++ b/include/configs/cm_t35.h
@@ -136,6 +136,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
 #define CONFIG_I2C_MULTI_BUS
 
 /*
diff --git a/include/configs/cm_t54.h b/include/configs/cm_t54.h
index db04095..aa97823 100644
--- a/include/configs/cm_t54.h
+++ b/include/configs/cm_t54.h
@@ -27,6 +27,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