move tca6424_reset_itr from tca6424.c to board-infosdk.c,this is used in i2c-rk2818...
author宋秀杰 <sxj@rock-chips.com>
Wed, 18 Aug 2010 12:57:42 +0000 (05:57 -0700)
committer宋秀杰 <sxj@rock-chips.com>
Wed, 18 Aug 2010 12:59:59 +0000 (05:59 -0700)
arch/arm/mach-rk2818/board-infosdk.c
arch/arm/mach-rk2818/include/mach/board.h
drivers/gpio/tca6424.c
drivers/i2c/busses/i2c-rk2818.c

index f15807a4dfd184212a2a0c784ce0d320572e331d..ed4b5668f1299122e150a40e01066c16546d61a4 100755 (executable)
@@ -316,6 +316,23 @@ struct rk2818_gpio_expander_info  extgpio_tca6424_settinginfo[] = {
         },
 };
 
+void tca6424_reset_itr(void)
+{
+               rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_GPIO1_A67);
+               gpio_request(RK2818_PIN_PE6,NULL);
+               gpio_request(RK2818_PIN_PE7,NULL);
+
+               gpio_direction_output(RK2818_PIN_PE6,GPIO_HIGH);
+               gpio_direction_output(RK2818_PIN_PE7,GPIO_LOW);
+               udelay(3);
+               gpio_set_value(RK2818_PIN_PE7,GPIO_HIGH);
+               udelay(1);
+               
+               gpio_free(RK2818_PIN_PE6);
+               gpio_free(RK2818_PIN_PE7);
+               rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_I2C1);
+}
+
 struct tca6424_platform_data rk2818_tca6424_data={
        .gpio_base=GPIO_EXPANDER_BASE,
        .gpio_pin_num=CONFIG_EXPANDED_GPIO_NUM,
@@ -325,6 +342,7 @@ struct tca6424_platform_data rk2818_tca6424_data={
        .settinginfo=extgpio_tca6424_settinginfo,
        .settinginfolen=ARRAY_SIZE(extgpio_tca6424_settinginfo),
        .names="extend_gpio_tca6424",
+       .reseti2cpin = tca6424_reset_itr,
 };
 #endif
 
index 2cb4ecd64f628175e57cae5f742ad3e335fb6a2c..0d360449aa8df17cc2c03936ca501c7267233399 100755 (executable)
@@ -135,6 +135,7 @@ struct tca6424_platform_data {
        int             (*setup)(struct i2c_client *client,unsigned gpio, unsigned ngpio,void *context);
        int             (*teardown)(struct i2c_client *client,unsigned gpio, unsigned ngpio,void *context);
        char            **names;
+       void    (*reseti2cpin)(void);
 };
 
 
index ba7d185076da24ad0ac04fd7994154631133f2be..11ce469035e3e9a70320663dd059be5bf0322866 100755 (executable)
@@ -834,22 +834,6 @@ int tca6424_init_pintype(struct tca6424_chip *chip,struct i2c_client *client)
 
        return 0;
 }
-void tca6424_reset_itr(void)
-{
-               rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_GPIO1_A67);
-               gpio_request(RK2818_PIN_PE6,NULL);
-               gpio_request(RK2818_PIN_PE7,NULL);
-
-               gpio_direction_output(RK2818_PIN_PE6,GPIO_HIGH);
-               gpio_direction_output(RK2818_PIN_PE7,GPIO_LOW);
-               udelay(3);
-               gpio_set_value(RK2818_PIN_PE7,GPIO_HIGH);
-               udelay(1);
-               rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_I2C1);
-               
-               gpio_free(RK2818_PIN_PE6);
-               gpio_free(RK2818_PIN_PE7);
-}
 
 static int __devinit tca6424_probe(struct i2c_client *client,const struct i2c_device_id *id)
 {
@@ -871,6 +855,8 @@ static int __devinit tca6424_probe(struct i2c_client *client,const struct i2c_de
                ret = -EINVAL;
                goto out_failed;
        }
+
+       client->adapter->dev.platform_data = pdata;
        
        chip->gpio_start = pdata->gpio_base;
        chip->gpio_irq_start =pdata->gpio_irq_start;
@@ -905,7 +891,6 @@ static int __devinit tca6424_probe(struct i2c_client *client,const struct i2c_de
        tca6424_gpio_irq_setup(chip);
        i2c_set_clientdata(client, chip);
        chip->client = client;
-
        return 0;
 
 out_failed:
index fde5cbe1ade0afc492f389a4ba3db22adf7c2d9d..54dacbb14f93948c006bff3d1c8d0a017aa74037 100755 (executable)
 #define RK2818_I2C_TIMEOUT             (msecs_to_jiffies(500))
 #define RK2818_DELAY_TIME              2
 
-#if defined (CONFIG_IOEXTEND_TCA6424)
-       void tca6424_reset_itr(void);
-#endif
-
 #if 0
 #define i2c_dbg(dev, format, arg...)           \
        dev_printk(KERN_INFO , dev , format , ## arg)
@@ -421,7 +417,10 @@ static int rk2818_xfer_msg(struct i2c_adapter *adap,
        struct rk2818_i2c_data *i2c = (struct rk2818_i2c_data *)adap->algo_data;
        unsigned long conr = readl(i2c->regs + I2C_CONR);
        int ret = 0;
-
+       
+       #if defined (CONFIG_IOEXTEND_TCA6424)
+       struct tca6424_platform_data  *pdata = adap->dev.platform_data;
+       #endif
        
        if(msg->len == 0)
        {
@@ -467,7 +466,9 @@ exit:
                if(msg->flags & I2C_M_RD)
                {
                        #if defined (CONFIG_IOEXTEND_TCA6424)
-                               tca6424_reset_itr( );
+                       if (pdata && pdata->reseti2cpin) {
+                               pdata->reseti2cpin();
+                       }
                        #endif  
                }