Re: [PATCH v11 0/8] Goodix touchscreen enhancements

2016-01-05 Thread Dmitry Torokhov
Hi Karsten,

On Tue, Jan 5, 2016 at 12:03 PM, Karsten Merker  wrote:
> On Thu, Dec 17, 2015 at 05:13:18PM -0800, Dmitry Torokhov wrote:
>> On Thu, Nov 19, 2015 at 02:26:33PM +0200, Irina Tirdea wrote:
>> > This patchset depends on Dmitry's patch that fixes the
>> > GPIO ACPI API[1], so devm_gpiod_get_optional can be properly
>> > used in the code.
>> >
>> > [1] https://lkml.org/lkml/2015/11/11/465
>>
>> Applied 1 through 5 (see my goodix branch), looking at the rest.
>
> Hello,
>
> as we are getting near to the next merge window, I wanted to
> kindly ask whether there is any news on this.  It would be really
> nice if the complete stack of goodix patches could go into kernel
> 4.5.

There is goodix branch at
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git that we
should be able to merge in 4.5. It has your patches and half of
Irina's (with config dump and ESD support missing at the moment). If
you could give ti a quick spin I'd appreciate it.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V4 0/3] Input: goodix - add axis swapping and axis inversion support

2015-12-17 Thread Dmitry Torokhov
On Sat, Nov 21, 2015 at 02:30:19PM +0100, Karsten Merker wrote:
> Hello,
> 
> this is v4 of my "Input: goodix - add axis swapping and axis inversion
> support" patchset.
> 
> The goodix touchscreen driver has gained device-tree support in kernel
> 4.1, but doesn't currently support the touchscreen-swapped-x-y,
> touchscreen-inverted-x and touchscreen-inverted-y properties.
> On systems which combine a portrait-mode display with a landscape-mode
> touchscreen, such as e.g. the MSI Primo 81 tablet, support for these
> features is necessary to have the touchscreen and the display use the
> same coordinate system.
> 
> With support for axis inversion, the "rotated_screen" flag in the
> driver can also be removed, as "rotated_screen" is just a special case
> of x/y axis inversion.
> 
> This patchset sits on top of the "[PATCH v11 0/8] Goodix touchscreen
> enhancements" series by Irina Tirdea:
> https://www.spinics.net/lists/linux-input/msg42146.html
> 
> The axis swapping has successfully been tested on an MSI Primo 81
> tablet and on a Wexler TAB7200 tablet; the x/y inversion resp. 
> the rotated_screen functionality has successfully been tested on
> a WinBook TW100.

Folded 3 into 1 and applied everything, see my goodix branch.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v11 0/8] Goodix touchscreen enhancements

2015-12-17 Thread Dmitry Torokhov
On Thu, Nov 19, 2015 at 02:26:33PM +0200, Irina Tirdea wrote:
> This patchset depends on Dmitry's patch that fixes the
> GPIO ACPI API[1], so devm_gpiod_get_optional can be properly
> used in the code. 
> 
> [1] https://lkml.org/lkml/2015/11/11/465

Applied 1 through 5 (see my goodix branch), looking at the rest.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v10 6/8] input: touchscreen: imx25 tcq driver

2015-12-17 Thread Dmitry Torokhov
On Mon, Dec 14, 2015 at 02:53:52PM +0100, Markus Pargmann wrote:
> This is a driver for the imx25 ADC/TSC module. It controls the
> touchscreen conversion queue and creates a touchscreen input device.
> The driver currently only supports 4 wire touchscreens. The driver uses
> a simple conversion queue of precharge, touch detection, X measurement,
> Y measurement, precharge and another touch detection.
> 
> This driver uses the regmap from the parent to setup some touch specific
> settings in the core driver and setup a idle configuration with touch
> detection.
> 
> Signed-off-by: Markus Pargmann 
> Signed-off-by: Denis Carikli 
> 
> [fix clock's period calculation]
> [fix calculation of the 'settling' value]
> Signed-off-by: Juergen Borleis 

Acked-by: Dmitry Torokhov 

Please merge with the rest of this MFD device.

> ---
> 
> Notes:
> Changes in v10:
>  - Renamed devicetree properties
> 
> Changes in v9:
>  - Added module description to Kconfig item
>  - Fixed devm_ioremap_resource() return value check to use IS_ERR()
>  - Removed return value of mx25_tcq_create_event_for_4wire()
>  - Renamed most 'ret' variables through 'error'
>  - Removed IRQF_ONESHOT
>  - Rearranged threaded handler to not mix up samples from multiple 
> measurements
> 
> Changes in v7:
>  - Moved clk_prepare_enable() and mx25_tcq_init() into mx25_tcq_open(). 
> This
>was done to be able to use devm_request_threaded_irq().
>  - Cleanup of the probe function through above change
>  - Removed mx25_tcq_remove(), not necessary now
> 
>  drivers/input/touchscreen/Kconfig |   9 +
>  drivers/input/touchscreen/Makefile|   1 +
>  drivers/input/touchscreen/fsl-imx25-tcq.c | 596 
> ++
>  3 files changed, 606 insertions(+)
>  create mode 100644 drivers/input/touchscreen/fsl-imx25-tcq.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index ae33da7ab51f..873bf3697e35 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -811,6 +811,15 @@ config TOUCHSCREEN_USB_COMPOSITE
> To compile this driver as a module, choose M here: the
> module will be called usbtouchscreen.
>  
> +config TOUCHSCREEN_MX25
> + tristate "Freescale i.MX25 touchscreen input driver"
> + depends on MFD_MX25_TSADC
> + help
> +   Enable support for touchscreen connected to your i.MX25.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called fsl-imx25-tcq.
> +
>  config TOUCHSCREEN_MC13783
>   tristate "Freescale MC13783 touchscreen input driver"
>   depends on MFD_MC13XXX
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index cbaa6abb08da..77a2ac54101a 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -45,6 +45,7 @@ obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o
>  obj-$(CONFIG_TOUCHSCREEN_IPROC)  += bcm_iproc_tsc.o
>  obj-$(CONFIG_TOUCHSCREEN_LPC32XX)+= lpc32xx_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_MAX11801)   += max11801_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_MX25)   += fsl-imx25-tcq.o
>  obj-$(CONFIG_TOUCHSCREEN_MC13783)+= mc13783_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_MCS5000)+= mcs5000_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_MIGOR)  += migor_ts.o
> diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c 
> b/drivers/input/touchscreen/fsl-imx25-tcq.c
> new file mode 100644
> index ..fe9877a6af9e
> --- /dev/null
> +++ b/drivers/input/touchscreen/fsl-imx25-tcq.c
> @@ -0,0 +1,596 @@
> +/*
> + * Copyright (C) 2014-2015 Pengutronix, Markus Pargmann 
> + *
> + * This program is free software; you can redistribute it and/or modify it 
> under
> + * the terms of the GNU General Public License version 2 as published by the
> + * Free Software Foundation.
> + *
> + * Based on driver from 2011:
> + *   Juergen Beisert, Pengutronix 
> + *
> + * This is the driver for the imx25 TCQ (Touchscreen Conversion Queue)
> + * connected to the imx25 ADC.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static const char mx25_tcq_name[] = "mx25-tcq";
> +
> +enum mx25_tcq_mode {
> + MX25_TS_4WIRE,
> +};
> +
> +struct mx25_tcq_priv {
> + struct regmap *regs;
> + struct regmap *core_regs;
> + struct input_dev *idev;
> + enum mx25_tcq_mode mode;
> +

Re: [PATCH 2/2] Input: add touchscreen support for TS-4800

2015-12-16 Thread Dmitry Torokhov
Hi Damien,

On Thu, Dec 10, 2015 at 11:11:12AM -0500, Damien Riegel wrote:
> On this board, the touchscreen, an ads7843, is not handled directly by
> Linux but by a companion FPGA. This FPGA is memory-mapped and the IP
> design is very similar to the mk712.
>
> This commit adds the support for this IP.
>
> Signed-off-by: Damien Riegel 
> ---
>  drivers/input/touchscreen/Kconfig |  15 +++
>  drivers/input/touchscreen/Makefile|   1 +
>  drivers/input/touchscreen/ts4800-ts.c | 238 
> ++
>  3 files changed, 254 insertions(+)
>  create mode 100644 drivers/input/touchscreen/ts4800-ts.c
>
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index deb14c1..2d3b2f2 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -914,6 +914,21 @@ config TOUCHSCREEN_TOUCHIT213
>To compile this driver as a module, choose M here: the
>module will be called touchit213.
>  
> +config TOUCHSCREEN_TS4800
> + tristate "TS-4800 touchscreen"
> + depends on HAS_IOMEM && OF
> + select MFD_SYSCON

You also need "select INPUT_POLLDEV" here.

> + help
> +  Say Y here if you have a touchscreen on a TS-4800 board.
> +
> +  On TS-4800, the touchscreen is not handled directly by Linux but by
> +  a companion FPGA.
> +
> +  If unsure, say N.
> +
> +  To compile this driver as a module, choose M here: the
> +  module will be called ts4800_ts.
> +
>  config TOUCHSCREEN_TSC_SERIO
>   tristate "TSC-10/25/40 serial touchscreen support"
>   select SERIO
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 1b79cc0..5d81ba8c 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -67,6 +67,7 @@ obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o
>  obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o
>  obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o
>  obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o
> +obj-$(CONFIG_TOUCHSCREEN_TS4800) += ts4800-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_TSC_SERIO) += tsc40.o
>  obj-$(CONFIG_TOUCHSCREEN_TSC2005) += tsc2005.o
>  obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o
> diff --git a/drivers/input/touchscreen/ts4800-ts.c 
> b/drivers/input/touchscreen/ts4800-ts.c
> new file mode 100644
> index 000..1e81b17
> --- /dev/null
> +++ b/drivers/input/touchscreen/ts4800-ts.c
> @@ -0,0 +1,238 @@
> +/*
> + * Touchscreen driver for the TS-4800 board
> + *
> + * Copyright (c) 2015 - Savoir-faire Linux
> + *
> + * This file is licensed under the terms of the GNU General Public
> + * License version 2. This program is licensed "as is" without any
> + * warranty of any kind, whether express or implied.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* polling interval in ms*/
> +#define POLL_INTERVAL   3
> +
> +/* sensor values are 12-bit wide */
> +#define MAX_12BIT   ((1 << 12) - 1)
> +
> +#define PENDOWN_MASK0x1
> +
> +#define X_OFFSET0x0
> +#define Y_OFFSET0x2
> +
> +struct ts4800_ts {
> + struct input_polled_dev *poll_dev;
> + struct device   *dev;
> + charphys[32];
> +
> + void __iomem*base;
> + struct regmap   *regmap;
> + unsigned intreg;
> + unsigned intbit;
> +
> + boolpendown;
> + int debounce;
> +};
> +
> +static void ts4800_ts_open(struct input_polled_dev *dev)
> +{
> + struct ts4800_ts *ts = dev->private;
> + int ret;
> +
> + ret = regmap_update_bits(ts->regmap, ts->reg,
> + 1 << ts->bit, 1  << ts->bit);

Instead of doing shift every time you can store already shifted value in
ts->bit.

> + if (ret)
> + dev_warn(ts->dev, "Failed to enable touchscreen\n");
> +}
> +
> +static void ts4800_ts_close(struct input_polled_dev *dev)
> +{
> + struct ts4800_ts *ts = dev->private;
> + int ret;
> +
> + ret = regmap_update_bits(ts->regmap, ts->reg,
> + 1 << ts->bit, 0);
> + if (ret)
> + dev_warn(ts->dev, "Failed to disable touchscreen\n");
> +
> +}
> +
> +static void ts4800_ts_poll(struct input_polled_dev *dev)
> +{
> + struct input_dev *input_dev = dev->input;
> + struct ts4800_ts *ts = dev->private;
> + u16 last_x = readw(ts->base + X_OFFSET);
> + u16 last_y = readw(ts->base + Y_OFFSET);
> + bool pendown = last_x & PENDOWN_MASK;
> +
> + if (!pendown && ts->pendown) {
> + ts->pendown = false;
> + ts->debounce = 1;
> + input_report_key(input_dev, BTN_TOUCH, 0);
> + input_sync(input_dev);
> + }
> +
> + if (pendown) {
> + if (ts->debounce) {
> + ts->debounce = 0;

This looks like a boolean, but I think having a counter for debounce is
more natural.

> + return;
> + }
> +
> + if (!ts->pendown) {
> + input_report_key(input_dev, BTN_TOUCH, 1);
> + ts->pendown = true;
> + }
> +
> + last_x = ((~last_x) >> 4) & MAX_12BIT;
> + last_y = ((~last_y) >> 4) & MAX_12BI

Re: [PATCH 2/2] Input: add touchscreen support for TS-4800

2015-12-12 Thread Dmitry Torokhov
Hi Damien,

On Thu, Dec 10, 2015 at 11:11:12AM -0500, Damien Riegel wrote:
> On this board, the touchscreen, an ads7843, is not handled directly by
> Linux but by a companion FPGA. This FPGA is memory-mapped and the IP
> design is very similar to the mk712.

...

> +
> + poll_dev = devm_input_allocate_polled_device(&pdev->dev);
> + if (!poll_dev)
> + return -ENOMEM;

I wonder how useful touchscreen implemented as polling device is. Isn't
there an interrupt line for it?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] touchscreen: pixcir_i2c: Add support for wake and enable gpios

2015-12-01 Thread Dmitry Torokhov
On Sun, Nov 22, 2015 at 04:19:50PM -0600, Rob Herring wrote:
> On Sun, Nov 22, 2015 at 04:57:33PM +0100, Hans de Goede wrote:
> > From: Sander Vermin 
> > 
> > On some devices the wake and enable pins of the pixcir touchscreen
> > controller are connected to gpios and these must be controlled by the
> > driver for the device to operate properly.
> > 
> > Signed-off-by: Sander Vermin 
> > Signed-off-by: Hans de Goede 
> > ---
> > Changes in v2 (Hans de Goede):
> > -Split the changes for dealing with inverted / swapped axis out into a
> >  separate patch
> > -Remove a bunch of dev_info calls to make the driver less chatty
> > -Use devm_gpiod_get_optional as these new gpios are optional
> > -Only msleep after setting enable high if we have an enable pin
> > Changes in v3 (Hans de Goede):
> > -Use "if (ts->gpio_foo)" instead of "if (!IS_ERR_OR_NULL(ts->foo))"
> > -No need to set gpio-s to 1 after requesting them with GPIOD_OUT_HIGH
> > ---
> >  .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  2 ++
> 
> For the binding:
> 
> Acked-by: Rob Herring 

Applied, thank you.

> 
> >  drivers/input/touchscreen/pixcir_i2c_ts.c  | 40 
> > ++
> >  2 files changed, 42 insertions(+)
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt 
> > b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> > index 8eb240a..72ca5ec 100644
> > --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> > @@ -10,6 +10,8 @@ Required properties:
> >  
> >  Optional properties:
> >  - reset-gpio: GPIO connected to the RESET line of the chip
> > +- enable-gpios: GPIO connected to the ENABLE line of the chip
> > +- wake-gpios: GPIO connected to the WAKE line of the chip
> >  
> >  Example:
> >  
> > diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> > b/drivers/input/touchscreen/pixcir_i2c_ts.c
> > index 211408c..22a67c6 100644
> > --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> > +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> > @@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
> > struct input_dev *input;
> > struct gpio_desc *gpio_attb;
> > struct gpio_desc *gpio_reset;
> > +   struct gpio_desc *gpio_enable;
> > +   struct gpio_desc *gpio_wake;
> > const struct pixcir_i2c_chip_data *chip;
> > int max_fingers;/* Max fingers supported in this instance */
> > bool running;
> > @@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct 
> > pixcir_i2c_ts_data *ts,
> > struct device *dev = &ts->client->dev;
> > int ret;
> >  
> > +   if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
> > +   if (ts->gpio_wake)
> > +   gpiod_set_value_cansleep(ts->gpio_wake, 1);
> > +   }
> > +
> > ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE);
> > if (ret < 0) {
> > dev_err(dev, "%s: can't read reg 0x%x : %d\n",
> > @@ -228,6 +235,11 @@ static int pixcir_set_power_mode(struct 
> > pixcir_i2c_ts_data *ts,
> > return ret;
> > }
> >  
> > +   if (mode == PIXCIR_POWER_HALT) {
> > +   if (ts->gpio_wake)
> > +   gpiod_set_value_cansleep(ts->gpio_wake, 0);
> > +   }
> > +
> > return 0;
> >  }
> >  
> > @@ -302,6 +314,11 @@ static int pixcir_start(struct pixcir_i2c_ts_data *ts)
> > struct device *dev = &ts->client->dev;
> > int error;
> >  
> > +   if (ts->gpio_enable) {
> > +   gpiod_set_value_cansleep(ts->gpio_enable, 1);
> > +   msleep(100);
> > +   }
> > +
> > /* LEVEL_TOUCH interrupt with active low polarity */
> > error = pixcir_set_int_mode(ts, PIXCIR_INT_LEVEL_TOUCH, 0);
> > if (error) {
> > @@ -343,6 +360,9 @@ static int pixcir_stop(struct pixcir_i2c_ts_data *ts)
> > /* Wait till running ISR is complete */
> > synchronize_irq(ts->client->irq);
> >  
> > +   if (ts->gpio_enable)
> > +   gpiod_set_value_cansleep(ts->gpio_enable, 0);
> > +
> > return 0;
> >  }
> >  
> > @@ -534,6 +554,26 @@ static int pixcir_i2c_ts_probe(struct i2c_client 
> > *client,
> > return error;
> > }
> >  
> > +   tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake",
> > +   GPIOD_OUT_HIGH);
> > +   if (IS_ERR(tsdata->gpio_wake)) {
> > +   error = PTR_ERR(tsdata->gpio_wake);
> > +   if (error != -EPROBE_DEFER)
> > +   dev_err(dev, "Failed to get wake gpio: %d\n", error);
> > +   return error;
> > +   }
> > +
> > +   tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable",
> > + GPIOD_OUT_HIGH);
> > +   if (IS_ERR(tsdata->gpio_enable)) {
> > +   error = PTR_ERR(tsdata->gpio_enable);
> > +   if (error != -EPROBE_DEFER)
> > +   dev_err(dev, "Failed to get enable gpio: %d\n", error);
> > + 

Re: [PATCH v11 6/8] Input: goodix - add support for ESD

2015-11-27 Thread Dmitry Torokhov
On Fri, Nov 27, 2015 at 05:24:21PM +, Tirdea, Irina wrote:
> 
> 
> > -Original Message-
> > From: Rob Herring [mailto:r...@kernel.org]
> > Sent: 20 November, 2015 17:45
> > To: Tirdea, Irina
> > Cc: Dmitry Torokhov; Bastien Nocera; Aleksei Mamlin; Karsten Merker; 
> > linux-in...@vger.kernel.org; Mark Rutland; Purdila, Octavian;
> > linux-ker...@vger.kernel.org; devicetree@vger.kernel.org
> > Subject: Re: [PATCH v11 6/8] Input: goodix - add support for ESD
> > 
> > On Thu, Nov 19, 2015 at 02:26:39PM +0200, Irina Tirdea wrote:
> > > Add ESD (Electrostatic Discharge) protection mechanism.
> > 
> > [...]
> > 
> > > This is based on Goodix datasheets for GT911 and GT9271 and on Goodix
> > > driver gt9xx.c for Android (publicly available in Android kernel
> > > trees for various devices).
> > >
> > > Signed-off-by: Irina Tirdea 
> > > For the binding: Acked-by: Rob Herring 
> > 
> > You should not have the "For the binding:" part here. It was just a note
> > so it was clear what part I looked at.
> > 
> 
> I saw it done like that in another patch already merged, so I thought it's
> the right way [1]. Dmitry, could you fix this at merge or you need me to
> send another patchset?

No, I can fix it up locally. Let me sort through the latest submission
and I'll let you know if I need any changes.

Thanks!

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios

2015-11-20 Thread Dmitry Torokhov
On Fri, Nov 20, 2015 at 08:19:52PM +0100, Hans de Goede wrote:
> Hi,
> 
> On 20-11-15 19:54, Dmitry Torokhov wrote:
> >On Fri, Nov 20, 2015 at 02:24:49PM +0100, Hans de Goede wrote:
> >>From: Sander Vermin 
> >>
> >>On some devices the wake and enable pins of the pixcir touchscreen
> >>controller are connected to gpios and these must be controlled by the
> >>driver for the device to operate properly.
> >>
> >>Signed-off-by: Sander Vermin 
> >>Signed-off-by: Hans de Goede 
> >>---
> >>Changes in v2 (Hans de Goede):
> >>-Split the changes for dealing with inverted / swapped axis out into a
> >>  separate patch
> >>-Remove a bunch of dev_info calls to make the driver less chatty
> >>-Use devm_gpiod_get_optional as these new gpios are optional
> >>-Only msleep after setting enable high if we have an enable pin
> >>---
> >>  .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  2 +
> >>  drivers/input/touchscreen/pixcir_i2c_ts.c  | 46 
> >> ++
> >>  2 files changed, 48 insertions(+)
> >>
> >>diff --git 
> >>a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt 
> >>b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> >>index 8eb240a..72ca5ec 100644
> >>--- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> >>+++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> >>@@ -10,6 +10,8 @@ Required properties:
> >>
> >>  Optional properties:
> >>  - reset-gpio: GPIO connected to the RESET line of the chip
> >>+- enable-gpios: GPIO connected to the ENABLE line of the chip
> >>+- wake-gpios: GPIO connected to the WAKE line of the chip
> >>
> >>  Example:
> >>
> >>diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> >>b/drivers/input/touchscreen/pixcir_i2c_ts.c
> >>index 211408c..b75ef65 100644
> >>--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> >>+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> >>@@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
> >>struct input_dev *input;
> >>struct gpio_desc *gpio_attb;
> >>struct gpio_desc *gpio_reset;
> >>+   struct gpio_desc *gpio_enable;
> >>+   struct gpio_desc *gpio_wake;
> >>const struct pixcir_i2c_chip_data *chip;
> >>int max_fingers;/* Max fingers supported in this instance */
> >>bool running;
> >>@@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct 
> >>pixcir_i2c_ts_data *ts,
> >>struct device *dev = &ts->client->dev;
> >>int ret;
> >>
> >>+   if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
> >>+   if (!IS_ERR_OR_NULL(ts->gpio_wake))
> >>+   gpiod_set_value_cansleep(ts->gpio_wake, 1);
> >>+   }
> >>+
> >>ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE);
> >>if (ret < 0) {
> >>dev_err(dev, "%s: can't read reg 0x%x : %d\n",
> >>@@ -228,6 +235,11 @@ static int pixcir_set_power_mode(struct 
> >>pixcir_i2c_ts_data *ts,
> >>return ret;
> >>}
> >>
> >>+   if (mode == PIXCIR_POWER_HALT) {
> >>+   if (!IS_ERR_OR_NULL(ts->gpio_wake))
> >>+   gpiod_set_value_cansleep(ts->gpio_wake, 0);
> >>+   }
> >>+
> >>return 0;
> >>  }
> >>
> >>@@ -302,6 +314,11 @@ static int pixcir_start(struct pixcir_i2c_ts_data *ts)
> >>struct device *dev = &ts->client->dev;
> >>int error;
> >>
> >>+   if (!IS_ERR_OR_NULL(ts->gpio_enable)) {
> >>+   gpiod_set_value_cansleep(ts->gpio_enable, 1);
> >>+   msleep(100);
> >>+   }
> >>+
> >>/* LEVEL_TOUCH interrupt with active low polarity */
> >>error = pixcir_set_int_mode(ts, PIXCIR_INT_LEVEL_TOUCH, 0);
> >>if (error) {
> >>@@ -343,6 +360,9 @@ static int pixcir_stop(struct pixcir_i2c_ts_data *ts)
> >>/* Wait till running ISR is complete */
> >>synchronize_irq(ts->client->irq);
> >>
> >>+   if (!IS_ERR_OR_NULL(ts->gpio_enable))
> >>+   gpiod_set_value_cansleep(ts->gpio_enable, 0);
> >>+
> >>return 0;
> >>  }
> >>
> >>@@ -534,6 +554,24 @@ static int p

Re: [PATCH v2 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios

2015-11-20 Thread Dmitry Torokhov
On Fri, Nov 20, 2015 at 02:24:49PM +0100, Hans de Goede wrote:
> From: Sander Vermin 
> 
> On some devices the wake and enable pins of the pixcir touchscreen
> controller are connected to gpios and these must be controlled by the
> driver for the device to operate properly.
> 
> Signed-off-by: Sander Vermin 
> Signed-off-by: Hans de Goede 
> ---
> Changes in v2 (Hans de Goede):
> -Split the changes for dealing with inverted / swapped axis out into a
>  separate patch
> -Remove a bunch of dev_info calls to make the driver less chatty
> -Use devm_gpiod_get_optional as these new gpios are optional
> -Only msleep after setting enable high if we have an enable pin
> ---
>  .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  2 +
>  drivers/input/touchscreen/pixcir_i2c_ts.c  | 46 
> ++
>  2 files changed, 48 insertions(+)
> 
> diff --git 
> a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt 
> b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> index 8eb240a..72ca5ec 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> @@ -10,6 +10,8 @@ Required properties:
>  
>  Optional properties:
>  - reset-gpio: GPIO connected to the RESET line of the chip
> +- enable-gpios: GPIO connected to the ENABLE line of the chip
> +- wake-gpios: GPIO connected to the WAKE line of the chip
>  
>  Example:
>  
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 211408c..b75ef65 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
>   struct input_dev *input;
>   struct gpio_desc *gpio_attb;
>   struct gpio_desc *gpio_reset;
> + struct gpio_desc *gpio_enable;
> + struct gpio_desc *gpio_wake;
>   const struct pixcir_i2c_chip_data *chip;
>   int max_fingers;/* Max fingers supported in this instance */
>   bool running;
> @@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct 
> pixcir_i2c_ts_data *ts,
>   struct device *dev = &ts->client->dev;
>   int ret;
>  
> + if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
> + gpiod_set_value_cansleep(ts->gpio_wake, 1);
> + }
> +
>   ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE);
>   if (ret < 0) {
>   dev_err(dev, "%s: can't read reg 0x%x : %d\n",
> @@ -228,6 +235,11 @@ static int pixcir_set_power_mode(struct 
> pixcir_i2c_ts_data *ts,
>   return ret;
>   }
>  
> + if (mode == PIXCIR_POWER_HALT) {
> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
> + gpiod_set_value_cansleep(ts->gpio_wake, 0);
> + }
> +
>   return 0;
>  }
>  
> @@ -302,6 +314,11 @@ static int pixcir_start(struct pixcir_i2c_ts_data *ts)
>   struct device *dev = &ts->client->dev;
>   int error;
>  
> + if (!IS_ERR_OR_NULL(ts->gpio_enable)) {
> + gpiod_set_value_cansleep(ts->gpio_enable, 1);
> + msleep(100);
> + }
> +
>   /* LEVEL_TOUCH interrupt with active low polarity */
>   error = pixcir_set_int_mode(ts, PIXCIR_INT_LEVEL_TOUCH, 0);
>   if (error) {
> @@ -343,6 +360,9 @@ static int pixcir_stop(struct pixcir_i2c_ts_data *ts)
>   /* Wait till running ISR is complete */
>   synchronize_irq(ts->client->irq);
>  
> + if (!IS_ERR_OR_NULL(ts->gpio_enable))
> + gpiod_set_value_cansleep(ts->gpio_enable, 0);
> +
>   return 0;
>  }
>  
> @@ -534,6 +554,24 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
>   return error;
>   }
>  
> + tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake",
> + GPIOD_OUT_HIGH);
> + if (IS_ERR(tsdata->gpio_wake)) {
> + error = PTR_ERR(tsdata->gpio_wake);
> + if (error != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get wake gpio: %d\n", error);
> + return error;
> + }
> +
> + tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable",
> +   GPIOD_OUT_HIGH);
> + if (IS_ERR(tsdata->gpio_enable)) {
> + error = PTR_ERR(tsdata->gpio_enable);
> + if (error != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get enable gpio: %d\n", error);
> + return error;
> + }
> +
>   error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr,
> IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> client->name, tsdata);
> @@ -542,6 +580,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
>   return error;
>   }
>  
> +

Re: [PATCH 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios

2015-11-20 Thread Dmitry Torokhov
On Fri, Nov 20, 2015 at 12:17:10PM +0100, Hans de Goede wrote:
> From: Sander Vermin 
> 
> On some devices the wake and enable pins of the pixcir touchscreen
> controller are connected to gpios and these must be controlled by the
> driver for the device to operate properly.
> 
> Signed-off-by: Sander Vermin 
> Signed-off-by: Hans de Goede 
> ---
> Changes in v2 (Hans de Goede):
> -Split the changes for dealing with inverted / swapped axis out into a
>  separate patch
> -Remove a bunch of dev_info calls to make the driver less chatty
> -Use devm_gpiod_get_optional as these new gpios are optional
> -Only msleep after setting enable high if we have an enable pin
> ---
>  .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  2 +
>  drivers/input/touchscreen/pixcir_i2c_ts.c  | 46 
> ++
>  2 files changed, 48 insertions(+)
> 
> diff --git 
> a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt 
> b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> index 8eb240a..72ca5ec 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> @@ -10,6 +10,8 @@ Required properties:
>  
>  Optional properties:
>  - reset-gpio: GPIO connected to the RESET line of the chip
> +- enable-gpios: GPIO connected to the ENABLE line of the chip
> +- wake-gpios: GPIO connected to the WAKE line of the chip
>  
>  Example:
>  
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 211408c..b75ef65 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
>   struct input_dev *input;
>   struct gpio_desc *gpio_attb;
>   struct gpio_desc *gpio_reset;
> + struct gpio_desc *gpio_enable;
> + struct gpio_desc *gpio_wake;
>   const struct pixcir_i2c_chip_data *chip;
>   int max_fingers;/* Max fingers supported in this instance */
>   bool running;
> @@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct 
> pixcir_i2c_ts_data *ts,
>   struct device *dev = &ts->client->dev;
>   int ret;
>  
> + if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
> + gpiod_set_value_cansleep(ts->gpio_wake, 1);

I believe you error out in case when IS_ERR(ts->gpio_wake) is true, so I
wonder if we should simply use

if (ts->gpio_wake)
gpiod_set_value_cansleep(ts->gpio_wake, 1);

here and elsewhere.

No need to resubmit, just let me know.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v11 6/8] Input: goodix - add support for ESD

2015-11-20 Thread Dmitry Torokhov
On Fri, Nov 20, 2015 at 7:44 AM, Rob Herring  wrote:
> On Thu, Nov 19, 2015 at 02:26:39PM +0200, Irina Tirdea wrote:
>> Add ESD (Electrostatic Discharge) protection mechanism.
>
> [...]
>
>> This is based on Goodix datasheets for GT911 and GT9271 and on Goodix
>> driver gt9xx.c for Android (publicly available in Android kernel
>> trees for various devices).
>>
>> Signed-off-by: Irina Tirdea 
>> For the binding: Acked-by: Rob Herring 
>
> You should not have the "For the binding:" part here. It was just a note
> so it was clear what part I looked at.
>
> It is preferred to split DT bindings to separate patches for this
> reason.
>

It however does not make sense if one wants to research when and why
something was changed. We do not split patches to .h files from .c
either.

Whenever I can I merge the driver and dt binding changes together if
they have been posted and reviewed as separate patches. The
Acks/Reviewed are mostly important for maintainers anyway.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v11 4/8] Input: goodix - add power management support

2015-11-19 Thread Dmitry Torokhov
On Thu, Nov 19, 2015 at 2:18 PM, Rafael J. Wysocki  wrote:
> Hi,
>
> On Thu, Nov 19, 2015 at 7:24 PM, Dmitry Torokhov
>  wrote:
>> On Thu, Nov 19, 2015 at 02:26:37PM +0200, Irina Tirdea wrote:
>>> Implement suspend/resume for goodix driver.
>>>
>
> [cut]
>
>>>
>>> +static int __maybe_unused goodix_suspend(struct device *dev)
>>> +{
>>> + struct i2c_client *client = to_i2c_client(dev);
>>> + struct goodix_ts_data *ts = i2c_get_clientdata(client);
>>> + int error;
>>> +
>>> + /* We need gpio pins to suspend/resume */
>>> + if (!ts->gpiod_int || !ts->gpiod_rst)
>>> + return 0;
>>> +
>>> + wait_for_completion(&ts->firmware_loading_complete);
>>
>> This is not that nice as it may lead to angry splats from the PM core if
>> firmware loading takes too long and we start suspending before it
>> completes.
>
> What exactly do you mean?  The suspend watchdog or something else?

I was thinking about dpm watchdog that will panic the system if
suspend takes too long. Hmm, this is debug facility and the default
timeout is 60 seconds, so I guess we can ignore my concern.

>
>> Rafael, if we issue pm_stay_awake() before requesting firmware and
>> pm_relax() once it is done, will this prevent the current suspend
>> timeouts?
>
> pm_stay_awake() only works if the checking of wakeup sources is
> enabled which generally depends on what user space does.

I see.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v11 4/8] Input: goodix - add power management support

2015-11-19 Thread Dmitry Torokhov
On Thu, Nov 19, 2015 at 02:26:37PM +0200, Irina Tirdea wrote:
> Implement suspend/resume for goodix driver.
> 
> The suspend and resume process uses the gpio pins.
> If the device ACPI/DT information does not declare gpio pins,
> suspend/resume will not be available for these devices.
> 
> This is based on Goodix datasheets for GT911 and GT9271
> and on Goodix driver gt9xx.c for Android (publicly available
> in Android kernel trees for various devices).
> 
> Signed-off-by: Octavian Purdila 
> Signed-off-by: Irina Tirdea 
> ---
>  drivers/input/touchscreen/goodix.c | 96 
> --
>  1 file changed, 91 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/goodix.c 
> b/drivers/input/touchscreen/goodix.c
> index 0911b0c9..0fd472d 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -45,6 +45,7 @@ struct goodix_ts_data {
>   u16 version;
>   char *cfg_name;
>   struct completion firmware_loading_complete;
> + unsigned long irq_flags;
>  };
>  
>  #define GOODIX_GPIO_INT_NAME "irq"
> @@ -61,6 +62,9 @@ struct goodix_ts_data {
>  #define GOODIX_CONFIG_967_LENGTH 228
>  
>  /* Register defines */
> +#define GOODIX_REG_COMMAND   0x8040
> +#define GOODIX_CMD_SCREEN_OFF0x05
> +
>  #define GOODIX_READ_COOR_ADDR0x814E
>  #define GOODIX_REG_CONFIG_DATA   0x8047
>  #define GOODIX_REG_ID0x8140
> @@ -162,6 +166,11 @@ static int goodix_i2c_write(struct i2c_client *client, 
> u16 reg, const u8 *buf,
>   return ret < 0 ? ret : (ret != 1 ? -EIO : 0);
>  }
>  
> +static int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value)
> +{
> + return goodix_i2c_write(client, reg, &value, sizeof(value));
> +}
> +
>  static int goodix_get_cfg_len(u16 id)
>  {
>   switch (id) {
> @@ -281,6 +290,18 @@ static irqreturn_t goodix_ts_irq_handler(int irq, void 
> *dev_id)
>   return IRQ_HANDLED;
>  }
>  
> +static void goodix_free_irq(struct goodix_ts_data *ts)
> +{
> + devm_free_irq(&ts->client->dev, ts->client->irq, ts);
> +}
> +
> +static int goodix_request_irq(struct goodix_ts_data *ts)
> +{
> + return devm_request_threaded_irq(&ts->client->dev, ts->client->irq,
> +  NULL, goodix_ts_irq_handler,
> +  ts->irq_flags, ts->client->name, ts);
> +}
> +
>  /**
>   * goodix_check_cfg - Checks if config fw is valid
>   *
> @@ -585,7 +606,6 @@ static int goodix_request_input_dev(struct goodix_ts_data 
> *ts)
>  static int goodix_configure_dev(struct goodix_ts_data *ts)
>  {
>   int error;
> - unsigned long irq_flags;
>  
>   goodix_read_config(ts);
>  
> @@ -593,10 +613,8 @@ static int goodix_configure_dev(struct goodix_ts_data 
> *ts)
>   if (error)
>   return error;
>  
> - irq_flags = goodix_irq_flags[ts->int_trigger_type] | IRQF_ONESHOT;
> - error = devm_request_threaded_irq(&ts->client->dev, ts->client->irq,
> -   NULL, goodix_ts_irq_handler,
> -   irq_flags, ts->client->name, ts);
> + ts->irq_flags = goodix_irq_flags[ts->int_trigger_type] | IRQF_ONESHOT;
> + error = goodix_request_irq(ts);
>   if (error) {
>   dev_err(&ts->client->dev, "request IRQ failed: %d\n", error);
>   return error;
> @@ -720,6 +738,73 @@ static int goodix_ts_remove(struct i2c_client *client)
>   return 0;
>  }
>  
> +static int __maybe_unused goodix_suspend(struct device *dev)
> +{
> + struct i2c_client *client = to_i2c_client(dev);
> + struct goodix_ts_data *ts = i2c_get_clientdata(client);
> + int error;
> +
> + /* We need gpio pins to suspend/resume */
> + if (!ts->gpiod_int || !ts->gpiod_rst)
> + return 0;
> +
> + wait_for_completion(&ts->firmware_loading_complete);

This is not that nice as it may lead to angry splats from the PM core if
firmware loading takes too long and we start suspending before it
completes.

Rafael, if we issue pm_stay_awake() before requesting firmware and
pm_relax() once it is done, will this prevent the current suspend
timeouts?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v11 3/8] Input: goodix - write configuration data to device

