From patchwork Mon Mar 21 14:24:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noam Camus X-Patchwork-Id: 600153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qTJ5Q6xtwz9s5Q for ; Tue, 22 Mar 2016 01:25:30 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b=CRe/ELTm; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ai0lt-000787-FF; Mon, 21 Mar 2016 14:25:29 +0000 Received: from mail-db3on0086.outbound.protection.outlook.com ([157.55.234.86] helo=emea01-db3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ai0ll-0005uL-6l for linux-snps-arc@lists.infradead.org; Mon, 21 Mar 2016 14:25:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MXmXrtIkYc0H5iPnruhWst95CEUJqJgcWdsxEH+l9k8=; b=CRe/ELTmE5xKXpWWyVEmw5Q4MycnSLOzca095E6LfUYC10IWZZpkwEOBMejS6m5X1g5Z1hFAGSKnnVVIGdnQGbEFjFOeYgRkLtsZyQVfuCLT4qJ8BQq+xywiP+n1tcTqz2JDYH+gCsSOQf27ur6k+mJT7O+gUM378LqHG8OGLjo= Received: from AM4PR0501CA0017.eurprd05.prod.outlook.com (10.167.83.155) by AMXPR05MB0661.eurprd05.prod.outlook.com (10.242.11.27) with Microsoft SMTP Server (TLS) id 15.1.434.16; Mon, 21 Mar 2016 14:24:58 +0000 Received: from AM1FFO11FD041.protection.gbl (2a01:111:f400:7e00::112) by AM4PR0501CA0017.outlook.office365.com (2603:10a6:200:6::27) with Microsoft SMTP Server (TLS) id 15.1.443.12 via Frontend Transport; Mon, 21 Mar 2016 14:24:58 +0000 Authentication-Results: spf=pass (sender IP is 193.47.165.134) smtp.mailfrom=mellanox.com; lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=pass action=none header.from=mellanox.com; Received-SPF: Pass (protection.outlook.com: domain of mellanox.com designates 193.47.165.134 as permitted sender) receiver=protection.outlook.com; client-ip=193.47.165.134; helo=mtlcas13.mtl.com; Received: from mtlcas13.mtl.com (193.47.165.134) by AM1FFO11FD041.mail.protection.outlook.com (10.174.64.230) with Microsoft SMTP Server (TLS) id 15.1.443.6 via Frontend Transport; Mon, 21 Mar 2016 14:24:56 +0000 Received: from MTLCAS13.mtl.com (10.0.8.78) by mtlcas13.mtl.com (10.0.8.78) with Microsoft SMTP Server (TLS) id 15.0.775.38; Mon, 21 Mar 2016 16:24:56 +0200 Received: from MTLCAS01.mtl.com (10.0.8.71) by MTLCAS13.mtl.com (10.0.8.78) with Microsoft SMTP Server (TLS) id 15.0.775.38 via Frontend Transport; Mon, 21 Mar 2016 16:24:56 +0200 Received: from ezex10.ezchip.com (10.0.13.1) by MTLCAS01.MTL.COM (10.0.8.71) with Microsoft SMTP Server (TLS) id 14.3.123.3; Mon, 21 Mar 2016 16:24:54 +0200 Received: from localhost.localdomain (10.1.3.132) by ezex10.ezchip.com (10.1.1.4) with Microsoft SMTP Server (TLS) id 14.3.224.2; Mon, 21 Mar 2016 16:24:54 +0200 From: Noam Camus To: , , Subject: [PATCH v6 3/3] irqchip: add nps Internal and external irqchips Date: Mon, 21 Mar 2016 16:24:32 +0200 Message-ID: <1458570272-23037-4-git-send-email-noamca@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1458570272-23037-1-git-send-email-noamca@mellanox.com> References: <1458570272-23037-1-git-send-email-noamca@mellanox.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.1191-8.000.1202-22206.007 X-TM-AS-Result: No--19.231200-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Received-SPF: None (MTLCAS01.mtl.com: noamca@mellanox.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:193.47.165.134; IPV:NLI; CTRY:IL; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(19580405001)(19580395003)(87936001)(81166005)(77096005)(48376002)(11100500001)(2950100001)(86362001)(2201001)(2906002)(76176999)(101416001)(229853001)(36756003)(49486002)(106466001)(50466002)(5003940100001)(6806005)(33646002)(189998001)(5008740100001)(92566002)(586003)(50986999)(1220700001)(50226001)(47776003)(5001770100001)(1096002); DIR:OUT; SFP:1101; SCL:1; SRVR:AMXPR05MB0661; H:mtlcas13.mtl.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD041; 1:u+j8PQrxoNfz0QPlAhBrfYBYnG78E0u2dMjQ+RzbLUq9H6OJ/KqXTHpWEdHW0f3ImK+gQqWa6iuecnj1iJsu8i8W7onrYnrDrwg9YNM+51lNYw1kiqysqQeQj0CNQgTbwlmrCLI9vQ3HxYm+JmiOjgtIH3O21RzxiZgms5eCtKycfoDmXSGfQEhJ8hf8wj/jZwI1zRtCVFKleNs3Y5VPXqV6Y78ku3CWaigO58pMlk6qsb3WoyqA5xbc4BtUZQTZeFL/yoQxIsoHJ+cGGJ6T20ngWK/Y9WoKZ3yJ9FxzLfFQkVibbLsadozhAGkylYIvsy3un0jyqnbmQ3Lwqm3v8KZiCx8jcLZ7wreh8U1kktEFKsKTT2gxvAG5rRcKjShzAvtacI9Sj0GT0+dX41RNIpG42elWIwt6M0x/Q+TUD74EWRqeP/sSvWh4VBuGTkOWobsJZ+WEi4v++p/8N/KXDX/oXw8RT1wfFflRyXwg6L91i1jL8HZFoY2QzVVIZQJx X-MS-Office365-Filtering-Correlation-Id: b6695bb4-6516-407a-9afe-08d3519493e5 X-Microsoft-Exchange-Diagnostics: 1; AMXPR05MB0661; 2:v7hR5qJSPr7KFAHAX5ntxpAtC1ZFtwp0W5rTKaAy/gIo/ySyc55odJ+x6RRnshiltLzJB1+6ubroc9fMKG+GJGc35go8Sdt7QJmrva4AlaoxcR0W2M9I+IV7wUOVa9OZDX4Y+RTXaRwWxW9BkZCDCMyWaCaOyz/gAgEjcotjQcDCbNiqwLoJepgsRyYn4F+l; 3:y2uMso89Ab0ok5ft14Ms5zVlDJKDhXXvs+uhIjEB3P6vEGViECHbMLbEPfMPG+2o61Oghj+fAo4tjPQWLYHBwakhf6CKQgC6N2xSCSVRwno6RcIsUndsCLbEHefJM9/ncLQm+xH3XQZtkhZS99p6BvObUhkiXBo7tAOPyE2vac47FUUmLa0oT3yzRXTAnfmwfaz6LAlq4mPbc6f1PO9z+bJN/JmDzndKWCJ0GB21NG6oJLlBQYhAFUFpCxglF3kqjnFt35oFz3Fks66jk+WzYA== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:AMXPR05MB0661; X-Microsoft-Exchange-Diagnostics: 1; AMXPR05MB0661; 25:JH3Ub5JWBevdHz4iQHlws+grRCdwdROCB+IzPLyxvrRS/iAyMsF4vVbf63wkMIYl5LL4b5tedeGNJKdu4X4q3OU10RZ1nspeXiCKLyWfHq4i1o9SQAm8sJHugkYxv3g7pYBem4ZPuQZJ6jbBZBjkmSrG4f2RJRhkEu8JijCa8axqwZXXj4B/n+9hAARmg7+u9MBY4bx6DxcUqTAfsNVFtqzb8Ey/Dmnm5Y3JDXq0VGZvBv85TLtzH4HEiXz3bVQt7wqXlW+ud8nZx0IePA/wEpc9+aA/BiwtnPqHi9PNMYsCdPzeX9yRItqw9W8qCgQHxw3WtF2hOa5yw4FrOnp56ILTYh3T4RcRPrKIHWZnpzQ0l+q4yI/tRgoY9MoA5+9Rb6KAl5iMp34fiL4PWk8IZvkxz3DrUyimSTPV4yDvTG+EgaHC1Wv4iAZTuGLh/dGWMzA2U0ynRSYf4ECbrfHzTygSOs4III/oT0uvJz5A9E1oIsX38TqrvwDcr80bvlVInM2TROK2792YlOtYvcpUhosDLgN3hd5EXEraoCWw8Cm1HxnFSRoYSbgyVdO7+GnwX4l6Ev3A5M1t8gcYCRyBDtWLTpe28tRDXcL0omZsYAlNOwRZsqxZQAJ2Ljyem7nBaaOb6s03g/9INKtEy5nfmQ== X-Microsoft-Exchange-Diagnostics: 1; AMXPR05MB0661; 20:lP59qaOMw4EfDFJzmiyePd7mqIUihdIkvmvCnUs4uPlTEVBq0a3RMYYEFrrENemZx2bXX3vziBEqPJ+twytxvkALZX8kW8r+3I2qhvs5okeu83YC9Vt6aK/L/Y99Wg++8hZSJVJUu3Ep3Pe3/rI89jem158XODEo8LsRfpuutcaTJYvH1jQTs5z5PyPewHm5UI9X76X2UOdUKQNhMnQr6r0/9qBfvO7rbMrAS3fjb5XcmOXuoqlITaAlSoXYr8Mt0UWuHyi8OSw3oH3n1eXNs/9Pl0M4FNCLcHM7vQf1Eb6vBCYxtglNaydCgNiLniVNpB6DR/ooRcPk9YdBpasJFTU6E9BDZP2shjP6y0YlgDY43l35D78jtrYHkjzbTLLVLa23DvHL5agu+LwujDKNMkwpzMolBlXG1sI4yhvXhxf0megJ/2wH4cA3mBLQHa5Ck3hOvuV2H3WrA3AiMfdgm2JDIxoB4e7NANsrp3QGPxHbCnsnEonU0/4YqbJM+GlU X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(5005006)(13024025)(13017025)(13015025)(13018025)(8121501046)(3002001)(10201501046); SRVR:AMXPR05MB0661; BCL:0; PCL:0; RULEID:; SRVR:AMXPR05MB0661; X-Microsoft-Exchange-Diagnostics: 1; AMXPR05MB0661; 4:nm0g3tAinM3h5BflKr0Oq4udkDFIHAPudK+IVscYdD+8dSzOjFJw5JkNJQdVi0k8Tu4nbwMekLA8pJSij9c7n6SptjdZ45EIcST91Zrmv7cOwUKse0VuOxzIdIYUsgqiRZMRQwWqztWq6tTBoirJiCvnN9u/u38+1ps43LmzMRhxTV1xFSWxvzdeqGGXSI5BMddtcg2kCusxFQZrsDqh77laWwThjo7CcxgSNJ9BDOr2UsMTFUvS404ZuFbFN+RqV5VXJZA6LBNCUfL9jt6CJDLf8WRVkPNA+Bs6eUqCgL9BdgcFEnmqifYrcByWJVAduoDvRcxZseKqGv9peWp0jBTIb+h+bA8K0hRwSguVVy9EAPFKPMwlTeQJxrkeN1rXe4rKC4TOG0MXZdjhfYwb6jO8vVX3gsJu1SqNSEhJmRORx97nYJ63MjQ9LR/T8Fv8cNkNvaBLMJQy1m4SMGlYzw== X-Forefront-PRVS: 0888B1D284 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AMXPR05MB0661; 23:5DTNozfpaE9cOAC3L+oLyfmuW/hOy1EWUppwM8dnG?= =?us-ascii?Q?AhqGBdsVpXA32nMlT40BDPZYcWrJAeIMHVdPe8PFQv3AM6eKyOcED8En201K?= =?us-ascii?Q?c9Eba68zWD2prbYN7TkWvCTqyuYTtqTRFo5yOZbvBsof9nxDEDM7nk9utXN1?= =?us-ascii?Q?ZvDO76liRiXzpIVe8RpqePIk9pnCT5OhKj9LkkotK2uD3S0ODM2BlCXdCnTP?= =?us-ascii?Q?ax7xw2Yv73a+HIHG2XXp17FNNzQyvjGp/p3sh1ExvH/fPUsBfie0JJ8jLkW7?= =?us-ascii?Q?TY3+K7jIqg5xu+PlW/g5VUzGAMlfFMVUoXeIJyAOovkewIQZDivRcKNl0E/6?= =?us-ascii?Q?ltSIcKgGYpFM6MaxF4+i0N+shK0C5nK2iOCK0dp4MVsO6yf65LlcApk8ZX0R?= =?us-ascii?Q?HAUhqfbA+5orr3ufWJQmx7Cq6Vd1M9lJ8C7udPuQ1XHs8Tbw17p4ZSBGjtQR?= =?us-ascii?Q?ysClzWa0C1lzSLn3XHHqFmk5605Dp/o3PL0yu2D1WICoTSXFqEVkPZPWVG+w?= =?us-ascii?Q?EfGPAzgJyYYbc8rVZobC1N157a3u9UFrPB7Ql4xvimLOQyJVQ9rBIUVkpW84?= =?us-ascii?Q?DoDhgt31YhiZU3G+TLDz5ZUNpOaWSNKHWyabENOxMT9BNiSQ6hKGy5n+cU3z?= =?us-ascii?Q?sz6tBMf9KPBWu2D1KR4DKRHBsJyzNBz4zLlgahkYCN5+M+Hi+G0+2p/SK1xO?= =?us-ascii?Q?qZ82Tq5fcpZUKLR3RKaQdaLQ1/F5tLi+ppk4RPPfF6y2kiPpy0uvFAP4/lAf?= =?us-ascii?Q?fyLxlmJUIGKNKnvsKRj19Sv7CD0ydWnAlhW4orcM+b6kTUKsuxF7V3SCYU6N?= =?us-ascii?Q?iYIGQ1LrEfiQ6yy6kEdNvQk9DZ/c5nPeo7eeYpaADguCKnnJxwpWhFxzKCRF?= =?us-ascii?Q?TlGoFzC5EjA3gWEr95f5Wn84OD5RNlwQ/SA/0SD94y+T4A5NW9VnxmxoINpC?= =?us-ascii?Q?516fj64QVX2vFv+6Wlgp3AOfvy0InW92TtzKfGNIg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; AMXPR05MB0661; 5:CERwXVdVPHJDQVQe2jqFWZO7tik9dTm/jmoK8K5z5LmlBoQws/SGpA8Z0Aqhv3CJV4IvrR/qnM2H8BS+idyeq2xGt2KKgUcxnyygZNPU3WH8yQcuJbi9LJZloldl48VzindxI8PYzwopMxZ7KuAN5g==; 24:dgJuXCMl7HfizownXVRG2Blnj6LdbLZJDlOBMrPqv2+QWy6JLhFcFFIDAtmkHrK84BOITiIhIsWvdMmrp5qaVPo6i5StEG8+pPPQhC2+fsE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2016 14:24:56.5183 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b; Ip=[193.47.165.134]; Helo=[mtlcas13.mtl.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMXPR05MB0661 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160321_072521_839597_0D94675C X-CRM114-Status: GOOD ( 15.00 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [157.55.234.86 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [157.55.234.86 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Gleixner , linux-snps-arc@lists.infradead.org, Noam Camus , linux-kernel@vger.kernel.org Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Noam Camus Adding EZchip NPS400 support. NPS internal interrupts are internally handled at Multi Thread Manager (MTM) that is signaled for deactivating an interrupt. External interrupts is handled also at Global Interrupt Controller (GIC) e.g. serial and network devices. Signed-off-by: Noam Camus Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier --- .../interrupt-controller/ezchip,nps400-ic.txt | 17 ++ drivers/irqchip/Kconfig | 6 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-eznps.c | 165 ++++++++++++++++++++ 4 files changed, 189 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/ezchip,nps400-ic.txt create mode 100644 drivers/irqchip/irq-eznps.c diff --git a/Documentation/devicetree/bindings/interrupt-controller/ezchip,nps400-ic.txt b/Documentation/devicetree/bindings/interrupt-controller/ezchip,nps400-ic.txt new file mode 100644 index 0000000..888b2b9 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/ezchip,nps400-ic.txt @@ -0,0 +1,17 @@ +EZchip NPS Interrupt Controller + +Required properties: + +- compatible : should be "ezchip,nps400-ic" +- interrupt-controller : Identifies the node as an interrupt controller +- #interrupt-cells : Specifies the number of cells needed to encode an + interrupt source. The value shall be 1. + + +Example: + +intc: interrupt-controller { + compatible = "ezchip,nps400-ic"; + interrupt-controller; + #interrupt-cells = <1>; +}; diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 4d7294e..bc5e775 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -193,3 +193,9 @@ config IRQ_MXS def_bool y if MACH_ASM9260 || ARCH_MXS select IRQ_DOMAIN select STMP_DEVICE + +config EZNPS_GIC + bool "NPS400 Global Interrupt Manager (GIM)" + select IRQ_DOMAIN + help + Support the EZchip NPS400 global interrupt controller diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 177f78f..1390142 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -55,3 +55,4 @@ obj-$(CONFIG_RENESAS_H8S_INTC) += irq-renesas-h8s.o obj-$(CONFIG_ARCH_SA1100) += irq-sa11x0.o obj-$(CONFIG_INGENIC_IRQ) += irq-ingenic.o obj-$(CONFIG_IMX_GPCV2) += irq-imx-gpcv2.o +obj-$(CONFIG_EZNPS_GIC) += irq-eznps.o diff --git a/drivers/irqchip/irq-eznps.c b/drivers/irqchip/irq-eznps.c new file mode 100644 index 0000000..97e4294 --- /dev/null +++ b/drivers/irqchip/irq-eznps.c @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2016, Mellanox Technologies. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define NPS_NR_CPU_IRQS 8 /* number of interrupt lines of NPS400 CPU */ +#define NPS_TIMER0_IRQ 3 + +/* + * NPS400 core includes an Interrupt Controller (IC) support. + * All cores can deactivate level irqs at first level control + * at cores mesh layer called MTM. + * For devices out side chip e.g. uart, network there is another + * level called Global Interrupt Manager (GIM). + * This second level can control level and edge interrupt. + * + * NOTE: AUX_IENABLE and CTOP_AUX_IACK are auxiliary registers + * with private HW copy per CPU. + */ + +static void nps400_irq_mask(struct irq_data *irqd) +{ + unsigned int ienb; + unsigned int irq = irqd_to_hwirq(irqd); + + ienb = read_aux_reg(AUX_IENABLE); + ienb &= ~(1 << irq); + write_aux_reg(AUX_IENABLE, ienb); +} + +static void nps400_irq_unmask(struct irq_data *irqd) +{ + unsigned int ienb; + unsigned int irq = irqd_to_hwirq(irqd); + + ienb = read_aux_reg(AUX_IENABLE); + ienb |= (1 << irq); + write_aux_reg(AUX_IENABLE, ienb); +} + +static void nps400_irq_eoi_global(struct irq_data *irqd) +{ + unsigned int __maybe_unused irq = irqd_to_hwirq(irqd); + + write_aux_reg(CTOP_AUX_IACK, 1 << irq); + + /* Don't ack GIC before all device access attempts are done */ + mb(); + + nps_ack_gic(); +} + +static void nps400_irq_eoi(struct irq_data *irqd) +{ + unsigned int __maybe_unused irq = irqd_to_hwirq(irqd); + + write_aux_reg(CTOP_AUX_IACK, 1 << irq); +} + +static struct irq_chip nps400_irq_chip_fasteoi = { + .name = "NPS400 IC Global", + .irq_mask = nps400_irq_mask, + .irq_unmask = nps400_irq_unmask, + .irq_eoi = nps400_irq_eoi_global, +}; + +static struct irq_chip nps400_irq_chip_percpu = { + .name = "NPS400 IC", + .irq_mask = nps400_irq_mask, + .irq_unmask = nps400_irq_unmask, + .irq_eoi = nps400_irq_eoi, +}; + +static int nps400_irq_map(struct irq_domain *d, unsigned int virq, + irq_hw_number_t hw) +{ + switch (hw) { + case NPS_TIMER0_IRQ: +#ifdef CONFIG_SMP + case IPI_IRQ: +#endif + irq_set_percpu_devid(virq); + irq_set_chip_and_handler(virq, &nps400_irq_chip_percpu, + handle_percpu_devid_irq); + break; + default: + irq_set_chip_and_handler(virq, &nps400_irq_chip_fasteoi, + handle_fasteoi_irq); + break; + } + + return 0; +} + +static const struct irq_domain_ops nps400_irq_ops = { + .xlate = irq_domain_xlate_onecell, + .map = nps400_irq_map, +}; + +static int __init nps400_of_init(struct device_node *node, + struct device_node *parent) +{ + static struct irq_domain *nps400_root_domain; + + if (parent) { + pr_err("DeviceTree incore ic not a root irq controller\n"); + return -EINVAL; + } + + nps400_root_domain = irq_domain_add_linear(node, NPS_NR_CPU_IRQS, + &nps400_irq_ops, NULL); + + if (!nps400_root_domain) { + pr_err("nps400 root irq domain not avail\n"); + return -ENOMEM; + } + + /* + * Needed for primary domain lookup to succeed + * This is a primary irqchip, and can never have a parent + */ + irq_set_default_host(nps400_root_domain); + +#ifdef CONFIG_SMP + irq_create_mapping(nps400_root_domain, IPI_IRQ); +#endif + + return 0; +} +IRQCHIP_DECLARE(ezchip_nps400_ic, "ezchip,nps400-ic", nps400_of_init);