Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752522AbbETH01 (ORCPT ); Wed, 20 May 2015 03:26:27 -0400 Received: from smtp43.i.mail.ru ([94.100.177.103]:54278 "EHLO smtp43.i.mail.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751277AbbETH0Z (ORCPT ); Wed, 20 May 2015 03:26:25 -0400 Date: Wed, 20 May 2015 10:26:20 +0300 From: Evgeniy Dushistov To: Dmitry Torokhov , Daniel Mack Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ads7846: do not ignore pendown-gpio flags Message-ID: <20150520072620.GA8930@fifteen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam: Not detected X-Mras: Ok Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3757 Lines: 111 At current state ads7846 driver ignore GPIO_ACTIVE_LOW, GPIO_ACTIVE_HIGH flags in such dts expression: pendown-gpio = <&gpio5 5 GPIO_ACTIVE_HIGH>; In times of usage arch/arm/.. you can handle this by get_pendown_state callback passed via platform_data, but at now with Device Tree it is impossible to handle 1 as interrupt trigger, this patch fixes this. Test on beagleboard-xm<-SPI->ads7845 It made on top of "ads7846: fix ads7846 driver for work with ads7845", but can applied with "hunks" on top of Linus's master, and it independent of "ads7846: fix ads7846 driver for work with ads7845". Signed-off-by: Evgeniy A. Dushistov --- drivers/input/touchscreen/ads7846.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 76728d4..0a02364 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -140,6 +140,7 @@ struct ads7846 { void (*filter_cleanup)(void *data); int (*get_pendown_state)(void); int gpio_pendown; + bool active_low; void (*wait_for_sync)(void); }; @@ -574,7 +575,7 @@ static int get_pendown_state(struct ads7846 *ts) if (ts->get_pendown_state) return ts->get_pendown_state(); - return !gpio_get_value(ts->gpio_pendown); + return ts->active_low != (!!gpio_get_value(ts->gpio_pendown)); } static void null_wait_for_sync(void) @@ -1108,11 +1109,13 @@ static const struct of_device_id ads7846_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, ads7846_dt_ids); -static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) +static const struct ads7846_platform_data * +ads7846_probe_dt(struct device *dev, bool *pen_active_low) { struct ads7846_platform_data *pdata; struct device_node *node = dev->of_node; const struct of_device_id *match; + enum of_gpio_flags gpio_flags; if (!node) { dev_err(dev, "Device does not have associated DT data\n"); @@ -1163,12 +1166,16 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) pdata->wakeup = of_property_read_bool(node, "linux,wakeup"); - pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0); + pdata->gpio_pendown = of_get_named_gpio_flags(dev->of_node, + "pendown-gpio", + 0, &gpio_flags); + *pen_active_low = !!(gpio_flags & OF_GPIO_ACTIVE_LOW); return pdata; } #else -static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) +static const struct ads7846_platform_data *ads7846_probe_dt( + struct device *dev, bool *pen_active_low) { dev_err(dev, "no platform data defined\n"); return ERR_PTR(-EINVAL); @@ -1183,6 +1190,7 @@ static int ads7846_probe(struct spi_device *spi) struct input_dev *input_dev; unsigned long irq_flags; int err; + bool pen_active_low = true; if (!spi->irq) { dev_dbg(&spi->dev, "no IRQ?\n"); @@ -1226,7 +1234,7 @@ static int ads7846_probe(struct spi_device *spi) pdata = dev_get_platdata(&spi->dev); if (!pdata) { - pdata = ads7846_probe_dt(&spi->dev); + pdata = ads7846_probe_dt(&spi->dev, &pen_active_low); if (IS_ERR(pdata)) { err = PTR_ERR(pdata); goto err_free_mem; @@ -1240,6 +1248,7 @@ static int ads7846_probe(struct spi_device *spi) ts->vref_mv = pdata->vref_mv; ts->swap_xy = pdata->swap_xy; + ts->active_low = pen_active_low; if (pdata->filter != NULL) { if (pdata->filter_init != NULL) { -- 2.3.6 -- /Evgeniy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/