update i2c drivers
authorkfx <kfx@rock-chips.com>
Thu, 9 Feb 2012 02:43:35 +0000 (10:43 +0800)
committerkfx <kfx@rock-chips.com>
Thu, 9 Feb 2012 02:43:35 +0000 (10:43 +0800)
arch/arm/mach-rk30/devices.c
drivers/i2c/busses/i2c-rk29-adapter.c
drivers/i2c/i2c-core.c
include/linux/i2c.h

index 8a9028bfedd621180d97f319eb661bcc93e82afa..45d9ceb9f48724866a9efd46139963dfec9ffcb1 100644 (file)
@@ -153,7 +153,7 @@ static struct resource resources_i2c0[] = {
 };
 
 static struct platform_device device_i2c0 = {
-       .name   = "i2c-rk30",
+       .name   = "rk30_i2c",
        .id     = 0,
        .num_resources  = ARRAY_SIZE(resources_i2c0),
        .resource       = resources_i2c0,
@@ -189,7 +189,7 @@ static struct resource resources_i2c1[] = {
 };
 
 static struct platform_device device_i2c1 = {
-       .name   = "i2c-rk30",
+       .name   = "rk30_i2c",
        .id     = 1,
        .num_resources  = ARRAY_SIZE(resources_i2c1),
        .resource       = resources_i2c1,
@@ -225,7 +225,7 @@ static struct resource resources_i2c2[] = {
 };
 
 static struct platform_device device_i2c2 = {
-       .name   = "i2c-rk30",
+       .name   = "rk30_i2c",
        .id     = 2,
        .num_resources  = ARRAY_SIZE(resources_i2c2),
        .resource       = resources_i2c2,
@@ -261,7 +261,7 @@ static struct resource resources_i2c3[] = {
 };
 
 static struct platform_device device_i2c3 = {
-       .name   = "i2c-rk30",
+       .name   = "rk30_i2c",
        .id     = 3,
        .num_resources  = ARRAY_SIZE(resources_i2c3),
        .resource       = resources_i2c3,
@@ -297,7 +297,7 @@ static struct resource resources_i2c4[] = {
 };
 
 static struct platform_device device_i2c4 = {
-       .name   = "i2c-rk30",
+       .name   = "rk30_i2c",
        .id     = 4,
        .num_resources  = ARRAY_SIZE(resources_i2c4),
        .resource       = resources_i2c4,
index 5edf143f69a2e34dc78755a1f545363cf8941d66..a560db3ce1507b9781c6dad30bcd4bffea3dcc8a 100755 (executable)
@@ -81,45 +81,45 @@ int i2c_suspended(struct i2c_adapter *adap)
 }
 EXPORT_SYMBOL(i2c_suspended);
 
-static inline void rk29_i2c_disable_ack(void __iomem *regs)
+static inline void rk29_i2c_disable_ack(struct rk30_i2c *i2c)
 {
-    unsigned long conr = readl(regs + I2C_CONR);
+    unsigned long conr = readl(i2c->regs + I2C_CONR);
 
        conr |= I2C_CONR_NAK;
-       writel(conr, regs + I2C_CONR);
+       writel(conr,i2c->regs + I2C_CONR);
 }
 
-static inline void rk29_i2c_enable_ack(void __iomem *regs)
+static inline void rk29_i2c_enable_ack(struct rk30_i2c *i2c)
 {
-    unsigned long conr = readl(regs + I2C_CONR);
+    unsigned long conr = readl(i2c->regs + I2C_CONR);
 
        conr &= I2C_CONR_ACK;
-       writel(conr, regs + I2C_CONR);
+       writel(conr,i2c->regs + I2C_CONR);
 }
-static inline void rk29_i2c_disable_mport(void __iomem *regs)
+static inline void rk29_i2c_disable_mport(struct rk30_i2c *i2c)
 {
-    unsigned long conr = readl(regs + I2C_CONR);
+    unsigned long conr = readl(i2c->regs + I2C_CONR);
 
        conr &= I2C_CONR_MPORT_DISABLE;
-       writel(conr, regs + I2C_CONR);
+       writel(conr,i2c->regs + I2C_CONR);
 }
 
-static inline void rk29_i2c_enable_mport(void __iomem *regs)
+static inline void rk29_i2c_enable_mport(struct rk30_i2c *i2c)
 {
-    unsigned long conr = readl(regs + I2C_CONR);
+    unsigned long conr = readl(i2c->regs + I2C_CONR);
 
        conr |= I2C_CONR_MPORT_ENABLE;
-       writel(conr, regs + I2C_CONR);
+       writel(conr,i2c->regs + I2C_CONR);
 }
 
-static inline void rk29_i2c_disable_irq(void __iomem *regs)
+static inline void rk29_i2c_disable_irq(struct rk30_i2c *i2c)
 {
-    writel(IRQ_ALL_DISABLE, regs + I2C_IER);
+    writel(IRQ_ALL_DISABLE, i2c->regs + I2C_IER);
 }
 
-static inline void rk29_i2c_enable_irq(void __iomem *regs)
+static inline void rk29_i2c_enable_irq(struct rk30_i2c *i2c)
 {
-    writel(IRQ_MST_ENABLE, regs + I2C_IER);
+    writel(IRQ_MST_ENABLE, i2c->regs + I2C_IER);
 }
 
 /* scl = pclk/(5 *(rem+1) * 2^(exp+1)) */
@@ -153,7 +153,7 @@ static void  rk29_i2c_set_clk(struct rk30_i2c *i2c, unsigned long scl_rate)
        unsigned int rem = 0, exp = 0;
        unsigned long real_rate = 0, tmp;
 
-       unsigned long i2c_rate = 24000000;//clk_get_rate(i2c->clk);
+       unsigned long i2c_rate = clk_get_rate(i2c->clk);
 
     if((scl_rate == i2c->scl_rate) && (i2c_rate == i2c->i2c_rate))
         return;
@@ -227,7 +227,7 @@ static void rk29_i2c_message_start(struct rk30_i2c *i2c,
        if (msg->flags & I2C_M_REV_DIR_ADDR)
                addr ^= 1;
 
-       rk29_i2c_enable_ack(i2c->regs);
+       rk29_i2c_enable_ack(i2c);
        i2c_dbg(i2c->dev, "START: set addr 0x%02x to DS\n", addr);
 
     conr = readl(i2c->regs + I2C_CONR);
@@ -260,7 +260,7 @@ static inline void rk29_i2c_stop(struct rk30_i2c *i2c, int ret)
        i2c->state = STATE_STOP;
 
        rk29_i2c_master_complete(i2c, ret);
-       rk29_i2c_disable_irq(i2c->regs);
+       rk29_i2c_disable_irq(i2c);
 }
 
 /* returns TRUE if the current message is the last in the set */
@@ -296,7 +296,7 @@ static int rk29_i2c_irq_nextbyte(struct rk30_i2c *i2c, unsigned long isr)
 
        case STATE_STOP:
                dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__);
-               rk29_i2c_disable_irq(i2c->regs);
+               rk29_i2c_disable_irq(i2c);
                goto out;
 
        case STATE_START:
@@ -564,7 +564,7 @@ static int rk29_i2c_xfer(struct i2c_adapter *adap,
                wake_lock(&i2c->idlelock[i2c->adap.nr]);
 
        rk29_i2c_set_clk(i2c, scl_rate);
-    rk29_i2c_enable_mport(i2c->regs);
+    rk29_i2c_enable_mport(i2c);
     udelay(i2c->tx_setup);
 
        for (retry = 0; retry < adap->retries; retry++) {
@@ -580,7 +580,7 @@ static int rk29_i2c_xfer(struct i2c_adapter *adap,
                msleep(1);
        }
        
-    rk29_i2c_disable_mport(i2c->regs);
+    rk29_i2c_disable_mport(i2c);
     if(i2c->is_div_from_arm[i2c->adap.nr])
                wake_unlock(&i2c->idlelock[i2c->adap.nr]);
        return -EREMOTEIO;
@@ -605,7 +605,7 @@ int i2c_add_rk29_adapter(struct i2c_adapter *adap)
     struct rk30_i2c *i2c = (struct rk30_i2c *)adap->algo_data;
 
     adap->algo = &rk29_i2c_algorithm;
-       adap->retries = 3;
+       adap->retries = 2;
 
     i2c->i2c_init_hw = &rk29_i2c_init_hw;
     i2c->i2c_set_clk = &rk29_i2c_set_clk;
index 45b2c77ca6c8d9a9de4eeaa788a5c8752e3b4323..b32f5654c6c15a82a858a28b623e5b775fc798d0 100755 (executable)
@@ -1427,7 +1427,7 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 }
 EXPORT_SYMBOL(i2c_transfer);
 
-#if defined (CONFIG_I2C_RK2818) || defined(CONFIG_I2C_RK29)
+#ifdef CONFIG_PLAT_RK
 int i2c_master_send(const struct i2c_client *client, const char *buf, int count)
 {
        int ret;
index 584a700b976e294bf9d10eced65d76ada3cb7242..a996acb9c0eac0822613d1a8378e0020bdd3ce9a 100644 (file)
@@ -61,7 +61,7 @@ extern int i2c_master_send(const struct i2c_client *client, const char *buf,
 extern int i2c_master_recv(const struct i2c_client *client, char *buf,
                           int count);
 
-#if defined (CONFIG_I2C_RK2818) || defined(CONFIG_I2C_RK29)
+#ifdef CONFIG_PLAT_RK
 /* If everything went ok, return 'count' transmitted, else error code. */
 extern int i2c_master_normal_send(const struct i2c_client *client, const char *buf, int count, int scl_rate);
 extern int i2c_master_normal_recv(const struct i2c_client *client, char *buf, int count, int scl_rate);