From patchwork Sun Apr 3 18:14:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noam Camus X-Patchwork-Id: 605624 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 3qdNbq2SPdz9s9k for ; Mon, 4 Apr 2016 04:16:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b=LJJCHLYy; 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 1ammZS-0000OX-0j; Sun, 03 Apr 2016 18:16:22 +0000 Received: from mail-db3on0087.outbound.protection.outlook.com ([157.55.234.87] helo=emea01-db3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ammZO-0000IP-6z for linux-snps-arc@lists.infradead.org; Sun, 03 Apr 2016 18:16:20 +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=e0FqcvzCL0qjxEQQ1/WNuU89u1fltj5y8C17cmY9GXA=; b=LJJCHLYy992ZM8SvZrCLn7wEJIiCltrAghZvsgOYmm49kDdvIPe5z5EaqOmbWdCbbHzn8urmejr2ZKzSFxE7BOOGdoHZDPD2m9obw6j3LpmbGNv/jJogl/VnvchfFBaMmbiacLtG0fDUqSAROnu7T3386YgiT9TbuFyfHKgUk5w= Received: from HE1PR05CA0032.eurprd05.prod.outlook.com (10.162.181.42) by AMSPR05MB0658.eurprd05.prod.outlook.com (10.242.74.22) with Microsoft SMTP Server (TLS) id 15.1.447.15; Sun, 3 Apr 2016 18:15:55 +0000 Received: from DB3FFO11FD053.protection.gbl (2a01:111:f400:7e04::163) by HE1PR05CA0032.outlook.office365.com (2a01:111:e400:51f9::42) with Microsoft SMTP Server (TLS) id 15.1.447.15 via Frontend Transport; Sun, 3 Apr 2016 18:15:55 +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 DB3FFO11FD053.mail.protection.outlook.com (10.47.217.125) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Sun, 3 Apr 2016 18:15:53 +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; Sun, 3 Apr 2016 21:15:51 +0300 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; Sun, 3 Apr 2016 21:15:51 +0300 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; Sun, 3 Apr 2016 21:15:50 +0300 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; Sun, 3 Apr 2016 21:15:50 +0300 From: Noam Camus To: , , Subject: [PATCH v8 3/3] irqchip: add nps Internal and external irqchips Date: Sun, 3 Apr 2016 21:14:59 +0300 Message-ID: <1459707299-31564-4-git-send-email-noamca@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1459707299-31564-1-git-send-email-noamca@mellanox.com> References: <1459707299-31564-1-git-send-email-noamca@mellanox.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.1191-8.000.1202-22238.001 X-TM-AS-Result: No--24.515000-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)(199003)(189002)(189998001)(2950100001)(48376002)(87936001)(49486002)(2201001)(5001770100001)(229853001)(2906002)(81166005)(92566002)(50466002)(5003940100001)(1096002)(19580395003)(19580405001)(4326007)(15975445007)(50986999)(77096005)(76176999)(5008740100001)(33646002)(50226001)(47776003)(86362001)(575784001)(11100500001)(586003)(1220700001)(6806005)(101416001)(36756003)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:AMSPR05MB0658; H:mtlcas13.mtl.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD053; 1:sRg784tKTlEfVT9/Ejr7aSjypptIBFaeaxpyULgPBYhCv/ucNoIqaEp+Y5FoCNtJiRQgA45JIy+lr2ox3eJPNyiBtIsAxKvp/BNIOTZ9hDsFBce4O/mq5lkGtsi/wTvrgXjOumQEREtp3shieWwlKJejSfUe6+soD2ErS1QxJWQSCbFfNt97Z/65zR/xU4YKtr0UkRD8okhqfMNJu58DcbuFwYjJSO23vPneGbtnwxTHQyW6+z7OfpByv/Vp1oRBvHG0ZZg1vqXccIHJoateQ8BTi0P5bshpYF2gTKiDBHOmlPPE3DSXu3zlgiwuE36pfIgjpTtN6OOBFzAN6wGPxsWSNTRCOXHSrt6jnW/8sSHQ/XxQAW+swcWjs/5Xy/R0lhREfLQT9ApDnR9o0hFa7IiHAm9yI+BQtZ6H0qGl96/jrt0QbKLRy9E941urPescmFeowZkfSc/ITFm5cjdA6zhsybQEzKzvf8Sw9lB2Bvve4v9xDZjVUuiJjJbW+7WDQJXf+2byXn2FIsuyqmLH7Q== X-MS-Office365-Filtering-Correlation-Id: 9298cb33-e9e2-4af7-b621-08d35bebfe92 X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB0658; 2:1Gh2mBsxG9znM5GZwheU7poeDreSQvhMn1cH+jxwnK/hb1atyc9yyG5ZRdXDdylwqjJqeDL0xgPd5uOLuaVMny6+1Olwe/NahMynR/EIOUyCPNGJBuNRogo7aubsbbTkkkGjs2wRSVrVHYxUAhU+H9/Fnnsi0gibUZHSJlUdL/Nk09Nj6+greAAbg5olvO1H; 3:ABgPRaJPO3qg87h36qITiml7Muy+xmAoYcCp+qMs7AEaGixotDmBm9YsbVdaxr2KYuVTWcXYykQ126p5Dv7hwqALy6f2BL+Zzi5YTNOM16yG4/VC90SNyIhKIb2vIfozZF4+p4h1EQG5suHijIPSkjzJmu8UukneTi8JKu16Zh1PtldPaA0IIqeP9TpWFhTTcPKH2i0HgWtdX+6tf1sJ8sj4tMg88yZt8dDyDs2mrMuq7QpW1z8S4l9uhDNYL9QSh7+ADXDcLnNYvO7ZouiV8w==; 25:PGa+M7AGPodOViW+JJPGXWiy+Hi8dVpmYe5nzLSpFz5e8wy9Nu9RUjkeRcpdL31RaAlFEMFfBd9dAC/mweBjVHkyK7KYH+avWmLErp3YdYY7eFoR36EreoW26Sitg4LBd3DSy+c/GmLihrs62KovFmwZoMLqSyKJ9asU653usqrig9iEuMGLHONMLm3AiWAenRpgDGqD7WlMGkUWihhEHGBGaW2Gqsw6sPxZLVQxHACbfR0Nnj6P8A++CkgUEE3USa1ejKNgDQZrDlJQrinIs4kMi2nPWIMtv/Gr19/3lcQY+tjkXU5PZYSG2pioZT02ISXxuOdjM9bGFajk72pKgg0nNmWxBPITtD4o6hfscMs= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:AMSPR05MB0658; X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB0658; 20:wSrkNBWRMkb8h8cqviwaQbjcRU+D1C6OYOO/IJJAWqq9SvPUBKPKvE+hHG1IJALtdd7OBT+dU5TDVFLiYwxzhjlPdRRYc3FzkYas4hyM6LrqMsSKS+CfXPWPI+VFsW8wzglqOHmBxj78UlEnr8T7KD3RYAEdZIyahbrobsRSH5HaNO2VwY6XJnr5gX4s7WVH0WThfK7tP4xgTYx+v/qH8RFZDaFB5VlwbOI69Au80IV5P2ob2kPQIlcK7TCwZZfGSDfG/wQACt1agmgylvyaZk9019OeUsD3NaXOnTemb40Rq0FW5iCxheQ22EBHJgSNVxCnYfQX4b8FX6t/GryK/v2hZrKXbw0SWeyAIE14FjDNZ0Ri7PpA0lCuAxfgE6fHccSCkcGMI5rFodzySAtlavt2nMWaJz3GANgV1561D6f13UyzYInXAUaS1uk4/n3EjT2jp0FrOZKanoy6AW2K76wmmbiBPz6i9dd393YO/c11jnjVV13pNWJuCBUmQlrF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(13018025)(13023025)(13024025)(13017025)(13015025)(3002001)(10201501046); SRVR:AMSPR05MB0658; BCL:0; PCL:0; RULEID:; SRVR:AMSPR05MB0658; X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB0658; 4:2sIuYs/TPLuVt0y6uYUQtz7G+G185qiu0cvTvgjoNPPsRBT4Kxw6c/jrakY13+jRNrf+OU7AihqyX3sMpJBcJhqtHxrN7zqLsaLRqEaNbak0kjKOOdsrxj5XeUxzVvJc3pbU8QwVqn5i54Rlb4bfyjqQiqzQ2HdWh5lPhw/R1Msd0CEEeaPuhBW7E6hBdAUdItEga2Wu64/T1S3Dg+Kk2ieiVMBJOBcMLgut1Pah9BQ2HFA4kBoY70H4d5Ytp3gdn51ln6liIYeSs4LbFyRVhtgKQLC4SWxpAsA/syedroJNltSvPcw+UspyNtt9OqdJdnpmxX/NVjjiXO1gsLaYM5vRCA/ZbKpMReJyz+SNvFWWqdBFiwXmIYBU2dO/Q5KDwr8PUXIP9wkbuhakv2zeSxp/gWVo722w9WMRL87TmvPSs3BahBdTgARsxrSooaZggK48blN/5C7Ux4LMl3ZXIw== X-Forefront-PRVS: 09011458FC X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AMSPR05MB0658; 23:B03H/kYksdcB7EsABOLY8eXWZcwTIGQudFv+DZLEJ?= =?us-ascii?Q?YKLzmqWVaER/eyhPjj+awpP0CUmcX7xNVfMI+njr8yS15+YeNGZyn3Gwtc+Y?= =?us-ascii?Q?tIqBoYdtuBSUTWWcQgSNtYimZ9aGEwGNMKVuKE23LhsnXPS0GuLMli7XKj/l?= =?us-ascii?Q?uYV1LhTW2xj1tWgg6FVTnNLOi4k6yjH9DfgGG5n4+sMJRIyI1GSzvEuUbQfR?= =?us-ascii?Q?BmGUQIRTCcvydtOv4EuwYVDK4xJHTQeqKK3QKk/9GAwBNnakbJ4cWkUnt+Dx?= =?us-ascii?Q?UOT+MxQuxPSCgJRjgmMeUJjsQ+8/UYZZJrBa0OXxxvPOONXZdPeJ+sZV3Thz?= =?us-ascii?Q?me9DX0MlFCtFkjXSYQ8GLFPg1hRjnIq1re3g6iYbLm+7H6JNQ8UZPR0QV1zW?= =?us-ascii?Q?D3OoxUplHFLDSmUgqrxU/TmS9ykEvPC/JvPPtVrewtG5ovV7SOlIxLos1pT3?= =?us-ascii?Q?DWcjRZ3aoAs1jJZICqQxOsGlW+4v78M+8Za9v57oNHIZqmU0zUkXUDKvPvyv?= =?us-ascii?Q?rY/gScvFjc4wQcSM6hQXYOhCz8TIreHnoy6GXB2Ko99c0TGLCTxR/mNW0NbV?= =?us-ascii?Q?P1EWeFAm2PlU5JcNiLLBzJXDm3oVfkKLjYHwqtuzhNoJHIkRJfoEgJxOm1ZR?= =?us-ascii?Q?q68kflrdekxFOX8IgKXgf6lyGB+D0qq2RayRdfk8BKdIDz2iTYdMumKA3xTW?= =?us-ascii?Q?zDa8zuIO3EjNNotNjzqDlXjMDLFKHyhjjk2Qryl3EsYYkAqCkPeY/817v7lp?= =?us-ascii?Q?Ok57DzgOvmXT3MgAL94BKVupTjEqrENyUgPUUHiZV4Tz+BXLZ147/LJuLhAw?= =?us-ascii?Q?b4olKHtshcwNZfm5Dof8K6i7op7AJP1QyPZBRD73NFPv+W/kVNrOo0hYkHrE?= =?us-ascii?Q?of1MZ8Ql1JuJCYWh6+rdRKT2H2ZQTA0mUzlH/vKlPXPsjBho8cW7e6cpQQuL?= =?us-ascii?Q?wMD9jI2qvxaKmmhW8o+Z4h2pkbaNhagIyI6plB3+Wdw89AtEaL8zuYnk9zbg?= =?us-ascii?Q?lAaI7/0N9cvXNtS88WZvSgNkfcYKkgs2gnbpHkIJbSlxg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB0658; 5:CpG7fqWo2sZ45dSwSrt2EjP/Vd1N3kyMN6HGo6sMqcFSr+NEGMyAPF50hvZNdnOUEBGeV/XS1bNISz8mImkBUyAp8I0cPGTOOcno7yTuK+I7Go3fAugRmGEbR3ddzEYSPeEJS9Fus8be96NbzhxNsQ==; 24:tIPip6d8oXjPHyd4toH6andTrd3rPKPQPxroMr4NTOR20I7H/otrAAeLfJ5NMIdQYyOjr450ElPipkt24A0eEij18ZumcgEyncU+DcwYlzs= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2016 18:15:53.3813 (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: AMSPR05MB0658 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160403_111618_747775_8B7F2728 X-CRM114-Status: GOOD ( 19.75 ) 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_MSPIKE_H2 RBL: Average reputation (+2) [157.55.234.87 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [157.55.234.87 listed in list.dnswl.org] -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_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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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. Internal interrupts are handled by Multi Thread Manager (MTM) Once interrupt is serviced MTM is acked for deactivating the interrupt. External interrupts are handled by MTM as well as 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 Cc: Daniel Lezcano Acked-by: Marc Zyngier Acked-by: Jason Cooper --- v8: Change macro name from IPI_IRQ to NPS_IPI_IRQ. This was needed due to build warning when building for parsic. v7: Rebased on latest HEAD (4.6-rc1) v6: Files headers changed to start with: Copyright (c) 2016, Mellanox Technologies ... This is due to the acquisition of EZchip made by Mellanox. One can still find "EZchip" used in tree, and this is ok. This patch set is a requierement before I can insert new platform to ARC, one that supports the NPS400 SoC. v5: Clocksource, irqchip - Fix gracefull return. replace call to panic() with pr_err() and proper return value. v4: clocksource -- Apply all Daniel comments (Thanks) Handle gracefull return and also using clocksoure mmio driver at init v3: irqchip - Fix ARM build failure by adding missing include of linux/irq.h clocksource -- Avoid 64bit arch's to build driver by adding new dependency !PHYS_ADDR_T_64BIT This is since we use explicit io access of 32 bit. So for test coverage we allow not only build for ARC, but restrict it to 32 bit arch's. irqchip - Apply all Thomas comments (Thank you) v2: Add header file include/soc/nps/common.h. Now to build we do not depend on ARC subtree. General summay: Both drivers are now apart of previous basic patch set of new platform for ARC. The rest is now can be seen at ARC srctree: https://git.kernel.org/cgit/linux/kernel/git/vgupta/arc.git/ Now ARC is supporting DT for clockevents and the interrupt controller ARC uses irq domain handling. Compare to last version now clocksource driver do not include clockevent registration since NPS400 can use ARC generic driver. Compare to last version now irqchip driver sets domain as default since it is the root domain. Also mapping of IPI is done in this driver. Last thing is that drivers can be build cleanly for i386 (still runs only for ARC) Note: in order to build we need to merge drivers into srctree which includes new header: soc/nps/common.h This header is part of patch set applied to ARC srctree. Regards, Noam Camus --- .../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 3e12479..1ab632a 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -244,3 +244,9 @@ config IRQ_MXS config MVEBU_ODMI bool select GENERIC_MSI_IRQ_DOMAIN + +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 b03cfcb..9d54d53 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -65,3 +65,4 @@ obj-$(CONFIG_INGENIC_IRQ) += irq-ingenic.o obj-$(CONFIG_IMX_GPCV2) += irq-imx-gpcv2.o obj-$(CONFIG_PIC32_EVIC) += irq-pic32-evic.o obj-$(CONFIG_MVEBU_ODMI) += irq-mvebu-odmi.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..efbf0e4 --- /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 NPS_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, NPS_IPI_IRQ); +#endif + + return 0; +} +IRQCHIP_DECLARE(ezchip_nps400_ic, "ezchip,nps400-ic", nps400_of_init);