From patchwork Sun Aug 12 12:22:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parthiban Nallathambi X-Patchwork-Id: 10563647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F1F61515 for ; Sun, 12 Aug 2018 12:34:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E9A729766 for ; Sun, 12 Aug 2018 12:34:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 800752976F; Sun, 12 Aug 2018 12:34:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7CFD029766 for ; Sun, 12 Aug 2018 12:34:49 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=1EvqiNHPoUzyK54tNGwmZkZjnxt7JSnarr4kxDYFAhM=; b=NPlrdyYa0E+y3bNE97hdv+EIp1 era47zlRFXGV72ObwawZHKKrXzD5SgVl4HxWlvEBSIO8061bOb0hMqVlAL8CZ0Sif6YpKNLb1rWZv oy4fs8voWpPx9XUlf+X/cdjE5R8oZIixElypvT206A9MIgJaWSO65owp5MtY+lTEkbcWBabfRkAZG +ixeLkI6m9A9JzYJcRbhPok8uCxjp75KMVckOfPHqQGqmoYaasmVf49K44JWa/GZfJbxfbreq9aAt MDZxJt88hFIT72czjG8jtJw1gQBjxxt/4cBgW1exzPWLIJvtpm/Qjy31hC2buBPXcerQ08yHmpxFR lpHZbpxA==; 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 1fopZr-0005DR-Dc; Sun, 12 Aug 2018 12:34:35 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fopZq-0005DB-82 for linux-arm-kernel@bombadil.infradead.org; Sun, 12 Aug 2018 12:34:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gU/mDGHjz9DARAFsdJZ6V/GH8DC0QbwGLHoIlx44tPc=; b=1sgsX0XOZMERVfQ3TN/8X/iV4 5GDZcmBr0cLCJq67PxRoruCJPbgPbWrJmgQhOJgGR1fKaDmyfDWqozfbSRq8mAzDMr1Ey7DcFIhNK FjXxK4q+Eb2bqwKDI1nrjgaaD5yh7CbTgZ5qz9cQn9uaFnvlcEdAMV6Ao/ab/IFOJEGkNtNBMiO79 YrJg+Ae+6b8j3rIWVEeelaf8I1hSEXGvDOWfRME42sHyRPI1UT97bZ2O7wTgeQAFxCxUeSEadhjp7 mciYD4dzpKnM/fFdDTmyPGor28orhm/Q6/hLrIqY6HE8Mb4Kn88al7lCGKkz6IsHNxr9oaJZILryo r77ZJKrNA==; Received: from mail-out.m-online.net ([212.18.0.10]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fopXi-0000R6-1y for linux-arm-kernel@lists.infradead.org; Sun, 12 Aug 2018 12:32:24 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 41pJ0K5sNBz1qw0L; Sun, 12 Aug 2018 14:22:37 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 41pJ0F4yrhz1qqlC; Sun, 12 Aug 2018 14:22:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id zO0_PMVjUjdA; Sun, 12 Aug 2018 14:22:36 +0200 (CEST) X-Auth-Info: ziT/UQMC++VVoDzLAnscmMod9iRE01uTcv4cc55oAs8= Received: from xpert.denx.de (unknown [62.91.23.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 12 Aug 2018 14:22:36 +0200 (CEST) From: Parthiban Nallathambi To: tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, mark.rutland@arm.com, afaerber@suse.de, catalin.marinas@arm.com, will.deacon@arm.com, manivannan.sadhasivam@linaro.org Subject: [PATCH v2 1/3] dt-bindings: interrupt-controller: Actions external interrupt controller Date: Sun, 12 Aug 2018 14:22:13 +0200 Message-Id: <20180812122215.1079590-2-pn@denx.de> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180812122215.1079590-1-pn@denx.de> References: <20180812122215.1079590-1-pn@denx.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180812_083222_404297_6182F5F9 X-CRM114-Status: GOOD ( 13.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux@cubietech.com, sravanhome@gmail.com, guilherme.simoes@lsitec.org.br, laisa.costa@lsitec.org.br, mkzuffo@lsi.usp.br, linux-kernel@vger.kernel.org, thomas.liau@actions-semi.com, mp-cs@actions-semi.com, Parthiban Nallathambi , edgar.righi@lsitec.org.br, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Actions Semi OWL family SoC's provides support for external interrupt controller to be connected and controlled using SIRQ pins. S500, S700 and S900 provides 3 SIRQ lines and works independently for 3 external interrupt controllers. Signed-off-by: Parthiban Nallathambi Signed-off-by: Saravanan Sekar --- .../interrupt-controller/actions,owl-sirq.txt | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/actions,owl-sirq.txt diff --git a/Documentation/devicetree/bindings/interrupt-controller/actions,owl-sirq.txt b/Documentation/devicetree/bindings/interrupt-controller/actions,owl-sirq.txt new file mode 100644 index 000000000000..4b8437751331 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/actions,owl-sirq.txt @@ -0,0 +1,46 @@ +Actions Semi Owl SoCs SIRQ interrupt controller + +S500, S700 and S900 SoC's from Actions provides 3 SPI's from GIC, +in which external interrupt controller can be connected. 3 SPI's +45, 46, 47 from GIC are directly exposed as SIRQ. It has +the following properties: + +- inputs three interrupt signal from external interrupt controller + +Required properties: + +- compatible: should be "actions,owl-sirq" +- reg: physical base address of the controller and length of memory mapped. +- interrupt-controller: identifies the node as an interrupt controller +- #interrupt-cells: specifies the number of cells needed to encode an interrupt + source, should be 2. +- actions,sirq-shared-reg: Applicable for S500 and S700 where SIRQ register + details are maintained at same offset/register. +- actions,sirq-offset: register offset for SIRQ interrupts. When registers are + shared, all the three offsets will be same (S500 and S700). +- actions,sirq-clk-sel: external interrupt controller can be either + connected to 32Khz or 24Mhz external/internal clock. This needs + to be configured for per SIRQ line. Failing defaults to 32Khz clock. + +Example for S900: + +sirq: interrupt-controller@e01b0000 { + compatible = "actions,owl-sirq"; + reg = <0 0xe01b0000 0 0x1000>; + interrupt-controller; + #interrupt-cells = <2>; + actions,sirq-clk-sel = <0 0 0>; + actions,sirq-offset = <0x200 0x528 0x52c>; +}; + +Example for S500 and S700: + +sirq: interrupt-controller@e01b0000 { + compatible = "actions,owl-sirq"; + reg = <0 0xe01b0000 0 0x1000>; + interrupt-controller; + #interrupt-cells = <2>; + actions,sirq-shared-reg; + actions,sirq-clk-sel = <0 0 0>; + actions,sirq-offset = <0x200 0x200 0x200>; +}; From patchwork Sun Aug 12 12:22:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parthiban Nallathambi X-Patchwork-Id: 10563641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D0BE1515 for ; Sun, 12 Aug 2018 12:31:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EBA329665 for ; Sun, 12 Aug 2018 12:31:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 004DF29768; Sun, 12 Aug 2018 12:31:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FDF129665 for ; Sun, 12 Aug 2018 12:31:56 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=UQj0oEzx16IOPvZLoQtk+xyN2bItNEDS/B7Gk8H1/vw=; b=oPj7vT8ihw/kM7kdCOrLjsdDMC AMbt9A+r69lYSIg2bWX1cbf/NTynbl+fNMOjSSwZL/IAj8YuH/i695pVtyIffPLv5/4q7TSN/KMet Z4BmY8OJEzZFmJLy2WmIA2FLMW+ki36NM5buPxEHAhf7xl9MuVhaInbY9/x8MgYy4AFiJSrK5HJaf TlO/XCliiYDXjxFoFY4oLhVkdLU4PxytS2QADMVTCM2aDkbz8uSddPbkEePZ14jSdwyFLQsked1IG 5TP4IIHz2w7YgMk+lgDR+u4CaopTz0vvqxmUyIpj5skvUuFDssXhDIuRiHe7nxN4cd1+D2Mn6YI88 JYosZklw==; 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 1fopWz-0004J2-3u; Sun, 12 Aug 2018 12:31:37 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fopWt-0004If-NO for linux-arm-kernel@bombadil.infradead.org; Sun, 12 Aug 2018 12:31:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4/J8lirOBsMoWjWyK9qKerqyKU6VsEkt0PovG2mnLmk=; b=RGAceWA6Tye2ueWAYE0QfeVyB hN5IsM0X/UCMHsWnt/UA8tDdGRi0epsQ90YRL/QY106TxE1vkJVbl5LXWQN3Uxw+S143D3SudCuGJ G1VsIFq7IsicG78zQJXxNSLdhDRDTYhP2zEEipzpQe/sRpMAB3Cn8b3bI+BQB6QHyIgRPS8qsz9w2 QJRe5bBA+3fQQm7lFXbwUMMrS/WHW4lLmfNbjKLSPUhCgHZ0Zx2q9C66PqCfott/oxNJor5Mf2dip fV1FhV7KR6uDI4Ldot6JdYLa8S4FNlRvlxE9r0ke/jpCE9CPU3g8AmuiRu/esztSW3wxgvwW6FF/5 pSPTIuoQg==; Received: from mail-out.m-online.net ([212.18.0.9]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fopWl-00037M-0z for linux-arm-kernel@lists.infradead.org; Sun, 12 Aug 2018 12:31:25 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 41pJ0N1cxzz1qwCt; Sun, 12 Aug 2018 14:22:40 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 41pJ0J4yRRz1qqlF; Sun, 12 Aug 2018 14:22:40 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id ca5mxRb0KNYR; Sun, 12 Aug 2018 14:22:38 +0200 (CEST) X-Auth-Info: APiCeDnHo1PokcrHtITTskpO8eoNsfGnrhYTCxpNQCw= Received: from xpert.denx.de (unknown [62.91.23.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 12 Aug 2018 14:22:38 +0200 (CEST) From: Parthiban Nallathambi To: tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, mark.rutland@arm.com, afaerber@suse.de, catalin.marinas@arm.com, will.deacon@arm.com, manivannan.sadhasivam@linaro.org Subject: [PATCH v2 2/3] drivers/irqchip: Add Actions external interrupts support Date: Sun, 12 Aug 2018 14:22:14 +0200 Message-Id: <20180812122215.1079590-3-pn@denx.de> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180812122215.1079590-1-pn@denx.de> References: <20180812122215.1079590-1-pn@denx.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180812_133123_111554_E154CF9D X-CRM114-Status: GOOD ( 27.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux@cubietech.com, sravanhome@gmail.com, guilherme.simoes@lsitec.org.br, laisa.costa@lsitec.org.br, mkzuffo@lsi.usp.br, linux-kernel@vger.kernel.org, thomas.liau@actions-semi.com, mp-cs@actions-semi.com, Parthiban Nallathambi , edgar.righi@lsitec.org.br, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Actions Semi Owl family SoC's S500, S700 and S900 provides support for 3 external interrupt controllers through SIRQ pins. Each line can be independently configured as interrupt and triggers on either of the edges (raising or falling) or either of the levels (high or low) . Each line can also be masked independently. Signed-off-by: Parthiban Nallathambi Signed-off-by: Saravanan Sekar --- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-owl-sirq.c | 305 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 306 insertions(+) create mode 100644 drivers/irqchip/irq-owl-sirq.c diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 15f268f646bf..072c4409e7c4 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_ATH79) += irq-ath79-misc.o obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2836.o obj-$(CONFIG_ARCH_EXYNOS) += exynos-combiner.o +obj-$(CONFIG_ARCH_ACTIONS) += irq-owl-sirq.o obj-$(CONFIG_FARADAY_FTINTC010) += irq-ftintc010.o obj-$(CONFIG_ARCH_HIP04) += irq-hip04.o obj-$(CONFIG_ARCH_LPC32XX) += irq-lpc32xx.o diff --git a/drivers/irqchip/irq-owl-sirq.c b/drivers/irqchip/irq-owl-sirq.c new file mode 100644 index 000000000000..b69301388300 --- /dev/null +++ b/drivers/irqchip/irq-owl-sirq.c @@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * + * Actions Semi Owl SoCs SIRQ interrupt controller driver + * + * Copyright (C) 2014 Actions Semi Inc. + * David Liu + * + * Author: Parthiban Nallathambi + * Author: Saravanan Sekar + */ + +#include +#include +#include +#include + +#include + +#define INTC_GIC_INTERRUPT_PIN 13 +#define INTC_EXTCTL_PENDING BIT(0) +#define INTC_EXTCTL_CLK_SEL BIT(4) +#define INTC_EXTCTL_EN BIT(5) +#define INTC_EXTCTL_TYPE_MASK GENMASK(6, 7) +#define INTC_EXTCTL_TYPE_HIGH 0 +#define INTC_EXTCTL_TYPE_LOW BIT(6) +#define INTC_EXTCTL_TYPE_RISING BIT(7) +#define INTC_EXTCTL_TYPE_FALLING (BIT(6) | BIT(7)) + +#define get_sirq_offset(x) chip_data->sirq[x].offset + +/* Per SIRQ data */ +struct owl_sirq { + u16 offset; + /* software is responsible to clear interrupt pending bit when + * type is edge triggered. This value is for per SIRQ line. + */ + bool type_edge; +}; + +struct owl_sirq_chip_data { + void __iomem *base; + raw_spinlock_t lock; + /* some SoC's share the register for all SIRQ lines, so maintain + * register is shared or not here. This value is from DT. + */ + bool shared_reg; + struct owl_sirq *sirq; +}; + +static struct owl_sirq_chip_data *sirq_data; + +static unsigned int sirq_read_extctl(struct irq_data *data) +{ + struct owl_sirq_chip_data *chip_data = data->chip_data; + unsigned int val; + + val = readl_relaxed(chip_data->base + get_sirq_offset(data->hwirq)); + if (chip_data->shared_reg) + val = (val >> (2 - data->hwirq) * 8) & 0xff; + + return val; +} + +static void sirq_write_extctl(struct irq_data *data, unsigned int extctl) +{ + struct owl_sirq_chip_data *chip_data = data->chip_data; + unsigned int val; + + if (chip_data->shared_reg) { + val = readl_relaxed(chip_data->base + + get_sirq_offset(data->hwirq)); + val &= ~(0xff << (2 - data->hwirq) * 8); + extctl &= 0xff; + extctl = (extctl << (2 - data->hwirq) * 8) | val; + } + + writel_relaxed(extctl, chip_data->base + + get_sirq_offset(data->hwirq)); +} + +static void owl_sirq_ack(struct irq_data *data) +{ + struct owl_sirq_chip_data *chip_data = data->chip_data; + unsigned int extctl; + unsigned long flags; + + /* software must clear external interrupt pending, when interrupt type + * is edge triggered, so we need per SIRQ based clearing. + */ + if (chip_data->sirq[data->hwirq].type_edge) { + raw_spin_lock_irqsave(&chip_data->lock, flags); + + extctl = sirq_read_extctl(data); + extctl |= INTC_EXTCTL_PENDING; + sirq_write_extctl(data, extctl); + + raw_spin_unlock_irqrestore(&chip_data->lock, flags); + } + irq_chip_ack_parent(data); +} + +static void owl_sirq_mask(struct irq_data *data) +{ + struct owl_sirq_chip_data *chip_data = data->chip_data; + unsigned int extctl; + unsigned long flags; + + raw_spin_lock_irqsave(&chip_data->lock, flags); + + extctl = sirq_read_extctl(data); + extctl &= ~(INTC_EXTCTL_EN); + sirq_write_extctl(data, extctl); + + raw_spin_unlock_irqrestore(&chip_data->lock, flags); + irq_chip_mask_parent(data); +} + +static void owl_sirq_unmask(struct irq_data *data) +{ + struct owl_sirq_chip_data *chip_data = data->chip_data; + unsigned int extctl; + unsigned long flags; + + raw_spin_lock_irqsave(&chip_data->lock, flags); + + extctl = sirq_read_extctl(data); + extctl |= INTC_EXTCTL_EN; + sirq_write_extctl(data, extctl); + + raw_spin_unlock_irqrestore(&chip_data->lock, flags); + irq_chip_unmask_parent(data); +} + +/* PAD_PULLCTL needs to be defined in pinctrl */ +static int owl_sirq_set_type(struct irq_data *data, unsigned int flow_type) +{ + struct owl_sirq_chip_data *chip_data = data->chip_data; + unsigned int extctl, type; + unsigned long flags; + + switch (flow_type) { + case IRQF_TRIGGER_LOW: + type = INTC_EXTCTL_TYPE_LOW; + break; + case IRQF_TRIGGER_HIGH: + type = INTC_EXTCTL_TYPE_HIGH; + break; + case IRQF_TRIGGER_FALLING: + type = INTC_EXTCTL_TYPE_FALLING; + chip_data->sirq[data->hwirq].type_edge = true; + break; + case IRQF_TRIGGER_RISING: + type = INTC_EXTCTL_TYPE_RISING; + chip_data->sirq[data->hwirq].type_edge = true; + break; + default: + return -EINVAL; + } + + raw_spin_lock_irqsave(&chip_data->lock, flags); + + extctl = sirq_read_extctl(data); + extctl &= ~INTC_EXTCTL_TYPE_MASK; + extctl |= type; + sirq_write_extctl(data, extctl); + + raw_spin_unlock_irqrestore(&chip_data->lock, flags); + data = data->parent_data; + return irq_chip_set_type_parent(data, flow_type); +} + +static struct irq_chip owl_sirq_chip = { + .name = "owl-sirq", + .irq_ack = owl_sirq_ack, + .irq_mask = owl_sirq_mask, + .irq_unmask = owl_sirq_unmask, + .irq_set_type = owl_sirq_set_type, + .irq_eoi = irq_chip_eoi_parent, + .irq_retrigger = irq_chip_retrigger_hierarchy, +}; + +static int owl_sirq_domain_alloc(struct irq_domain *domain, unsigned int virq, + unsigned int nr_irqs, void *arg) +{ + struct irq_fwspec *fwspec = arg; + struct irq_fwspec parent_fwspec = { + .param_count = 3, + .param[0] = GIC_SPI, + .param[1] = fwspec->param[0] + INTC_GIC_INTERRUPT_PIN, + .param[2] = fwspec->param[1], + .fwnode = domain->parent->fwnode, + }; + + if (WARN_ON(nr_irqs != 1)) + return -EINVAL; + + irq_domain_set_hwirq_and_chip(domain, virq, fwspec->param[0], + &owl_sirq_chip, + domain->host_data); + + return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, + &parent_fwspec); +} + +static const struct irq_domain_ops sirq_domain_ops = { + .alloc = owl_sirq_domain_alloc, + .free = irq_domain_free_irqs_common, +}; + +static void owl_sirq_clk_init(int offset, int hwirq) +{ + unsigned int val; + + /* register default clock is 32Khz, change to 24Mhz only when defined */ + val = readl_relaxed(sirq_data->base + offset); + if (sirq_data->shared_reg) + val |= INTC_EXTCTL_CLK_SEL << (2 - hwirq) * 8; + else + val |= INTC_EXTCTL_CLK_SEL; + + writel_relaxed(val, sirq_data->base + offset); +} + +static int __init owl_sirq_of_init(struct device_node *node, + struct device_node *parent) +{ + struct irq_domain *domain, *domain_parent; + int ret = 0, i, sirq_cnt = 0; + struct owl_sirq_chip_data *chip_data; + + sirq_cnt = of_property_count_u32_elems(node, "actions,sirq-offset"); + if (sirq_cnt <= 0) { + pr_err("owl_sirq: register offset not specified\n"); + return -EINVAL; + } + + chip_data = kzalloc(sizeof(*chip_data), GFP_KERNEL); + if (!chip_data) + return -ENOMEM; + sirq_data = chip_data; + + chip_data->sirq = kcalloc(sirq_cnt, sizeof(*chip_data->sirq), + GFP_KERNEL); + if (!chip_data->sirq) + goto out_free; + + raw_spin_lock_init(&chip_data->lock); + chip_data->base = of_iomap(node, 0); + if (!chip_data->base) { + pr_err("owl_sirq: unable to map sirq register\n"); + ret = -ENXIO; + goto out_free; + } + + chip_data->shared_reg = of_property_read_bool(node, + "actions,sirq-shared-reg"); + for (i = 0; i < sirq_cnt; i++) { + u32 value; + + ret = of_property_read_u32_index(node, "actions,sirq-offset", + i, &value); + if (ret) + goto out_unmap; + + get_sirq_offset(i) = (u16)value; + + ret = of_property_read_u32_index(node, "actions,sirq-clk-sel", + i, &value); + if (ret || !value) + continue; + + /* external interrupt controller can be either connect to 32Khz/ + * 24Mhz external/internal clock. This shall be configured for + * per SIRQ line. It can be defined from DT, failing defaults to + * 24Mhz clock. + */ + owl_sirq_clk_init(get_sirq_offset(i), i); + } + + domain_parent = irq_find_host(parent); + if (!domain_parent) { + pr_err("owl_sirq: interrupt-parent not found\n"); + goto out_unmap; + } + + domain = irq_domain_add_hierarchy(domain_parent, 0, + sirq_cnt, node, + &sirq_domain_ops, chip_data); + if (!domain) { + ret = -ENOMEM; + goto out_unmap; + } + + return 0; + +out_unmap: + iounmap(chip_data->base); +out_free: + kfree(chip_data); + kfree(chip_data->sirq); + return ret; +} + +IRQCHIP_DECLARE(owl_sirq, "actions,owl-sirq", owl_sirq_of_init); From patchwork Sun Aug 12 12:22:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parthiban Nallathambi X-Patchwork-Id: 10563643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CDA41510 for ; Sun, 12 Aug 2018 12:33:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0136D29766 for ; Sun, 12 Aug 2018 12:33:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E761B2976F; Sun, 12 Aug 2018 12:33:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8EB2D29766 for ; Sun, 12 Aug 2018 12:33:57 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=vLVdSljb/ihhcv6XqPI8fO/AGBPzQhAAH8npZuj/Je8=; b=mHiHadUjmxiOwZyvNbP/FiWX+I UFPaUFrlcuPcqOUPjqurJovi2ne14SGjWjsCzsK1gu4dse0TOT3gChN8pyoZfkWIaTmkalTw2Mupd hZR31eUajBzaHqW1glJoh4Pp/HfUJ0fkM8pHm1YQoSDcCONt/5aUCpxRKSJwqFDF6INirieubQu28 A8018BrTz6jusnwcO+jtfq9Pv/loondm8vQ5lEuuODyiTKeyleV5rTKPJRWpWLLrleDckg9fDNaSJ dKXHgk3w6zr03fRKkvWYWNABpzkgawgL9mW2lNfHL7YQuH3FmveyuE8lchE8Q39qDWHzlrwVCzYby Xz2uEL0A==; 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 1fopZ3-0004q7-6x; Sun, 12 Aug 2018 12:33:45 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fopZ0-0004mn-P8 for linux-arm-kernel@bombadil.infradead.org; Sun, 12 Aug 2018 12:33:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FF3BV8uqbgL2xturmdXLjLL9CVNBlzyYgVOUQzjyLcM=; b=Bc/rcL8+metoTrRp70nRhT43A TWwHvqkEDyDLvq2RP8uPTfKBBvAHjoCtzwg8umbh5cNL0X1ldnCgULquYKF4OOo3MLQ2fmQCAut8+ SDyphPea3tN3HmDYeCMGZQ57EFjOXyg0bgbuN+UbZD/mz6cqecjYbkjJupuJg+RAW1vuUTIpcVZVT I5lx7cUsaxzKd8RFkjKbCaAkzyc6LiP6KBeWnDMwQB0q9/uCQMH7y0qrjVk7Lq/usfz7xcsVZY0Qn 1BHv/vuwkFmTCj2JrAprYDtjIcLJm/PZDh0aCQ71aF0vf+CCE58YWGOEwIOhk5iXAOxGJdVTq0fwZ 2GdKwTOZw==; Received: from mail-out.m-online.net ([212.18.0.9]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fopWq-0000Qk-0D for linux-arm-kernel@lists.infradead.org; Sun, 12 Aug 2018 12:31:30 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 41pJ0L6zDrz1qwC5; Sun, 12 Aug 2018 14:22:42 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 41pJ0L3XRyz1qr24; Sun, 12 Aug 2018 14:22:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id UaYCNZfe90Qc; Sun, 12 Aug 2018 14:22:41 +0200 (CEST) X-Auth-Info: W0vHxIPplSaFnB/7ok72Adr2U9SgutzwME46cA0fuuc= Received: from xpert.denx.de (unknown [62.91.23.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 12 Aug 2018 14:22:40 +0200 (CEST) From: Parthiban Nallathambi To: tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, mark.rutland@arm.com, afaerber@suse.de, catalin.marinas@arm.com, will.deacon@arm.com, manivannan.sadhasivam@linaro.org Subject: [PATCH v2 3/3] arm64: dts: actions: Add sirq node for Actions Semi S700 Date: Sun, 12 Aug 2018 14:22:15 +0200 Message-Id: <20180812122215.1079590-4-pn@denx.de> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180812122215.1079590-1-pn@denx.de> References: <20180812122215.1079590-1-pn@denx.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180812_083128_190624_C3E06BAC X-CRM114-Status: UNSURE ( 9.46 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux@cubietech.com, sravanhome@gmail.com, guilherme.simoes@lsitec.org.br, laisa.costa@lsitec.org.br, mkzuffo@lsi.usp.br, linux-kernel@vger.kernel.org, thomas.liau@actions-semi.com, mp-cs@actions-semi.com, Parthiban Nallathambi , edgar.righi@lsitec.org.br, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add sirq node for Actions Semi S700 SoC with 3 SIRQ pins support, in which external interrupt controllers can be connected. Example: atc260x: atc2603c@65 { interrupt-parent = <&sirq>; interrupts = <2 IRQ_TYPE_LEVEL_HIGH>; }; Signed-off-by: Parthiban Nallathambi Signed-off-by: Saravanan Sekar --- arch/arm64/boot/dts/actions/s700.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/boot/dts/actions/s700.dtsi b/arch/arm64/boot/dts/actions/s700.dtsi index 66dd5309f0a2..c5aef5ac7f46 100644 --- a/arch/arm64/boot/dts/actions/s700.dtsi +++ b/arch/arm64/boot/dts/actions/s700.dtsi @@ -153,6 +153,15 @@ status = "disabled"; }; + sirq: interrupt-controller@e01b0000 { + compatible = "actions,owl-sirq"; + reg = <0 0xe01b0000 0 0x1000>; + interrupt-controller; + #interrupt-cells = <2>; + actions,sirq-shared-reg; + actions,sirq-offset = <0x200 0x200 0x200>; + }; + sps: power-controller@e01b0100 { compatible = "actions,s700-sps"; reg = <0x0 0xe01b0100 0x0 0x100>;