rk30: touchscreen: support IC(SDDA)
authorkfx <kfx@rock-chips.com>
Tue, 8 May 2012 08:45:32 +0000 (16:45 +0800)
committerkfx <kfx@rock-chips.com>
Tue, 8 May 2012 08:45:32 +0000 (16:45 +0800)
arch/arm/mach-rk30/board-rk30-sdk.c
drivers/input/touchscreen/rk29_i2c_goodix.c

index 6cef0f9bbbbdd94a29971b05c4ee7e616387dade..ba0b818243b8cb50b13fc3149cea7db71c88b434 100755 (executable)
@@ -502,11 +502,12 @@ int goodix_init_platform_hw(void)
                        printk("goodix gpio_request error\n");
                        return -EIO;
                }
-               gpio_direction_output(TOUCH_RESET_PIN, 0);
-               gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
-               msleep(10);
-               gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
-               msleep(500);
+               gpio_direction_output(TOUCH_RESET_PIN, 1);
+                msleep(100);
+               //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
+               //msleep(100);
+               //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
+               //msleep(500);
        }
        return 0;
 }
index 0dfa571d55d1153f2709914d228eab71ac42349d..6d8a74b30d221d9be277ed3f525e1529b9f30372 100755 (executable)
@@ -136,6 +136,33 @@ static int goodix_i2c_write_bytes(struct i2c_client *client,uint8_t *data,int le
        return ret;\r
 }\r
 \r
+static int goodix_config_ok(struct rk_ts_data *ts)\r
+{\r
+        int ret = 0;\r
+        unsigned int w,h, n;\r
+       uint8_t rd_cfg_buf[7] = {0x66,};\r
+        \r
+       ret = goodix_i2c_read_bytes(ts->client, rd_cfg_buf, 7);\r
+\r
+       w = (rd_cfg_buf[1]<<8) + rd_cfg_buf[2];\r
+       h = (rd_cfg_buf[3]<<8) + rd_cfg_buf[4];\r
+        n = rd_cfg_buf[5];\r
+\r
+#ifdef CONFIG_ARCH_RK29\r
+        if((ret < 0) || (w != TS_MAX_X) || (h != TS_MAX_Y) || (n != 10))\r
+#else\r
+        if((ret < 0) || (w != TS_MAX_X) || (h != TS_MAX_Y) || (n != 170))\r
+#endif\r
+                return -1;\r
+\r
+       ts->abs_x_max = w;\r
+       ts->abs_y_max = h;\r
+       ts->max_touch_num = n;\r
+        \r
+       printk("goodix_ts_init: X_MAX = %d,Y_MAX = %d,MAX_TOUCH_NUM = %d\n",ts->abs_x_max,ts->abs_y_max,ts->max_touch_num);\r
+\r
+        return 0;\r
+}\r
 /*******************************************************\r
 Description:\r
        Goodix touchscreen initialize function.\r
@@ -148,7 +175,7 @@ return:
 *******************************************************/\r
 static int goodix_init_panel(struct rk_ts_data *ts)\r
 {\r
-       int ret=-1;\r
+       int ret=-1, retry = 10;\r
        uint8_t rd_cfg_buf[7] = {0x66,};\r
 \r
 #if (TS_MAX_X == 1024)&&(TS_MAX_Y == 768)                      //for malata 10.1\r
@@ -162,6 +189,7 @@ static int goodix_init_panel(struct rk_ts_data *ts)
        };\r
              \r
 #elif (TS_MAX_X == 1280)&&(TS_MAX_Y == 800)    \r
+#ifdef CONFIG_ARCH_RK29\r
        uint8_t config_info[] = {\r
                0x65,0x02,0x05,0x00,0x03,0x20,0x0A,0x22,0x1E,0xE7,0x32,0x05,0x08,0x10,0x4C,\r
                0x41,0x41,0x20,0x07,0x00,0xA0,0xA0,0x46,0x64,0x0E,0x0D,0x0C,0x0B,0x0A,0x09,\r
@@ -170,6 +198,16 @@ static int goodix_init_panel(struct rk_ts_data *ts)
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\r
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\r
        };\r
+#else\r
+       uint8_t config_info[] = {\r
+                0x65,0xA2,0x05,0x00,0x03,0x20,0xAA,0x22,0x1E,0xE7,0x32,0x05,0x08,0x10,0x4C,\r
+                0x42,0x42,0x20,0x00,0x09,0x80,0x80,0x32,0x46,0x0E,0x0D,0x0C,0x0B,0x0A,0x09,\r
+                0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x1D,0x1C,0x1B,0x1A,0x19,0x18,\r
+                0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,\r
+                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\r
+                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\r
+        };\r
+#endif\r
 #else\r
        uint8_t config_info[] = {\r
                0x65,0x02,0x05,0x00,0x03,0x20,0x0A,0x22,0x1E,0xE7,0x32,0x05,0x08,0x10,0x4C,\r
@@ -181,30 +219,21 @@ static int goodix_init_panel(struct rk_ts_data *ts)
                0x00,0x00,0x00,0x00\r
        };\r
 #endif\r
