All of lore.kernel.org
 help / color / mirror / Atom feed
From: Piotr Wilczek <p.wilczek@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 7/9] driver:i2c: Modify s3c24x0_i2c driver for Multi-I2C
Date: Mon, 22 Oct 2012 09:21:21 +0200	[thread overview]
Message-ID: <1350890483-26579-8-git-send-email-p.wilczek@samsung.com> (raw)
In-Reply-To: <1350890483-26579-1-git-send-email-p.wilczek@samsung.com>

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@samsung.com>
Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Minkyu Kang <mk7.kang@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

  parent reply	other threads:[~2012-10-22  7:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22  7:21 [U-Boot] [PATCH v2 0/9] arm:exynos4: Enable Multi I2C Piotr Wilczek
2012-10-22  7:21 ` [U-Boot] [PATCH v2 1/9] exynos:clock: Add i2c clock Piotr Wilczek
2012-10-22  7:21 ` [U-Boot] [PATCH v2 2/9] exynos:cpu: Add Exynos4 I2C spacing Piotr Wilczek
2012-10-22  7:21 ` [U-Boot] [PATCH v2 3/9] exynos:pinmux: Add pinmux support for i2c Piotr Wilczek
2012-10-22  7:21 ` [U-Boot] [PATCH v2 4/9] drivers:i2c: Modify I2C driver for Exynos4 Piotr Wilczek
2012-10-22  7:21 ` [U-Boot] [PATCH v2 5/9] drivers:i2c: Add support for multi I2C Piotr Wilczek
2012-10-22  7:21 ` [U-Boot] [PATCH v2 6/9] driver:i2c: Modify Soft I2C driver for Multi-I2C Piotr Wilczek
2012-10-22  7:21 ` Piotr Wilczek [this message]
2012-10-22  7:21 ` [U-Boot] [PATCH v2 8/9] drivers:i2c: modify I2C header " Piotr Wilczek
2012-10-22  7:21 ` [U-Boot] [PATCH v2 9/9] arm:trats: Use Multi-I2C on Trarts board Piotr Wilczek
2012-10-22 17:07 ` [U-Boot] [PATCH v2 0/9] arm:exynos4: Enable Multi I2C Heiko Schocher
2012-10-23 11:31   ` Piotr Wilczek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350890483-26579-8-git-send-email-p.wilczek@samsung.com \
    --to=p.wilczek@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.