[U-Boot] [PATCH v2 7/9] driver:i2c: Modify s3c24x0_i2c driver for Multi-I2C

Piotr Wilczek p.wilczek at samsung.com
Mon Oct 22 09:21:21 CEST 2012


This patch modifies s3c24x0_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/s3c24x0_i2c.c |   70 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
index 90d297a..d9e01f4 100644
--- a/drivers/i2c/s3c24x0_i2c.c
+++ b/drivers/i2c/s3c24x0_i2c.c
@@ -168,7 +168,7 @@ static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
  */
 
 #ifdef CONFIG_I2C_MULTI_BUS
-int i2c_set_bus_num(unsigned int bus)
+static int s3c24x0_i2c_set_bus_num(unsigned int bus)
 {
 	struct s3c24x0_i2c *i2c;
 
@@ -184,13 +184,13 @@ int i2c_set_bus_num(unsigned int bus)
 	return 0;
 }
 
-unsigned int i2c_get_bus_num(void)
+static unsigned int s3c24x0_i2c_get_bus_num(void)
 {
 	return g_current_bus;
 }
 #endif
 
-void i2c_init(int speed, int slaveadd)
+static void s3c24x0_i2c_init(int speed, int slaveadd)
 {
 	struct s3c24x0_i2c *i2c;
 #if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
@@ -415,7 +415,7 @@ static int i2c_transfer(struct s3c24x0_i2c *i2c,
 	return result;
 }
 
-int i2c_probe(uchar chip)
+static int s3c24x0_i2c_probe(uchar chip)
 {
 	struct s3c24x0_i2c *i2c;
 	uchar buf[1];
@@ -431,7 +431,8 @@ int i2c_probe(uchar chip)
 	return i2c_transfer(i2c, I2C_READ, chip << 1, 0, 0, buf, 1) != I2C_OK;
 }
 
-int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
+static int
+s3c24x0_i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
 	struct s3c24x0_i2c *i2c;
 	uchar xaddr[4];
@@ -475,7 +476,8 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 	return 0;
 }
 
-int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
+static int
+s3c24x0_i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
 	struct s3c24x0_i2c *i2c;
 	uchar xaddr[4];
@@ -512,4 +514,60 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 		(i2c, I2C_WRITE, chip << 1, &xaddr[4 - alen], alen, buffer,
 		 len) != 0);
 }
+
+void s3c24x0_i2c_reset(void)
+{
+	struct s3c24x0_i2c *i2c;
+
+	i2c = get_base_i2c();
+
+	/* init to STATUS register */
+	writel(0, &i2c->iicstat);
+}
 #endif /* CONFIG_HARD_I2C */
+
+#if defined(CONFIG_MULTI_I2C)
+struct i2c_ops s3c24x0_i2c_ops = {
+	.init        = s3c24x0_i2c_init,
+	.probe       = s3c24x0_i2c_probe,
+	.read        = s3c24x0_i2c_read,
+	.write       = s3c24x0_i2c_write,
+	.get_bus_num = s3c24x0_i2c_get_bus_num,
+	.set_bus_num = s3c24x0_i2c_set_bus_num,
+	.reset       = s3c24x0_i2c_reset,
+};
+#else
+void i2c_init(int speed, int slaveaddr)
+{
+	return s3c24x0_i2c_init(speed, slaveaddr);
+}
+
+int i2c_probe(uchar chip)
+{
+	return s3c24x0_i2c_probe(chip);
+}
+
+int i2c_read(uchar chip, uint addr, int alen,
+	uchar *buffer, int len)
+{
+	return s3c24x0_i2c_read(chip, addr, alen, buffer, len);
+}
+
+int i2c_write(uchar chip, uint addr, int alen,
+	uchar *buffer, int len)
+{
+	return s3c24x0_i2c_write(chip, addr, alen, buffer, len);
+}
+
+#ifdef CONFIG_I2C_MULTI_BUS
+unsigned int i2c_get_bus_num(void)
+{
+	return s3c24x0_i2c_get_bus_num();
+}
+
+int i2c_set_bus_num(unsigned int bus)
+{
+	return s3c24x0_i2c_set_bus_num(bus);
+}
+#endif /* CONFIG_I2C_MULTI_BUS */
+#endif
-- 
1.7.5.4



More information about the U-Boot mailing list