mfd: madera: Add irqchip data pointer into struct madera
Richard Fitzgerald
maintainerPATCH v10 1/2 mfd: madera: Add irqchip data pointer into struct madera
Put the pointer to struct regmap_irq_chip_data into the parent mfd structure so that the child irqchip driver does not need a trivial private structure to store only this pointer. As the irqchip child driver already has a pointer to the parent struct madera it can use that to store the pointer. This also means that the irqchip driver does not need a double-indirection from its local struct to get at the parent struct madera.
--- include/linux/mfd/madera/core.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/mfd/madera/core.h +2 -0
@@ -148,6 +148,7 @@ struct snd_soc_dapm_context;* @internal_dcvdd: true if DCVDD is supplied from the internal LDO1 * @pdata: our pdata * @irq_dev: the irqchip child driver device +* @irq_data: pointer to irqchip data for the child irqchip driver * @irq: host irq number from SPI or I2C configuration * @out_clamp: indicates output clamp state for each analogue output * @out_shorted: indicates short circuit state for each analogue output
@@ -175,6 +176,7 @@ struct madera {struct madera_pdata pdata;struct device *irq_dev; +struct regmap_irq_chip_data *irq_data;int irq;unsigned int num_micbias;
Signature · 1 line
2.11.0
Richard Fitzgerald
maintainerPATCH v10 2/2 irqchip: Add driver for Cirrus Logic Madera codecs
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.
--- MAINTAINERS | 2 + drivers/irqchip/Kconfig | 3 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-madera.c | 244 +++++++++++++++++++++++++++++++++++++ include/linux/irqchip/irq-madera.h | 135 ++++++++++++++++++++ 5 files changed, 385 insertions(+) create mode 100644 drivers/irqchip/irq-madera.c create mode 100644 include/linux/irqchip/irq-madera.h
MAINTAINERS +2 -0
@@ -3594,8 +3594,10 @@ W: https://github.com/CirrusLogic/linux-drivers/wiki S: Supported F: Documentation/devicetree/bindings/mfd/madera.txt F: Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt +F: include/linux/irqchip/irq-madera* F: include/linux/mfd/madera/* F: drivers/gpio/gpio-madera* +F: drivers/irqchip/irq-madera* F: drivers/mfd/madera* F: drivers/mfd/cs47l* F: drivers/pinctrl/cirrus/*
drivers/irqchip/Kconfig +3 -0
@@ -150,6 +150,9 @@ config IMGPDC_IRQ select GENERIC_IRQ_CHIP select IRQ_DOMAIN +config MADERA_IRQ + tristate + config IRQ_MIPS_CPU bool select GENERIC_IRQ_CHIP
drivers/irqchip/Makefile +1 -0
@@ -88,3 +88,4 @@ obj-$(CONFIG_GOLDFISH_PIC) += irq-goldfish-pic.o obj-$(CONFIG_NDS32) += irq-ativic32.o obj-$(CONFIG_QCOM_PDC) += qcom-pdc.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o +obj-$(CONFIG_MADERA_IRQ) += irq-madera.o
drivers/irqchip/irq-madera.c new file +244 -0
244 lines not on this page · raw message
include/linux/irqchip/irq-madera.h new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH v10 2/2] irqchip: Add driver for Cirrus Logic Madera codecs
drivers/irqchip/irq-madera.c line 9
Quoted 10 lines · Richard Fitzgerald
drivers/irqchip/irq-madera.c new file +9
-0@@ -0,0 +1,244 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Interrupt support for Cirrus Logic Madera codecs +* +* Copyright (C) 2015-2018 Cirrus Logic +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the +* Free Software Foundation; version 2.
You have the SPDX identifier above, which makes this boilerplate superfluous.
Quoted 12 lines
drivers/irqchip/irq-madera.c new file +12
-0+#ifdef CONFIG_PM_SLEEP +static int madera_suspend_noirq (struct device *dev) +{ +struct madera *madera =dev_get_drvdata (dev->parent); + +dev_dbg (madera->irq_dev,"No IRQ suspend, reenabling IRQ\n" ); + +enable_irq (madera->irq); + +return 0 ; +} +
drivers/irqchip/irq-madera.c line 126
Quoted 10 lines
drivers/irqchip/irq-madera.c new file +10
-0+static int madera_suspend (struct device *dev) +{ +struct madera *madera =dev_get_drvdata (dev->parent); + +dev_dbg (madera->irq_dev,"Suspend, disabling IRQ\n" ); + +disable_irq (madera->irq); + +return 0 ; +}
This really wants a comment why you are disabling it first and reenabling it afterwards. I have no idea why you are doing this and it doesn't make much sense from the S/R perspective either.
Quoted 23 lines
drivers/irqchip/irq-madera.c new file +23
-0+/* +* Read the flags from the interrupt controller if not specified +* by pdata +*/ + irq_flags = madera->pdata.irq_flags; +if (!irq_flags) { + irq_data =irq_get_irq_data (madera->irq); +if (!irq_data) { +dev_err (&pdev->dev,"Invalid IRQ: %d\n" , madera->irq); +return -EINVAL ; + } + + irq_flags =irqd_get_trigger_type (irq_data); + +/* Codec defaults to trigger low, use this if no flags given */ +if (irq_flags ==IRQ_TYPE_NONE ) + irq_flags =IRQF_TRIGGER_LOW ; + } + +if (irq_flags & (IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING )) { +dev_err (&pdev->dev,"Host interrupt not level-triggered\n" ); +return -EINVAL ; + }
drivers/irqchip/irq-madera.c line 198
Quoted 10 lines
drivers/irqchip/irq-madera.c new file +10
-0+ +if (irq_flags &IRQF_TRIGGER_HIGH ) { + ret =regmap_update_bits (madera->regmap,MADERA_IRQ1_CTRL , +MADERA_IRQ_POL_MASK ,0 ); +if (ret) { +dev_err (&pdev->dev, +"Failed to set IRQ polarity: %d\n" , ret); +return ret; + } + }
This looks wrong. Why are you only updating the polarity for trigger HIGH?
Quoted 6 lines
include/linux/irqchip/irq-madera.h new file +0
-0
include/linux/irqchip/irq-madera.h line 9
Quoted 9 lines
include/linux/irqchip/irq-madera.h new file +9
-0@@ -0,0 +1,135 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Interrupt support for Cirrus Logic Madera codecs +* +* Copyright 2016-2018 Cirrus Logic +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the +* Free Software Foundation; version 2.
See above.
Thanks,
tglx
Richard Fitzgerald
maintainerRe: [PATCH v10 2/2] irqchip: Add driver for Cirrus Logic Madera codecs
Quoted 15 lines · Thomas Gleixner
drivers/irqchip/irq-madera.c line 9
Quoted 10 lines · Richard Fitzgerald
drivers/irqchip/irq-madera.c new file +9
-0@@ -0,0 +1,244 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Interrupt support for Cirrus Logic Madera codecs +* +* Copyright (C) 2015-2018 Cirrus Logic +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the +* Free Software Foundation; version 2. You have the SPDX identifier above, which makes this boilerplate superfluous.
Our legal people want it left here.
They are ok with the SPDX reference, but they want to keep an explicit statement of the license that was intended.
Quoted 85 lines
Quoted 12 lines
drivers/irqchip/irq-madera.c new file +12
-0+#ifdef CONFIG_PM_SLEEP +static int madera_suspend_noirq (struct device *dev) +{ +struct madera *madera =dev_get_drvdata (dev->parent); + +dev_dbg (madera->irq_dev,"No IRQ suspend, reenabling IRQ\n" ); + +enable_irq (madera->irq); + +return 0 ; +} +drivers/irqchip/irq-madera.c line 126
Quoted 10 lines
drivers/irqchip/irq-madera.c new file +10
-0+static int madera_suspend (struct device *dev) +{ +struct madera *madera =dev_get_drvdata (dev->parent); + +dev_dbg (madera->irq_dev,"Suspend, disabling IRQ\n" ); + +disable_irq (madera->irq); + +return 0 ; +}This really wants a comment why you are disabling it first and reenabling it afterwards. I have no idea why you are doing this and it doesn't make much sense from the S/R perspective either.
Quoted 23 lines
drivers/irqchip/irq-madera.c new file +23
-0+/* +* Read the flags from the interrupt controller if not specified +* by pdata +*/ + irq_flags = madera->pdata.irq_flags; +if (!irq_flags) { + irq_data =irq_get_irq_data (madera->irq); +if (!irq_data) { +dev_err (&pdev->dev,"Invalid IRQ: %d\n" , madera->irq); +return -EINVAL ; + } + + irq_flags =irqd_get_trigger_type (irq_data); + +/* Codec defaults to trigger low, use this if no flags given */ +if (irq_flags ==IRQ_TYPE_NONE ) + irq_flags =IRQF_TRIGGER_LOW ; + } + +if (irq_flags & (IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING )) { +dev_err (&pdev->dev,"Host interrupt not level-triggered\n" ); +return -EINVAL ; + }drivers/irqchip/irq-madera.c line 198
Quoted 10 lines
drivers/irqchip/irq-madera.c new file +10
-0+ +if (irq_flags &IRQF_TRIGGER_HIGH ) { + ret =regmap_update_bits (madera->regmap,MADERA_IRQ1_CTRL , +MADERA_IRQ_POL_MASK ,0 ); +if (ret) { +dev_err (&pdev->dev, +"Failed to set IRQ polarity: %d\n" , ret); +return ret; + } + }This looks wrong. Why are you only updating the polarity for trigger HIGH?
Quoted 6 lines
include/linux/irqchip/irq-madera.h new file +0
-0include/linux/irqchip/irq-madera.h line 9
Quoted 9 lines
include/linux/irqchip/irq-madera.h new file +9
-0@@ -0,0 +1,135 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Interrupt support for Cirrus Logic Madera codecs +* +* Copyright 2016-2018 Cirrus Logic +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the +* Free Software Foundation; version 2. See above.
Thanks,
tglx
Re: [PATCH v10 2/2] irqchip: Add driver for Cirrus Logic Madera codecs
Quoted 18 lines · Richard Fitzgerald
Quoted 16 lines · Thomas Gleixner
Quoted 11 lines · Richard Fitzgerald
drivers/irqchip/irq-madera.c new file +8
-0@@ -0,0 +1,244 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Interrupt support for Cirrus Logic Madera codecs +* +* Copyright (C) 2015-2018 Cirrus Logic +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2.You have the SPDX identifier above, which makes this boilerplate superfluous.
Quoted 3 lines
Our legal people want it left here.
They are ok with the SPDX reference, but they want to keep an explicit statement of the license that was intended.
The SPDX identifier is an explicit statement. Sigh...
Thanks,
tglx
Re: [PATCH v10 2/2] irqchip: Add driver for Cirrus Logic Madera codecs
Quoted 19 lines · Thomas Gleixner
Quoted 18 lines · Richard Fitzgerald
Quoted 16 lines · Thomas Gleixner
Quoted 11 lines · Richard Fitzgerald
drivers/irqchip/irq-madera.c new file +8
-0@@ -0,0 +1,244 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Interrupt support for Cirrus Logic Madera codecs +* +* Copyright (C) 2015-2018 Cirrus Logic +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2.You have the SPDX identifier above, which makes this boilerplate superfluous.
Quoted 5 lines
Quoted 3 lines
Our legal people want it left here.
They are ok with the SPDX reference, but they want to keep an explicit statement of the license that was intended.The SPDX identifier is an explicit statement. Sigh...
Richard, could you please try to re-engage with your legal team and explain that the SPDX identifier replaces the licence statement.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Richard Fitzgerald
maintainerRe: [PATCH v10 2/2] irqchip: Add driver for Cirrus Logic Madera codecs
Quoted 21 lines · Lee Jones
Quoted 19 lines · Thomas Gleixner
Quoted 18 lines · Richard Fitzgerald
Quoted 16 lines · Thomas Gleixner
Quoted 11 lines · Richard Fitzgerald
drivers/irqchip/irq-madera.c new file +8
-0@@ -0,0 +1,244 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Interrupt support for Cirrus Logic Madera codecs +* +* Copyright (C) 2015-2018 Cirrus Logic +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2.You have the SPDX identifier above, which makes this boilerplate superfluous.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Our legal people want it left here.
They are ok with the SPDX reference, but they want to keep an explicit statement of the license that was intended.The SPDX identifier is an explicit statement. Sigh...
Richard, could you please try to re-engage with your legal team and explain that the SPDX identifier replaces the licence statement.
I'll ask.
Richard Fitzgerald
maintainerRe: [PATCH v10 2/2] irqchip: Add driver for Cirrus Logic Madera codecs
Quoted 26 lines · Richard Fitzgerald
Quoted 25 lines · Lee Jones
Quoted 23 lines · Thomas Gleixner
Quoted 21 lines · Richard Fitzgerald
Quoted 16 lines · Thomas Gleixner
Quoted 11 lines · Richard Fitzgerald
drivers/irqchip/irq-madera.c new file +8
-0@@ -0,0 +1,244 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Interrupt support for Cirrus Logic Madera codecs +* +* Copyright (C) 2015-2018 Cirrus Logic +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2.You have the SPDX identifier above, which makes this boilerplate superfluous.
Our legal people want it left here.
They are ok with the SPDX reference, but they want to keep an explicit statement of the license that was intended.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
The SPDX identifier is an explicit statement. Sigh...
Richard, could you please try to re-engage with your legal team and explain that the SPDX identifier replaces the licence statement.
I'll ask.
I just dug out what our legal dept told me, and noticed a point they made is that the licence referenced by the SPDX still says that these headers should be added to each source file.