From patchwork Thu Nov 15 08:15:24 2012
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Piotr Wilczek
X-Patchwork-Id: 199217
X-Patchwork-Delegate: hs@denx.de
Return-Path:
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Received: from theia.denx.de (theia.denx.de [85.214.87.163])
by ozlabs.org (Postfix) with ESMTP id EA1B32C00BE
for ;
Thu, 15 Nov 2012 19:16:54 +1100 (EST)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 6DB454A0FD;
Thu, 15 Nov 2012 09:16:37 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at theia.denx.de
Received: from theia.denx.de ([127.0.0.1])
by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id o++MKDnayQWN; Thu, 15 Nov 2012 09:16:37 +0100 (CET)
Received: from theia.denx.de (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id D597E4A0FE;
Thu, 15 Nov 2012 09:16:18 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
by theia.denx.de (Postfix) with ESMTP id 65F974A057
for ; Thu, 15 Nov 2012 09:16:13 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at theia.denx.de
Received: from theia.denx.de ([127.0.0.1])
by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id KJC-0CNmz71s for ;
Thu, 15 Nov 2012 09:16:12 +0100 (CET)
X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5
NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested)
Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34])
by theia.denx.de (Postfix) with ESMTP id F0A254A0A8
for ; Thu, 15 Nov 2012 09:16:02 +0100 (CET)
Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26])
by mailout4.samsung.com
(Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit
(built Nov
17 2011)) with ESMTP id <0MDI00KFZS99BJI0@mailout4.samsung.com> for
u-boot@lists.denx.de; Thu, 15 Nov 2012 17:16:00 +0900 (KST)
X-AuditID: cbfee61a-b7fa66d0000004cf-4a-50a4a4c0f83f
Received: from epmmp1.local.host ( [203.254.227.16])
by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 24.F4.01231.0C4A4A05;
Thu, 15 Nov 2012 17:16:00 +0900 (KST)
Received: from mcdsrvbld02.digital.local ([106.116.37.23])
by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01
(7.0.4.24.0) 64bit (built Nov 17 2011))
with ESMTPA id <0MDI00E3HS9U1070@mmp1.samsung.com> for
u-boot@lists.denx.de; Thu, 15 Nov 2012 17:16:00 +0900 (KST)
From: Piotr Wilczek
To: u-boot@lists.denx.de
Date: Thu, 15 Nov 2012 09:15:24 +0100
Message-id: <1352967325-26426-6-git-send-email-p.wilczek@samsung.com>
X-Mailer: git-send-email 1.7.10
In-reply-to: <1352967325-26426-1-git-send-email-p.wilczek@samsung.com>
References: <1352967325-26426-1-git-send-email-p.wilczek@samsung.com>
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrIJMWRmVeSWpSXmKPExsVy+t9jAd0DS5YEGLQfsLR4u7eT3YHR4+yd
HYwBjFFcNimpOZllqUX6dglcGf2f+9gL9ttUrHx7i6mBcYtBFyMnh4SAicTu6fsZIWwxiQv3
1rOB2EICixglbizK6WLkArIXM0ksa3wHVsQmoC2x/M0bMFtEQELiV/9VRpAiZoGlTBLn7v0H
cjg4hAW8JSY0OoOYLAKqEo8WCYKU8wq4Sjy+PYcJYpe8xNP7fWC7OAXcJI7suMcOsddVonXF
acYJjLwLGBlWMYqmFiQXFCel5xrqFSfmFpfmpesl5+duYgR7/JnUDsaVDRaHGAU4GJV4eB1+
LA4QYk0sK67MPcQowcGsJML74iBQiDclsbIqtSg/vqg0J7X4EKM0B4uSOG+zR0qAkEB6Yklq
dmpqQWoRTJaJg1OqgVEsYEfShgl9/GlNr2S+/H9ld1exqkQs65mMcdPHsys2/vmX6uljI2t1
f73G7WTZQ5M3hlr96b+3+dXECWkXltiUyF9gZtfyfyMUbbSx6GzD9MYHy/Rfhu9Q3lyzMjH9
YPrR3ZuaXh1iMNu0bH2ctNta26UVG4vY39ysmbXUUydid729r4jMkUolluKMREMt5qLiRABY
2k5J9AEAAA==
Cc: Stephen Warren ,
Piotr Wilczek ,
Kyungmin Park ,
Tom Rini , Heiko Schocher
Subject: [U-Boot] [PATCH 5/6] WIP: i2c: s3c24x0: modify driver for new I2C
framework
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: U-Boot discussion
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
MIME-Version: 1.0
Sender: u-boot-bounces@lists.denx.de
Errors-To: u-boot-bounces@lists.denx.de
This patch modifies s3c24x0 driver for the new I2C framework.
Configs for VCMA9.h and smdk5250.h boards are modified.
Boards compile successfully but were not tested.
Signed-off-by: Piotr Wilczek
Signed-off-by: Kyungmin Park
CC: Minkyu Kang
---
drivers/i2c/i2c_core.c | 5 ++
drivers/i2c/s3c24x0_i2c.c | 129 ++++++++++++++++++++++++++++++++++++++++---
include/configs/VCMA9.h | 4 ++
include/configs/smdk5250.h | 4 ++
4 files changed, 133 insertions(+), 9 deletions(-)
diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
index d3b5a8d..f0816f7 100644
--- a/drivers/i2c/i2c_core.c
+++ b/drivers/i2c/i2c_core.c
@@ -10,6 +10,10 @@
extern struct i2c_adapter fsl_i2c_adap[];
#endif
+#ifdef CONFIG_DRIVER_S3C24X0_I2C
+extern struct i2c_adapter s3c24x0_i2c_adap[];
+#endif
+
#ifdef CONFIG_SYS_I2C_SOFT
extern struct i2c_adapter soft_i2c_adap[];
#endif
@@ -214,6 +218,7 @@ unsigned int i2c_get_bus_num(void)
*/
int i2c_set_bus_num(unsigned int bus)
{
+
#ifndef CONFIG_SYS_I2C_DIRECT_BUS
int i;
uint8_t buf;
diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
index 90d297a..d473eaa 100644
--- a/drivers/i2c/s3c24x0_i2c.c
+++ b/drivers/i2c/s3c24x0_i2c.c
@@ -155,7 +155,6 @@ static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
/* set prescaler, divisor according to freq, also set ACKGEN, IRQ */
writel((div & 0x0F) | 0xA0 | ((pres == 512) ? 0x40 : 0), &i2c->iiccon);
-
/* init to SLAVE REVEIVE and set slaveaddr */
writel(0, &i2c->iicstat);
writel(slaveadd, &i2c->iicadd);
@@ -168,7 +167,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)
+int s3c24x0_i2c_set_bus_num(unsigned int bus)
{
struct s3c24x0_i2c *i2c;
@@ -184,13 +183,13 @@ int i2c_set_bus_num(unsigned int bus)
return 0;
}
-unsigned int i2c_get_bus_num(void)
+unsigned int s3c24x0_i2c_get_bus_num(void)
{
return g_current_bus;
}
#endif
-void i2c_init(int speed, int slaveadd)
+void s3c24x0_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
{
struct s3c24x0_i2c *i2c;
#if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
@@ -198,8 +197,7 @@ void i2c_init(int speed, int slaveadd)
#endif
int i;
- /* By default i2c channel 0 is the current bus */
- g_current_bus = 0;
+ g_current_bus = adap->hwadapnr;
i2c = get_base_i2c();
/* wait for some time to give previous transfer a chance to finish */
@@ -415,11 +413,13 @@ static int i2c_transfer(struct s3c24x0_i2c *i2c,
return result;
}
-int i2c_probe(uchar chip)
+int s3c24x0_i2c_probe(struct i2c_adapter *adap, uchar chip)
{
struct s3c24x0_i2c *i2c;
uchar buf[1];
+ g_current_bus = adap->hwadapnr;
+
i2c = get_base_i2c();
buf[0] = 0;
@@ -431,12 +431,15 @@ 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)
+int s3c24x0_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
+ int alen, uchar *buffer, int len)
{
struct s3c24x0_i2c *i2c;
uchar xaddr[4];
int ret;
+ g_current_bus = adap->hwadapnr;
+
if (alen > 4) {
debug("I2C read: addr len %d not supported\n", alen);
return 1;
@@ -475,11 +478,14 @@ 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)
+int s3c24x0_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
+ int alen, uchar *buffer, int len)
{
struct s3c24x0_i2c *i2c;
uchar xaddr[4];
+ g_current_bus = adap->hwadapnr;
+
if (alen > 4) {
debug("I2C write: addr len %d not supported\n", alen);
return 1;
@@ -512,4 +518,109 @@ 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);
}
+
+struct i2c_adapter s3c24x0_i2c_adap[] = {
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 0,
+ .name = "s3c24x0-i2c#0"
+ },
+#if CONFIG_MAX_I2C_NUM > 1
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 1,
+ .name = "s3c24x0-i2c#1"
+ },
+#endif
+#if CONFIG_MAX_I2C_NUM > 2
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 2,
+ .name = "s3c24x0-i2c#2"
+ },
+#endif
+#if CONFIG_MAX_I2C_NUM > 3
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 3,
+ .name = "s3c24x0-i2c#3"
+ },
+#endif
+#if CONFIG_MAX_I2C_NUM > 4
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 4,
+ .name = "s3c24x0-i2c#4"
+ },
+#endif
+#if CONFIG_MAX_I2C_NUM > 5
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 5,
+ .name = "s3c24x0-i2c#5"
+ },
+#endif
+#if CONFIG_MAX_I2C_NUM > 6
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 6,
+ .name = "s3c24x0-i2c#6"
+ },
+#endif
+#if CONFIG_MAX_I2C_NUM > 7
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 7,
+ .name = "s3c24x0-i2c#7"
+ },
+#endif
+};
#endif /* CONFIG_HARD_I2C */
diff --git a/include/configs/VCMA9.h b/include/configs/VCMA9.h
index fb7d922..f1de21d 100644
--- a/include/configs/VCMA9.h
+++ b/include/configs/VCMA9.h
@@ -95,6 +95,10 @@
/* we use the built-in I2C controller */
#define CONFIG_DRIVER_S3C24X0_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_ADAPTERS {&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
/* use EEPROM for environment vars */
diff --git a/include/configs/smdk5250.h b/include/configs/smdk5250.h
index c0f8622..cb0f449 100644
--- a/include/configs/smdk5250.h
+++ b/include/configs/smdk5250.h
@@ -204,6 +204,10 @@
#define CONFIG_MAX_I2C_NUM 8
#define CONFIG_SYS_I2C_SLAVE 0x0
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_ADAPTERS {&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+
/* Ethernet Controllor Driver */
#ifdef CONFIG_CMD_NET
#define CONFIG_SMC911X