-       ret=goodix_i2c_write_bytes(ts->client,config_info, (sizeof(config_info)/sizeof(config_info[0])));\r
-       if (ret < 0) {\r
-               printk("goodix write cfg info err");\r
-               return ret;\r
-       }\r
-       ret=goodix_i2c_read_bytes(ts->client, rd_cfg_buf, 7);\r
-       if(ret != 2)\r
-       {\r
-               dev_info(&ts->client->dev, "Read resolution & max_touch_num failed, use default value!\n");\r
-               ts->max_touch_num = MAX_FINGER_NUM;\r
-               //ts->int_trigger_type = INT_TRIGGER;\r
-               return 0;\r
-       }\r
-       ts->abs_x_max = (rd_cfg_buf[1]<<8) + rd_cfg_buf[2];\r
-       ts->abs_y_max = (rd_cfg_buf[3]<<8) + rd_cfg_buf[4];\r
-       ts->max_touch_num = rd_cfg_buf[5];\r
-       //ts->int_trigger_type = rd_cfg_buf[6]&0x03;\r
-       if((!ts->abs_x_max)||(!ts->abs_y_max)||(!ts->max_touch_num))\r
-       {\r
-               printk(KERN_INFO "Read invalid resolution & max_touch_num, use default value!\n");\r
-               ts->max_touch_num = MAX_FINGER_NUM;\r
-       }\r
 \r
-       printk(KERN_INFO "X_MAX = %d,Y_MAX = %d,MAX_TOUCH_NUM = %d\n",ts->abs_x_max,ts->abs_y_max,ts->max_touch_num);\r
+        while(--retry && (goodix_config_ok(ts) < 0)){\r
+               ret=goodix_i2c_write_bytes(ts->client,config_info, (sizeof(config_info)/sizeof(config_info[0])));\r
+               if (ret < 0) {\r
+                       printk("goodix write cfg info err");\r
+                       return ret;\r
+               }\r
+                msleep(100);\r
+        }\r
+\r
+        if(retry <= 0){\r
+                printk("goodix write cfg info err\n");\r
+                return -1;\r
+        }\r
+\r
        \r
        rd_cfg_buf[0] = 0x6e;\r
        rd_cfg_buf[1] = 0x00;\r
@@ -478,8 +507,6 @@ static void  rk_ts_work_func(struct work_struct *pwork)
   }\r
        \r
        \r
-       \r
-\r
 /*******************************************************\r
 Description:\r
        Timer interrupt service routine.\r
@@ -497,7 +524,6 @@ static enum hrtimer_restart goodix_ts_timer_func(struct hrtimer *timer)
        hrtimer_start(&ts->timer, ktime_set(0, (POLL_TIME+6)*1000000), HRTIMER_MODE_REL);\r
        return HRTIMER_NORESTART;\r
 }\r
-\r
 /*******************************************************\r
 Description:\r
        External interrupt service routine.\r
@@ -662,10 +688,11 @@ static int goodix_input_params_init(struct rk_ts_data *ts)
        \r
 static int goodix_ts_init(struct rk_ts_data *ts)\r
 {\r
-       char retry;\r
        char ret ;\r
-       char test_data = 1;\r
        char *version_info = NULL;\r
+#if 0\r
+       char test_data = 1;\r
+       char retry;\r
        for(retry=0;retry < 30; retry++)    //test goodix\r
        {\r
                ret =goodix_i2c_write_bytes(ts->client, &test_data, 1);\r
@@ -677,17 +704,13 @@ static int goodix_ts_init(struct rk_ts_data *ts)
                printk(KERN_INFO "I2C communication ERROR!Goodix touchscreen driver become invalid\n");\r
                return -1;\r
        }       \r
-       \r
+#endif \r
        \r
        ret=goodix_init_panel(ts);\r
        if(ret != 0) {\r
                printk("goodix panel init fail\n");\r
                return -1;\r
        }\r
-       else\r
-       {\r
-               printk(KERN_INFO "%s>>>>>>>max_point %d\n",__func__,ts->max_touch_num);\r
-       }\r
        ret = goodix_read_version(ts, &version_info);\r
        if(ret <= 0)\r
        {\r
@@ -695,7 +718,7 @@ static int goodix_ts_init(struct rk_ts_data *ts)
        }\r
        else\r
        {\r
-               printk(KERN_INFO"Goodix TouchScreen Version:%s>>>max_point:%d\n", (version_info+1),ts->max_touch_num);\r
+               printk("goodix_ts_init: version %s\n", (version_info+1));\r
        }\r
        vfree(version_info);\r
        #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP\r
@@ -708,7 +731,7 @@ static int goodix_ts_init(struct rk_ts_data *ts)
        }\r
        else\r
        {\r
-               printk("Create proc entry success!\n");\r
+               printk("goodix_ts_init: create proc entry success!\n");\r
                goodix_proc_entry->write_proc = goodix_update_write;\r
                goodix_proc_entry->read_proc = goodix_update_read;\r
                //goodix_proc_entry->owner = THIS_MODULE;\r
@@ -828,7 +851,7 @@ static int rk_ts_probe(struct i2c_client *client, const struct i2c_device_id *id
                        goto err_input_register_device_failed;\r
                }\r
        }\r
-       printk("Goodix TS probe successfully!\n");\r
+       printk("goodix_ts_init: probe successfully!\n");\r
        return 0;\r
 \r
        \r