Skip to contentSkip to conversation

mfd: fsl imx25 Touchscreen ADC driver

PATCH Superseded Denis Carikli 2 participants 3 messages Jun 24, 2014 – Aug 17, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/6 mfd: fsl imx25 Touchscreen ADC driver

From: Markus Pargmann <[email protected]>

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.

---
Changelog v3->v4:
- Added Jonathan's Ack
- ARCH_MXC Kconfigdependency removed.
- mx25_tsadc_get_regmap and mx25_tsadc_get_ipg contents have been moved in the caller function.
- mx25_tsadc_irq_chip has been removed.
- Register definitions are now more humain readable.
- Many other code and style cleanups.

Changelog v2->v3:
- None

---
 .../devicetree/bindings/mfd/fsl-imx25-tsadc.txt    |   46 ++++++
 drivers/mfd/Kconfig                                |    8 +
 drivers/mfd/Makefile                               |    2 +
 drivers/mfd/fsl-imx25-tsadc.c                      |  170 ++++++++++++++++++++
 include/linux/mfd/imx25-tsadc.h                    |  140 ++++++++++++++++
 5 files changed, 366 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/fsl-imx25-tsadc.txt
 create mode 100644 drivers/mfd/fsl-imx25-tsadc.c
 create mode 100644 include/linux/mfd/imx25-tsadc.h
Documentation/devicetree/bindings/mfd/fsl-imx25-tsadc.txt new file +46 -0
new file mode 100644
index 0000000..a857af0e
@@ -0,0 +1,46 @@
+Freescale mx25 ADC/TSC multifunction device
+
+This device combines two general purpose conversion queues one used for general
+ADC and the other used for touchscreens.
+
+Required properties:
+ - compatible: Should be "fsl,imx25-tsadc".
+ - reg: Memory range of the device.
+ - interrupts: Interrupt for this device as described in
+   interrupts/interrupts.txt
+ - clocks: An 'ipg' clock defined as described in clocks/clock.txt
+ - interrupt-controller: This device is an interrupt controller. It controls
+   the interrupts of both conversion queues.
+ - #interrupt-cells: Should be '<1>'.
+ - #address-cells: Should be '<1>'.
+ - #size-cells: Should be '<1>'.
+ - ranges
+
+This device includes two conversion queues which can be added as subnodes.
+The first queue is for the touchscreen, the second for general purpose ADC.
+
+Example:
+	tscadc: tscadc at 50030000 {
+		compatible = "fsl,imx25-tsadc";
+		reg = <0x50030000 0xc>;
+		interrupts = <46>;
+		clocks = <&clks 119>;
+		clock-names = "ipg";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		tsc: tcq at 50030400 {
+			compatible = "fsl,imx25-tcq";
+			reg = <0x50030400 0x60>;
+			...
+		};
+
+		adc: gcq at 50030800 {
+			compatible = "fsl,imx25-gcq";
+			reg = <0x50030800 0x60>;
+			...
+		};
+	};
drivers/mfd/Kconfig +8 -0
index af0e83f..d354547 100644
@@ -183,6 +183,14 @@ config MFD_DA9063
 	  Additional drivers must be enabled in order to use the functionality
 	  of the device.
 
+config MFD_MX25_TSADC
+	tristate "Freescale i.MX25 integrated Touchscreen and ADC unit"
+	select REGMAP_MMIO
+	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_MC13XXX
 	tristate
 	depends on (SPI_MASTER || I2C)
drivers/mfd/Makefile +2 -0
index 4e2bc25..34388c4 100644
@@ -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
drivers/mfd/fsl-imx25-tsadc.c new file +170 -0

170 lines not on this page · raw message

include/linux/mfd/imx25-tsadc.h new file +140 -0

140 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v4 1/6 mfd: fsl imx25 Touchscreen ADC driver

Quoted 7 lines · Denis Carikli

From: Markus Pargmann <[email protected]>

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.

Quoted 7 lines

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.

I think the subject and commit message is misleading. What this patch does is create a MFD hub to handle spawning devices and handle chained IRQs for the ADC unit right? It's not a "core driver" because it's not really driving anything, just proxying things.

drivers/mfd/fsl-imx25-tsadc.c line 57

Quoted 6 lines
drivers/mfd/fsl-imx25-tsadc.c new file +6 -0
+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);

You also need to set a unique lockdep class or lockdep will complain.

static struct lock_class_key my_lock_class;

irq_set_lockdep_class(irq, &my_lock_class);

drivers/mfd/fsl-imx25-tsadc.c line 60

Quoted 3 lines
drivers/mfd/fsl-imx25-tsadc.c new file +3 -0
+       irq_set_chip_and_handler(irq, &dummy_irq_chip,
+                                handle_level_irq);
+       set_irq_flags(irq, IRQF_VALID);

This function only exists on ARM. Unless Kconfig ensures this is only available on ARM platforms, use

#ifdef CONFIG_ARM
      set_irq_flags(irq, IRQF_VALID);
#else
      irq_set_noprobe(irq);

#endif

(Sorry we have no better way of doing it.)

Quoted 2 lines
drivers/mfd/fsl-imx25-tsadc.c new file +2 -0
+static int mx25_tsadc_probe(struct platform_device *pdev)
+{

(...)

Quoted 1 line

+ of_platform_populate(np, NULL, NULL, dev);

This was news2me. Why aren't MFD cells used now that you're using MFD as a spawning hub?

MFD also has a way of translating IRQs passed as resources to children, so they arrive at their children readily translated. Not using MFD cells means you don't use this nice mechanism right?

Or is there some new nice design style that I'm not familiar with, like the OF core handling that translation? (Seems like that, hence asking...)

Yours,
Linus Walleij

#2 lore raw

PATCH v4 1/6 mfd: fsl imx25 Touchscreen ADC driver

Quoted 9 lines · Linus Walleij

drivers/mfd/fsl-imx25-tsadc.c line 60

Quoted 3 lines · Denis Carikli
drivers/mfd/fsl-imx25-tsadc.c new file +3 -0
+       irq_set_chip_and_handler(irq, &dummy_irq_chip,
+                                handle_level_irq);
+       set_irq_flags(irq, IRQF_VALID);

This function only exists on ARM. Unless Kconfig ensures this is only available on ARM platforms, use

Quoted 7 lines
#ifdef CONFIG_ARM
      set_irq_flags(irq, IRQF_VALID);
#else
      irq_set_noprobe(irq);

#endif

(Sorry we have no better way of doing it.)

Since I wrote this, there have been cleanups from Rob Herring merged to the kernel to get rid of this oddity. Please check in linux-next how to get this right, see c.f. commit e8d36d5dbb6a6ec4f5222f8775d664ec29d5527d
"ARM: kill off set_irq_flags usage"

Yours,
Linus Walleij