Re: [PATCH v8 4/8] mfd: fsl imx25 Touchscreen ADC driver

2015-11-23 Thread Markus Pargmann
On Saturday 21 November 2015 17:02:34 Jonathan Cameron wrote:
> On 16/11/15 12:01, 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 
> > 
> > [ensure correct ADC clock depending on the IPG clock]
> > Signed-off-by: Juergen Borleis 
> Looks good to me - one query on meaning of a comment inline.
> 
> Acked-by: Jonathan Cameron 

Thanks, comment inline.

> 
> I'm taking the view this series wants to go through the MFD tree
> but don't mind if it goes through IIO or input instead
> if there is a good reason to do so.
> 
> Jonathan
> > ---
> > 
> > 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 |   9 ++
> >  drivers/mfd/Makefile|   2 +
> >  drivers/mfd/fsl-imx25-tsadc.c   | 204 
> > 
> >  include/linux/mfd/imx25-tsadc.h | 140 +++
> >  4 files changed, 355 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 4d92df6ef9fe..4222e202ad2b 100644
> > --- a/drivers/mfd/Kconfig
> > +++ b/drivers/mfd/Kconfig
> > @@ -271,6 +271,15 @@ 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 && 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 a8b76b81b467..5741be88c173 100644
> > --- a/drivers/mfd/Makefile
> > +++ b/drivers/mfd/Makefile
> > @@ -81,6 +81,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 ..e67d5ca81e10
> > --- /dev/null
> > +++ b/drivers/mfd/fsl-imx25-tsadc.c
> > @@ -0,0 +1,204 @@
> > +/*
> > + * 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(struct irq_desc *desc)
> > +{
> > +   struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc);
> > +   struct irq_chip *chip = irq_desc_get_chip(desc);
> > +   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, unsigne

Re: [PATCH v8 4/8] mfd: fsl imx25 Touchscreen ADC driver

2015-11-21 Thread Jonathan Cameron
On 21/11/15 17:02, Jonathan Cameron wrote:
> On 16/11/15 12:01, 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 
>>
>> [ensure correct ADC clock depending on the IPG clock]
>> Signed-off-by: Juergen Borleis 
> Looks good to me - one query on meaning of a comment inline.
> 
> Acked-by: Jonathan Cameron 
> 
> I'm taking the view this series wants to go through the MFD tree
> but don't mind if it goes through IIO or input instead
> if there is a good reason to do so.
> 
> Jonathan
>> ---
>>
>> 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 |   9 ++
>>  drivers/mfd/Makefile|   2 +
>>  drivers/mfd/fsl-imx25-tsadc.c   | 204 
>> 
>>  include/linux/mfd/imx25-tsadc.h | 140 +++
>>  4 files changed, 355 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 4d92df6ef9fe..4222e202ad2b 100644
>> --- a/drivers/mfd/Kconfig
>> +++ b/drivers/mfd/Kconfig
>> @@ -271,6 +271,15 @@ 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 && 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 a8b76b81b467..5741be88c173 100644
>> --- a/drivers/mfd/Makefile
>> +++ b/drivers/mfd/Makefile
>> @@ -81,6 +81,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 ..e67d5ca81e10
>> --- /dev/null
>> +++ b/drivers/mfd/fsl-imx25-tsadc.c
>> @@ -0,0 +1,204 @@
>> +/*
>> + * 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(struct irq_desc *desc)
>> +{
>> +struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc);
>> +struct irq_chip *chip = irq_desc_get_chip(desc);
>> +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(ir

Re: [PATCH v8 4/8] mfd: fsl imx25 Touchscreen ADC driver

2015-11-21 Thread Jonathan Cameron
On 16/11/15 12:01, 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 
> 
> [ensure correct ADC clock depending on the IPG clock]
> Signed-off-by: Juergen Borleis 
Looks good to me - one query on meaning of a comment inline.

Acked-by: Jonathan Cameron 

I'm taking the view this series wants to go through the MFD tree
but don't mind if it goes through IIO or input instead
if there is a good reason to do so.

Jonathan
> ---
> 
> 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 |   9 ++
>  drivers/mfd/Makefile|   2 +
>  drivers/mfd/fsl-imx25-tsadc.c   | 204 
> 
>  include/linux/mfd/imx25-tsadc.h | 140 +++
>  4 files changed, 355 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 4d92df6ef9fe..4222e202ad2b 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -271,6 +271,15 @@ 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 && 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 a8b76b81b467..5741be88c173 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -81,6 +81,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 ..e67d5ca81e10
> --- /dev/null
> +++ b/drivers/mfd/fsl-imx25-tsadc.c
> @@ -0,0 +1,204 @@
> +/*
> + * 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(struct irq_desc *desc)
> +{
> + struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc);
> + struct irq_chip *chip = irq_desc_get_chip(desc);
> + 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);
> + irq_modify_status(irq, IRQ_NOREQUEST, IRQ_N

[PATCH v8 4/8] mfd: fsl imx25 Touchscreen ADC driver

2015-11-16 Thread Markus Pargmann
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 

[ensure correct ADC clock depending on the IPG clock]
Signed-off-by: Juergen Borleis 
---

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 |   9 ++
 drivers/mfd/Makefile|   2 +
 drivers/mfd/fsl-imx25-tsadc.c   | 204 
 include/linux/mfd/imx25-tsadc.h | 140 +++
 4 files changed, 355 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 4d92df6ef9fe..4222e202ad2b 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -271,6 +271,15 @@ 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 && 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 a8b76b81b467..5741be88c173 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -81,6 +81,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 ..e67d5ca81e10
--- /dev/null
+++ b/drivers/mfd/fsl-imx25-tsadc.c
@@ -0,0 +1,204 @@
+/*
+ * 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(struct irq_desc *desc)
+{
+   struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc);
+   struct irq_chip *chip = irq_desc_get_chip(desc);
+   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);
+   irq_modify_status(irq, IRQ_NOREQUEST, IRQ_NOPROBE);
+
+   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