2015-11-19 Thread Dmitry Torokhov
On Thu, Nov 19, 2015 at 02:26:36PM +0200, Irina Tirdea wrote:
> + if (ts->gpiod_int && ts->gpiod_rst) {
> + /* update device config */
> + ts->cfg_name = kasprintf(GFP_KERNEL, "goodix_%d_cfg.bin",
> +  ts->id);

devm_kasprintf maybe (don't resubmit)?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Input: pixcir_i2c_ts: add wake and enable gpios

2015-11-17 Thread Dmitry Torokhov
On Mon, Nov 16, 2015 at 09:39:06AM -0600, Rob Herring wrote:
> On Sun, Nov 15, 2015 at 04:56:43PM +0100, Sander Vermin wrote:
> > This patch improves the pixcir_i2c_ts touchscreen controller which is used 
> > by the POV PROTAB2 tablet.
> > 
> > On POV PROTAB2 tablet the WAKE and ENABLE gpios are used, and the screen is 
> > rotated, so touchscreen-inverted-x and touchscreen-inverted-y are needed.
> > 
> > In this patch the WAKE and ENABLE gpios are implemented and furtermore the 
> > touchscreen-inverted-x/y and touchscreen-swapped-x-y devicetree options are 
> > implemented.
> 
> Need to fix the line wrapping.

Please split up the gpio handling form coordinate conversion.

> 
> > 
> > Signed-off-by: Sander Vermin 
> > ---
> >  .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  24 ++--
> >  drivers/input/touchscreen/pixcir_i2c_ts.c  | 125 
> > +++--
> >  2 files changed, 135 insertions(+), 14 deletions(-)
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt 
> > b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> > index 8eb240a..5f25e96 100644
> > --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> > @@ -1,15 +1,25 @@
> >  * Pixcir I2C touchscreen controllers
> >  
> >  Required properties:
> > -- compatible: must be "pixcir,pixcir_ts" or "pixcir,pixcir_tangoc"
> > -- reg: I2C address of the chip
> > -- interrupts: interrupt to which the chip is connected
> > -- attb-gpio: GPIO connected to the ATTB line of the chip
> > -- touchscreen-size-x: horizontal resolution of touchscreen (in pixels)
> > -- touchscreen-size-y: vertical resolution of touchscreen (in pixels)
> > +- compatible   : must be "pixcir,pixcir_ts" or 
> > "pixcir,pixcir_tangoc"
> > +- reg  : I2C address of the chip
> > +- interrupts   : interrupt to which the chip is connected
> > +- attb-gpio: GPIO connected to the ATTB line of the chip
> > +- touchscreen-size-x   : horizontal resolution of touchscreen (in 
> > pixels)
> > +- touchscreen-size-y   : vertical resolution of touchscreen (in pixels)
> 
> Please do reformatting in a separate patch.
> 
> >  Optional properties:
> > -- reset-gpio: GPIO connected to the RESET line of the chip
> > +- reset-gpio   : GPIO connected to the RESET line of the chip
> > +- enable-gpios : GPIO connected to the ENABLE line of the chip
> > +- wake-gpios   : GPIO connected to the WAKE line of the chip
> > +- touchscreen-fuzz-x   : horizontal noise value of the absolute input
> > +   device (in pixels)
> > +- touchscreen-fuzz-y   : vertical noise value of the absolute input
> > +   device (in pixels)
> > +- touchscreen-inverted-x: X axis is inverted (boolean)
> > +- touchscreen-inverted-y: Y axis is inverted (boolean)
> > +- touchscreen-swapped-x-y: X and Y axis are swapped (boolean)
> > +   Swapping is done after inverting the axis
> 
> Adding these touchscreen properties are not mentioned in the subject.
> 
> >  
> >  Example:
> >  
> > diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> > b/drivers/input/touchscreen/pixcir_i2c_ts.c
> > index 4b961ad..87f86b5 100644
> > --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> > +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> > @@ -38,6 +38,13 @@ struct pixcir_i2c_ts_data {
> > struct input_dev *input;
> > struct gpio_desc *gpio_attb;
> > struct gpio_desc *gpio_reset;
> > +   struct gpio_desc *gpio_enable;
> > +   struct gpio_desc *gpio_wake;
> > +   u32 max_x;
> > +   u32 max_y;
> > +   bool invert_x;
> > +   bool invert_y;
> > +   bool swap_x_y;
> > const struct pixcir_i2c_chip_data *chip;
> > int max_fingers;/* Max fingers supported in this instance */
> > bool running;
> > @@ -146,12 +153,27 @@ static void pixcir_ts_report(struct 
> > pixcir_i2c_ts_data *ts,
> > slot = slots[i];
> > }
> >  
> > +   if (ts->invert_x)
> > +   touch->x = ts->max_x - touch->x;
> > +
> > +   if (ts->invert_y)
> > +   touch->y = ts->max_y - touch->y;
> > +
> > input_mt_slot(ts->input, slot);
> > input_mt_report_slot_state(ts->input,
> >MT_TOOL_FINGER, true);
> >  
> > -   input_event(ts->input, EV_ABS, ABS_MT_POSITION_X, touch->x);
> > -   input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y, touch->y);
> > +   if (!ts->swap_x_y) {
> > +   input_event(ts->input, EV_ABS, ABS_MT_POSITION_X,
> > +   touch->x);
> > +   input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y,
> > +   touch->y);
> > +   } else {
> > +   

Re: [PATCH] input: st1232.c: Add devicetree attributes

2015-11-17 Thread Dmitry Torokhov
Hi Sander,

On Sun, Nov 15, 2015 at 05:20:47PM +0100, Sander Vermin wrote:
> -static int __maybe_unused st1232_ts_suspend(struct device *dev)
> +#ifdef CONFIG_PM_SLEEP

Why?

> +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);
> + struct st1232_data *data = i2c_get_clientdata(client);
>  
> - if (device_may_wakeup(&client->dev)) {
> - enable_irq_wake(client->irq);
> - } else {
> - disable_irq(client->irq);
> - st1232_ts_power(ts, false);
> - }
> + mutex_lock(&data->input_dev->mutex);
> + if (data->input_dev->users)
> + st1232_stop(data->input_dev);
> + mutex_unlock(&data->input_dev->mutex);
>  
>   return 0;
>  }
>  
> -static int __maybe_unused st1232_ts_resume(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);
> + struct st1232_data *data = i2c_get_clientdata(client);
>  
> - if (device_may_wakeup(&client->dev)) {
> - disable_irq_wake(client->irq);
> - } else {
> - st1232_ts_power(ts, true);
> - enable_irq(client->irq);
> - }
> + mutex_lock(&data->input_dev->mutex);
> + if (data->input_dev->users)
> + st1232_start(data->input_dev);
> + mutex_unlock(&data->input_dev->mutex);
>  
>   return 0;
>  }
> +#endif
>  
>  static SIMPLE_DEV_PM_OPS(st1232_ts_pm_ops,
>st1232_ts_suspend, st1232_ts_resume);
> @@ -282,13 +436,12 @@ static const struct i2c_device_id st1232_ts_id[] = {
>  };
>  MODULE_DEVICE_TABLE(i2c, st1232_ts_id);
>  
> -#ifdef CONFIG_OF

Why?

> -static const struct of_device_id st1232_ts_dt_ids[] = {
> +static const struct of_device_id st1232_of_match[] = {
>   { .compatible = "sitronix,st1232", },
>   { }
>  };
> -MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
> -#endif
> +MODULE_DEVICE_TABLE(of, st1232_of_match);
> +
>  
>  static struct i2c_driver st1232_ts_driver = {
>   .probe  = st1232_ts_probe,
> @@ -296,13 +449,14 @@ static struct i2c_driver st1232_ts_driver = {
>   .id_table   = st1232_ts_id,
>   .driver = {
>   .name   = ST1232_TS_NAME,
> - .of_match_table = of_match_ptr(st1232_ts_dt_ids),
> + .owner  = THIS_MODULE,
> + .of_match_table = st1232_of_match,

Why?

There seems many intermingled changes that are done to the driver, you
need to split them apart and explain why they are needed.

Thanks!

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 6/8] input: touchscreen: imx25 tcq driver

2015-11-17 Thread Dmitry Torokhov
On Mon, Nov 16, 2015 at 01:01:07PM +0100, Markus Pargmann wrote:
> This is a driver for the imx25 ADC/TSC module. It controls the
> touchscreen conversion queue and creates a touchscreen input device.
> The driver currently only supports 4 wire touchscreens. The driver uses
> a simple conversion queue of precharge, touch detection, X measurement,
> Y measurement, precharge and another touch detection.
> 
> This driver uses the regmap from the parent to setup some touch specific
> settings in the core driver and setup a idle configuration with touch
> detection.
> 
> Signed-off-by: Markus Pargmann 
> Signed-off-by: Denis Carikli 
> 
> [fix clock's period calculation]
> [fix calculation of the 'settling' value]
> Signed-off-by: Juergen Borleis 
> ---
> 
> Notes:
> Changes in v7:
>  - Moved clk_prepare_enable() and mx25_tcq_init() into mx25_tcq_open(). 
> This
>was done to be able to use devm_request_threaded_irq().
>  - Cleanup of the probe function through above change
>  - Removed mx25_tcq_remove(), not necessary now
> 
>  drivers/input/touchscreen/Kconfig |   6 +
>  drivers/input/touchscreen/Makefile|   1 +
>  drivers/input/touchscreen/fsl-imx25-tcq.c | 600 
> ++
>  3 files changed, 607 insertions(+)
>  create mode 100644 drivers/input/touchscreen/fsl-imx25-tcq.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index ae33da7ab51f..b44651d33080 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -811,6 +811,12 @@ config TOUCHSCREEN_USB_COMPOSITE
> To compile this driver as a module, choose M here: the
> module will be called usbtouchscreen.
>  
> +config TOUCHSCREEN_MX25
> + tristate "Freescale i.MX25 touchscreen input driver"
> + depends on MFD_MX25_TSADC
> + help
> +   Enable support for touchscreen connected to your i.MX25.
> +

  To compile this driver as a module...

>  config TOUCHSCREEN_MC13783
>   tristate "Freescale MC13783 touchscreen input driver"
>   depends on MFD_MC13XXX
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index cbaa6abb08da..77a2ac54101a 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -45,6 +45,7 @@ obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o
>  obj-$(CONFIG_TOUCHSCREEN_IPROC)  += bcm_iproc_tsc.o
>  obj-$(CONFIG_TOUCHSCREEN_LPC32XX)+= lpc32xx_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_MAX11801)   += max11801_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_MX25)   += fsl-imx25-tcq.o
>  obj-$(CONFIG_TOUCHSCREEN_MC13783)+= mc13783_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_MCS5000)+= mcs5000_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_MIGOR)  += migor_ts.o
> diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c 
> b/drivers/input/touchscreen/fsl-imx25-tcq.c
> new file mode 100644
> index ..c833cd814972
> --- /dev/null
> +++ b/drivers/input/touchscreen/fsl-imx25-tcq.c
> @@ -0,0 +1,600 @@
> +/*
> + * Copyright (C) 2014-2015 Pengutronix, Markus Pargmann 
> + *
> + * This program is free software; you can redistribute it and/or modify it 
> under
> + * the terms of the GNU General Public License version 2 as published by the
> + * Free Software Foundation.
> + *
> + * Based on driver from 2011:
> + *   Juergen Beisert, Pengutronix 
> + *
> + * This is the driver for the imx25 TCQ (Touchscreen Conversion Queue)
> + * connected to the imx25 ADC.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static const char mx25_tcq_name[] = "mx25-tcq";
> +
> +enum mx25_tcq_mode {
> + MX25_TS_4WIRE,
> +};
> +
> +struct mx25_tcq_priv {
> + struct regmap *regs;
> + struct regmap *core_regs;
> + struct input_dev *idev;
> + enum mx25_tcq_mode mode;
> + unsigned int pen_threshold;
> + unsigned int sample_count;
> + unsigned int expected_samples;
> + unsigned int pen_debounce;
> + unsigned int settling_time;
> + struct clk *clk;
> + int irq;
> +};
> +
> +static struct regmap_config mx25_tcq_regconfig = {
> + .fast_io = true,
> + .max_register = 0x5c,
> + .reg_bits = 32,
> + .val_bits = 32,
> + .reg_stride = 4,
> +};
> +
> +static const struct of_device_id mx25_tcq_ids[] = {
> + { .compatible = "fsl,imx25-tcq", },
> + { /* Sentinel */ }
> +};
> +
> +#define TSC_4WIRE_PRE_INDEX 0
> +#define TSC_4WIRE_X_INDEX 1
> +#define TSC_4WIRE_Y_INDEX 2
> +#define TSC_4WIRE_POST_INDEX 3
> +#define TSC_4WIRE_LEAVE 4
> +
> +#define MX25_TSC_DEF_THRESHOLD 80
> +#define TSC_MAX_SAMPLES 16
> +
> +#define MX25_TSC_REPEAT_WAIT 14
> +
> +enum mx25_adc_configurations {
> + MX25_CFG_PRECHARGE = 0,
> + MX25_CFG_TOUCH_DETECT,
> + MX25_CFG_X_MEASUREMENT,
> + MX25_CFG_Y_MEASUREMENT,
> +};
> +
> +#define MX25_PRECHARGE_VALUE (\
> +   

Re: [PATCH v8 3/8] ARM: dt: Binding documentation for imx25 touchscreen controller

2015-11-17 Thread Dmitry Torokhov
On Mon, Nov 16, 2015 at 08:16:09AM -0600, Rob Herring wrote:
> On Mon, Nov 16, 2015 at 01:01:04PM +0100, Markus Pargmann wrote:
> > This is the touchscreen conversion queue binding documentation. It uses
> > the shared imx25 ADC.
> > 
> > Signed-off-by: Markus Pargmann 
> > ---
> > 
> > Notes:
> > Changes in v5:
> >  - Fix signed/unsigned comparison
> >  - Fix unused variable settling_time by putting it in the correct 
> > argument list
> >  - Use continous conversion queue with the repeat feature and a proper
> >repeat-wait. Previously the touchscreen caused massive number of 
> > interrupts.
> > 
> >  .../bindings/input/touchscreen/fsl-mx25-tcq.txt| 29 
> > ++
> >  1 file changed, 29 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/input/touchscreen/fsl-mx25-tcq.txt
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/input/touchscreen/fsl-mx25-tcq.txt 
> > b/Documentation/devicetree/bindings/input/touchscreen/fsl-mx25-tcq.txt
> > new file mode 100644
> > index ..89ab47a3acc1
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/fsl-mx25-tcq.txt
> > @@ -0,0 +1,29 @@
> > +Freescale mx25 TS conversion queue module
> > +
> > +mx25 touchscreen conversion queue module which controls the ADC unit of the
> > +mx25 for attached touchscreens.
> > +
> > +Required properties:
> > + - compatible: Should be "fsl,imx25-tcq".
> > + - reg: Memory range of the device.
> > + - interrupts: Should be the interrupt number associated with this module 
> > within
> > +   the tscadc unit (<0>).
> > + - interrupt-parent: Should be a phandle to the tscadc unit.
> > + - fsl,wires: Should be '<4>' or '<5>'
> > +
> > +Optional properties:
> > + - fsl,pen-debounce: Pen debounce time in nanoseconds.
> > + - fsl,pen-threshold: Pen-down threshold for the touchscreen.
> > + - fsl,settling-time: Settling time in nanoseconds.
> 
> Don't we have standard properties for these?

These are usually controller-specific so no.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] Input: tsc2004 - Document ts2004 dt bindings

2015-11-03 Thread Dmitry Torokhov
On Tue, Nov 03, 2015 at 05:11:56PM -0600, Michael Welling wrote:
> On Tue, Nov 03, 2015 at 02:59:13PM -0800, Dmitry Torokhov wrote:
> > On Tue, Nov 03, 2015 at 09:41:17AM -0600, Michael Welling wrote:
> > > On Tue, Nov 03, 2015 at 09:31:10AM -0600, Rob Herring wrote:
> > > > On Tue, Nov 3, 2015 at 1:21 AM, Dmitry Torokhov
> > > >  wrote:
> > > > > On Mon, Nov 02, 2015 at 02:50:29PM -0600, Michael Welling wrote:
> > > > >> On Mon, Nov 02, 2015 at 09:19:50AM -0600, Rob Herring wrote:
> > > > >> > > +Required properties:
> > > > >> > > + - compatible: "ti,tsc2004"
> > > > >> > > + - interrupts: IRQ specifier
> > > > >> > > + - vio-supply : Regulator specifier
> > > > >> >
> > > > >> > reg property?
> > > > >>
> > > > >> Rob,
> > > > >>
> > > > >> It appears that I missed this in the description.
> > > > >>
> > > > >> Probably because I was following the lead of the ts2005 description.
> > > > >>
> > > > >> How does this look:
> > > > >> - reg : I2C address. 0x48 - 0x4b based on the 
> > > > >> voltage applied to
> > > > >> the AD1 and AD0 inputs on the IC.
> > > > >>
> > > > >
> > > > > How about the version below?
> > > > >
> > > > > Thanks.
> > > > >
> > > > > --
> > > > > Dmitry
> > > > >
> > > > >
> > > > > Input: tsc2004 - document ts2004 dt bindings
> > > 
> > > Just noticed that it says ts2004 instead of tsc2004 in the subject.
> > > Otherwise, I am fine with it.
> > > 
> > > Thanks for the assistance.
> > > 
> > > Still no acks or reviews for the other patches in the series.
> > > I would like for someone to test the tsc2005 support to see if it still 
> > > works.
> > > 
> > > The tsc2004 works very well on the target that I have here.
> > 
> > I folded this patch into the patch #3 and applied everything.
> >
> 
> Great.
> 
> Will this patch series conflict with the patch series to take out the 
> .owner=THIS_MODULE
> from spi_drivers?
> 
> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1004626.html

If he tries to get them in one pass - probably, but the conflicts should
be trivial and should be easily resolved by SPI maintainer and/or Linus.

Or he could split the patch per-subsystem.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] Input: tsc2004 - Document ts2004 dt bindings

2015-11-03 Thread Dmitry Torokhov
On Tue, Nov 03, 2015 at 09:41:17AM -0600, Michael Welling wrote:
> On Tue, Nov 03, 2015 at 09:31:10AM -0600, Rob Herring wrote:
> > On Tue, Nov 3, 2015 at 1:21 AM, Dmitry Torokhov
> >  wrote:
> > > On Mon, Nov 02, 2015 at 02:50:29PM -0600, Michael Welling wrote:
> > >> On Mon, Nov 02, 2015 at 09:19:50AM -0600, Rob Herring wrote:
> > >> > > +Required properties:
> > >> > > + - compatible: "ti,tsc2004"
> > >> > > + - interrupts: IRQ specifier
> > >> > > + - vio-supply : Regulator specifier
> > >> >
> > >> > reg property?
> > >>
> > >> Rob,
> > >>
> > >> It appears that I missed this in the description.
> > >>
> > >> Probably because I was following the lead of the ts2005 description.
> > >>
> > >> How does this look:
> > >> - reg : I2C address. 0x48 - 0x4b based on the voltage 
> > >> applied to
> > >> the AD1 and AD0 inputs on the IC.
> > >>
> > >
> > > How about the version below?
> > >
> > > Thanks.
> > >
> > > --
> > > Dmitry
> > >
> > >
> > > Input: tsc2004 - document ts2004 dt bindings
> 
> Just noticed that it says ts2004 instead of tsc2004 in the subject.
> Otherwise, I am fine with it.
> 
> Thanks for the assistance.
> 
> Still no acks or reviews for the other patches in the series.
> I would like for someone to test the tsc2005 support to see if it still works.
> 
> The tsc2004 works very well on the target that I have here.

I folded this patch into the patch #3 and applied everything.

Thanks!

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] Input: tsc2004 - Document ts2004 dt bindings

2015-11-02 Thread Dmitry Torokhov
On Mon, Nov 02, 2015 at 02:50:29PM -0600, Michael Welling wrote:
> On Mon, Nov 02, 2015 at 09:19:50AM -0600, Rob Herring wrote:
> > > +Required properties:
> > > + - compatible: "ti,tsc2004"
> > > + - interrupts: IRQ specifier
> > > + - vio-supply : Regulator specifier
> > 
> > reg property?
> 
> Rob,
> 
> It appears that I missed this in the description.
> 
> Probably because I was following the lead of the ts2005 description.
> 
> How does this look:
> - reg : I2C address. 0x48 - 0x4b based on the voltage applied 
> to
> the AD1 and AD0 inputs on the IC.
> 

How about the version below?

Thanks.

-- 
Dmitry


Input: tsc2004 - document ts2004 dt bindings

From: Michael Welling 

Adds documentation for the devicetree bindings of the new tsc2004 driver.

Signed-off-by: Michael Welling 
Signed-off-by: Dmitry Torokhov 
---
 .../bindings/input/touchscreen/tsc2005.txt |   34 
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt 
b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
index 09089a6..b80c04b 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
@@ -1,14 +1,15 @@
-* Texas Instruments tsc2005 touchscreen controller
+* Texas Instruments tsc2004 and tsc2005 touchscreen controllers
 
 Required properties:
- - compatible: "ti,tsc2005"
- - reg   : SPI device address
- - spi-max-frequency : Maximal SPI speed
+ - compatible: "ti,tsc2004" or "ti,tsc2005"
+ - reg   : Device address
  - interrupts: IRQ specifier
- - reset-gpios   : GPIO specifier
- - vio-supply : Regulator specifier
+ - spi-max-frequency : Maximum SPI clocking speed of the device
+   (for tsc2005)
 
 Optional properties:
+ - vio-supply: Regulator specifier
+ - reset-gpios   : GPIO specifier for the controller reset line
  - ti,x-plate-ohms   : integer, resistance of the touchscreen's X 
plates
in ohm (defaults to 280)
  - ti,esd-recovery-timeout-ms : integer, if the touchscreen does not respond 
after
@@ -18,6 +19,27 @@ Optional properties:
 
 Example:
 
+&i2c3 {
+   tsc2004@48 {
+   compatible = "ti,tsc2004";
+   reg = <0x48>;
+   vio-supply = <&vio>;
+
+   reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>;
+   interrupts-extended = <&gpio1 27 IRQ_TYPE_EDGE_RISING>;
+
+   touchscreen-fuzz-x = <4>;
+   touchscreen-fuzz-y = <7>;
+   touchscreen-fuzz-pressure = <2>;
+   touchscreen-size-x = <4096>;
+   touchscreen-size-y = <4096>;
+   touchscreen-max-pressure = <2048>;
+
+   ti,x-plate-ohms = <280>;
+   ti,esd-recovery-timeout-ms = <8000>;
+   };
+}
+
 &mcspi1 {
tsc2005@0 {
compatible = "ti,tsc2005";
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] Input: tsc2005 - Separate SPI and core functions

2015-11-02 Thread Dmitry Torokhov
On Fri, Oct 30, 2015 at 07:41:23PM -0500, Michael Welling wrote:
> This patch separates the SPI functionality from core functionality
> that overlaps with the tsc2004.
> 
> Prepares kernel for new tsc2004 driver without much redundant code.
> 
> Signed-off-by: Michael Welling 
> ---
>  drivers/input/touchscreen/Kconfig  |   4 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/tsc2005.c| 709 
> +
>  .../touchscreen/{tsc2005.c => tsc200x-core.c}  | 226 ++-
>  drivers/input/touchscreen/tsc200x-core.h   |  78 +++
>  5 files changed, 162 insertions(+), 856 deletions(-)
>  copy drivers/input/touchscreen/{tsc2005.c => tsc200x-core.c} (72%)
>  create mode 100644 drivers/input/touchscreen/tsc200x-core.h

This was giving me:

Kernel: arch/x86/boot/bzImage is ready  (#1451)
  MODPOST 1447 modules
ERROR: "tsc200x_regmap_config" [drivers/input/touchscreen/tsc2005.ko] undefined!
make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2

I'll fix it up locally by exporting the symbol.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 2/9] Input: goodix - reset device at init

2015-10-31 Thread Dmitry Torokhov
On Fri, Oct 30, 2015 at 09:33:28AM -0700, Dmitry Torokhov wrote:
> On Mon, Oct 19, 2015 at 05:52:39PM +0300, mika.westerb...@linux.intel.com 
> wrote:
> > On Mon, Oct 19, 2015 at 02:32:24PM +, Tirdea, Irina wrote:
> > > 
> > > 
> > > > -Original Message-
> > > > From: linux-input-ow...@vger.kernel.org 
> > > > [mailto:linux-input-ow...@vger.kernel.org] On Behalf Of
> > > > mika.westerb...@linux.intel.com
> > > > Sent: 14 October, 2015 16:44
> > > > To: Dmitry Torokhov
> > > > Cc: Tirdea, Irina; Bastien Nocera; Aleksei Mamlin; Karsten Merker; 
> > > > linux-in...@vger.kernel.org; Mark Rutland; Purdila, Octavian; linux-
> > > > ker...@vger.kernel.org; devicetree@vger.kernel.org
> > > > Subject: Re: [PATCH v9 2/9] Input: goodix - reset device at init
> > > > 
> > > > On Wed, Oct 14, 2015 at 02:18:20PM +0300, 
> > > > mika.westerb...@linux.intel.com wrote:
> > > > > On Tue, Oct 13, 2015 at 11:23:03PM -0700, Dmitry Torokhov wrote:
> > > > > > I understand why one might use acpi_dev_add_driver_gpios() to 
> > > > > > augment
> > > > > > data in ACPI, however here we have completely different issue: 
> > > > > > driver
> > > > > > that expects named gpios gets returned gpio that has nothing to do 
> > > > > > with
> > > > > > what it requested, because gpiolib acpi code always falls back to
> > > > > > unnamed gpio if it does not find named gpio. That can be acceptable 
> > > > > > if
> > > > > > driver uses the same con_id for all requests to gpiolib, but is not
> > > > > > working when driver supplies different con_ids.
> > > > >
> > > > > Right, the ACPI fallback ignores con_id completely and uses only the
> > > > > index.
> > > > >
> > > > > AFAIK there is only one driver using ACPI _CRS index method:
> > > > > sdhci-[acpi|pci].c. If we can convert that to use 
> > > > > acpi_dev_add_driver_gpios()
> > > > > to feed names for card detection GPIOs, I think we can remove the
> > > > > fallback alltogether in favor of named GPIOs for ACPI.
> > > > 
> > > > Nah, there seems to be several drivers relying on this already :-/
> > > 
> > > Would it be possible to add an optional parameter to the GPIO API
> > > to specify whether we want to fall back to indexed GPIOs for ACPI?
> > 
> > I don't think it's a good idea to add ACPI specifics to generic APIs.
> > 
> > I went through ACPI enabled drivers calling GPIO APIs and majority of
> > them are doing this:
> > 
> > static int stk8312_gpio_probe(struct i2c_client *client)
> > {
> > struct device *dev;
> > struct gpio_desc *gpio;
> > int ret;
> > 
> > if (!client)
> > return -EINVAL;
> > 
> > dev = &client->dev;
> > 
> > /* data ready gpio interrupt pin */
> > gpio = devm_gpiod_get_index(dev, STK8312_GPIO, 0, GPIOD_IN);
> > if (IS_ERR(gpio)) {
> > dev_err(dev, "acpi gpio get index failed\n");
> > return PTR_ERR(gpio);
> > }
> > 
> > ret = gpiod_to_irq(gpio);
> >     dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), 
> > ret);
> > 
> > return ret;
> > }
> > 
> > We can drop all this because I2C core already handles GpioInt -> interrupt
> > number translation.
> > 
> > Few drivers are doing something more complex but I think we can still 
> > convert
> > them to use acpi_dev_add_driver_gpios() and eventually get rid of the whole
> > _CRS index lookup.
> 
> cpi_dev_add_driver_gpios() does not really help with generic drivers
> (unless we keep adding more and more board specific data to them). How
> about we keep track of names used and only allow conversion for the
> first name used, like in the patch below?
> 
> -- 
> Dmitry
> 
> gpiolib: tighten up ACPI legacy gpio lookups
> 
> From: Dmitry Torokhov 
> 
> We should not fall back to the legacy unnamed gpio lookup style if the
> driver requests gpios with different names, because we'll give out the same
> gpio twice. Let's keep track of the names that were used for the device and
> only do the fallback for the first name used.
> 
> Signed-

Re: [PATCH v9 2/9] Input: goodix - reset device at init

2015-10-30 Thread Dmitry Torokhov
On Mon, Oct 19, 2015 at 05:52:39PM +0300, mika.westerb...@linux.intel.com wrote:
> On Mon, Oct 19, 2015 at 02:32:24PM +, Tirdea, Irina wrote:
> > 
> > 
> > > -Original Message-
> > > From: linux-input-ow...@vger.kernel.org 
> > > [mailto:linux-input-ow...@vger.kernel.org] On Behalf Of
> > > mika.westerb...@linux.intel.com
> > > Sent: 14 October, 2015 16:44
> > > To: Dmitry Torokhov
> > > Cc: Tirdea, Irina; Bastien Nocera; Aleksei Mamlin; Karsten Merker; 
> > > linux-in...@vger.kernel.org; Mark Rutland; Purdila, Octavian; linux-
> > > ker...@vger.kernel.org; devicetree@vger.kernel.org
> > > Subject: Re: [PATCH v9 2/9] Input: goodix - reset device at init
> > > 
> > > On Wed, Oct 14, 2015 at 02:18:20PM +0300, mika.westerb...@linux.intel.com 
> > > wrote:
> > > > On Tue, Oct 13, 2015 at 11:23:03PM -0700, Dmitry Torokhov wrote:
> > > > > I understand why one might use acpi_dev_add_driver_gpios() to augment
> > > > > data in ACPI, however here we have completely different issue: driver
> > > > > that expects named gpios gets returned gpio that has nothing to do 
> > > > > with
> > > > > what it requested, because gpiolib acpi code always falls back to
> > > > > unnamed gpio if it does not find named gpio. That can be acceptable if
> > > > > driver uses the same con_id for all requests to gpiolib, but is not
> > > > > working when driver supplies different con_ids.
> > > >
> > > > Right, the ACPI fallback ignores con_id completely and uses only the
> > > > index.
> > > >
> > > > AFAIK there is only one driver using ACPI _CRS index method:
> > > > sdhci-[acpi|pci].c. If we can convert that to use 
> > > > acpi_dev_add_driver_gpios()
> > > > to feed names for card detection GPIOs, I think we can remove the
> > > > fallback alltogether in favor of named GPIOs for ACPI.
> > > 
> > > Nah, there seems to be several drivers relying on this already :-/
> > 
> > Would it be possible to add an optional parameter to the GPIO API
> > to specify whether we want to fall back to indexed GPIOs for ACPI?
> 
> I don't think it's a good idea to add ACPI specifics to generic APIs.
> 
> I went through ACPI enabled drivers calling GPIO APIs and majority of
> them are doing this:
> 
> static int stk8312_gpio_probe(struct i2c_client *client)
> {
> struct device *dev;
> struct gpio_desc *gpio;
> int ret;
> 
> if (!client)
> return -EINVAL;
> 
> dev = &client->dev;
> 
> /* data ready gpio interrupt pin */
> gpio = devm_gpiod_get_index(dev, STK8312_GPIO, 0, GPIOD_IN);
> if (IS_ERR(gpio)) {
> dev_err(dev, "acpi gpio get index failed\n");
> return PTR_ERR(gpio);
> }
> 
> ret = gpiod_to_irq(gpio);
> dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), 
> ret);
> 
> return ret;
> }
> 
> We can drop all this because I2C core already handles GpioInt -> interrupt
> number translation.
> 
> Few drivers are doing something more complex but I think we can still convert
> them to use acpi_dev_add_driver_gpios() and eventually get rid of the whole
> _CRS index lookup.

cpi_dev_add_driver_gpios() does not really help with generic drivers
(unless we keep adding more and more board specific data to them). How
about we keep track of names used and only allow conversion for the
first name used, like in the patch below?

-- 
Dmitry

gpiolib: tighten up ACPI legacy gpio lookups

From: Dmitry Torokhov 

We should not fall back to the legacy unnamed gpio lookup style if the
driver requests gpios with different names, because we'll give out the same
gpio twice. Let's keep track of the names that were used for the device and
only do the fallback for the first name used.

Signed-off-by: Dmitry Torokhov 
---
 drivers/gpio/gpiolib.c |   42 +-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 5db3445..4ae5447 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1738,6 +1738,45 @@ static struct gpio_desc *of_find_gpio(struct device 
*dev, const char *con_id,
return desc;
 }
 
+struct acpi_gpio_lookup {
+   struct list_head node;
+   struct device *dev;
+   const char *con_id;
+};
+
+static DEFINE_MUTEX(acpi_gpio_lookup_lock);
+static LIST_HEAD(acpi_gpio_lookup_list);
+
+static bool

Re: [PATCH v3] Input: tsc2005 - Add support for tsc2004

2015-10-29 Thread Dmitry Torokhov
On Thu, Oct 29, 2015 at 09:08:45PM -0500, Michael Welling wrote:
> Dmitry,
> 
> On Thu, Oct 29, 2015 at 06:45:22PM -0700, Dmitry Torokhov wrote:
> > Hi Michael,
> > 
> > On Wed, Oct 28, 2015 at 07:12:34PM -0500, Michael Welling wrote:
> > > Adds support for the i2c based tsc2004.
> > > 
> > > Due to the overlapping functionality of the tsc2004 and tsc2005
> > > the common code was moved to a core driver (tsc200x-core).
> > > 
> > > Signed-off-by: Michael Welling 
> > 
> > In addition to what has been discussed in the other email:
> > 
> > > ---
> > > v3: Splits the tsc2004 and tsc2005 into separate drivers with
> > > with common routines in tsc200x-core.
> > > v2: Fixes Kconfig based on report for 0-day build bot.
> > >  .../bindings/input/touchscreen/tsc2004.txt |  38 +
> > 
> > Can we please combine tsc2004.txt and tsc2005.txt?
> 
> Sure.
> 
> > 
> > >  
> > > +config TOUCHSCREEN_TSC200X
> > > + tristate
> > 
> > Let's call it TOUCHSCREEN_TSC200X_CORE.
> 
> Okay.
> 
> > 
> > > --- /dev/null
> > > +++ b/drivers/input/touchscreen/tsc2004.c
> > > @@ -0,0 +1,73 @@
> > > +/*
> > > + * TSC2004 touchscreen driver
> > > + *
> > > + * Copyright (C) 2015 EMAC Inc.
> > > + * Copyright (C) 2015 QWERTY Embedded Design
> > > + *
> > > + * This program is free software; you can redistribute it and/or modify
> > > + * it under the terms of the GNU General Public License as published by
> > > + * the Free Software Foundation; either version 2 of the License, or
> > > + * (at your option) any later version.
> > > + *
> > > + * This program is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > > + * GNU General Public License for more details.
> > > + *
> > 
> > Please drop this empty line in the comment.
> >
> 
> No problem.
>  
> > > + */
> > > +
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include "tsc200x-core.h"
> > > +
> > > +static int tsc2004_probe(struct i2c_client *i2c,
> > > +  const struct i2c_device_id *id)
> > > +
> > > +{
> > > + return tsc200x_probe(&i2c->dev, i2c->irq, BUS_I2C,
> > > +  devm_regmap_init_i2c(i2c,
> > > +   &tsc2005_regmap_config));
> > > +}
> > > +
> > > +static int tsc2004_remove(struct i2c_client *i2c)
> > > +{
> > > + return tsc200x_remove(&i2c->dev);
> > > +}
> > > +
> > > +static const struct i2c_device_id tsc2004_idtable[] = {
> > > + { "tsc2004", 0 },
> > > + { }
> > > +};
> > > +
> > > +MODULE_DEVICE_TABLE(i2c, tsc2004_idtable);
> > > +
> > > +#ifdef CONFIG_OF
> > > +static const struct of_device_id tsc2004_of_match[] = {
> > > + { .compatible = "ti,tsc2004" },
> > > + { /* sentinel */ }
> > > +};
> > > +MODULE_DEVICE_TABLE(of, tsc2004_of_match);
> > > +#endif
> > > +
> > > +static SIMPLE_DEV_PM_OPS(tsc2004_pm_ops, tsc200x_suspend, 
> > > tsc200x_resume);
> > 
> > Hmm, maybe you should export tsc200x_pm_ops instead of individual
> > functions.
> > 
> > > +
> > > +int __maybe_unused tsc200x_suspend(struct device *dev)
> > > +{
> > > + struct tsc2005 *ts = dev_get_drvdata(dev);
> > > +
> > > + mutex_lock(&ts->mutex);
> > > +
> > > + if (!ts->suspended && ts->opened)
> > > + __tsc2005_disable(ts);
> > > +
> > > + ts->suspended = true;
> > > +
> > > + mutex_unlock(&ts->mutex);
> > > +
> > > + return 0;
> > > +}
> > > +EXPORT_SYMBOL_GPL(tsc200x_suspend);
> > 
> > __maybe_unused does not make sense here - the symbol is exported and
> > therefore is always used. If you export the pm_ops stucture then you can
> > keep functions as __maybe_unused.
> > 
> > BTW, can you generate the patch with -M to let git do the rename
> > detection - it will be easier to see what changed in the core.
> 
> Okay.
> 
> Her

Re: [PATCH v3] Input: tsc2005 - Add support for tsc2004

2015-10-29 Thread Dmitry Torokhov
Hi Michael,

On Wed, Oct 28, 2015 at 07:12:34PM -0500, Michael Welling wrote:
> Adds support for the i2c based tsc2004.
> 
> Due to the overlapping functionality of the tsc2004 and tsc2005
> the common code was moved to a core driver (tsc200x-core).
> 
> Signed-off-by: Michael Welling 

In addition to what has been discussed in the other email:

> ---
> v3: Splits the tsc2004 and tsc2005 into separate drivers with
> with common routines in tsc200x-core.
> v2: Fixes Kconfig based on report for 0-day build bot.
>  .../bindings/input/touchscreen/tsc2004.txt |  38 +

Can we please combine tsc2004.txt and tsc2005.txt?

>  
> +config TOUCHSCREEN_TSC200X
> + tristate

Let's call it TOUCHSCREEN_TSC200X_CORE.

