[U-Boot] [PATCH v2 6/9] driver:i2c: Modify Soft I2C driver for Multi-I2C
Piotr Wilczek
p.wilczek at samsung.com
Mon Oct 22 09:21:20 CEST 2012
This patch modifies soft_i2c driver to support multi-I2C.
If CONFIG_MULTI_I2C is not set the original version is used.
Signed-off-by: Gwuieon Jin <ge.jin at samsung.com>
Signed-off-by: Piotr Wilczek <p.wilczek at samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
CC: Minkyu Kang <mk7.kang at samsung.com>
---
Changes in v2:
- new patch
drivers/i2c/soft_i2c.c | 60 +++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index 36c6114..f50758b 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -271,12 +271,12 @@ static int write_byte(uchar data)
/*
* Functions for multiple I2C bus handling
*/
-unsigned int i2c_get_bus_num(void)
+static unsigned int soft_i2c_get_bus_num(void)
{
return i2c_bus_num;
}
-int i2c_set_bus_num(unsigned int bus)
+static int soft_i2c_set_bus_num(unsigned int bus)
{
#if defined(CONFIG_I2C_MUX)
if (bus < CONFIG_SYS_MAX_I2C_BUS) {
@@ -337,7 +337,7 @@ static uchar read_byte(int ack)
/*-----------------------------------------------------------------------
* Initialization
*/
-void i2c_init (int speed, int slaveaddr)
+static void soft_i2c_init(int speed, int slaveaddr)
{
#if defined(CONFIG_SYS_I2C_INIT_BOARD)
/* call board specific i2c bus reset routine before accessing the */
@@ -360,7 +360,7 @@ void i2c_init (int speed, int slaveaddr)
* completion of EEPROM writes since the chip stops responding until
* the write completes (typically 10mSec).
*/
-int i2c_probe(uchar addr)
+static int soft_i2c_probe(uchar addr)
{
int rc;
@@ -378,7 +378,8 @@ int i2c_probe(uchar addr)
/*-----------------------------------------------------------------------
* Read bytes
*/
-int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
+static int
+soft_i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
{
int shift;
PRINTD("i2c_read: chip %02X addr %02X alen %d buffer %p len %d\n",
@@ -452,7 +453,8 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
/*-----------------------------------------------------------------------
* Write bytes
*/
-int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
+static int
+soft_i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
{
int shift, failures = 0;
@@ -482,3 +484,49 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
send_stop();
return(failures);
}
+
+#if defined(CONFIG_MULTI_I2C)
+struct i2c_ops soft_i2c_ops = {
+ .init = soft_i2c_init,
+ .probe = soft_i2c_probe,
+ .read = soft_i2c_read,
+ .read_r = NULL,
+ .write = soft_i2c_write,
+ .get_bus_num = soft_i2c_get_bus_num,
+ .set_bus_num = soft_i2c_set_bus_num,
+};
+#else
+void i2c_init(int speed, int slaveaddr)
+{
+ return soft_i2c_init(speed, slaveaddr);
+}
+
+int i2c_probe(uchar chip)
+{
+ return soft_i2c_probe(chip);
+}
+
+int i2c_read(uchar chip, uint addr, int alen,
+ uchar *buffer, int len)
+{
+ return soft_i2c_read(chip, addr, alen, buffer, len);
+}
+
+int i2c_write(uchar chip, uint addr, int alen,
+ uchar *buffer, int len)
+{
+ return soft_i2c_write(chip, addr, alen, buffer, len);
+}
+
+#ifdef CONFIG_I2C_MULTI_BUS
+unsigned int i2c_get_bus_num(void)
+{
+ return soft_i2c_get_bus_num();
+}
+
+int i2c_set_bus_num(unsigned int bus)
+{
+ return soft_i2c_set_bus_num(bus);
+}
+#endif /* CONFIG_I2C_MULTI_BUS */
+#endif
--
1.7.5.4
More information about the U-Boot
mailing list