i2c: s3c: Implant support for S3C2440
[oweals/u-boot.git] / drivers / i2c / s3c24x0_i2c.c
index 0dd1abcf80fcfe0e87fdb09323907244b3033e15..c053e84cdb6175da97de085fc0a4bc2512656f8e 100644 (file)
 #define I2C_START_STOP 0x20    /* START / STOP */
 #define I2C_TXRX_ENA   0x10    /* I2C Tx/Rx enable */
 
-#define I2C_TIMEOUT_MS 1000            /* 1 second */
+#define I2C_TIMEOUT_MS 10              /* 10 ms */
 
-#define        HSI2C_TIMEOUT_US 100000 /* 100 ms, finer granularity */
+#define        HSI2C_TIMEOUT_US 10000 /* 10 ms, finer granularity */
 
 
 /* To support VCMA9 boards and other who dont define max_i2c_num */
@@ -165,7 +165,7 @@ static int GetI2CSDA(void)
 {
        struct s3c24x0_gpio *gpio = s3c24x0_get_base_gpio();
 
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
        return (readl(&gpio->gpedat) & 0x8000) >> 15;
 #endif
 #ifdef CONFIG_S3C2400
@@ -177,7 +177,7 @@ static void SetI2CSCL(int x)
 {
        struct s3c24x0_gpio *gpio = s3c24x0_get_base_gpio();
 
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
        writel((readl(&gpio->gpedat) & ~0x4000) |
                                        (x & 1) << 14, &gpio->gpedat);
 #endif
@@ -443,7 +443,7 @@ static void s3c24x0_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
        int i;
 
        if ((readl(&i2c->iicstat) & I2CSTAT_BSY) || GetI2CSDA() == 0) {
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
                ulong old_gpecon = readl(&gpio->gpecon);
 #endif
 #ifdef CONFIG_S3C2400
@@ -452,7 +452,7 @@ static void s3c24x0_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
                /* bus still busy probably by (most) previously interrupted
                   transfer */
 
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
                /* set I2CSDA and I2CSCL (GPE15, GPE14) to GPIO */
                writel((readl(&gpio->gpecon) & ~0xF0000000) | 0x10000000,
                       &gpio->gpecon);
@@ -478,7 +478,7 @@ static void s3c24x0_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
                udelay(1000);
 
                /* restore pin functions */
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
                writel(old_gpecon, &gpio->gpecon);
 #endif
 #ifdef CONFIG_S3C2400
@@ -1348,7 +1348,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
        struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
        int node, flags;
 
-       i2c_bus->is_highspeed = dev->of_id->data;
+       i2c_bus->is_highspeed = dev_get_driver_data(dev);
        node = dev->of_offset;
 
        if (i2c_bus->is_highspeed) {