> --- /dev/null
> +++ b/drivers/input/touchscreen/tsc2004.c
> @@ -0,0 +1,73 @@
> +/*
> + * TSC2004 touchscreen driver
> + *
> + * Copyright (C) 2015 EMAC Inc.
> + * Copyright (C) 2015 QWERTY Embedded Design
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *

Please drop this empty line in the comment.

> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "tsc200x-core.h"
> +
> +static int tsc2004_probe(struct i2c_client *i2c,
> +  const struct i2c_device_id *id)
> +
> +{
> + return tsc200x_probe(&i2c->dev, i2c->irq, BUS_I2C,
> +  devm_regmap_init_i2c(i2c,
> +   &tsc2005_regmap_config));
> +}
> +
> +static int tsc2004_remove(struct i2c_client *i2c)
> +{
> + return tsc200x_remove(&i2c->dev);
> +}
> +
> +static const struct i2c_device_id tsc2004_idtable[] = {
> + { "tsc2004", 0 },
> + { }
> +};
> +
> +MODULE_DEVICE_TABLE(i2c, tsc2004_idtable);
> +
> +#ifdef CONFIG_OF
> +static const struct of_device_id tsc2004_of_match[] = {
> + { .compatible = "ti,tsc2004" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, tsc2004_of_match);
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(tsc2004_pm_ops, tsc200x_suspend, tsc200x_resume);

Hmm, maybe you should export tsc200x_pm_ops instead of individual
functions.

> +
> +int __maybe_unused tsc200x_suspend(struct device *dev)
> +{
> + struct tsc2005 *ts = dev_get_drvdata(dev);
> +
> + mutex_lock(&ts->mutex);
> +
> + if (!ts->suspended && ts->opened)
> + __tsc2005_disable(ts);
> +
> + ts->suspended = true;
> +
> + mutex_unlock(&ts->mutex);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(tsc200x_suspend);

__maybe_unused does not make sense here - the symbol is exported and
therefore is always used. If you export the pm_ops stucture then you can
keep functions as __maybe_unused.

BTW, can you generate the patch with -M to let git do the rename
detection - it will be easier to see what changed in the core.

Thanks!

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] Input: tsc2005 - Add support for tsc2004

2015-10-29 Thread Dmitry Torokhov
On Thu, Oct 29, 2015 at 04:53:53PM -0500, Michael Welling wrote:
> On Thu, Oct 29, 2015 at 10:46:20PM +0100, Arnd Bergmann wrote:
> > On Thursday 29 October 2015 09:22:37 Michael Welling wrote:
> > > > 
> > > > All errors (new ones prefixed by >>):
> > > > 
> > > >drivers/built-in.o: In function `tsc2005_cmd':
> > > > >> tsc200x-core.c:(.text+0x2ae07f): undefined reference to 
> > > > >> `i2c_smbus_write_byte'
> > > 
> > > Argh!
> > > 
> > > How do I fix this one?
> > > 
> > 
> > Move all the I2C specific code into the tsc2004.c file and remove the
> > #ifdef. The problem is that tsc200x-core.c is used as built-in when
> > TOUCHSCREEN_TSC2005=y and I2C=m, so it can't call functions that are
> > defined in i2c-core.c.
> 
> How would I call the function from the core then?

You can pass a cmd function from the transport module into core module
and store and use it.

However, you have regmap in the driver core already. Mark, is it
possible to have regmap API also allow doing raw underlying protocol
transfer so that consumers could issue command requests without needing
to know if they need to do it over i2c or spi or whatever. Or we need a
notion of command registers in regmap...

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] Input: tsc2005 - Add support for tsc2004

2015-10-27 Thread Dmitry Torokhov
On Wed, Oct 28, 2015 at 12:48:29AM -0500, Michael Welling wrote:
> On Tue, Oct 27, 2015 at 10:41:52PM -0700, Dmitry Torokhov wrote:
> > On Wed, Oct 28, 2015 at 12:23:34AM -0500, Michael Welling wrote:
> > > On Tue, Oct 27, 2015 at 06:51:41PM -0700, Dmitry Torokhov wrote:
> > > > Hi Michael,
> > > > On Tue, Oct 27, 2015 at 07:17:01PM -0500, Michael Welling wrote:
> > > > > Adds support for the i2c based tsc2004. Support was added to the 
> > > > > tsc2005 driver
> > > > > due to the similarity of the devices.
> > > > > 
> > > > > Signed-off-by: Michael Welling 
> > > > > ---
> > > > > v2: Fixes Kconfig based on report for 0-day build bot.
> > > > > 
> > > > >  .../bindings/input/touchscreen/tsc2004.txt |  38 
> > > > >  drivers/input/touchscreen/Kconfig  |   7 +-
> > > > >  drivers/input/touchscreen/tsc2005.c| 206 
> > > > > -
> > > > 
> > > > Could we maybe split the code into core, spi and i2c drivers instead of
> > > > keeping everything together and rely on #ifdefs?
> > > >
> > > Dmitry,
> > > 
> > > So then we have three files?
> > > Perhaps:
> > > drivers/input/touchscreen/tsc2004.c
> > > drivers/input/touchscreen/tsc2005.c
> > > drivers/input/touchscreen/tsc200x-core.c
> > > 
> > > Please ellaborate exactly how you want things to be structured and named 
> > > so
> > > that I don't waste time in revision.
> > 
> > Sure, the naming above is fine. You'd have to export the
> > tsc_common_probe() and put I2C and SPI bits into tsc2005.c/tsc2004.c
> > 
> > I'd probably have separate Kconfig entries for TSC2004 and TSC2005 and
> > have the core be invisible module that the former 2 explicitly "select".
> > 
> > Does this make sense?
> 
> Yes it does.
> 
> I have been told that using wildcard names is bad in other subsystems.
> Perhaps tsc200x-core.c should be called something else because it has
> nothing to do with the tsc2007 but it is covered by the wildcard.
> 
> You you think this is a big deal?

No I do not.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] Input: tsc2005 - Add support for tsc2004

2015-10-27 Thread Dmitry Torokhov
On Wed, Oct 28, 2015 at 12:38:31AM -0500, Michael Welling wrote:
> On Wed, Oct 28, 2015 at 12:37:35PM +0800, kbuild test robot wrote:
> > Hi Michael,
> > 
> > [auto build test ERROR on input/next -- if it's inappropriate base, please 
> > suggest rules for selecting the more suitable base]
> > 
> > url:
> > https://github.com/0day-ci/linux/commits/Michael-Welling/Input-tsc2005-Add-support-for-tsc2004/20151028-082017
> > config: x86_64-randconfig-s1-10281141 (attached as .config)
> > reproduce:
> > # save the attached .config to linux build tree
> > make ARCH=x86_64 
> > 
> > All errors (new ones prefixed by >>):
> > 
> >drivers/built-in.o: In function `tsc2005_cmd':
> >tsc2005.c:(.text+0x21a352): undefined reference to `i2c_smbus_write_byte'
> >drivers/built-in.o: In function `tsc200x_probe_common':
> > >> tsc2005.c:(.text+0x21b554): undefined reference to 
> > >> `__devm_regmap_init_i2c'
> >drivers/built-in.o: In function `tsc2005_modinit':
> >tsc2005.c:(.init.text+0xe2b2): undefined reference to 
> > `i2c_register_driver'
> >drivers/built-in.o: In function `tsc2005_exit':
> >tsc2005.c:(.exit.text+0xf4c): undefined reference to `i2c_del_driver'
> >
> 
> Sorry Mr. Robot but this configuration does not make sense.
> 
> How is CONFIG_REGMAP_I2C=m set without CONFIG_I2C being selected?
> CONFIG_REGMAP_I2C depends on CONFIG_I2C.

The call to devm_regmap_init_i2c() in tsc200x_probe_common() is not
protected by #ifdef guard and we do not have stub for it in case of
!CONFIG_I2C.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] Input: tsc2005 - Add support for tsc2004

2015-10-27 Thread Dmitry Torokhov
On Wed, Oct 28, 2015 at 12:23:34AM -0500, Michael Welling wrote:
> On Tue, Oct 27, 2015 at 06:51:41PM -0700, Dmitry Torokhov wrote:
> > Hi Michael,
> > On Tue, Oct 27, 2015 at 07:17:01PM -0500, Michael Welling wrote:
> > > Adds support for the i2c based tsc2004. Support was added to the tsc2005 
> > > driver
> > > due to the similarity of the devices.
> > > 
> > > Signed-off-by: Michael Welling 
> > > ---
> > > v2: Fixes Kconfig based on report for 0-day build bot.
> > > 
> > >  .../bindings/input/touchscreen/tsc2004.txt |  38 
> > >  drivers/input/touchscreen/Kconfig  |   7 +-
> > >  drivers/input/touchscreen/tsc2005.c| 206 
> > > -
> > 
> > Could we maybe split the code into core, spi and i2c drivers instead of
> > keeping everything together and rely on #ifdefs?
> >
> Dmitry,
> 
> So then we have three files?
> Perhaps:
> drivers/input/touchscreen/tsc2004.c
> drivers/input/touchscreen/tsc2005.c
> drivers/input/touchscreen/tsc200x-core.c
> 
> Please ellaborate exactly how you want things to be structured and named so
> that I don't waste time in revision.

Sure, the naming above is fine. You'd have to export the
tsc_common_probe() and put I2C and SPI bits into tsc2005.c/tsc2004.c

I'd probably have separate Kconfig entries for TSC2004 and TSC2005 and
have the core be invisible module that the former 2 explicitly "select".

Does this make sense?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] Input: tsc2005 - Add support for tsc2004

2015-10-27 Thread Dmitry Torokhov
Hi Michael,
On Tue, Oct 27, 2015 at 07:17:01PM -0500, Michael Welling wrote:
> Adds support for the i2c based tsc2004. Support was added to the tsc2005 
> driver
> due to the similarity of the devices.
> 
> Signed-off-by: Michael Welling 
> ---
> v2: Fixes Kconfig based on report for 0-day build bot.
> 
>  .../bindings/input/touchscreen/tsc2004.txt |  38 
>  drivers/input/touchscreen/Kconfig  |   7 +-
>  drivers/input/touchscreen/tsc2005.c| 206 
> -

Could we maybe split the code into core, spi and i2c drivers instead of
keeping everything together and rely on #ifdefs?

Thanks!

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 0/9] Goodix touchscreen enhancements

2015-10-26 Thread Dmitry Torokhov
On Mon, Oct 26, 2015 at 07:21:12PM +0100, Karsten Merker wrote:
> On Mon, Oct 26, 2015 at 04:06:29PM +0100, Bastien Nocera wrote:
> > On Mon, 2015-10-12 at 18:24 +0300, Irina Tirdea wrote:
> 
> > > v9 only adds GPIOLIB dependency in Kconfig for patch 2:
> > > "Input: goodix - reset device at init". There are no other code
> > > changes from v8.
> > > 
> > > Thanks for testing these changes, Bastien and Aleksei!
> > > 
> > > Karsten, there is no need to rebase your series on top of v9.
> > 
> > Are we waiting on anything else before merging this? I'd like it to be
> > scheduled to be merged so I can start focusing on the subsequent and
> > dependent patches for that same driver.
> 
> Hello,
> 
> AFAICS there is one open point (cf. 
> http://www.spinics.net/lists/linux-input/msg41567.html) which
> Irina wanted to address in a v10 of the patchset (cf. 
> http://www.spinics.net/lists/linux-input/msg41642.html).

There is also the whole thing about insane handling of named gpios in
ACPI layer, which stops me from merging the reset code since these gpios
should be marked as optional and we should stop ignoring errors coming
from gpiolib.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/19] input: tegra-kbc: enable support for the standard "wakeup-source" property

2015-10-26 Thread Dmitry Torokhov
On Fri, Oct 23, 2015 at 11:23:51AM +0100, Sudeep Holla wrote:
> 
> 
> On 23/10/15 07:39, Dmitry Torokhov wrote:
> >On Wed, Oct 21, 2015 at 11:10:03AM +0100, Sudeep Holla wrote:
> >>Though the mmc core driver should/will continue to support the legacy
> >>"nvidia,wakeup-source" property to enable SDIO as the wakeup source, we
> >>need to add support for the new standard property "wakeup-source".
> >>
> >>This patch adds support for "wakeup-source" property in addition to the
> >>existing "nvidia,wakeup-source" property.
> >>
> >>Cc: Laxman Dewangan 
> >>Cc: Dmitry Torokhov 
> >>Cc: Thierry Reding 
> >>Cc: linux-in...@vger.kernel.org
> >>Cc: linux-te...@vger.kernel.org
> >>Signed-off-by: Sudeep Holla 
> >
> >Applied, thank you.
> >
> 
> Thanks, but I think I sent out a old copy which had unrelated commit
> message because of copy-paste. *Sorry for that*. Can you update it
> something like:
> 
> "
> Though the tegra-kbc driver should/will continue to support the legacy
> "nvidia,wakeup-source" property to enable keyboard as the wakeup source,
> we need to add support for the new standard property "wakeup-source".
> 
> This patch adds support for "wakeup-source" property in addition to the
> existing "nvidia,wakeup-source" property.
> "

Thanks, I replaced the description with what you supplied.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 04/22] of: add function to allow probing a device from a OF node

2015-10-25 Thread Dmitry Torokhov
On October 26, 2015 9:13:01 AM GMT+09:00, Mark Brown  wrote:
>On Sat, Oct 24, 2015 at 03:09:06PM -0500, Rob Herring wrote:
>
>> Let's get agreement on the flow and structure and how to address
>other
>> issues like suspend, then we can worry about whether this needs to be
>> abstracted from subsystems. We can discuss more this week at KS.
>
>Should we try to schedule an ad-hoc session today (Monday) for those of
>us who are here to talk this over?


That would be great.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/19] input: tegra-kbc: enable support for the standard "wakeup-source" property

2015-10-22 Thread Dmitry Torokhov
On Wed, Oct 21, 2015 at 11:10:03AM +0100, Sudeep Holla wrote:
> Though the mmc core driver should/will continue to support the legacy
> "nvidia,wakeup-source" property to enable SDIO as the wakeup source, we
> need to add support for the new standard property "wakeup-source".
> 
> This patch adds support for "wakeup-source" property in addition to the
> existing "nvidia,wakeup-source" property.
> 
> Cc: Laxman Dewangan 
> Cc: Dmitry Torokhov 
> Cc: Thierry Reding 
> Cc: linux-in...@vger.kernel.org
> Cc: linux-te...@vger.kernel.org
> Signed-off-by: Sudeep Holla 

Applied, thank you.

> ---
>  drivers/input/keyboard/tegra-kbc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/tegra-kbc.c 
> b/drivers/input/keyboard/tegra-kbc.c
> index f97c73bd14f8..f80c72d4ac8f 100644
> --- a/drivers/input/keyboard/tegra-kbc.c
> +++ b/drivers/input/keyboard/tegra-kbc.c
> @@ -517,7 +517,8 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc)
>   if (of_find_property(np, "nvidia,needs-ghost-filter", NULL))
>   kbc->use_ghost_filter = true;
>  
> - if (of_find_property(np, "nvidia,wakeup-source", NULL))
> + if (of_property_read_bool(np, "wakeup-source") ||
> + of_property_read_bool(np, "nvidia,wakeup-source")) /* legacy */
>   kbc->wakeup = true;
>  
>   if (!of_get_property(np, "nvidia,kbc-row-pins", &proplen)) {
> -- 
> 1.9.1
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/4] input: gpio_keys_polled: Add support for abs/rel axis

2015-10-14 Thread Dmitry Torokhov
On Tue, Sep 22, 2015 at 03:23:56PM +0200, Hans de Goede wrote:
> Hi Dmitry,
> 
> This patch-series really is 2 related series:
> 
> Patch 1 + 2:
> 
> Support for abs/rel axis in gpio_keys_polled, the dt-bindings patch is
> updated, the actual implementation is the same as the v2 version.
> 
> Patch 3 + 4:
> 
> Add a single header with key / btn / axis defines to be shared by input.h
> and the dt-bindings headers, as requested by you. The first patch introduces
> a new header for this, the second patch makes dt-bindings/input/input.h
> use this new header. The second patch has been Acked by the devicetree
> maintainer, and since it depends on the first one I believe that it is
> best if this patch gets merged via your tree too.

Applied the lot, thank you.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 3/9] Input: goodix - write configuration data to device

