From patchwork Wed Nov 28 13:50:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 1004566 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="L+kWDRkl"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="A5dqLRB9"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 434hw32h1Gz9s1c for ; Thu, 29 Nov 2018 00:54:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8nq+UYrikz+GfzHbJYb2JwLWnkhRt+QmxHuhKfmS+p4=; b=L+kWDRklNwZk/r 2///JSsNuVDFnfaXzxDTr/feQ4CNFWPOd/5TGksfO4eJwrq2C5VpV0QuHaJvh/Dt6lXboRH/0CdPi L95UdFborERJwpz56JmvnaqgsvYFvk5sK2rwTy4rhwBY1vS4yW2IQki/52w3MOoreF0GSICXjiRqP mHfdMr8/bdZoL/C3MEKgb+dinzShqG9zVK7VXh80zR1xZ+tNhwYAKLC7u3/9GSu2lS61LFOMyOZhE 7McBQe724M/l5veHwKpfwMu6cy6KQUhT/S/0H1JVqj5YrSoCFB3YFyHonkmPcKAdP8zrTmwuuP9d+ 5wt3owwPxVRgYWcDZfxw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS0I0-0004ZB-4S; Wed, 28 Nov 2018 13:54:04 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS0Go-0003eW-MC for linux-arm-kernel@lists.infradead.org; Wed, 28 Nov 2018 13:52:59 +0000 Received: by mail-pg1-x544.google.com with SMTP id t13so9527520pgr.11 for ; Wed, 28 Nov 2018 05:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ipl/Aeuyj0hY3JqUyjxodwF3khWSWc9r89gdL6ISlr0=; b=A5dqLRB9vKBRW4eNzqt8FmmIp0y6NJ9NRuDM/4eTO3l3dxi75ijY0PVW2YEMLwe+ut 1pl0IHdBLR5O7+P/e5l0F8tSMuy0IvI40aq+JJNitfs8o0A09o2EvsRjiLWmfj8RpO0U fQbGI9nmuLBRd5383Z6mI/7UTxC59n4coPDEI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ipl/Aeuyj0hY3JqUyjxodwF3khWSWc9r89gdL6ISlr0=; b=c3RSAD7NuVs6qXaMU5FIJSyZl9CsojCpLWZC7lpWUABpQkJpdZGKLU00jkfNhe8CCb PIdvvGxWbXLz+57+QOuX5uS4ChfZwbL/oohXqwuvwJaGhjW2JhYxqlkt5X2BarM8m88M ve3Ivw7+iSHMfVMim/jN0J15nATb00sJeSY06OdPmUj4dt0oiKy5LXyq+7uuPH/ZDz7n lFGBljtD69OAB7+mdpSBuZJeydjCXlOO2eL4L34mfwGk8zGb1fm+8ov0reZgmpgjKS7d OpnCbBuxn0VypfLiGbZiwjCINZS3z3xGRVQ1Mi/YFivmWdpjHN7UxO8Graqt2hinBYoQ 8H3g== X-Gm-Message-State: AGRZ1gI5JJpVo+rMUHZKcMmgigCTBt19Cbho0q0VmLxYWc+wbEpiHEVx RfOYDsK6yGrW+Qbxc3GBoiq4 X-Google-Smtp-Source: AJdET5fNs1ZuFMECW7yxJ0eZu0GNskCR5G3G41us1+PGzi7O4S/id3dxi50kxR5gzEQkymMUe/U+eQ== X-Received: by 2002:a62:1289:: with SMTP id 9mr38039276pfs.102.1543413159692; Wed, 28 Nov 2018 05:52:39 -0800 (PST) Received: from localhost.localdomain ([2409:4072:90a:a93f:b481:6fae:6692:c3ee]) by smtp.gmail.com with ESMTPSA id c4sm22049854pfm.151.2018.11.28.05.52.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 05:52:39 -0800 (PST) From: Manivannan Sadhasivam To: olof@lixom.net, arnd@arndb.de, robh+dt@kernel.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, daniel.lezcano@linaro.org, gregkh@linuxfoundation.org, jslaby@suse.com Subject: [PATCH v3 08/15] irqchip: Add RDA8810PL interrupt driver Date: Wed, 28 Nov 2018 19:20:59 +0530 Message-Id: <20181128135106.9255-9-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181128135106.9255-1-manivannan.sadhasivam@linaro.org> References: <20181128135106.9255-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181128_055251_021334_6BE049F6 X-CRM114-Status: GOOD ( 16.74 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:544 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, amit.kucheria@linaro.org, linux-serial@vger.kernel.org, Manivannan Sadhasivam , overseas.sales@unisoc.com, afaerber@suse.de, linux-arm-kernel@lists.infradead.org, zhao_steven@263.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Add interrupt driver for RDA Micro RDA8810PL SoC. Signed-off-by: Andreas Färber Signed-off-by: Manivannan Sadhasivam Reviewed-by: Marc Zyngier --- arch/arm/mach-rda/Kconfig | 1 + drivers/irqchip/Kconfig | 4 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-rda-intc.c | 107 +++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 drivers/irqchip/irq-rda-intc.c diff --git a/arch/arm/mach-rda/Kconfig b/arch/arm/mach-rda/Kconfig index dafab78d7aab..29012bc68ca4 100644 --- a/arch/arm/mach-rda/Kconfig +++ b/arch/arm/mach-rda/Kconfig @@ -3,5 +3,6 @@ menuconfig ARCH_RDA depends on ARCH_MULTI_V7 select COMMON_CLK select GENERIC_IRQ_CHIP + select RDA_INTC help This enables support for the RDA Micro 8810PL SoC family. diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 51a5ef0e96ed..9d54645870ad 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -195,6 +195,10 @@ config JCORE_AIC help Support for the J-Core integrated AIC. +config RDA_INTC + bool + select IRQ_DOMAIN + config RENESAS_INTC_IRQPIN bool select IRQ_DOMAIN diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 794c13d3ac3d..417108027e40 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -43,6 +43,7 @@ obj-$(CONFIG_IMGPDC_IRQ) += irq-imgpdc.o obj-$(CONFIG_IRQ_MIPS_CPU) += irq-mips-cpu.o obj-$(CONFIG_SIRF_IRQ) += irq-sirfsoc.o obj-$(CONFIG_JCORE_AIC) += irq-jcore-aic.o +obj-$(CONFIG_RDA_INTC) += irq-rda-intc.o obj-$(CONFIG_RENESAS_INTC_IRQPIN) += irq-renesas-intc-irqpin.o obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o diff --git a/drivers/irqchip/irq-rda-intc.c b/drivers/irqchip/irq-rda-intc.c new file mode 100644 index 000000000000..1176291fdef8 --- /dev/null +++ b/drivers/irqchip/irq-rda-intc.c @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * RDA8810PL SoC irqchip driver + * + * Copyright RDA Microelectronics Company Limited + * Copyright (c) 2017 Andreas Färber + * Copyright (c) 2018 Manivannan Sadhasivam + */ + +#include +#include +#include +#include +#include +#include + +#include + +#define RDA_INTC_FINALSTATUS 0x00 +#define RDA_INTC_MASK_SET 0x08 +#define RDA_INTC_MASK_CLR 0x0c + +#define RDA_IRQ_MASK_ALL 0xFFFFFFFF + +#define RDA_NR_IRQS 32 + +static void __iomem *rda_intc_base; +static struct irq_domain *rda_irq_domain; + +static void rda_intc_mask_irq(struct irq_data *d) +{ + writel_relaxed(BIT(d->hwirq), rda_intc_base + RDA_INTC_MASK_CLR); +} + +static void rda_intc_unmask_irq(struct irq_data *d) +{ + writel_relaxed(BIT(d->hwirq), rda_intc_base + RDA_INTC_MASK_SET); +} + +static int rda_intc_set_type(struct irq_data *data, unsigned int flow_type) +{ + /* Hardware supports only level triggered interrupts */ + if ((flow_type & (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW)) == flow_type) + return 0; + + return -EINVAL; +} + +static void __exception_irq_entry rda_handle_irq(struct pt_regs *regs) +{ + u32 stat = readl_relaxed(rda_intc_base + RDA_INTC_FINALSTATUS); + u32 hwirq; + + while (stat) { + hwirq = __fls(stat); + handle_domain_irq(rda_irq_domain, hwirq, regs); + stat &= ~BIT(hwirq); + } +} + +static struct irq_chip rda_irq_chip = { + .name = "rda-intc", + .irq_mask = rda_intc_mask_irq, + .irq_unmask = rda_intc_unmask_irq, + .irq_set_type = rda_intc_set_type, +}; + +static int rda_irq_map(struct irq_domain *d, + unsigned int virq, irq_hw_number_t hw) +{ + irq_set_status_flags(virq, IRQ_LEVEL); + irq_set_chip_and_handler(virq, &rda_irq_chip, handle_level_irq); + irq_set_chip_data(virq, d->host_data); + irq_set_probe(virq); + + return 0; +} + +static const struct irq_domain_ops rda_irq_domain_ops = { + .map = rda_irq_map, + .xlate = irq_domain_xlate_onecell, +}; + +static int __init rda8810_intc_init(struct device_node *node, + struct device_node *parent) +{ + rda_intc_base = of_io_request_and_map(node, 0, "rda-intc"); + if (!rda_intc_base) + return -ENXIO; + + /* Mask all interrupt sources */ + writel_relaxed(RDA_IRQ_MASK_ALL, rda_intc_base + RDA_INTC_MASK_CLR); + + rda_irq_domain = irq_domain_create_linear(&node->fwnode, RDA_NR_IRQS, + &rda_irq_domain_ops, + rda_intc_base); + if (!rda_irq_domain) { + iounmap(rda_intc_base); + return -ENOMEM; + } + + set_handle_irq(rda_handle_irq); + + return 0; +} + +IRQCHIP_DECLARE(rda_intc, "rda,8810pl-intc", rda8810_intc_init);