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

2015-08-24 Thread Chen Bough
Hi Markus,



> -Original Message-
> From: Markus Pargmann [mailto:m...@pengutronix.de]
> Sent: Friday, August 21, 2015 5:26 PM
> To: Chen Haibo-B51421
> Cc: robh...@kernel.org; pawel.m...@arm.com; mark.rutl...@arm.com;
> ijc+devicet...@hellion.org.uk; ga...@codeaurora.org; shawn...@kernel.org;
> ker...@pengutronix.de; li...@arm.linux.org.uk; dmitry.torok...@gmail.com;
> hans.verk...@cisco.com; had...@hadess.net; mche...@osg.samsung.com;
> mamli...@gmail.com; a...@arndb.de; jonat...@broadcom.com;
> hdego...@redhat.com; christian.gmei...@gmail.com; scott@emc.com.tw;
> ge...@linux-m68k.org; benjamin.tissoi...@redhat.com;
> sebastien.szyman...@armadeus.com; sbran...@broadcom.com;
> devicetree@vger.kernel.org; linux-ker...@vger.kernel.org; linux-arm-
> ker...@lists.infradead.org; linux-in...@vger.kernel.org
> Subject: Re: [PATCH v2 1/5] input: touchscreen: add imx6ul_tsc driver
> support
> 
> On Tue, Jul 28, 2015 at 05:58:37PM +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 | 504
> > +
> >  3 files changed, 517 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..807f1db
> > --- /dev/null
> > +++ b/drivers/input/touchscreen/imx6ul_tsc.c
> > @@ -0,0 +1,504 @@
> > +/*
> > + * 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_CLK0x00
> > +#define ADC_CLK_DIV_8  (0x03 << 5)
> > +#define ADC_SHORT_SAMPLE_MODE  (0x0 << 4)
> > +#define ADC_HARDWARE_TRIGGER   (0x1 <&l

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

2015-08-21 Thread Markus Pargmann
On Tue, Jul 28, 2015 at 05:58:37PM +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 | 504 
> +
>  3 files changed, 517 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..807f1db
> --- /dev/null
> +++ b/drivers/input/touchscreen/imx6ul_tsc.c
> @@ -0,0 +1,504 @@
> +/*
> + * 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)

These defines are in two drivers. Here and in
drivers/iio/adc/vf610_adc.c

> +
> +/* 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;
> + voi

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

2015-08-21 Thread Chen Bough
Hi Dmitry,

Thanks for your patient review, especially for the patch you attached.

I test your patch these days, with below change, touch can work normally.
(also change the xnur to active low in dts)

In probe function:

> - tsc->xnur_gpio = of_get_named_gpio(np, "xnur-gpio", 0);
> - err = gpio_request_one(tsc->xnur_gpio, GPIOF_IN, "tsc_X-");
> - if (err) {
> - dev_err(&pdev->dev, "failed to request GPIO tsc_X-\n");
> + input_set_drvdata(input_dev, tsc);
> +
> + tsc->dev = &pdev->dev;
> + tsc->input = input_dev;
> + init_completion(&tsc->completion);
> +
> + tsc->xnur_gpio = devm_gpiod_get(&pdev->dev, "xnur-gpio", GPIOD_IN);  

Here, we need to change "xnur-gpio" to "xnur", otherwise the gpio request will 
be failed.
This is because gpiod common code already add suffix '-gpio' or 'gpios'.  



For others, your patch seems normal and rational. I will add your patch and 
send patch-V3.

Thanks again!


Best Regards
Haibo Chen



> -Original Message-
> From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com]
> Sent: Wednesday, August 19, 2015 1:12 PM
> To: Chen Haibo-B51421
> Cc: robh...@kernel.org; pawel.m...@arm.com; mark.rutl...@arm.com;
> ijc+devicet...@hellion.org.uk; ga...@codeaurora.org; shawn...@kernel.org;
> ker...@pengutronix.de; li...@arm.linux.org.uk; hans.verk...@cisco.com;
> had...@hadess.net; mche...@osg.samsung.com; mamli...@gmail.com;
> a...@arndb.de; jonat...@broadcom.com; hdego...@redhat.com;
> christian.gmei...@gmail.com; scott@emc.com.tw; ge...@linux-m68k.org;
> benjamin.tissoi...@redhat.com; sebastien.szyman...@armadeus.com;
> sbran...@broadcom.com; devicetree@vger.kernel.org; linux-
> ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; linux-
> in...@vger.kernel.org
> Subject: Re: [PATCH v2 1/5] input: touchscreen: add imx6ul_tsc driver
> support
> 
> Hi Haibo,
> 
> On Tue, Jul 28, 2015 at 05:58:37PM +0800, Haibo Chen wrote:
> > Freescale i.MX6UL contains a internal touchscreen controller, this
> > patch add a driver to support this controller.
> >
> 
> This looks pretty reasonable; just a few comments below.
> 
> > Signed-off-by: Haibo Chen 
> > ---
> >  drivers/input/touchscreen/Kconfig  |  12 +
> >  drivers/input/touchscreen/Makefile |   1 +
> >  drivers/input/touchscreen/imx6ul_tsc.c | 504
> > +
> >  3 files changed, 517 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..807f1db
> > --- /dev/null
> > +++ b/drivers/input/touchscreen/imx6ul_tsc.c
> > @@ -0,0 +1,504 @@
> > +/*
> > + * Freescale i.MX6UL touchscreen controller driver
> > + *
> > + * Copyright (C) 2015 Fre

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

2015-08-18 Thread Dmitry Torokhov
Hi Haibo,

On Tue, Jul 28, 2015 at 05:58:37PM +0800, Haibo Chen wrote:
> Freescale i.MX6UL contains a internal touchscreen controller,
> this patch add a driver to support this controller.
> 

This looks pretty reasonable; just a few comments below.

> Signed-off-by: Haibo Chen 
> ---
>  drivers/input/touchscreen/Kconfig  |  12 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/imx6ul_tsc.c | 504 
> +
>  3 files changed, 517 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..807f1db
> --- /dev/null
> +++ b/drivers/input/touchscreen/imx6ul_tsc.c
> @@ -0,0 +1,504 @@
> +/*
> + * 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 

I do not think you need of_irq and of_device.

> +#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;
>

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

2015-07-28 Thread Haibo Chen
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 | 504 +
 3 files changed, 517 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..807f1db
--- /dev/null
+++ b/drivers/input/touchscreen/imx6ul_tsc.c
@@ -0,0 +1,504 @@
+/*
+ * 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_CLK0x00
+#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_HC00x00
+#define REG_ADC_HC10x04
+#define REG_ADC_HC20x08
+#define REG_ADC_HC30x0C
+#define REG_ADC_HC40x10
+#define REG_ADC_HS 0x14
+#define REG_ADC_R0 0x18
+#define REG_ADC_CFG0x2C
+#define REG_ADC_GC 0x30
+#define REG_ADC_GS 0x34
+
+#define ADC_TIMEOUTmsecs_to_jiffies(100)
+
+/* TSC registers */
+#define REG_TSC_BASIC_SETING   0x00
+#define REG_TSC_PRE_CHARGE_TIME0x10
+#define REG_TSC_FLOW_CONTROL   0x20
+#define REG_TSC_MEASURE_VALUE  0x30
+#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_MODE20x80
+
+/* 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_MODE0x2
+
+struct imx6ul_tsc {
+   struct device *dev;
+   struct input_dev *input;
+   void __iomem *tsc_regs;
+   void __iomem *adc_regs;
+   struct clk *tsc_clk;
+   struct clk *adc_clk;
+
+   int xnur_gpio;
+   int measure_delay_time;
+   int pre_charge_time;
+
+   struct completion completion;
+};
+
+/*
+ * TSC module need ADC to get the measure value. So
+ * before config TSC, we should initialize ADC module.
+ */
+static void imx6ul_adc_init(struc