Re: [PATCH 08/16] irqchip: Add driver for Cirrus Logic Madera codecs

2017-04-10 Thread Rob Herring
On Wed, Apr 05, 2017 at 11:07:56AM +0100, Richard Fitzgerald wrote:
> The Cirrus Logic Madera codecs (Cirrus Logic CS47L35/85/90/91 and WM1840)
> are highly complex devices containing up to 7 programmable DSPs and many
> other internal sources of interrupts plus a number of GPIOs that can be
> used as interrupt inputs. The large number (>150) of internal interrupt
> sources are managed by an on-board interrupt controller.
> 
> This driver provides the handling for the interrupt controller. As the
> codec is accessed via regmap, we can make use of the generic IRQ
> functionality from regmap to do most of the work. Only around half of
> the possible interrupt source are currently of interest from the driver
> so only this subset is defined. Others can be added in future if needed.
> 
> The KConfig options are not user-configurable because this driver is
> mandatory so is automatically included when the parent MFD driver is
> selected.
> 
> Signed-off-by: Richard Fitzgerald 
> Signed-off-by: Charles Keepax 
> ---
>  .../interrupt-controller/cirrus,madera.txt |  31 ++
>  MAINTAINERS|   3 +
>  drivers/irqchip/Kconfig|   5 +
>  drivers/irqchip/Makefile   |   1 +
>  drivers/irqchip/irq-madera.c   | 349 
> +
>  include/linux/irqchip/irq-madera-pdata.h   |  19 ++
>  include/linux/irqchip/irq-madera.h |  96 ++
>  7 files changed, 504 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/interrupt-controller/cirrus,madera.txt
>  create mode 100644 drivers/irqchip/irq-madera.c
>  create mode 100644 include/linux/irqchip/irq-madera-pdata.h
>  create mode 100644 include/linux/irqchip/irq-madera.h
> 
> diff --git 
> a/Documentation/devicetree/bindings/interrupt-controller/cirrus,madera.txt 
> b/Documentation/devicetree/bindings/interrupt-controller/cirrus,madera.txt
> new file mode 100644
> index 000..4505315
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/interrupt-controller/cirrus,madera.txt
> @@ -0,0 +1,31 @@
> +Cirrus Logic Madera class audio codec IRQ driver
> +
> +The IRQ properties are members of the parent MFD node.

Just document them in the MFD binding.

> +
> +See also the core bindings for the parent MFD driver:
> +See Documentation/devicetree/bindings/mfd/madera.txt
> +
> +Required properties:
> +  - interrupt-controller : Madera class devices contain interrupt controllers
> +and may provide interrupt services to other devices.
> +
> +  - #interrupt-cells: the number of cells to describe an IRQ, this should be 
> 2.
> +The first cell is the IRQ number.
> +The second cell is the flags, encoded as the trigger masks from
> +bindings/interrupt-controller/interrupts.txt
> +
> +  - interrupts : The interrupt line the /IRQ signal for the device is
> +connected to.
> +
> +  - interrupt-parent : The parent interrupt controller.
> +
> +Example:
> +
> +codec: cs47l85@0 {
> + compatible = "cirrus,cs47l85";
> +
> + interrupt-controller;
> + #interrupt-cells = <2>;
> + interrupts = <&host_irq1>;
> + interrupt-parent = <&gic>;
> +};


[PATCH 08/16] irqchip: Add driver for Cirrus Logic Madera codecs

2017-04-05 Thread Richard Fitzgerald
The Cirrus Logic Madera codecs (Cirrus Logic CS47L35/85/90/91 and WM1840)
are highly complex devices containing up to 7 programmable DSPs and many
other internal sources of interrupts plus a number of GPIOs that can be
used as interrupt inputs. The large number (>150) of internal interrupt
sources are managed by an on-board interrupt controller.

This driver provides the handling for the interrupt controller. As the
codec is accessed via regmap, we can make use of the generic IRQ
functionality from regmap to do most of the work. Only around half of
the possible interrupt source are currently of interest from the driver
so only this subset is defined. Others can be added in future if needed.

The KConfig options are not user-configurable because this driver is
mandatory so is automatically included when the parent MFD driver is
selected.

