Re: [PATCH v10 6/8] input: touchscreen: imx25 tcq driver
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; > + 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; > + struct device *dev; > +}; > + > +static struct regmap_config mx25_tcq_regconfig = { > + .fast_io = true, > + .max_register = 0x5c, > + .reg_bits = 32, > + .val_bits = 32, > + .reg_stride = 4, > +}; >
[PATCH v10 6/8] input: touchscreen: imx25 tcq driver
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 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; + 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; + struct device *dev; +}; + +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 MX2