在spi驱动休眠和唤醒的函数中加了解决spi_cs0漏电的代码,更新触摸面板的驱动
author宋秀杰 <sxj@rock-chips.com>
Fri, 8 Oct 2010 11:26:31 +0000 (04:26 -0700)
committer宋秀杰 <sxj@rock-chips.com>
Fri, 8 Oct 2010 11:50:01 +0000 (04:50 -0700)
arch/arm/mach-rk2818/board-raho-0928.c
arch/arm/mach-rk2818/board-raho.c
arch/arm/mach-rk2818/include/mach/board.h
drivers/input/touchscreen/ctp_it7250.c
drivers/spi/rk2818_spim.c

index 29a41c61b9d60760147d10a949a645bffa494fa7..8672ce4b93ba757dcc104140ed353274f53c7b13 100755 (executable)
@@ -1311,11 +1311,25 @@ static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
        return 0;
 }
 
+static int spi_io_fix_leakage_bug(void)
+{
+       gpio_direction_output(RK2818_PIN_PB4,GPIO_LOW); 
+       return 0;
+}
+
+static int spi_io_resume_leakage_bug(void)
+{
+       gpio_direction_output(RK2818_PIN_PB4,GPIO_HIGH);
+       return 0;
+}
+
 struct rk2818_spi_platform_data rk2818_spi_platdata = {
        .num_chipselect = SPI_CHIPSELECT_NUM,//raho ´ó°åÐèÒªÖ§³Ö3¸öƬѡ dxj
        .chipselect_gpios = rk2818_spi_cs_gpios,
        .io_init = spi_io_init,
        .io_deinit = spi_io_deinit,
+       .io_fix_leakage_bug=spi_io_fix_leakage_bug,
+       .io_resume_leakage_bug=spi_io_resume_leakage_bug,
 };
 
 
index d9d09c78c4016bb98e0ac0665712a2d1a2124125..950a3355b88978b86240dbeffdefc175cd972952 100755 (executable)
@@ -1311,11 +1311,25 @@ static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
        return 0;
 }
 
+static int spi_io_fix_leakage_bug(void)
+{
+       gpio_direction_output(RK2818_PIN_PB4,GPIO_LOW); 
+       return 0;
+}
+
+static int spi_io_resume_leakage_bug(void)
+{
+       gpio_direction_output(RK2818_PIN_PB4,GPIO_HIGH);
+       return 0;
+}
+
 struct rk2818_spi_platform_data rk2818_spi_platdata = {
        .num_chipselect = SPI_CHIPSELECT_NUM,//raho ´ó°åÐèÒªÖ§³Ö3¸öƬѡ dxj
        .chipselect_gpios = rk2818_spi_cs_gpios,
        .io_init = spi_io_init,
        .io_deinit = spi_io_deinit,
+       .io_fix_leakage_bug=spi_io_fix_leakage_bug,
+       .io_resume_leakage_bug=spi_io_resume_leakage_bug,
 };
 
 
