Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2766340rwb; Fri, 20 Jan 2023 07:08:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZLQFQKgs5ZaKJA1jydIHJHfmrOevTcnPnBeFfF2m0EKjYAOGNuiwsjzcCPxs9FDyTwNmu X-Received: by 2002:a17:906:f889:b0:86f:c7df:4a63 with SMTP id lg9-20020a170906f88900b0086fc7df4a63mr15175939ejb.56.1674227307848; Fri, 20 Jan 2023 07:08:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674227307; cv=none; d=google.com; s=arc-20160816; b=g3G9/TLBxcEM0p8HDUs3lbQYWFz1FylAlnbL7IjOmFdAYa0O2eKLxkeJJ0nB8cY1RM 4Yhdy4dQMb4QvMSTyTlrExb1nirVC9iHZnBZ4R+w0gkH8f61/uU9EnaLKgTz2GinD6Yw 13Flt/Cm2WXNZE79tvnr2O+voiN2cyDaI+N4z2kzryU9AO/kfEaajSK4gaLoLCjuIdr2 RYvs0QjDsClpc4ZtbA7JQQYrEJTfKxFrKZTFAZjCAaGF0EOkgq5jv73zj0k2Uc+C4Pyp dcnJxRHdYN/0TGfISvuOrdboCniQi4xlinaZwHVu9ZaKG/6FDQHytbNIcDQFz30tqqtx SVYg== 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 :dkim-signature:dkim-filter:secumail-id:dkim-signature; bh=4jvJ7IvD9VlgFq/7Z4UB2wJmPSp4a7HqRY/uj2OjyW4=; b=NEk7tzCmSLxD4xHH5Wiog22l9Jtxj6tKiN50UQbiPJrwAkKp4opuEpToeTSvUbo5D+ Gr5GhjgKIrMsqWkS90fmSgsCf1nS3kbsO+q2z/AMx662beMUwkHQAsypwOkR6e2O6sG7 1/kU7+yjsP+wFV/Lv/0FIKgB2+WDTxIGqeN6XY+6CD6pCO6p28i0PGcnVKhPiJpfkDmg Jw5qBTE1ZYB9O0O22MFeyEbwqB+uXC6HoWYkEzETexe2x8+0BCKE3fy8OvKDzeRFFr0K UguZFBRWNnNG2OIXzYMSI4UT5E5zedcUms/rwAQtevlMTtt5eYhzQAdJA/+Ex4cZFDJ3 TMqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kalray.eu header.s=sec-sig-email header.b=OEAowwf4; dkim=neutral (body hash did not verify) header.i=@kalray.eu header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=FSrUM33I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=kalray.eu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc41-20020a17090716a900b007ae74740fa4si40291463ejc.275.2023.01.20.07.08.14; Fri, 20 Jan 2023 07:08:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kalray.eu header.s=sec-sig-email header.b=OEAowwf4; dkim=neutral (body hash did not verify) header.i=@kalray.eu header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=FSrUM33I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=kalray.eu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231164AbjATO0j (ORCPT + 49 others); Fri, 20 Jan 2023 09:26:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229852AbjATO0T (ORCPT ); Fri, 20 Jan 2023 09:26:19 -0500 Received: from fx408.security-mail.net (smtpout140.security-mail.net [85.31.212.148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2842A7AF03 for ; Fri, 20 Jan 2023 06:25:46 -0800 (PST) Received: from localhost (fx408.security-mail.net [127.0.0.1]) by fx408.security-mail.net (Postfix) with ESMTP id 029E4322A33 for ; Fri, 20 Jan 2023 15:25:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1674224745; bh=C4JX2KDfJMf+kd6dGlNUF/l2OL1SVZPZi+/ckEfH3UU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OEAowwf4PHI9aHodicAZw2OmPCkxNfZ9jczBNGXv9tGymDEannLiE1LP+n9nmqO7+ 1cckPFYv4q6PFzmYhvScsOqu9QykuhINoOX3RAbhMQi3QQnGdmISLPYDox5zSNMbnO qegSyV5aWJrnc3PEAdTLgoFhK+tO7nBwmqbmlamA= Received: from fx408 (fx408.security-mail.net [127.0.0.1]) by fx408.security-mail.net (Postfix) with ESMTP id B5716322547; Fri, 20 Jan 2023 15:25:44 +0100 (CET) Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx408.security-mail.net (Postfix) with ESMTPS id 1C87E322929; Fri, 20 Jan 2023 15:25:44 +0100 (CET) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 2A48827E0437; Fri, 20 Jan 2023 15:10:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 0210427E043D; Fri, 20 Jan 2023 15:10:33 +0100 (CET) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ImWCZZGcWW5W; Fri, 20 Jan 2023 15:10:32 +0100 (CET) Received: from junon.lin.mbt.kalray.eu (unknown [192.168.37.161]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 8995D27E043A; Fri, 20 Jan 2023 15:10:32 +0100 (CET) X-Virus-Scanned: E-securemail Secumail-id: DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 0210427E043D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1674223833; bh=5XXrgrQzCfc4vEIClRHO/5PBD+bYAS7ERJgrp4OCvF8=; h=From:To:Date:Message-Id:MIME-Version; b=FSrUM33In5SGjg9c4LwAoWf/AQZS0QSN3rkfGHBE+hEzpy/Vbg1dnPf32zDa8kKMa MP0vhwj3UfQzIUAbEwlHIAX+q89B2EfKjyUFxpR38io82dkQQDXMofBuaYRqLg7798 JotwpQrZZ+Hy6YLcj2fPGriS/JxTFf2hsIWLvBEE= From: Yann Sionneau To: Arnd Bergmann , Jonathan Corbet , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland , Eric Biederman , Kees Cook , Oleg Nesterov , Ingo Molnar , Waiman Long , "Aneesh Kumar K.V" , Andrew Morton , Nick Piggin , Paul Moore , Eric Paris , Christian Brauner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jules Maselbas , Yann Sionneau , Guillaume Thouvenin , Clement Leger , Vincent Chardon , Marc =?utf-8?b?UG91bGhpw6hz?= , Julian Vetter , Samuel Jones , Ashley Lesdalons , Thomas Costis , Marius Gligor , Jonathan Borne , Julien Villette , Luc Michel , Louis Morhet , Julien Hascoet , Jean-Christophe Pince , Guillaume Missonnier , Alex Michon , Huacai Chen , WANG Xuerui , Shaokun Zhang , John Garry , Guangbin Huang , Bharat Bhushan , Bibo Mao , Atish Patra , "Jason A. Donenfeld" , Qi Liu , Jiaxun Yang , Catalin Marinas , Mark Brown , Janosch Frank , Alexey Dobriyan Cc: Benjamin Mugnier , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-audit@redhat.com, linux-riscv@lists.infradead.org, bpf@vger.kernel.org Subject: [RFC PATCH v2 18/31] irqchip: Add kvx-core-intc core interupt controller driver Date: Fri, 20 Jan 2023 15:09:49 +0100 Message-ID: <20230120141002.2442-19-ysionneau@kalray.eu> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230120141002.2442-1-ysionneau@kalray.eu> References: <20230120141002.2442-1-ysionneau@kalray.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 X-ALTERMIMEV2_out: done X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jules Maselbas Each kvx core includes a hardware interrupt controller (core INTC) with the following features: - 32 independent interrupt sources - 4-bit priotity level - Individual interrupt enable bit - Interrupt status bit displaying the pending interrupts - Priority management between the 32 interrupts Among those 32 interrupt sources, the first are hard-wired to hardware sources. The remaining interrupt sources can be triggered via software by directly writing to the ILR SFR. The hard-wired interrupt sources are the following: 0: Timer 0 1: Timer 1 2: Watchdog 3: Performance Monitors 4: APIC GIC line 0 5: APIC GIC line 1 6: APIC GIC line 2 7: APIC GIC line 3 12: SECC error from memory system 13: Arithmetic exception (carry and IEEE 754 flags) 16: Data Asynchronous Memory Error (DAME), raised for DECC/DSYS errors 17: CLI (Cache Line Invalidation) for L1D or L1I following DECC/DSYS/Parity errors The APIC GIC lines will be used to route interrupts coming from SoC peripherals from outside the Cluster to the kvx core. Those peripherals include USB host controller, eMMC/SD host controller, i2c, spi, PCIe, IOMMUs etc... Co-developed-by: Clement Leger Signed-off-by: Clement Leger Co-developed-by: Julian Vetter Signed-off-by: Julian Vetter Co-developed-by: Vincent Chardon Signed-off-by: Vincent Chardon Co-developed-by: Jules Maselbas Signed-off-by: Jules Maselbas Signed-off-by: Yann Sionneau --- Notes: V1 -> V2: new patch - removed print on probe success drivers/irqchip/Kconfig | 5 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-kvx-core-intc.c | 80 +++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 drivers/irqchip/irq-kvx-core-intc.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 806adbc7b2a4..d242e02771e3 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -334,6 +334,11 @@ config MIPS_GIC select IRQ_DOMAIN_HIERARCHY select MIPS_CM +config KVX_CORE_INTC + bool + depends on KVX + select IRQ_DOMAIN + config KVX_APIC_GIC bool depends on KVX diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 7eaea87ca9ab..d931f2eb38b6 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -69,6 +69,7 @@ obj-$(CONFIG_BCM7120_L2_IRQ) += irq-bcm7120-l2.o obj-$(CONFIG_BRCMSTB_L2_IRQ) += irq-brcmstb-l2.o obj-$(CONFIG_KEYSTONE_IRQ) += irq-keystone.o obj-$(CONFIG_MIPS_GIC) += irq-mips-gic.o +obj-$(CONFIG_KVX_CORE_INTC) += irq-kvx-core-intc.o obj-$(CONFIG_KVX_APIC_GIC) += irq-kvx-apic-gic.o obj-$(CONFIG_KVX_ITGEN) += irq-kvx-itgen.o obj-$(CONFIG_KVX_APIC_MAILBOX) += irq-kvx-apic-mailbox.o diff --git a/drivers/irqchip/irq-kvx-core-intc.c b/drivers/irqchip/irq-kvx-core-intc.c new file mode 100644 index 000000000000..145f1248925b --- /dev/null +++ b/drivers/irqchip/irq-kvx-core-intc.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2017-2023 Kalray Inc. + * Author(s): Clement Leger + */ + +#define pr_fmt(fmt) "kvx_core_intc: " fmt + +#include +#include +#include +#include +#include +#include +#include + +#define KVX_CORE_INTC_IRQ 32 + + +static void kvx_irq_mask(struct irq_data *data) +{ + kvx_sfr_clear_bit(ILE, data->hwirq); +} + +static void kvx_irq_unmask(struct irq_data *data) +{ + kvx_sfr_set_bit(ILE, data->hwirq); +} + +static struct irq_chip kvx_irq_chip = { + .name = "kvx core Intc", + .irq_mask = kvx_irq_mask, + .irq_unmask = kvx_irq_unmask, +}; + +static int kvx_irq_map(struct irq_domain *d, unsigned int irq, + irq_hw_number_t hw) +{ + /* All interrupts for core are per cpu */ + irq_set_percpu_devid(irq); + irq_set_chip_and_handler(irq, &kvx_irq_chip, handle_percpu_irq); + + return 0; +} + +static const struct irq_domain_ops kvx_irq_ops = { + .xlate = irq_domain_xlate_onecell, + .map = kvx_irq_map, +}; + +static int __init +kvx_init_core_intc(struct device_node *intc, struct device_node *parent) +{ + struct irq_domain *root_domain; + uint32_t core_nr_irqs; + + if (parent) + panic("DeviceTree core intc not a root irq controller\n"); + + if (of_property_read_u32(intc, "kalray,intc-nr-irqs", &core_nr_irqs)) + core_nr_irqs = KVX_CORE_INTC_IRQ; + + /* We only have up to 32 interrupts, according to IRQ-domain.txt, + * linear is likely to be the best choice + */ + root_domain = irq_domain_add_linear(intc, core_nr_irqs, + &kvx_irq_ops, NULL); + if (!root_domain) + panic("root irq domain not avail\n"); + + /* + * Needed for primary domain lookup to succeed + * This is a primary irqchip, and can never have a parent + */ + irq_set_default_host(root_domain); + + return 0; +} + +IRQCHIP_DECLARE(kvx_core_intc, "kalray,kvx-core-intc", kvx_init_core_intc); -- 2.37.2