From patchwork Wed Apr 10 21:41:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Hecht X-Patchwork-Id: 2423501 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 82893DF2E5 for ; Wed, 10 Apr 2013 21:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935583Ab3DJVl2 (ORCPT ); Wed, 10 Apr 2013 17:41:28 -0400 Received: from mail-bk0-f48.google.com ([209.85.214.48]:51796 "EHLO mail-bk0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752556Ab3DJVl1 (ORCPT ); Wed, 10 Apr 2013 17:41:27 -0400 Received: by mail-bk0-f48.google.com with SMTP id jf3so474113bkc.7 for ; Wed, 10 Apr 2013 14:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=vPT5UzAL2Cf522OCsVZA7J099QgFi+CM2MZlgrGW2yE=; b=ocJ70ChLHkqToY/LBjsms8iogVJX1hv31aVWXNjYmY17WyYUQKPGvGXj/JK6TepBNh CyWfGBOwrkx7wTv//pd+sJ1iIqKT8yvMqDewQu1MtumrmZWODeFsSHx7s+/NdTBt1Vc4 ljdENCTlTRXrtqJ3jA9OB6GhCRISR1eC2h8BqvSjO3L/gCWwCXMRh2VPJYZXYgXMHGld QKT4CUNpEXht1MZDpt1AE+W52vFrhiyLFia14qYrs0WuHZYM9KDUvvZ+mfV4bpum8zJj 8lQwtCKFxOeywjvicgEiW2hhzzUTiVJjl3behronHYWoQqemQ279BScJrASZ2lI3N9gf fqsg== X-Received: by 10.204.172.80 with SMTP id k16mr1518665bkz.123.1365630085782; Wed, 10 Apr 2013 14:41:25 -0700 (PDT) Received: from localhost.localdomain (g229017229.adsl.alicedsl.de. [92.229.17.229]) by mx.google.com with ESMTPS id io13sm760642bkc.15.2013.04.10.14.41.24 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Apr 2013 14:41:25 -0700 (PDT) From: Bastian Hecht To: linux-sh@vger.kernel.org, linux-input@vger.kernel.org Cc: Laurent Pichart , Magnus Damm , Simon Horman , Kuninori Morimoto , Dmitry Torokhov Subject: [PATCH v3 1/2] input: st1232: Add reset pin handling Date: Wed, 10 Apr 2013 23:41:22 +0200 Message-Id: <1365630083-9758-1-git-send-email-hechtb+renesas@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We add the possiblity to hand over a GPIO number for the reset pin. This way we can remove existing board code that takes care of it and group this information properly in the platform data or in the device tree confguration. The implementation is analogous to the cy8ctmg110 driver, thanks. Signed-off-by: Bastian Hecht --- v3: - Based on Laurent Pinchart's patch: input: st1232: Convert to devm_* infrastructure - use gpio_valid() - reorder probing for reset_gpio data drivers/input/touchscreen/st1232.c | 43 ++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index f091451..874e0ff 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -19,13 +19,16 @@ */ #include +#include #include #include #include #include +#include #include #include #include +#include #define ST1232_TS_NAME "st1232-ts" @@ -48,6 +51,7 @@ struct st1232_ts_data { struct input_dev *input_dev; struct st1232_ts_finger finger[MAX_FINGERS]; struct dev_pm_qos_request low_latency_req; + int reset_gpio; }; static int st1232_ts_read_data(struct st1232_ts_data *ts) @@ -139,10 +143,17 @@ end: return IRQ_HANDLED; } +static void st1232_ts_power(struct st1232_ts_data *ts, bool poweron) +{ + if (gpio_is_valid(ts->reset_gpio)) + gpio_direction_output(ts->reset_gpio, poweron); +} + static int st1232_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct st1232_ts_data *ts; + struct st1232_pdata *pdata = client->dev.platform_data; struct input_dev *input_dev; int error; @@ -165,6 +176,25 @@ static int st1232_ts_probe(struct i2c_client *client, ts->client = client; ts->input_dev = input_dev; + if (pdata) + ts->reset_gpio = pdata->reset_gpio; + else if (client->dev.of_node) + ts->reset_gpio = of_get_gpio(client->dev.of_node, 0); + else + ts->reset_gpio = -ENODEV; + + if (gpio_is_valid(ts->reset_gpio)) { + error = devm_gpio_request(&client->dev, ts->reset_gpio, NULL); + if (error) { + dev_err(&client->dev, + "Unable to request GPIO pin %d.\n", + ts->reset_gpio); + return error; + } + } + + st1232_ts_power(ts, true); + input_dev->name = "st1232-touchscreen"; input_dev->id.bustype = BUS_I2C; input_dev->dev.parent = &client->dev; @@ -200,7 +230,10 @@ static int st1232_ts_probe(struct i2c_client *client, static int st1232_ts_remove(struct i2c_client *client) { + struct st1232_ts_data *ts = i2c_get_clientdata(client); + device_init_wakeup(&client->dev, 0); + st1232_ts_power(ts, false); return 0; } @@ -209,11 +242,14 @@ static int st1232_ts_remove(struct i2c_client *client) static int st1232_ts_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct st1232_ts_data *ts = i2c_get_clientdata(client); if (device_may_wakeup(&client->dev)) enable_irq_wake(client->irq); - else + else { disable_irq(client->irq); + st1232_ts_power(ts, false); + } return 0; } @@ -221,11 +257,14 @@ static int st1232_ts_suspend(struct device *dev) static int st1232_ts_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct st1232_ts_data *ts = i2c_get_clientdata(client); if (device_may_wakeup(&client->dev)) disable_irq_wake(client->irq); - else + else { + st1232_ts_power(ts, true); enable_irq(client->irq); + } return 0; }