mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: Richard Fitzgerald <rf@opensource.cirrus.com>
Cc: <tglx@linutronix.de>, <jason@lakedaemon.net>,
	<patches@opensource.cirrus.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v13] irqchip: Add driver for Cirrus Logic Madera codecs
Date: Fri, 14 Sep 2018 16:55:12 +0100	[thread overview]
Message-ID: <86pnxgvztr.wl-marc.zyngier@arm.com> (raw)
In-Reply-To: <20180914152809.18248-1-rf@opensource.cirrus.com>

On Fri, 14 Sep 2018 16:28:09 +0100,
Richard Fitzgerald <rf@opensource.cirrus.com> 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 <rf@opensource.cirrus.com>
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> ---
> Only difference from v11 is the copyright headers
> ---
>  MAINTAINERS                        |   2 +
>  drivers/irqchip/Kconfig            |   3 +
>  drivers/irqchip/Makefile           |   1 +
>  drivers/irqchip/irq-madera.c       | 256 +++++++++++++++++++++++++++++++++++++
>  include/linux/irqchip/irq-madera.h | 132 +++++++++++++++++++
>  5 files changed, 394 insertions(+)
>  create mode 100644 drivers/irqchip/irq-madera.c
>  create mode 100644 include/linux/irqchip/irq-madera.h
> 

[...]

> diff --git a/drivers/irqchip/irq-madera.c b/drivers/irqchip/irq-madera.c
> new file mode 100644
> index 000000000000..e9256dee1a45
> --- /dev/null
> +++ b/drivers/irqchip/irq-madera.c

[...]

> +static int madera_irq_probe(struct platform_device *pdev)
> +{
> +	struct madera *madera = dev_get_drvdata(pdev->dev.parent);
> +	struct irq_data *irq_data;
> +	unsigned int irq_flags = 0;
> +	int ret;
> +
> +	dev_dbg(&pdev->dev, "probe\n");
> +
> +	/*
> +	 * 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;
> +	}
> +
> +	/*
> +	 * The silicon always starts at active-low, check if we need to
> +	 * switch to active-high.
> +	 */
> +	if (irq_flags & IRQF_TRIGGER_HIGH) {

Is it safe to assume that the HW is in its reset state? What if the
firmware has configured it otherwise, or if gone through kexec?

> +		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;
> +		}
> +	}
> +
> +	/*
> +	 * NOTE: regmap registers this against the OF node of the parent of
> +	 * the regmap - that is, against the mfd driver
> +	 */
> +	ret = regmap_add_irq_chip(madera->regmap, madera->irq, IRQF_ONESHOT, 0,
> +				  &madera_irq_chip, &madera->irq_data);
> +	if (ret) {
> +		dev_err(&pdev->dev, "add_irq_chip failed: %d\n", ret);
> +		return ret;
> +	}
> +
> +	/* Save dev in parent MFD struct so it is accessible to siblings */
> +	madera->irq_dev = &pdev->dev;
> +
> +	return 0;
> +}

Thanks,

	M.

-- 
Jazz is not dead, it just smell funny.

  reply	other threads:[~2018-09-14 15:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14 15:28 Richard Fitzgerald
2018-09-14 15:55 ` Marc Zyngier [this message]
2018-09-14 16:31   ` Richard Fitzgerald

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86pnxgvztr.wl-marc.zyngier@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=rf@opensource.cirrus.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®