Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp63158pxf; Tue, 9 Mar 2021 23:58:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoQY+OTu+37qSqBkVd7hzRZpvf4aTMf9/wh6Dt2OAd4xsN7LrjOG98lSqAUvEasZ7Yjbc4 X-Received: by 2002:a05:6402:1383:: with SMTP id b3mr1859579edv.374.1615363121181; Tue, 09 Mar 2021 23:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615363121; cv=none; d=google.com; s=arc-20160816; b=V0qqKFMDVGTPQpCb5fDGI3/42MH9oSq2l09rHfWi5bTCdBMNg21pM071c6+bk4563z uGQAE30haPRMNU1SWePiABAt+t2z4kgP/NGKQCfwh+/5Ro2lJWtvyuzk76U7V4vcwfxj yIsyEVs3ZE3tQhqUj6aa7tC63W8zev38qb97sQjzIAHLJeSkXBNF+eOFlR6FrKvVx50Q 7vCqCqI8LrjAc77FGubKRK1HlQci7UxsbViXHrhLVZstysxQ9DukZ5WsGpUWKrUudvHq aKrxuYzL+TBYO0F6e0RDHszEZD+82ZYh9nqp5X6amOhbZrJ0MBs58b+ignfy3dnTJ+ts 19lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=H6XM1sTMqTknMTI6PHO50T4deu8ezC/hLJnEaJ/dyVg=; b=Ox7evR1nL5CvT6ZXVwRxd0KEXOjQGqEqSB5d0ccc570z4ash2hLwbHkVNAwOeF02yk cWUfZOGlaOMgOiAzJn6ZdmpcLp0Pt0jE6/P8LrtlWTRaSbCoVQmhc9bZK6YAQD0ZHniV pUVBVv9ya4tQ7ql6SSs5qNGme3+tp9BGk1mSICxxd7IRIUbmbirCnHcQz1dXXX90gQb9 aPfoubDSsupQS5eIRkQYr6cYOq4U3TZPjJ7Q/cjpMDlk4nxo4Y9OLanpKFwcdflvIkCm QKY2i5q6EZZ90n0dHIDIDG2ZnyD4LzVUqrkcVTEpsz3CwwcJh5ifNXzlXKLDZwZylw25 OyhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw1si11864800edb.412.2021.03.09.23.58.18; Tue, 09 Mar 2021 23:58:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231966AbhCJH5S (ORCPT + 99 others); Wed, 10 Mar 2021 02:57:18 -0500 Received: from mail.loongson.cn ([114.242.206.163]:33362 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229851AbhCJH4z (ORCPT ); Wed, 10 Mar 2021 02:56:55 -0500 Received: from localhost.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxn_O3e0hg6KoXAA--.12657S7; Wed, 10 Mar 2021 15:56:47 +0800 (CST) From: Qing Zhang To: Huacai Chen , Jiaxun Yang , Thomas Bogendoerfer , Thomas Gleixner , Marc Zyngier Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Ming Wang Subject: [PATCH v4 5/7] irqchip/loongson-liointc: irqchip add 2.0 version Date: Wed, 10 Mar 2021 15:56:37 +0800 Message-Id: <20210310075639.20372-6-zhangqing@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210310075639.20372-1-zhangqing@loongson.cn> References: <20210310075639.20372-1-zhangqing@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IcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0x vEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvg4hUUUUU= X-CM-SenderInfo: x2kd0wptlqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add IO interrupt controller support for Loongson-2K1000, different from the Loongson-3A series is that 2K1000 has 64 interrupt sources, 0-31 correspond to the device tree liointc0 device node, and the other correspond to liointc1 node. Signed-off-by: Jiaxun Yang Signed-off-by: Qing Zhang Tested-by: Ming Wang --- v3-v4: Standard submission of information drivers/irqchip/irq-loongson-liointc.c | 58 ++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c index 09b91b81851c..33219244c551 100644 --- a/drivers/irqchip/irq-loongson-liointc.c +++ b/drivers/irqchip/irq-loongson-liointc.c @@ -20,6 +20,7 @@ #define LIOINTC_CHIP_IRQ 32 #define LIOINTC_NUM_PARENT 4 +#define LIOINTC_NUM_CORES 4 #define LIOINTC_INTC_CHIP_START 0x20 @@ -42,6 +43,7 @@ struct liointc_handler_data { struct liointc_priv { struct irq_chip_generic *gc; struct liointc_handler_data handler[LIOINTC_NUM_PARENT]; + void __iomem *core_isr[LIOINTC_NUM_CORES]; u8 map_cache[LIOINTC_CHIP_IRQ]; bool has_lpc_irq_errata; }; @@ -51,11 +53,12 @@ static void liointc_chained_handle_irq(struct irq_desc *desc) struct liointc_handler_data *handler = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); struct irq_chip_generic *gc = handler->priv->gc; + int core = get_ebase_cpunum() % LIOINTC_NUM_CORES; u32 pending; chained_irq_enter(chip, desc); - pending = readl(gc->reg_base + LIOINTC_REG_INTC_STATUS); + pending = readl(handler->priv->core_isr[core]); if (!pending) { /* Always blame LPC IRQ if we have that bug */ @@ -141,6 +144,18 @@ static void liointc_resume(struct irq_chip_generic *gc) } static const char * const parent_names[] = {"int0", "int1", "int2", "int3"}; +static const char * const core_reg_names[] = {"isr0", "isr1", "isr2", "isr3"}; + +static void __iomem *liointc_get_reg_byname(struct device_node *node, + const char *name) +{ + int index = of_property_match_string(node, "reg-names", name); + + if (index < 0) + return NULL; + + return of_iomap(node, index); +} static int __init liointc_of_init(struct device_node *node, struct device_node *parent) @@ -159,10 +174,28 @@ static int __init liointc_of_init(struct device_node *node, if (!priv) return -ENOMEM; - base = of_iomap(node, 0); - if (!base) { - err = -ENODEV; - goto out_free_priv; + if (of_device_is_compatible(node, "loongson,liointc-2.0")) { + base = liointc_get_reg_byname(node, "main"); + if (!base) { + err = -ENODEV; + goto out_free_priv; + } + + for (i = 0; i < LIOINTC_NUM_CORES; i++) + priv->core_isr[i] = liointc_get_reg_byname(node, core_reg_names[i]); + if (!priv->core_isr[0]) { + err = -ENODEV; + goto out_iounmap_base; + } + } else { + base = of_iomap(node, 0); + if (!base) { + err = -ENODEV; + goto out_free_priv; + } + + for (i = 0; i < LIOINTC_NUM_CORES; i++) + priv->core_isr[i] = base + LIOINTC_REG_INTC_STATUS; } for (i = 0; i < LIOINTC_NUM_PARENT; i++) { @@ -172,7 +205,7 @@ static int __init liointc_of_init(struct device_node *node, } if (!have_parent) { err = -ENODEV; - goto out_iounmap; + goto out_iounmap_isr; } sz = of_property_read_variable_u32_array(node, @@ -183,7 +216,7 @@ static int __init liointc_of_init(struct device_node *node, if (sz < 4) { pr_err("loongson-liointc: No parent_int_map\n"); err = -ENODEV; - goto out_iounmap; + goto out_iounmap_isr; } for (i = 0; i < LIOINTC_NUM_PARENT; i++) @@ -195,7 +228,7 @@ static int __init liointc_of_init(struct device_node *node, if (!domain) { pr_err("loongson-liointc: cannot add IRQ domain\n"); err = -EINVAL; - goto out_iounmap; + goto out_iounmap_isr; } err = irq_alloc_domain_generic_chips(domain, 32, 1, @@ -260,7 +293,13 @@ static int __init liointc_of_init(struct device_node *node, out_free_domain: irq_domain_remove(domain); -out_iounmap: +out_iounmap_isr: + for (i = 0; i < LIOINTC_NUM_CORES; i++) { + if (!priv->core_isr[i]) + continue; + iounmap(priv->core_isr[i]); + } +out_iounmap_base: iounmap(base); out_free_priv: kfree(priv); @@ -270,3 +309,4 @@ static int __init liointc_of_init(struct device_node *node, IRQCHIP_DECLARE(loongson_liointc_1_0, "loongson,liointc-1.0", liointc_of_init); IRQCHIP_DECLARE(loongson_liointc_1_0a, "loongson,liointc-1.0a", liointc_of_init); +IRQCHIP_DECLARE(loongson_liointc_2_0, "loongson,liointc-2.0", liointc_of_init); -- 2.20.1