Re: [PATCH v7 4/8] mfd: fsl imx25 Touchscreen ADC driver
Markus Pargmann schrieb am 03.03.2015 um 08:58: > This is the core driver for imx25 touchscreen/adc driver. The module > has one shared ADC and two different conversion queues which use the > ADC. The two queues are identical. Both can be used for general purpose > ADC but one is meant to be used for touchscreens. > > This driver is the core which manages the central components and > registers of the TSC/ADC unit. It manages the IRQs and forwards them to > the correct components. > > Signed-off-by: Markus Pargmann > Signed-off-by: Denis Carikli > Acked-by: Jonathan Cameron > --- > Hi Markus, I would recommend to make use of GENMASK for many of the masks you define below. That makes it better readable from which to which bitnumber that mask applies. Thanks, Hartmut <...> > diff --git a/include/linux/mfd/imx25-tsadc.h b/include/linux/mfd/imx25-tsadc.h > new file mode 100644 > index ..da348ac34a41 > --- /dev/null > +++ b/include/linux/mfd/imx25-tsadc.h > @@ -0,0 +1,141 @@ > +#ifndef _LINUX_INCLUDE_INPUT_IMX25_TSADC_H_ > +#define _LINUX_INCLUDE_INPUT_IMX25_TSADC_H_ > + > +struct regmap; > +struct device; > +struct clk; > + > +struct mx25_tsadc { > + struct regmap *regs; > + struct irq_domain *domain; > + struct clk *clk; > +}; > + > +#define MX25_TSC_TGCR0x00 > +#define MX25_TSC_TGSR0x04 > +#define MX25_TSC_TICR0x08 > + > +/* The same register layout for TC and GC queue */ > +#define MX25_ADCQ_FIFO 0x00 > +#define MX25_ADCQ_CR 0x04 > +#define MX25_ADCQ_SR 0x08 > +#define MX25_ADCQ_MR 0x0c > +#define MX25_ADCQ_ITEM_7_0 0x20 > +#define MX25_ADCQ_ITEM_15_8 0x24 > +#define MX25_ADCQ_CFG(n) (0x40 + ((n) * 0x4)) > + > +#define MX25_ADCQ_MR_MASK0x > + > +/* TGCR */ > +#define MX25_TGCR_PDBTIME(x) ((x) << 25) > +#define MX25_TGCR_PDBTIME_MASK MX25_TGCR_PDBTIME(0x7f) > +#define MX25_TGCR_PDBEN BIT(24) > +#define MX25_TGCR_PDEN BIT(23) > +#define MX25_TGCR_ADCCLKCFG(x) ((x) << 16) > +#define MX25_TGCR_GET_ADCCLK(x) (((x) >> 16) & 0x1f) > +#define MX25_TGCR_INTREFEN BIT(10) > +#define MX25_TGCR_POWERMODE_MASK (3 << 8) > +#define MX25_TGCR_POWERMODE_SAVE (1 << 8) > +#define MX25_TGCR_POWERMODE_ON (2 << 8) > +#define MX25_TGCR_STLC BIT(5) > +#define MX25_TGCR_SLPC BIT(4) > +#define MX25_TGCR_FUNC_RST BIT(2) > +#define MX25_TGCR_TSC_RSTBIT(1) > +#define MX25_TGCR_CLK_EN BIT(0) > + > +/* TGSR */ > +#define MX25_TGSR_SLP_INTBIT(2) > +#define MX25_TGSR_GCQ_INTBIT(1) > +#define MX25_TGSR_TCQ_INTBIT(0) > + > +/* ADCQ_ITEM_* */ > +#define _MX25_ADCQ_ITEM(item, x) ((x) << ((item) * 4)) > +#define MX25_ADCQ_ITEM(item, x) ((item) >= 8 ? \ > + _MX25_ADCQ_ITEM((item) - 8, (x)) : _MX25_ADCQ_ITEM((item), (x))) > + > +/* ADCQ_FIFO (TCQFIFO and GCQFIFO) */ > +#define MX25_ADCQ_FIFO_DATA(x) (((x) >> 4) & 0xfff) > +#define MX25_ADCQ_FIFO_ID(x) ((x) & 0xf) > + > +/* ADCQ_CR (TCQR and GCQR) */ > +#define MX25_ADCQ_CR_PDCFG_LEVEL BIT(19) > +#define MX25_ADCQ_CR_PDMSK BIT(18) > +#define MX25_ADCQ_CR_FRSTBIT(17) > +#define MX25_ADCQ_CR_QRSTBIT(16) > +#define MX25_ADCQ_CR_RWAIT_MASK (0xf << 12) > +#define MX25_ADCQ_CR_RWAIT(x)((x) << 12) > +#define MX25_ADCQ_CR_WMRK_MASK (0xf << 8) > +#define MX25_ADCQ_CR_WMRK(x) ((x) << 8) > +#define MX25_ADCQ_CR_LITEMID_MASK(0xf << 4) > +#define MX25_ADCQ_CR_LITEMID(x) ((x) << 4) > +#define MX25_ADCQ_CR_RPT BIT(3) > +#define MX25_ADCQ_CR_FQS BIT(2) > +#define MX25_ADCQ_CR_QSM_MASK0x3 > +#define MX25_ADCQ_CR_QSM_PD 0x1 > +#define MX25_ADCQ_CR_QSM_FQS 0x2 > +#define MX25_ADCQ_CR_QSM_FQS_PD 0x3 > + > +/* ADCQ_SR (TCQSR and GCQSR) */ > +#define MX25_ADCQ_SR_FDRYBIT(15) > +#define MX25_ADCQ_SR_FULLBIT(14) > +#define MX25_ADCQ_SR_EMPTBIT(13) > +#define MX25_ADCQ_SR_FDN(x) (((x) >> 8) & 0x1f) > +#define MX25_ADCQ_SR_FRR BIT(6) > +#define MX25_ADCQ_SR_FUR BIT(5) > +#define MX25_ADCQ_SR_FOR BIT(4) > +#define MX25_ADCQ_SR_EOQ BIT(1) > +#define MX25_ADCQ_SR_PD BIT(0) > + > +/* ADCQ_MR (TCQMR and GCQMR) */ > +#define MX25_ADCQ_MR_FDRY_DMABIT(31) > +#define MX25_ADCQ_MR_FER_DMA BIT(22) > +#define MX25_ADCQ_MR_FUR_DMA BIT(21) > +#define MX25_ADCQ_MR_FOR_DMA BIT(20) > +#define MX25_ADCQ_MR_EOQ_DMA BIT(17) > +#define MX25_ADCQ_MR_PD_DMA BIT(16) > +#define MX25_ADCQ_MR_FDRY_IRQ
Re: [PATCH v7 4/8] mfd: fsl imx25 Touchscreen ADC driver
Hi, Sorry for the late reply, On Mon, Mar 09, 2015 at 09:27:10AM +, Lee Jones wrote: > On Tue, 03 Mar 2015, Markus Pargmann wrote: > > > This is the core driver for imx25 touchscreen/adc driver. The module > > has one shared ADC and two different conversion queues which use the > > ADC. The two queues are identical. Both can be used for general purpose > > ADC but one is meant to be used for touchscreens. > > > > This driver is the core which manages the central components and > > registers of the TSC/ADC unit. It manages the IRQs and forwards them to > > the correct components. > > > > Signed-off-by: Markus Pargmann > > Signed-off-by: Denis Carikli > > Acked-by: Jonathan Cameron > > --- > > > > Notes: > > Changes in v7: > > - Cleanup bit defines in header files to be more readable > > - Fix irq check to return with an error for irq <= 0 > > - Add COMPILE_TEST in Kconfig file > > > > Changes in v5: > > - Remove ifdef CONFIG_OF as this driver is only for DT usage > > - Remove module owner > > - Add Kconfig dependencies ARCH_MX25 and OF > > > > @Jonathan Cameron: > > I left your acked-by on the patch as these were small changes. If it > > should be > > removed, please say so. Thanks > > > > drivers/mfd/Kconfig | 10 +++ > > drivers/mfd/Makefile| 2 + > > drivers/mfd/fsl-imx25-tsadc.c | 164 > > > > include/linux/mfd/imx25-tsadc.h | 141 ++ > > 4 files changed, 317 insertions(+) > > create mode 100644 drivers/mfd/fsl-imx25-tsadc.c > > create mode 100644 include/linux/mfd/imx25-tsadc.h > > > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > > index 38356e39adba..c0036aef61d7 100644 > > --- a/drivers/mfd/Kconfig > > +++ b/drivers/mfd/Kconfig > > @@ -244,6 +244,16 @@ config MFD_MC13XXX_I2C > > help > > Select this if your MC13xxx is connected via an I2C bus. > > > > +config MFD_MX25_TSADC > > + tristate "Freescale i.MX25 integrated Touchscreen and ADC unit" > > + select REGMAP_MMIO > > + depends on SOC_IMX25 || COMPILE_TEST > > + depends on OF > > Are you sure you can't compile test with OF disabled? > > depends on (SOC_IMX25 && OF) || COMPILE_TEST Yes, should be possible without OF. > > > + help > > + Enable support for the integrated Touchscreen and ADC unit of the > > + i.MX25 processors. They consist of a conversion queue for general > > + purpose ADC and a queue for Touchscreens. > > + > > config MFD_HI6421_PMIC > > tristate "HiSilicon Hi6421 PMU/Codec IC" > > depends on OF > > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile > > index 19f3d744e3bd..acfe639e147c 100644 > > --- a/drivers/mfd/Makefile > > +++ b/drivers/mfd/Makefile > > @@ -78,6 +78,8 @@ obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o > > obj-$(CONFIG_MFD_TWL4030_AUDIO)+= twl4030-audio.o > > obj-$(CONFIG_TWL6040_CORE) += twl6040.o > > > > +obj-$(CONFIG_MFD_MX25_TSADC) += fsl-imx25-tsadc.o > > + > > obj-$(CONFIG_MFD_MC13XXX) += mc13xxx-core.o > > obj-$(CONFIG_MFD_MC13XXX_SPI) += mc13xxx-spi.o > > obj-$(CONFIG_MFD_MC13XXX_I2C) += mc13xxx-i2c.o > > diff --git a/drivers/mfd/fsl-imx25-tsadc.c b/drivers/mfd/fsl-imx25-tsadc.c > > new file mode 100644 > > index ..c4a3e15001ea > > --- /dev/null > > +++ b/drivers/mfd/fsl-imx25-tsadc.c > > @@ -0,0 +1,164 @@ > > +/* > > + * 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. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +static struct regmap_config mx25_tsadc_regmap_config = { > > + .fast_io = true, > > + .max_register = 8, > > + .reg_bits = 32, > > + .val_bits = 32, > > + .reg_stride = 4, > > +}; > > + > > +static void mx25_tsadc_irq_handler(u32 irq, struct irq_desc *desc) > > +{ > > + struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc); > > + struct irq_chip *chip = irq_get_chip(irq); > > + u32 status; > > + > > + chained_irq_enter(chip, desc); > > + > > + regmap_read(tsadc->regs, MX25_TSC_TGSR, &status); > > + > > + if (status & MX25_TGSR_GCQ_INT) > > + generic_handle_irq(irq_find_mapping(tsadc->domain, 1)); > > + > > + if (status & MX25_TGSR_TCQ_INT) > > + generic_handle_irq(irq_find_mapping(tsadc->domain, 0)); > > + > > + chained_irq_exit(chip, desc); > > +} > > + > > +static int mx25_tsadc_domain_map(struct irq_domain *d, unsigned int irq, > > +irq_hw_number_t hwirq) > > +{ > > + struct mx25_tsadc *tsadc = d->host_data; > > + > > + irq_set_chip_dat
Re: [PATCH v7 4/8] mfd: fsl imx25 Touchscreen ADC driver
On Tue, 03 Mar 2015, Markus Pargmann wrote: > This is the core driver for imx25 touchscreen/adc driver. The module > has one shared ADC and two different conversion queues which use the > ADC. The two queues are identical. Both can be used for general purpose > ADC but one is meant to be used for touchscreens. > > This driver is the core which manages the central components and > registers of the TSC/ADC unit. It manages the IRQs and forwards them to > the correct components. > > Signed-off-by: Markus Pargmann > Signed-off-by: Denis Carikli > Acked-by: Jonathan Cameron > --- > > Notes: > Changes in v7: > - Cleanup bit defines in header files to be more readable > - Fix irq check to return with an error for irq <= 0 > - Add COMPILE_TEST in Kconfig file > > Changes in v5: > - Remove ifdef CONFIG_OF as this driver is only for DT usage > - Remove module owner > - Add Kconfig dependencies ARCH_MX25 and OF > > @Jonathan Cameron: > I left your acked-by on the patch as these were small changes. If it > should be > removed, please say so. Thanks > > drivers/mfd/Kconfig | 10 +++ > drivers/mfd/Makefile| 2 + > drivers/mfd/fsl-imx25-tsadc.c | 164 > > include/linux/mfd/imx25-tsadc.h | 141 ++ > 4 files changed, 317 insertions(+) > create mode 100644 drivers/mfd/fsl-imx25-tsadc.c > create mode 100644 include/linux/mfd/imx25-tsadc.h > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > index 38356e39adba..c0036aef61d7 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -244,6 +244,16 @@ config MFD_MC13XXX_I2C > help > Select this if your MC13xxx is connected via an I2C bus. > > +config MFD_MX25_TSADC > + tristate "Freescale i.MX25 integrated Touchscreen and ADC unit" > + select REGMAP_MMIO > + depends on SOC_IMX25 || COMPILE_TEST > + depends on OF Are you sure you can't compile test with OF disabled? depends on (SOC_IMX25 && OF) || COMPILE_TEST > + help > + Enable support for the integrated Touchscreen and ADC unit of the > + i.MX25 processors. They consist of a conversion queue for general > + purpose ADC and a queue for Touchscreens. > + > config MFD_HI6421_PMIC > tristate "HiSilicon Hi6421 PMU/Codec IC" > depends on OF > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile > index 19f3d744e3bd..acfe639e147c 100644 > --- a/drivers/mfd/Makefile > +++ b/drivers/mfd/Makefile > @@ -78,6 +78,8 @@ obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o > obj-$(CONFIG_MFD_TWL4030_AUDIO) += twl4030-audio.o > obj-$(CONFIG_TWL6040_CORE) += twl6040.o > > +obj-$(CONFIG_MFD_MX25_TSADC) += fsl-imx25-tsadc.o > + > obj-$(CONFIG_MFD_MC13XXX)+= mc13xxx-core.o > obj-$(CONFIG_MFD_MC13XXX_SPI)+= mc13xxx-spi.o > obj-$(CONFIG_MFD_MC13XXX_I2C)+= mc13xxx-i2c.o > diff --git a/drivers/mfd/fsl-imx25-tsadc.c b/drivers/mfd/fsl-imx25-tsadc.c > new file mode 100644 > index ..c4a3e15001ea > --- /dev/null > +++ b/drivers/mfd/fsl-imx25-tsadc.c > @@ -0,0 +1,164 @@ > +/* > + * 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. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +static struct regmap_config mx25_tsadc_regmap_config = { > + .fast_io = true, > + .max_register = 8, > + .reg_bits = 32, > + .val_bits = 32, > + .reg_stride = 4, > +}; > + > +static void mx25_tsadc_irq_handler(u32 irq, struct irq_desc *desc) > +{ > + struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc); > + struct irq_chip *chip = irq_get_chip(irq); > + u32 status; > + > + chained_irq_enter(chip, desc); > + > + regmap_read(tsadc->regs, MX25_TSC_TGSR, &status); > + > + if (status & MX25_TGSR_GCQ_INT) > + generic_handle_irq(irq_find_mapping(tsadc->domain, 1)); > + > + if (status & MX25_TGSR_TCQ_INT) > + generic_handle_irq(irq_find_mapping(tsadc->domain, 0)); > + > + chained_irq_exit(chip, desc); > +} > + > +static int mx25_tsadc_domain_map(struct irq_domain *d, unsigned int irq, > + irq_hw_number_t hwirq) > +{ > + struct mx25_tsadc *tsadc = d->host_data; > + > + irq_set_chip_data(irq, tsadc); > + irq_set_chip_and_handler(irq, &dummy_irq_chip, > + handle_level_irq); > + set_irq_flags(irq, IRQF_VALID); I think you need to protect this with CONFIG_ARM. > + return 0; > +} > + > +static struct irq_domain_ops mx25_tsadc_domain_ops = { > + .map = mx25_tsadc_domain_map, > + .xlate = i
Re: [PATCH v7 4/8] mfd: fsl imx25 Touchscreen ADC driver
On Sat, Mar 07, 2015 at 05:52:26PM +, Jonathan Cameron wrote: > On 03/03/15 07:58, Markus Pargmann wrote: > > This is the core driver for imx25 touchscreen/adc driver. The module > > has one shared ADC and two different conversion queues which use the > > ADC. The two queues are identical. Both can be used for general purpose > > ADC but one is meant to be used for touchscreens. > > > > This driver is the core which manages the central components and > > registers of the TSC/ADC unit. It manages the IRQs and forwards them to > > the correct components. > > > > Signed-off-by: Markus Pargmann > > Signed-off-by: Denis Carikli > > Acked-by: Jonathan Cameron > hehe. Read it again (backwards so only just found my Ack). > > Anyhow, one really minor comment inline. Feel free > to ignore it. Ack still stands. > > > --- > > > > Notes: > > Changes in v7: > > - Cleanup bit defines in header files to be more readable > > - Fix irq check to return with an error for irq <= 0 > > - Add COMPILE_TEST in Kconfig file > > > > Changes in v5: > > - Remove ifdef CONFIG_OF as this driver is only for DT usage > > - Remove module owner > > - Add Kconfig dependencies ARCH_MX25 and OF > > > > @Jonathan Cameron: > > I left your acked-by on the patch as these were small changes. If it > > should be > > removed, please say so. Thanks > > > > drivers/mfd/Kconfig | 10 +++ > > drivers/mfd/Makefile| 2 + > > drivers/mfd/fsl-imx25-tsadc.c | 164 > > > > include/linux/mfd/imx25-tsadc.h | 141 ++ > > 4 files changed, 317 insertions(+) > > create mode 100644 drivers/mfd/fsl-imx25-tsadc.c > > create mode 100644 include/linux/mfd/imx25-tsadc.h > > > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > > index 38356e39adba..c0036aef61d7 100644 > > --- a/drivers/mfd/Kconfig > > +++ b/drivers/mfd/Kconfig > > @@ -244,6 +244,16 @@ config MFD_MC13XXX_I2C > > help > > Select this if your MC13xxx is connected via an I2C bus. > > > > +config MFD_MX25_TSADC > > + tristate "Freescale i.MX25 integrated Touchscreen and ADC unit" > > + select REGMAP_MMIO > > + depends on SOC_IMX25 || COMPILE_TEST > > + depends on OF > > + help > > + Enable support for the integrated Touchscreen and ADC unit of the > > + i.MX25 processors. They consist of a conversion queue for general > > + purpose ADC and a queue for Touchscreens. > > + > > config MFD_HI6421_PMIC > > tristate "HiSilicon Hi6421 PMU/Codec IC" > > depends on OF > > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile > > index 19f3d744e3bd..acfe639e147c 100644 > > --- a/drivers/mfd/Makefile > > +++ b/drivers/mfd/Makefile > > @@ -78,6 +78,8 @@ obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o > > obj-$(CONFIG_MFD_TWL4030_AUDIO)+= twl4030-audio.o > > obj-$(CONFIG_TWL6040_CORE) += twl6040.o > > > > +obj-$(CONFIG_MFD_MX25_TSADC) += fsl-imx25-tsadc.o > > + > > obj-$(CONFIG_MFD_MC13XXX) += mc13xxx-core.o > > obj-$(CONFIG_MFD_MC13XXX_SPI) += mc13xxx-spi.o > > obj-$(CONFIG_MFD_MC13XXX_I2C) += mc13xxx-i2c.o > > diff --git a/drivers/mfd/fsl-imx25-tsadc.c b/drivers/mfd/fsl-imx25-tsadc.c > > new file mode 100644 > > index ..c4a3e15001ea > > --- /dev/null > > +++ b/drivers/mfd/fsl-imx25-tsadc.c > > @@ -0,0 +1,164 @@ > > +/* > > + * 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. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +static struct regmap_config mx25_tsadc_regmap_config = { > > + .fast_io = true, > > + .max_register = 8, > > + .reg_bits = 32, > > + .val_bits = 32, > > + .reg_stride = 4, > > +}; > > + > > +static void mx25_tsadc_irq_handler(u32 irq, struct irq_desc *desc) > > +{ > > + struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc); > > + struct irq_chip *chip = irq_get_chip(irq); > > + u32 status; > > + > > + chained_irq_enter(chip, desc); > > + > > + regmap_read(tsadc->regs, MX25_TSC_TGSR, &status); > > + > > + if (status & MX25_TGSR_GCQ_INT) > > + generic_handle_irq(irq_find_mapping(tsadc->domain, 1)); > > + > > + if (status & MX25_TGSR_TCQ_INT) > > + generic_handle_irq(irq_find_mapping(tsadc->domain, 0)); > > + > > + chained_irq_exit(chip, desc); > > +} > > + > > +static int mx25_tsadc_domain_map(struct irq_domain *d, unsigned int irq, > > +irq_hw_number_t hwirq) > > +{ > > + struct mx25_tsadc *tsadc = d->host_data; > > + > > + irq_set_chip_data(irq, tsadc); > > + irq_set_
Re: [PATCH v7 4/8] mfd: fsl imx25 Touchscreen ADC driver
On 03/03/15 07:58, Markus Pargmann wrote: > This is the core driver for imx25 touchscreen/adc driver. The module > has one shared ADC and two different conversion queues which use the > ADC. The two queues are identical. Both can be used for general purpose > ADC but one is meant to be used for touchscreens. > > This driver is the core which manages the central components and > registers of the TSC/ADC unit. It manages the IRQs and forwards them to > the correct components. > > Signed-off-by: Markus Pargmann > Signed-off-by: Denis Carikli > Acked-by: Jonathan Cameron hehe. Read it again (backwards so only just found my Ack). Anyhow, one really minor comment inline. Feel free to ignore it. Ack still stands. > --- > > Notes: > Changes in v7: > - Cleanup bit defines in header files to be more readable > - Fix irq check to return with an error for irq <= 0 > - Add COMPILE_TEST in Kconfig file > > Changes in v5: > - Remove ifdef CONFIG_OF as this driver is only for DT usage > - Remove module owner > - Add Kconfig dependencies ARCH_MX25 and OF > > @Jonathan Cameron: > I left your acked-by on the patch as these were small changes. If it > should be > removed, please say so. Thanks > > drivers/mfd/Kconfig | 10 +++ > drivers/mfd/Makefile| 2 + > drivers/mfd/fsl-imx25-tsadc.c | 164 > > include/linux/mfd/imx25-tsadc.h | 141 ++ > 4 files changed, 317 insertions(+) > create mode 100644 drivers/mfd/fsl-imx25-tsadc.c > create mode 100644 include/linux/mfd/imx25-tsadc.h > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > index 38356e39adba..c0036aef61d7 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -244,6 +244,16 @@ config MFD_MC13XXX_I2C > help > Select this if your MC13xxx is connected via an I2C bus. > > +config MFD_MX25_TSADC > + tristate "Freescale i.MX25 integrated Touchscreen and ADC unit" > + select REGMAP_MMIO > + depends on SOC_IMX25 || COMPILE_TEST > + depends on OF > + help > + Enable support for the integrated Touchscreen and ADC unit of the > + i.MX25 processors. They consist of a conversion queue for general > + purpose ADC and a queue for Touchscreens. > + > config MFD_HI6421_PMIC > tristate "HiSilicon Hi6421 PMU/Codec IC" > depends on OF > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile > index 19f3d744e3bd..acfe639e147c 100644 > --- a/drivers/mfd/Makefile > +++ b/drivers/mfd/Makefile > @@ -78,6 +78,8 @@ obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o > obj-$(CONFIG_MFD_TWL4030_AUDIO) += twl4030-audio.o > obj-$(CONFIG_TWL6040_CORE) += twl6040.o > > +obj-$(CONFIG_MFD_MX25_TSADC) += fsl-imx25-tsadc.o > + > obj-$(CONFIG_MFD_MC13XXX)+= mc13xxx-core.o > obj-$(CONFIG_MFD_MC13XXX_SPI)+= mc13xxx-spi.o > obj-$(CONFIG_MFD_MC13XXX_I2C)+= mc13xxx-i2c.o > diff --git a/drivers/mfd/fsl-imx25-tsadc.c b/drivers/mfd/fsl-imx25-tsadc.c > new file mode 100644 > index ..c4a3e15001ea > --- /dev/null > +++ b/drivers/mfd/fsl-imx25-tsadc.c > @@ -0,0 +1,164 @@ > +/* > + * 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. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +static struct regmap_config mx25_tsadc_regmap_config = { > + .fast_io = true, > + .max_register = 8, > + .reg_bits = 32, > + .val_bits = 32, > + .reg_stride = 4, > +}; > + > +static void mx25_tsadc_irq_handler(u32 irq, struct irq_desc *desc) > +{ > + struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc); > + struct irq_chip *chip = irq_get_chip(irq); > + u32 status; > + > + chained_irq_enter(chip, desc); > + > + regmap_read(tsadc->regs, MX25_TSC_TGSR, &status); > + > + if (status & MX25_TGSR_GCQ_INT) > + generic_handle_irq(irq_find_mapping(tsadc->domain, 1)); > + > + if (status & MX25_TGSR_TCQ_INT) > + generic_handle_irq(irq_find_mapping(tsadc->domain, 0)); > + > + chained_irq_exit(chip, desc); > +} > + > +static int mx25_tsadc_domain_map(struct irq_domain *d, unsigned int irq, > + irq_hw_number_t hwirq) > +{ > + struct mx25_tsadc *tsadc = d->host_data; > + > + irq_set_chip_data(irq, tsadc); > + irq_set_chip_and_handler(irq, &dummy_irq_chip, > + handle_level_irq); > + set_irq_flags(irq, IRQF_VALID); > + > + return 0; > +} > + > +static struct irq_domain_ops mx25_tsadc_domain_ops = { > + .map = mx25_tsadc_domain_map, > + .xlate = irq_domain_xlate_
[PATCH v7 4/8] mfd: fsl imx25 Touchscreen ADC driver
This is the core driver for imx25 touchscreen/adc driver. The module has one shared ADC and two different conversion queues which use the ADC. The two queues are identical. Both can be used for general purpose ADC but one is meant to be used for touchscreens. This driver is the core which manages the central components and registers of the TSC/ADC unit. It manages the IRQs and forwards them to the correct components. Signed-off-by: Markus Pargmann Signed-off-by: Denis Carikli Acked-by: Jonathan Cameron --- Notes: Changes in v7: - Cleanup bit defines in header files to be more readable - Fix irq check to return with an error for irq <= 0 - Add COMPILE_TEST in Kconfig file Changes in v5: - Remove ifdef CONFIG_OF as this driver is only for DT usage - Remove module owner - Add Kconfig dependencies ARCH_MX25 and OF @Jonathan Cameron: I left your acked-by on the patch as these were small changes. If it should be removed, please say so. Thanks drivers/mfd/Kconfig | 10 +++ drivers/mfd/Makefile| 2 + drivers/mfd/fsl-imx25-tsadc.c | 164 include/linux/mfd/imx25-tsadc.h | 141 ++ 4 files changed, 317 insertions(+) create mode 100644 drivers/mfd/fsl-imx25-tsadc.c create mode 100644 include/linux/mfd/imx25-tsadc.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 38356e39adba..c0036aef61d7 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -244,6 +244,16 @@ config MFD_MC13XXX_I2C help Select this if your MC13xxx is connected via an I2C bus. +config MFD_MX25_TSADC + tristate "Freescale i.MX25 integrated Touchscreen and ADC unit" + select REGMAP_MMIO + depends on SOC_IMX25 || COMPILE_TEST + depends on OF + help + Enable support for the integrated Touchscreen and ADC unit of the + i.MX25 processors. They consist of a conversion queue for general + purpose ADC and a queue for Touchscreens. + config MFD_HI6421_PMIC tristate "HiSilicon Hi6421 PMU/Codec IC" depends on OF diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 19f3d744e3bd..acfe639e147c 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -78,6 +78,8 @@ obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o obj-$(CONFIG_MFD_TWL4030_AUDIO)+= twl4030-audio.o obj-$(CONFIG_TWL6040_CORE) += twl6040.o +obj-$(CONFIG_MFD_MX25_TSADC) += fsl-imx25-tsadc.o + obj-$(CONFIG_MFD_MC13XXX) += mc13xxx-core.o obj-$(CONFIG_MFD_MC13XXX_SPI) += mc13xxx-spi.o obj-$(CONFIG_MFD_MC13XXX_I2C) += mc13xxx-i2c.o diff --git a/drivers/mfd/fsl-imx25-tsadc.c b/drivers/mfd/fsl-imx25-tsadc.c new file mode 100644 index ..c4a3e15001ea --- /dev/null +++ b/drivers/mfd/fsl-imx25-tsadc.c @@ -0,0 +1,164 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct regmap_config mx25_tsadc_regmap_config = { + .fast_io = true, + .max_register = 8, + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + +static void mx25_tsadc_irq_handler(u32 irq, struct irq_desc *desc) +{ + struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc); + struct irq_chip *chip = irq_get_chip(irq); + u32 status; + + chained_irq_enter(chip, desc); + + regmap_read(tsadc->regs, MX25_TSC_TGSR, &status); + + if (status & MX25_TGSR_GCQ_INT) + generic_handle_irq(irq_find_mapping(tsadc->domain, 1)); + + if (status & MX25_TGSR_TCQ_INT) + generic_handle_irq(irq_find_mapping(tsadc->domain, 0)); + + chained_irq_exit(chip, desc); +} + +static int mx25_tsadc_domain_map(struct irq_domain *d, unsigned int irq, +irq_hw_number_t hwirq) +{ + struct mx25_tsadc *tsadc = d->host_data; + + irq_set_chip_data(irq, tsadc); + irq_set_chip_and_handler(irq, &dummy_irq_chip, +handle_level_irq); + set_irq_flags(irq, IRQF_VALID); + + return 0; +} + +static struct irq_domain_ops mx25_tsadc_domain_ops = { + .map = mx25_tsadc_domain_map, + .xlate = irq_domain_xlate_onecell, +}; + +static int mx25_tsadc_setup_irq(struct platform_device *pdev, + struct mx25_tsadc *tsadc) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + int irq; + + irq = platform_get_irq(pdev, 0); + if (irq <= 0) { + dev_err(dev, "Failed to get irq\n"); + return irq; + } + +