From patchwork Tue Jun 2 09:33:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 6527901 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 71ABE9F1CC for ; Tue, 2 Jun 2015 09:34:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7445120531 for ; Tue, 2 Jun 2015 09:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C49F2052A for ; Tue, 2 Jun 2015 09:33:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755657AbbFBJdz (ORCPT ); Tue, 2 Jun 2015 05:33:55 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:58955 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754508AbbFBJdy (ORCPT ); Tue, 2 Jun 2015 05:33:54 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id t529XkLP029836; Tue, 2 Jun 2015 04:33:46 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t529XjUp023457; Tue, 2 Jun 2015 04:33:45 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Tue, 2 Jun 2015 04:33:45 -0500 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t529XdDo018133; Tue, 2 Jun 2015 04:33:41 -0500 Message-ID: <556D786E.60003@ti.com> Date: Tue, 2 Jun 2015 12:33:34 +0300 From: Roger Quadros User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: , CC: , , , , Subject: [PATCH v2] Input: pixcir_i2c_ts - Add RESET gpio References: <1423227190-10943-1-git-send-email-rogerq@ti.com> In-Reply-To: <1423227190-10943-1-git-send-email-rogerq@ti.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The controller has a RESET pin which is usually controlled over a GPIO line. If such a GPIO is provided, perform a RESET during probe. Signed-off-by: Roger Quadros --- .../bindings/input/touchscreen/pixcir_i2c_ts.txt | 3 ++ drivers/input/touchscreen/pixcir_i2c_ts.c | 37 ++++++++++++++++++++-- include/linux/input/pixcir_ts.h | 1 + 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt index 6e55109..8eb240a 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt @@ -8,6 +8,9 @@ Required properties: - touchscreen-size-x: horizontal resolution of touchscreen (in pixels) - touchscreen-size-y: vertical resolution of touchscreen (in pixels) +Optional properties: +- reset-gpio: GPIO connected to the RESET line of the chip + Example: i2c@00000000 { diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 2c21071..80c956d 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -51,6 +51,19 @@ struct pixcir_report_data { struct pixcir_touch touches[PIXCIR_MAX_SLOTS]; }; +static void pixcir_reset(struct pixcir_i2c_ts_data *tsdata) +{ + const struct pixcir_ts_platform_data *pdata = tsdata->pdata; + + if (gpio_is_valid(pdata->gpio_reset)) { + gpio_set_value(pdata->gpio_reset, 1); + ndelay(100); /* datasheet section 1.2.3 says 80ns min. */ + gpio_set_value(pdata->gpio_reset, 0); + /* wait for controller ready. 100ms guess. */ + msleep(100); + } +} + static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata, struct pixcir_report_data *report) { @@ -428,7 +441,8 @@ static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev) pdata->chip = *(const struct pixcir_i2c_chip_data *)match->data; pdata->gpio_attb = of_get_named_gpio(np, "attb-gpio", 0); - /* gpio_attb validity is checked in probe */ + pdata->gpio_reset = of_get_named_gpio(np, "reset-gpio", 0); + /* gpio validity is checked in probe */ if (of_property_read_u32(np, "touchscreen-size-x", &pdata->x_max)) { dev_err(dev, "Failed to get touchscreen-size-x property\n"); @@ -442,8 +456,9 @@ static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev) } pdata->y_max -= 1; - dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__, - pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb); + dev_dbg(dev, "%s: x %d, y %d, ATTB gpio %d, RESET gpio %d\n", __func__, + pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb, + pdata->gpio_reset); return pdata; } @@ -481,6 +496,10 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, return -EINVAL; } + /* RESET gpio is optional */ + if (!gpio_is_valid(pdata->gpio_reset)) + dev_info(dev, "Invalid gpio_reset in pdata\n"); + if (!pdata->chip.max_fingers) { dev_err(dev, "Invalid max_fingers in pdata\n"); return -EINVAL; @@ -530,6 +549,16 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, input_set_drvdata(input, tsdata); + if (gpio_is_valid(pdata->gpio_reset)) { + error = devm_gpio_request_one(dev, pdata->gpio_reset, + GPIOF_OUT_INIT_LOW, + "pixcir_i2c_reset"); + if (error) { + dev_err(dev, "Failed to request RESET gpio\n"); + return error; + } + } + error = devm_gpio_request_one(dev, pdata->gpio_attb, GPIOF_DIR_IN, "pixcir_i2c_attb"); if (error) { @@ -545,6 +574,8 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, return error; } + pixcir_reset(tsdata); + /* Always be in IDLE mode to save power, device supports auto wake */ error = pixcir_set_power_mode(tsdata, PIXCIR_POWER_IDLE); if (error) { diff --git a/include/linux/input/pixcir_ts.h b/include/linux/input/pixcir_ts.h index 7bae83b..5b204dd 100644 --- a/include/linux/input/pixcir_ts.h +++ b/include/linux/input/pixcir_ts.h @@ -58,6 +58,7 @@ struct pixcir_ts_platform_data { int x_max; int y_max; int gpio_attb; /* GPIO connected to ATTB line */ + int gpio_reset; /* GPIO to RESET line. Set to -1 if unused */ struct pixcir_i2c_chip_data chip; };