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

2015-11-23 Thread Markus Pargmann
On Saturday 21 November 2015 17:48:10 Jonathan Cameron wrote:
> On 16/11/15 12:01, 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 
> I read this out of curiousity to see how you had handled the touchscreen
> usecase of this hardware differently from the generic version.
> 
> Anyhow, a few little bits and pieces inline from me as a result
> 
> Jonathan
> > ---
> > 
> > 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.
> > +
> >  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

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

2015-11-23 Thread Juergen Borleis
Hi Jonathan,

On Saturday 21 November 2015 18:48:10 Jonathan Cameron wrote:
> [...]
> Another personal preference. I'd not bother wrapping these single line
> calls up but rather just make them inline.  They don't in of
> themselves add much to my mind.  Still this one is very much up to you
> as far as I'm concerned.

A matter of taste. Programming bits is more or less hard to understand even if 
we use macros with useful names. So it is me to prefer self explaining 
functions by no cost of code because the compiler will optimise it away.

Regards,
Juergen

-- 
Pengutronix e.K.                              | Juergen Borleis             |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
--
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-21 Thread Jonathan Cameron
On 21/11/15 17:48, Jonathan Cameron wrote:
> On 16/11/15 12:01, 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 
> I read this out of curiousity to see how you had handled the touchscreen
> usecase of this hardware differently from the generic version.
> 
> Anyhow, a few little bits and pieces inline from me as a result
Ah, I'd missed Dmitry's review.  Looks like he raised the same issue
on ordering in the probe so it doesn't work how I thought ;)
> 
> Jonathan
>> ---
>>
>> 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.
>> +
>>  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

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

2015-11-21 Thread Jonathan Cameron
On 16/11/15 12:01, 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 
I read this out of curiousity to see how you had handled the touchscreen
usecase of this hardware differently from the generic version.

Anyhow, a few little bits and pieces inline from me as a result

Jonathan
> ---
> 
> 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.
> +
>  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

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

2015-11-20 Thread Markus Pargmann
Hi,

On Tuesday 17 November 2015 10:17:20 Dmitry Torokhov wrote:
> 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 

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 (\
> +   

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

2015-11-16 Thread Markus Pargmann
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.
+
 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 (\
+   MX25_ADCQ_CFG_YPLL_OFF | \
+   MX25_ADCQ_CFG_XNUR_OFF | \
+   MX25_ADCQ_CFG_XPUL_HIGH | \
+   MX25_ADCQ_CFG_REFP_INT | \
+   MX25_ADCQ_CFG_IN_XP | \
+   MX25_ADCQ_CFG_REFN_NGND2 | \
+   MX25_ADCQ_CFG_IGS)
+
+#defi