OSDN Git Service

input: it7258_ts_i2c: add low reset and reset delay support
authorShantanu Jain <shjain@codeaurora.org>
Tue, 19 May 2015 09:59:26 +0000 (15:29 +0530)
committerAbinaya P <abinayap@codeaurora.org>
Wed, 3 Aug 2016 06:20:18 +0000 (11:50 +0530)
Add low reset gpio and delay reset support for ITE tech
driver.
ITE tech controller support low reset gpio configuration. This
property is parsed from the DT, and reset gpio is set to low.
Reset delay value is also parsed from DT which is required by the
ITE tech controller.

Change-Id: I314677747e8bbbcb273cd898376bbe03197c8c25
Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
Documentation/devicetree/bindings/input/touchscreen/it7258_ts_i2c.txt
drivers/input/touchscreen/it7258_ts_i2c.c

index a43eb3a..832ec34 100644 (file)
@@ -17,6 +17,7 @@ Required properties:
                          same as "interrupts" node. It will also
                          contain active low or active high information.
  - ite,reset-gpio      : reset gpio to control the reset of chip
+ - ite,reset-delay     : reset delay for controller (ms), default 20
 
 Optional properties:
  - avdd-supply         : Analog power supply needed to power device
@@ -41,6 +42,9 @@ Optional properties:
                        config defined in pin groups of interrupt and reset gpio.
                        "pmx_ts_release" : Release configuration of pins, this should specify
                        release config defined in pin groups of interrupt and reset gpio.
+ - ite,low-reset       : boolean, if the controller needs low-state of the reset gpio while
+                         initializing, and reset gpio should be made as high-state to reset the
+                         controller. It means the controller needs "active-high" reset gpio.
 
 Required properties palm-detect-en feature:
  - ite,palm-detect-keycode     : The keycode that is required to be sent when
@@ -70,5 +74,7 @@ Example:
                        ite,panel-coords = <0 0 320 320>;
                        ite,display-coords = <0 0 320 320>;
                        ite,num-fingers = <2>;
+                       ite,reset-delay = <20>;
+                       ite,low-reset;
                };
        };
index 2a161cd..85da132 100644 (file)
 #define PINCTRL_STATE_ACTIVE   "pmx_ts_active"
 #define PINCTRL_STATE_SUSPEND  "pmx_ts_suspend"
 #define PINCTRL_STATE_RELEASE  "pmx_ts_release"
+#define IT_I2C_WAIT            1000
 
 struct FingerData {
        uint8_t xLo;
@@ -163,6 +164,8 @@ struct IT7260_ts_platform_data {
        unsigned int disp_maxx;
        unsigned int disp_maxy;
        unsigned num_of_fingers;
+       unsigned int reset_delay;
+       bool low_reset;
 };
 
 struct IT7260_ts_data {
@@ -285,7 +288,7 @@ static bool IT7260_waitDeviceReady(bool forever, bool slowly)
                        query = CMD_STATUS_BUSY;
 
                if (slowly)
-                       mdelay(1000);
+                       msleep(IT_I2C_WAIT);
                if (!forever)
                        count--;
 
@@ -1259,6 +1262,16 @@ static int IT7260_parse_dt(struct device *dev,
        snprintf(gl_ts->cfg_name, MAX_BUFFER_SIZE, "%s",
                (pdata->cfg_name != NULL) ? pdata->cfg_name : CFG_NAME);
 
+       rc = of_property_read_u32(np, "ite,reset-delay", &temp_val);
+       if (!rc)
+               pdata->reset_delay = temp_val;
+       else if (rc != -EINVAL) {
+               dev_err(dev, "Unable to read reset delay\n");
+               return rc;
+       }
+
+       pdata->low_reset = of_property_read_bool(np, "ite,low-reset");
+
        rc = IT7260_get_dt_coords(dev, "ite,display-coords", pdata);
        if (rc && (rc != -EINVAL))
                return rc;
@@ -1441,12 +1454,14 @@ static int IT7260_ts_probe(struct i2c_client *client,
                if (gpio_request(pdata->reset_gpio, "ite_reset_gpio")) {
                        dev_err(&client->dev,
                                "gpio_request failed for reset GPIO\n");
-                       return -EINVAL;
-               }
-               if (gpio_direction_output(pdata->reset_gpio, 0)) {
-                       dev_err(&client->dev,
-                               "gpio_direction_output for reset GPIO\n");
-                       return -EINVAL;
+               if (pdata->low_reset) {
+                       if (gpio_direction_output(pdata->reset_gpio, 0))
+                               dev_err(&gl_ts->client->dev,
+                                       "gpio_direction_output for reset GPIO\n");
+               } else {
+                       if (gpio_direction_output(pdata->reset_gpio, 1))
+                               dev_err(&gl_ts->client->dev,
+                                       "gpio_direction_output for reset GPIO\n");
                }
                dev_dbg(&gl_ts->client->dev, "Reset GPIO %d\n",
                                                        pdata->reset_gpio);
@@ -1533,9 +1548,9 @@ static int IT7260_ts_probe(struct i2c_client *client,
 #endif
        
        IT7260_i2cWriteNoReadyCheck(BUF_COMMAND, cmd_start, sizeof(cmd_start));
-       mdelay(10);
+       msleep(pdata->reset_delay);
        IT7260_i2cReadNoReadyCheck(BUF_RESPONSE, rsp, sizeof(rsp));
-       mdelay(10);
+       msleep(pdata->reset_delay);
 
        gl_ts->dir = debugfs_create_dir(DEBUGFS_DIR_NAME, NULL);
        if (gl_ts->dir == NULL || IS_ERR(gl_ts->dir)) {