From mboxrd@z Thu Jan 1 00:00:00 1970 From: Piotr Wilczek Date: Mon, 22 Oct 2012 09:21:21 +0200 Subject: [U-Boot] [PATCH v2 7/9] driver:i2c: Modify s3c24x0_i2c driver for Multi-I2C In-Reply-To: <1350890483-26579-1-git-send-email-p.wilczek@samsung.com> References: <1350890483-26579-1-git-send-email-p.wilczek@samsung.com> Message-ID: <1350890483-26579-8-git-send-email-p.wilczek@samsung.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 Signed-off-by: Piotr Wilczek Signed-off-by: Kyungmin Park CC: Minkyu Kang --- 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