input: eeti_egalax_i2c: never report ABS_MT_TOUCH_MAJOR with 0
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / xpt2046_ts_320X480.c
old mode 100644 (file)
new mode 100755 (executable)
index 86ce61d..e2628e2
@@ -1,7 +1,7 @@
 /*
- * drivers/input/touchscreen/xpt2046_ts.c - driver for rk2818 spi xpt2046 device and console
+ * drivers/input/touchscreen/xpt2046_ts.c - driver for rk29 spi xpt2046 device and console
  *
- * Copyright (C) 2010 ROCKCHIP, Inc.
+ * Copyright (C) 2011 ROCKCHIP, Inc.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -201,22 +201,6 @@ struct dfr_req {
        struct spi_transfer     xfer[4];
 };
 
-static struct xpt2046_platform_data xpt2046_info = {
-       .model                  = 2046,
-       .keep_vref_on   = 1,
-       .swap_xy                = 0,
-       .x_min                  = 0,
-       .x_max                  = 320,
-       .y_min                  = 0,
-       .y_max                  = 480,
-       .debounce_max           = 7,
-       .debounce_rep           = DEBOUNCE_REPTIME,
-       .debounce_tol           = 20,
-       .gpio_pendown           = RK2818_PIN_PE1,//RK2818_PIN_PE3, //modify by zhao
-       .penirq_recheck_delay_usecs = 1,
-
-};
-
 //add by zhao
 #define LEN_TO_PIX(x)  (unsigned int)( 320 * (x) / 47 )
 #define KEY1_X                 6.3
@@ -250,7 +234,7 @@ static struct KeyInfo panel_key_info[]={
 {KEY1_LEFT, KEY1_RIGHT, KEY_HOME, 0},
 {KEY2_LEFT, KEY2_RIGHT, KEY_MENU, 0},
 {KEY3_LEFT, KEY3_RIGHT, KEY_BACK, 0},
-{KEY4_LEFT, KEY4_RIGHT, KEY_FIND, 0},
+{KEY4_LEFT, KEY4_RIGHT, KEY_SEARCH, 0},
 };
 //end by zhao
 
@@ -342,7 +326,8 @@ static void null_wait_for_sync(void)
 
 static void xpt2046_rx(void *xpt)
 {
-       struct xpt2046          *ts = xpt;
+       struct xpt2046          *ts = xpt;      
+       struct xpt2046_platform_data    *pdata = ts->spi->dev.platform_data;
        struct xpt2046_packet   *packet = ts->packet;
        unsigned                Rt = 1;
        u16                     x, y;
@@ -421,7 +406,7 @@ static void xpt2046_rx(void *xpt)
                        }
                                        
                }
-               else if (y <= xpt2046_info.y_max)
+               else if (y <= pdata->y_max)
                {
                        if (!ts->pendown) {
                                input_report_key(input, BTN_TOUCH, 1);
@@ -729,7 +714,13 @@ static int __devinit setup_pendown(struct spi_device *spi, struct xpt2046 *ts)
                ts->get_pendown_state = pdata->get_pendown_state;
                return 0;
        }
-
+       
+    if (pdata->io_init) {
+        err = pdata->io_init();
+        if (err)
+            dev_err(&spi->dev, "xpt2046 io_init fail\n");
+    }
+    
        err = gpio_request(pdata->gpio_pendown, "xpt2046_pendown");
        if (err) {
                dev_err(&spi->dev, "failed to request pendown GPIO%d\n",
@@ -737,6 +728,15 @@ static int __devinit setup_pendown(struct spi_device *spi, struct xpt2046 *ts)
                return err;
        }
 
+    err = gpio_direction_input(pdata->gpio_pendown);
+    if (err) {
+               dev_err(&spi->dev, "failed to switch GPIO to input%d\n",
+                               pdata->gpio_pendown);
+               return err;
+    }
+    
+    gpio_pull_updown(pdata->gpio_pendown,GPIOPullUp);
+
        ts->gpio_pendown = pdata->gpio_pendown;
        return 0;
 }
@@ -762,12 +762,11 @@ static int __devinit xpt2046_probe(struct spi_device *spi)
                spi->irq = gpio_to_irq(spi->irq);
                dev_dbg(&spi->dev, "no IRQ?\n");
        }
-       
-       if (!pdata) {
-               xpt2046printk("-----------------pdata is null -------------------------\n");
-               spi->dev.platform_data = &xpt2046_info;
-               pdata = spi->dev.platform_data;
-       }
+
+    if (!pdata) {
+        dev_err(&spi->dev, "empty platform_data\n");
+        return -EFAULT;
+    }
 
        /* don't exceed max specified sample rate */
        if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
@@ -818,8 +817,8 @@ static int __devinit xpt2046_probe(struct spi_device *spi)
                ts->filter_cleanup = pdata->filter_cleanup;
        } else if (pdata->debounce_max) {
                ts->debounce_max = pdata->debounce_max;
-               if (ts->debounce_max < DEBOUNCE_REPTIME)
-                       ts->debounce_max = DEBOUNCE_REPTIME;
+               if (ts->debounce_max < pdata->debounce_rep)
+                       ts->debounce_max = pdata->debounce_rep;
                ts->debounce_tol = pdata->debounce_tol;
                ts->debounce_rep = pdata->debounce_rep;
                ts->filter = xpt2046_debounce;
@@ -1004,7 +1003,7 @@ static int __init xpt2046_init(void)
 {
        return spi_register_driver(&xpt2046_driver);
 }
-module_init(xpt2046_init);
+late_initcall_sync(xpt2046_init);
 
 static void __exit xpt2046_exit(void)
 {