2015-10-13 Thread Dmitry Torokhov
On Thu, Oct 08, 2015 at 01:19:29PM +0300, Irina Tirdea wrote:
> Goodix devices can be configured by writing custom data to the device at
> init. The configuration data is read with request_firmware from
> "goodix__cfg.bin", where  is the product id read from the device
> (e.g.: goodix_911_cfg.bin for Goodix GT911, goodix_9271_cfg.bin for
> GT9271).
> 
> The configuration information has a specific format described in the Goodix
> datasheet. It includes X/Y resolution, maximum supported touch points,
> interrupt flags, various sensitivity factors and settings for advanced
> features (like gesture recognition).
> 
> Before writing the firmware, it is necessary to reset the device. If
> the device ACPI/DT information does not declare gpio pins (needed for
> reset), writing the firmware will not be available for these devices.
> 
> This is based on Goodix datasheets for GT911 and GT9271 and on Goodix
> driver gt9xx.c for Android (publicly available in Android kernel
> trees for various devices).
> 
> Signed-off-by: Octavian Purdila 
> Signed-off-by: Irina Tirdea 
> ---
>  drivers/input/touchscreen/goodix.c | 229 
> +++--
>  1 file changed, 196 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/goodix.c 
> b/drivers/input/touchscreen/goodix.c
> index 916198d..37035fb 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -16,6 +16,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -40,6 +41,9 @@ struct goodix_ts_data {
>   int cfg_len;
>   struct gpio_desc *gpiod_int;
>   struct gpio_desc *gpiod_rst;
> + u16 id;
> + u16 version;
> + char *cfg_name;
>  };
>  
>  #define GOODIX_GPIO_INT_NAME "irq"
> @@ -159,6 +163,39 @@ static int goodix_i2c_read(struct i2c_client *client,
>   return ret < 0 ? ret : (ret != ARRAY_SIZE(msgs) ? -EIO : 0);
>  }
>  
> +/**
> + * goodix_i2c_write - write data to a register of the i2c slave device.
> + *
> + * @client: i2c device.
> + * @reg: the register to write to.
> + * @buf: raw data buffer to write.
> + * @len: length of the buffer to write
> + */
> +static int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 
> *buf,
> + unsigned len)
> +{
> + u8 *addr_buf;
> + struct i2c_msg msg;
> + int ret;
> +
> + addr_buf = kmalloc(len + 2, GFP_KERNEL);
> + if (!addr_buf)
> + return -ENOMEM;
> +
> + addr_buf[0] = reg >> 8;
> + addr_buf[1] = reg & 0xFF;
> + memcpy(&addr_buf[2], buf, len);
> +
> + msg.flags = 0;
> + msg.addr = client->addr;
> + msg.buf = addr_buf;
> + msg.len = len + 2;
> +
> + ret = i2c_transfer(client->adapter, &msg, 1);
> + kfree(addr_buf);
> + return ret < 0 ? ret : (ret != 1 ? -EIO : 0);
> +}
> +
>  static int goodix_get_cfg_len(u16 id)
>  {
>   switch (id) {
> @@ -278,6 +315,73 @@ static irqreturn_t goodix_ts_irq_handler(int irq, void 
> *dev_id)
>   return IRQ_HANDLED;
>  }
>  
> +/**
> + * goodix_check_cfg - Checks if config fw is valid
> + *
> + * @ts: goodix_ts_data pointer
> + * @cfg: firmware config data
> + */
> +static int goodix_check_cfg(struct goodix_ts_data *ts,
> + const struct firmware *cfg)
> +{
> + int i, raw_cfg_len;
> + u8 check_sum = 0;
> +
> + if (cfg->size > GOODIX_CONFIG_MAX_LENGTH) {
> + dev_err(&ts->client->dev,
> + "The length of the config fw is not correct");
> + return -EINVAL;
> + }
> +
> + raw_cfg_len = cfg->size - 2;
> + for (i = 0; i < raw_cfg_len; i++)
> + check_sum += cfg->data[i];
> + check_sum = (~check_sum) + 1;
> + if (check_sum != cfg->data[raw_cfg_len]) {
> + dev_err(&ts->client->dev,
> + "The checksum of the config fw is not correct");
> + return -EINVAL;
> + }
> +
> + if (cfg->data[raw_cfg_len + 1] != 1) {
> + dev_err(&ts->client->dev,
> + "Config fw must have Config_Fresh register set");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +/**
> + * goodix_send_cfg - Write fw config to device
> + *
> + * @ts: goodix_ts_data pointer
> + * @cfg: config firmware to write to device
> + */
> +static int goodix_send_cfg(struct goodix_ts_data *ts,
> +const struct firmware *cfg)
> +{
> + int error;
> +
> + error = goodix_check_cfg(ts, cfg);
> + if (error)
> + return error;
> +
> + error = goodix_i2c_write(ts->client, GOODIX_REG_CONFIG_DATA, cfg->data,
> +  cfg->size);
> + if (error) {
> + dev_err(&ts->client->dev, "Failed to write config data: %d",
> + error);
> + return error;
> + }
> + dev_dbg(&ts->client->dev, "Config sent successfully.");
> +
> + /* Let the firmware reconfigure itself, so sle

Re: [PATCH 3/3] input: rotary-encoder: Support 'steps-per-period' DT property

2015-10-13 Thread Dmitry Torokhov
On Fri, Oct 09, 2015 at 10:46:56AM -0300, Ezequiel Garcia wrote:
> As per the recent devicetree binding changes, this commit adds the
> support for the new 'steps-per-period' property.
> 
> Legacy properties to specify the rotary behavior, are now deprecated
> and instead the new 'steps-per-period' is supported. The default behavior
> is retained.
> 
> This allows to support rotary-encoder devices with detents wich are capable
> of producing a stable event on each step.
> 
> Signed-off-by: Guido Martínez 
> Signed-off-by: Ezequiel Garcia 
> ---
>  drivers/input/misc/rotary_encoder.c | 87 
> +++--
>  include/linux/rotary_encoder.h  |  2 +-
>  2 files changed, 84 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/input/misc/rotary_encoder.c 
> b/drivers/input/misc/rotary_encoder.c
> index 15a4cc670a3f..e021615dd3c0 100644
> --- a/drivers/input/misc/rotary_encoder.c
> +++ b/drivers/input/misc/rotary_encoder.c
> @@ -142,6 +142,55 @@ static irqreturn_t rotary_encoder_half_period_irq(int 
> irq, void *dev_id)
>   return IRQ_HANDLED;
>  }
>  
> +static irqreturn_t rotary_encoder_quarter_period_irq(int irq, void *dev_id)
> +{
> + struct rotary_encoder *encoder = dev_id;
> + unsigned char sum;
> + int state;
> +
> + state = rotary_encoder_get_state(encoder->pdata);
> +
> + /*
> +  * We encode the previous and the current state using a byte.
> +  * The previous state in the MSB nibble, the current state in the LSB
> +  * nibble. Then use a table to decide the direction of the turn.
> +  */
> + sum = (encoder->last_stable << 4) + state;
> + switch (sum) {
> + case 0x31:
> + case 0x10:
> + case 0x02:
> + case 0x23:
> + encoder->dir = 0; /* clockwise */
> + break;
> +
> + case 0x13:
> + case 0x01:
> + case 0x20:
> + case 0x32:
> + encoder->dir = 1; /* counter-clockwise */
> + break;
> +
> + default:
> + /*
> +  * Ignore all other values. This covers the case when the
> +  * state didn't change (a spurious interrupt) and the
> +  * cases where the state changed by two steps, making it
> +  * impossible to tell the direction.
> +  *
> +  * In either case, don't report any event and save the
> +  * state for later.
> +  */
> + goto out;
> + }
> +
> + rotary_encoder_report_event(encoder);
> +
> +out:
> + encoder->last_stable = state;
> + return IRQ_HANDLED;
> +}
> +
>  #ifdef CONFIG_OF
>  static const struct of_device_id rotary_encoder_of_match[] = {
>   { .compatible = "rotary-encoder", },
> @@ -176,7 +225,26 @@ static struct rotary_encoder_platform_data 
> *rotary_encoder_parse_dt(struct devic
>  
>   pdata->relative_axis = of_property_read_bool(np, 
> "rotary-encoder,relative-axis");
>   pdata->rollover = of_property_read_bool(np, "rotary-encoder,rollover");
> - pdata->half_period = of_property_read_bool(np, 
> "rotary-encoder,half-period");
> +
> + if (!of_get_property(np, "rotary-encoder,steps-per-period", NULL)) {
> + /*
> +  * Fallback to a one step per period behavior if the
> +  * 'steps-per-period' is not set.
> +  */
> + pdata->steps_per_period = 1;
> + } else {
> + of_property_read_u32(np, "rotary-encoder,steps-per-period",
> +  &pdata->steps_per_period);
> + }
> +
> + /*
> +  * The 'half-period' property has been deprecated, you must use
> +  * 'steps-per-period' and set an appropriate value.
> +  */
> + if (of_get_property(np, "rotary-encoder,half-period", NULL)) {
> + pr_warn(FW_WARN "\"rotary-encoder,half-period\" is 
> deprecated\n");
> + pdata->steps_per_period = 2;
> + }

Hmm, I do not think we need to warn about old DTSes if we consider them
ABI. How about if we parse like this:

error = of_property_read_u32(np, "rotary-encoder,steps-per-period",
 &pdata->steps_per_period);
if (error) {
/*
 * The 'half-period' property has been deprecated, you must use
 * 'steps-per-period' and set an appropriate value, but we still
 * need to parse it to maintain compatibility.
 */
if (of_property_read_bool(np, "rotary-encoder,half-period")) {
pdata->steps_per_period = 2;
} else {
/* Fallback to a one step per period behavior */
pdata->steps_per_period = 1;
}
}


(no need to resubmit if you are OK with this).

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http:/

Re: [PATCH v9 2/9] Input: goodix - reset device at init

2015-10-13 Thread Dmitry Torokhov
On Tue, Oct 13, 2015 at 01:07:24PM +0300, mika.westerb...@linux.intel.com wrote:
> On Tue, Oct 13, 2015 at 08:54:12AM +, Tirdea, Irina wrote:
> > > > I did not use devm_gpiod_get_optional() in order to ignore more errors
> > > > than -ENOENT. This is needed because the ACPI gpio core will fall back
> > > > to indexed gpios if named gpios are not found. In the common case of
> > > > having 2 indexed gpio pins declared in the ACPI table, the first
> > > > devm_gpiod_get() will successfully get indexed gpio pin 0 and the
> > > > second devm_gpiod_get() will try to get the same gpio pin 0 and return
> > > > -EBUSY. Considering this, I thought it is better to just ignore all 
> > > > errors in
> > > > order not to break any platforms currently using this driver.
> > > 
> > > This seems like issue with ACPI gpio lookup implementation. If I am
> > > requesting named gpio and it is not present then I definitely do not
> > > need to be returned some random gpio. Doing so breaks all other drivers
> > > that use several names to retrieve GPIOs. We basically can't trust GPIO
> > > API on ACPI systems.
> > > 
> > 
> > I'm not sure there is a way to avoid fall back to indexed gpios when 
> > requesting
> > named gpios.
> > Adding Mika to this thread as he might help answer this.
> 
> Before ACPI 5.1 _DSD device properties were introduced all we had was an
> array of GPIOs returned by _CRS ACPI method. Ordering of those GPIOs
> could change from one vendor to another :-(
> 
> We can (and do) use acpi_dev_add_driver_gpios() to pass correct mappings
> where _DSD is not present based on the device ACPI ID for instance. Not
> all drivers do that, though.
> 
> I would like to get rid of the fallback completely at some point. We
> have had already problems with the API because then some ACPI only
> drivers did this:
> 
>   reset_gpio = gpiod_get_index(dev, NULL, 0);
>   power_gpio = gpiod_get_index(dev, NULL, 1);
> 
> which might not do what is expected on DT systems. That's why
> acpi_dev_add_driver_gpios() was added in the first place IIRC.

I understand why one might use acpi_dev_add_driver_gpios() to augment
data in ACPI, however here we have completely different issue: driver
that expects named gpios gets returned gpio that has nothing to do with
what it requested, because gpiolib acpi code always falls back to
unnamed gpio if it does not find named gpio. That can be acceptable if
driver uses the same con_id for all requests to gpiolib, but is not
working when driver supplies different con_ids.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 2/9] Input: goodix - reset device at init

2015-10-13 Thread Dmitry Torokhov
On Tue, Oct 13, 2015 at 06:38:23AM +, Tirdea, Irina wrote:
> 
> 
> > -Original Message-
> > From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com]
> > Sent: 12 October, 2015 19:48
> > To: Tirdea, Irina
> > Cc: Bastien Nocera; Aleksei Mamlin; Karsten Merker; 
> > linux-in...@vger.kernel.org; Mark Rutland; Purdila, Octavian; linux-
> > ker...@vger.kernel.org; devicetree@vger.kernel.org
> > Subject: Re: [PATCH v9 2/9] Input: goodix - reset device at init
> > 
> > On Mon, Oct 12, 2015 at 06:24:30PM +0300, Irina Tirdea wrote:
> > > After power on, it is recommended that the driver resets the device.
> > > The reset procedure timing is described in the datasheet and is used
> > > at device init (before writing device configuration) and
> > > for power management. It is a sequence of setting the interrupt
> > > and reset pins high/low at specific timing intervals. This procedure
> > > also includes setting the slave address to the one specified in the
> > > ACPI/device tree.
> > >
> > > This is based on Goodix datasheets for GT911 and GT9271 and on Goodix
> > > driver gt9xx.c for Android (publicly available in Android kernel
> > > trees for various devices).
> > >
> > > For reset the driver needs to control the interrupt and
> > > reset gpio pins (configured through ACPI/device tree). For devices
> > > that do not have the gpio pins properly declared, the functionality
> > > depending on these pins will not be available, but the device can still
> > > be used with basic functionality.
> > >
> > > For both device tree and ACPI, the interrupt gpio pin configuration is
> > > read from the "irq-gpio" property and the reset pin configuration is
> > > read from the "reset-gpio" property. For ACPI 5.1, named properties
> > > can be specified using the _DSD section. This functionality will not be
> > > available for devices that use indexed gpio pins declared in the _CRS
> > > section (we need to provide backward compatibility with devices
> > > that do not support using the interrupt gpio pin as output).
> > >
> > > For ACPI, the pins can be specified using ACPI 5.1:
> > > Device (STAC)
> > > {
> > > Name (_HID, "GDIX1001")
> > > ...
> > >
> > > Method (_CRS, 0, Serialized)
> > > {
> > > Name (RBUF, ResourceTemplate ()
> > > {
> > > I2cSerialBus (0x0014, ControllerInitiated, 0x00061A80,
> > > AddressingMode7Bit, "\\I2C0",
> > > 0x00, ResourceConsumer, ,
> > > )
> > >
> > > GpioInt (Edge, ActiveHigh, Exclusive, PullNone, 0x,
> > > "\\I2C0", 0x00, ResourceConsumer, ,
> > >  )
> > >  {   // Pin list
> > >  0
> > >  }
> > >
> > > GpioIo (Exclusive, PullDown, 0x, 0x,
> > > IoRestrictionOutputOnly, "\\I2C0", 0x00,
> > > ResourceConsumer, ,
> > > )
> > > {
> > >  1
> > > }
> > > })
> > > Return (RBUF)
> > > }
> > >
> > > Name (_DSD,  Package ()
> > > {
> > > ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> > > Package ()
> > > {
> > > Package (2) {"irq-gpio", Package() {^STAC, 0, 0, 0 }},
> > > Package (2) {"reset-gpio", Package() {^STAC, 1, 0, 0 }},
> > > ...
> > > }
> > > }
> > >
> > > Signed-off-by: Octavian Purdila 
> > > Signed-off-by: Irina Tirdea 
> > > Acked-by: Bastien Nocera 
> > > Tested-by: Bastien Nocera 
> > > Tested-by: Aleksei Mamlin 
> > > ---
> > >  .../bindings/input/touchscreen/goodix.txt  |   5 +
> > >  drivers/input/touchscreen/Kconfig  |   1 +
> > >  drivers/input/touchscreen/goodix.c | 101 
> > > +
> > >  3 files changed, 107 insertions(+)
> > >
> > > diff --git 
> > > a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> > b/Documentation/devicetree/bindings/input/touchsc

Re: [PATCH v9 2/9] Input: goodix - reset device at init

2015-10-12 Thread Dmitry Torokhov
On Mon, Oct 12, 2015 at 06:24:30PM +0300, Irina Tirdea wrote:
> After power on, it is recommended that the driver resets the device.
> The reset procedure timing is described in the datasheet and is used
> at device init (before writing device configuration) and
> for power management. It is a sequence of setting the interrupt
> and reset pins high/low at specific timing intervals. This procedure
> also includes setting the slave address to the one specified in the
> ACPI/device tree.
> 
> This is based on Goodix datasheets for GT911 and GT9271 and on Goodix
> driver gt9xx.c for Android (publicly available in Android kernel
> trees for various devices).
> 
> For reset the driver needs to control the interrupt and
> reset gpio pins (configured through ACPI/device tree). For devices
> that do not have the gpio pins properly declared, the functionality
> depending on these pins will not be available, but the device can still
> be used with basic functionality.
> 
> For both device tree and ACPI, the interrupt gpio pin configuration is
> read from the "irq-gpio" property and the reset pin configuration is
> read from the "reset-gpio" property. For ACPI 5.1, named properties
> can be specified using the _DSD section. This functionality will not be
> available for devices that use indexed gpio pins declared in the _CRS
> section (we need to provide backward compatibility with devices
> that do not support using the interrupt gpio pin as output).
> 
> For ACPI, the pins can be specified using ACPI 5.1:
> Device (STAC)
> {
> Name (_HID, "GDIX1001")
> ...
> 
> Method (_CRS, 0, Serialized)
> {
> Name (RBUF, ResourceTemplate ()
> {
> I2cSerialBus (0x0014, ControllerInitiated, 0x00061A80,
> AddressingMode7Bit, "\\I2C0",
> 0x00, ResourceConsumer, ,
> )
> 
> GpioInt (Edge, ActiveHigh, Exclusive, PullNone, 0x,
> "\\I2C0", 0x00, ResourceConsumer, ,
>  )
>  {   // Pin list
>  0
>  }
> 
> GpioIo (Exclusive, PullDown, 0x, 0x,
> IoRestrictionOutputOnly, "\\I2C0", 0x00,
> ResourceConsumer, ,
> )
> {
>  1
> }
> })
> Return (RBUF)
> }
> 
> Name (_DSD,  Package ()
> {
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> Package ()
> {
> Package (2) {"irq-gpio", Package() {^STAC, 0, 0, 0 }},
> Package (2) {"reset-gpio", Package() {^STAC, 1, 0, 0 }},
> ...
> }
> }
> 
> Signed-off-by: Octavian Purdila 
> Signed-off-by: Irina Tirdea 
> Acked-by: Bastien Nocera 
> Tested-by: Bastien Nocera 
> Tested-by: Aleksei Mamlin 
> ---
>  .../bindings/input/touchscreen/goodix.txt  |   5 +
>  drivers/input/touchscreen/Kconfig  |   1 +
>  drivers/input/touchscreen/goodix.c | 101 
> +
>  3 files changed, 107 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt 
> b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> index 8ba98ee..7137881 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> @@ -12,6 +12,8 @@ Required properties:
>   - reg   : I2C address of the chip. Should be 0x5d or 
> 0x14
>   - interrupt-parent  : Interrupt controller to which the chip is connected
>   - interrupts: Interrupt to which the chip is connected
> + - irq-gpio  : GPIO pin used for IRQ
> + - reset-gpio: GPIO pin used for reset
>  
>  Example:
>  
> @@ -23,6 +25,9 @@ Example:
>   reg = <0x5d>;
>   interrupt-parent = <&gpio>;
>   interrupts = <0 0>;
> +
> + irq-gpio = <&gpio1 0 0>;
> + reset-gpio = <&gpio1 1 0>;
>   };
>  
>   /* ... */
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 771d95c..76f5a9d 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -324,6 +324,7 @@ config TOUCHSCREEN_FUJITSU
>  config TOUCHSCREEN_GOODIX
>   tristate "Goodix I2C touchscreen"
>   depends on I2C
> + depends on GPIOLIB
>   help
> Say Y here if you have the Goodix touchscreen (such as one
> installed in Onda v975w tablets) connected to your
> diff --git a/drivers/input/touchscreen/goodix.c 
> b/drivers/input/touchscreen/goodix.c
> index 56d0330..87304ac 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -16,6 +16,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -37,8 +38,13 @@ struct go

Re: [PATCH v9 9/9] Input: goodix - sort includes using inverse Xmas tree order

2015-10-12 Thread Dmitry Torokhov
On Mon, Oct 12, 2015 at 8:53 AM, Bastien Nocera  wrote:
> On Mon, 2015-10-12 at 16:51 +0100, Mark Rutland wrote:
>> On Mon, Oct 12, 2015 at 05:40:37PM +0200, Bastien Nocera wrote:
>> > On Mon, 2015-10-12 at 16:39 +0100, Mark Rutland wrote:
>> > > Why?
>> >
>> > It was already discussed in the thread for a previous version,
>> > please
>> > refer to that.
>>
>> Fine, but surely that should be in the commit message, to prevent
>> others
>> like myself repeatedly asking the same question?
>
> Fair point. Irina?

No, let's just leave poor includes alone.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Correct property to use for wake up support on rotary encoders

2015-10-12 Thread Dmitry Torokhov
Hi Sylvain,

On Mon, Oct 12, 2015 at 9:09 AM, Sylvain Rochet
 wrote:
> Hi,
>
> Several month ago I proposed a patch[1][2] to add wake up support to
> rotary encoders[3].
>
> Among all the properties currently used in Linux kernels device trees,
> we have three recognisable patterns for wake up support:
>  - driver-name,wakeup
>  - linux,wakeup
>  - wakeup-source
>
> We don't know which one to use, could you tell which one we should use
> for GPIO rotary encoders ?
>

Please use "wakeup-source", we've been trying to standardize on it.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V3 3/3] devicetree: da9062: Add device tree bindings for DA9062 OnKey

2015-09-29 Thread Dmitry Torokhov
On Mon, Sep 28, 2015 at 08:19:27AM +, Opensource [Steve Twiss] wrote:
> 
> > Subject: Re: [PATCH V3 3/3] devicetree: da9062: Add device tree bindings 
> > for DA9062 OnKey
> > 
> > On Mon, Jul 27, 2015 at 03:43:00PM -0700, Dmitry Torokhov wrote:
> > > On Thu, Jul 23, 2015 at 05:17:41PM +0100, S Twiss wrote:
> > > > From: S Twiss 
> > > >
> > > > Add device tree bindings for the DA9062 OnKey driver component
> > > >
> > > > Signed-off-by: Steve Twiss 
> > > >
> > > > ---
> > > > Changes in V3:
> > > >  - Child driver specifics separated out into separate document
> > > >in this case ../input/da9062-onkey.txt
> > > > Changes in V2:
> > > >  - No change
> > > >
> > > > This patch applies against linux-next and next-20150708
> > > >
> > > >
> > > >  .../devicetree/bindings/input/da9062-onkey.txt | 36
> > ++
> > > >  Documentation/devicetree/bindings/mfd/da9062.txt   |  3 ++
> > >
> > > I dropped bits for mfd/da9062.txt, changed to mention both 9062 and
> > > 9063, folded into the onkey patch and applied.
> > 
> > Argh, da9062 core is not in mainline yet... OK, below is the patch I
> > had; if Lee does not pick it up I'll re-apply it when da9062 core hits
> > mainline.
> > 
> 
> Hi Lee and Dmitry,
> 
> This patch seems to have been missed. It is the main OnKey driver for DA9062 
> and this
> component was waiting for the DA9062 MFD core to make it into 
> linux-mainline/v4.3-rc1.
> 
> Is there any reply on this yet please? There just seems to be a little patch 
> administration
> problem holding things up.

I queued it for 4.4.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/5] thermal: rockchip: Support the RK3368 SoCs in thermal driver

2015-09-21 Thread Dmitry Torokhov
Hi Caesar,

On Mon, Sep 21, 2015 at 12:16:08PM +0800, Caesar Wang wrote:
> The RK3368 SoCs support to 2 channel TS-ADC, the temperature criteria
> of each channel can be configurable.
> 
> The system has two Temperature Sensors, channel 0 is for CPU,
> and channel 1 is for GPU.
> 
> Signed-off-by: Caesar Wang 
> ---
> 
>  drivers/thermal/rockchip_thermal.c | 201 
> -
>  1 file changed, 176 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/thermal/rockchip_thermal.c 
> b/drivers/thermal/rockchip_thermal.c
> index 4d5b7d4..16d2476 100644
> --- a/drivers/thermal/rockchip_thermal.c
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -1,6 +1,9 @@
>  /*
>   * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
>   *
> + * Copyright (c) 2015, Fuzhou Rockchip Electronics Co., Ltd
> + * Caesar Wang 
> + *
>   * This program is free software; you can redistribute it and/or modify it
>   * under the terms and conditions of the GNU General Public License,
>   * version 2, as published by the Free Software Foundation.
> @@ -43,16 +46,11 @@ enum tshut_polarity {
>   TSHUT_HIGH_ACTIVE,
>  };
>  
> -/**
> - * The system has three Temperature Sensors.  channel 0 is reserved,
> - * channel 1 is for CPU, and channel 2 is for GPU.
> - */
> -enum sensor_id {
> - SENSOR_CPU = 1,
> - SENSOR_GPU,
> -};
> -
>  struct rockchip_tsadc_chip {
> + /* The sensor id of chip correspond to the ADC channel */
> + int cpu_id;
> + int gpu_id;
> +
>   /* The hardware-controlled tshut property */
>   long tshut_temp;
>   enum tshut_mode tshut_mode;
> @@ -72,10 +70,11 @@ struct rockchip_tsadc_chip {
>  struct rockchip_thermal_sensor {
>   struct rockchip_thermal_data *thermal;
>   struct thermal_zone_device *tzd;
> - enum sensor_id id;
> + int id;
>  };
>  
> -#define NUM_SENSORS  2 /* Ignore unused sensor 0 */
> +/* Two sensors: CPU and GPU */
> +#define NUM_SENSORS  2
>  
>  struct rockchip_thermal_data {
>   const struct rockchip_tsadc_chip *chip;
> @@ -94,7 +93,7 @@ struct rockchip_thermal_data {
>   enum tshut_polarity tshut_polarity;
>  };
>  
> -/* TSADC V2 Sensor info define: */
> +/* TSADC Sensor info define: */
>  #define TSADCV2_AUTO_CON 0x04
>  #define TSADCV2_INT_EN   0x08
>  #define TSADCV2_INT_PD   0x0c
> @@ -116,6 +115,8 @@ struct rockchip_thermal_data {
>  #define TSADCV2_INT_PD_CLEAR_MASK~BIT(8)
>  
>  #define TSADCV2_DATA_MASK0xfff
> +#define TSADCV3_DATA_MASK0x3ff
> +
>  #define TSADCV2_HIGHT_INT_DEBOUNCE_COUNT 4
>  #define TSADCV2_HIGHT_TSHUT_DEBOUNCE_COUNT   4
>  #define TSADCV2_AUTO_PERIOD_TIME 250 /* msec */
> @@ -164,6 +165,45 @@ static const struct tsadc_table v2_code_table[] = {
>   {3421, 125000},
>  };
>  
> +static const struct tsadc_table v3_code_table[] = {
> + {0, -4},
> + {106, -4},
> + {108, -35000},
> + {110, -3},
> + {112, -25000},
> + {114, -2},
> + {116, -15000},
> + {118, -1},
> + {120, -5000},
> + {122, 0},
> + {124, 5000},
> + {126, 1},
> + {128, 15000},
> + {130, 2},
> + {132, 25000},
> + {134, 3},
> + {136, 35000},
> + {138, 4},
> + {140, 45000},
> + {142, 5},
> + {144, 55000},
> + {146, 6},
> + {148, 65000},
> + {150, 7},
> + {152, 75000},
> + {154, 8},
> + {156, 85000},
> + {158, 9},
> + {160, 95000},
> + {162, 10},
> + {163, 105000},
> + {165, 11},
> + {167, 115000},
> + {169, 12},
> + {171, 125000},
> + {TSADCV3_DATA_MASK, 125000},
> +};
> +
>  static u32 rk_tsadcv2_temp_to_code(long temp)
>  {
>   int high, low, mid;
> @@ -227,16 +267,83 @@ static int rk_tsadcv2_code_to_temp(u32 code, int *temp)
>   return 0;
>  }
>  
> +static u32 rk_tsadcv3_temp_to_code(long temp)
> +{
> + int high, low, mid;
> +
> + low = 0;
> + high = ARRAY_SIZE(v3_code_table) - 1;
> + mid = (high + low) / 2;
> +
> + if (temp < v3_code_table[low].temp || temp > v3_code_table[high].temp)
> + return 0;

How is this different from v2 conversion except for the table being
used? I think you should be able to reuse the conversion routines if you
pass the conversion table in as a parameter.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] input: gpio_keys_polled: Add support for abs/rel axis

2015-09-19 Thread Dmitry Torokhov
On Thu, Sep 17, 2015 at 06:14:40PM -0400, Hans de Goede wrote:
> Add support for EV_ABS / EV_REL events to the gpio-keys-polled driver.
> 
> Signed-off-by: Hans de Goede 
> ---
> Changes in v2:
> -Fix commit message to actually describe what the patch does
>  (fix patch squashing fail)
> ---
>  drivers/input/keyboard/gpio_keys_polled.c | 88 
> +++
>  1 file changed, 79 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/input/keyboard/gpio_keys_polled.c 
> b/drivers/input/keyboard/gpio_keys_polled.c
> index 870cfa6..62bdb1d 100644
> --- a/drivers/input/keyboard/gpio_keys_polled.c
> +++ b/drivers/input/keyboard/gpio_keys_polled.c
> @@ -40,10 +40,36 @@ struct gpio_keys_polled_dev {
>   struct input_polled_dev *poll_dev;
>   struct device *dev;
>   const struct gpio_keys_platform_data *pdata;
> + unsigned long rel_axis_seen[BITS_TO_LONGS(REL_CNT)];
> + unsigned long abs_axis_seen[BITS_TO_LONGS(ABS_CNT)];
>   struct gpio_keys_button_data data[0];
>  };
>  
> -static void gpio_keys_polled_check_state(struct input_dev *input,
> +static void gpio_keys_button_event(struct input_polled_dev *dev,
> +struct gpio_keys_button *button,
> +int state)
> +{
> + struct gpio_keys_polled_dev *bdev = dev->private;
> + struct input_dev *input = dev->input;
> + unsigned int type = button->type ?: EV_KEY;
> +
> + if (type == EV_REL) {
> + if (state) {
> + input_event(input, type, button->code, button->value);
> + __set_bit(button->code, bdev->rel_axis_seen);
> + }
> + } else if (type == EV_ABS) {
> + if (state) {
> + input_event(input, type, button->code, button->value);
> + __set_bit(button->code, bdev->abs_axis_seen);
> + }
> + } else {
> + input_event(input, type, button->code, state);
> + input_sync(input);
> + }
> +}
> +
> +static void gpio_keys_polled_check_state(struct input_polled_dev *dev,
>struct gpio_keys_button *button,
>struct gpio_keys_button_data *bdata)
>  {
> @@ -54,11 +80,9 @@ static void gpio_keys_polled_check_state(struct input_dev 
> *input,
>   else
>   state = !!gpiod_get_value(button->gpiod);
>  
> - if (state != bdata->last_state) {
> - unsigned int type = button->type ?: EV_KEY;
> + gpio_keys_button_event(dev, button, state);
>  
> - input_event(input, type, button->code, state);
> - input_sync(input);
> + if (state != bdata->last_state) {
>   bdata->count = 0;
>   bdata->last_state = state;
>   }
> @@ -71,15 +95,33 @@ static void gpio_keys_polled_poll(struct input_polled_dev 
> *dev)
>   struct input_dev *input = dev->input;
>   int i;
>  
> + memset(bdev->rel_axis_seen, 0, sizeof(bdev->rel_axis_seen));
> + memset(bdev->abs_axis_seen, 0, sizeof(bdev->abs_axis_seen));
> +
>   for (i = 0; i < pdata->nbuttons; i++) {
>   struct gpio_keys_button_data *bdata = &bdev->data[i];
>  
> - if (bdata->count < bdata->threshold)
> + if (bdata->count < bdata->threshold) {
>   bdata->count++;
> - else
> - gpio_keys_polled_check_state(input, &pdata->buttons[i],
> + gpio_keys_button_event(dev, &pdata->buttons[i],
> +bdata->last_state);
> + } else {
> + gpio_keys_polled_check_state(dev, &pdata->buttons[i],
>bdata);
> + }
> + }
> +
> + for_each_set_bit(i, input->relbit, REL_CNT) {
> + if (!test_bit(i, bdev->rel_axis_seen))
> + input_event(input, EV_REL, i, 0);
> + }

I wonder if this should be written as

for_each_set_bit(i, bdev->rel_axis_seen, REL_CNT)
input_event(input, EV_REL, i, 0);

i.e. the 2nd bit test is not really needed because we should not see
unsupported bits in "seen" axes.

> +
> + for_each_set_bit(i, input->absbit, ABS_CNT) {
> + if (!test_bit(i, bdev->abs_axis_seen))
> + input_event(input, EV_ABS, i, 0);
>   }
> +
> + input_sync(input);
>  }
>  
>  static void gpio_keys_polled_open(struct input_polled_dev *dev)
> @@ -152,6 +194,10 @@ static struct gpio_keys_platform_data 
> *gpio_keys_polled_get_devtree_pdata(struct
>&button->type))
>   button->type = EV_KEY;
>  
> + if (fwnode_property_read_u32(child, "linux,input-value",
> +  (u32 *)&button->value))
> + button->value = 1;

Umm, we need negative values too... but there is no
fwnode_pro

Re: [PATCH] Documentation: cypress,cyapa.txt: correct the I2C address of Gen3 touchpads to 0x67

2015-09-19 Thread Dmitry Torokhov
On Fri, Sep 18, 2015 at 10:37:44AM +0800, Dudley Du wrote:
> All of the Gen3 touchpads are fixed with I2C address 0x67, so correct the
> reg value description from 0x24 to 0x67.
> 
> Signed-off-by: Dudley Du 

Applied, thank you.

> ---
>  Documentation/devicetree/bindings/input/cypress,cyapa.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/input/cypress,cyapa.txt 
> b/Documentation/devicetree/bindings/input/cypress,cyapa.txt
> index 635a3b0..8d91ba9 100644
> --- a/Documentation/devicetree/bindings/input/cypress,cyapa.txt
> +++ b/Documentation/devicetree/bindings/input/cypress,cyapa.txt
> @@ -25,7 +25,7 @@ Example:
>   /* Cypress Gen3 touchpad */
>   touchpad@67 {
>   compatible = "cypress,cyapa";
> - reg = <0x24>;
> + reg = <0x67>;
>   interrupt-parent = <&gpio>;
>   interrupts = <2 IRQ_TYPE_EDGE_FALLING>; /* GPIO 2 */
>   wakeup-source;
> -- 
> 1.9.1
> 
> 
> ---
> This message and any attachments may contain Cypress (or its
> subsidiaries) confidential information. If it has been received
> in error, please advise the sender and immediately delete this
> message.
> ---
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] devicetree: bindings: Add header file with evdev type and abs/rel code defines

2015-09-12 Thread Dmitry Torokhov
On Thu, Sep 10, 2015 at 3:48 PM, Rob Herring  wrote:
> +Ian
>
> On 09/10/2015 01:50 PM, Hans de Goede wrote:
>> Hi,
>>
>> On 10-09-15 20:42, Dmitry Torokhov wrote:
>>> On Thu, Sep 10, 2015 at 11:40 AM, Hans de Goede 
>>> wrote:
>>>> Hi,
>>>>
>>>>
>>>> On 10-09-15 20:34, Dmitry Torokhov wrote:
>>>>>
>>>>> On Thu, Sep 10, 2015 at 10:25 AM, Rob Herring  wrote:
>>>>>>
>>>>>> On 09/09/2015 04:11 AM, Hans de Goede wrote:
>>>>>>>
>>>>>>> This header provides evdev constants for linux,code, and
>>>>>>> linux,input-*
>>>>>>> properties.
>>>>>>>
>>>>>>> Signed-off-by: Hans de Goede 
>>>>>>> ---
>>>>>>>include/dt-bindings/input/evdev.h | 76
>>>>>>> +++
>>>>>>
>>>>>>
>>>>>> This looks fine, but please just add to input/input.h.
>
> [...]
>
>>>>> Actually I'd rather we removed include/dt-bindings/input/input.h and
>>>>> instead used the header file from uapi. As it is now we already
>>>>> duplicating definitions and the copy in dt-bindings is missing several
>>>>> key codes. Until we split DT bindings form the kernel code I'd rather
>>>>> have definitions in one place.
>
> We do already have split binding tree. It is generated from the kernel
> tree ATM.

But the data in the kernel is the "source of truth" for now since the
other tree is simply generated.

> Adding Ian for any comments.
>
>>>> AFAIK we cannot do that as the uapi header also contains things like:
>>>>
>>>> struct input_event {
>>>>  struct timeval time;
>>>>  __u16 type;
>>>>  __u16 code;
>>>>  __s32 value;
>>>> };
>>>>
>>>> Which is not valid device tree syntax.
>>>>
>>>> If you want this we need to split the uapi headers in one with only
>>>> defines and one with all the rest.
>>>
>>> That would be fine by me. event-codes.h?
>>
>> Since this will live in the generic include/linux namespace (for userspace)
>> maybe input-event-codes ?
>>
>> Rob are you ok with including uapi headers from dts files if those uapi
>> headers are guaranteed to have only #define-s in them?
>
> No. If you can do it as a symlink or some limited way, I'd be fine with
> that. I don't want to see wholesale addition of uapi headers though.

Umm, not sure if I like symlink, it makes hard to see what includes
what. The individual DTSes will continue including
dt-bindings/input/input.h and only input.h will include uapi header
(so use of uapi is internal detail). Would that still be a problem?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts

2015-09-12 Thread Dmitry Torokhov
Now that the driver respects IRQ trigger settings from device tree, let's
fix them up in individual DTSes (note that the driver is still compatible
with older DTSes).

Signed-off-by: Dmitry Torokhov 
---
 arch/arm/boot/dts/am437x-sk-evm.dts   | 2 +-
 arch/arm/boot/dts/imx28-tx28.dts  | 3 ++-
 arch/arm/boot/dts/imx53-tx53-x03x.dts | 3 ++-
 arch/arm/boot/dts/imx6qdl-tx6.dtsi| 3 ++-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts 
b/arch/arm/boot/dts/am437x-sk-evm.dts
index c17097d..d83fdcd 100644
--- a/arch/arm/boot/dts/am437x-sk-evm.dts
+++ b/arch/arm/boot/dts/am437x-sk-evm.dts
@@ -471,7 +471,7 @@
 
reg = <0x38>;
interrupt-parent = <&gpio0>;
-   interrupts = <31 0>;
+   interrupts = <31 IRQ_TYPE_EDGE_FALLING>;
 
reset-gpios = <&gpio1 28 GPIO_ACTIVE_LOW>;
 
diff --git a/arch/arm/boot/dts/imx28-tx28.dts b/arch/arm/boot/dts/imx28-tx28.dts
index a5b27c8..4ea8934 100644
--- a/arch/arm/boot/dts/imx28-tx28.dts
+++ b/arch/arm/boot/dts/imx28-tx28.dts
@@ -13,6 +13,7 @@
 /dts-v1/;
 #include "imx28.dtsi"
 #include 
+#include 
 
 / {
model = "Ka-Ro electronics TX28 module";
@@ -324,7 +325,7 @@
pinctrl-names = "default";
pinctrl-0 = <&tx28_edt_ft5x06_pins>;
interrupt-parent = <&gpio2>;
-   interrupts = <5 0>;
+   interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
};
diff --git a/arch/arm/boot/dts/imx53-tx53-x03x.dts 
b/arch/arm/boot/dts/imx53-tx53-x03x.dts
index 3b73e81..13e842b 100644
--- a/arch/arm/boot/dts/imx53-tx53-x03x.dts
+++ b/arch/arm/boot/dts/imx53-tx53-x03x.dts
@@ -12,6 +12,7 @@
 /dts-v1/;
 #include "imx53-tx53.dtsi"
 #include 
+#include 
 #include 
 
 / {
@@ -216,7 +217,7 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_edt_ft5x06_1>;
interrupt-parent = <&gpio6>;
-   interrupts = <15 0>;
+   interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
reset-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
wake-gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>;
};
diff --git a/arch/arm/boot/dts/imx6qdl-tx6.dtsi 
b/arch/arm/boot/dts/imx6qdl-tx6.dtsi
index da08de3..13cb7cc 100644
--- a/arch/arm/boot/dts/imx6qdl-tx6.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-tx6.dtsi
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -272,7 +273,7 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_edt_ft5x06>;
interrupt-parent = <&gpio6>;
-   interrupts = <15 0>;
+   interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
reset-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
wake-gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>;
linux,wakeup;
-- 
2.6.0.rc0.131.gf624c3d

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] devicetree: bindings: Add header file with evdev type and abs/rel code defines

2015-09-10 Thread Dmitry Torokhov
On Thu, Sep 10, 2015 at 11:40 AM, Hans de Goede  wrote:
> Hi,
>
>
> On 10-09-15 20:34, Dmitry Torokhov wrote:
>>
>> On Thu, Sep 10, 2015 at 10:25 AM, Rob Herring  wrote:
>>>
>>> On 09/09/2015 04:11 AM, Hans de Goede wrote:
>>>>
>>>> This header provides evdev constants for linux,code, and linux,input-*
>>>> properties.
>>>>
>>>> Signed-off-by: Hans de Goede 
>>>> ---
>>>>   include/dt-bindings/input/evdev.h | 76
>>>> +++
>>>
>>>
>>> This looks fine, but please just add to input/input.h.
>>>
>>> Rob
>>>
>>>>   1 file changed, 76 insertions(+)
>>>>   create mode 100644 include/dt-bindings/input/evdev.h
>>>>
>>>> diff --git a/include/dt-bindings/input/evdev.h
>>>> b/include/dt-bindings/input/evdev.h
>>>> new file mode 100644
>>>> index 000..c1f7e0d
>>>> --- /dev/null
>>>> +++ b/include/dt-bindings/input/evdev.h
>>>> @@ -0,0 +1,76 @@
>>>> +/*
>>>> + * This header provides evdev constants for linux,code, and
>>>> linux,input-*
>>>> + * properties.
>>>> + */
>>>> +
>>>> +#ifndef _DT_BINDINGS_INPUT_LINUX_H
>>>> +#define _DT_BINDINGS_INPUT_LINUX_H
>>>> +
>>>> +/*
>>>> + * Event types
>>>> + */
>>>> +
>>>> +#define EV_SYN   0x00
>>>> +#define EV_KEY   0x01
>>>> +#define EV_REL   0x02
>>>> +#define EV_ABS   0x03
>>>> +#define EV_MSC   0x04
>>>> +#define EV_SW0x05
>>>> +#define EV_LED   0x11
>>>> +#define EV_SND   0x12
>>>> +#define EV_REP   0x14
>>>> +#define EV_FF0x15
>>>> +#define EV_PWR   0x16
>>>> +#define EV_FF_STATUS 0x17
>>>> +#define EV_MAX   0x1f
>>>> +
>>>> +/*
>>>> + * Relative axes
>>>> + */
>>>> +
>>>> +#define REL_X0x00
>>>> +#define REL_Y0x01
>>>> +#define REL_Z0x02
>>>> +#define REL_RX   0x03
>>>> +#define REL_RY   0x04
>>>> +#define REL_RZ   0x05
>>>> +#define REL_HWHEEL   0x06
>>>> +#define REL_DIAL 0x07
>>>> +#define REL_WHEEL0x08
>>>> +#define REL_MISC 0x09
>>>> +#define REL_MAX  0x0f
>>>> +
>>>> +/*
>>>> + * Absolute axes
>>>> + */
>>>> +
>>>> +#define ABS_X0x00
>>>> +#define ABS_Y0x01
>>>> +#define ABS_Z0x02
>>>> +#define ABS_RX   0x03
>>>> +#define ABS_RY   0x04
>>>> +#define ABS_RZ   0x05
>>>> +#define ABS_THROTTLE 0x06
>>>> +#define ABS_RUDDER   0x07
>>>> +#define ABS_WHEEL0x08
>>>> +#define ABS_GAS  0x09
>>>> +#define ABS_BRAKE0x0a
>>>> +#define ABS_HAT0X0x10
>>>> +#define ABS_HAT0Y0x11
>>>> +#define ABS_HAT1X0x12
>>>> +#define ABS_HAT1Y0x13
>>>> +#define ABS_HAT2X0x14
>>>> +#define ABS_HAT2Y0x15
>>>> +#define ABS_HAT3X0x16
>>>> +#define ABS_HAT3Y0x17
>>>> +#define ABS_PRESSURE 0x18
>>>> +#define ABS_DISTANCE 0x19
>>>> +#define ABS_TILT_X   0x1a
>>>> +#define ABS_TILT_Y   0x1b
>>>> +#define ABS_TOOL_WIDTH   0x1c
>>>> +
>>>> +#define ABS_VOLUME   0x20
>>>> +
>>>> +#define ABS_MISC 0x28
>>>> +
>>>> +#endif /* _DT_BINDINGS_INPUT_LINUX_H */
>>>>
>>>
>>
>> Actually I'd rather we removed include/dt-bindings/input/input.h and
>> instead used the header file from uapi. As it is now we already
>> duplicating definitions and the copy in dt-bindings is missing several
>> key codes. Until we split DT bindings form the kernel code I'd rather
>> have definitions in one place.
>
>
> AFAIK we cannot do that as the uapi header also contains things like:
>
> struct input_event {
> struct timeval time;
> __u16 type;
> __u16 code;
> __s32 value;
> };
>
> Which is not valid device tree syntax.
>
> If you want this we need to split the uapi headers in one with only
> defines and one with all the rest.

That would be fine by me. event-codes.h?

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] devicetree: bindings: Add header file with evdev type and abs/rel code defines

2015-09-10 Thread Dmitry Torokhov
On Thu, Sep 10, 2015 at 10:25 AM, Rob Herring  wrote:
> On 09/09/2015 04:11 AM, Hans de Goede wrote:
>> This header provides evdev constants for linux,code, and linux,input-*
>> properties.
>>
>> Signed-off-by: Hans de Goede 
>> ---
>>  include/dt-bindings/input/evdev.h | 76 
>> +++
>
> This looks fine, but please just add to input/input.h.
>
> Rob
>
>>  1 file changed, 76 insertions(+)
>>  create mode 100644 include/dt-bindings/input/evdev.h
>>
>> diff --git a/include/dt-bindings/input/evdev.h 
>> b/include/dt-bindings/input/evdev.h
>> new file mode 100644
>> index 000..c1f7e0d
>> --- /dev/null
>> +++ b/include/dt-bindings/input/evdev.h
>> @@ -0,0 +1,76 @@
>> +/*
>> + * This header provides evdev constants for linux,code, and linux,input-*
>> + * properties.
>> + */
>> +
>> +#ifndef _DT_BINDINGS_INPUT_LINUX_H
>> +#define _DT_BINDINGS_INPUT_LINUX_H
>> +
>> +/*
>> + * Event types
>> + */
>> +
>> +#define EV_SYN   0x00
>> +#define EV_KEY   0x01
>> +#define EV_REL   0x02
>> +#define EV_ABS   0x03
>> +#define EV_MSC   0x04
>> +#define EV_SW0x05
>> +#define EV_LED   0x11
>> +#define EV_SND   0x12
>> +#define EV_REP   0x14
>> +#define EV_FF0x15
>> +#define EV_PWR   0x16
>> +#define EV_FF_STATUS 0x17
>> +#define EV_MAX   0x1f
>> +
>> +/*
>> + * Relative axes
>> + */
>> +
>> +#define REL_X0x00
>> +#define REL_Y0x01
>> +#define REL_Z0x02
>> +#define REL_RX   0x03
>> +#define REL_RY   0x04
>> +#define REL_RZ   0x05
>> +#define REL_HWHEEL   0x06
>> +#define REL_DIAL 0x07
>> +#define REL_WHEEL0x08
>> +#define REL_MISC 0x09
>> +#define REL_MAX  0x0f
>> +
>> +/*
>> + * Absolute axes
>> + */
>> +
>> +#define ABS_X0x00
>> +#define ABS_Y0x01
>> +#define ABS_Z0x02
>> +#define ABS_RX   0x03
>> +#define ABS_RY   0x04
>> +#define ABS_RZ   0x05
>> +#define ABS_THROTTLE 0x06
>> +#define ABS_RUDDER   0x07
>> +#define ABS_WHEEL0x08
>> +#define ABS_GAS  0x09
>> +#define ABS_BRAKE0x0a
>> +#define ABS_HAT0X0x10
>> +#define ABS_HAT0Y0x11
>> +#define ABS_HAT1X0x12
>> +#define ABS_HAT1Y0x13
>> +#define ABS_HAT2X0x14
>> +#define ABS_HAT2Y0x15
>> +#define ABS_HAT3X0x16
>> +#define ABS_HAT3Y0x17
>> +#define ABS_PRESSURE 0x18
>> +#define ABS_DISTANCE 0x19
>> +#define ABS_TILT_X   0x1a
>> +#define ABS_TILT_Y   0x1b
>> +#define ABS_TOOL_WIDTH   0x1c
>> +
>> +#define ABS_VOLUME   0x20
>> +
>> +#define ABS_MISC 0x28
>> +
>> +#endif /* _DT_BINDINGS_INPUT_LINUX_H */
>>
>

Actually I'd rather we removed include/dt-bindings/input/input.h and
instead used the header file from uapi. As it is now we already
duplicating definitions and the copy in dt-bindings is missing several
key codes. Until we split DT bindings form the kernel code I'd rather
have definitions in one place.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/5] input: touchscreen: add imx6ul_tsc driver support

2015-09-05 Thread Dmitry Torokhov
On Fri, Aug 28, 2015 at 05:09:32PM +0800, Haibo Chen wrote:
> Freescale i.MX6UL contains a internal touchscreen controller,
> this patch add a driver to support this controller.
> 
> Signed-off-by: Haibo Chen 

Merged #1 and #2 and applied, thank you.

Also:

> + /*
> +  * Delay some time(max 2ms), wait the pre-charge done.
> +  * After the pre-change mode, TSC go into detect mode.
> +  * And in detect mode, we can get the xnur gpio value.
> +  * If xnur is high, this means the touch screen still
> +  * be touched. If xnur is low, this means finger leave
> +  * the touch screen.
> +  */
> + timeout = jiffies + HZ/500;

I do not think that would quite work with HZ < 500. I changed this to

timeout = jiffies + msecs_to_jiffies(2);

and also moved this block into a separate function.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 3/3] touchscreen: colibri-vf50-ts: Add touchscreen support for Colibri VF50

2015-09-05 Thread Dmitry Torokhov
On Tue, Sep 01, 2015 at 06:06:55PM +0530, Sanchayan Maity wrote:
> The Colibri Vybrid VF50 module supports 4-wire touchscreens using
> FETs and ADC inputs. This driver uses the IIO consumer interface
> and relies on the vf610_adc driver based on the IIO framework.
> 
> Signed-off-by: Sanchayan Maity 

Merged #2 and #3 and applied, thank you.

> ---
>  drivers/input/touchscreen/Kconfig   |  12 +
>  drivers/input/touchscreen/Makefile  |   1 +
>  drivers/input/touchscreen/colibri-vf50-ts.c | 381 
> 
>  3 files changed, 394 insertions(+)
>  create mode 100644 drivers/input/touchscreen/colibri-vf50-ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 80f6386..28948ca 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -1027,4 +1027,16 @@ config TOUCHSCREEN_ZFORCE
> To compile this driver as a module, choose M here: the
> module will be called zforce_ts.
>  
> +config TOUCHSCREEN_COLIBRI_VF50
> + tristate "Toradex Colibri on board touchscreen driver"
> + depends on GPIOLIB && IIO && VF610_ADC
> + help
> +   Say Y here if you have a Colibri VF50 and plan to use
> +   the on-board provided 4-wire touchscreen driver.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called colibri_vf50_ts.
> +
>  endif
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 44deea7..93746a0 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -84,3 +84,4 @@ obj-$(CONFIG_TOUCHSCREEN_W90X900)   += w90p910_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o
>  obj-$(CONFIG_TOUCHSCREEN_TPS6507X)   += tps6507x-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50)   += colibri-vf50-ts.o
> diff --git a/drivers/input/touchscreen/colibri-vf50-ts.c 
> b/drivers/input/touchscreen/colibri-vf50-ts.c
> new file mode 100644
> index 000..26187e0
> --- /dev/null
> +++ b/drivers/input/touchscreen/colibri-vf50-ts.c
> @@ -0,0 +1,381 @@
> +/* Copyright 2015 Toradex AG
> + *
> + * Toradex Colibri VF50 Touchscreen driver
> + *
> + * Originally authored by Stefan Agner for 3.0 kernel
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DRIVER_NAME "colibri-vf50-ts"
> +#define DRV_VERSION "1.0"
> +
> +#define VF_ADC_MAX ((1 << 12) - 1)
> +
> +#define COLI_TOUCH_MIN_DELAY_US 1000
> +#define COLI_TOUCH_MAX_DELAY_US 2000
> +#define COLI_TOUCH_NO_OF_AVGS5
> +#define COLI_TOUCH_REQ_ADC_CHAN  4
> +
> +struct vf50_touch_device {
> + struct platform_device  *pdev;
> + struct input_dev*ts_input;
> + struct iio_channel  *channels;
> + struct gpio_desc *gpio_xp;
> + struct gpio_desc *gpio_xm;
> + struct gpio_desc *gpio_yp;
> + struct gpio_desc *gpio_ym;
> + int pen_irq;
> + int min_pressure;
> + bool stop_touchscreen;
> +};
> +
> +/*
> + * Enables given plates and measures touch parameters using ADC
> + */
> +static int adc_ts_measure(struct iio_channel *channel,
> +   struct gpio_desc *plate_p, struct gpio_desc *plate_m)
> +{
> + int i, value = 0, val = 0;
> + int ret;
> +
> + gpiod_set_value(plate_p, 1);
> + gpiod_set_value(plate_m, 1);
> +
> + usleep_range(COLI_TOUCH_MIN_DELAY_US, COLI_TOUCH_MAX_DELAY_US);
> +
> + for (i = 0; i < COLI_TOUCH_NO_OF_AVGS; i++) {
> + ret = iio_read_channel_raw(channel, &val);
> + if (ret < 0) {
> + value = ret;
> + goto error_iio_read;
> + }
> +
> + value += val;
> + }
> +
> + value /= COLI_TOUCH_NO_OF_AVGS;
> +
> +error_iio_read:
> + gpiod_set_value(plate_p, 0);
> + gpiod_set_value(plate_m, 0);
> +
> + return value;
> +}
> +
> +/*
> + * Enable touch detection using falling edge detection on XM
> + */
> +static void vf50_ts_enable_touch_detection(struct vf50_touch_device *vf50_ts)
> +{
> + /* Enable plate YM (needs to be strong GND, high active) */
> + gpiod_set_value(vf50_ts->gpio_ym, 1);
> +
> + /*
> +  * Let the platform mux to idle state in order to enable
> +  * Pull-Up on GPIO
> +  */
> + pinctrl_pm_select_idle_state(&vf50_ts->pdev->dev);
> +}
> +
> +/*
> + * ADC touch screen sampling bottom half irq handler
> + */
> +static irqreturn_t vf50_ts_irq_bh(int irq, void *private)
> +{
> + s

[PATCH] of/irq: export of_get_irq_byname()

2015-08-25 Thread Dmitry Torokhov
Similarly to of_get_irq(), let's export of_irq_get_byname(), so if a bus core
can be compiled as a module (such as I2C) it can have access to the symbol.

Reported-by: Stephen Rothwell 
Reported-by: kbuild test robot 
Signed-off-by: Dmitry Torokhov 
---
 drivers/of/irq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 7ef837e..1a7911d 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -446,6 +446,7 @@ int of_irq_get_byname(struct device_node *dev, const char 
*name)
 
return of_irq_get(dev, index);
 }
+EXPORT_SYMBOL_GPL(of_irq_get_byname);
 
 /**
  * of_irq_count - Count the number of IRQs a node uses
-- 
2.5.0.457.gab17608


-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH v16 4/4] ARM: dts: add the support power-domain node on RK3288 SoCs

2015-08-25 Thread Dmitry Torokhov
On Tue, Aug 25, 2015 at 3:45 PM, Kevin Hilman  wrote:
> Doug Anderson  writes:
>
>> To put things in a
>> concrete way, for pd_vio we'd go through the entire device tree
>> ourselves and find all properties that look like "power-domains =
>> <&power RK3288_PD_VIO>;".  We'd then find the parent of those
>> properties and look for a property named "clocks".  We'd then iterate
>> over all those clocks and turn those on.  Did I get that right?
>
> ... but you make it sound like more work than it is.  The genpd already
> keeps a list of devices that refer to the power domain.  In fact, the
> genpd 'attach' method can be platform-specific, so could be used to keep
> track of a list (or a subset) of clocks which are needed for reset.

That is not really workable: the attach and detach happen in
probe/remove path; if you do not have driver for the device you will
miss the clocks for it. And the quirk of this SoC is that we need to
turn all clocks during domain transition, regardless of whether there
is a driver for all devices.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Input: edt-ft5x06 - Switch to newer gpio framework

2015-08-24 Thread Dmitry Torokhov
On Mon, Aug 24, 2015 at 05:16:15PM -0500, Franklin S Cooper Jr. wrote:
> 
> 
> On 08/24/2015 03:56 PM, Dmitry Torokhov wrote:
> > On Mon, Aug 24, 2015 at 03:23:43PM -0500, Franklin S Cooper Jr. wrote:
> >>
> >> On 08/24/2015 03:16 PM, Franklin S Cooper Jr. wrote:
> >>> On 08/24/2015 03:01 PM, Dmitry Torokhov wrote:
> >>>> On Mon, Aug 24, 2015 at 02:48:36PM -0500, Franklin S Cooper Jr. wrote:
> >>>>> On 08/24/2015 02:41 PM, Dmitry Torokhov wrote:
> >>>>>> On Fri, Aug 21, 2015 at 02:08:32PM -0500, Franklin S Cooper Jr wrote:
> >>>>>>> The current/old gpio framework used doesn't properly listen to
> >>>>>>> ACTIVE_LOW and ACTIVE_HIGH flags. The newer gpio framework takes into
> >>>>>>> account these flags when setting gpio values.
> >>>>>>>
> >>>>>>> Also use gpiod_set_value_cansleep since wake and reset pins can be
> >>>>>>> provided by bus based io expanders.
> >>>>>>>
> >>>>>>> Signed-off-by: Franklin S Cooper Jr 
> >>>>>>> ---
> >>>>>>>  .../bindings/input/touchscreen/edt-ft5x06.txt  |   4 +-
> >>>>>>>  drivers/input/touchscreen/edt-ft5x06.c | 115 
> >>>>>>> +++--
> >>>>>>>  include/linux/input/edt-ft5x06.h   |   4 +-
> >>>>>>>  3 files changed, 43 insertions(+), 80 deletions(-)
> >>>>>>>
> >>>>>>> diff --git 
> >>>>>>> a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt 
> >>>>>>> b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> >>>>>>> index 76db967..9330d4d 100644
> >>>>>>> --- 
> >>>>>>> a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> >>>>>>> +++ 
> >>>>>>> b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> >>>>>>> @@ -50,6 +50,6 @@ Example:
> >>>>>>>   pinctrl-0 = <&edt_ft5x06_pins>;
> >>>>>>>   interrupt-parent = <&gpio2>;
> >>>>>>>   interrupts = <5 0>;
> >>>>>>> - reset-gpios = <&gpio2 6 1>;
> >>>>>>> - wake-gpios = <&gpio4 9 0>;
> >>>>>>> + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
> >>>>>>> + wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
> >>>>>>>   };
> >>>>>>> diff --git a/drivers/input/touchscreen/edt-ft5x06.c 
> >>>>>>> b/drivers/input/touchscreen/edt-ft5x06.c
> >>>>>>> index 394b1de..6b128b3 100644
> >>>>>>> --- a/drivers/input/touchscreen/edt-ft5x06.c
> >>>>>>> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> >>>>>>> @@ -91,9 +91,9 @@ struct edt_ft5x06_ts_data {
> >>>>>>>   u16 num_x;
> >>>>>>>   u16 num_y;
> >>>>>>>  
> >>>>>>> - int reset_pin;
> >>>>>>> - int irq_pin;
> >>>>>>> - int wake_pin;
> >>>>>>> + struct gpio_desc *reset_pin;
> >>>>>>> + struct gpio_desc *wake_pin;
> >>>>>>> + struct gpio_desc *irq_pin;
> >>>>>>>  
> >>>>>>>  #if defined(CONFIG_DEBUG_FS)
> >>>>>>>   struct dentry *debug_dir;
> >>>>>>> @@ -755,36 +755,14 @@ edt_ft5x06_ts_teardown_debugfs(struct 
> >>>>>>> edt_ft5x06_ts_data *tsdata)
> >>>>>>>  static int edt_ft5x06_ts_reset(struct i2c_client *client,
> >>>>>>>   struct edt_ft5x06_ts_data *tsdata)
> >>>>>>>  {
> >>>>>>> - int error;
> >>>>>>> -
> >>>>>>> - if (gpio_is_valid(tsdata->wake_pin)) {
> >>>>>>> - error = devm_gpio_request_one(&client->dev,
> >>>>>>> - tsdata->wake_pin, 
> >>>>>>> GPIOF_OUT_INIT_LOW,
> &

Re: [PATCH] Input: edt-ft5x06 - Switch to newer gpio framework

2015-08-24 Thread Dmitry Torokhov
On Mon, Aug 24, 2015 at 03:23:43PM -0500, Franklin S Cooper Jr. wrote:
> 
> 
> On 08/24/2015 03:16 PM, Franklin S Cooper Jr. wrote:
> >
> > On 08/24/2015 03:01 PM, Dmitry Torokhov wrote:
> >> On Mon, Aug 24, 2015 at 02:48:36PM -0500, Franklin S Cooper Jr. wrote:
> >>> On 08/24/2015 02:41 PM, Dmitry Torokhov wrote:
> >>>> On Fri, Aug 21, 2015 at 02:08:32PM -0500, Franklin S Cooper Jr wrote:
> >>>>> The current/old gpio framework used doesn't properly listen to
> >>>>> ACTIVE_LOW and ACTIVE_HIGH flags. The newer gpio framework takes into
> >>>>> account these flags when setting gpio values.
> >>>>>
> >>>>> Also use gpiod_set_value_cansleep since wake and reset pins can be
> >>>>> provided by bus based io expanders.
> >>>>>
> >>>>> Signed-off-by: Franklin S Cooper Jr 
> >>>>> ---
> >>>>>  .../bindings/input/touchscreen/edt-ft5x06.txt  |   4 +-
> >>>>>  drivers/input/touchscreen/edt-ft5x06.c | 115 
> >>>>> +++--
> >>>>>  include/linux/input/edt-ft5x06.h   |   4 +-
> >>>>>  3 files changed, 43 insertions(+), 80 deletions(-)
> >>>>>
> >>>>> diff --git 
> >>>>> a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt 
> >>>>> b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> >>>>> index 76db967..9330d4d 100644
> >>>>> --- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> >>>>> +++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> >>>>> @@ -50,6 +50,6 @@ Example:
> >>>>> pinctrl-0 = <&edt_ft5x06_pins>;
> >>>>> interrupt-parent = <&gpio2>;
> >>>>> interrupts = <5 0>;
> >>>>> -   reset-gpios = <&gpio2 6 1>;
> >>>>> -   wake-gpios = <&gpio4 9 0>;
> >>>>> +   reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
> >>>>> +   wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
> >>>>> };
> >>>>> diff --git a/drivers/input/touchscreen/edt-ft5x06.c 
> >>>>> b/drivers/input/touchscreen/edt-ft5x06.c
> >>>>> index 394b1de..6b128b3 100644
> >>>>> --- a/drivers/input/touchscreen/edt-ft5x06.c
> >>>>> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> >>>>> @@ -91,9 +91,9 @@ struct edt_ft5x06_ts_data {
> >>>>> u16 num_x;
> >>>>> u16 num_y;
> >>>>>  
> >>>>> -   int reset_pin;
> >>>>> -   int irq_pin;
> >>>>> -   int wake_pin;
> >>>>> +   struct gpio_desc *reset_pin;
> >>>>> +   struct gpio_desc *wake_pin;
> >>>>> +   struct gpio_desc *irq_pin;
> >>>>>  
> >>>>>  #if defined(CONFIG_DEBUG_FS)
> >>>>> struct dentry *debug_dir;
> >>>>> @@ -755,36 +755,14 @@ edt_ft5x06_ts_teardown_debugfs(struct 
> >>>>> edt_ft5x06_ts_data *tsdata)
> >>>>>  static int edt_ft5x06_ts_reset(struct i2c_client *client,
> >>>>> struct edt_ft5x06_ts_data *tsdata)
> >>>>>  {
> >>>>> -   int error;
> >>>>> -
> >>>>> -   if (gpio_is_valid(tsdata->wake_pin)) {
> >>>>> -   error = devm_gpio_request_one(&client->dev,
> >>>>> -   tsdata->wake_pin, 
> >>>>> GPIOF_OUT_INIT_LOW,
> >>>>> -   "edt-ft5x06 wake");
> >>>>> -   if (error) {
> >>>>> -   dev_err(&client->dev,
> >>>>> -   "Failed to request GPIO %d as wake pin, 
> >>>>> error %d\n",
> >>>>> -   tsdata->wake_pin, error);
> >>>>> -   return error;
> >>>>> -   }
> >>>>> -
> >>>>> +   if (tsdata->wake_pin) {
> >>>>>   

Re: [PATCH] Input: edt-ft5x06 - Switch to newer gpio framework

2015-08-24 Thread Dmitry Torokhov
On Fri, Aug 21, 2015 at 02:08:32PM -0500, Franklin S Cooper Jr wrote:
> The current/old gpio framework used doesn't properly listen to
> ACTIVE_LOW and ACTIVE_HIGH flags. The newer gpio framework takes into
> account these flags when setting gpio values.
> 
> Also use gpiod_set_value_cansleep since wake and reset pins can be
> provided by bus based io expanders.
> 
> Signed-off-by: Franklin S Cooper Jr 
> ---
>  .../bindings/input/touchscreen/edt-ft5x06.txt  |   4 +-
>  drivers/input/touchscreen/edt-ft5x06.c | 115 
> +++--
>  include/linux/input/edt-ft5x06.h   |   4 +-
>  3 files changed, 43 insertions(+), 80 deletions(-)
> 
> diff --git 
> a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt 
> b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> index 76db967..9330d4d 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> @@ -50,6 +50,6 @@ Example:
>   pinctrl-0 = <&edt_ft5x06_pins>;
>   interrupt-parent = <&gpio2>;
>   interrupts = <5 0>;
> - reset-gpios = <&gpio2 6 1>;
> - wake-gpios = <&gpio4 9 0>;
> + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
> + wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
>   };
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c 
> b/drivers/input/touchscreen/edt-ft5x06.c
> index 394b1de..6b128b3 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -91,9 +91,9 @@ struct edt_ft5x06_ts_data {
>   u16 num_x;
>   u16 num_y;
>  
> - int reset_pin;
> - int irq_pin;
> - int wake_pin;
> + struct gpio_desc *reset_pin;
> + struct gpio_desc *wake_pin;
> + struct gpio_desc *irq_pin;
>  
>  #if defined(CONFIG_DEBUG_FS)
>   struct dentry *debug_dir;
> @@ -755,36 +755,14 @@ edt_ft5x06_ts_teardown_debugfs(struct 
> edt_ft5x06_ts_data *tsdata)
>  static int edt_ft5x06_ts_reset(struct i2c_client *client,
>   struct edt_ft5x06_ts_data *tsdata)
>  {
> - int error;
> -
> - if (gpio_is_valid(tsdata->wake_pin)) {
> - error = devm_gpio_request_one(&client->dev,
> - tsdata->wake_pin, GPIOF_OUT_INIT_LOW,
> - "edt-ft5x06 wake");
> - if (error) {
> - dev_err(&client->dev,
> - "Failed to request GPIO %d as wake pin, error 
> %d\n",
> - tsdata->wake_pin, error);
> - return error;
> - }
> -
> + if (tsdata->wake_pin) {
>   msleep(5);
> - gpio_set_value(tsdata->wake_pin, 1);
> + gpiod_set_value_cansleep(tsdata->wake_pin, 1);
>   }
> - if (gpio_is_valid(tsdata->reset_pin)) {
> - /* this pulls reset down, enabling the low active reset */
> - error = devm_gpio_request_one(&client->dev,
> - tsdata->reset_pin, GPIOF_OUT_INIT_LOW,
> - "edt-ft5x06 reset");
> - if (error) {
> - dev_err(&client->dev,
> - "Failed to request GPIO %d as reset pin, error 
> %d\n",
> - tsdata->reset_pin, error);
> - return error;
> - }
>  
> + if (tsdata->reset_pin) {
>   msleep(5);
> - gpio_set_value(tsdata->reset_pin, 1);
> + gpiod_set_value_cansleep(tsdata->reset_pin, 1);

So this leaves the reset pin active. How exactly was this tested?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 3/3] touchscreen: colibri-vf50-ts: Add touchscreen support for Colibri VF50

2015-08-23 Thread Dmitry Torokhov
Hi Sanchayan,

On Fri, Aug 21, 2015 at 06:56:32PM +0530, Sanchayan Maity wrote:
> The Colibri Vybrid VF50 module supports 4-wire touchscreens using
> FETs and ADC inputs. This driver uses the IIO consumer interface
> and relies on the vf610_adc driver based on the IIO framework.
> 

Thank you for making changes. I have a few comments still.

> Signed-off-by: Sanchayan Maity 
> ---
>  drivers/input/touchscreen/Kconfig   |  12 +
>  drivers/input/touchscreen/Makefile  |   1 +
>  drivers/input/touchscreen/colibri-vf50-ts.c | 370 
> 
>  3 files changed, 383 insertions(+)
>  create mode 100644 drivers/input/touchscreen/colibri-vf50-ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 80f6386..28948ca 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -1027,4 +1027,16 @@ config TOUCHSCREEN_ZFORCE
> To compile this driver as a module, choose M here: the
> module will be called zforce_ts.
>  
> +config TOUCHSCREEN_COLIBRI_VF50
> + tristate "Toradex Colibri on board touchscreen driver"
> + depends on GPIOLIB && IIO && VF610_ADC

Can we possibly add "|| COMPILE_TEST" dependency? Will it compile
without IIO or VF610_ADC enabled?


> + help
> +   Say Y here if you have a Colibri VF50 and plan to use
> +   the on-board provided 4-wire touchscreen driver.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called colibri_vf50_ts.
> +
>  endif
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 44deea7..93746a0 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -84,3 +84,4 @@ obj-$(CONFIG_TOUCHSCREEN_W90X900)   += w90p910_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o
>  obj-$(CONFIG_TOUCHSCREEN_TPS6507X)   += tps6507x-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50)   += colibri-vf50-ts.o
> diff --git a/drivers/input/touchscreen/colibri-vf50-ts.c 
> b/drivers/input/touchscreen/colibri-vf50-ts.c
> new file mode 100644
> index 000..0793fdc
> --- /dev/null
> +++ b/drivers/input/touchscreen/colibri-vf50-ts.c
> @@ -0,0 +1,370 @@
> +/* Copyright 2015 Toradex AG
> + *
> + * Toradex Colibri VF50 Touchscreen driver
> + *
> + * Originally authored by Stefan Agner for 3.0 kernel
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Don't you need gpio/consumer.h?

> +#include 
> +#include 
> +#include 
> +
> +#define DRIVER_NAME "colibri-vf50-ts"
> +#define DRV_VERSION "1.0"
> +
> +#define VF_ADC_MAX ((1 << 12) - 1)
> +
> +#define COLI_TOUCH_MIN_DELAY_US 1000
> +#define COLI_TOUCH_MAX_DELAY_US 2000
> +#define COLI_TOUCH_NO_OF_AVGS5
> +
> +struct vf50_touch_device {
> + struct platform_device  *pdev;
> + struct input_dev*ts_input;
> + struct iio_channel  *channels;
> + struct gpio_desc *gpio_xp;
> + struct gpio_desc *gpio_xm;
> + struct gpio_desc *gpio_yp;
> + struct gpio_desc *gpio_ym;
> + struct gpio_desc *gpio_pen_detect;

I do not see gpio_pen_detect being used anymore.

> + int pen_irq;
> + int min_pressure;
> + bool stop_touchscreen;
> +};
> +
> +/*
> + * Enables given plates and measures touch parameters using ADC
> + */
> +static int adc_ts_measure(struct iio_channel *channel,
> +   struct gpio_desc *plate_p, struct gpio_desc *plate_m)
> +{
> + int i, value = 0, val = 0;
> + int ret;
> +
> + gpiod_set_value(plate_p, 1);
> + gpiod_set_value(plate_m, 1);
> +
> + usleep_range(COLI_TOUCH_MIN_DELAY_US, COLI_TOUCH_MAX_DELAY_US);
> +
> + for (i = 0; i < COLI_TOUCH_NO_OF_AVGS; i++) {
> + ret = iio_read_channel_raw(channel, &val);
> + if (ret < 0) {
> + value = ret;
> + goto error_iio_read;
> + }
> +
> + value += val;
> + }
> +
> + value /= COLI_TOUCH_NO_OF_AVGS;
> +
> +error_iio_read:
> + gpiod_set_value(plate_p, 0);
> + gpiod_set_value(plate_m, 0);
> +
> + return value;
> +}
> +
> +/*
> + * Enable touch detection using falling edge detection on XM
> + */
> +static void vf50_ts_enable_touch_detection(struct vf50_touch_device *vf50_ts)
> +{
> + /* Enable plate YM (needs to be strong GND, high active) */
> + gpiod_set_value(vf50_ts->gpio_ym, 1);
> +
> + /*
> +  * Let the platform mux to idle state in order to enable
> +  * Pull-Up on GPIO
> +  */
> +

Re: [PATCH v2 1/5] input: touchscreen: add imx6ul_tsc driver support

2015-08-18 Thread Dmitry Torokhov
 ADC_CONV_DISABLE;
> + writel(adc_cfg, tsc->adc_regs + REG_ADC_HC0);
> +}
> +
> +static int imx6ul_tsc_remove(struct platform_device *pdev)
> +{
> + struct imx6ul_tsc *tsc = platform_get_drvdata(pdev);
> +
> + imx6ul_tsc_disable(tsc);
> +
> + clk_disable_unprepare(tsc->tsc_clk);
> + clk_disable_unprepare(tsc->adc_clk);
> + input_unregister_device(tsc->input);
> + kfree(tsc);

Tsc is allocated with devm(), you can't kfree() it.
> +
> + return 0;
> +}
> +
> +static int __maybe_unused imx6ul_tsc_suspend(struct device *dev)
> +{
> + struct platform_device *pdev = to_platform_device(dev);
> + struct imx6ul_tsc *tsc = platform_get_drvdata(pdev);
> +
> + imx6ul_tsc_disable(tsc);
> +
> + clk_disable_unprepare(tsc->tsc_clk);
> + clk_disable_unprepare(tsc->adc_clk);
> +
> + return 0;
> +}
> +
> +static int __maybe_unused imx6ul_tsc_resume(struct device *dev)
> +{
> + struct platform_device *pdev = to_platform_device(dev);
> + struct imx6ul_tsc *tsc = platform_get_drvdata(pdev);
> + int err;
> +
> + err = clk_prepare_enable(tsc->adc_clk);
> + if (err)
> + return err;
> +
> + err = clk_prepare_enable(tsc->tsc_clk);
> + if (err) {
> + clk_disable_unprepare(tsc->adc_clk);
> + return err;
> + }
> +
> + imx6ul_tsc_init(tsc);
> + return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(imx6ul_tsc_pm_ops,
> +  imx6ul_tsc_suspend,
> +  imx6ul_tsc_resume);
> +
> +static struct platform_driver imx6ul_tsc_driver = {
> + .driver = {
> + .name   = "imx6ul-tsc",
> + .owner  = THIS_MODULE,
> + .of_match_table = imx6ul_tsc_match,
> + .pm = &imx6ul_tsc_pm_ops,
> + },
> + .probe  = imx6ul_tsc_probe,
> + .remove = imx6ul_tsc_remove,
> +};
> +module_platform_driver(imx6ul_tsc_driver);
> +
> +MODULE_AUTHOR("Haibo Chen ");
> +MODULE_DESCRIPTION("Freescale i.MX6UL Touchscreen controller driver");
> +MODULE_LICENSE("GPL v2");
> -- 
> 1.9.1
> 

Can you try the patch below and let me know if it still works (you'll
need to adjust your DTS for xnur gpio being active low).

Thanks!

-- 
Dmitry

Input: imx6ul_tsc - misc changes

From: Dmitry Torokhov 

Signed-off-by: Dmitry Torokhov 
---
 .../bindings/input/touchscreen/imx6ul_tsc.txt  |2 
 drivers/input/touchscreen/Kconfig  |2 
 drivers/input/touchscreen/imx6ul_tsc.c |  262 +++-
 3 files changed, 143 insertions(+), 123 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/imx6ul_tsc.txt 
b/Documentation/devicetree/bindings/input/touchscreen/imx6ul_tsc.txt
index ac41c32..c933588 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/imx6ul_tsc.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/imx6ul_tsc.txt
@@ -29,7 +29,7 @@ Example:
clock-names = "tsc", "adc";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_tsc>;
-   xnur-gpio = <&gpio1 3 GPIO_ACTIVE_HIGH>;
+   xnur-gpio = <&gpio1 3 GPIO_ACTIVE_LOW>;
measure-delay-time = <0xfff>;
pre-charge-time = <0x>;
status = "okay";
diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 9a1a293..5ecf19b 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -481,7 +481,7 @@ config TOUCHSCREEN_MTOUCH
 
 config TOUCHSCREEN_IMX6UL_TSC
tristate "Freescale i.MX6UL touchscreen controller"
-   depends on OF
+   depends on (OF && GPIOLIB) || COMPILE_TEST
help
  Say Y here if you have a Freescale i.MX6UL, and want to
  use the internal touchscreen controller.
diff --git a/drivers/input/touchscreen/imx6ul_tsc.c 
b/drivers/input/touchscreen/imx6ul_tsc.c
index 807f1db..1d028ed 100644
--- a/drivers/input/touchscreen/imx6ul_tsc.c
+++ b/drivers/input/touchscreen/imx6ul_tsc.c
@@ -11,15 +11,12 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -85,8 +82,8 @@ struct imx6ul_tsc {
void __iomem *adc_regs;
struct clk *tsc_clk;
struct clk *adc_clk;
+   struct gpio_desc *xnur_gpio;
 
-   int xnur_gpio;
int measure_delay_time;
int pre_charge_time;
 
@@ -105,6 +102,8 @@ static void imx6ul_adc_init(struct imx6ul_tsc *tsc)
int

[PATCH v2] i2c: allow specifying separate wakeup interrupt in device tree

2015-08-17 Thread Dmitry Torokhov
Instead of having each i2c driver individually parse device tree data in
case it or platform supports separate wakeup interrupt, and handle
enabling and disabling wakeup interrupts in their power management
routines, let's have i2c core do that for us.

Platforms wishing to specify separate wakeup interrupt for the device
should use named interrupt syntax in their DTSes:

interrupt-parent = <&intc1>;
interrupts = <5 0>, <6 0>;
interrupt-names = "irq", "wakeup";

This patch is inspired by work done by Vignesh R  for
pixcir_i2c_ts driver.

Signed-off-by: Dmitry Torokhov 
---

v1 -> v2:

- added binding documentation for interrupts property;
- simplified initializing device as wakeup source - now just doing based on
  client's flags.

 Documentation/devicetree/bindings/i2c/i2c.txt | 16 +++--
 drivers/i2c/i2c-core.c| 51 ++-
 2 files changed, 56 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt 
b/Documentation/devicetree/bindings/i2c/i2c.txt
index 1175efe..8a99150 100644
--- a/Documentation/devicetree/bindings/i2c/i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c.txt
@@ -12,7 +12,7 @@ Required properties
 - compatible  - name of I2C bus controller following generic names
recommended practice.
 
-For other required properties e.g. to describe register sets, interrupts,
+For other required properties e.g. to describe register sets,
 clocks, etc. check the binding documentation of the specific driver.
 
 The cells properties above define that an address of children of an I2C bus
@@ -29,5 +29,17 @@ Optional properties
 These properties may not be supported by all drivers. However, if a driver
 wants to support one of the below features, it should adapt the bindings below.
 
-- clock-frequency  - frequency of bus clock in Hz
+- clock-frequency  - frequency of bus clock in Hz.
 - wakeup-source- device can be used as a wakeup source.
+
+- interrupts   - interrupts used by the device.
+- interrupt-names  - "irq" and "wakeup" names are recognized by I2C core,
+ other names are left to individual drivers.
+
+Binding may contain optional "interrupts" property, describing interrupts
+used by the device. I2C core will assign "irq" interrupt (or the very first
+interrupt if not using interrupt names) as primary interrupt for the slave.
+
+Also, if device is marked as a wakeup source, I2C core will set up "wakeup"
+interrupt for the device. If "wakeup" interrupt name is not present in the
+binding, then primary interrupt will be used as wakeup interrupt.
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e6d4935..d8fd226 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -639,11 +640,13 @@ static int i2c_device_probe(struct device *dev)
if (!client->irq) {
int irq = -ENOENT;
 
-   if (dev->of_node)
-   irq = of_irq_get(dev->of_node, 0);
-   else if (ACPI_COMPANION(dev))
+   if (dev->of_node) {
+   irq = of_irq_get_byname(dev->of_node, "irq");
+   if (irq == -EINVAL || irq == -ENODATA)
+   irq = of_irq_get(dev->of_node, 0);
+   } else if (ACPI_COMPANION(dev)) {
irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0);
-
+   }
if (irq == -EPROBE_DEFER)
return irq;
if (irq < 0)
@@ -656,23 +659,49 @@ static int i2c_device_probe(struct device *dev)
if (!driver->probe || !driver->id_table)
return -ENODEV;
 
-   if (!device_can_wakeup(&client->dev))
-   device_init_wakeup(&client->dev,
-   client->flags & I2C_CLIENT_WAKE);
+   if (client->flags & I2C_CLIENT_WAKE) {
+   int wakeirq = -ENOENT;
+
+   if (dev->of_node) {
+   wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
+   if (wakeirq == -EPROBE_DEFER)
+   return wakeirq;
+   }
+
+   device_init_wakeup(&client->dev, true);
+
+   if (wakeirq > 0 && wakeirq != client->irq)
+   status = dev_pm_set_dedicated_wake_irq(dev, wakeirq);
+   else if (client->irq > 0)
+   status = dev_pm_set_wake_irq(dev, wakeirq);
+   else
+   status = 0;
+
+   if (status)
+   dev_warn(&

Re: [PATCH RESEND 2/2] cap11xx: add LED support

2015-08-16 Thread Dmitry Torokhov
On Tue, Aug 04, 2015 at 09:24:56PM -0700, Matt Ranostay wrote:
> Several cap11xx variants have LEDs that be can be controlled, this
> patchset implements this functionality.
> 
> Signed-off-by: Matt Ranostay 

Folded both together and applied with minor edits, thank you.

> ---
>  drivers/input/keyboard/cap11xx.c | 140 
> ++-
>  1 file changed, 137 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/keyboard/cap11xx.c 
> b/drivers/input/keyboard/cap11xx.c
> index b58fd9d..64d0079 100644
> --- a/drivers/input/keyboard/cap11xx.c
> +++ b/drivers/input/keyboard/cap11xx.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -47,6 +48,20 @@
>  #define CAP11XX_REG_CONFIG2  0x44
>  #define CAP11XX_REG_CONFIG2_ALT_POL  BIT(6)
>  #define CAP11XX_REG_SENSOR_BASE_CNT(X)   (0x50 + (X))
> +#define CAP11XX_REG_LED_POLARITY 0x73
> +#define CAP11XX_REG_LED_OUTPUT_CONTROL   0x74
> +
> +#define CAP11XX_REG_LED_DUTY_CYCLE_1 0x90
> +#define CAP11XX_REG_LED_DUTY_CYCLE_2 0x91
> +#define CAP11XX_REG_LED_DUTY_CYCLE_3 0x92
> +#define CAP11XX_REG_LED_DUTY_CYCLE_4 0x93
> +
> +#define CAP11XX_REG_LED_DUTY_MIN_MASK(0x0f)
> +#define CAP11XX_REG_LED_DUTY_MIN_MASK_SHIFT  (0)
> +#define CAP11XX_REG_LED_DUTY_MAX_MASK(0xf0)
> +#define CAP11XX_REG_LED_DUTY_MAX_MASK_SHIFT  (4)
> +#define CAP11XX_REG_LED_DUTY_MAX_VALUE   (15)
> +
>  #define CAP11XX_REG_SENSOR_CALIB (0xb1 + (X))
>  #define CAP11XX_REG_SENSOR_CALIB_LSB10xb9
>  #define CAP11XX_REG_SENSOR_CALIB_LSB20xba
> @@ -56,10 +71,23 @@
>  
>  #define CAP11XX_MANUFACTURER_ID  0x5d
>  
> +#ifdef CONFIG_LEDS_CLASS
> +struct cap11xx_led {
> + struct cap11xx_priv *priv;
> + struct led_classdev cdev;
> + struct work_struct work;
> + u32 reg;
> + enum led_brightness new_brightness;
> +};
> +#endif
> +
>  struct cap11xx_priv {
>   struct regmap *regmap;
>   struct input_dev *idev;
>  
> + struct cap11xx_led *leds;
> + int num_leds;
> +
>   /* config */
>   u32 keycodes[];
>  };
> @@ -67,6 +95,7 @@ struct cap11xx_priv {
>  struct cap11xx_hw_model {
>   u8 product_id;
>   unsigned int num_channels;
> + unsigned int num_leds;
>  };
>  
>  enum {
> @@ -76,9 +105,9 @@ enum {
>  };
>  
>  static const struct cap11xx_hw_model cap11xx_devices[] = {
> - [CAP1106] = { .product_id = 0x55, .num_channels = 6 },
> - [CAP1126] = { .product_id = 0x53, .num_channels = 6 },
> - [CAP1188] = { .product_id = 0x50, .num_channels = 8 },
> + [CAP1106] = { .product_id = 0x55, .num_channels = 6, .num_leds = 0 },
> + [CAP1126] = { .product_id = 0x53, .num_channels = 6, .num_leds = 2 },
> + [CAP1188] = { .product_id = 0x50, .num_channels = 8, .num_leds = 8 },
>  };
>  
>  static const struct reg_default cap11xx_reg_defaults[] = {
> @@ -111,6 +140,7 @@ static const struct reg_default cap11xx_reg_defaults[] = {
>   { CAP11XX_REG_STANDBY_SENSITIVITY,  0x02 },
>   { CAP11XX_REG_STANDBY_THRESH,   0x40 },
>   { CAP11XX_REG_CONFIG2,  0x40 },
> + { CAP11XX_REG_LED_POLARITY, 0x00 },
>   { CAP11XX_REG_SENSOR_CALIB_LSB1,0x00 },
>   { CAP11XX_REG_SENSOR_CALIB_LSB2,0x00 },
>  };
> @@ -177,6 +207,13 @@ out:
>  
>  static int cap11xx_set_sleep(struct cap11xx_priv *priv, bool sleep)
>  {
> +#ifdef CONFIG_LEDS_CLASS
> + /*
> +  * DLSEEP mode will turn off all LEDS, prevent this
> +  */
> + if (priv->num_leds)
> + return 0;
> +#endif
>   return regmap_update_bits(priv->regmap, CAP11XX_REG_MAIN_CONTROL,
> CAP11XX_REG_MAIN_CONTROL_DLSEEP,
> sleep ? CAP11XX_REG_MAIN_CONTROL_DLSEEP : 0);
> @@ -196,6 +233,99 @@ static void cap11xx_input_close(struct input_dev *idev)
>   cap11xx_set_sleep(priv, true);
>  }
>  
> +#ifdef CONFIG_LEDS_CLASS
> +static void cap11xx_led_work(struct work_struct *work)
> +{
> + struct cap11xx_led *led = container_of(work, struct cap11xx_led, work);
> + struct cap11xx_priv *priv = led->priv;
> + int value = led->new_brightness;
> +
> + /*
> +  * All LEDs share the same duty cycle as this is a HW limitation.
> +  * Brightness levels per LED are either 0 (OFF) and 1 (ON).
> +  */
> + regmap_update_bits(priv->regmap, CAP11XX_REG_LED_OUTPUT_CONTROL,
> + BIT(led->reg), value ? BIT(led->reg) : 0);
> +}
> +
> +static void cap11xx_led_set(struct led_classdev *cdev,
> +enum led_brightness value)
> +{
> + struct cap11xx_led *led = container_of(cdev, struct cap11xx_led, cdev);
> +
> + if (led->new_brightness == value)
> + return;
> +
> + led->new_brightness = value;
> + schedule_work(&led->work);
> +}
> +
> +static int cap11xx_init_leds(struct device *dev,
> +  struct cap11xx_pri

Re: [PATCH v3 3/3] touchscreen: colibri-vf50-ts: Add touchscreen support for Colibri VF50

2015-08-14 Thread Dmitry Torokhov
Hi Sanchayan,

On Wed, Aug 05, 2015 at 02:25:51PM +0530, Sanchayan Maity wrote:
> The Colibri Vybrid VF50 module supports 4-wire touchscreens using
> FETs and ADC inputs. This driver uses the IIO consumer interface
> and relies on the vf610_adc driver based on the IIO framework.
> 
> Signed-off-by: Sanchayan Maity 
> ---
>  drivers/input/touchscreen/Kconfig   |  12 +
>  drivers/input/touchscreen/Makefile  |   1 +
>  drivers/input/touchscreen/colibri-vf50-ts.c | 404 
> 
>  3 files changed, 417 insertions(+)
>  create mode 100644 drivers/input/touchscreen/colibri-vf50-ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 80f6386..28948ca 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -1027,4 +1027,16 @@ config TOUCHSCREEN_ZFORCE
> To compile this driver as a module, choose M here: the
> module will be called zforce_ts.
>  
> +config TOUCHSCREEN_COLIBRI_VF50
> + tristate "Toradex Colibri on board touchscreen driver"
> + depends on GPIOLIB && IIO && VF610_ADC
> + help
> +   Say Y here if you have a Colibri VF50 and plan to use
> +   the on-board provided 4-wire touchscreen driver.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called colibri_vf50_ts.
> +
>  endif
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 44deea7..93746a0 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -84,3 +84,4 @@ obj-$(CONFIG_TOUCHSCREEN_W90X900)   += w90p910_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o
>  obj-$(CONFIG_TOUCHSCREEN_TPS6507X)   += tps6507x-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50)   += colibri-vf50-ts.o
> diff --git a/drivers/input/touchscreen/colibri-vf50-ts.c 
> b/drivers/input/touchscreen/colibri-vf50-ts.c
> new file mode 100644
> index 000..d7bc91a
> --- /dev/null
> +++ b/drivers/input/touchscreen/colibri-vf50-ts.c
> @@ -0,0 +1,404 @@
> +/* Copyright 2015 Toradex AG
> + *
> + * Toradex Colibri VF50 Touchscreen driver
> + *
> + * Originally authored by Stefan Agner for 3.0 kernel
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DRIVER_NAME "colibri-vf50-ts"
> +#define DRV_VERSION "1.0"
> +
> +#define VF_ADC_MAX ((1 << 12) - 1)
> +
> +#define COLI_TOUCH_MIN_DELAY_US 1000
> +#define COLI_TOUCH_MAX_DELAY_US 2000
> +
> +static int min_pressure = 200;
> +
> +struct vf50_touch_device {
> + struct platform_device  *pdev;
> + struct input_dev*ts_input;
> + struct iio_channel  *channels;
> + struct gpio_desc *gpio_xp;
> + struct gpio_desc *gpio_xm;
> + struct gpio_desc *gpio_yp;
> + struct gpio_desc *gpio_ym;
> + struct gpio_desc *gpio_pen_detect;
> + int pen_irq;
> + bool stop_touchscreen;
> +};
> +
> +/*
> + * Enables given plates and measures touch parameters using ADC
> + */
> +static int adc_ts_measure(struct iio_channel *channel,
> +   struct gpio_desc *plate_p, struct gpio_desc *plate_m)
> +{
> + int i, value = 0, val = 0;
> + int ret;
> +
> + gpiod_set_value(plate_p, 1);
> + gpiod_set_value(plate_m, 1);
> +
> + usleep_range(COLI_TOUCH_MIN_DELAY_US, COLI_TOUCH_MAX_DELAY_US);
> +
> + for (i = 0; i < 5; i++) {

Can we have a #define for 5?

> + ret = iio_read_channel_raw(channel, &val);
> + if (ret < 0) {
> + value = ret;
> + goto error_iio_read;
> + }
> +
> + value += val;
> + }
> +
> + value /= 5;
> +
> +error_iio_read:
> + gpiod_set_value(plate_p, 0);
> + gpiod_set_value(plate_m, 0);
> +
> + return value;
> +}
> +
> +/*
> + * Enable touch detection using falling edge detection on XM
> + */
> +static void vf50_ts_enable_touch_detection(struct vf50_touch_device *vf50_ts)
> +{
> + /* Enable plate YM (needs to be strong GND, high active) */
> + gpiod_set_value(vf50_ts->gpio_ym, 1);
> +
> + /*
> +  * Let the platform mux to idle state in order to enable
> +  * Pull-Up on GPIO
> +  */
> + pinctrl_pm_select_idle_state(&vf50_ts->pdev->dev);
> +}
> +
> +/*
> + * ADC touch screen sampling bottom half irq handler
> + */
> +static irqreturn_t vf50_ts_irq_bh(int irq, void *private)
> +{
> + struct vf50_touch_device *vf50_ts = (struct vf50_touch_device *)private;
> +

Re: [PATCH] Input: elants_i2c - wire up regulator support

2015-08-06 Thread Dmitry Torokhov
Hi Scott,

On Thu, Aug 6, 2015 at 12:03 AM, ELAN 劉嘉駿  wrote:
> Hi Dmitry
>
> I am curious about how reset gpio works and I think the reset gpio
> at low level after elants_i2c_power_on(),
> So that the controller won't response anyway, please see below my
> question and correct me if I am wrong.
>
>> -Original Message-
>> From: Dmitry Torokhov [mailto:d...@chromium.org]
>> Sent: Thursday, August 06, 2015 2:54 AM
>> To: linux-in...@vger.kernel.org
>> Cc: Rob Herring; Mark Rutland; Benson Leung; Duson Lin; Scott Liu; James
>> Chen; devicetree@vger.kernel.org; linux-ker...@vger.kernel.org;
>> linux-in...@vger.kernel.org
>> Subject: [PATCH] Input: elants_i2c - wire up regulator support
>>
>> Elan touchscreen controllers use two power supplies, vcc33 and vccio, and
>> we need to enable them before trying to access the device. On X86 firmware
>> usually does this, but on ARM it is usually left to the kernel.
>>
>> Signed-off-by: Dmitry Torokhov 
>> Reviewed-by: Benson Leung 
>> Signed-off-by: Dmitry Torokhov 
>> ---
>>  .../devicetree/bindings/input/elants_i2c.txt   |   3 +
>>  drivers/input/touchscreen/elants_i2c.c | 184
>> ++---
>>  2 files changed, 165 insertions(+), 22 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/input/elants_i2c.txt
>> b/Documentation/devicetree/bindings/input/elants_i2c.txt
>> index a765232..8a71038 100644
>> --- a/Documentation/devicetree/bindings/input/elants_i2c.txt
>> +++ b/Documentation/devicetree/bindings/input/elants_i2c.txt
>> @@ -13,6 +13,9 @@ Optional properties:
>>  - pinctrl-names: should be "default" (see pinctrl binding [1]).
>>  - pinctrl-0: a phandle pointing to the pin settings for the device (see
>>pinctrl binding [1]).
>> +- reset-gpios: reset gpio the chip is connected to.
>> +- vcc33-supply: a phandle for the regulator supplying 3.3V power.
>> +- vccio-supply: a phandle for the regulator supplying IO power.
>>
>>  [0]:
> Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
>>  [1]: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
>> diff --git a/drivers/input/touchscreen/elants_i2c.c
>> b/drivers/input/touchscreen/elants_i2c.c
>> index 42e43f1..1912265 100644
>> --- a/drivers/input/touchscreen/elants_i2c.c
>> +++ b/drivers/input/touchscreen/elants_i2c.c
>> @@ -38,6 +38,8 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>> +#include 
>>  #include 
>>
>>  /* Device, Driver information */
>> @@ -102,6 +104,9 @@
>>  /* calibration timeout definition */
>>  #define ELAN_CALI_TIMEOUT_MSEC   1
>>
>> +#define ELAN_POWERON_DELAY_USEC  500
>> +#define ELAN_RESET_DELAY_MSEC20
>> +
>>  enum elants_state {
>>   ELAN_STATE_NORMAL,
>>   ELAN_WAIT_QUEUE_HEADER,
>> @@ -118,6 +123,10 @@ struct elants_data {
>>   struct i2c_client *client;
>>   struct input_dev *input;
>>
>> + struct regulator *vcc33;
>> + struct regulator *vccio;
>> + struct gpio_desc *reset_gpio;
>> +
>>   u16 fw_version;
>>   u8 test_version;
>>   u8 solution_version;
>> @@ -141,6 +150,7 @@ struct elants_data {
>>   u8 buf[MAX_PACKET_SIZE];
>>
>>   bool wake_irq_enabled;
>> + bool keep_power_in_suspend;
>>  };
>>
>>  static int elants_i2c_send(struct i2c_client *client, @@ -1058,6 +1068,67
>> @@ static void elants_i2c_remove_sysfs_group(void *_data)
>>   sysfs_remove_group(&ts->client->dev.kobj,
>> &elants_attribute_group);  }
>>
>> +static int elants_i2c_power_on(struct elants_data *ts) {
>> + int error;
>> +
>> + /*
>> +  * If we do not have reset gpio assume platform firmware
>> +  * controls regulators and does power them on for us.
>> +  */
>> + if (IS_ERR_OR_NULL(ts->reset_gpio))
>> + return 0;
>> +
>> + gpiod_set_value_cansleep(ts->reset_gpio, 1);
>> +
>> + error = regulator_enable(ts->vcc33);
>> + if (error) {
>> + dev_err(&ts->client->dev,
>> + "failed to enable vcc33 regulator: %d\n",
>> + error);
>> + goto release_reset_gpio;
>> + }
>> +
>> + error = regulator_enable(ts->vccio);
>> + if (error) {
>> + dev_err(&ts->client->dev,
>> +

[PATCH] Input: elants_i2c - wire up regulator support

2015-08-05 Thread Dmitry Torokhov
Elan touchscreen controllers use two power supplies, vcc33 and vccio,
and we need to enable them before trying to access the device. On X86
firmware usually does this, but on ARM it is usually left to the kernel.

Signed-off-by: Dmitry Torokhov 
Reviewed-by: Benson Leung 
Signed-off-by: Dmitry Torokhov 
---
 .../devicetree/bindings/input/elants_i2c.txt   |   3 +
 drivers/input/touchscreen/elants_i2c.c | 184 ++---
 2 files changed, 165 insertions(+), 22 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/elants_i2c.txt 
b/Documentation/devicetree/bindings/input/elants_i2c.txt
index a765232..8a71038 100644
--- a/Documentation/devicetree/bindings/input/elants_i2c.txt
+++ b/Documentation/devicetree/bindings/input/elants_i2c.txt
@@ -13,6 +13,9 @@ Optional properties:
 - pinctrl-names: should be "default" (see pinctrl binding [1]).
 - pinctrl-0: a phandle pointing to the pin settings for the device (see
   pinctrl binding [1]).
+- reset-gpios: reset gpio the chip is connected to.
+- vcc33-supply: a phandle for the regulator supplying 3.3V power.
+- vccio-supply: a phandle for the regulator supplying IO power.
 
 [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
 [1]: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
diff --git a/drivers/input/touchscreen/elants_i2c.c 
b/drivers/input/touchscreen/elants_i2c.c
index 42e43f1..1912265 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -38,6 +38,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 /* Device, Driver information */
@@ -102,6 +104,9 @@
 /* calibration timeout definition */
 #define ELAN_CALI_TIMEOUT_MSEC 1
 
+#define ELAN_POWERON_DELAY_USEC500
+#define ELAN_RESET_DELAY_MSEC  20
+
 enum elants_state {
ELAN_STATE_NORMAL,
ELAN_WAIT_QUEUE_HEADER,
@@ -118,6 +123,10 @@ struct elants_data {
struct i2c_client *client;
struct input_dev *input;
 
+   struct regulator *vcc33;
+   struct regulator *vccio;
+   struct gpio_desc *reset_gpio;
+
u16 fw_version;
u8 test_version;
u8 solution_version;
@@ -141,6 +150,7 @@ struct elants_data {
u8 buf[MAX_PACKET_SIZE];
 
bool wake_irq_enabled;
+   bool keep_power_in_suspend;
 };
 
 static int elants_i2c_send(struct i2c_client *client,
@@ -1058,6 +1068,67 @@ static void elants_i2c_remove_sysfs_group(void *_data)
sysfs_remove_group(&ts->client->dev.kobj, &elants_attribute_group);
 }
 
+static int elants_i2c_power_on(struct elants_data *ts)
+{
+   int error;
+
+   /*
+* If we do not have reset gpio assume platform firmware
+* controls regulators and does power them on for us.
+*/
+   if (IS_ERR_OR_NULL(ts->reset_gpio))
+   return 0;
+
+   gpiod_set_value_cansleep(ts->reset_gpio, 1);
+
+   error = regulator_enable(ts->vcc33);
+   if (error) {
+   dev_err(&ts->client->dev,
+   "failed to enable vcc33 regulator: %d\n",
+   error);
+   goto release_reset_gpio;
+   }
+
+   error = regulator_enable(ts->vccio);
+   if (error) {
+   dev_err(&ts->client->dev,
+   "failed to enable vccio regulator: %d\n",
+   error);
+   regulator_disable(ts->vcc33);
+   goto release_reset_gpio;
+   }
+
+   /*
+* We need to wait a bit after powering on controller before
+* we are allowed to release reset GPIO.
+*/
+   udelay(ELAN_POWERON_DELAY_USEC);
+
+release_reset_gpio:
+   gpiod_set_value_cansleep(ts->reset_gpio, 0);
+   if (error)
+   return error;
+
+   msleep(ELAN_RESET_DELAY_MSEC);
+
+   return 0;
+}
+
+static void elants_i2c_power_off(void *_data)
+{
+   struct elants_data *ts = _data;
+
+   if (!IS_ERR_OR_NULL(ts->reset_gpio)) {
+   /*
+* Activate reset gpio to prevent leakage through the
+* pin once we shut off power to the controller.
+*/
+   gpiod_set_value_cansleep(ts->reset_gpio, 1);
+   regulator_disable(ts->vccio);
+   regulator_disable(ts->vcc33);
+   }
+}
+
 static int elants_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
 {
@@ -1072,13 +1143,6 @@ static int elants_i2c_probe(struct i2c_client *client,
return -ENXIO;
}
 
-   /* Make sure there is something at this address */
-   if (i2c_smbus_xfer(client->adapter, client->addr, 0,
-   I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) < 0) {
-   dev_err(&client->dev, "nothing at this address\n");
-  

Re: [PATCH v2 3/4] touchscreen: colibri-vf50-ts: Add touchscreen support for Colibri VF50

2015-08-03 Thread Dmitry Torokhov
Hi Sanchayan,

On Mon, Aug 03, 2015 at 08:55:44PM +0530, maitysancha...@gmail.com wrote:
> Hello Dmitry,
> 
> On 15-07-21 10:20:44, Dmitry Torokhov wrote:
> > Hi Stefan,
> > 
> > On Tue, Jul 21, 2015 at 04:43:36PM +0200, Stefan Agner wrote:
> > > Hi Dmitry,
> > > 
> > > As the original author of the driver I have some remarks to your review
> > > 
> > > On 2015-07-18 01:42, Dmitry Torokhov wrote:
> > > >> +  /*
> > > >> +   * If touch pressure is too low, stop measuring and 
> > > >> reenable
> > > >> +   * touch detection
> > > >> +   */
> > > >> +  if (val_p < min_pressure || val_p > 2000)
> > > >> +  break;
> > > 
> > > This is where the modules touch pressure is used to stop the measurement
> > > process and switch back to interrupt mode. See my remarks at the end.
> > > 
> > > >> +
> > > >> +  /*
> > > >> +   * The pressure may not be enough for the first x and 
> > > >> the
> > > >> +   * second y measurement, but, the pressure is ok when 
> > > >> the
> > > >> +   * driver is doing the third and fourth measurement. To
> > > >> +   * take care of this, we drop the first measurement 
> > > >> always.
> > > >> +   */
> > > >> +  if (discard_val_on_start) {
> > > >> +  discard_val_on_start = false;
> > > >> +  } else {
> > > >> +  /*
> > > >> +   * Report touch position and sleep for
> > > >> +   * next measurement
> > > >> +   */
> > > >> +  input_report_abs(vf50_ts->ts_input,
> > > >> +  ABS_X, VF_ADC_MAX - val_x);
> > > >> +  input_report_abs(vf50_ts->ts_input,
> > > >> +  ABS_Y, VF_ADC_MAX - val_y);
> > > >> +  input_report_abs(vf50_ts->ts_input,
> > > >> +  ABS_PRESSURE, val_p);
> > > >> +  input_report_key(vf50_ts->ts_input, BTN_TOUCH, 
> > > >> 1);
> > > >> +  input_sync(vf50_ts->ts_input);
> > > >> +  }
> > > >> +
> > > >> +  msleep(10);
> > > >> +  }
> > > >> +
> > > >> +  /* Report no more touch, reenable touch detection */
> > > >> +  input_report_abs(vf50_ts->ts_input, ABS_PRESSURE, 0);
> > > >> +  input_report_key(vf50_ts->ts_input, BTN_TOUCH, 0);
> > > >> +  input_sync(vf50_ts->ts_input);
> > > >> +
> > > >> +  vf50_ts_enable_touch_detection(vf50_ts);
> > > >> +
> > > >> +  /* Wait for the pull-up to be stable on high */
> > > >> +  msleep(10);
> > > >> +
> > > >> +  /* Reenable IRQ to detect touch */
> > > >> +  enable_irq(vf50_ts->pen_irq);
> > > >> +
> > > >> +  dev_dbg(dev, "Reenabled touch detection interrupt\n");
> > > >> +}
> > > >> +
> > > >> +static irqreturn_t vf50_ts_touched(int irq, void *dev_id)
> > > >> +{
> > > >> +  struct vf50_touch_device *vf50_ts = (struct vf50_touch_device 
> > > >> *)dev_id;
> > > >> +  struct device *dev = &vf50_ts->pdev->dev;
> > > >> +
> > > >> +  dev_dbg(dev, "Touch detected, start worker thread\n");
> > > >> +
> > > >> +  disable_irq_nosync(irq);
> > > >> +
> > > >> +  /* Disable the touch detection plates */
> > > >> +  gpiod_set_value(vf50_ts->gpio_ym, 0);
> > > >> +
> > > >> +  /* Let the platform mux to default state in order to mux as ADC 
> > > >> */
> > > >> +  pinctrl_pm_select_default_state(dev);
> > > >> +
> > > >> +  queue_work(vf50_ts->ts_workqueue, &vf50_ts->ts_work);
> > > > 
> > > > If you 

Re: [PATCH 2/3] input: cyapa: add of match device support and description document

2015-07-30 Thread Dmitry Torokhov
On Fri, Jul 24, 2015 at 01:05:58PM +0800, Dudley Du wrote:
> Add of_match_device mechanism support for Cypress trackpad device, and
> add the sample description document on how to adding the trackpad device node
> in the device tree.
> 
> Signed-off-by: Dudley Du 

Applied, thank you.

> ---
>  .../devicetree/bindings/input/cypress,cyapa.txt| 44 
> ++
>  .../devicetree/bindings/vendor-prefixes.txt|  1 +
>  drivers/input/mouse/cyapa.c| 10 +
>  3 files changed, 55 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/cypress,cyapa.txt
> 
> diff --git a/Documentation/devicetree/bindings/input/cypress,cyapa.txt 
> b/Documentation/devicetree/bindings/input/cypress,cyapa.txt
> new file mode 100644
> index 000..9be2b44
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/cypress,cyapa.txt
> @@ -0,0 +1,44 @@
> +Cypress I2C Touchpad
> +
> +Required properties:
> +- compatible: must be "cypress,cyapa".
> +- reg: I2C address of the chip.
> +- interrupt-parent: a phandle for the interrupt controller (see interrupt
> +  binding[0]).
> +- interrupts: interrupt to which the chip is connected (see interrupt
> +  binding[0]).
> +
> +Optional properties:
> +- wakeup-source: touchpad can be used as a wakeup source.
> +- pinctrl-names: should be "default" (see pinctrl binding [1]).
> +- pinctrl-0: a phandle pointing to the pin settings for the device (see
> +  pinctrl binding [1]).
> +- vcc-supply: a phandle for the regulator supplying 3.3V power.
> +
> +[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
> +[1]: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
> +
> +Example:
> + &i2c0 {
> + /* ... */
> +
> + /* Cypress Gen3 touchpad */
> + touchpad@67 {
> + compatible = "cypress,cyapa";
> + reg = <0x24>;
> + interrupt-parent = <&gpio>;
> + interrupts = <2 IRQ_TYPE_EDGE_FALLING>; /* GPIO 2 */
> + wakeup-source;
> + };
> +
> + /* Cypress Gen5 and later touchpad */
> + touchpad@24 {
> + compatible = "cypress,cyapa";
> + reg = <0x24>;
> + interrupt-parent = <&gpio>;
> + interrupts = <2 IRQ_TYPE_EDGE_FALLING>; /* GPIO 2 */
> + wakeup-source;
> + };
> +
> + /* ... */
> + };
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index d444757..57c0f5f 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -54,6 +54,7 @@ cortina Cortina Systems, Inc.
>  cosmic   Cosmic Circuits
>  crystalfontz Crystalfontz America, Inc.
>  cubietechCubietech, Ltd.
> +cypress  Cypress Semiconductor Corporation
>  dallas   Maxim Integrated Products (formerly Dallas Semiconductor)
>  davicom  DAVICOM Semiconductor, Inc.
>  deltaDelta Electronics, Inc.
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index 2159c5e..3431510 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include "cyapa.h"
>  
>  
> @@ -1486,11 +1487,20 @@ static const struct acpi_device_id cyapa_acpi_id[] = {
>  MODULE_DEVICE_TABLE(acpi, cyapa_acpi_id);
>  #endif
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id cyapa_of_match[] = {
> + { .compatible = "cypress,cyapa" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, cyapa_of_match);
> +#endif
> +
>  static struct i2c_driver cyapa_driver = {
>   .driver = {
>   .name = "cyapa",
>   .pm = &cyapa_pm_ops,
>   .acpi_match_table = ACPI_PTR(cyapa_acpi_id),
> + .of_match_table = of_match_ptr(cyapa_of_match),
>   },
>  
>   .probe = cyapa_probe,
> -- 
> 1.9.1
> 
> 
> ---
> This message and any attachments may contain Cypress (or its
> subsidiaries) confidential information. If it has been received
> in error, please advise the sender and immediately delete this
> message.
> ---
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] input: cyapa: fix output unwanted warning issue

2015-07-30 Thread Dmitry Torokhov
On Fri, Jul 24, 2015 at 01:05:59PM +0800, Dudley Du wrote:
> Avoid the driver generate warning message when the cyapa driver working
> with the old Gen5 trackpad device which does not support the proximity 
> function.
> Those old Gen5 trackpad device all have the platform version less than 2.
> 
> Signed-off-by: Dudley Du 

Applied, thank you.

> ---
>  drivers/input/mouse/cyapa_gen5.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/mouse/cyapa_gen5.c 
> b/drivers/input/mouse/cyapa_gen5.c
> index 6d7abbe..118ba97 100644
> --- a/drivers/input/mouse/cyapa_gen5.c
> +++ b/drivers/input/mouse/cyapa_gen5.c
> @@ -2519,10 +2519,13 @@ static int cyapa_gen5_do_operational_check(struct 
> cyapa *cyapa)
>   __func__);
>  
>   /* By default, the trackpad proximity function is enabled. */
> - error = cyapa_pip_set_proximity(cyapa, true);
> - if (error)
> - dev_warn(dev, "%s: failed to enable proximity.\n",
> - __func__);
> + if (cyapa->platform_ver >= 2) {
> + error = cyapa_pip_set_proximity(cyapa, true);
> + if (error)
> + dev_warn(dev,
> + "%s: failed to enable proximity.\n",
> + __func__);
> + }
>  
>   /* Get trackpad product information. */
>   error = cyapa_gen5_get_query_data(cyapa);
> -- 
> 1.9.1
> 
> 
> ---
> This message and any attachments may contain Cypress (or its
> subsidiaries) confidential information. If it has been received
> in error, please advise the sender and immediately delete this
> message.
> ---
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] input: cyapa: add regulator vcc support

2015-07-30 Thread Dmitry Torokhov
On Fri, Jul 24, 2015 at 01:05:57PM +0800, Dudley Du wrote:
> Add power management regulator vcc support.
> It's described to be supported in the cypress,cyapa.txt document.
> 
> Signed-off-by: Dudley Du 

It looks like we were missing linux/regulator/consumer.h include, I
added it and applied.

Thanks.

> ---
>  drivers/input/mouse/cyapa.c | 28 
>  drivers/input/mouse/cyapa.h |  1 +
>  2 files changed, 29 insertions(+)
> 
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index 6195ccb..2159c5e 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
> @@ -1241,6 +1241,13 @@ static void cyapa_remove_sysfs_group(void *data)
>   sysfs_remove_group(&cyapa->client->dev.kobj, &cyapa_sysfs_group);
>  }
>  
> +static void cyapa_disable_regulator(void *data)
> +{
> + struct cyapa *cyapa = data;
> +
> + regulator_disable(cyapa->vcc);
> +}
> +
>  static int cyapa_probe(struct i2c_client *client,
>  const struct i2c_device_id *dev_id)
>  {
> @@ -1274,6 +1281,27 @@ static int cyapa_probe(struct i2c_client *client,
>   sprintf(cyapa->phys, "i2c-%d-%04x/input0", client->adapter->nr,
>   client->addr);
>  
> + cyapa->vcc = devm_regulator_get(dev, "vcc");
> + if (IS_ERR(cyapa->vcc)) {
> + error = PTR_ERR(cyapa->vcc);
> + dev_err(dev, "failed to get vcc regulator: %d\n", error);
> + return error;
> + }
> +
> + error = regulator_enable(cyapa->vcc);
> + if (error) {
> + dev_err(dev, "failed to enable regulator: %d\n", error);
> + return error;
> + }
> +
> + error = devm_add_action(dev, cyapa_disable_regulator, cyapa);
> + if (error) {
> + cyapa_disable_regulator(cyapa);
> + dev_err(dev, "failed to add disable regulator action: %d\n",
> + error);
> + return error;
> + }
> +
>   error = cyapa_initialize(cyapa);
>   if (error) {
>   dev_err(dev, "failed to detect and initialize tp device.\n");
> diff --git a/drivers/input/mouse/cyapa.h b/drivers/input/mouse/cyapa.h
> index af12536..b812bba 100644
> --- a/drivers/input/mouse/cyapa.h
> +++ b/drivers/input/mouse/cyapa.h
> @@ -321,6 +321,7 @@ struct cyapa {
>   u8 status[BL_STATUS_SIZE];
>   bool operational; /* true: ready for data reporting; false: not. */
>  
> + struct regulator *vcc;
>   struct i2c_client *client;
>   struct input_dev *input;
>   char phys[32];  /* Device physical location */
> -- 
> 1.9.1
> 
> 
> ---
> This message and any attachments may contain Cypress (or its
> subsidiaries) confidential information. If it has been received
> in error, please advise the sender and immediately delete this
> message.
> ---
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] of/irq: introduce of_has_named_irqs helper

2015-07-28 Thread Dmitry Torokhov
On Tue, Jul 28, 2015 at 11:16:44PM +0530, R, Vignesh wrote:
> Hi,
> 
> On 7/28/2015 10:53 PM, Dmitry Torokhov wrote:
> > On Tue, Jul 28, 2015 at 06:53:52PM +0530, Vignesh R wrote:
> >> Hi Dmitry,
> >>
> >> On 07/25/2015 01:46 AM, Dmitry Torokhov wrote:
> >>> On Fri, Jul 24, 2015 at 12:26:19PM -0700, Dmitry Torokhov wrote:
> >>>> On Fri, Jul 24, 2015 at 02:14:57PM -0500, Rob Herring wrote:
> >>>>> On Fri, Jul 24, 2015 at 1:26 PM, Dmitry Torokhov
> >>>>>  wrote:
> >>>>>> Sometimes drivers might wish to transition from index-based to named
> >>>>>> interrupt descriptions. To aid in decision-making when parsing device
> >>>>>> tree data let's provide a helper that will indicate the scheme that is
> >>>>>> being used.
> >>>>>
> >>>>> Generally, IRQs are retrieved by platform_get_irq or
> >>>>> platform_get_irq_byname. Drivers should not call the of_irq_*
> >>>>> functions directly in most cases.
> >>>>
> >>>> That would be true for platform drivers, but not all devices are
> >>>> platform devices.
> >>>>
> >>>>>
> >>>>>>
> >>>>>> Signed-off-by: Dmitry Torokhov 
> >>>>>> ---
> >>>>>>
> >>>>>> The intent is to it like this:
> >>>>>>
> >>>>>> if (of_has_named_irqs(np) {
> >>>>>> /* Wake IRQ is optional */
> >>>>>> dev->wakeirq = of_irq_get_byname(np, "wakeup");
> >>>>>> if (dev->wakeirq < 0 && dev->wakeirq != -ENODATA)
> >>>>>> return dev->wakeirq;
> >>>>>> }
> >>>>>
> >>>>> of_irq_get_byname will already return an error if the property is not
> >>>>> present. Use that.
> >>>>
> >>>> I do not like that it returns -EINVAL when property is missing, can we
> >>>> change it to return -ENODATA (so it is the same as when the property is
> >>>> defined but such name is missing)?
> >>>
> >>> So here is what I had in mind.. It is based on recent patch by Vignesh
> >>> for pixcir touchscreen, but I think it should be made available to all
> >>> I2C devices. Completely untested at the moment.
> >>>
> >>
> >> Thanks for the patch! I tested this on am437x-gp-evm and the
> >> suspend/resume worked fine (below patch + $subject patch). I was able to
> >> wake the system from low power state using touchscreen. Also verified
> >> module insertion and removal. One comment though, please see below.
> >>
> >>> ---
> >>>  drivers/i2c/i2c-core.c |   43 +--
> >>>  1 file changed, 37 insertions(+), 6 deletions(-)
> >>>
> >>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> >>> index e6d4935..3971461 100644
> >>> --- a/drivers/i2c/i2c-core.c
> >>> +++ b/drivers/i2c/i2c-core.c
> >>> @@ -47,6 +47,7 @@
> >>>  #include 
> >>>  #include 
> >>>  #include 
> >>> +#include 
> >>>  #include 
> >>>  #include 
> >>>  #include 
> >>> @@ -631,6 +632,7 @@ static int i2c_device_probe(struct device *dev)
> >>>  {
> >>>   struct i2c_client   *client = i2c_verify_client(dev);
> >>>   struct i2c_driver   *driver;
> >>> + int wakeirq = 0;
> >>>   int status;
> >>>  
> >>>   if (!client)
> >>> @@ -639,11 +641,13 @@ static int i2c_device_probe(struct device *dev)
> >>>   if (!client->irq) {
> >>>   int irq = -ENOENT;
> >>>  
> >>> - if (dev->of_node)
> >>> - irq = of_irq_get(dev->of_node, 0);
> >>> - else if (ACPI_COMPANION(dev))
> >>> + if (dev->of_node) {
> >>> + irq = of_has_named_irqs(dev->of_node) ?
> >>> + of_irq_get_byname(dev->of_node, "irq") :
> >>> + of_irq_get(dev->of_node, 0);
> >>> + } else if (ACPI_COMPANION(dev)) {
> >>>   irq = acpi_dev_gpio_irq_get

Re: [PATCH] of/irq: introduce of_has_named_irqs helper

2015-07-28 Thread Dmitry Torokhov
On Tue, Jul 28, 2015 at 06:53:52PM +0530, Vignesh R wrote:
> Hi Dmitry,
> 
> On 07/25/2015 01:46 AM, Dmitry Torokhov wrote:
> > On Fri, Jul 24, 2015 at 12:26:19PM -0700, Dmitry Torokhov wrote:
> >> On Fri, Jul 24, 2015 at 02:14:57PM -0500, Rob Herring wrote:
> >>> On Fri, Jul 24, 2015 at 1:26 PM, Dmitry Torokhov
> >>>  wrote:
> >>>> Sometimes drivers might wish to transition from index-based to named
> >>>> interrupt descriptions. To aid in decision-making when parsing device
> >>>> tree data let's provide a helper that will indicate the scheme that is
> >>>> being used.
> >>>
> >>> Generally, IRQs are retrieved by platform_get_irq or
> >>> platform_get_irq_byname. Drivers should not call the of_irq_*
> >>> functions directly in most cases.
> >>
> >> That would be true for platform drivers, but not all devices are
> >> platform devices.
> >>
> >>>
> >>>>
> >>>> Signed-off-by: Dmitry Torokhov 
> >>>> ---
> >>>>
> >>>> The intent is to it like this:
> >>>>
> >>>> if (of_has_named_irqs(np) {
> >>>> /* Wake IRQ is optional */
> >>>> dev->wakeirq = of_irq_get_byname(np, "wakeup");
> >>>> if (dev->wakeirq < 0 && dev->wakeirq != -ENODATA)
> >>>> return dev->wakeirq;
> >>>> }
> >>>
> >>> of_irq_get_byname will already return an error if the property is not
> >>> present. Use that.
> >>
> >> I do not like that it returns -EINVAL when property is missing, can we
> >> change it to return -ENODATA (so it is the same as when the property is
> >> defined but such name is missing)?
> > 
> > So here is what I had in mind.. It is based on recent patch by Vignesh
> > for pixcir touchscreen, but I think it should be made available to all
> > I2C devices. Completely untested at the moment.
> > 
> 
> Thanks for the patch! I tested this on am437x-gp-evm and the
> suspend/resume worked fine (below patch + $subject patch). I was able to
> wake the system from low power state using touchscreen. Also verified
> module insertion and removal. One comment though, please see below.
> 
> > ---
> >  drivers/i2c/i2c-core.c |   43 +--
> >  1 file changed, 37 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> > index e6d4935..3971461 100644
> > --- a/drivers/i2c/i2c-core.c
> > +++ b/drivers/i2c/i2c-core.c
> > @@ -47,6 +47,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -631,6 +632,7 @@ static int i2c_device_probe(struct device *dev)
> >  {
> > struct i2c_client   *client = i2c_verify_client(dev);
> > struct i2c_driver   *driver;
> > +   int wakeirq = 0;
> > int status;
> >  
> > if (!client)
> > @@ -639,11 +641,13 @@ static int i2c_device_probe(struct device *dev)
> > if (!client->irq) {
> > int irq = -ENOENT;
> >  
> > -   if (dev->of_node)
> > -   irq = of_irq_get(dev->of_node, 0);
> > -   else if (ACPI_COMPANION(dev))
> > +   if (dev->of_node) {
> > +   irq = of_has_named_irqs(dev->of_node) ?
> > +   of_irq_get_byname(dev->of_node, "irq") :
> > +   of_irq_get(dev->of_node, 0);
> > +   } else if (ACPI_COMPANION(dev)) {
> > irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0);
> > -
> > +   }
> > if (irq == -EPROBE_DEFER)
> > return irq;
> > if (irq < 0)
> > @@ -652,6 +656,15 @@ static int i2c_device_probe(struct device *dev)
> > client->irq = irq;
> > }
> >  
> > +   if (dev->of_node && of_has_named_irqs(dev->of_node)) {
> > +   wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
> > +   if (wakeirq < 0) {
> > +   if (wakeirq != -ENODATA)
> > +   return wakeirq;
> > +   wakeirq = 0;
> > +   }
> > +   }
> > +
> > driver = to_i2c_driver(dev->driver)

Re: [PATCH V3 3/3] devicetree: da9062: Add device tree bindings for DA9062 OnKey

2015-07-28 Thread Dmitry Torokhov
On Tue, Jul 28, 2015 at 09:40:19AM +0100, Lee Jones wrote:
> On Mon, 27 Jul 2015, Dmitry Torokhov wrote:
> 
> > On Mon, Jul 27, 2015 at 03:43:00PM -0700, Dmitry Torokhov wrote:
> > > On Thu, Jul 23, 2015 at 05:17:41PM +0100, S Twiss wrote:
> > > > From: S Twiss 
> > > > 
> > > > Add device tree bindings for the DA9062 OnKey driver component
> > > > 
> > > > Signed-off-by: Steve Twiss 
> > > > 
> > > > ---
> > > > Changes in V3:
> > > >  - Child driver specifics separated out into separate document
> > > >in this case ../input/da9062-onkey.txt
> > > > Changes in V2:
> > > >  - No change
> > > > 
> > > > This patch applies against linux-next and next-20150708 
> > > > 
> > > > 
> > > >  .../devicetree/bindings/input/da9062-onkey.txt | 36 
> > > > ++
> > > >  Documentation/devicetree/bindings/mfd/da9062.txt   |  3 ++
> > > 
> > > I dropped bits for mfd/da9062.txt, changed to mention both 9062 and
> > > 9063, folded into the onkey patch and applied.
> > 
> > Argh, da9062 core is not in mainline yet... OK, below is the patch I
> > had; if Lee does not pick it up I'll re-apply it when da9062 core hits
> > mainline.
> 
> Hmm... that's annoying.  You've put the patch below your signature
> '--', so my mailer cuts it off.

OK, sorry, I'll make sure to put in before the signature next time.

> 
> [pasting]
> 
> > Input: add DA9062 OnKey capability to DA9063 OnKey driver
> > 
> > From: S Twiss 
> > 
> > Add DA9062 OnKey support into the existing DA9063 OnKey driver component by
> > using generic access tables for common register and bit mask definitions.
> > 
> > The following change will add generic register and bit mask support to the
> > DA9063 OnKey.
> > 
> > The following alterations have been made to the DA9063 OnKey:
> > 
> > - Addition of a da906x_chip_config structure to hold all
> >   generic registers and bitmasks for this type of OnKey component.
> > - Addition of an struct of_device_id table for DA9063 and DA9062
> >   defaults
> > - Refactoring functions to use struct da9063_onkey accesses to generic
> >   registers/masks instead of using defines from registers.h
> > - Re-work of da9063_onkey_probe() to use of_match_node() and
> >   dev_get_regmap() to provide initialisation of generic registers and
> >   masks and access to regmap
> > 
> > Signed-off-by: Steve Twiss 
> > Signed-off-by: Dmitry Torokhov 
> > ---
> >  .../devicetree/bindings/input/da9062-onkey.txt |   32 +
> >  drivers/input/misc/Kconfig |8 +
> >  drivers/input/misc/da9063_onkey.c  |  129 
> > 
> >  3 files changed, 140 insertions(+), 29 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/input/da9062-onkey.txt
>  
> I'm confused.  What's the dependency?
> 
> There shouldn't be any issue applying input patches, just because
> there isn't an MFD counterpart.  In fact, I would take prior
> acceptance of the child into consideration (would be like a +1 vote)
> when reviewing the MFD part.

It's this chunk:

+#include 
+#include 

and these header files are not in mainline yet.

> 
> One suggestion however, I would ask for the DT binding and the driver
> to be separated, as per [0].
> 
> [0] Documentation/devicetree/bindings/submitting-patches.txt

Right, but that says about submitting patches, not applying them ;)

When I chatted with Grant he said that the policy of separating binding
and code into separate patches is done so not to overwhelm devicetree
list and that is is perfectly fine to actually apply them as a single
commit. I try to combine them together so that when looking through
history they show up as one.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V3 3/3] devicetree: da9062: Add device tree bindings for DA9062 OnKey

2015-07-27 Thread Dmitry Torokhov
On Mon, Jul 27, 2015 at 03:43:00PM -0700, Dmitry Torokhov wrote:
> On Thu, Jul 23, 2015 at 05:17:41PM +0100, S Twiss wrote:
> > From: S Twiss 
> > 
> > Add device tree bindings for the DA9062 OnKey driver component
> > 
> > Signed-off-by: Steve Twiss 
> > 
> > ---
> > Changes in V3:
> >  - Child driver specifics separated out into separate document
> >in this case ../input/da9062-onkey.txt
> > Changes in V2:
> >  - No change
> > 
> > This patch applies against linux-next and next-20150708 
> > 
> > 
> >  .../devicetree/bindings/input/da9062-onkey.txt | 36 
> > ++
> >  Documentation/devicetree/bindings/mfd/da9062.txt   |  3 ++
> 
> I dropped bits for mfd/da9062.txt, changed to mention both 9062 and
> 9063, folded into the onkey patch and applied.

Argh, da9062 core is not in mainline yet... OK, below is the patch I
had; if Lee does not pick it up I'll re-apply it when da9062 core hits
mainline.

Thanks.

-- 
Dmitry


Input: add DA9062 OnKey capability to DA9063 OnKey driver

From: S Twiss 

Add DA9062 OnKey support into the existing DA9063 OnKey driver component by
using generic access tables for common register and bit mask definitions.

The following change will add generic register and bit mask support to the
DA9063 OnKey.

The following alterations have been made to the DA9063 OnKey:

- Addition of a da906x_chip_config structure to hold all
  generic registers and bitmasks for this type of OnKey component.
- Addition of an struct of_device_id table for DA9063 and DA9062
  defaults
- Refactoring functions to use struct da9063_onkey accesses to generic
  registers/masks instead of using defines from registers.h
- Re-work of da9063_onkey_probe() to use of_match_node() and
  dev_get_regmap() to provide initialisation of generic registers and
  masks and access to regmap

Signed-off-by: Steve Twiss 
Signed-off-by: Dmitry Torokhov 
---
 .../devicetree/bindings/input/da9062-onkey.txt |   32 +
 drivers/input/misc/Kconfig |8 +
 drivers/input/misc/da9063_onkey.c  |  129 
 3 files changed, 140 insertions(+), 29 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/da9062-onkey.txt

diff --git a/Documentation/devicetree/bindings/input/da9062-onkey.txt 
b/Documentation/devicetree/bindings/input/da9062-onkey.txt
new file mode 100644
index 000..ab0e048
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/da9062-onkey.txt
@@ -0,0 +1,32 @@
+* Dialog DA9062/63 OnKey Module
+
+This module is part of the DA9062/DA9063. For more details about entire
+chips see Documentation/devicetree/bindings/mfd/da9062.txt and
+Documentation/devicetree/bindings/mfd/da9063.txt
+
+This module provides KEY_POWER, KEY_SLEEP and events.
+
+Required properties:
+
+  - compatible: should be one of:
+   dlg,da9062-onkey
+   dlg,da9063-onkey
+
+Optional properties:
+
+  - dlg,disable-key-power : Disable power-down using a long key-press. If this
+entry exists the OnKey driver will remove support for the KEY_POWER key
+press. If this entry does not exist then by default the key-press
+triggered power down is enabled and the OnKey will support both KEY_POWER
+and KEY_SLEEP.
+
+Example:
+
+   pmic0: da9062@58 {
+
+   onkey {
+   compatible = "dlg,da9063-onkey";
+   dlg,disable-key-power;
+   };
+
+   };
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index d4f0a81..d4b993d 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -611,11 +611,11 @@ config INPUT_DA9055_ONKEY
  will be called da9055_onkey.
 
 config INPUT_DA9063_ONKEY
-   tristate "Dialog DA9063 OnKey"
-   depends on MFD_DA9063
+   tristate "Dialog DA9062/63 OnKey"
+   depends on MFD_DA9063 || MFD_DA9062
help
- Support the ONKEY of Dialog DA9063 Power Management IC as an
- input device reporting power button statue.
+ Support the ONKEY of Dialog DA9063 and DA9062 Power Management ICs
+ as an input device capable of reporting the power button status.
 
  To compile this driver as a module, choose M here: the module
  will be called da9063_onkey.
diff --git a/drivers/input/misc/da9063_onkey.c 
b/drivers/input/misc/da9063_onkey.c
index f577585..8eb697d 100644
--- a/drivers/input/misc/da9063_onkey.c
+++ b/drivers/input/misc/da9063_onkey.c
@@ -1,5 +1,5 @@
 /*
- * OnKey device driver for DA9063
+ * OnKey device driver for DA9063 and DA9062 PMICs
  * Copyright (C) 2015  Dialog Semiconductor Ltd.
  *
  * This program is free software; you can redistribute it and/or
@@ -24,36 +24,96 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+
+struct da906x_chip_config {
+   /* REGS */
+

Re: [PATCH V3 3/3] devicetree: da9062: Add device tree bindings for DA9062 OnKey

2015-07-27 Thread Dmitry Torokhov
On Thu, Jul 23, 2015 at 05:17:41PM +0100, S Twiss wrote:
> From: S Twiss 
> 
> Add device tree bindings for the DA9062 OnKey driver component
> 
> Signed-off-by: Steve Twiss 
> 
> ---
> Changes in V3:
>  - Child driver specifics separated out into separate document
>in this case ../input/da9062-onkey.txt
> Changes in V2:
>  - No change
> 
> This patch applies against linux-next and next-20150708 
> 
> 
>  .../devicetree/bindings/input/da9062-onkey.txt | 36 
> ++
>  Documentation/devicetree/bindings/mfd/da9062.txt   |  3 ++

I dropped bits for mfd/da9062.txt, changed to mention both 9062 and
9063, folded into the onkey patch and applied.

Thanks.
 
-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/5] input: touchscreen: add imx6ul_tsc driver support

2015-07-27 Thread Dmitry Torokhov
Hi Haibo,

On Mon, Jul 27, 2015 at 07:26:43PM +0800, Haibo Chen wrote:
> Freescale i.MX6UL contains a internal touchscreen controller,
> this patch add a driver to support this controller.
> 
> Signed-off-by: Haibo Chen 
> ---
>  drivers/input/touchscreen/Kconfig  |  12 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/imx6ul_tsc.c | 510 
> +
>  3 files changed, 523 insertions(+)
>  create mode 100644 drivers/input/touchscreen/imx6ul_tsc.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 5b272ba..32c300d 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -479,6 +479,18 @@ config TOUCHSCREEN_MTOUCH
> To compile this driver as a module, choose M here: the
> module will be called mtouch.
>  
> +config TOUCHSCREEN_IMX6UL_TSC
> + tristate "Freescale i.MX6UL touchscreen controller"
> + depends on OF
> + help
> +   Say Y here if you have a Freescale i.MX6UL, and want to
> +   use the internal touchscreen controller.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   moduel will be called imx6ul_tsc.
> +
>  config TOUCHSCREEN_INEXIO
>   tristate "iNexio serial touchscreens"
>   select SERIO
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index c85aae2..9379b32 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -38,6 +38,7 @@ obj-$(CONFIG_TOUCHSCREEN_EGALAX)+= egalax_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_FUJITSU)+= fujitsu_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix.o
>  obj-$(CONFIG_TOUCHSCREEN_ILI210X)+= ili210x.o
> +obj-$(CONFIG_TOUCHSCREEN_IMX6UL_TSC) += imx6ul_tsc.o
>  obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o
>  obj-$(CONFIG_TOUCHSCREEN_INTEL_MID)  += intel-mid-touch.o
>  obj-$(CONFIG_TOUCHSCREEN_IPROC)  += bcm_iproc_tsc.o
> diff --git a/drivers/input/touchscreen/imx6ul_tsc.c 
> b/drivers/input/touchscreen/imx6ul_tsc.c
> new file mode 100644
> index 000..5a5a368
> --- /dev/null
> +++ b/drivers/input/touchscreen/imx6ul_tsc.c
> @@ -0,0 +1,510 @@
> +/*
> + * Freescale i.MX6UL touchscreen controller driver
> + *
> + * Copyright (C) 2015 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* ADC configuration registers field define */
> +#define ADC_AIEN (0x1 << 7)
> +#define ADC_CONV_DISABLE 0x1F
> +#define ADC_CAL  (0x1 << 7)
> +#define ADC_CALF 0x2
> +#define ADC_12BIT_MODE   (0x2 << 2)
> +#define ADC_IPG_CLK  0x00
> +#define ADC_CLK_DIV_8(0x03 << 5)
> +#define ADC_SHORT_SAMPLE_MODE(0x0 << 4)
> +#define ADC_HARDWARE_TRIGGER (0x1 << 13)
> +#define SELECT_CHANNEL_4 0x04
> +#define SELECT_CHANNEL_1 0x01
> +#define DISABLE_CONVERSION_INT   (0x0 << 7)
> +
> +/* ADC registers */
> +#define REG_ADC_HC0  0x00
> +#define REG_ADC_HC1  0x04
> +#define REG_ADC_HC2  0x08
> +#define REG_ADC_HC3  0x0C
> +#define REG_ADC_HC4  0x10
> +#define REG_ADC_HS   0x14
> +#define REG_ADC_R0   0x18
> +#define REG_ADC_CFG  0x2C
> +#define REG_ADC_GC   0x30
> +#define REG_ADC_GS   0x34
> +
> +#define ADC_TIMEOUT  msecs_to_jiffies(100)
> +
> +/* TSC registers */
> +#define REG_TSC_BASIC_SETING 0x00
> +#define REG_TSC_PRE_CHARGE_TIME  0x10
> +#define REG_TSC_FLOW_CONTROL 0x20
> +#define REG_TSC_MEASURE_VALUE0x30
> +#define REG_TSC_INT_EN   0x40
> +#define REG_TSC_INT_SIG_EN   0x50
> +#define REG_TSC_INT_STATUS   0x60
> +#define REG_TSC_DEBUG_MODE   0x70
> +#define REG_TSC_DEBUG_MODE2  0x80
> +
> +/* TSC configuration registers field define */
> +#define DETECT_4_WIRE_MODE   (0x0 << 4)
> +#define AUTO_MEASURE 0x1
> +#define MEASURE_SIGNAL   0x1
> +#define DETECT_SIGNAL(0x1 << 4)
> +#define VALID_SIGNAL (0x1 << 8)
> +#define MEASURE_INT_EN   0x1
> +#define MEASURE_SIG_EN   0x1
> +#define VALID_SIG_EN (0x1 << 8)
> +#define DE_GLITCH_2  (0x2 << 29)
> +#define START_SENSE  (0x1 << 12)
> +#define TSC_DISABLE  (0x1 << 16)
> +#define DETECT_MODE  0x2
> +
> +struct imx6ul_tsc {
> + struct device *dev;
> + struct input_dev *input;
> + void __iomem *tsc_regs;
> + void __iomem *adc_regs;
> + struct clk *tsc_clk;
> + struct 

Re: [PATCH v3 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

2015-07-27 Thread Dmitry Torokhov
On Mon, Jul 27, 2015 at 04:49:22PM +0530, Vignesh R wrote:
> 
> 
> On 07/27/2015 04:19 PM, Roger Quadros wrote:
> > Hi,
> > 
> > On 23/07/15 17:54, Vignesh R wrote:
> >> On am437x-gp-evm, pixcir touchscreen can wake the system from low power
> >> state by generating wake-up interrupt via pinctrl and IO daisy chain.
> >> Add support for optional wakeup interrupt source by regsitering to
> >> automated wake IRQ framework introduced by commit 4990d4fe327b ("PM /
> >> Wakeirq: Add automated device wake IRQ handling").
> >> This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
> >> support for optional wake-up")
> >>
> >> Signed-off-by: Vignesh R 
> >> ---
> >>
> >> v3:
> >>  * handle error code returned by of_irq_get_byname()
> >>
> >> v2:
> >>  * use of_irq_get_byname()
> >>  * remove enable/disable_wake_irq()
> >>
> >>  drivers/input/touchscreen/pixcir_i2c_ts.c | 22 ++
> >>  include/linux/input/pixcir_ts.h   |  1 +
> >>  2 files changed, 19 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> >> b/drivers/input/touchscreen/pixcir_i2c_ts.c
> >> index 8f3e243a62bf..3a4ab358bf52 100644
> >> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> >> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> >> @@ -29,6 +29,8 @@
> >>  #include 
> >>  #include 
> >>  #include 
> >> +#include 
> >> +#include 
> >>  
> >>  #define PIXCIR_MAX_SLOTS   5 /* Max fingers supported by driver */
> >>  
> >> @@ -364,8 +366,6 @@ static int __maybe_unused pixcir_i2c_ts_suspend(struct 
> >> device *dev)
> >>goto unlock;
> >>}
> >>}
> >> -
> >> -  enable_irq_wake(client->irq);
> >>} else if (input->users) {
> >>ret = pixcir_stop(ts);
> >>}
> >> @@ -386,8 +386,6 @@ static int __maybe_unused pixcir_i2c_ts_resume(struct 
> >> device *dev)
> >>mutex_lock(&input->mutex);
> >>  
> >>if (device_may_wakeup(&client->dev)) {
> >> -  disable_irq_wake(client->irq);
> >> -
> >>if (!input->users) {
> >>ret = pixcir_stop(ts);
> >>if (ret) {
> >> @@ -445,6 +443,13 @@ static struct pixcir_ts_platform_data 
> >> *pixcir_parse_dt(struct device *dev)
> >>dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__,
> >>pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb);
> >>  
> >> +  pdata->wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
> >> +  if (pdata->wakeirq < 0 && pdata->wakeirq != -ENODATA &&
> >> +  pdata->wakeirq != -EINVAL) {
> >> +  dev_err(dev, "Failed to get wakeirq\n");
> >> +  return ERR_PTR(pdata->wakeirq);
> >> +  }
> >> +
> >>return pdata;
> >>  }
> >>  #else
> >> @@ -564,11 +569,20 @@ static int pixcir_i2c_ts_probe(struct i2c_client 
> >> *client,
> >>i2c_set_clientdata(client, tsdata);
> >>device_init_wakeup(&client->dev, 1);
> >>  
> >> +  /* Register wakeirq */
> >> +  error = (pdata->wakeirq > 0) ?
> >> +  dev_pm_set_dedicated_wake_irq(dev, pdata->wakeirq) :
> >> +  dev_pm_set_wake_irq(dev, client->irq);
> > 
> > Can 0 be a valid wakeirq or client->irq?
> > If yes then this logic is broken.
> > 
> 
> AFAIK, IRQ 0 is always assigned to system timer interrupt (cannot find
> reliable source to quote).
> 
> > I would set wakeirq to -EINVAL or something if it is not available
> > during probe and check for that condition.
> > 
> 
> Not sure, if I understand you correctly
> pdata->wakeirq will have -ENODATA or -EINVAL(as returned by
> of_irq_get_byname()), if wakeirq is not available. Do you want me to
> check for these two conditions specifically rather than
> (pdata->wakeirq > 0) ?

0 is not really valid general IRQ number; I2C for example sets
client->irq to 0 when there is no IRQ.

BTW, what do you think about my patch pushing this into i2c core? Could
you try and see if it works for you?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] of/irq: introduce of_has_named_irqs helper

2015-07-24 Thread Dmitry Torokhov
On Fri, Jul 24, 2015 at 03:59:39PM -0500, Rob Herring wrote:
> On Fri, Jul 24, 2015 at 2:26 PM, Dmitry Torokhov
>  wrote:
> > On Fri, Jul 24, 2015 at 02:14:57PM -0500, Rob Herring wrote:
> >> On Fri, Jul 24, 2015 at 1:26 PM, Dmitry Torokhov
> >>  wrote:
> >> > Sometimes drivers might wish to transition from index-based to named
> >> > interrupt descriptions. To aid in decision-making when parsing device
> >> > tree data let's provide a helper that will indicate the scheme that is
> >> > being used.
> >>
> >> Generally, IRQs are retrieved by platform_get_irq or
> >> platform_get_irq_byname. Drivers should not call the of_irq_*
> >> functions directly in most cases.
> >
> > That would be true for platform drivers, but not all devices are
> > platform devices.
> 
> I should say for drivers, IRQs are retrieved by a bus specific method,
> not DT functions. There are 3 cases of drivers using them:
> 
> arch/arm/mach-omap2/prm3xxx.c:  irq_num = of_irq_get(np, 0);
> arch/arm/mach-omap2/prm44xx.c:  irq_num = of_irq_get(prm_init_data->np, 0);
> drivers/pinctrl/sirf/pinctrl-atlas7.c:  ret = of_irq_get(np, idx);

Right, but I think with the newer wakeirq infrastructure we may start
seeing them for non-platform devices unless we push it into bus code (as
I've attempted to do in the patch I sent in the other email). 

> 
> >> > Signed-off-by: Dmitry Torokhov 
> >> > ---
> >> >
> >> > The intent is to it like this:
> >> >
> >> > if (of_has_named_irqs(np) {
> >> > /* Wake IRQ is optional */
> >> > dev->wakeirq = of_irq_get_byname(np, "wakeup");
> >> > if (dev->wakeirq < 0 && dev->wakeirq != -ENODATA)
> >> > return dev->wakeirq;
> >> > }
> >>
> >> of_irq_get_byname will already return an error if the property is not
> >> present. Use that.
> >
> > I do not like that it returns -EINVAL when property is missing, can we
> > change it to return -ENODATA (so it is the same as when the property is
> > defined but such name is missing)?
> 
> It may be useful to distinguish between those cases. If you want audit
> all the callers we could possibly change it though.

It looks like the only user of of_irq_get_byname() is
platform_get_irq_byname() and it doe snot care about anything but
-EPROBE_DEFER, so my audit effort is complete ;)

> 
> Really, I don't understand why you would care about any error code
> other than EPROBE_DEFER. If it is optional, then you would want to
> continue no matter what is returned.

No, I only want to proceed if it is not there. If there are errors (in
DTS, elsewhere in the kernel) I want to let the user know and abort.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] of/irq: introduce of_has_named_irqs helper

2015-07-24 Thread Dmitry Torokhov
On Fri, Jul 24, 2015 at 12:26:19PM -0700, Dmitry Torokhov wrote:
> On Fri, Jul 24, 2015 at 02:14:57PM -0500, Rob Herring wrote:
> > On Fri, Jul 24, 2015 at 1:26 PM, Dmitry Torokhov
> >  wrote:
> > > Sometimes drivers might wish to transition from index-based to named
> > > interrupt descriptions. To aid in decision-making when parsing device
> > > tree data let's provide a helper that will indicate the scheme that is
> > > being used.
> > 
> > Generally, IRQs are retrieved by platform_get_irq or
> > platform_get_irq_byname. Drivers should not call the of_irq_*
> > functions directly in most cases.
> 
> That would be true for platform drivers, but not all devices are
> platform devices.
> 
> > 
> > >
> > > Signed-off-by: Dmitry Torokhov 
> > > ---
> > >
> > > The intent is to it like this:
> > >
> > > if (of_has_named_irqs(np) {
> > > /* Wake IRQ is optional */
> > > dev->wakeirq = of_irq_get_byname(np, "wakeup");
> > > if (dev->wakeirq < 0 && dev->wakeirq != -ENODATA)
> > > return dev->wakeirq;
> > > }
> > 
> > of_irq_get_byname will already return an error if the property is not
> > present. Use that.
> 
> I do not like that it returns -EINVAL when property is missing, can we
> change it to return -ENODATA (so it is the same as when the property is
> defined but such name is missing)?

So here is what I had in mind.. It is based on recent patch by Vignesh
for pixcir touchscreen, but I think it should be made available to all
I2C devices. Completely untested at the moment.

---
 drivers/i2c/i2c-core.c |   43 +--
 1 file changed, 37 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e6d4935..3971461 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -631,6 +632,7 @@ static int i2c_device_probe(struct device *dev)
 {
struct i2c_client   *client = i2c_verify_client(dev);
struct i2c_driver   *driver;
+   int wakeirq = 0;
int status;
 
if (!client)
@@ -639,11 +641,13 @@ static int i2c_device_probe(struct device *dev)
if (!client->irq) {
int irq = -ENOENT;
 
-   if (dev->of_node)
-   irq = of_irq_get(dev->of_node, 0);
-   else if (ACPI_COMPANION(dev))
+   if (dev->of_node) {
+   irq = of_has_named_irqs(dev->of_node) ?
+   of_irq_get_byname(dev->of_node, "irq") :
+   of_irq_get(dev->of_node, 0);
+   } else if (ACPI_COMPANION(dev)) {
irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0);
-
+   }
if (irq == -EPROBE_DEFER)
return irq;
if (irq < 0)
@@ -652,6 +656,15 @@ static int i2c_device_probe(struct device *dev)
client->irq = irq;
}
 
+   if (dev->of_node && of_has_named_irqs(dev->of_node)) {
+   wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
+   if (wakeirq < 0) {
+   if (wakeirq != -ENODATA)
+   return wakeirq;
+   wakeirq = 0;
+   }
+   }
+
driver = to_i2c_driver(dev->driver);
if (!driver->probe || !driver->id_table)
return -ENODEV;
@@ -659,20 +672,34 @@ static int i2c_device_probe(struct device *dev)
if (!device_can_wakeup(&client->dev))
device_init_wakeup(&client->dev,
client->flags & I2C_CLIENT_WAKE);
+
+   status = wakeirq > 0 ?
+   dev_pm_set_dedicated_wake_irq(dev, wakeirq) :
+   (client->irq > 0 ?
+   dev_pm_set_wake_irq(dev, client->irq) : 0);
+   if (status)
+   dev_warn(&client->dev, "failed to set up wakeup irq");
+
dev_dbg(dev, "probe\n");
 
status = of_clk_set_defaults(dev->of_node, false);
if (status < 0)
-   return status;
+   goto err_clear_wakeup_irq;
 
status = dev_pm_domain_attach(&client->dev, true);
if (status != -EPROBE_DEFER) {
status = driver->probe(client, i2c_match_id(driver->id_table,
client));
if (status)
-  

Re: [PATCH] of/irq: introduce of_has_named_irqs helper

2015-07-24 Thread Dmitry Torokhov
On Fri, Jul 24, 2015 at 02:14:57PM -0500, Rob Herring wrote:
> On Fri, Jul 24, 2015 at 1:26 PM, Dmitry Torokhov
>  wrote:
> > Sometimes drivers might wish to transition from index-based to named
> > interrupt descriptions. To aid in decision-making when parsing device
> > tree data let's provide a helper that will indicate the scheme that is
> > being used.
> 
> Generally, IRQs are retrieved by platform_get_irq or
> platform_get_irq_byname. Drivers should not call the of_irq_*
> functions directly in most cases.

That would be true for platform drivers, but not all devices are
platform devices.

> 
> >
> > Signed-off-by: Dmitry Torokhov 
> > ---
> >
> > The intent is to it like this:
> >
> > if (of_has_named_irqs(np) {
> > /* Wake IRQ is optional */
> > dev->wakeirq = of_irq_get_byname(np, "wakeup");
> > if (dev->wakeirq < 0 && dev->wakeirq != -ENODATA)
> > return dev->wakeirq;
> > }
> 
> of_irq_get_byname will already return an error if the property is not
> present. Use that.

I do not like that it returns -EINVAL when property is missing, can we
change it to return -ENODATA (so it is the same as when the property is
defined but such name is missing)?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] of/irq: introduce of_has_named_irqs helper

2015-07-24 Thread Dmitry Torokhov
Sometimes drivers might wish to transition from index-based to named
interrupt descriptions. To aid in decision-making when parsing device
tree data let's provide a helper that will indicate the scheme that is
being used.

Signed-off-by: Dmitry Torokhov 
---

The intent is to it like this:

if (of_has_named_irqs(np) {
/* Wake IRQ is optional */
dev->wakeirq = of_irq_get_byname(np, "wakeup");
if (dev->wakeirq < 0 && dev->wakeirq != -ENODATA)
return dev->wakeirq;
}

 drivers/of/irq.c   | 14 ++
 include/linux/of_irq.h |  5 +
 2 files changed, 19 insertions(+)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 3cf7a01..e02c43e 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -384,6 +384,19 @@ int of_irq_to_resource(struct device_node *dev, int index, 
struct resource *r)
 EXPORT_SYMBOL_GPL(of_irq_to_resource);
 
 /**
+ * of_has_named_irq - Check if given node contains named interrupts
+ * @dev: pointer to device tree node
+ *
+ * Returns %true if node contains non-empty "interrupt-names" property.
+ */
+bool of_has_named_irqs(struct device_node *dev)
+{
+   struct property *prop = of_find_property(dev, "interrupt-names", NULL);
+
+   return prop && prop->value;
+}
+
+/**
  * of_irq_get - Decode a node's IRQ and return it as a Linux irq number
  * @dev: pointer to device tree node
  * @index: zero-based index of the irq
@@ -410,6 +423,7 @@ int of_irq_get(struct device_node *dev, int index)
 }
 EXPORT_SYMBOL_GPL(of_irq_get);
 
+
 /**
  * of_irq_get_byname - Decode a node's IRQ and return it as a Linux irq number
  * @dev: pointer to device tree node
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index d884929..fed6ccc 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -46,6 +46,7 @@ extern int of_irq_get(struct device_node *dev, int index);
 extern int of_irq_get_byname(struct device_node *dev, const char *name);
 extern int of_irq_to_resource_table(struct device_node *dev,
struct resource *res, int nr_irqs);
+extern bool of_has_named_irqs(struct device_node *dev);
 #else
 static inline int of_irq_count(struct device_node *dev)
 {
@@ -64,6 +65,10 @@ static inline int of_irq_to_resource_table(struct 
device_node *dev,
 {
return 0;
 }
+static inline bool of_has_named_irqs(struct device_node *dev)
+{
+   return false;
+}
 #endif
 
 #if defined(CONFIG_OF)
-- 
2.5.0.rc2.392.g76e840b


-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/4] touchscreen: colibri-vf50-ts: Add touchscreen support for Colibri VF50

2015-07-21 Thread Dmitry Torokhov
Hi Stefan,

On Tue, Jul 21, 2015 at 04:43:36PM +0200, Stefan Agner wrote:
> Hi Dmitry,
> 
> As the original author of the driver I have some remarks to your review
> 
> On 2015-07-18 01:42, Dmitry Torokhov wrote:
> >> +  /*
> >> +   * If touch pressure is too low, stop measuring and reenable
> >> +   * touch detection
> >> +   */
> >> +  if (val_p < min_pressure || val_p > 2000)
> >> +  break;
> 
> This is where the modules touch pressure is used to stop the measurement
> process and switch back to interrupt mode. See my remarks at the end.
> 
> >> +
> >> +  /*
> >> +   * The pressure may not be enough for the first x and the
> >> +   * second y measurement, but, the pressure is ok when the
> >> +   * driver is doing the third and fourth measurement. To
> >> +   * take care of this, we drop the first measurement always.
> >> +   */
> >> +  if (discard_val_on_start) {
> >> +  discard_val_on_start = false;
> >> +  } else {
> >> +  /*
> >> +   * Report touch position and sleep for
> >> +   * next measurement
> >> +   */
> >> +  input_report_abs(vf50_ts->ts_input,
> >> +  ABS_X, VF_ADC_MAX - val_x);
> >> +  input_report_abs(vf50_ts->ts_input,
> >> +  ABS_Y, VF_ADC_MAX - val_y);
> >> +  input_report_abs(vf50_ts->ts_input,
> >> +  ABS_PRESSURE, val_p);
> >> +  input_report_key(vf50_ts->ts_input, BTN_TOUCH, 1);
> >> +  input_sync(vf50_ts->ts_input);
> >> +  }
> >> +
> >> +  msleep(10);
> >> +  }
> >> +
> >> +  /* Report no more touch, reenable touch detection */
> >> +  input_report_abs(vf50_ts->ts_input, ABS_PRESSURE, 0);
> >> +  input_report_key(vf50_ts->ts_input, BTN_TOUCH, 0);
> >> +  input_sync(vf50_ts->ts_input);
> >> +
> >> +  vf50_ts_enable_touch_detection(vf50_ts);
> >> +
> >> +  /* Wait for the pull-up to be stable on high */
> >> +  msleep(10);
> >> +
> >> +  /* Reenable IRQ to detect touch */
> >> +  enable_irq(vf50_ts->pen_irq);
> >> +
> >> +  dev_dbg(dev, "Reenabled touch detection interrupt\n");
> >> +}
> >> +
> >> +static irqreturn_t vf50_ts_touched(int irq, void *dev_id)
> >> +{
> >> +  struct vf50_touch_device *vf50_ts = (struct vf50_touch_device *)dev_id;
> >> +  struct device *dev = &vf50_ts->pdev->dev;
> >> +
> >> +  dev_dbg(dev, "Touch detected, start worker thread\n");
> >> +
> >> +  disable_irq_nosync(irq);
> >> +
> >> +  /* Disable the touch detection plates */
> >> +  gpiod_set_value(vf50_ts->gpio_ym, 0);
> >> +
> >> +  /* Let the platform mux to default state in order to mux as ADC */
> >> +  pinctrl_pm_select_default_state(dev);
> >> +
> >> +  queue_work(vf50_ts->ts_workqueue, &vf50_ts->ts_work);
> > 
> > If you convert this to a threaded interrupt you won't need to
> > disable/reenable interrupt or queue work. You should also be able to use
> > gpiod_set_value_cansleep() extending the range of ways the controller
> > could be connected to systems.
> > 
> 
> I'm not sure if a threaded interrupt is the right thing here. While the
> pen is on the touchscreen (which can be for several seconds)
> measurements have to be made in a continuous loop. Is it ok for a
> threaded interrupt to run that long?

Yes, why not? Threaded interrupt is simply a kernel thread that is woken
when hard interrupt handler tells it to wake up. Very similar to
interrupt + work queue, except that the kernel manages interactions
properly for you. There are several drivers in kernel that do that, for
example auo-pixcir-ts.c or tsc2007.c

> 
> I'm also not sure if it is really safe to _not_ disable the pen down
> GPIO interrupt. If we get a interrupt while measuring, we should ignore
> that interrupt.

The interrupt management core (you'll have to annotate it as
IRQF_ONESHOT) will make sure it stays masked properly until the threaded
handler completes so you do not need to disable it explicitly.

> 
> On resistive touch screens the pen down works by relying on the 

Re: [PATCH v1 7/7] input: cyapa: add CYAP0002 Gen6 device for ACPI configuration

2015-07-20 Thread Dmitry Torokhov
On Mon, Jun 15, 2015 at 05:01:37PM +0800, Dudley Du wrote:
> Add CYTP0002 name for Gen6 device for ACPI configuration
> TEST=test on Chromebook.
> 
> Signed-off-by: Dudley Du 

Applied, thank you.

> ---
>  drivers/input/mouse/cyapa.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index 7b6d6d4..7f674aa 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
> @@ -1558,6 +1558,7 @@ MODULE_DEVICE_TABLE(i2c, cyapa_id_table);
>  static const struct acpi_device_id cyapa_acpi_id[] = {
>   { "CYAP", 0 },  /* Gen3 trackpad with 0x67 I2C address. */
>   { "CYAP0001", 0 },  /* Gen5 trackpad with 0x24 I2C address. */
> + { "CYAP0002", 0 },  /* Gen6 trackpad with 0x24 I2C address. */
>   { }
>  };
>  MODULE_DEVICE_TABLE(acpi, cyapa_acpi_id);
> -- 
> 1.9.1
> 
> 
> ---
> This message and any attachments may contain Cypress (or its
> subsidiaries) confidential information. If it has been received
> in error, please advise the sender and immediately delete this
> message.
> ---
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 6/7] input: cyapa: add of match device support and description document

2015-07-20 Thread Dmitry Torokhov
On Mon, Jun 15, 2015 at 05:01:36PM +0800, Dudley Du wrote:
> Add of_match_device mechanism support for Cypress trackpad device, and
> add the sample description document of adding the trackpad device node in
> device tree.
> TEST=test on Chromebook.
> 
> Signed-off-by: Dudley Du 
> ---
>  .../devicetree/bindings/input/cypress,cyapa.txt| 44 
> ++
>  .../devicetree/bindings/vendor-prefixes.txt|  1 +
>  drivers/input/mouse/cyapa.c| 10 +
>  3 files changed, 55 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/cypress,cyapa.txt
> 
> diff --git a/Documentation/devicetree/bindings/input/cypress,cyapa.txt 
> b/Documentation/devicetree/bindings/input/cypress,cyapa.txt
> new file mode 100644
> index 000..9be2b44
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/cypress,cyapa.txt
> @@ -0,0 +1,44 @@
> +Cypress I2C Touchpad
> +
> +Required properties:
> +- compatible: must be "cypress,cyapa".
> +- reg: I2C address of the chip.
> +- interrupt-parent: a phandle for the interrupt controller (see interrupt
> +  binding[0]).
> +- interrupts: interrupt to which the chip is connected (see interrupt
> +  binding[0]).
> +
> +Optional properties:
> +- wakeup-source: touchpad can be used as a wakeup source.
> +- pinctrl-names: should be "default" (see pinctrl binding [1]).
> +- pinctrl-0: a phandle pointing to the pin settings for the device (see
> +  pinctrl binding [1]).
> +- vcc-supply: a phandle for the regulator supplying 3.3V power.

I do not see it being used in the driver?

> +
> +[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
> +[1]: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
> +
> +Example:
> + &i2c0 {
> + /* ... */
> +
> + /* Cypress Gen3 touchpad */
> + touchpad@67 {
> + compatible = "cypress,cyapa";
> + reg = <0x24>;
> + interrupt-parent = <&gpio>;
> + interrupts = <2 IRQ_TYPE_EDGE_FALLING>; /* GPIO 2 */
> + wakeup-source;
> + };
> +
> + /* Cypress Gen5 and later touchpad */
> + touchpad@24 {
> + compatible = "cypress,cyapa";
> + reg = <0x24>;
> + interrupt-parent = <&gpio>;
> + interrupts = <2 IRQ_TYPE_EDGE_FALLING>; /* GPIO 2 */
> + wakeup-source;
> + };
> +
> + /* ... */
> + };
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index ee2ce7b..e43d532 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -54,6 +54,7 @@ cortina Cortina Systems, Inc.
>  cosmic   Cosmic Circuits
>  crystalfontz Crystalfontz America, Inc.
>  cubietechCubietech, Ltd.
> +cypress  Cypress Semiconductor Corporation
>  dallas   Maxim Integrated Products (formerly Dallas Semiconductor)
>  davicom  DAVICOM Semiconductor, Inc.
>  deltaDelta Electronics, Inc.
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index 4e69594..7b6d6d4 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include "cyapa.h"
>  
>  
> @@ -1562,12 +1563,21 @@ static const struct acpi_device_id cyapa_acpi_id[] = {
>  MODULE_DEVICE_TABLE(acpi, cyapa_acpi_id);
>  #endif
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id cyapa_of_match[] = {
> + { .compatible = "cypress,cyapa" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, cyapa_of_match);
> +#endif
> +
>  static struct i2c_driver cyapa_driver = {
>   .driver = {
>   .name = "cyapa",
>   .owner = THIS_MODULE,
>   .pm = &cyapa_pm_ops,
>   .acpi_match_table = ACPI_PTR(cyapa_acpi_id),
> + .of_match_table = of_match_ptr(cyapa_of_match),
>   },
>  
>   .probe = cyapa_probe,
> -- 
> 1.9.1
> 
> 
> ---
> This message and any attachments may contain Cypress (or its
> subsidiaries) confidential information. If it has been received
> in error, please advise the sender and immediately delete this
> message.
> ---
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 4/7] input: cyapa: fully support runtime suspend power management

2015-07-20 Thread Dmitry Torokhov
On Mon, Jun 15, 2015 at 05:01:34PM +0800, Dudley Du wrote:
> Fix the the runtime suspend power management not working issue when system
> starts up and before user touches the trackpad device.
> TEST=test on Chromebook.
> 
> Signed-off-by: Dudley Du 

Applied, thank you.

> ---
>  drivers/input/mouse/cyapa.c  | 79 
> +++-
>  drivers/input/mouse/cyapa.h  |  2 +-
>  drivers/input/mouse/cyapa_gen3.c |  4 +-
>  drivers/input/mouse/cyapa_gen5.c | 21 +++
>  drivers/input/mouse/cyapa_gen6.c |  4 +-
>  5 files changed, 72 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index d2a24fc..9288948 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
> @@ -371,7 +371,7 @@ static int cyapa_detect(struct cyapa *cyapa)
>  static int cyapa_open(struct input_dev *input)
>  {
>   struct cyapa *cyapa = input_get_drvdata(input);
> - struct i2c_client *client = cyapa->client;
> + struct device *dev = &cyapa->client->dev;
>   int error;
>  
>   error = mutex_lock_interruptible(&cyapa->state_sync_lock);
> @@ -385,10 +385,9 @@ static int cyapa_open(struct input_dev *input)
>* when in operational mode.
>*/
>   error = cyapa->ops->set_power_mode(cyapa,
> - PWR_MODE_FULL_ACTIVE, 0);
> + PWR_MODE_FULL_ACTIVE, 0, false);
>   if (error) {
> - dev_warn(&client->dev,
> - "set active power failed: %d\n", error);
> + dev_warn(dev, "set active power failed: %d\n", error);
>   goto out;
>   }
>   } else {
> @@ -399,11 +398,15 @@ static int cyapa_open(struct input_dev *input)
>   }
>   }
>  
> - enable_irq(client->irq);
> - if (!pm_runtime_enabled(&client->dev)) {
> - pm_runtime_set_active(&client->dev);
> - pm_runtime_enable(&client->dev);
> + enable_irq(cyapa->client->irq);
> + if (!pm_runtime_enabled(dev)) {
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
>   }
> +
> + pm_runtime_get_sync(dev);
> + pm_runtime_mark_last_busy(dev);
> + pm_runtime_put_sync_autosuspend(dev);
>  out:
>   mutex_unlock(&cyapa->state_sync_lock);
>   return error;
> @@ -412,17 +415,17 @@ out:
>  static void cyapa_close(struct input_dev *input)
>  {
>   struct cyapa *cyapa = input_get_drvdata(input);
> - struct i2c_client *client = cyapa->client;
> + struct device *dev = &cyapa->client->dev;
>  
>   mutex_lock(&cyapa->state_sync_lock);
>  
> - disable_irq(client->irq);
> - if (pm_runtime_enabled(&client->dev))
> - pm_runtime_disable(&client->dev);
> - pm_runtime_set_suspended(&client->dev);
> + disable_irq(cyapa->client->irq);
> + if (pm_runtime_enabled(dev))
> + pm_runtime_disable(dev);
> + pm_runtime_set_suspended(dev);
>  
>   if (cyapa->operational)
> - cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0);
> + cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0, false);
>  
>   mutex_unlock(&cyapa->state_sync_lock);
>  }
> @@ -533,7 +536,7 @@ static void cyapa_enable_irq_for_cmd(struct cyapa *cyapa)
>*/
>   if (!input || cyapa->operational)
>   cyapa->ops->set_power_mode(cyapa,
> - PWR_MODE_FULL_ACTIVE, 0);
> + PWR_MODE_FULL_ACTIVE, 0, false);
>   /* Gen3 always using polling mode for command. */
>   if (cyapa->gen >= CYAPA_GEN5)
>   enable_irq(cyapa->client->irq);
> @@ -548,7 +551,8 @@ static void cyapa_disable_irq_for_cmd(struct cyapa *cyapa)
>   if (cyapa->gen >= CYAPA_GEN5)
>   disable_irq(cyapa->client->irq);
>   if (!input || cyapa->operational)
> - cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0);
> + cyapa->ops->set_power_mode(cyapa,
> +PWR_MODE_OFF, 0, false);
>   }
>  }
>  
> @@ -615,7 +619,7 @@ static int cyapa_initialize(struct cyapa *cyapa)
>  
>   /* Power down the device until we need it. */
>   if (cyapa->operational)
> - cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0);
> + cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0, false);
>  
>   return 0;
>  }
> @@ -631,7 +635,8 @@ static int cyapa_reinitialize(struct cyapa *cyapa)
>  
>   /* Avoid command failures when TP was in OFF state. */
>   if (cyapa->operational)
> - cyapa->ops->set_power_mode(cyapa, PWR_MODE_FULL_ACTIVE, 0);
> + cyapa->ops->set_power_mode(cyapa,
> +PWR_MODE_FULL_ACTIVE, 0, false);
>  
>   error = cyapa_detect(cyapa

Re: [PATCH v1 3/7] input: cyapa: add proximity function support for gen5 and gen6 modules

2015-07-20 Thread Dmitry Torokhov
Hi Dudley,

On Mon, Jun 15, 2015 at 05:01:33PM +0800, Dudley Du wrote:
>  
> +static void cyapa_pip_report_proximity(struct cyapa *cyapa,
> + const struct cyapa_pip_report_data *report_data)
> +{
> + struct input_dev *input = cyapa->input;
> + u8 distance = report_data->report_head[PIP_PROXIMITY_DISTANCE_OFFSET] &
> + PIP_PROXIMITY_DISTANCE_MASK;
> +
> + input_report_abs(input, ABS_MT_DISTANCE, distance);
> + input_sync(input);

It looks like the distance reported by the hardware is not per-contact
(i.e. it can not tell that we had 2 fingers on surface and the 2nd one
was lifted and is now hovering over the surface), so we should be using
ABS_DISTANCE, not ABS_MT_DISTANCE.

I can adjust it here, no need to resend.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 2/7] input: cyapa: add gen6 device module support in driver

2015-07-20 Thread Dmitry Torokhov
On Mon, Jun 15, 2015 at 05:01:32PM +0800, Dudley Du wrote:
> Based on the cyapa core, add the gen6 trackpad device's basic functions
> supported, so gen6 trackpad device can work with kernel input system.
> And also based on the state parse interface, the cyapa driver can
> automatically determine the attached is gen3, gen5 or gen6 protocol
> trackpad device, then set the correct protocol to work with the attached
> trackpad device.
> TEST=test on Chromebook.
> 
> Signed-off-by: Dudley Du 

Applied, thank you.

> ---
>  drivers/input/mouse/Makefile |   2 +-
>  drivers/input/mouse/cyapa.c  |  22 ++
>  drivers/input/mouse/cyapa.h  |  15 +
>  drivers/input/mouse/cyapa_gen5.c |  69 +++-
>  drivers/input/mouse/cyapa_gen6.c | 727 
> +++
>  5 files changed, 831 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/input/mouse/cyapa_gen6.c
> 
> diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
> index 793300b..ee6a6e9 100644
> --- a/drivers/input/mouse/Makefile
> +++ b/drivers/input/mouse/Makefile
> @@ -24,7 +24,7 @@ obj-$(CONFIG_MOUSE_SYNAPTICS_I2C)   += synaptics_i2c.o
>  obj-$(CONFIG_MOUSE_SYNAPTICS_USB)+= synaptics_usb.o
>  obj-$(CONFIG_MOUSE_VSXXXAA)  += vsxxxaa.o
>  
> -cyapatp-objs := cyapa.o cyapa_gen3.o cyapa_gen5.o
> +cyapatp-objs := cyapa.o cyapa_gen3.o cyapa_gen5.o cyapa_gen6.o
>  psmouse-objs := psmouse-base.o synaptics.o focaltech.o
>  
>  psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index 4f0d76e..dbb53eb 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
> @@ -41,6 +41,9 @@ static int cyapa_reinitialize(struct cyapa *cyapa);
>  
>  bool cyapa_is_pip_bl_mode(struct cyapa *cyapa)
>  {
> + if (cyapa->gen == CYAPA_GEN6 && cyapa->state == CYAPA_STATE_GEN6_BL)
> + return true;
> +
>   if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_BL)
>   return true;
>  
> @@ -49,6 +52,9 @@ bool cyapa_is_pip_bl_mode(struct cyapa *cyapa)
>  
>  bool cyapa_is_pip_app_mode(struct cyapa *cyapa)
>  {
> + if (cyapa->gen == CYAPA_GEN6 && cyapa->state == CYAPA_STATE_GEN6_APP)
> + return true;
> +
>   if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_APP)
>   return true;
>  
> @@ -204,6 +210,15 @@ static int cyapa_get_state(struct cyapa *cyapa)
>   if (!error)
>   goto out_detected;
>   }
> + if (cyapa->gen == CYAPA_GEN_UNKNOWN ||
> + cyapa->gen == CYAPA_GEN6 ||
> + cyapa->gen == CYAPA_GEN5) {
> + error = cyapa_pip_state_parse(cyapa,
> + status, BL_STATUS_SIZE);
> + if (!error)
> + goto out_detected;
> + }
> + /* For old Gen5 trackpads detecting. */
>   if ((cyapa->gen == CYAPA_GEN_UNKNOWN ||
>   cyapa->gen == CYAPA_GEN5) &&
>   !smbus && even_addr) {
> @@ -300,6 +315,9 @@ static int cyapa_check_is_operational(struct cyapa *cyapa)
>   return error;
>  
>   switch (cyapa->gen) {
> + case CYAPA_GEN6:
> + cyapa->ops = &cyapa_gen6_ops;
> + break;
>   case CYAPA_GEN5:
>   cyapa->ops = &cyapa_gen5_ops;
>   break;
> @@ -579,6 +597,8 @@ static int cyapa_initialize(struct cyapa *cyapa)
>   error = cyapa_gen3_ops.initialize(cyapa);
>   if (!error)
>   error = cyapa_gen5_ops.initialize(cyapa);
> + if (!error)
> + error = cyapa_gen6_ops.initialize(cyapa);
>   if (error)
>   return error;
>  
> @@ -1136,9 +1156,11 @@ static char *cyapa_state_to_string(struct cyapa *cyapa)
>   case CYAPA_STATE_BL_ACTIVE:
>   return "bootloader active";
>   case CYAPA_STATE_GEN5_BL:
> + case CYAPA_STATE_GEN6_BL:
>   return "bootloader";
>   case CYAPA_STATE_OP:
>   case CYAPA_STATE_GEN5_APP:
> + case CYAPA_STATE_GEN6_APP:
>   return "operational";  /* Normal valid state. */
>   default:
>   return "invalid mode";
> diff --git a/drivers/input/mouse/cyapa.h b/drivers/input/mouse/cyapa.h
> index d019d1d..3a211c0 100644
> --- a/drivers/input/mouse/cyapa.h
> +++ b/drivers/input/mouse/cyapa.h
> @@ -19,6 +19,7 @@
>  #define CYAPA_GEN_UNKNOWN   0x00   /* unknown protocol. */
>  #define CYAPA_GEN3   0x03   /* support MT-protocol B with tracking ID. */
>  #define CYAPA_GEN5   0x05   /* support TrueTouch GEN5 trackpad device. */
> +#define CYAPA_GEN6   0x06   /* support TrueTouch GEN6 trackpad device. */
>  
>  #define CYAPA_NAME   "Cypress APA Trackpad (cyapa)"
>  
> @@ -198,6 +199,9 @@
>  #define PIP_BL_APP_INFO_RESP_LENGTH  30
>  #define PIP_BL_GET_INFO_RESP_LENGTH  19
>  
> 

Re: [PATCH v1 1/7] input: cyapa: change strings of gen5 to pip in the name when they are shared

2015-07-20 Thread Dmitry Torokhov
On Mon, Jun 15, 2015 at 05:01:31PM +0800, Dudley Du wrote:
> Change strings 'gen5' to 'pip' for all macros, variables and functions when
> they are shared in gen5 and gen6 modules. The change of these strings is
> aimed to keep name definition much more clear and readable.
> Also the spelling errors are fix in this patch.
> TEST=test on Chromebook.
> 
> Signed-off-by: Dudley Du 

Applied, thank you.

> ---
>  drivers/input/mouse/cyapa.c  |   34 +-
>  drivers/input/mouse/cyapa.h  |  136 -
>  drivers/input/mouse/cyapa_gen3.c |4 +-
>  drivers/input/mouse/cyapa_gen5.c | 1103 
> ++
>  4 files changed, 673 insertions(+), 604 deletions(-)
> 
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index efe1484..4f0d76e 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
> @@ -6,7 +6,7 @@
>   *   Daniel Kurtz 
>   *   Benson Leung 
>   *
> - * Copyright (C) 2011-2014 Cypress Semiconductor, Inc.
> + * Copyright (C) 2011-2015 Cypress Semiconductor, Inc.
>   * Copyright (C) 2011-2012 Google, Inc.
>   *
>   * This file is subject to the terms and conditions of the GNU General Public
> @@ -39,11 +39,27 @@ const char product_id[] = "CYTRA";
>  
>  static int cyapa_reinitialize(struct cyapa *cyapa);
>  
> -static inline bool cyapa_is_bootloader_mode(struct cyapa *cyapa)
> +bool cyapa_is_pip_bl_mode(struct cyapa *cyapa)
>  {
>   if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_BL)
>   return true;
>  
> + return false;
> +}
> +
> +bool cyapa_is_pip_app_mode(struct cyapa *cyapa)
> +{
> + if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_APP)
> + return true;
> +
> + return false;
> +}
> +
> +static inline bool cyapa_is_bootloader_mode(struct cyapa *cyapa)
> +{
> + if (cyapa_is_pip_bl_mode(cyapa))
> + return true;
> +
>   if (cyapa->gen == CYAPA_GEN3 &&
>   cyapa->state >= CYAPA_STATE_BL_BUSY &&
>   cyapa->state <= CYAPA_STATE_BL_ACTIVE)
> @@ -54,7 +70,7 @@ static inline bool cyapa_is_bootloader_mode(struct cyapa 
> *cyapa)
>  
>  static inline bool cyapa_is_operational_mode(struct cyapa *cyapa)
>  {
> - if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_APP)
> + if (cyapa_is_pip_app_mode(cyapa))
>   return true;
>  
>   if (cyapa->gen == CYAPA_GEN3 && cyapa->state == CYAPA_STATE_OP)
> @@ -306,7 +322,7 @@ static int cyapa_check_is_operational(struct cyapa *cyapa)
>  
>  /*
>   * Returns 0 on device detected, negative errno on no device detected.
> - * And when the device is detected and opertaional, it will be reset to
> + * And when the device is detected and operational, it will be reset to
>   * full power active mode automatically.
>   */
>  static int cyapa_detect(struct cyapa *cyapa)
> @@ -629,15 +645,15 @@ static irqreturn_t cyapa_irq(int irq, void *dev_id)
>   if (device_may_wakeup(dev))
>   pm_wakeup_event(dev, 0);
>  
> - /* Interrupt event maybe cuased by host command to trackpad device. */
> + /* Interrupt event maybe caused by host command to trackpad device. */
>   if (cyapa->ops->irq_cmd_handler(cyapa)) {
>   /*
>* Interrupt event maybe from trackpad device input reporting.
>*/
>   if (!cyapa->input) {
>   /*
> -  * Still in probling or in firware image
> -  * udpating or reading.
> +  * Still in probing or in firmware image
> +  * updating or reading.
>*/
>   cyapa->ops->sort_empty_output_data(cyapa,
>   NULL, NULL, NULL);
> @@ -1051,12 +1067,12 @@ static ssize_t cyapa_update_fw_store(struct device 
> *dev,
>   dev_dbg(dev, "firmware update successfully done.\n");
>  
>   /*
> -  * Redetect trackpad device states because firmware update process
> +  * Re-detect trackpad device states because firmware update process
>* will reset trackpad device into bootloader mode.
>*/
>   ret = cyapa_reinitialize(cyapa);
>   if (ret) {
> - dev_err(dev, "failed to redetect after updated: %d\n", ret);
> + dev_err(dev, "failed to re-detect after updated: %d\n", ret);
>   error = error ? error : ret;
>   }
>  
> diff --git a/drivers/input/mouse/cyapa.h b/drivers/input/mouse/cyapa.h
> index adc9ed5..d019d1d 100644
> --- a/drivers/input/mouse/cyapa.h
> +++ b/drivers/input/mouse/cyapa.h
> @@ -3,7 +3,7 @@
>   *
>   * Author: Dudley Du 
>   *
> - * Copyright (C) 2014 Cypress Semiconductor, Inc.
> + * Copyright (C) 2014-2015 Cypress Semiconductor, Inc.
>   *
>   * This file is subject to the terms and conditions of the GNU General Public
>   * License.  See the file COPYING in the main directory of this archive for
> @@ -25,7 +25,7 @@
>  /*

Re: [PATCH 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

2015-07-19 Thread Dmitry Torokhov
On Sun, Jul 19, 2015 at 11:05:07PM -0700, Tony Lindgren wrote:
> * Vignesh R  [150719 21:51]:
> > On 7/18/2015 3:21 AM, Dmitry Torokhov wrote:
> > > 
> > > I wonder if driver core should be responsible for clearing wake irq and
> > > also for clearing wakeup flag.
> > > 
> > 
> > AFAICU, wakeup flag is deleted when struct device is deleted, hence,
> > device_init_wakeup() call may not be required in .remove(). But,
> > dev_pm_clear_wake_irq() can be moved to driver core.
> 
> Currently the lifecycle of struct wakeup_source is not necessarily
> the same as the lifecycle struct device. I believe net and usb drivers
> at least allocate it dynamically.

I am not sure if I follow. I was wondering if we should clear the wakeup
IRQ setting on the driver unbinding. It does not mean that we'd be
deleting wakeup_source, just that we'll clear wakeup irq setting from
it.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

2015-07-19 Thread Dmitry Torokhov
On Mon, Jul 20, 2015 at 10:20:13AM +0530, Vignesh R wrote:
> On am437x-gp-evm, pixcir touchscreen can wake the system from low power
> state by generating wake-up interrupt via pinctrl and IO daisy chain.
> Add support for optional wakeup interrupt source by regsitering to
> automated wake IRQ framework introduced by commit 4990d4fe327b ("PM /
> Wakeirq: Add automated device wake IRQ handling").
> This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
> support for optional wake-up")
> 
> Signed-off-by: Vignesh R 
> ---
> v2:
>  * use of_irq_get_byname()
>  * remove enable/disable_wake_irq()
> 
>  drivers/input/touchscreen/pixcir_i2c_ts.c | 17 +
>  include/linux/input/pixcir_ts.h   |  1 +
>  2 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 8f3e243a62bf..b9cebf274678 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -29,6 +29,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #define PIXCIR_MAX_SLOTS   5 /* Max fingers supported by driver */
>  
> @@ -364,8 +366,6 @@ static int __maybe_unused pixcir_i2c_ts_suspend(struct 
> device *dev)
>   goto unlock;
>   }
>   }
> -
> - enable_irq_wake(client->irq);
>   } else if (input->users) {
>   ret = pixcir_stop(ts);
>   }
> @@ -386,8 +386,6 @@ static int __maybe_unused pixcir_i2c_ts_resume(struct 
> device *dev)
>   mutex_lock(&input->mutex);
>  
>   if (device_may_wakeup(&client->dev)) {
> - disable_irq_wake(client->irq);
> -
>   if (!input->users) {
>   ret = pixcir_stop(ts);
>   if (ret) {
> @@ -445,6 +443,8 @@ static struct pixcir_ts_platform_data 
> *pixcir_parse_dt(struct device *dev)
>   dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__,
>   pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb);
>  
> + pdata->wakeirq = of_irq_get_byname(dev->of_node, "wakeupirq");
> +
>   return pdata;
>  }
>  #else
> @@ -564,11 +564,20 @@ static int pixcir_i2c_ts_probe(struct i2c_client 
> *client,
>   i2c_set_clientdata(client, tsdata);
>   device_init_wakeup(&client->dev, 1);
>  
> + /* Register wakeirq */
> + error = pdata->wakeirq ?

Hmm, I guess the condition should be pdata->wakeirq > 0.

> + dev_pm_set_dedicated_wake_irq(dev, pdata->wakeirq) :
> + dev_pm_set_wake_irq(dev, client->irq);
> + if (error)
> + dev_info(dev, "unable to get wakeirq %d\n",
> +  error);
> +
>   return 0;
>  }
>  
>  static int pixcir_i2c_ts_remove(struct i2c_client *client)
>  {
> + dev_pm_clear_wake_irq(&client->dev);
>   device_init_wakeup(&client->dev, 0);
>  
>   return 0;
> diff --git a/include/linux/input/pixcir_ts.h b/include/linux/input/pixcir_ts.h
> index 7bae83b7c396..da573de5a5ee 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 wakeirq;
>   struct pixcir_i2c_chip_data chip;
>  };
>  
> -- 
> 2.4.5
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

2015-07-19 Thread Dmitry Torokhov
On Sun, Jul 19, 2015 at 11:09:30PM -0700, Tony Lindgren wrote:
> * Vignesh R  [150719 21:53]:
> > @@ -445,6 +443,8 @@ static struct pixcir_ts_platform_data 
> > *pixcir_parse_dt(struct device *dev)
> > dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__,
> > pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb);
> >  
> > +   pdata->wakeirq = of_irq_get_byname(dev->of_node, "wakeupirq");
> > +
> > return pdata;
> 
> What about handling -EPROVE_DEFER here? At least pinctrl-single can be
> be a loadable module for the dedicated wakeirqs.

Right. I think we should only allow -ENODATA to continue and return
error in all other cases.

Also, I think "irq" suffix on name is redundant.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] Input: ads7846 - change name of wakeup property to "wakeup-source"

2015-07-17 Thread Dmitry Torokhov
Wakeup property of device is not Linux-specific, it describes intended
system behavior regardless of the OS being used. Therefore let's drop
"linux," prefix, and, while at it, use the same name as I2C bus does:
"wakeup-source".

We keep parsing old name to keep compatibility with old DTSes.

Signed-off-by: Dmitry Torokhov 
---
 Documentation/devicetree/bindings/input/ads7846.txt | 2 +-
 drivers/input/touchscreen/ads7846.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/ads7846.txt 
b/Documentation/devicetree/bindings/input/ads7846.txt
index 5f7619c..df8b127 100644
--- a/Documentation/devicetree/bindings/input/ads7846.txt
+++ b/Documentation/devicetree/bindings/input/ads7846.txt
@@ -64,7 +64,7 @@ Optional properties:
pendown-gpio (u32).
pendown-gpioGPIO handle describing the pin the 
!PENIRQ
line is connected to.
-   linux,wakeupuse any event on touchscreen as wakeup 
event.
+   wakeup-source   use any event on touchscreen as wakeup 
event.
 
 
 Example for a TSC2046 chip connected to an McSPI controller of an OMAP SoC::
diff --git a/drivers/input/touchscreen/ads7846.c 
b/drivers/input/touchscreen/ads7846.c
index e4eb8a6..0f5f968 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -1234,7 +1234,8 @@ static const struct ads7846_platform_data 
*ads7846_probe_dt(struct device *dev)
of_property_read_u32(node, "ti,pendown-gpio-debounce",
 &pdata->gpio_pendown_debounce);
 
-   pdata->wakeup = of_property_read_bool(node, "linux,wakeup");
+   pdata->wakeup = of_property_read_bool(node, "wakeup-source") ||
+   of_property_read_bool(node, "linux,wakeup");
 
pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 
0);
 
-- 
2.4.3.573.g4eafbef

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] Input: gpio_keys[_polled] - change name of wakeup property

2015-07-17 Thread Dmitry Torokhov
Wakeup property of device is not Linux-specific, it describes intended
system behavior regardless of the OS being used. Therefore let's drop
"linux," prefix, and, while at it, use the same name as I2C bus does:
"wakeup-source".

We keep parsing old name to keep compatibility with old DTSes.

Signed-off-by: Dmitry Torokhov 
---
 Documentation/devicetree/bindings/input/gpio-keys-polled.txt | 2 +-
 Documentation/devicetree/bindings/input/gpio-keys.txt| 2 +-
 drivers/input/keyboard/gpio_keys.c   | 4 +++-
 drivers/input/keyboard/gpio_keys_polled.c| 5 -
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/gpio-keys-polled.txt 
b/Documentation/devicetree/bindings/input/gpio-keys-polled.txt
index 313abef..5b91f5a 100644
--- a/Documentation/devicetree/bindings/input/gpio-keys-polled.txt
+++ b/Documentation/devicetree/bindings/input/gpio-keys-polled.txt
@@ -20,7 +20,7 @@ Optional subnode-properties:
  If not specified defaults to <1> == EV_KEY.
- debounce-interval: Debouncing interval time in milliseconds.
  If not specified defaults to 5.
-   - gpio-key,wakeup: Boolean, button can wake-up the system.
+   - wakeup-source: Boolean, button can wake-up the system.
 
 Example nodes:
 
diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt 
b/Documentation/devicetree/bindings/input/gpio-keys.txt
index 44b7057..072bf75 100644
--- a/Documentation/devicetree/bindings/input/gpio-keys.txt
+++ b/Documentation/devicetree/bindings/input/gpio-keys.txt
@@ -23,7 +23,7 @@ Optional subnode-properties:
  If not specified defaults to <1> == EV_KEY.
- debounce-interval: Debouncing interval time in milliseconds.
  If not specified defaults to 5.
-   - gpio-key,wakeup: Boolean, button can wake-up the system.
+   - wakeup-source: Boolean, button can wake-up the system.
- linux,can-disable: Boolean, indicates that button is connected
  to dedicated (not shared) interrupt which can be disabled to
  suppress events from the button.
diff --git a/drivers/input/keyboard/gpio_keys.c 
b/drivers/input/keyboard/gpio_keys.c
index ddf4045..1df4507 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -655,7 +655,9 @@ gpio_keys_get_devtree_pdata(struct device *dev)
if (of_property_read_u32(pp, "linux,input-type", &button->type))
button->type = EV_KEY;
 
-   button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
+   button->wakeup = of_property_read_bool(pp, "wakeup-source") ||
+/* legacy name */
+of_property_read_bool(pp, "gpio-key,wakeup");
 
button->can_disable = !!of_get_property(pp, 
"linux,can-disable", NULL);
 
diff --git a/drivers/input/keyboard/gpio_keys_polled.c 
b/drivers/input/keyboard/gpio_keys_polled.c
index 097d721..5a0c999 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -152,7 +152,10 @@ static struct gpio_keys_platform_data 
*gpio_keys_polled_get_devtree_pdata(struct
 &button->type))
button->type = EV_KEY;
 
-   button->wakeup = fwnode_property_present(child, 
"gpio-key,wakeup");
+   button->wakeup =
+   fwnode_property_read_bool(child, "wakeup-source") ||
+   /* legacy name */
+   fwnode_property_read_bool(child, "gpio-key,wakeup");
 
if (fwnode_property_read_u32(child, "debounce-interval",
 &button->debounce_interval))
-- 
2.4.3.573.g4eafbef

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] Input: pmic8xxx-keypad - change name of wakeup property

2015-07-17 Thread Dmitry Torokhov
Wakeup property of device is not Linux-specific, it describes intended
system behavior regardless of the OS being used. Therefore let's drop
"linux," prefix, and, while at it, use the same name as I2C bus does:
"wakeup-source".

We keep parsing old name to keep compatibility with old DTSes.

Signed-off-by: Dmitry Torokhov 
---
 Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt |  2 +-
 drivers/input/keyboard/pmic8xxx-keypad.c   | 10 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt 
b/Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt
index 7d8cb92..ee62156 100644
--- a/Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt
+++ b/Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt
@@ -33,7 +33,7 @@ PROPERTIES
Value type: 
Definition: don't enable autorepeat feature.
 
-- linux,keypad-wakeup:
+- wakeup-source:
Usage: optional
Value type: 
Definition: use any event on keypad as wakeup event.
diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c 
b/drivers/input/keyboard/pmic8xxx-keypad.c
index 32580af..5c68e3f 100644
--- a/drivers/input/keyboard/pmic8xxx-keypad.c
+++ b/drivers/input/keyboard/pmic8xxx-keypad.c
@@ -507,6 +507,7 @@ static void pmic8xxx_kp_close(struct input_dev *dev)
  */
 static int pmic8xxx_kp_probe(struct platform_device *pdev)
 {
+   struct device_node *np = pdev->dev.of_node;
unsigned int rows, cols;
bool repeat;
bool wakeup;
@@ -524,10 +525,11 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev)
return -EINVAL;
}
 
-   repeat = !of_property_read_bool(pdev->dev.of_node,
-   "linux,input-no-autorepeat");
-   wakeup = of_property_read_bool(pdev->dev.of_node,
-   "linux,keypad-wakeup");
+   repeat = !of_property_read_bool(np, "linux,input-no-autorepeat");
+
+   wakeup = of_property_read_bool(np, "wakeup-source") ||
+/* legacy name */
+of_property_read_bool(np, "linux,keypad-wakeup");
 
kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL);
if (!kp)
-- 
2.4.3.573.g4eafbef

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] Input: samsung-keypad - change name of wakeup property

2015-07-17 Thread Dmitry Torokhov
Wakeup property of device is not Linux-specific, it describes intended
system behavior regardless of the OS being used. Therefore let's drop
"linux," prefix, and, while at it, use the same name as I2C bus does:
"wakeup-source".

We keep parsing old name to keep compatibility with old DTSes.

Signed-off-by: Dmitry Torokhov 
---
 Documentation/devicetree/bindings/input/samsung-keypad.txt | 4 +++-
 drivers/input/keyboard/samsung-keypad.c| 6 --
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/samsung-keypad.txt 
b/Documentation/devicetree/bindings/input/samsung-keypad.txt
index 942d071..863e77f 100644
--- a/Documentation/devicetree/bindings/input/samsung-keypad.txt
+++ b/Documentation/devicetree/bindings/input/samsung-keypad.txt
@@ -36,9 +36,11 @@ Required Board Specific Properties:
 - pinctrl-0: Should specify pin control groups used for this controller.
 - pinctrl-names: Should contain only one value - "default".
 
+Optional Properties:
+- wakeup-source: use any event on keypad as wakeup event.
+
 Optional Properties specific to linux:
 - linux,keypad-no-autorepeat: do no enable autorepeat feature.
-- linux,keypad-wakeup: use any event on keypad as wakeup event.
 
 
 Example:
diff --git a/drivers/input/keyboard/samsung-keypad.c 
b/drivers/input/keyboard/samsung-keypad.c
index 43e48dac..dc05f39 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -299,8 +299,10 @@ samsung_keypad_parse_dt(struct device *dev)
if (of_get_property(np, "linux,input-no-autorepeat", NULL))
pdata->no_autorepeat = true;
 
-   if (of_get_property(np, "linux,input-wakeup", NULL))
-   pdata->wakeup = true;
+   pdata->wakeup = of_property_read_bool(pp, "wakeup-source") ||
+   /* legacy name */
+   of_property_read_bool(pp, "linux,input-wakeup");
+
 
return pdata;
 }
-- 
2.4.3.573.g4eafbef

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] Input: tc3589x-keypad - change name of wakeup property

2015-07-17 Thread Dmitry Torokhov
Wakeup property of device is not Linux-specific, it describes intended
system behavior regardless of the OS being used. Therefore let's drop
"linux," prefix, and, while at it, use the same name as I2C bus does:
"wakeup-source".

We keep parsing old name to keep compatibility with old DTSes.

Signed-off-by: Dmitry Torokhov 
---
 Documentation/devicetree/bindings/mfd/tc3589x.txt | 4 ++--
 drivers/input/keyboard/tc3589x-keypad.c   | 5 -
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/tc3589x.txt 
b/Documentation/devicetree/bindings/mfd/tc3589x.txt
index 6fcedba..37bf7f1 100644
--- a/Documentation/devicetree/bindings/mfd/tc3589x.txt
+++ b/Documentation/devicetree/bindings/mfd/tc3589x.txt
@@ -55,7 +55,7 @@ Optional nodes:
  - linux,keymap: the definition can be found in
bindings/input/matrix-keymap.txt
  - linux,no-autorepeat: do no enable autorepeat feature.
- - linux,wakeup: use any event on keypad as wakeup event.
+ - wakeup-source: use any event on keypad as wakeup event.
 
 Example:
 
@@ -84,7 +84,6 @@ tc35893@44 {
keypad,num-columns = <8>;
keypad,num-rows = <8>;
linux,no-autorepeat;
-   linux,wakeup;
linux,keymap = <0x0301006b
0x04010066
0x06040072
@@ -103,5 +102,6 @@ tc35893@44 {
0x01030039
0x07060069
0x050500d9>;
+   wakeup-source;
};
 };
diff --git a/drivers/input/keyboard/tc3589x-keypad.c 
b/drivers/input/keyboard/tc3589x-keypad.c
index 31c606a..565805e 100644
--- a/drivers/input/keyboard/tc3589x-keypad.c
+++ b/drivers/input/keyboard/tc3589x-keypad.c
@@ -352,7 +352,10 @@ tc3589x_keypad_of_probe(struct device *dev)
}
 
plat->no_autorepeat = of_property_read_bool(np, "linux,no-autorepeat");
-   plat->enable_wakeup = of_property_read_bool(np, "linux,wakeup");
+
+   plat->enable_wakeup = of_property_read_bool(np, "wakeup-source") ||
+ /* legacy name */
+ of_property_read_bool(np, "linux,wakeup");
 
/* The custom delay format is ms/16 */
of_property_read_u32(np, "debounce-delay-ms", &debounce_ms);
-- 
2.4.3.573.g4eafbef

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/6] Input: standardize on "wakeup-source" property

2015-07-17 Thread Dmitry Torokhov
Hi,

Currently input drivers use many forms of annotating devices that should
be set up as wakeup sources for the system. This patch series converts them
all to use "wakeup-source" name (to match what i2c devices are using) while
keeping old names as fallback to keep compatibility with existing DTSes.

Maybe in the future we could move parsing of "wakeup-source" into device
core.

Thanks.

-- 
Dmitry

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] Input: matrix_keypad - change name of wakeup property to "wakeup-source"

2015-07-17 Thread Dmitry Torokhov
Wakeup property of device is not Linux-specific, it describes intended
system behavior regardless of the OS being used. Therefore let's drop
"linux," prefix, and, while at it, use the same name as I2C bus does:
"wakeup-source".

We keep parsing old name to keep compatibility with old DTSes.

Signed-off-by: Dmitry Torokhov 
---
 Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt | 2 +-
 drivers/input/keyboard/matrix_keypad.c | 6 --
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt 
b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
index ead641c..4d86059 100644
--- a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
+++ b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
@@ -19,7 +19,7 @@ Required Properties:
 
 Optional Properties:
 - linux,no-autorepeat: do no enable autorepeat feature.
-- linux,wakeup:use any event on keypad as wakeup event.
+- wakeup-source:   use any event on keypad as wakeup event.
 - debounce-delay-ms:   debounce interval in milliseconds
 - col-scan-delay-us:   delay, measured in microseconds, that is needed
before we can scan keypad after activating column gpio
diff --git a/drivers/input/keyboard/matrix_keypad.c 
b/drivers/input/keyboard/matrix_keypad.c
index b370a59..7f12b65 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -425,8 +425,10 @@ matrix_keypad_parse_dt(struct device *dev)
 
if (of_get_property(np, "linux,no-autorepeat", NULL))
pdata->no_autorepeat = true;
-   if (of_get_property(np, "linux,wakeup", NULL))
-   pdata->wakeup = true;
+
+   pdata->wakeup = of_property_read_bool(np, "wakeup-source") ||
+   of_property_read_bool(np, "linux,wakeup"); /* legacy */
+
if (of_get_property(np, "gpio-activelow", NULL))
pdata->active_low = true;
 
-- 
2.4.3.573.g4eafbef

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/4] touchscreen: colibri-vf50-ts: Add touchscreen support for Colibri VF50

2015-07-17 Thread Dmitry Torokhov
Hi Sanchayan,


On Thu, Jul 16, 2015 at 08:43:21PM +0530, Sanchayan Maity wrote:
> The Colibri Vybrid VF50 module supports 4-wire touchscreens using
> FETs and ADC inputs. This driver uses the IIO consumer interface
> and relies on the vf610_adc driver based on the IIO framework.

This looks pretty good, thank you. Just a few comments below.

> 
> Signed-off-by: Sanchayan Maity 
> ---
>  drivers/input/touchscreen/Kconfig   |  12 +
>  drivers/input/touchscreen/Makefile  |   1 +
>  drivers/input/touchscreen/colibri-vf50-ts.c | 451 
> 
>  3 files changed, 464 insertions(+)
>  create mode 100644 drivers/input/touchscreen/colibri-vf50-ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 80f6386..28948ca 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -1027,4 +1027,16 @@ config TOUCHSCREEN_ZFORCE
> To compile this driver as a module, choose M here: the
> module will be called zforce_ts.
>  
> +config TOUCHSCREEN_COLIBRI_VF50
> + tristate "Toradex Colibri on board touchscreen driver"
> + depends on GPIOLIB && IIO && VF610_ADC
> + help
> +   Say Y here if you have a Colibri VF50 and plan to use
> +   the on-board provided 4-wire touchscreen driver.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called colibri_vf50_ts.
> +
>  endif
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 44deea7..93746a0 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -84,3 +84,4 @@ obj-$(CONFIG_TOUCHSCREEN_W90X900)   += w90p910_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o
>  obj-$(CONFIG_TOUCHSCREEN_TPS6507X)   += tps6507x-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50)   += colibri-vf50-ts.o
> diff --git a/drivers/input/touchscreen/colibri-vf50-ts.c 
> b/drivers/input/touchscreen/colibri-vf50-ts.c
> new file mode 100644
> index 000..eb16bdc
> --- /dev/null
> +++ b/drivers/input/touchscreen/colibri-vf50-ts.c
> @@ -0,0 +1,451 @@
> +/* Copyright 2015 Toradex AG
> + *
> + * Toradex Colibri VF50 Touchscreen driver
> + *
> + * Originally authored by Stefan Agner for 3.0 kernel
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include 

Why?

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Is not used as far as I can see.

> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DRIVER_NAME "colibri-vf50-ts"
> +#define DRV_VERSION "1.0"
> +
> +#define VF_ADC_MAX ((1 << 12) - 1)
> +
> +#define COLI_TOUCH_MIN_DELAY_US 1000
> +#define COLI_TOUCH_MAX_DELAY_US 2000
> +
> +static int min_pressure = 200;
> +
> +struct vf50_touch_device {
> + struct platform_device  *pdev;
> + struct input_dev*ts_input;
> + struct workqueue_struct *ts_workqueue;
> + struct work_struct  ts_work;
> + struct iio_channel  *channels;
> + struct gpio_desc *gpio_xp;
> + struct gpio_desc *gpio_xm;
> + struct gpio_desc *gpio_yp;
> + struct gpio_desc *gpio_ym;
> + struct gpio_desc *gpio_pen_detect;
> + struct gpio_desc *gpio_pen_detect_pullup;
> + int pen_irq;
> + bool stop_touchscreen;
> +};
> +
> +/*
> + * Enables given plates and measures touch parameters using ADC
> + */
> +static int adc_ts_measure(struct iio_channel *channel,
> +   struct gpio_desc *plate_p, struct gpio_desc *plate_m)
> +{
> + int i, value = 0, val = 0;
> + int ret;
> +
> + gpiod_set_value(plate_p, 1);
> + gpiod_set_value(plate_m, 1);
> +
> + usleep_range(COLI_TOUCH_MIN_DELAY_US, COLI_TOUCH_MAX_DELAY_US);
> +
> + for (i = 0; i < 5; i++) {
> + ret = iio_read_channel_raw(channel, &val);
> + if (ret < 0)
> + return -EINVAL;
> +
> + value += val;
> + }
> +
> + value /= 5;
> +
> + gpiod_set_value(plate_p, 0);
> + gpiod_set_value(plate_m, 0);
> +
> + return value;
> +}
> +
> +/*
> + * Enable touch detection using falling edge detection on XM
> + */
> +static void vf50_ts_enable_touch_detection(struct vf50_touch_device *vf50_ts)
> +{
> + /* Enable plate YM (needs to be strong GND, high active) */
> + gpiod_set_value(vf50_ts->gpio_ym, 1);
> +
> + /*
> +  * Let the platform mux to idle state in order to enable
> +  * Pull-Up on GPIO
> +  */
> + pinctrl_pm_select_idle_state(&vf50_ts->pdev->dev);
> +}
> +
> +/*
> + * ADC touch screen sampling worker function
> + */
> +

Re: [PATCH RFC V1 2/3] onkey: da9063: Add DA9062 OnKey capability to DA9063 OnKey driver

2015-07-17 Thread Dmitry Torokhov
Hi Steve,

On Tue, Jul 14, 2015 at 02:07:50PM +0100, S Twiss wrote:
> From: S Twiss 
> 
> Add DA9062 OnKey support into the existing DA9063 OnKey driver component by
> using generic access tables for common register and bit mask definitions.
> 
> The following change will add generic register and bit mask support to the
> DA9063 OnKey.
> 
> The following alterations have been made to the DA9063 OnKey:
> 
> - Addition of a da9063_compatible_onkey_regmap structure to hold all
>   generic registers and bitmasks for this type of OnKey component.
> - Addition of an struct of_device_id table for DA9063 and DA9062
>   defaults
> - Refactoring functions to use struct da9063_compatible_onkey accesses
>   to generic registers/masks instead of using defines from registers.h
> - Re-work of da9063_onkey_probe() to use of_match_node() and
>   dev_get_regmap() to provide initialisation of generic registers and
>   masks and access to regmap
> 
> Signed-off-by: Steve Twiss 

Looks generally good, just a few comments.

> 
> ---
> Checks performed with linux-next/next-20150708/scripts/checkpatch.pl
>  Kconfig   total: 0 errors, 14 warnings, 810 lines checked
>  da9063_onkey.ctotal: 0 errors, 2 warnings, 305 lines checked
> This patch applies against linux-next and next-20150708 
> 
> 
>  drivers/input/misc/Kconfig|   6 +-
>  drivers/input/misc/da9063_onkey.c | 139 
> ++
>  2 files changed, 112 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> index d4f0a81..42860f9 100644
> --- a/drivers/input/misc/Kconfig
> +++ b/drivers/input/misc/Kconfig
> @@ -612,10 +612,10 @@ config INPUT_DA9055_ONKEY
>  
>  config INPUT_DA9063_ONKEY
>   tristate "Dialog DA9063 OnKey"

"Dialog DA9062/63 OnKey" maybe?

> - depends on MFD_DA9063
> + depends on MFD_DA9063 || MFD_DA9062
>   help
> -   Support the ONKEY of Dialog DA9063 Power Management IC as an
> -   input device reporting power button statue.
> +   Support the ONKEY of Dialog DA9063 and DA9062 Power Management ICs
> +   as an input device capable for reporting the power button status.
>  
> To compile this driver as a module, choose M here: the module
> will be called da9063_onkey.
> diff --git a/drivers/input/misc/da9063_onkey.c 
> b/drivers/input/misc/da9063_onkey.c
> index f577585..308de2e 100644
> --- a/drivers/input/misc/da9063_onkey.c
> +++ b/drivers/input/misc/da9063_onkey.c
> @@ -1,5 +1,5 @@
>  /*
> - * OnKey device driver for DA9063
> + * OnKey device driver for DA9063 and DA9062 PMICs
>   * Copyright (C) 2015  Dialog Semiconductor Ltd.
>   *
>   * This program is free software; you can redistribute it and/or
> @@ -24,36 +24,96 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
> -struct da9063_onkey {
> - struct da9063 *hw;
> +struct da9063_compatible_onkey_regmap {

Maybe call it da906x_chip_config?

> + /* REGS */
> + int onkey_status;
> + int onkey_pwr_signalling;
> + int onkey_fault_log;
> + int onkey_shutdown;
> + /* MASKS */
> + int onkey_nonkey_mask;
> + int onkey_nonkey_lock_mask;
> + int onkey_key_reset_mask;
> + int onkey_shutdown_mask;
> + /* NAMES */
> + char *name;

const char *?

> +};
> +
> +struct da9063_compatible_onkey {

If you did not rename the structure your diff would be smaller.

>   struct delayed_work work;
>   struct input_dev *input;
>   struct device *dev;
> + struct regmap *regmap;
> + const struct da9063_compatible_onkey_regmap *config;
> + char phys[32];
>   bool key_power;
>  };
>  
> +static const struct da9063_compatible_onkey_regmap da9063_regs = {
> + /* REGS */
> + .onkey_status = DA9063_REG_STATUS_A,
> + .onkey_pwr_signalling = DA9063_REG_CONTROL_B,
> + .onkey_fault_log = DA9063_REG_FAULT_LOG,
> + .onkey_shutdown = DA9063_REG_CONTROL_F,
> + /* MASKS */
> + .onkey_nonkey_mask = DA9063_NONKEY,
> + .onkey_nonkey_lock_mask = DA9063_NONKEY_LOCK,
> + .onkey_key_reset_mask = DA9063_KEY_RESET,
> + .onkey_shutdown_mask = DA9063_SHUTDOWN,
> + /* NAMES */
> + .name = DA9063_DRVNAME_ONKEY,
> +};
> +
> +static const struct da9063_compatible_onkey_regmap da9062_regs = {
> + /* REGS */
> + .onkey_status = DA9062AA_STATUS_A,
> + .onkey_pwr_signalling = DA9062AA_CONTROL_B,
> + .onkey_fault_log = DA9062AA_FAULT_LOG,
> + .onkey_shutdown = DA9062AA_CONTROL_F,
> + /* MASKS */
> + .onkey_nonkey_mask = DA9062AA_NONKEY_MASK,
> + .onkey_nonkey_lock_mask = DA9062AA_NONKEY_LOCK_MASK,
> + .onkey_key_reset_mask = DA9062AA_KEY_RESET_MASK,
> + .onkey_shutdown_mask = DA9062AA_SHUTDOWN_MASK,
> + /* NAMES */
> + .name = "da9062-onkey",
> +};
> +
> +static const struct of_device_id da9063_compatible_reg_id_table[] = {
> + { .compatible = "dlg,da9063-onkey", .data = &da9063_regs },
> + { .compatible =

  1   2   3   4   5   >