From patchwork Tue Oct 22 04:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13845077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE0EAD1715D for ; Tue, 22 Oct 2024 04:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mqD4gjq9EtfuWfMKrqbD+ligcOZAE1ZVSILHqKX+Ues=; b=bsT8S1be0wqBTG gxAvOgnTtxJ6rUWPNdtbO1aQQCZ6vW0DlKGfcx7pkSm2z9chrFPE4f0rphDWNf1dvu2/Wm8GpKmDb IWX/FJuH6ZxvwU+p6pUaAu9qoMuwPFZrYL78DRkVKkzzH0JpAS9GPALw+s9f3uTGdchvRoT3K2Ks0 R1wpPldZyQ7WS9ABC/LESd6a1cNnfk12ZOb5GjpoEvsG4QmIvwhpPrHJWVd6b0eQq3PWha8KpieDj T7+XX8WwJ2U9pUhGFNJ2vNWDTLILQh9ma0G9KmLK/vms+qrlQzITyupauz5UXks/h8/Vd/Pl8m+IA rBuB/NfwT2L44AOhdj5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t366Y-00000009WJ5-3eWL; Tue, 22 Oct 2024 04:02:46 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t366V-00000009WHU-1pX9 for linux-riscv@lists.infradead.org; Tue, 22 Oct 2024 04:02:44 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-71e49ef3b2bso3676543b3a.2 for ; Mon, 21 Oct 2024 21:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729569762; x=1730174562; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ESpVDdqvWArJZ/zn9KV45HICoQoUKaqzB0C6fhXH0e8=; b=e4nXsZtNIxXTEj7KBVbVif+ZIvJLPBI4mri1SsrauiEJludIK9jGoFdXaAFIgQMPdo JSUt9FAkb53HQh+bM8e/MQzIbdKhH7U1yV3JdfosVUQSmEnAWKiZW0nxvIDEaSzUwuCy 0BE0SfLghwQPxA1AP1xoUP1kajwLZUrN2qXg2WHSbq3Sa4HmrIh0HrjXCXjwTjI8XLL8 TSl/TWw52xS0ecK6kkRJR7dJV3m1sOWPClQjXzMr4F6XHdWZmli9yNeD7zVbPRNZCwXp UCN2dpMd6lAmuFSGIUME0TsYiWLRSbfBwSD8Zr0jhjKUaNgOhA4MCWnw7vjwthvRFbHZ O9MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729569762; x=1730174562; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ESpVDdqvWArJZ/zn9KV45HICoQoUKaqzB0C6fhXH0e8=; b=SJFE+tYjMpqc9DrnnOiwo3hxzpDbs5AqtsVBPq49qSmHGBbjhY3rI7DIjtYlBu9tYe 8rKINjwqVjRIHe/qhQV3KhlBEdMbWLcJvuF7BoB9vl9VgWojB0EGKZqVlRr9cefiMIBN WH5n0fYfIXaj/FFu4yuERGIBVLg9h0SaZvEUWZVsKA9shm2SslvS/vBsl4mMay0mf7zv zoLQgaGMXUSG3XAmVCP9mltCbfjxMFNHtiQtAqzRqfGVwCFgBzyTf0yQRd21JKaMMaBp I07gECttnctikfw/D0ec28R+X1lrQwLdTn3iKIelU51RB5JowYaFpRPkLkQ2d2o/h1vH s+xw== X-Forwarded-Encrypted: i=1; AJvYcCW5MvDT1Ud5s0MWXgQC0nnRz5T4KP/s3fznNrdMsFZSTsazZ0kG5vvff/4/Bszbxf00pCAlIizcSncyQg==@lists.infradead.org X-Gm-Message-State: AOJu0YwRRIqZ4uLYdC1FSV9aegK6hC2ylJJUblzWHoTh4lCWNKsBc5GC RRLsXPixUb3qHO0Cm8Dh4A2CBZQ53KAQdANjgv2JXNOlV1VM/Ljr X-Google-Smtp-Source: AGHT+IFpvbKAGMcBFfuBrPC9vCpoH+zVcNDvH81Wljcvo2dEo6JSn4vRv3yO5yMxJ/YDoSwbgcxnyw== X-Received: by 2002:a05:6a00:9282:b0:71e:587d:f268 with SMTP id d2e1a72fcca58-71edbbc153bmr2884829b3a.4.1729569761875; Mon, 21 Oct 2024 21:02:41 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec1338c80sm3718457b3a.48.2024.10.21.21.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 21:02:41 -0700 (PDT) From: Inochi Amaoto To: Chen Wang , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Peter Zijlstra , Inochi Amaoto , Geert Uytterhoeven , Lad Prabhakar , Yangyu Chen , Hal Feng Cc: Yixun Lan , Inochi Amaoto , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, Conor Dooley Subject: [PATCH v4 1/3] dt-bindings: interrupt-controller: Add Sophgo SG2044 ACLINT SSWI Date: Tue, 22 Oct 2024 12:02:15 +0800 Message-ID: <20241022040218.450573-2-inochiama@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022040218.450573-1-inochiama@gmail.com> References: <20241022040218.450573-1-inochiama@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_210243_489172_065D7034 X-CRM114-Status: GOOD ( 14.57 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Sophgo SG2044 has a new version of T-HEAD C920, which implement a fully featured ACLINT device. This ACLINT has an extra SSWI field to support fast S-mode IPI. Add necessary compatible string for the T-HEAD ACLINT sswi device. Signed-off-by: Inochi Amaoto Reviewed-by: Conor Dooley --- .../thead,c900-aclint-sswi.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/thead,c900-aclint-sswi.yaml diff --git a/Documentation/devicetree/bindings/interrupt-controller/thead,c900-aclint-sswi.yaml b/Documentation/devicetree/bindings/interrupt-controller/thead,c900-aclint-sswi.yaml new file mode 100644 index 000000000000..0106fbf3ea1f --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/thead,c900-aclint-sswi.yaml @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/thead,c900-aclint-sswi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sophgo sg2044 ACLINT Supervisor-level Software Interrupt Device + +maintainers: + - Inochi Amaoto + +description: + The SSWI device is a part of the riscv ACLINT device. It provides + supervisor-level IPI functionality for a set of HARTs on a RISC-V + platform. It provides a register to set an IPI (SETSSIP) for each + HART connected to the SSWI device. + +properties: + compatible: + items: + - enum: + - sophgo,sg2044-aclint-sswi + - const: thead,c900-aclint-sswi + + reg: + maxItems: 1 + + "#interrupt-cells": + const: 0 + + interrupt-controller: true + + interrupts-extended: + minItems: 1 + maxItems: 4095 + +additionalProperties: false + +required: + - compatible + - reg + - "#interrupt-cells" + - interrupt-controller + - interrupts-extended + +examples: + - | + interrupt-controller@94000000 { + compatible = "sophgo,sg2044-aclint-sswi", "thead,c900-aclint-sswi"; + reg = <0x94000000 0x00004000>; + #interrupt-cells = <0>; + interrupt-controller; + interrupts-extended = <&cpu1intc 1>, + <&cpu2intc 1>, + <&cpu3intc 1>, + <&cpu4intc 1>; + }; +... From patchwork Tue Oct 22 04:02:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13845078 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 605BCD1715E for ; Tue, 22 Oct 2024 04:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5yANAD9bp43P20L3WPgQ0Jj1GBHJzr0vgNI4kAGlerg=; b=eS01P7Thlbo+mm gJE6oWgyQVnC0IQbWYG5XHAfdic89heHBFcX5TE03ML1FQdQOh/7xpGQxUYPtvxLNqNWLIaarbzy1 +NQeEPjchVgximHtpRxCY97xLrZO/yBEMuJsTHoP39cnxydZVHTuRZbZM5gxfHiLBdFc//wdDdJJy J0BLHiI3RLBNc0o1kdN4ANZUXMf32DVFFNN1yq9BosQG4m3BVdc9Ssxevy7d81n1FWw0DjU3wjpIx c+h5gxDaqlgAlQjHcawdjRvnQTcaum0IU1bZVsCN2uCaPuRY0DHhtQswzDSTMVjVNuvgYvVtPz3mj LT26VRcn7XbE5IMbcabg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t366b-00000009WKg-31nT; Tue, 22 Oct 2024 04:02:49 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t366X-00000009WID-20mY for linux-riscv@lists.infradead.org; Tue, 22 Oct 2024 04:02:46 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-71e70c32cd7so4187145b3a.1 for ; Mon, 21 Oct 2024 21:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729569764; x=1730174564; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z+VbakcLlqoj4xLjf3FAI0FFGEm/UarNqoU1aaBvySA=; b=i5QybrI6lEco/yYUGrYrfgaPOg+Or3dJaVtB24DMXuWBiG92qlmoU+p+072wSVnA3U +f39r63h90hCBTBCmmdCvL84TxPvOQJbG7tS88dtZ09kmB3N4UahZ3BkitIL+63x2RQ7 /MEgleKF++dHpJ4rV8KUQiVHKqc/j/8T2+DB93uQJpXYMQgmhKL58SdiOkQ7Ds9GNWej sc5dXGjIXMo1c42dXp+Nw9ESs0ZKrO8hc7N3c3HyHyHL4JbduB1WBDsoFvdUm3QMl833 tpHIkiqXKepJM4fB0yZzrcd0TiNJryzpBUg8Kz+BGSnQkP6KPCowaJq9TdYskM47wMwn jkzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729569764; x=1730174564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z+VbakcLlqoj4xLjf3FAI0FFGEm/UarNqoU1aaBvySA=; b=OTok95Bqmy8fBvomGL1BqFrvLtK+VSYh12c18h2BzGZ7AMA4WuQCoaoWg7cvKcRqNG qqbW40pEjIp8AS/OFecPuHyVxbKCpctcJcAoOHS09hCNoZnNvnteyKUjYqa/usWtAEGF xmmB6o3OlOAVmF2Z8TCiAg9g5agrcKnxivJtmxz9ZmwikkLi164/4zGb26LYcZczkyQ2 mfeYvxgiQTQB1AMmf7D3wnOvmgUf/lMMvegGPhhhypoy3Y3Edva4zbeDzd1eJW4HvzRK uj8rCKhNPt2xy373N5X0gk9qdbh/B5IRaklWROQ3KxXje8nSEwRMpC07h9KxqcYT21Mj 4FwA== X-Forwarded-Encrypted: i=1; AJvYcCV10JhYi4a0mXUFaU22EM1THRqMRwvkAgZwDKvik+ipznnnK+2sy6W2NgDjmPGt98QbffzkrIqpCcb7cQ==@lists.infradead.org X-Gm-Message-State: AOJu0YxMwfDVtgxqKgpHELlhccApYzdQe1cZ+L4A9ocXj7aDVnpszVkg Krf9byYAnmyCeqlkHFFyyN6YhCKl2RUawY9zozK+SeRI6M+820K7 X-Google-Smtp-Source: AGHT+IGrc6dzU3hlE8kadMfycwHOsQtAl+ToJea/stKX8GGjURNkw9Ygp+3Aqj0AopEgYe0hp4nr2w== X-Received: by 2002:a05:6a00:140c:b0:71e:5150:61d6 with SMTP id d2e1a72fcca58-71ea31d290amr20204371b3a.21.1729569764482; Mon, 21 Oct 2024 21:02:44 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec1408989sm3710207b3a.213.2024.10.21.21.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 21:02:44 -0700 (PDT) From: Inochi Amaoto To: Chen Wang , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Peter Zijlstra , Inochi Amaoto , Geert Uytterhoeven , Lad Prabhakar , Yangyu Chen , Hal Feng Cc: Yixun Lan , Inochi Amaoto , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v4 2/3] irqchip: add T-HEAD C900 ACLINT SSWI driver Date: Tue, 22 Oct 2024 12:02:16 +0800 Message-ID: <20241022040218.450573-3-inochiama@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022040218.450573-1-inochiama@gmail.com> References: <20241022040218.450573-1-inochiama@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_210245_535384_6BC61279 X-CRM114-Status: GOOD ( 24.08 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add a driver for the T-HEAD C900 ACLINT SSWI device, which is an enhanced implementation of the RISC-V ACLINT SSWI specification. This device allows the system to send ipi via fast device interface. Signed-off-by: Inochi Amaoto --- drivers/irqchip/Kconfig | 12 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-thead-c900-aclint-sswi.c | 176 +++++++++++++++++++ include/linux/cpuhotplug.h | 1 + 4 files changed, 190 insertions(+) create mode 100644 drivers/irqchip/irq-thead-c900-aclint-sswi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 341cd9ca5a05..b6e8411f28d3 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -611,6 +611,18 @@ config STARFIVE_JH8100_INTC If you don't know what to do here, say Y. +config THEAD_C900_ACLINT_SSWI + bool "THEAD C9XX ACLINT S-mode IPI Interrupt Controller" + depends on RISCV + depends on SMP + select IRQ_DOMAIN_HIERARCHY + select GENERIC_IRQ_IPI_MUX + help + This enables support for T-HEAD specific ACLINT SSWI device + support. + + If you don't know what to do here, say Y. + config EXYNOS_IRQ_COMBINER bool "Samsung Exynos IRQ combiner support" if COMPILE_TEST depends on (ARCH_EXYNOS && ARM) || COMPILE_TEST diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index e3679ec2b9f7..583418261253 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -101,6 +101,7 @@ obj-$(CONFIG_RISCV_APLIC_MSI) += irq-riscv-aplic-msi.o obj-$(CONFIG_RISCV_IMSIC) += irq-riscv-imsic-state.o irq-riscv-imsic-early.o irq-riscv-imsic-platform.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o obj-$(CONFIG_STARFIVE_JH8100_INTC) += irq-starfive-jh8100-intc.o +obj-$(CONFIG_THEAD_C900_ACLINT_SSWI) += irq-thead-c900-aclint-sswi.o obj-$(CONFIG_IMX_IRQSTEER) += irq-imx-irqsteer.o obj-$(CONFIG_IMX_INTMUX) += irq-imx-intmux.o obj-$(CONFIG_IMX_MU_MSI) += irq-imx-mu-msi.o diff --git a/drivers/irqchip/irq-thead-c900-aclint-sswi.c b/drivers/irqchip/irq-thead-c900-aclint-sswi.c new file mode 100644 index 000000000000..e1051869a7ab --- /dev/null +++ b/drivers/irqchip/irq-thead-c900-aclint-sswi.c @@ -0,0 +1,176 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2024 Inochi Amaoto + */ + +#define pr_fmt(fmt) "thead-c900-aclint-sswi: " fmt +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ACLINT_xSWI_REGISTER_SIZE 4 + +#define THEAD_C9XX_CSR_SXSTATUS 0x5c0 +#define THEAD_C9XX_SXSTATUS_CLINTEE BIT(17) + +static int sswi_ipi_virq __ro_after_init; +static DEFINE_PER_CPU(void __iomem *, sswi_cpu_regs); + +static void thead_aclint_sswi_ipi_send(unsigned int cpu) +{ + writel_relaxed(0x1, per_cpu(sswi_cpu_regs, cpu)); +} + +static void thead_aclint_sswi_ipi_clear(void) +{ + writel_relaxed(0x0, this_cpu_read(sswi_cpu_regs)); +} + +static void thead_aclint_sswi_ipi_handle(struct irq_desc *desc) +{ + struct irq_chip *chip = irq_desc_get_chip(desc); + + chained_irq_enter(chip, desc); + + csr_clear(CSR_IP, IE_SIE); + thead_aclint_sswi_ipi_clear(); + + ipi_mux_process(); + + chained_irq_exit(chip, desc); +} + +static int thead_aclint_sswi_starting_cpu(unsigned int cpu) +{ + enable_percpu_irq(sswi_ipi_virq, irq_get_trigger_type(sswi_ipi_virq)); + + return 0; +} + +static int thead_aclint_sswi_dying_cpu(unsigned int cpu) +{ + thead_aclint_sswi_ipi_clear(); + + disable_percpu_irq(sswi_ipi_virq); + + return 0; +} + +static int __init aclint_sswi_parse_irq(struct fwnode_handle *fwnode, + void __iomem *reg) +{ + struct of_phandle_args parent; + unsigned long hartid; + u32 contexts, i; + int rc, cpu; + + contexts = of_irq_count(to_of_node(fwnode)); + if (!(contexts)) { + pr_err("%pfwP: no ACLINT SSWI context available\n", fwnode); + return -EINVAL; + } + + for (i = 0; i < contexts; i++) { + rc = of_irq_parse_one(to_of_node(fwnode), i, &parent); + if (rc) + return rc; + + rc = riscv_of_parent_hartid(parent.np, &hartid); + if (rc) + return rc; + + if (parent.args[0] != RV_IRQ_SOFT) + return -ENOTSUPP; + + cpu = riscv_hartid_to_cpuid(hartid); + + per_cpu(sswi_cpu_regs, cpu) = reg + i * ACLINT_xSWI_REGISTER_SIZE; + } + + pr_info("%pfwP: register %u CPU%s\n", fwnode, contexts, str_plural(contexts)); + + return 0; +} + +static int __init aclint_sswi_probe(struct fwnode_handle *fwnode) +{ + struct irq_domain *domain; + void __iomem *reg; + int virq, rc; + + /* If it is T-HEAD CPU, check whether SSWI is enabled */ + if (riscv_cached_mvendorid(0) == THEAD_VENDOR_ID && + !(csr_read(THEAD_C9XX_CSR_SXSTATUS) & THEAD_C9XX_SXSTATUS_CLINTEE)) + return -ENOTSUPP; + + if (!is_of_node(fwnode)) + return -EINVAL; + + reg = of_iomap(to_of_node(fwnode), 0); + if (!reg) + return -ENOMEM; + + /* Parse SSWI setting */ + rc = aclint_sswi_parse_irq(fwnode, reg); + if (rc < 0) + return rc; + + /* If mulitple SSWI devices are present, do not register irq again */ + if (sswi_ipi_virq) + return 0; + + /* Find riscv intc domain and create IPI irq mapping */ + domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), DOMAIN_BUS_ANY); + if (!domain) { + pr_err("%pfwP: Failed to find INTC domain\n", fwnode); + return -ENOENT; + } + + sswi_ipi_virq = irq_create_mapping(domain, RV_IRQ_SOFT); + if (!sswi_ipi_virq) { + pr_err("unable to create ACLINT SSWI IRQ mapping\n"); + return -ENOMEM; + } + + /* Register SSWI irq and handler */ + virq = ipi_mux_create(BITS_PER_BYTE, thead_aclint_sswi_ipi_send); + if (virq <= 0) { + pr_err("unable to create muxed IPIs\n"); + irq_dispose_mapping(sswi_ipi_virq); + return virq < 0 ? virq : -ENOMEM; + } + + irq_set_chained_handler(sswi_ipi_virq, thead_aclint_sswi_ipi_handle); + + cpuhp_setup_state(CPUHP_AP_IRQ_THEAD_ACLINT_SSWI_STARTING, + "irqchip/thead-aclint-sswi:starting", + thead_aclint_sswi_starting_cpu, + thead_aclint_sswi_dying_cpu); + + riscv_ipi_set_virq_range(virq, BITS_PER_BYTE); + + /* Announce that SSWI is providing IPIs */ + pr_info("providing IPIs using THEAD ACLINT SSWI\n"); + + return 0; +} + +static int __init aclint_sswi_early_probe(struct device_node *node, + struct device_node *parent) +{ + return aclint_sswi_probe(&node->fwnode); +} +IRQCHIP_DECLARE(thead_aclint_sswi, "thead,c900-aclint-sswi", aclint_sswi_early_probe); diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 2361ed4d2b15..799052249c7b 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -147,6 +147,7 @@ enum cpuhp_state { CPUHP_AP_IRQ_EIOINTC_STARTING, CPUHP_AP_IRQ_AVECINTC_STARTING, CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, + CPUHP_AP_IRQ_THEAD_ACLINT_SSWI_STARTING, CPUHP_AP_IRQ_RISCV_IMSIC_STARTING, CPUHP_AP_IRQ_RISCV_SBI_IPI_STARTING, CPUHP_AP_ARM_MVEBU_COHERENCY, From patchwork Tue Oct 22 04:02:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13845079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E8D3CCFA0E for ; Tue, 22 Oct 2024 04:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Y6vsZkeq46s4j+xbTOZsWQMwJJ3/0cvMlwXVa6Gtcqc=; b=dK2ycvY6Hl728A 7HA9GFkLapV/yiDwXyUBJxR0sjvv3StKMUO0AEcXTE0DpHB+TZzsaN9x6tFOjGRO0B7dV1PJyR1nL k2b6B+PccCoi6WOakhGbaLVqHr7n/H9w9ATamyGTQpAxHKDp1BnvN2qDMohCJmvWP9X8akwfyqAxo JvtLWjngTkUQhmPD352a/hYOZYwtzoyuzLuYSefSrX2tEtiEOwsuE86Fz+TYMXmMnMigYRYyu5HM/ pJvnusW3pm1Eyisd4z5F3zvLvhSvx1tKOeNwkg37zYPgEcsyZg/y8EQXlf22x1/sZqxOcstfK1dMv vl/NZz40w+206V9stqgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t366e-00000009WLm-3EU3; Tue, 22 Oct 2024 04:02:52 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t366a-00000009WJR-0W8S for linux-riscv@lists.infradead.org; Tue, 22 Oct 2024 04:02:50 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-207115e3056so42485075ad.2 for ; Mon, 21 Oct 2024 21:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729569767; x=1730174567; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ncgmlyGfcrqHCYKyqt0DRpGIqa2UXUmRq5v7oAb7ZpU=; b=b5ztyGRugWmNy2H46zNYFUwDyht4Z0hDTZX/BtFEEU+s0LKXfBx+gHd+jfcA4RyW1S Ndc4p4BxMJsQFFkUmE+TXQ+0CuRkoFjBX4ngEy+gDxoHkIB++SemYmIq4SlHevCatI5H MhaFUIR/YBEoaX9MvgDFAQoz51pUxGZzdvqPbZbdK0cQ5DnBBIBKgpyW7PT0XCFY0p+R IXTceLwRjF1e5CXh4jCrGHRrzPpGmPdoP7Ot2G9kRlVWTRY7H0KZaNpdI0TIo03KJuoJ pOPaw1/0iudfxlOpL0ABH0H1WXlLA8yLSGnbsvejWh+4sa0UT94YnpjdRnAblsurX5sa j4kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729569767; x=1730174567; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ncgmlyGfcrqHCYKyqt0DRpGIqa2UXUmRq5v7oAb7ZpU=; b=P9VHt/VgkTK5ngDPMycPPYm8mvXl59MfWDzarZCN/KaPxze0Y/I6Q/Y2033F5W8LdO RkVIlduVtjNBAiGgTaYbxs8YXtX9u7Eq/PfAo0xyxPlMcv2Kq5CMydI/qMSF5kaRheUg CC2gLfLCu9VzegzeHvC+LsfoqJcFDBTDf6umj6GQimnMnkjQtCToEPN/3f4uo7gkj8SF 7F+34sUBDrUYeltZ9eDP3ioPmC1w7bXZUAcXOKhDVdPMI+JMFpu0aeUV+RatqJUd2qKU pSqE7XhsF6eQl+9L77FHNLSzIw/EZDGC7MtYhnofAe/bdKzYYAS076cGk2PNTnFnCg0O MT+g== X-Forwarded-Encrypted: i=1; AJvYcCUrYiSeCtpMzMmveNjU8NO4IQtdB1ligHesLSDolcbhAtk7lPalbF+bdMYgB2KDJPpCk6yRcZRGZMrYkg==@lists.infradead.org X-Gm-Message-State: AOJu0Yy2iCc2uXqtMoTY469byrQB3sxBXaPsmI4W8LtnNIIUI4wcK6hB tnHdUKotSw6VLAB2OtAkdIGF6NJiJ7pxbM5baKwB9L9xJMrv69nY X-Google-Smtp-Source: AGHT+IHPcCzAx+iiW8df3gz3gZtXUxLdDe9DNtEZZmDqrW9DCC3AAd2AKq1gArxRGkZyiZRD4OwkTQ== X-Received: by 2002:a05:6a21:6282:b0:1d5:2b7f:d2f8 with SMTP id adf61e73a8af0-1d92c4e05b3mr16504132637.13.1729569766739; Mon, 21 Oct 2024 21:02:46 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7eaeabda3b2sm3924281a12.83.2024.10.21.21.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 21:02:46 -0700 (PDT) From: Inochi Amaoto To: Chen Wang , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Peter Zijlstra , Inochi Amaoto , Geert Uytterhoeven , Lad Prabhakar , Yangyu Chen , Hal Feng Cc: Yixun Lan , Inochi Amaoto , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v4 3/3] riscv: defconfig: Enable T-HEAD C900 ACLINT SSWI drivers Date: Tue, 22 Oct 2024 12:02:17 +0800 Message-ID: <20241022040218.450573-4-inochiama@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022040218.450573-1-inochiama@gmail.com> References: <20241022040218.450573-1-inochiama@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_210248_188690_F5824AEB X-CRM114-Status: UNSURE ( 8.48 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add support for T-HEAD C900 ACLINT SSWI irqchip. Signed-off-by: Inochi Amaoto --- arch/riscv/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index 2341393cfac1..5b1d6325df85 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -256,6 +256,7 @@ CONFIG_RPMSG_CTRL=y CONFIG_RPMSG_VIRTIO=y CONFIG_PM_DEVFREQ=y CONFIG_IIO=y +CONFIG_THEAD_C900_ACLINT_SSWI=y CONFIG_PHY_SUN4I_USB=m CONFIG_PHY_STARFIVE_JH7110_DPHY_RX=m CONFIG_PHY_STARFIVE_JH7110_PCIE=m