From patchwork Fri Jul 31 21:33:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 6919801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7062DC05AC for ; Fri, 31 Jul 2015 21:37:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C2CC2045E for ; Fri, 31 Jul 2015 21:37:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C8E7E20453 for ; Fri, 31 Jul 2015 21:37:05 +0000 (UTC) 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 1ZLHxU-0005ep-7A; Fri, 31 Jul 2015 21:35:16 +0000 Received: from mail-bl2on0736.outbound.protection.outlook.com ([2a01:111:f400:fc09::736] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZLHx9-0004cL-LN for linux-arm-kernel@lists.infradead.org; Fri, 31 Jul 2015 21:34:58 +0000 Received: from DM2PR03CA0042.namprd03.prod.outlook.com (10.141.96.41) by BY1PR03MB1370.namprd03.prod.outlook.com (10.162.109.28) with Microsoft SMTP Server (TLS) id 15.1.225.19; Fri, 31 Jul 2015 21:34:32 +0000 Received: from BN1AFFO11FD050.protection.gbl (2a01:111:f400:7c10::167) by DM2PR03CA0042.outlook.office365.com (2a01:111:e400:2428::41) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Fri, 31 Jul 2015 21:34:32 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD050.mail.protection.outlook.com (10.58.53.65) with Microsoft SMTP Server (TLS) id 15.1.231.11 via Frontend Transport; Fri, 31 Jul 2015 21:34:31 +0000 Received: from [az84smr01.freescale.net (B38339-11.am.freescale.net [10.81.93.199]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t6VLY9h9028985; Fri, 31 Jul 2015 14:34:30 -0700 From: Shenwei Wang To: , , Subject: [PATCH v8 1/2] irqchip: imx-gpcv2: IMX GPCv2 driver for wakeup sources Date: Fri, 31 Jul 2015 16:33:58 -0500 Message-ID: <1438378439-11569-2-git-send-email-shenwei.wang@freescale.com> X-Mailer: git-send-email 2.5.0.rc2 In-Reply-To: <1438378439-11569-1-git-send-email-shenwei.wang@freescale.com> References: <1438378439-11569-1-git-send-email-shenwei.wang@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD050; 1:gj4Bq/P5bntxQy4cbgcObhDhJH+4xMiTlVLkX0VpgN7j2kxYbQG+nVKxa9EVejXrmG/gORN9VpyWJTt9cNBbAt3s6Wx8ewpg4Yze+4C5WwTOVDLRx4Pelz6FP+xbeTwq6HmAMoiSLuTpWjiGlvbKS+090HwZ5Iy23rtE2V9//a4ArsIzCSWviF+h4re2P5mXviBjtld+2TogqZCk7p9oxQL0w0zYO+bGDXSuBq+HMZ3WgoCRkkP2nULDA2bDLIWArp+mGcDEbPCtTPmDSMr81ZmXxTIR1yUyjjFN8+FNQJbsA76qW6IYbeS9etOP2fqesQ1Jd6TPiGC8HtGhWEEobQ== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(104016003)(5001770100001)(575784001)(107886002)(48376002)(106466001)(105606002)(5001960100002)(19580405001)(92566002)(229853001)(62966003)(86362001)(87936001)(2201001)(36756003)(19580395003)(6806004)(77156002)(46102003)(50466002)(189998001)(77096005)(2950100001)(47776003)(50986999)(33646002)(76176999)(85426001)(50226001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR03MB1370; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1370; 2:Arj5r223KDwDCHP/l7z7I5y2oreV9WXL2ZIyshklxt7xM8bLCD8WpZvo8Bkqj0wSdbz9KaFc20Sw+nH9PBqu+vQSlJI/LfA8C3wPFFQYG9qRHPmu/5eDiiZmteeHdGMtKvwzRC5hsLY8daxHRjhK5kynSVKCmLvEIlkJy33qCxY=; 3:PQicuY8yTD6fIVg95tSELRdebUelBU4d4CBXLU8ejv6Uld3qODgFoKxWb+ZaQMmEA3s+gGMhje+OPGb8qZq+LYkEeu6CBUPMJZe5nWJvcgv2tmlBd8gEjFbiQWhfQaT+j25Dkk4OP5moFMqTaRkwloLBL+aaEHxVanfwn+vgJ3X2jVmytTQIM5cuvTzZZ0tfS6WHwvVwFON+9rgmX6m4kv7agdDp1tEMhclVyn4YMTg=; 25:QtP6qrjbMGVPXjcCgHxnHcpp/75DBQLTX4QNJwIannP46BfMkFmW68QJxaTX+CJCHqtpN5Q4KIzraI2dtO9/0DCBNYybZV1crJHnwSZLwHJtSVthh9BGzqU79xIXLB6GEPNkO9J/ohQsxrbJ5hBgYDlVS2ArWoGT3ayw5o09vdWs3Xx3bte/HtD19LEuPMcuosKo0w1QzElgHMX4rKIqHshvBAthe3ZdMyUZGmo1zELo4QYYh8YtqZygviXif91c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1370; X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1370; 20:+wMlfo4mw7mwDNPumwpucJ+FvB2wk473J+zRuDP9j1tt4Fzqzp8tEck96MwzMFxPn8detnwriNqJo9KYxbYbd6PfPJgprHTRdWPT6QiIGocQO1r5ag+h/wEgAt7W6gd4/CCLSWlmxmfF+38txcFrhv7wBJogarfTiNAEh9Jfj6F4PrxzsgSDu7ytlmJqjDJVASV0s4azhgTkwqSBehgF8OqFOczug8pToVB+P2AU5uE4Dsp71fJnbucrF8GRILdvRX/kYLnCFKDRj7Vm0Os1QhtwSoEMeQQAwMkFX3YpZugL5vCAIIecgm5LITdmHy9UMeAL3SFwUTPppgdott1g6pDcF2g2+yBIlGx7anHGwaM=; 4:PTomk6HbHQdm9vjYOBPZylvj3Ko3AQxenyMQci6hUB1Wp5f/43LrN5cx82hQ3ooCs4QpuYD0EMcqUpXBIaudS9YEIIgeBM0M79Zlipj4hZf3BSseAANYjYnbkmPND3PhIICo81w/dgYDMeMjDUdHb5+06HtmN5x2ejGcd7uue29KyPL82IO0bgbV9WATycy2kfj0A0m3bnqKcYYFkAZVyNMv+iGW4U/RafZjpSjZtNLIKIB0eW7QC9Z2N4RTbzAlOkwfsrKYERPu1GTvajlQ5JolEb8HIBmt/q02pJ87oy8= BY1PR03MB1370: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BY1PR03MB1370; BCL:0; PCL:0; RULEID:; SRVR:BY1PR03MB1370; X-Forefront-PRVS: 0654257CF5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR03MB1370; 23:oCgePvzIaMsL4IRdIH/v0ouKOp2bPZn+Y0V0nKkLl?= =?us-ascii?Q?hT7XGEllYejskmJYbVYVOnyzB/vUabEf7BHmPahWrk8napk6NIJJUGQHZz8D?= =?us-ascii?Q?eFioZ3lfCrqWeBdXH/aQfz0rT7aQ/5UZucWcL4ZMSx6gEFa4dlMvNkHribNT?= =?us-ascii?Q?JCkGkDkIfwpiPSsf34NmuKBULQU5VzjOG0+gOnpVaeIACE++ErEYs/z87BZr?= =?us-ascii?Q?xVbWQQH/swcTq0YC0ZNq1y+HfRZ/fk+8v8LgkOCApqywj8g3TSsFSu/oT2gI?= =?us-ascii?Q?JJ1gz0J1ooGwGgTQaIUnyyXW29L1P6lYzmLtmP0OAUVqXs/M1az3caeEoVNV?= =?us-ascii?Q?fQh7iAJ8hLAKU3afTfecwxgs3LNScX3enWDNYBDvt4J8pPNgxC4wHOLZNmXO?= =?us-ascii?Q?eY0cgNze7R0QGzkZY/Stn76C7tmbkObcBX8Wahx6gM8f4Um07f9w+c06RJ/m?= =?us-ascii?Q?Zstf8XLvkvvAYvJsA8vv3UGnN4FLtgV5YqUIJ8dEgNWU1rX7jSq5lo3fp77R?= =?us-ascii?Q?gzHfkZYwA0c0O8ogOty5FvScdm42SQzEs0pUTpYxR71U6RKi2uFUO/S4YZqq?= =?us-ascii?Q?RMWHeKtJkelJfSNp6erbtzjwl8Kz329U2dwqgmc6tphwv3HL0/PAZhcAsKJv?= =?us-ascii?Q?Ykzg/DFQToOoZqjugRzTjXTcKOWn3fRK4ei+zeHLsl4TdR+TOd0MHxaSGCD6?= =?us-ascii?Q?Voa3eE0i6OjWFPh4EjStQgpbFEv24mjPn13vRMlt9I6VTt+tE6lFFH0DhFub?= =?us-ascii?Q?VmX9tRm+gqp1EmQNhuS/pl4g5qO4Gd1lIpHAJiAPg1KvMseL0IrNsyIO/M1f?= =?us-ascii?Q?cr/1+Xqth17mas9sPBEWF7jK+TcoOboy9qWNUvum0knbyIXXEV+1G03NZ5H1?= =?us-ascii?Q?5FSrLnScHfiFg9H5GjdqMtH1VqWirfLgGeDeKDi67ojQlu6PHs4ORxJwTnn5?= =?us-ascii?Q?tJBbzg5GIMVcRspkh+h13YZNjpNoINYfrtQXvDBnQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1370; 5:VF4Quc5IRxEI4PEopnnwk9Las091+lMBD2yPOawuVMAyWeGLZf+EhrglhadkyNkjdHpD0o/QePHHK6t8NBWvMktexSiIdvARiaZRFLlmxQO7PvESHHtbGZNlylOqlwdhCt+0zzK7YEl4mnO51JwbmQ==; 24:d1lKiEWbKqhKt3+bNhaK0ua2tIGtwhyk8G7hSm9c74OKVqX7reTnqPE5tUOSYp2Lo9Sa0fbdgPVuo69XJutIgGr4K352vvKpkPB0oIwHXC0=; 20:dkt9KZEuR1Jrb5SPEJ6L+d7TYtIlZ+kOUKGH38zlJ+GlTTAqi/TrRBmVAP0ZqhGse/Hm/HZ7iu1RwNUQzFb4SA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2015 21:34:31.5064 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1370 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150731_143456_121397_3E4DBE59 X-CRM114-Status: GOOD ( 28.11 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: b20788@freescale.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP IMX7D contains a new version of GPC IP block (GPCv2). It has two major functions: power management and wakeup source management. This patch adds a new irqchip driver to manage the interrupt wakeup sources on IMX7D. When the system is in WFI (wait for interrupt) mode, this GPC block will be the first block on the platform to be activated and signaled. Under normal wait mode during cpu idle, the system can be woke up by any enabled interrupts. Under standby or suspend mode, the system can only be woke up by the pre-defined wakeup sources. Signed-off-by: Shenwei Wang Signed-off-by: Anson Huang --- drivers/irqchip/Kconfig | 7 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-imx-gpcv2.c | 273 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 281 insertions(+) create mode 100644 drivers/irqchip/irq-imx-gpcv2.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 120d815..3fc0fac 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -177,3 +177,10 @@ config RENESAS_H8300H_INTC config RENESAS_H8S_INTC bool select IRQ_DOMAIN + +config IMX_GPCV2 + bool + select IRQ_DOMAIN + help + Enables the wakeup IRQs for IMX platforms with GPCv2 block + diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index b8d4e96..8eb5f60 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -52,3 +52,4 @@ obj-$(CONFIG_RENESAS_H8300H_INTC) += irq-renesas-h8300h.o 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 diff --git a/drivers/irqchip/irq-imx-gpcv2.c b/drivers/irqchip/irq-imx-gpcv2.c new file mode 100644 index 0000000..c2728b0 --- /dev/null +++ b/drivers/irqchip/irq-imx-gpcv2.c @@ -0,0 +1,273 @@ +/* + * Copyright (C) 2015 Freescale Semiconductor, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#define IMR_NUM 4 +#define GPC_MAX_IRQS (IMR_NUM * 32) + +#define GPC_IMR1_CORE0 0x30 +#define GPC_IMR1_CORE1 0x40 + +struct gpcv2_irqchip_data { + struct raw_spinlock rlock; + void __iomem *gpc_base; + u32 wakeup_sources[IMR_NUM]; + u32 enabled_irqs[IMR_NUM]; + u32 cpu2wakeup; +}; + +static struct gpcv2_irqchip_data *imx_gpcv2_instance; + +u32 imx_gpcv2_get_wakeup_source(u32 **sources) +{ + if (!imx_gpcv2_instance) + return 0; + + if (sources) + *sources = imx_gpcv2_instance->wakeup_sources; + + return IMR_NUM; +} + +static int gpcv2_wakeup_source_save(void) +{ + struct gpcv2_irqchip_data *cd; + void __iomem *reg; + int i; + + cd = imx_gpcv2_instance; + if (!cd) + return 0; + + for (i = 0; i < IMR_NUM; i++) { + reg = cd->gpc_base + cd->cpu2wakeup + i * 4; + cd->enabled_irqs[i] = readl_relaxed(reg); + writel_relaxed(cd->wakeup_sources[i], reg); + } + + return 0; +} + +static void gpcv2_wakeup_source_restore(void) +{ + struct gpcv2_irqchip_data *cd; + void __iomem *reg; + int i; + + cd = imx_gpcv2_instance; + if (!cd) + return; + + for (i = 0; i < IMR_NUM; i++) { + reg = cd->gpc_base + cd->cpu2wakeup + i * 4; + writel_relaxed(cd->enabled_irqs[i], reg); + cd->wakeup_sources[i] = ~0; + } +} + +static struct syscore_ops imx_gpcv2_syscore_ops = { + .suspend = gpcv2_wakeup_source_save, + .resume = gpcv2_wakeup_source_restore, +}; + +static int imx_gpcv2_irq_set_wake(struct irq_data *d, unsigned int on) +{ + struct gpcv2_irqchip_data *cd = d->chip_data; + unsigned int idx = d->hwirq / 32; + unsigned long flags; + void __iomem *reg; + u32 mask, val; + + raw_spin_lock_irqsave(&cd->rlock, flags); + reg = cd->gpc_base + cd->cpu2wakeup + idx * 4; + mask = 1 << d->hwirq % 32; + val = cd->wakeup_sources[idx]; + + cd->wakeup_sources[idx] = on ? (val & ~mask) : (val | mask); + raw_spin_unlock_irqrestore(&cd->rlock, flags); + + /* + * Do *not* call into the parent, as the GIC doesn't have any + * wake-up facility... + */ + + return 0; +} + +static void imx_gpcv2_irq_unmask(struct irq_data *d) +{ + struct gpcv2_irqchip_data *cd = d->chip_data; + void __iomem *reg; + u32 val; + + raw_spin_lock(&cd->rlock); + reg = cd->gpc_base + cd->cpu2wakeup + d->hwirq / 32 * 4; + val = readl_relaxed(reg); + val &= ~(1 << d->hwirq % 32); + writel_relaxed(val, reg); + raw_spin_unlock(&cd->rlock); + + irq_chip_unmask_parent(d); +} + +static void imx_gpcv2_irq_mask(struct irq_data *d) +{ + struct gpcv2_irqchip_data *cd = d->chip_data; + void __iomem *reg; + u32 val; + + raw_spin_lock(&cd->rlock); + reg = cd->gpc_base + cd->cpu2wakeup + d->hwirq / 32 * 4; + val = readl_relaxed(reg); + val |= 1 << (d->hwirq % 32); + writel_relaxed(val, reg); + raw_spin_unlock(&cd->rlock); + + irq_chip_mask_parent(d); +} + +static struct irq_chip gpcv2_irqchip_data_chip = { + .name = "GPCv2", + .irq_eoi = irq_chip_eoi_parent, + .irq_mask = imx_gpcv2_irq_mask, + .irq_unmask = imx_gpcv2_irq_unmask, + .irq_set_wake = imx_gpcv2_irq_set_wake, + .irq_retrigger = irq_chip_retrigger_hierarchy, +#ifdef CONFIG_SMP + .irq_set_affinity = irq_chip_set_affinity_parent, +#endif +}; + +static int imx_gpcv2_domain_xlate(struct irq_domain *domain, + struct device_node *controller, + const u32 *intspec, + unsigned int intsize, + unsigned long *out_hwirq, + unsigned int *out_type) +{ + /* Shouldn't happen, really... */ + if (domain->of_node != controller) + return -EINVAL; + + /* Not GIC compliant */ + if (intsize != 3) + return -EINVAL; + + /* No PPI should point to this domain */ + if (intspec[0] != 0) + return -EINVAL; + + *out_hwirq = intspec[1]; + *out_type = intspec[2]; + return 0; +} + +static int imx_gpcv2_domain_alloc(struct irq_domain *domain, + unsigned int irq, unsigned int nr_irqs, + void *data) +{ + struct of_phandle_args *args = data; + struct of_phandle_args parent_args; + irq_hw_number_t hwirq; + int i; + + /* Not GIC compliant */ + if (args->args_count != 3) + return -EINVAL; + + /* No PPI should point to this domain */ + if (args->args[0] != 0) + return -EINVAL; + + /* Can't deal with this */ + hwirq = args->args[1]; + if (hwirq >= GPC_MAX_IRQS) + return -EINVAL; + + for (i = 0; i < nr_irqs; i++) { + irq_domain_set_hwirq_and_chip(domain, irq + i, hwirq + i, + &gpcv2_irqchip_data_chip, domain->host_data); + } + + parent_args = *args; + parent_args.np = domain->parent->of_node; + return irq_domain_alloc_irqs_parent(domain, irq, nr_irqs, &parent_args); +} + +static struct irq_domain_ops gpcv2_irqchip_data_domain_ops = { + .xlate = imx_gpcv2_domain_xlate, + .alloc = imx_gpcv2_domain_alloc, + .free = irq_domain_free_irqs_common, +}; + +static int __init imx_gpcv2_irqchip_init(struct device_node *node, + struct device_node *parent) +{ + struct irq_domain *parent_domain, *domain; + struct gpcv2_irqchip_data *cd; + int i; + + if (!parent) { + pr_err("%s: no parent, giving up\n", node->full_name); + return -ENODEV; + } + + parent_domain = irq_find_host(parent); + if (!parent_domain) { + pr_err("%s: unable to get parent domain\n", node->full_name); + return -ENXIO; + } + + cd = kzalloc(sizeof(struct gpcv2_irqchip_data), GFP_KERNEL); + BUG_ON(!cd); + + cd->gpc_base = of_iomap(node, 0); + if (!cd->gpc_base) { + pr_err("fsl-gpcv2: unable to map gpc registers\n"); + kfree(cd); + return -ENOMEM; + } + + domain = irq_domain_add_hierarchy(parent_domain, 0, GPC_MAX_IRQS, + node, &gpcv2_irqchip_data_domain_ops, cd); + if (!domain) { + iounmap(cd->gpc_base); + kfree(cd); + return -ENOMEM; + } + irq_set_default_host(domain); + + /* Initially mask all interrupts */ + for (i = 0; i < IMR_NUM; i++) { + writel_relaxed(~0, cd->gpc_base + GPC_IMR1_CORE0 + i * 4); + writel_relaxed(~0, cd->gpc_base + GPC_IMR1_CORE1 + i * 4); + cd->wakeup_sources[i] = ~0; + } + + /* Let CORE0 as the default CPU to wake up by GPC */ + cd->cpu2wakeup = GPC_IMR1_CORE0; + + /* + * Due to hardware design failure, need to make sure GPR + * interrupt(#32) is unmasked during RUN mode to avoid entering + * DSM by mistake. + */ + writel_relaxed(~0x1, cd->gpc_base + cd->cpu2wakeup); + + imx_gpcv2_instance = cd; + register_syscore_ops(&imx_gpcv2_syscore_ops); + + return 0; +} + +IRQCHIP_DECLARE(imx_gpcv2, "fsl,imx7d-gpc", imx_gpcv2_irqchip_init);