From patchwork Wed Aug 5 11:00:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Palmer X-Patchwork-Id: 11701749 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD486138A for ; Wed, 5 Aug 2020 11:01:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A902722CAD for ; Wed, 5 Aug 2020 11:01:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZCFXiiBb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=0x0f.com header.i=@0x0f.com header.b="EQulCbJg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A902722CAD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=0x0f.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=yNMaTc717FqYmdPUz6U17+RVwCH36cM8LNvH2+NhXsI=; b=ZCFXiiBbKV5HjzVYFw9CAFP7H mf1DgtYUuGaAqH2HYsMV81EkvZ/njln55d+JtDC1qI+1n9+CuQNS6eTgKjAWDerAOIP26nJlTAWGg csiY0qL3yl8bHruTtfoTLyuCV+YE8vtPp9i/JHIiO8gDZAHuZR8xNc6b9IrKmTMWZk9C7DzyDVsXS zBXgD6lhFpWqytgro+86qybm1D64BawhMG6oCn8GW7vk1gC4c58k71gWJ5HTnXy/E8JTHZNzFeHlG iic6MqONhmAP28JySPsRaEkOQVIy2LRc/uU2+QtbTkO+Jfia8fM8eeWWdbG4XgkkzatafJ99Ha/Ff DLnc5sKWw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3HAp-0004BA-IK; Wed, 05 Aug 2020 11:01:31 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3HAl-00049s-J6 for linux-arm-kernel@lists.infradead.org; Wed, 05 Aug 2020 11:01:29 +0000 Received: by mail-pl1-x62f.google.com with SMTP id f10so108106plj.8 for ; Wed, 05 Aug 2020 04:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0x0f.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bEXE45LcqvqPQXnOIHLz5P7xwCTBDkRs/TdXM1m+mFI=; b=EQulCbJgChPEOrrWhj0Yj6pCh0S3mTWPli5hIxKes2rVZ/rB3VbS0zWELm0qovgRox 3RNcvKc/Ka4EV3Yu+AQsAw0wmqdiDoxPx8/cNg5caL+P1l0ZU1xGoZxU+SflhuXk8+sb 7TBVPNm86jPhCITaDJk8n2ts8Dzg5iWCDocwQ= 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=bEXE45LcqvqPQXnOIHLz5P7xwCTBDkRs/TdXM1m+mFI=; b=p4Ciu/Q1dK1exX8wsyMTmyh8Ts8tPM0huZcnfuFA3BWq8K6SgBotm5GY1IU4Riotyk g/GWRGRqTL9QuzMcVE0V5mfz1EQ2gJIpXWwBMmVIRmyE+yjgoPpMJXC3aO/hPcZBPdbg lpJbRU4w5Uldcnz4pvd456N1XH60RDbyq1z3ysuzhIkMJ1JmDNJUF/PEucAkKfFsk5op S0fcUhQ52PVYEZ8N/IWYa1kwhDecO1yn+oenp0C63qxIsyMdFkXyxh9yhQamtngXX5VG ULtLkWc3nT9Csut7mOtqTXECT7kzqrDx9gtWJMVhYLxEuf4E8sW85EJRRWh8drF3evA2 Np1A== X-Gm-Message-State: AOAM5309nf9lvT6Ffe/DXXCsmNABISHLWYDWE7/pVmw98b2RCl+20fw9 hdCAQPb4Fdvvf6A8+HSdA6czL5dXI2Q= X-Google-Smtp-Source: ABdhPJyvJqUXzc7a83FfWTPCOuRjbh298XT8zPB8FEb7iiv/46NZBBTcpzUImBIfusw1aOQW/aMxLw== X-Received: by 2002:a17:902:ed13:: with SMTP id b19mr2520446pld.24.1596625284813; Wed, 05 Aug 2020 04:01:24 -0700 (PDT) Received: from shiro.work (p532183-ipngn200506sizuokaden.shizuoka.ocn.ne.jp. [153.199.2.183]) by smtp.googlemail.com with ESMTPSA id fv21sm2583142pjb.16.2020.08.05.04.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 04:01:24 -0700 (PDT) From: Daniel Palmer To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] dt: bindings: interrupt-controller: Add binding description for msc313-intc Date: Wed, 5 Aug 2020 20:00:50 +0900 Message-Id: <20200805110052.2655487-2-daniel@0x0f.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200805110052.2655487-1-daniel@0x0f.com> References: <20200805110052.2655487-1-daniel@0x0f.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200805_070127_665987_FB015FF2 X-CRM114-Status: GOOD ( 17.10 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:62f listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -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 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, jason@lakedaemon.net, arnd@arndb.de, maz@kernel.org, Daniel Palmer , linux-kernel@vger.kernel.org, robh+dt@kernel.org, tglx@linutronix.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Adds a YAML description of the binding for the msc313-intc. Signed-off-by: Daniel Palmer --- .../mstar,msc313-intc.yaml | 79 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/mstar,msc313-intc.yaml diff --git a/Documentation/devicetree/bindings/interrupt-controller/mstar,msc313-intc.yaml b/Documentation/devicetree/bindings/interrupt-controller/mstar,msc313-intc.yaml new file mode 100644 index 000000000000..e256887aa847 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/mstar,msc313-intc.yaml @@ -0,0 +1,79 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2020 thingy.jp. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/interrupt-controller/mstar,msc313-intc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: MStar/SigmaStar ARMv7 SoC Interrupt Controller Device Tree Bindings + +maintainers: + - Daniel Palmer + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + +properties: + "#interrupt-cells": + const: 2 + + compatible: + enum: + - mstar,msc313-intc-irq + - mstar,msc313-intc-fiq + + reg: + maxItems: 1 + + interrupt-controller: true + + mstar,gic-offset: + description: + Offset added to the intc irq number to get the parent GIC irq. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - minimum: 0 + maximum: 255 + + mstar,nr-interrupts: + description: + Number of interrupt lines this intc has. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - minimum: 1 + maximum: 64 + +required: + - "#interrupt-cells" + - compatible + - reg + - interrupt-controller + - mstar,gic-offset + - mstar,nr-interrupts + +additionalProperties: false + +examples: + - | + intc_fiq: intc@201310 { + compatible = "mstar,msc313-intc-fiq"; + interrupt-controller; + reg = <0x201310 0x40>; + #interrupt-cells = <2>; + interrupt-parent = <&gic>; + mstar,gic-offset = <96>; + mstar,nr-interrupts = <32>; + }; + + - | + intc_irq: intc@201350 { + compatible = "mstar,msc313-intc-irq"; + interrupt-controller; + reg = <0x201350 0x40>; + #interrupt-cells = <2>; + interrupt-parent = <&gic>; + mstar,gic-offset = <32>; + mstar,nr-interrupts = <64>; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index c8e8232c65da..6e64d17aad7b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2152,6 +2152,7 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained W: http://linux-chenxing.org/ F: Documentation/devicetree/bindings/arm/mstar/* +F: Documentation/devicetree/bindings/interrupt-controller/mstar,msc313-intc.yaml F: arch/arm/boot/dts/infinity*.dtsi F: arch/arm/boot/dts/mercury*.dtsi F: arch/arm/boot/dts/mstar-v7.dtsi From patchwork Wed Aug 5 11:00:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Palmer X-Patchwork-Id: 11701751 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BE321392 for ; Wed, 5 Aug 2020 11:01:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37E2B22CAD for ; Wed, 5 Aug 2020 11:01:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AnEp+UJT"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=0x0f.com header.i=@0x0f.com header.b="AgEIBPo7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37E2B22CAD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=0x0f.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=cidpxc746nE3AUv6NLn5IqVnT7X7DS3Nd2Acm6rpQSw=; b=AnEp+UJT7gJuThAHHOrJ0iC0K 1F+NnSXjXA4s077t8vt5Hv74h/vfid11xLcuoWwHzM5CKGemS2s4brTK5L2wLtIvjSKc6Yja1Arm4 nDoAOnRH5jj4s14nheXm3jzDiyqXKBGfIZZcRb6QusuZnMRIEsBMvEdJp0iP057Z5o4qOx+ajRcMZ Jj2dgaKQZeSZ66P80c6gN1qO5SLV5QD3YTm2QNOXmKCKTXwI4twWuCDuNb2aSnAOc3A6uBDgZ003c i9Qb9Lu0XashMXpafDn6CWA68PXZq1dCdxAY/SQNfB6omOKQ9IPdVlY78OayxIhyJVQNq7Q/wXVbr LKOvgnk1w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3HAs-0004C4-Bf; Wed, 05 Aug 2020 11:01:34 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3HAp-0004Ar-6G for linux-arm-kernel@lists.infradead.org; Wed, 05 Aug 2020 11:01:32 +0000 Received: by mail-pf1-x441.google.com with SMTP id 17so2130725pfw.9 for ; Wed, 05 Aug 2020 04:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0x0f.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R4fpWOqpBFl4YW+gjIGDtcJmKMkUJgphCM8cmn4jPi0=; b=AgEIBPo7jkQpOlkHlqljgV9zaXxH9CVK+sp71nP3S85oCgjoPbBIX9hEGrvRfF8S2S wlH9yDchUSJ6psQ2YzxDgSpauTHLTHImjH5yH8kKL6CeUv99FqEdaqknCPh1sARYsZBK YhPW3G2PXL8mkDbHfkm5wZ4IsdFbbDarKqxPQ= 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=R4fpWOqpBFl4YW+gjIGDtcJmKMkUJgphCM8cmn4jPi0=; b=L/F5IUHkqBHjy1eU1pKDPbO/OmcZhG3E7RvfZwAh0RSendXqXz2NDzDSQ93VU2NZu7 cR4s9BtHRZjCJMKetm5bqb8v/Ihbn+/TfUS8ZkW3DpHnztkyoo4u2yAifml2dsj+JZ07 5RKYVOuGCXe40yrGDhXcLukF5CjIsHbGN0O7e2esCHns8vbyRKLAMP0qdyNxSsJikb3d 2cWz1glfUO2/3wddwgDPP/SqUYT7Jq5ysmqIttPoAeZs7Z3fRoZi2src74mWqfjRxZkf QPYknAR4fHZc6oOVQsG7A0xcgpktgczrILRYeVx7XOTEjTNtU347hqYPFHIWY08+wvVp 77+A== X-Gm-Message-State: AOAM531Xrjss1AHya+HwLh5wCgGtAC9RRLOi4HLFSPLwG1PJqhOA57qJ NjBsyIHSTaT11IQo3eJxlmsMtYI8ut1u8A== X-Google-Smtp-Source: ABdhPJySE9UZPCujh2vALZVNOpXJZnYkWwGKM0HQFCvSc2ybGU3FBflfuw+pnV1AAWlHtgeBiS3E6Q== X-Received: by 2002:aa7:8eca:: with SMTP id b10mr1046302pfr.50.1596625288482; Wed, 05 Aug 2020 04:01:28 -0700 (PDT) Received: from shiro.work (p532183-ipngn200506sizuokaden.shizuoka.ocn.ne.jp. [153.199.2.183]) by smtp.googlemail.com with ESMTPSA id fv21sm2583142pjb.16.2020.08.05.04.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 04:01:27 -0700 (PDT) From: Daniel Palmer To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] irqchip: mstar: msc313-intc interrupt controller driver Date: Wed, 5 Aug 2020 20:00:51 +0900 Message-Id: <20200805110052.2655487-3-daniel@0x0f.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200805110052.2655487-1-daniel@0x0f.com> References: <20200805110052.2655487-1-daniel@0x0f.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200805_070131_296474_3456BD7C X-CRM114-Status: GOOD ( 23.18 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -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 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, jason@lakedaemon.net, arnd@arndb.de, maz@kernel.org, Daniel Palmer , linux-kernel@vger.kernel.org, robh+dt@kernel.org, tglx@linutronix.de, Willy Tarreau Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add a driver for the two peripheral interrupt controllers in MStar MSC313 and other MStar/Sigmastar Armv7 SoCs. Supports both the "IRQ" and "FIQ" controllers that forward interrupts from the various IP blocks inside the SoC to the ARM GIC. They are basically the same thing except for one difference: The FIQ controller needs to clear the interrupt and the IRQ controller doesn't. Signed-off-by: Daniel Palmer Tested-by: Willy Tarreau --- MAINTAINERS | 1 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-msc313-intc.c | 210 ++++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 drivers/irqchip/irq-msc313-intc.c diff --git a/MAINTAINERS b/MAINTAINERS index 6e64d17aad7b..4d07403a7726 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2157,6 +2157,7 @@ F: arch/arm/boot/dts/infinity*.dtsi F: arch/arm/boot/dts/mercury*.dtsi F: arch/arm/boot/dts/mstar-v7.dtsi F: arch/arm/mach-mstar/ +F: drivers/irqchip/irq-msc313-intc.c ARM/NEC MOBILEPRO 900/c MACHINE SUPPORT M: Michael Petchkovsky diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 133f9c45744a..67f3ae3507b8 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -111,3 +111,4 @@ obj-$(CONFIG_LOONGSON_HTPIC) += irq-loongson-htpic.o obj-$(CONFIG_LOONGSON_HTVEC) += irq-loongson-htvec.o obj-$(CONFIG_LOONGSON_PCH_PIC) += irq-loongson-pch-pic.o obj-$(CONFIG_LOONGSON_PCH_MSI) += irq-loongson-pch-msi.o +obj-$(CONFIG_ARCH_MSTARV7) += irq-msc313-intc.o diff --git a/drivers/irqchip/irq-msc313-intc.c b/drivers/irqchip/irq-msc313-intc.c new file mode 100644 index 000000000000..b50f5c858d38 --- /dev/null +++ b/drivers/irqchip/irq-msc313-intc.c @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 Daniel Palmer + */ + +#include +#include +#include +#include +#include +#include + +#define REGOFF_MASK 0x0 +#define REGOFF_POLARITY 0x10 +#define REGOFF_STATUSCLEAR 0x20 +#define IRQSPERREG 16 +#define IRQBIT(hwirq) BIT((hwirq % IRQSPERREG)) +#define REGOFF(hwirq) ((hwirq >> 4) * 4) + +struct msc313_intc { + struct irq_domain *domain; + void __iomem *base; + struct irq_chip irqchip; + u8 gicoff; +}; + +static void msc313_intc_maskunmask(struct msc313_intc *intc, int hwirq, bool mask) +{ + int regoff = REGOFF(hwirq); + void __iomem *addr = intc->base + REGOFF_MASK + regoff; + u16 bit = IRQBIT(hwirq); + u16 reg = readw_relaxed(addr); + + if (mask) + reg |= bit; + else + reg &= ~bit; + + writew_relaxed(reg, addr); +} + +static void msc313_intc_mask_irq(struct irq_data *data) +{ + struct msc313_intc *intc = data->chip_data; + + msc313_intc_maskunmask(intc, data->hwirq, true); + irq_chip_mask_parent(data); +} + +static void msc313_intc_unmask_irq(struct irq_data *data) +{ + struct msc313_intc *intc = data->chip_data; + + msc313_intc_maskunmask(intc, data->hwirq, false); + irq_chip_unmask_parent(data); +} + +static int msc313_intc_set_type_irq(struct irq_data *data, unsigned int flow_type) +{ + struct msc313_intc *intc = data->chip_data; + int irq = data->hwirq; + int regoff = REGOFF(irq); + void __iomem *addr = intc->base + REGOFF_POLARITY + regoff; + u16 bit = IRQBIT(irq); + u16 reg = readw_relaxed(addr); + + if (flow_type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_HIGH)) + reg &= ~bit; + else + reg |= bit; + + writew_relaxed(reg, addr); + return 0; +} + +static void msc313_intc_irq_eoi(struct irq_data *data) +{ + struct msc313_intc *intc = data->chip_data; + int irq = data->hwirq; + int regoff = REGOFF(irq); + void __iomem *addr = intc->base + REGOFF_STATUSCLEAR + regoff; + u16 bit = IRQBIT(irq); + u16 reg = readw_relaxed(addr); + + reg |= bit; + writew_relaxed(reg, addr); + irq_chip_eoi_parent(data); +} + +static int msc313_intc_domain_translate(struct irq_domain *d, + struct irq_fwspec *fwspec, + unsigned long *hwirq, + unsigned int *type) +{ + if (!is_of_node(fwspec->fwnode) || fwspec->param_count != 2) + return -EINVAL; + + *hwirq = fwspec->param[0]; + *type = fwspec->param[1]; + + return 0; +} + +static int msc313_intc_domain_alloc(struct irq_domain *domain, unsigned int virq, + unsigned int nr_irqs, void *data) +{ + struct irq_fwspec *fwspec = data; + struct irq_fwspec parent_fwspec; + struct msc313_intc *intc = domain->host_data; + + if (fwspec->param_count != 2) + return -EINVAL; + + irq_domain_set_hwirq_and_chip(domain, virq, fwspec->param[0], &intc->irqchip, intc); + + parent_fwspec.fwnode = domain->parent->fwnode; + parent_fwspec.param[0] = GIC_SPI; + parent_fwspec.param[1] = fwspec->param[0] + intc->gicoff; + parent_fwspec.param[2] = fwspec->param[1]; + parent_fwspec.param_count = 3; + + return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, + &parent_fwspec); +} + +static const struct irq_domain_ops msc313_intc_domain_ops = { + .translate = msc313_intc_domain_translate, + .alloc = msc313_intc_domain_alloc, + .free = irq_domain_free_irqs_common, +}; + +static int msc313_intc_of_init(struct device_node *node, + struct device_node *parent, + void (*eoi)(struct irq_data *data)) +{ + struct irq_domain *domain_parent; + struct msc313_intc *intc; + int ret = 0; + u32 gicoffset, numirqs; + + if (of_property_read_u32(node, "mstar,gic-offset", &gicoffset)) { + ret = -EINVAL; + goto out; + } + + if (of_property_read_u32(node, "mstar,nr-interrupts", &numirqs)) { + ret = -EINVAL; + goto out; + } + + domain_parent = irq_find_host(parent); + if (!domain_parent) { + ret = -EINVAL; + goto out; + } + + intc = kzalloc(sizeof(*intc), GFP_KERNEL); + if (!intc) { + ret = -ENOMEM; + goto out; + } + + intc->base = of_iomap(node, 0); + if (IS_ERR(intc->base)) { + ret = PTR_ERR(intc->base); + goto free_intc; + } + + intc->irqchip.name = node->name; + intc->irqchip.irq_mask = msc313_intc_mask_irq; + intc->irqchip.irq_unmask = msc313_intc_unmask_irq; + intc->irqchip.irq_eoi = eoi; + intc->irqchip.irq_set_type = msc313_intc_set_type_irq; + intc->irqchip.flags = IRQCHIP_MASK_ON_SUSPEND; + + intc->gicoff = gicoffset; + + intc->domain = irq_domain_add_hierarchy(domain_parent, 0, numirqs, node, + &msc313_intc_domain_ops, intc); + if (!intc->domain) { + ret = -ENOMEM; + goto unmap; + } + + return 0; + +unmap: + iounmap(intc->base); +free_intc: + kfree(intc); +out: + return ret; +} + +static int __init msc313_intc_irq_of_init(struct device_node *node, + struct device_node *parent) +{ + return msc313_intc_of_init(node, parent, irq_chip_eoi_parent); +}; + +static int __init msc313_intc_fiq_of_init(struct device_node *node, + struct device_node *parent) +{ + return msc313_intc_of_init(node, parent, msc313_intc_irq_eoi); +}; + +IRQCHIP_DECLARE(msc313_intc_irq, "mstar,msc313-intc-irq", + msc313_intc_irq_of_init); +IRQCHIP_DECLARE(mstar_intc_fiq, "mstar,msc313-intc-fiq", + msc313_intc_fiq_of_init); From patchwork Wed Aug 5 11:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Palmer X-Patchwork-Id: 11701753 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8CAC1392 for ; Wed, 5 Aug 2020 11:01:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C243222CAD for ; Wed, 5 Aug 2020 11:01:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZjAR/0W6"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=0x0f.com header.i=@0x0f.com header.b="YRCgWsJ8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C243222CAD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=0x0f.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=MBMMdCelMCvppI/45qPGuWjSUb1ve5HfsTjfuaD5W/U=; b=ZjAR/0W6vaNJAl++l/AWgR5fu n0/j3z562PoHhjy7NY4Sy3P9/VQa3C5lkEjkGQEc4UccsCLdxHEoROh/nzVLWCdZvhR017Vk3qciv z+wQlhwGyD6ybRtN5LgypbEbButh1JBR9keybudekcXZCTPnMFI72W2H/BA2bdKBelSk3J39j+/qU 4XCWMtO+XD8XbRZ8mkeAPmzT7a70RsjW5lQXS6TsR1pSAbgnJwSQ9fBh/GIm5mRLNhqUTEn0jRwgI LCuUJdEqrxZYZ/yfLZ2S3Ev5Ewos9DBp1QRE5o/S+WbFrBPh1DsrHeQ7qUf6PWyurpsqA8zhE3ceu bDzr1RqEA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3HAv-0004D4-L1; Wed, 05 Aug 2020 11:01:37 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3HAs-0004Bz-UJ for linux-arm-kernel@lists.infradead.org; Wed, 05 Aug 2020 11:01:35 +0000 Received: by mail-pj1-x1043.google.com with SMTP id c6so4318873pje.1 for ; Wed, 05 Aug 2020 04:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0x0f.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Az+AszYcHQWzYCnqT/5thfyfYHza99FgAVuo6NVwe5o=; b=YRCgWsJ8pGTf9hSUA+n2UAu2tevH60z+ftxm0yHShwRstP9B0a1upVpRfJz9WDL68j l8yEHTiQCLSdNiS/bRbYfVZ+rUErAa9vmbTXK3h+gByDGPVvEMF7jquoke5sRJfn1vME CoeVdQYK0iRon/IxKtqOxQkQ8hb7nxsG5ig+U= 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=Az+AszYcHQWzYCnqT/5thfyfYHza99FgAVuo6NVwe5o=; b=QMCBMMv68zBMPecP2bApgpHQgQV76V+NUfDmO6ZLji5/hgta0EJcQdqXzbj+amx82x +CkzRtRAc10GBREg7oL3klKG4H9cNKPek8KjGjCCsmSvce//2sxA/Xd/+ZquDMu/tPDb mjjJ0Ul6H3oU0sHOiqr100gznFaPq/aPaBFPYfqCVyEx192/VXxUFsoDpEi9ZVy6LLd9 ddqLHNt707UniNXMZfxr/GLOCdcW3TzyJnKwCEnudcfeIrqwDbjCvYlswZyGeYc8dBsZ nH0Se0puG5SEoYVWY34fLR7IZm4Paf9Nhhv19ZZMVUVAuUE1xKIGVt5DA5XTTtkS78LE iZAg== X-Gm-Message-State: AOAM5312OBtB7G1siTUid6ocApP5Lm6u/Qz3fM4oikugTJdkLp9+YTn5 nA3+FJ1LH2eI5jhNsnuyNU9DhP49fIAw8w== X-Google-Smtp-Source: ABdhPJxtCw0v0qrAXzPqLGiqTkiXcYFmKfdnKsHWfbhgvd5nuFoxNKvUzwQxkBrwLUbkzgfT+9qCGA== X-Received: by 2002:a17:90a:e643:: with SMTP id ep3mr2780313pjb.18.1596625292189; Wed, 05 Aug 2020 04:01:32 -0700 (PDT) Received: from shiro.work (p532183-ipngn200506sizuokaden.shizuoka.ocn.ne.jp. [153.199.2.183]) by smtp.googlemail.com with ESMTPSA id fv21sm2583142pjb.16.2020.08.05.04.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 04:01:31 -0700 (PDT) From: Daniel Palmer To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] ARM: mstar: Add interrupt controller to base dtsi Date: Wed, 5 Aug 2020 20:00:52 +0900 Message-Id: <20200805110052.2655487-4-daniel@0x0f.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200805110052.2655487-1-daniel@0x0f.com> References: <20200805110052.2655487-1-daniel@0x0f.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200805_070135_042385_D0D5521B X-CRM114-Status: GOOD ( 12.46 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1043 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -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 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, jason@lakedaemon.net, arnd@arndb.de, maz@kernel.org, Daniel Palmer , linux-kernel@vger.kernel.org, robh+dt@kernel.org, tglx@linutronix.de, Willy Tarreau Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add the IRQ and FIQ intc instances to the base MStar/SigmaStar v7 dtsi. All of the known SoCs have both and at the same place with their common IPs using the same interrupt lines. Signed-off-by: Daniel Palmer Tested-by: Willy Tarreau --- arch/arm/boot/dts/mstar-v7.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm/boot/dts/mstar-v7.dtsi b/arch/arm/boot/dts/mstar-v7.dtsi index 3b7b9b793736..2b3bb0886d1a 100644 --- a/arch/arm/boot/dts/mstar-v7.dtsi +++ b/arch/arm/boot/dts/mstar-v7.dtsi @@ -85,6 +85,26 @@ reboot { mask = <0x79>; }; + intc_fiq: intc@201310 { + compatible = "mstar,msc313-intc-fiq"; + interrupt-controller; + reg = <0x201310 0x40>; + #interrupt-cells = <2>; + interrupt-parent = <&gic>; + mstar,gic-offset = <96>; + mstar,nr-interrupts = <32>; + }; + + intc_irq: intc@201350 { + compatible = "mstar,msc313-intc-irq"; + interrupt-controller; + reg = <0x201350 0x40>; + #interrupt-cells = <2>; + interrupt-parent = <&gic>; + mstar,gic-offset = <32>; + mstar,nr-interrupts = <64>; + }; + l3bridge: l3bridge@204400 { compatible = "mstar,l3bridge"; reg = <0x204400 0x200>;