Signed-off-by: Richard Fitzgerald 
Signed-off-by: Charles Keepax 
---
 .../interrupt-controller/cirrus,madera.txt |  31 ++
 MAINTAINERS|   3 +
 drivers/irqchip/Kconfig|   5 +
 drivers/irqchip/Makefile   |   1 +
 drivers/irqchip/irq-madera.c   | 349 +
 include/linux/irqchip/irq-madera-pdata.h   |  19 ++
 include/linux/irqchip/irq-madera.h |  96 ++
 7 files changed, 504 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/cirrus,madera.txt
 create mode 100644 drivers/irqchip/irq-madera.c
 create mode 100644 include/linux/irqchip/irq-madera-pdata.h
 create mode 100644 include/linux/irqchip/irq-madera.h

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/cirrus,madera.txt 
b/Documentation/devicetree/bindings/interrupt-controller/cirrus,madera.txt
new file mode 100644
index 000..4505315
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/cirrus,madera.txt
@@ -0,0 +1,31 @@
+Cirrus Logic Madera class audio codec IRQ driver
+
+The IRQ properties are members of the parent MFD node.
+
+See also the core bindings for the parent MFD driver:
+See Documentation/devicetree/bindings/mfd/madera.txt
+
+Required properties:
+  - interrupt-controller : Madera class devices contain interrupt controllers
+and may provide interrupt services to other devices.
+
+  - #interrupt-cells: the number of cells to describe an IRQ, this should be 2.
+The first cell is the IRQ number.
+The second cell is the flags, encoded as the trigger masks from
+bindings/interrupt-controller/interrupts.txt
+
+  - interrupts : The interrupt line the /IRQ signal for the device is
+connected to.
+
+  - interrupt-parent : The parent interrupt controller.
+
+Example:
+
+codec: cs47l85@0 {
+   compatible = "cirrus,cs47l85";
+
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   interrupts = <&host_irq1>;
+   interrupt-parent = <&gic>;
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 1207c9c..a06701f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3266,10 +3266,13 @@ L:  patc...@opensource.wolfsonmicro.com
 T: git https://github.com/CirrusLogic/linux-drivers.git
 W: https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
+F: Documentation/devicetree/bindings/interrupt-controller/cirrus,madera.txt
 F: Documentation/devicetree/bindings/mfd/madera.txt
 F: Documentation/devicetree/bindings/regulator/madera*
+F: include/linux/irqchip/irq-madera*
 F: include/linux/mfd/madera/*
 F: include/linux/regulator/madera*
+F: drivers/irqchip/irq-madera*
 F: drivers/mfd/madera*
 F: drivers/mfd/cs47l*
 F: drivers/regulator/madera*
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 8162121..9c5eae7 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -125,6 +125,11 @@ config IMGPDC_IRQ
select GENERIC_IRQ_CHIP
select IRQ_DOMAIN
 
+config MADERA_IRQ
+   bool
+   select REGMAP_IRQ
+   default y if MFD_MADERA=y
+
 config IRQ_MIPS_CPU
bool
select GENERIC_IRQ_CHIP
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 152bc40..bcc2a8f 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_ARCH_S3C24XX)+= irq-s3c24xx.o
 obj-$(CONFIG_DW_APB_ICTL)  += irq-dw-apb-ictl.o
 obj-$(CONFIG_METAG)+= irq-metag-ext.o
 obj-$(CONFIG_METAG_PERFCOUNTER_IRQS)   += irq-metag.o
+obj-$(CONFIG_MADERA_IRQ)   += irq-madera.o
 obj-$(CONFIG_ARCH_MOXART)  += irq-moxart.o
 obj-$(CONFIG_CLPS711X_IRQCHIP) += irq-clps711x.o
 obj-$(CONFIG_OR1K_PIC) += irq-or1k-pic.o
diff --git a/drivers/irqchip/irq-madera.c b/drivers/irqchip/irq-madera.c
new file mode 100644
index 000..461cbb9
--- /dev/null
+++ b/drivers/irqchip/irq-madera.c
@@ -0,0 +1,349 @@
+/*
+ * Interrupt support for Cirrus Logic Madera codecs