From patchwork Tue Dec 1 13:02:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noam Camus X-Patchwork-Id: 550838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::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 3411E1400DE for ; Wed, 2 Dec 2015 00:10:52 +1100 (AEDT) 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 1a3khm-0004Df-OX; Tue, 01 Dec 2015 13:10:50 +0000 Received: from mail-db3on0063.outbound.protection.outlook.com ([157.55.234.63] helo=emea01-db3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a3kdS-0006yk-1D for linux-snps-arc@lists.infradead.org; Tue, 01 Dec 2015 13:06:29 +0000 Received: from HE1PR02CA0045.eurprd02.prod.outlook.com (10.163.170.13) by AMSPR02MB182.eurprd02.prod.outlook.com (10.242.94.20) with Microsoft SMTP Server (TLS) id 15.1.331.20; Tue, 1 Dec 2015 13:05:58 +0000 Received: from AM1FFO11FD029.protection.gbl (2a01:111:f400:7e00::126) by HE1PR02CA0045.outlook.office365.com (2a01:111:e400:5350::13) with Microsoft SMTP Server (TLS) id 15.1.331.20 via Frontend Transport; Tue, 1 Dec 2015 13:05:58 +0000 Authentication-Results: spf=fail (sender IP is 212.179.42.66) smtp.mailfrom=ezchip.com; lakedaemon.net; dkim=none (message not signed) header.d=none; lakedaemon.net; dmarc=none action=none header.from=ezchip.com; Received-SPF: Fail (protection.outlook.com: domain of ezchip.com does not designate 212.179.42.66 as permitted sender) receiver=protection.outlook.com; client-ip=212.179.42.66; helo=ezex10.ezchip.com; Received: from ezex10.ezchip.com (212.179.42.66) by AM1FFO11FD029.mail.protection.outlook.com (10.174.64.218) with Microsoft SMTP Server (TLS) id 15.1.331.11 via Frontend Transport; Tue, 1 Dec 2015 13:05:57 +0000 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; Tue, 1 Dec 2015 15:05:34 +0200 From: Noam Camus To: Subject: [PATCH v3 04/18] irqchip: add nps Internal and external irqchips Date: Tue, 1 Dec 2015 15:02:51 +0200 Message-ID: <1448974985-11487-5-git-send-email-noamc@ezchip.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1448974985-11487-1-git-send-email-noamc@ezchip.com> References: <1448974985-11487-1-git-send-email-noamc@ezchip.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.1191-8.000.1202-21974.007 X-TM-AS-Result: No--19.311100-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD029; 1:ysTZhMV3g8q53JvoiV4bgqeE0qE61hcGo68IrA1YTCze0L5iLvpnOpvPFDmeublrt0bnykxXvtcVvpPQgCX3pVpmY23Zibg/X2+LJxWTy3QMZqtjedRBx9K9f6rwG5CoaonJqjDf7McNnQHovPeTsrLhievtv5lQ/paBB71ABspEA81XwUAxYhMrya8FhH4IqDaBvIKLi0e/cZpw9M5jEVZm+XSIyI6gpvrpoJifuzasz/yL8sCpSeJtxFHAhO1kxs/OoscmYB9PFWPOBLPCtW+pAOL07ezjEJ0C6L+olrgLCOozoJa5T2UrvfqydtZcohRnmJg6CQfer7EvSEOcmLK1D07krBWkMAOA7Bco+tbLJGX05NVz+mv4NgltB9St+OnNOgFPMWt0es1tU9jYUigArFYww3CcM23PZnEv+9HCJZSp0IGORoT21d9bPPzh X-Forefront-Antispam-Report: CIP:212.179.42.66; CTRY:IL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(5008740100001)(2351001)(110136002)(50986999)(48376002)(1096002)(106466001)(77096005)(189998001)(105606002)(86362001)(19580395003)(33646002)(50226001)(229853001)(5001970100001)(19580405001)(50466002)(6806005)(586003)(92566002)(104016004)(87936001)(85426001)(76176999)(2950100001)(1220700001)(47776003)(36756003)(49486002)(11100500001)(5003940100001)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:AMSPR02MB182; H:ezex10.ezchip.com; FPR:; SPF:Fail; PTR:ezmail.ezchip.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AMSPR02MB182; 2:H+tme4zHuJXvBeNaQQgDsZgy27225YWp+JFf18SV9MzlOQsXYkNg60deMGVOhvHe6jE5pGDXJq7YMj7GiGGhq4KZowNZoH/Sw4pfP0gZ2kYkRupAKkrMH+mVytEOn6kh5BATD/P3AegEdvavzfSDsA==; 3:qwsFD8NpIO1dy4wGtb4DVRZSom0kXnw8kyr+Ef9p/98vE+XdGPp7rXeurb6t6c66een+q2s1IXo2vIzSz0uux/fuIXAnPpPMOj0XT5Xd5w5rllw4UB+DLOisNWgw4iuqRYXKGKGCZ2FYKH7njUihea7RQ6PSxNhaUK74owK39ZnhgCOU012HfyMz0u/xNgtqYaoqixcvO1uSizYS4oUz9xxpzrGr5DkX5VifNLJXhfw=; 25:MQwQzf8IdguHzUUCx23qp+HluMk+oCDU3wmdItK4HdETatXBDw7ewYa61bqbST1Y7qmOA9IvuQ1mND9LxM1e7IFGAS5V1NJRme7eFTT0+eua/IQtOPkx7+ILB4syudPdWM3kV2IAiKqWbXG3YOUhnRBELlNsR8pJBUsFIxuxz3nikvb2ubt687UD5oBA62/UqVBOIXqlvD/fq1RgaK1MRYzKwqE/ruFjNv3MWUm/57WtT+rZkXsEP4tceRSWjf3OKTk5uyidNuS/1EWxDS0YDg==; 20:oWfH46Nk2uxBWIXyz0g3/bNp4c/f3UxX9Hm1Y0OaPD19uOpL2PFgll8Og1kmqyYBBDcK25I6W+TfVyFThU5bJCh3UdcHFOk08Z7CZCmmt5NYWSoEH5gBJE//FyjOMGFLQPwISNawn/LORrMer8aIl8+OcmagEcrsK2c5dQ6S3OM= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AMSPR02MB182; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(121898900299872)(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046); SRVR:AMSPR02MB182; BCL:0; PCL:0; RULEID:; SRVR:AMSPR02MB182; X-Microsoft-Exchange-Diagnostics: 1; AMSPR02MB182; 4:qmKWBiHp3V6Q8C59cuEqlbxiNbVzdjtK7UbJ6NWaonAd+0T3hJ2KyWiTzlDcJLzMWD9GAtn67ojrSBX7ZfnoH1z8iEGdC46DEGs2S5o/szE5u/5yUe/6jcmcCJ7CkJStscGSiueLDahJc/JAJW9NDE8wvN8NfJ8H8jaXYxYHh4tWelnmXBN+ULLCg13RrSJeQ0JaASxmPnmoWzz4pE8+K5pR4kgQZcHBGTPkDhlwiNHkZpElPhfn2n0CppJWSD2X/ljrif371J84yAoy3piFRQn9ExmYa8Ks1WGy9ZA8F/Ay3fpPtVbIu2JEhAwIV6PfCWA5+fGRE2bk5lluhwZCGIN90fXTu6cXs7TojwXPKwsBEg41jBYkKcSfDr/WUOaIFxpKT5lu6JGs6zq/Cg38krcyoQtYN862s0Z5UfnEFiQP5kWzND9cet0WzkAxu1uwnvLm9JISF/c60wCoTTssGA== X-Forefront-PRVS: 07778E4001 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AMSPR02MB182; 23:T7WsjoAji/eHXR6DVO59eK6Ur17y7TI+13y6LOJTc9?= =?us-ascii?Q?OjLyDdoYRV3MDnJSQgQwMhNEyYtbYppjAPvfb9DQaJr760odGos1OfcuFonq?= =?us-ascii?Q?9MDzE0g3ajybHBXBJaCbVqwpTraCOMTTV6ys/HARf8qN1RTMDI2brtPv1IBt?= =?us-ascii?Q?bByFxeHQyZ8W/NkdnLHn+nOAu29KNYKWJN3fgXxYJPoqptAOJcs/6T/JglKt?= =?us-ascii?Q?9XcDt6gwxfFnOCZYotpnlxFDvWnbkh/X8G9SwkdMSP+nfRhfCEKiMR2eujku?= =?us-ascii?Q?h19UZxsZ9N3omZ1y1zizsrmasc/TgtEOMN52BwxL7mt3UDGbuNa/v8kyo1s9?= =?us-ascii?Q?kr+z2n1d3SxA8pij+g6P+UxwWGd2rsWPyXSfxIYgZ1updXhfkYxIM61wTq5r?= =?us-ascii?Q?UE/CMLDgXaRYF5yrX9QpknFqVyqAUPRwOwBuzYyiOFADEqAekVY7j/gpwpau?= =?us-ascii?Q?9w9j1IPyeXlLwHt0zo/miv4OYUlX5hIYzb4N3l95ZZUVJ4/KcdL0U3SYIRfp?= =?us-ascii?Q?HzLDGVPt02r+vX/UKOr1j4r3ayj8zmMzjV/EGwxptDG/YV4LUArq8BM3fzzH?= =?us-ascii?Q?KFYDtMt18U+bVHoj8VOt5/wcmAj2TMVReqVX7Kl3rF3zFxAJCK4Rvv8k3PWJ?= =?us-ascii?Q?htf3yNFyCZKR106WtiRv/5VlmEznjZGj7hLckGHMfRf2gYLObzfSb2xYViqf?= =?us-ascii?Q?fmAjWBVUYA+XHPAvkXJ+Ymj3fZyscsyrSpkHjgIaM8z/diD+aEwfsuFnVnwk?= =?us-ascii?Q?gt61QHFUYXcs/G20cAq4wWcqp4wTr08zVvheEcOlcoZMfv7FCDYl2oeu+oqB?= =?us-ascii?Q?bMfXpKvFsa8TZmD6LBn546SyAM3skyKLiBzUGwRfpjavgMUMidqsTIVBBUXL?= =?us-ascii?Q?JrB60OmsATCffSHov22ELlUPer5YYMhPabxlhPVt6VOv6z8iLA1d0XM2X/L0?= =?us-ascii?Q?K66zFNe6//n49lC2b5GjqfvsMubzmHkzZx2ChB/qrFtqDl9EozrsLhZrlrlR?= =?us-ascii?Q?3bIOPb1CUYdKhS3WVvVRTPANby+JRH5yeq4ltQ1KuhT//Q7smp8ukDF5Ur9c?= =?us-ascii?Q?31zTE=3D?= X-Microsoft-Exchange-Diagnostics: 1; AMSPR02MB182; 5:Cb1VgcQa19tVY3kAVlbVTkLzlc44JqVXGu+ba99Scm5n4q9dbcSr68MNtb2eHSj78P6M7wI66gsRQSnxu73yM4liIX1ZHMuMP6XrxT3Gs10gQcqMYkbNgtNgnk82ATjsYPrPIUmM29XuFyZEuMmi2w==; 24:9E7Kg0pvZZ9uvpN3A7x1AY+EAGrqF5ermAq/3CDVmEZ2EKvspgan6fU9WWrUeQiQ4ZP38FTJmbuYVaIh0fANAhmB/VGmSok/1odD5ymph0U= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2015 13:05:57.2664 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3; Ip=[212.179.42.66]; Helo=[ezex10.ezchip.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR02MB182 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151201_050623_014296_1F2FCE27 X-CRM114-Status: GOOD ( 17.33 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [157.55.234.63 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [157.55.234.63 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] 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: Jason Cooper , Marc Zyngier , linux-kernel@vger.kernel.org, cmetcalf@ezchip.com, Noam Camus , Thomas Gleixner 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/Makefile | 1 + drivers/irqchip/irq-eznps.c | 213 ++++++++++++++++++++ 3 files changed, 231 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/Makefile b/drivers/irqchip/Makefile index 177f78f..b95b954 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_ARC_PLAT_EZNPS) += irq-eznps.o diff --git a/drivers/irqchip/irq-eznps.c b/drivers/irqchip/irq-eznps.c new file mode 100644 index 0000000..bb8d547 --- /dev/null +++ b/drivers/irqchip/irq-eznps.c @@ -0,0 +1,213 @@ +/* + * Copyright(c) 2015 EZchip Technologies. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * The full GNU General Public License is included in this distribution in + * the file called "COPYING". + */ + +#include +#include +#include +#include +#include +#include +#include + +#define NPS_MSU_EN_CFG 0x80 /* MSU Enable Configuration Register */ +#define MSU_EN BIT(0) /* MSU block enable */ +#define IPI_EN BIT(16) /* Enable service of incoming IPI Messages */ +#define GIM0_EN BIT(17) /* Enable service of incoming GIM 0 messages */ +#define GIM1_EN BIT(18) /* Enable service of incoming GIM 1 messages */ + +#define NPS_GIM_P_POL 0x110 /* Peripheral interrupts source polarity */ +#define NPS_GIM_P_SENS 0x114 /* Peripheral interrupts sensitivity */ +#define GIM_UART BIT(7) +#define GIM_LAN_TX (BIT(10) | BIT(25)) +#define GIM_LAN_RX (BIT(11) | BIT(26)) +#define GIM_PERIPH_ALL (GIM_UART | GIM_LAN_TX | GIM_LAN_RX) + +#define NPS_GIM_P_DST10 0x13A /* Peripheral Interrupt Destination (LAN RX) */ +#define NPS_GIM_P_DST11 0x13B /* Peripheral Interrupt Destination (LAN TX) */ +#define NPS_GIM_P_DST25 0x149 /* Peripheral Interrupt Destination (LAN RX) */ +#define NPS_GIM_P_DST26 0x14A /* Peripheral Interrupt Destination (LAN TX) */ +#define DST_IS BIT(26) /* Interrupt select for line 7 */ + +#define NPS_GIM_P_EN 0x100 /* Peripheral interrupts source enable */ +#define NPS_GIM_P_BLK 0x118 /* Peripheral interrupts blocking for sources */ + +/* Messaging and Scheduling Unit: + * Provides message management for a CPU cluster. + */ +static void __init eznps_configure_msu(void) +{ + int cpu; + u32 value = MSU_EN | IPI_EN | GIM0_EN | GIM1_EN; + + /* Enable IPI and GIM messages on all clusters */ + for (cpu = 0 ; cpu < eznps_max_cpus; cpu += eznps_cpus_per_cluster) + iowrite32be(value, + nps_host_reg(cpu, NPS_MSU_BLKID, NPS_MSU_EN_CFG)); +} + +/* Global Interrupt Manager: + * Configures and manages up to 64 interrupts from peripherals, + * 16 interrupts from CPUs (virtual interrupts) and ECC interrupts. + * Receives the interrupts and transmits them to relevant CPU. + */ +static void __init eznps_configure_gim(void) +{ + u32 reg_addr, reg_val; + + /* IRQ polarity, low or high level, negative or positive edge */ + reg_addr = nps_host_reg_non_cl(NPS_GIM_BLKID, NPS_GIM_P_POL); + reg_val = ioread32be(reg_addr); + reg_val &= ~GIM_PERIPH_ALL; + iowrite32be(reg_val, reg_addr); + + /* IRQ type level or edge */ + reg_addr = nps_host_reg_non_cl(NPS_GIM_BLKID, NPS_GIM_P_SENS); + reg_val = ioread32be(reg_addr); + reg_val |= GIM_LAN_TX; + iowrite32be(reg_val, reg_addr); + + /* GIM interrupt select type for debug LAN interrupts (both sides) */ + reg_val = DST_IS; + reg_addr = nps_host_reg_non_cl(NPS_GIM_BLKID, NPS_GIM_P_DST10); + iowrite32be(reg_val, reg_addr); + reg_addr = nps_host_reg_non_cl(NPS_GIM_BLKID, NPS_GIM_P_DST11); + iowrite32be(reg_val, reg_addr); + reg_addr = nps_host_reg_non_cl(NPS_GIM_BLKID, NPS_GIM_P_DST25); + iowrite32be(reg_val, reg_addr); + reg_addr = nps_host_reg_non_cl(NPS_GIM_BLKID, NPS_GIM_P_DST26); + iowrite32be(reg_val, reg_addr); + + /* CTOP IRQ lines should be defined as blocking in GIM */ + iowrite32be(GIM_PERIPH_ALL, + nps_host_reg_non_cl(NPS_GIM_BLKID, NPS_GIM_P_BLK)); + + /* Enable CTOP IRQ lines in GIM */ + iowrite32be(GIM_PERIPH_ALL, + nps_host_reg_non_cl(NPS_GIM_BLKID, NPS_GIM_P_EN)); +} + +/* + * NPS400 core includes a 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 *data) +{ + unsigned int ienb; + + ienb = read_aux_reg(AUX_IENABLE); + ienb &= ~(1 << data->hwirq); + write_aux_reg(AUX_IENABLE, ienb); +} + +static void nps400_irq_unmask(struct irq_data *data) +{ + unsigned int ienb; + + ienb = read_aux_reg(AUX_IENABLE); + ienb |= (1 << data->hwirq); + write_aux_reg(AUX_IENABLE, ienb); +} + +static void nps400_irq_eoi_global(struct irq_data *data) +{ + write_aux_reg(CTOP_AUX_IACK, 1 << data->hwirq); + + /* Don't ack before all device access is done */ + mb(); + + __asm__ __volatile__ ( + " .word %0\n" + : + : "i"(CTOP_INST_RSPI_GIC_0_R12) + : "memory"); +} + +static void nps400_irq_eoi(struct irq_data *data) +{ + write_aux_reg(CTOP_AUX_IACK, 1 << data->hwirq); +} + + +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 irq, + irq_hw_number_t hw) +{ + switch (irq) { + case TIMER0_IRQ: +#if defined(CONFIG_SMP) + case IPI_IRQ: +#endif + irq_set_chip_and_handler(irq, &nps400_irq_chip_percpu, + handle_percpu_irq); + break; + default: + irq_set_chip_and_handler(irq, &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 struct irq_domain *nps400_root_domain; + +static int __init nps400_of_init(struct device_node *node, + struct device_node *parent) +{ + if (parent) + panic("DeviceTree incore ic not a root irq controller\n"); + + eznps_configure_msu(); + eznps_configure_gim(); + + nps400_root_domain = irq_domain_add_legacy(node, NR_CPU_IRQS, 0, 0, + &nps400_irq_ops, NULL); + + if (!nps400_root_domain) + panic("nps400 root irq domain not avail\n"); + + /* with this we don't need to export nps400_root_domain */ + irq_set_default_host(nps400_root_domain); + + return 0; +} +IRQCHIP_DECLARE(ezchip_nps400_ic, "ezchip,nps400-ic", nps400_of_init);