index fb400ca25f4eae830d0f0993ff61700d61f4a50c..6f9f9c4315f6967911334b3d3805b3a5507294c9 100755 (executable)
@@ -210,6 +210,8 @@ struct spi_cs_gpio {
 struct rk2818_spi_platform_data {
        int (*io_init)(struct spi_cs_gpio*, int);
        int (*io_deinit)(struct spi_cs_gpio*, int);
+       int (*io_fix_leakage_bug)(void);
+       int (*io_resume_leakage_bug)(void);
        struct spi_cs_gpio *chipselect_gpios;   
        u16 num_chipselect;
 };
index 5c7f3833227e98a834e007b6bc77caac6fdfa508..c4b832eaa50b8720374167726fe52a2b08afdd64 100755 (executable)
@@ -198,7 +198,7 @@ return ;
 static irqreturn_t Ctp_it7250_touch_irq(int irq, void *dev_id)\r
 {      \r
        struct Ctp_it7250_data *Ctp_it7250 = dev_id;\r
-\r
+       //printk("%s++++ %d \r\n",__FUNCTION__,__LINE__);\r
        //rk28printk("%s++++ %d \r\n",__FUNCTION__,__LINE__);\r
        disable_irq_nosync(irq);\r
        //rk28printk("%s++++ %d irq=%d\r\n",__FUNCTION__,__LINE__,irq);\r
@@ -313,7 +313,6 @@ ret = gpio_direction_input(client->irq);
        return true;    \r
 }\r
 \r
-\r
 // ================================================================================\r
 // Function Name --- GetFirmwareInformation\r
 // Description --- Get firmware information\r
@@ -457,7 +456,7 @@ bool IdentifyCapSensor(struct i2c_client *client)
        ucWriteLength = 1;\r
        ucReadLength = 0x0A;\r
        pucData[0] = 0x00;\r
-rk28printk("%s\r\n",__FUNCTION__);\r
+       rk28printk("%s\r\n",__FUNCTION__);\r
        // Query\r
        do\r
        {//printk("first wait 111\r\n");\r
@@ -699,6 +698,7 @@ int CaptouchHWInitial(struct i2c_client *client)
        if (!IdentifyCapSensor(client))\r
        {\r
                rk28printk("%s IdentifyCapSensor error \r\n",__FUNCTION__);\r
+               printk("%s IdentifyCapSensor error \r\n",__FUNCTION__);\r
                return false;\r
                //goto resetagin;\r
 }\r
@@ -706,12 +706,14 @@ int CaptouchHWInitial(struct i2c_client *client)
 if (!GetFirmwareInformation (client))\r
        {\r
        rk28printk("%s GetFirmwareInformation error \r\n",__FUNCTION__);\r
+       printk("%s GetFirmwareInformation error \r\n",__FUNCTION__);\r
        //      goto resetagin;\r
 }\r
 \r
        if (!Get2DResolutions(client, &wXResolution, &wYResolution, &ucStep))\r
        {\r
        rk28printk("%s Get2DResolutions error \r\n",__FUNCTION__);\r
+       printk("%s Get2DResolutions error \r\n",__FUNCTION__);\r
        //      goto resetagin;\r
 }\r
 \r
@@ -956,9 +958,7 @@ static void  Ctp_it7250_delaywork_func(struct work_struct  *work)
  static int  Ctp_it7250_probe(struct i2c_client *client, const struct i2c_device_id *id)\r
 {\r
        struct Ctp_it7250_data *Ctp_it7250;\r
-//     u16 TempReg=0x0;\r
-//     u16 val=0x0;\r
-       \r
+\r
        Ctp_it7250_client = client;\r
        rk28printk("+++++++     %s+++++++\n", __FUNCTION__);\r
        Ctp_it7250 = kzalloc(sizeof(struct Ctp_it7250_data), GFP_KERNEL);\r
@@ -971,41 +971,34 @@ static void  Ctp_it7250_delaywork_func(struct work_struct  *work)
 //     INIT_WORK(&Ctp_it7250->irq_work, Ctp_it7250_irq_worker);\r
        INIT_DELAYED_WORK(&Ctp_it7250->delaywork, Ctp_it7250_delaywork_func);\r
 \r
-\r
        Ctp_it7250->client = client;\r
        i2c_set_clientdata(client, Ctp_it7250);\r
-\r
        \r
-if (!CaptouchHWInitial(client))\r
-       goto  err_free_mem;\r
-Ctp_it7250_init_irq(client);   \r
+       if (!CaptouchHWInitial(client))\r
+               goto  err_free_mem;\r
+       Ctp_it7250_init_irq(client);    \r
        ts_input_init(client);\r
 //     CTS_configure_pin(client);\r
 \r
-{\r
 #if 0\r
-lp8725_lilo_en(2,0);\r
-mdelay(100);\r
+       lp8725_lilo_en(2,0);\r
+       mdelay(100);\r
 \r
-lp8725_lilo_en(2,1);\r
-mdelay(100);\r
-lp8725_set_lilo_vol(2,300);\r
-mdelay(5);\r
+       lp8725_lilo_en(2,1);\r
+       mdelay(100);\r
+       lp8725_set_lilo_vol(2,300);\r
+       mdelay(5);\r
 #endif\r
 \r
-}\r
-\r
-       \r
-       \r
 //²»ÊDzéѯģʽ£¬²»ÐèÒªÂÖѯ\r
 //schedule_delayed_work(&Ctp_it7250->delaywork,msecs_to_jiffies(50));\r
 \r
 \r
        rk28printk("+++++++     %s+++++++\n", __FUNCTION__);\r
        return 0;\r
-err_free_mem:\r
- kfree(Ctp_it7250);\r
- return false;\r
+       err_free_mem:\r
      kfree(Ctp_it7250);\r
       return false;\r
 \r
 }\r
 \r
@@ -1022,37 +1015,11 @@ static int Ctp_it7250_remove(struct i2c_client *client)
 #ifdef CONFIG_PM\r
 static int Ctp_it7250_suspend(struct i2c_client *client, pm_message_t state)\r
 {//pr_emerg("\n irq1=%d \n",irq1);\r
-struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdata(client);\r
-\r
-//send command to make ctp into sleep mode\r
-#if 1\r
-       u8 ucWriteLength;\r
-       u8 pucData[128];\r
-       u8 ucQuery;\r
-\r
-       ucWriteLength = 3;\r
-       pucData[0] = 0x04;\r
-       pucData[1] = 0x00;\r
-       pucData[2] = 0x02;\r
-\r
-       // Query\r
-       do\r
-       {\r
-               if(!ReadQueryBuffer(client, &ucQuery))\r
-               {\r
-                       ucQuery = QUERY_BUSY;\r
-               }\r
-       }while(ucQuery & QUERY_BUSY);\r
+       struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdata(client);\r
 \r
-       // Write Command\r
-       rk28printk("%s WriteCommandBuffer\r\n",__FUNCTION__);\r
-       if(!WriteCommandBuffer(client, pucData, ucWriteLength))\r
-       {\r
-               return false;\r
-       }\r
-       #endif\r
-//send sleep command end\r
+       rk28printk("%s\n",__func__);\r
 \r
+       CaptouchMode(client, 2);\r
        disable_irq(Ctp_it7250->irq);\r
 \r
        return 0;\r
@@ -1060,14 +1027,21 @@ struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdat
 \r
 static int Ctp_it7250_resume(struct i2c_client *client)\r
 {\r
-struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdata(client);\r
-//read command to wakeup ctp\r
-#if 1\r
-u8 ucQuery;\r
-ReadQueryBuffer(client, &ucQuery);\r
-#endif\r
-//wakeup end\r
+       struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdata(client);\r
+\r
+       u8 ucQuery;\r
+       rk28printk("%s\n",__func__);\r
+\r
+       if(gpio_direction_output(client->irq,GPIO_LOW))\r
+               printk("%s:set pin output error\n",__func__);\r
+       msleep(20);\r
+       ReadQueryBuffer(client, &ucQuery);\r
+       if (gpio_direction_input(client->irq)) \r
+               printk("%s:failed to set CTS_configure_pin gpio input\n",__func__);\r
+       gpio_pull_updown(client->irq,GPIOPullUp);\r
+       msleep(20);\r
        enable_irq(Ctp_it7250->irq);\r
+       \r
        return 0;\r
 }\r
 #else\r
@@ -1086,9 +1060,9 @@ static struct i2c_driver Ctp_it7250_driver = {
        },\r
        .id_table       = Ctp_it7250_id,\r
        .probe  = Ctp_it7250_probe,\r
-       .remove     =  Ctp_it7250_remove,
-       .suspend = Ctp_it7250_suspend,
-       .resume = Ctp_it7250_resume,\r
+        .remove     =  Ctp_it7250_remove,\r
+        .suspend  = Ctp_it7250_suspend,\r
+        .resume = Ctp_it7250_resume,\r
 };\r
 \r
 static int __init Ctp_it7250_init(void)\r
@@ -1113,3 +1087,4 @@ module_exit(Ctp_it7250_exit);
 \r
 MODULE_AUTHOR("Robert_mu<robert.mu@rahotech.com>");\r
 \r
+\r
index 2136feca7994140e5272537b713aa3ed6b030999..543262ae0098e7b4b1d36023d07f8c5fe95dcdbd 100755 (executable)
@@ -1451,13 +1451,17 @@ static int rk2818_spim_suspend(struct platform_device *pdev, pm_message_t mesg)
 {
        struct spi_master *master = platform_get_drvdata(pdev);
        struct rk2818_spi *dws = spi_master_get_devdata(master);
+       struct rk2818_spi_platform_data *pdata = pdev->dev.platform_data;
        int status;
 
        status = stop_queue(dws);
        if (status != 0)
                return status;
        clk_disable(dws->clock_spim);
-
+       if (pdata && pdata->io_fix_leakage_bug)
+       {
+               pdata->io_fix_leakage_bug( );
+       }
        return 0;
 }
 
@@ -1465,6 +1469,7 @@ static int rk2818_spim_resume(struct platform_device *pdev)
 {
        struct spi_master *master = platform_get_drvdata(pdev);
        struct rk2818_spi *dws = spi_master_get_devdata(master);
+       struct rk2818_spi_platform_data *pdata = pdev->dev.platform_data;
        int ret;
        
        clk_enable(dws->clock_spim);    
@@ -1472,6 +1477,10 @@ static int rk2818_spim_resume(struct platform_device *pdev)
        ret = start_queue(dws);
        if (ret)
                dev_err(&dws->master->dev, "fail to start queue (%d)\n", ret);
+       if (pdata && pdata->io_resume_leakage_bug)
+       {
+               pdata->io_resume_leakage_bug( ); 
+       }
        return ret;
 }