From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1829ECDFD0 for ; Fri, 14 Sep 2018 15:55:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94B0D21480 for ; Fri, 14 Sep 2018 15:55:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94B0D21480 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727805AbeINVK3 (ORCPT ); Fri, 14 Sep 2018 17:10:29 -0400 Received: from foss.arm.com ([217.140.101.70]:35822 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbeINVK3 (ORCPT ); Fri, 14 Sep 2018 17:10:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 18C6780D; Fri, 14 Sep 2018 08:55:23 -0700 (PDT) Received: from big-swifty.misterjones.org (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CEC3C3F557; Fri, 14 Sep 2018 08:55:20 -0700 (PDT) Date: Fri, 14 Sep 2018 16:55:12 +0100 Message-ID: <86pnxgvztr.wl-marc.zyngier@arm.com> From: Marc Zyngier To: Richard Fitzgerald Cc: , , , Subject: Re: [PATCH v13] irqchip: Add driver for Cirrus Logic Madera codecs In-Reply-To: <20180914152809.18248-1-rf@opensource.cirrus.com> References: <20180914152809.18248-1-rf@opensource.cirrus.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 14 Sep 2018 16:28:09 +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 > --- > 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.