@@ -178,7 +178,7 @@ static int board_i2c_init(void)
{
int i, err;
- for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
+ for (i = 0; i < CONFIG_SYS_I2C_S3C24X0_MAX_NUM; i++) {
err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
PINMUX_FLAG_NONE);
if (err) {
@@ -186,7 +186,7 @@ static int board_i2c_init(void)
return err;
}
}
- i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+ i2c_init(CONFIG_SYS_I2C_S3C24X0_SPEED, CONFIG_SYS_I2C_S3C24X0_SLAVE);
return 0;
}
#endif
@@ -37,7 +37,7 @@ COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
COBJS-$(CONFIG_PCA9564_I2C) += pca9564_i2c.o
COBJS-$(CONFIG_PPC4XX_I2C) += ppc4xx_i2c.o
-COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
+COBJS-$(CONFIG_SYS_I2C_S3C24X0) += s3c24x0_i2c.o
COBJS-$(CONFIG_S3C44B0_I2C) += s3c44b0_i2c.o
COBJS-$(CONFIG_TEGRA_I2C) += tegra_i2c.o
COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
@@ -10,6 +10,10 @@
extern struct i2c_adapter fsl_i2c_adap[];
#endif
+#ifdef CONFIG_SYS_I2C_S3C24X0
+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;
@@ -37,8 +37,6 @@
#include <i2c.h>
#include "s3c24x0_i2c.h"
-#ifdef CONFIG_HARD_I2C
-
#define I2C_WRITE 0
#define I2C_READ 1
@@ -59,9 +57,6 @@
#define I2C_TIMEOUT 1 /* 1 second */
-
-static unsigned int g_current_bus; /* Stores Current I2C Bus */
-
#if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
static int GetI2CSDA(void)
{
@@ -119,17 +114,17 @@ static void ReadWriteByte(struct s3c24x0_i2c *i2c)
writel(readl(&i2c->iiccon) & ~I2CCON_IRPND, &i2c->iiccon);
}
-static struct s3c24x0_i2c *get_base_i2c(void)
+static struct s3c24x0_i2c *get_base_i2c(int bus)
{
#ifdef CONFIG_EXYNOS4
struct s3c24x0_i2c *i2c = (struct s3c24x0_i2c *)(samsung_get_base_i2c()
+ (EXYNOS4_I2C_SPACING
- * g_current_bus));
+ * bus));
return i2c;
#elif defined CONFIG_EXYNOS5
struct s3c24x0_i2c *i2c = (struct s3c24x0_i2c *)(samsung_get_base_i2c()
+ (EXYNOS5_I2C_SPACING
- * g_current_bus));
+ * bus));
return i2c;
#else
return s3c24x0_get_base_i2c();
@@ -163,34 +158,7 @@ static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
writel(I2C_MODE_MT | I2C_TXRX_ENA, &i2c->iicstat);
}
-/*
- * MULTI BUS I2C support
- */
-
-#ifdef CONFIG_I2C_MULTI_BUS
-int i2c_set_bus_num(unsigned int bus)
-{
- struct s3c24x0_i2c *i2c;
-
- if ((bus < 0) || (bus >= CONFIG_MAX_I2C_NUM)) {
- debug("Bad bus: %d\n", bus);
- return -1;
- }
-
- g_current_bus = bus;
- i2c = get_base_i2c();
- i2c_ch_init(i2c, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-
- return 0;
-}
-
-unsigned int i2c_get_bus_num(void)
-{
- return g_current_bus;
-}
-#endif
-
-void i2c_init(int speed, int slaveadd)
+static void s3c24x0_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
{
struct s3c24x0_i2c *i2c;
#if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
@@ -198,9 +166,7 @@ void i2c_init(int speed, int slaveadd)
#endif
int i;
- /* By default i2c channel 0 is the current bus */
- g_current_bus = 0;
- i2c = get_base_i2c();
+ i2c = get_base_i2c(adap->hwadapnr);
/* wait for some time to give previous transfer a chance to finish */
i = I2C_TIMEOUT * 1000;
@@ -415,12 +381,12 @@ static int i2c_transfer(struct s3c24x0_i2c *i2c,
return result;
}
-int i2c_probe(uchar chip)
+static int s3c24x0_i2c_probe(struct i2c_adapter *adap, uchar chip)
{
struct s3c24x0_i2c *i2c;
uchar buf[1];
- i2c = get_base_i2c();
+ i2c = get_base_i2c(adap->hwadapnr);
buf[0] = 0;
/*
@@ -431,7 +397,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(struct i2c_adapter *adap, uchar chip, uint addr,
+ int alen, uchar *buffer, int len)
{
struct s3c24x0_i2c *i2c;
uchar xaddr[4];
@@ -465,7 +432,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
chip |= ((addr >> (alen * 8)) &
CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
#endif
- i2c = get_base_i2c();
+ i2c = get_base_i2c(adap->hwadapnr);
ret = i2c_transfer(i2c, I2C_READ, chip << 1, &xaddr[4 - alen], alen,
buffer, len);
if (ret != 0) {
@@ -475,7 +442,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(struct i2c_adapter *adap, uchar chip, uint addr,
+ int alen, uchar *buffer, int len)
{
struct s3c24x0_i2c *i2c;
uchar xaddr[4];
@@ -507,9 +475,113 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
chip |= ((addr >> (alen * 8)) &
CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
#endif
- i2c = get_base_i2c();
+ i2c = get_base_i2c(adap->hwadapnr);
return (i2c_transfer
(i2c, I2C_WRITE, chip << 1, &xaddr[4 - alen], alen, buffer,
len) != 0);
}
-#endif /* CONFIG_HARD_I2C */
+
+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_S3C24X0_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_S3C24X0_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 0,
+ .name = "s3c24x0-i2c"
+ },
+#if CONFIG_SYS_I2C_S3C24X0_MAX_NUM > 1
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_S3C24X0_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_S3C24X0_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 1,
+ .name = "s3c24x0-i2c#1"
+ },
+#endif
+#if CONFIG_SYS_I2C_S3C24X0_MAX_NUM > 2
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_S3C24X0_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_S3C24X0_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 2,
+ .name = "s3c24x0-i2c#2"
+ },
+#endif
+#if CONFIG_SYS_I2C_S3C24X0_MAX_NUM > 3
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_S3C24X0_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_S3C24X0_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 3,
+ .name = "s3c24x0-i2c#3"
+ },
+#endif
+#if CONFIG_SYS_I2C_S3C24X0_MAX_NUM > 4
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_S3C24X0_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_S3C24X0_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 4,
+ .name = "s3c24x0-i2c#4"
+ },
+#endif
+#if CONFIG_SYS_I2C_S3C24X0_MAX_NUM > 5
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_S3C24X0_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_S3C24X0_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 5,
+ .name = "s3c24x0-i2c#5"
+ },
+#endif
+#if CONFIG_SYS_I2C_S3C24X0_MAX_NUM > 6
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_S3C24X0_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_S3C24X0_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 6,
+ .name = "s3c24x0-i2c#6"
+ },
+#endif
+#if CONFIG_SYS_I2C_S3C24X0_MAX_NUM > 7
+ {
+ .init = s3c24x0_i2c_init,
+ .probe = s3c24x0_i2c_probe,
+ .read = s3c24x0_i2c_read,
+ .write = s3c24x0_i2c_write,
+ .speed = CONFIG_SYS_I2C_S3C24X0_SPEED,
+ .slaveaddr = CONFIG_SYS_I2C_S3C24X0_SLAVE,
+ .init_done = 0,
+ .hwadapnr = 7,
+ .name = "s3c24x0-i2c#7"
+ },
+#endif
+};
@@ -88,12 +88,15 @@
* the MPL VCMA9 is equipped with an ATMEL 24C256 EEPROM at
* address 0x50 with 16bit addressing
*/
-#define CONFIG_HARD_I2C /* I2C with hardware support */
-#define CONFIG_SYS_I2C_SPEED 100000 /* I2C speed */
-#define CONFIG_SYS_I2C_SLAVE 0x7F /* I2C slave addr */
+#define CONFIG_SYS_I2C_S3C24X0_SPEED 100000 /* I2C speed */
+#define CONFIG_SYS_I2C_S3C24X0_SLAVE 0x7F /* I2C slave addr */
/* we use the built-in I2C controller */
-#define CONFIG_DRIVER_S3C24X0_I2C
+#define CONFIG_SYS_I2C_S3C24X0
+
+#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
@@ -196,13 +196,14 @@
/* I2C */
#define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_HARD_I2C
#define CONFIG_CMD_I2C
-#define CONFIG_SYS_I2C_SPEED 100000 /* 100 Kbps */
-#define CONFIG_DRIVER_S3C24X0_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_MAX_I2C_NUM 8
-#define CONFIG_SYS_I2C_SLAVE 0x0
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_S3C24X0
+#define CONFIG_SYS_I2C_S3C24X0_MAX_NUM 8
+#define CONFIG_SYS_I2C_S3C24X0_SPEED 100000 /* 100 Kbps */
+#define CONFIG_SYS_I2C_S3C24X0_SLAVE 0x0
+#define CONFIG_SYS_I2C_ADAPTERS {&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
/* Ethernet Controllor Driver */
#ifdef CONFIG_CMD_NET