Skip to contentSkip to conversation

soft_i2c: add multibus support

PATCH New Heiko Schocher 1 participant 1 message Feb 13, 2009 I2C

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soft_i2c: add multibus support

---
 drivers/i2c/i2c_core.c   |    3 +
 drivers/i2c/soft_i2c.c   |  129 ++++++++++++++++++++++++++++------------------
 include/configs/mgsuvd.h |    3 +
 include/i2c.h            |    8 +++-
 4 files changed, 91 insertions(+), 52 deletions(-)
drivers/i2c/i2c_core.c +3 -0
index 4466908..e0afd10 100644
@@ -39,6 +39,7 @@ extern i2c_adap_t	tsi108_i2c_adap;
 #endif
 
 i2c_adap_t	*i2c_adap[CONFIG_SYS_NUM_I2C_ADAPTERS] = CONFIG_SYS_I2C_ADAPTERS;
+i2c_adap_t	*cur_adap_nr = NULL;
 #ifndef CONFIG_SYS_I2C_DIRECT_BUS
 i2c_bus_t	i2c_bus[CONFIG_SYS_NUM_I2C_BUSSES] = CONFIG_SYS_I2C_BUSSES;
 #endif
@@ -208,6 +209,7 @@ int i2c_set_bus_num(unsigned int bus)
 #endif
 
 	i2c_cur_bus = bus;
+	cur_adap_nr = (i2c_adap_t *)&ADAP(bus);
 	return(0);
 }
 
@@ -243,6 +245,7 @@ void i2c_init_all(void)
 {
 	int	i;
 
+	cur_adap_nr = (i2c_adap_t *)&ADAP(0);
 	for (i = 0; i < CONFIG_SYS_NUM_I2C_ADAPTERS; i++) {
 		if ((i2c_adap[i]->speed != 0) && (i2c_adap[i]->init != NULL)) {
 			i2c_adap[i]->init(i2c_adap[i]->speed, i2c_adap[i]->slaveaddr);
drivers/i2c/soft_i2c.c +78 -51

168 lines not on this page · raw message

include/configs/mgsuvd.h +3 -0
index 3ea0725..b1debbc 100644
@@ -270,6 +270,7 @@
 #define CONFIG_SYS_NUM_I2C_BUSSES	3
 #define CONFIG_SYS_I2C_MAX_HOPS		1
 #define CONFIG_SOFT_I2C			/* I2C bit-banged */
+#define I2C_SOFT_DEFS
 #define I2C_SOFT_DECLARATIONS		I2C_SOFT_DEFS
 #define CONFIG_SYS_SOFT_I2C_SPEED	50000
 #define CONFIG_SYS_SOFT_I2C_SLAVE	0x7F
@@ -277,6 +278,8 @@
 #define CONFIG_SYS_I2C_BUSSES	{	{0, {I2C_NULL_HOP}}, \
 			{0, {{I2C_MUX_PCA9542, 0x70, 0}}}, \
 			{0, {{I2C_MUX_PCA9542, 0x70, 1}}}}
+
+#define CONFIG_I2C_CMD_TREE		1
 /*
  * Software (bit-bang) I2C driver configuration
  */
include/i2c.h +7 -1
index ea2c3b2..a3cc3ca 100644
@@ -95,7 +95,8 @@ typedef struct i2c_adapter {
 	int		speed;
 	int		slaveaddr;
 	int		init_done;
-	char		*name;	
+	int		hwadapnr;
+	char		*name;
 } i2c_adap_t;
 
 #ifndef CONFIG_SYS_I2C_DIRECT_BUS
@@ -130,6 +131,7 @@ extern i2c_bus_t	i2c_bus[];
 #endif
 
 extern i2c_adap_t	*i2c_adap[];
+extern i2c_adap_t	*cur_adap_nr;
 
 /*
  * i2c_get_bus_num:
@@ -226,7 +228,11 @@ void i2c_reloc_fixup(void);
 # else
 #  define I2C_SOFT_DEFS
 # endif
+#endif
 
+#ifndef CONFIG_SYS_I2C_SLAVE
+#define CONFIG_SYS_I2C_SLAVE	0x7f
+#endif
 /*
  * Initialization, must be called once on start up, may be called
  * repeatedly to change the speed and slave addresses.
Signature · 5 lines
1.6.0.6

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany