From patchwork Mon Feb 3 08:48:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957043 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 1A658C02193 for ; Mon, 3 Feb 2025 08:49:45 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=89/odvqIWcLwfWokreG+707fcRZIDzWdrNUYprdPl7o=; b=rpbh5qnHn2ChaY cgqd+ORt/g83WdsfbTnLh0JgfuE+W4o5z0fW+9ZSYwQYKWCG/Q1seX1Z1E7qqJ+YLMVfYY+5PHPEz hdLFnmv0sjoNyUvM/dSezJzeuZ0BgyiuIg9VVARMhR5neIH07MsfOW1/WApiI/rAkOKTwcf7Spz6c ywXnFAKCJux2uZC7Af8eoE/r4+o4QwYDlh+7aXDmAUWBT62PzNjEqZFWaaXvmXF6Mqp2BDvRNQmqd 3w0o7Ma05LlYaz3UTFU9pvDaZmR1gOainlTRTcy1FKJaFHrNn3IQDFJIIbztlI6YkUxWlOjYIe1Gc 5cBNr+ezXEOqFbJzKq1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tes9F-0000000Etgb-1IAE; Mon, 03 Feb 2025 08:49:41 +0000 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tes9D-0000000EtfK-1s20 for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:49:40 +0000 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-4678cce3d60so42824121cf.2 for ; Mon, 03 Feb 2025 00:49:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572578; x=1739177378; 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=asyaJaTKEI2I1t9xzdu0UJ7536vRQbg3knNHFZYwbZs=; b=m5XihedHrsTpyV9U6TrBpLeMCRp5dKP4JCCs3vAIkHj12kptD+odfp/+zsLzLA3GDh UF7OhQdZJq5lo3KRhd5smC4VYdRXrLEHtCZywVHEgb6gSo35mzitB4ZqI/jKBEhoqmW5 qHpuIhxSUc9SR4FRHeUL6bLFfN3eZJti4L1JH/pzcuwp/Pk813/PuoNUE/98o+g2ah/k Aw3PuSjo/4HhUkr7obEvVsGYIA/wdC9utYPZmHY5Js6jVytFOr7b9aAi0bPbsItBa9Lw +VASE8mrRHybsx7/TJDO3iHhVRSnX2j4sjWPwPXDOPmz2s/Fvlhck/fPXyq6du0Oonf0 voyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572578; x=1739177378; 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=asyaJaTKEI2I1t9xzdu0UJ7536vRQbg3knNHFZYwbZs=; b=MKjNfB8EN9/r2I19CyX8Zx/bnr4mUVL7s57EFIgidgOIpNhGLF6EDkBC4OZ6/befw9 TKPea24NKK/T2TVEYbWNvZS5dChBJOESrHrdfbzx70toWgYlZ/CPPNpWLX8J9wOEM6Hf /77QzoKb4ph1CmS9SyMlVW5yNIEj5xwapA9MFkkoQwMvLvVJfiYjVKeAwgSyV21murhk SscyvKWEsrbhcTe64GDAB/WYXu671VcyEzA/hZH1HUZMhS6meaTHQSsWO6QSSsHTYOqe ciUTS8UmB0aSe0ohu+mn8N1FLOrCoq5MPY8UEJrvhwIxm3SInk/qcnqJ3HoVVSsQQRhe Vj8A== X-Forwarded-Encrypted: i=1; AJvYcCULMLnPlOOjBnOg6za6JPiGoJrIiy6ERwMErxuWH8Y+YLyITthzgdeoDDMHUGd8wWt8Yc60AZd30oaj2Q==@lists.infradead.org X-Gm-Message-State: AOJu0YwyoGa//Gen28+VPt0AnjWRMnxxT66F/9RJIUtg4aNh8aAyIpfB lXqy7rrTl2yxx1xP0BF+/hiVyCJOpOKmmCvulALLf52da6k9tZq1Rhpz8tVAD0E= X-Gm-Gg: ASbGncvTW3NzrtfhqbN333UEzk8nu+tMVNd03pVd6D7/8kkT3FFgzj5jxGTvXnfaruh NZzxAmd9VjOvsZxrYuMajG1h982hObq/7Af6i2ZMssqMap2oAFIb0XejGdrfopRgcGsXZjKxXRG j+4TPNfJXo6u8yEpiqqRzkA903ThMpywTANM7yWLezeBjiJdrd0cn1R2oxB+BGVNB5kNWg3V23h 1CWBBNip0VRKHCPxMXn5jwKzsiyYm/VgEzfNoEai2bGSLjqxOzQaVcGpjaGPI8BX3pwrKLmvolp 2PMWwf3t4wKBAR+rRB//BoDQ1AI+ne/7nmkU+bQMdWqRYMCUrvEn7mA= X-Google-Smtp-Source: AGHT+IGcjaF2SJDXsNc6wLt4ldMm5Rj7yqw3jGMd8EZTRoB/t2JLI6T/ZVSpOvzgm5WgVhySwgNT+g== X-Received: by 2002:a05:622a:2594:b0:467:7cda:936d with SMTP id d75a77b69052e-46fd0a1e8bcmr332465921cf.14.1738572578196; Mon, 03 Feb 2025 00:49:38 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:49:36 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 01/17] riscv: Add new error codes defined by SBI v3.0 Date: Mon, 3 Feb 2025 14:18:50 +0530 Message-ID: <20250203084906.681418-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_004939_482416_FB747BAE X-CRM114-Status: GOOD ( 10.16 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The SBI v3.0 defines new error codes so add these new error codes to the asm/sbi.h for use by newer SBI extensions. Signed-off-by: Anup Patel --- arch/riscv/include/asm/sbi.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 3d250824178b..972eecccfb2a 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -419,6 +419,10 @@ enum sbi_ext_nacl_feature { #define SBI_ERR_ALREADY_STARTED -7 #define SBI_ERR_ALREADY_STOPPED -8 #define SBI_ERR_NO_SHMEM -9 +#define SBI_ERR_INVALID_STATE -10 +#define SBI_ERR_BAD_RANGE -11 +#define SBI_ERR_TIMEOUT -12 +#define SBI_ERR_IO -13 extern unsigned long sbi_spec_version; struct sbiret { @@ -505,9 +509,15 @@ static inline int sbi_err_map_linux_errno(int err) case SBI_ERR_DENIED: return -EPERM; case SBI_ERR_INVALID_PARAM: + case SBI_ERR_INVALID_STATE: + case SBI_ERR_BAD_RANGE: return -EINVAL; case SBI_ERR_INVALID_ADDRESS: return -EFAULT; + case SBI_ERR_TIMEOUT: + return -ETIMEDOUT; + case SBI_ERR_IO: + return -EIO; case SBI_ERR_NOT_SUPPORTED: case SBI_ERR_FAILURE: default: From patchwork Mon Feb 3 08:48:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957044 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 334A8C02193 for ; Mon, 3 Feb 2025 08:49:58 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yw0vaBOZfP0/YwTQVsGyJTlKti21CsVnjApQg9fn/ew=; b=pwrR6rnt8+0LND 092Vd0ixEm75okoN9jnDCf48dyF9I6pF9EuyQxWSTAXTOPb01y8XtLkBJdID7d8uCshpGDe8HWiVp SOYdGnw8ENw2knDPjZjfNXtnVago/xAiVYkvWykYB8Q1OlHqCBtTAxxkKDTD3kd0IpWP9u5kpMtc0 098OHgs9AdEVvGMzS/CT9o1htjRxLtGdGEpEBNB1sHJ/tn6UWSbXW2OE/jPUBEZc3MzKvWQryZTcu 7ofd8EYNrZEIjE5NoYLPGfYNtUInJMNMgQ3Iape2RGPUNSEF7x0LTkT8nUjPeaWNVZyBCXDTGTBg2 iDc3LzYtjOpsv2j9h3bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tes9R-0000000Etl8-3hRn; Mon, 03 Feb 2025 08:49:53 +0000 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tes9P-0000000Etk9-1WSV for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:49:52 +0000 Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-467a17055e6so50448431cf.3 for ; Mon, 03 Feb 2025 00:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572590; x=1739177390; 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=uIptlls0lSoEbPx5zusAvJxAewxDBRI9b9ePSXx/HLg=; b=UAh5sLC+MowD1H8QyhemBefxYn6f+OnvbpnVpaB/x2I6C5PZbdxqAz5Lj0SpQB08Td +SynC8/lKBOaAz+PGrT9kAbf/DiGaqn0AFNZxRZLkUkeyEQt1CFe+S0WL5QcbXht+mie jmGuaHsYvJNmJh+9B/Ye1/IMp50epHc8TJlflKYZHoy9C/4hvpDHTzOqpJ1tEGhlvKA/ +BB5sA3ah+ZXHXqX2UoLCESWyp98VV/Z03JK+FAxmIu6qTc1Miqind4rLvRCRsn/Z91y au/6krm2BEk2cSQH66RiKN+gdEji+dvUjDeNQMiCo4syFHmhpdZ1/8cceriJQ7f9Gm7J NF4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572590; x=1739177390; 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=uIptlls0lSoEbPx5zusAvJxAewxDBRI9b9ePSXx/HLg=; b=xMY74BrNkzSlXFv5Sx7oKWih2SOSW21M3ySaBEbgTfQ850VDaiM6eE1sL0MqOGfdOz EFxNGhOSqLl71fVNbbTGdYohV8aBbnHKIurESxZwWCjZAG+3qOoP97BUgpRKznt/tZK8 9tYoziE7MmE20HFyZYiQtZTi9tjs9vrY3LwQRpMHMg8LCQ86WUMy6J46qSZAxBhYHgsZ MPPjU029SFKapVnMx07hXHw1FXff5zs28Bf2PQ5St4bNTcKCygpaZmzdjZuLGE4ge+rZ KCmP+t6Qtx7BMQCJH80XgFvmuBQKnBif+mYjEIKjbt5jrbawI/EplFrtGuXPgxSDKZz4 LJgw== X-Forwarded-Encrypted: i=1; AJvYcCUhRhVhggKkw9H+HlXYHIldOGovDw65WpFzOkX6mb0yP8BQU5zAVc2gAKoSxTqE9MRF5WfMeBgLpkIz/A==@lists.infradead.org X-Gm-Message-State: AOJu0Yygl/L2bJ0r4LxJ+1B8AK+qvd8RBrjuLLXoSUEFXZhAJ+RTF4Rx x5eXkB0f5murxYdsepxoNUcOQu246RxB9LsbAdKVvXkHogtD/cDrZ3e0KwnTCKg= X-Gm-Gg: ASbGnctzeYdSBNkF8p3tB8gaKqp7LMpFK5rfvlOe8v7Vtr26hX3lk1GKLZfnPj6TBDo oB9vkeKNVaW94v22sv1eEYJfPnFkMEFGtqBX5f88UCWBSR3M+ZPUsIROPcwQ7tMu4mFuKGOTi6t I+xTh6q0Rn/McSOMsVJNXaHBAx1t4WMBaDGmbIIkVYdB6qgL8YuZGkt1X4rnfNTm3d54SFHUC3f NMlswpVgg5TEFpEq3At6Y+uhviQrounFap3k20sBHB9BqD1lShJJPoN4REfoAnKKrSfLJRvWVq3 Yd4ZHCP6cNbChgmoJ4yB8gR98P7+3yR/fSdCgKlv0DFNo4N5zzRF2sM= X-Google-Smtp-Source: AGHT+IFHHlk6yRWs1ijlylKke56DmU0/tkygTt4Q+373jN4c1Xddg6tNHv+laUzh55eYL8Gx++jhPQ== X-Received: by 2002:a05:622a:258f:b0:46e:23ad:a120 with SMTP id d75a77b69052e-46fd0b89329mr324786311cf.35.1738572590072; Mon, 03 Feb 2025 00:49:50 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:49:48 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 02/17] dt-bindings: mailbox: Add bindings for RPMI shared memory transport Date: Mon, 3 Feb 2025 14:18:51 +0530 Message-ID: <20250203084906.681418-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_004951_404962_CBB4B781 X-CRM114-Status: GOOD ( 14.17 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add device tree bindings for the common RISC-V Platform Management Interface (RPMI) shared memory transport as a mailbox controller. Signed-off-by: Anup Patel --- .../mailbox/riscv,rpmi-shmem-mbox.yaml | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/riscv,rpmi-shmem-mbox.yaml diff --git a/Documentation/devicetree/bindings/mailbox/riscv,rpmi-shmem-mbox.yaml b/Documentation/devicetree/bindings/mailbox/riscv,rpmi-shmem-mbox.yaml new file mode 100644 index 000000000000..c339df5d9e24 --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/riscv,rpmi-shmem-mbox.yaml @@ -0,0 +1,150 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mailbox/riscv,rpmi-shmem-mbox.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V Platform Management Interface (RPMI) shared memory mailbox + +maintainers: + - Anup Patel + +description: | + The RISC-V Platform Management Interface (RPMI) [1] defines a common shared + memory based RPMI transport. This RPMI shared memory transport integrates as + mailbox controller in the SBI implementation or supervisor software whereas + each RPMI service group is mailbox client in the SBI implementation and + supervisor software. + + =========================================== + References + =========================================== + + [1] RISC-V Platform Management Interface (RPMI) + https://github.com/riscv-non-isa/riscv-rpmi/releases + +properties: + compatible: + const: riscv,rpmi-shmem-mbox + + reg: + oneOf: + - items: + - description: A2P request queue base address + - description: P2A acknowledgment queue base address + - description: P2A request queue base address + - description: A2P acknowledgment queue base address + - description: A2P doorbell address + - items: + - description: A2P request queue base address + - description: P2A acknowledgment queue base address + - description: P2A request queue base address + - description: A2P acknowledgment queue base address + - items: + - description: A2P request queue base address + - description: P2A acknowledgment queue base address + - description: A2P doorbell address + - items: + - description: A2P request queue base address + - description: P2A acknowledgment queue base address + + reg-names: + oneOf: + - items: + - const: a2p-req + - const: p2a-ack + - const: p2a-req + - const: a2p-ack + - const: doorbell + - items: + - const: a2p-req + - const: p2a-ack + - const: p2a-req + - const: a2p-ack + - items: + - const: a2p-req + - const: p2a-ack + - const: doorbell + - items: + - const: a2p-req + - const: p2a-ack + + interrupts: + maxItems: 1 + description: + The RPMI shared memory transport supports wired interrupt specified by + this property as the P2A doorbell. + + msi-parent: + description: + The RPMI shared memory transport supports MSI as P2A doorbell and this + property specifies the target MSI controller. + + riscv,slot-size: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 64 + description: + Power-of-2 RPMI slot size of the RPMI shared memory transport. + + riscv,doorbell-mask: + $ref: /schemas/types.yaml#/definitions/uint32 + default: 0xffffffff + description: + Update only the register bits of doorbell defined by the mask (32 bit). + + riscv,doorbell-value: + $ref: /schemas/types.yaml#/definitions/uint32 + default: 0x1 + description: + Value written to the doorbell register bits (32-bit access) specified + by the riscv,db-mask property. + + "#mbox-cells": + const: 1 + description: + The first cell specifies RPMI service group ID. + +required: + - compatible + - reg + - reg-names + - riscv,slot-size + - "#mbox-cells" + +anyOf: + - required: + - interrupts + - required: + - msi-parent + +additionalProperties: false + +examples: + - | + // Example 1 (RPMI shared memory with only 2 queues): + mailbox@10080000 { + compatible = "riscv,rpmi-shmem-mbox"; + reg = <0x10080000 0x10000>, + <0x10090000 0x10000>, + <0x100a0000 0x4>; + reg-names = "a2p-req", "p2a-ack", "doorbell"; + msi-parent = <&imsic_mlevel>; + riscv,slot-size = <64>; + #mbox-cells = <1>; + }; + - | + // Example 2 (RPMI shared memory with only 4 queues): + mailbox@10001000 { + compatible = "riscv,rpmi-shmem-mbox"; + reg = <0x10001000 0x800>, + <0x10001800 0x800>, + <0x10002000 0x800>, + <0x10002800 0x800>, + <0x10003000 0x4>; + reg-names = "a2p-req", "p2a-ack", "p2a-req", "a2p-ack", "doorbell"; + msi-parent = <&imsic_mlevel>; + riscv,slot-size = <64>; + riscv,doorbell-mask = <0x00008000>; + riscv,doorbell-value = <0x00008000>; + #mbox-cells = <1>; + }; From patchwork Mon Feb 3 08:48:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957045 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 B896BC02193 for ; Mon, 3 Feb 2025 08:50:09 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cQ3s2YLlI1tcrBlcnenUY3rBKde2HZKFn9ZuP65dnGg=; b=BrhESvyKrGDbT2 8Vf/YbsUVIqyBV0bCmLOE4qXq8bvUG3vpnfJmtMgvGh1e4H3Y6HmQBbZmQEz63yhhGpBXqfxFTpN1 5zgnxiMXQ1wU1GGEWSisgO6ALZ8NkoZXwAmbfEoOVV/k4JnLe1x9Oic+pKovYIph+7V6hGCh7Qhnd oJADnX3Zk5geODBIYx3PX+irdKF89bdZjh01VD5B+3Acrm+own3seJvf+RFKGToYPm76qpPF2KOim SSZ0Y3bXTpASuNf5K3l9mxUH9Gx09CvQp5ph49tHwGedAH7aTtmTMQzimxtIKXw91RBgeqqzXjNW8 A6nmxLU51eRsWlmCGhqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tes9d-0000000Etqm-1uoo; Mon, 03 Feb 2025 08:50:05 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tes9b-0000000Etpy-2CLp for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:50:04 +0000 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-4679eacf25cso26954451cf.3 for ; Mon, 03 Feb 2025 00:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572602; x=1739177402; 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=ssg9a8o6gZjpZvchZzGUt0Qt044T+B0HdxLRYjAYuuA=; b=jkqVw1X9TMIK23aEQVIjsPPNIt96grFDoa9to8I/gSMGx4BBpogKvvMjs9CdSwfCVB n0LpTp9oVkXg5QVvEDgb5rsLNNBZW1hy4SYPbjMzvy35G+CQx1qD0tpP27VwXrm8Ouvt 2YV645aZvu7Ifg6boJiSpbzM+wBp2tDNu7g35DQnVb5PteHuTLBmZIJ8QIkx7QxgcAxS XVxXOh6RKRis9eFMn4k9vfIlwwSGiAFfB1Tjh9csEhmHZyssnCVhqHngUjkALKGlwFRN 6ojkYAKoFaS560oob+XL1VIyKrgBjVM0MiO3bTEHVJwLFPnSybHMMvSdpnNWUGYBLx9Q eaWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572602; x=1739177402; 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=ssg9a8o6gZjpZvchZzGUt0Qt044T+B0HdxLRYjAYuuA=; b=sVenxNlRxbHMTwAaZ5XrKRSAz7+GeHcMhzQ2IAXq6lVFZQENAxohJmHTqlurxAUYAq kuOAP0iA7Rtc2sUqeJWivB5r05v+kVUp6toKsnl29O8sSE5b6Li5ExdkvQZ6tUNWWHvr kwZcVsq/bs5Pu8bCjgnD0Q+Mr7L2wdPWDl7BHJS5aiwPh+1FdXf+jRr2ob8/KO193Svn vzyCF19NBltRkkUsMsxl5VFe7D9TPfYBuhFN/THM7rtg873VwbQShIArOvlvlS4DgfJG 470fCv19m69QXt4YX4w8BqcSw74liW28C2j73rzNcJ2hFl2GhcbCJBCrWgoe10xtNOGO k67w== X-Forwarded-Encrypted: i=1; AJvYcCVeWJngpeUqRRXAM4o+c3bkpN2LuVdjRPG9E4Fx+8IbhVVJVzfwRVthsjNxANLt2IKwiy/O6QQjS/gx2w==@lists.infradead.org X-Gm-Message-State: AOJu0YxFkCpHAX4scBaCihv2/MwDgw4EydM5rFlZqq/RLrnvPz2yxveI ksD9lBtHkXz4LwRkOF9y6nyG2mGzIOeFTf4GIs0SFgeTbdv9Jg8fMVvv/MR22Io= X-Gm-Gg: ASbGncslKsXsI4xuPK+8P8elEYzvHNjGrrCq2z9yFRt2+Rq7RB7xGOjwBrgS3GZV1yb ENoBXCUSViizRzsNZt0AAroaonxgyv+s0QnQcK0W0P9pMDWONPOs9eZ5OxuS7snggIePvq1YHfG GJWT3AEwex1g1LNGZ1EJMMpF7u/IJFBT+hIC1FV0jTown5p6SmmGxH1JvdCCJRTb/Rc1My000je 2wgpj3DSL2oILrrkHMV+UwBSjsH6TzDVhAFFxb0zj0re7r+SNNcGq2KqXaVtZJ7YA0TKpk2XDIW UhJWxn+ev4fFzlaAxgcE31HVfVyXSot89ttMu1m++olzle6FE7sC9xw= X-Google-Smtp-Source: AGHT+IEumBd7wOc/wh3jyz0afWhLZy8y7yKZMAluEJD5UqFuCGfrMInxfJFsvFE/QBEyK9tHDtTWWw== X-Received: by 2002:a05:622a:5108:b0:46f:cc36:d51e with SMTP id d75a77b69052e-46fd0b68b70mr329868001cf.35.1738572602314; Mon, 03 Feb 2025 00:50:02 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:50:01 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 03/17] dt-bindings: mailbox: Add bindings for RISC-V SBI MPXY extension Date: Mon, 3 Feb 2025 14:18:52 +0530 Message-ID: <20250203084906.681418-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005003_561782_C0ED4211 X-CRM114-Status: GOOD ( 13.61 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add device tree bindings for the RISC-V SBI Message Proxy (MPXY) extension as a mailbox controller. Signed-off-by: Anup Patel --- .../bindings/mailbox/riscv,sbi-mpxy-mbox.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/riscv,sbi-mpxy-mbox.yaml diff --git a/Documentation/devicetree/bindings/mailbox/riscv,sbi-mpxy-mbox.yaml b/Documentation/devicetree/bindings/mailbox/riscv,sbi-mpxy-mbox.yaml new file mode 100644 index 000000000000..8a05e089b710 --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/riscv,sbi-mpxy-mbox.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mailbox/riscv,sbi-mpxy-mbox.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V SBI Message Proxy (MPXY) extension based mailbox + +maintainers: + - Anup Patel + +description: | + The RISC-V SBI Message Proxy (MPXY) extension [1] allows supervisor + software to send messages through the SBI implementation (M-mode + firmware or HS-mode hypervisor). The underlying message protocol + and message format used by the supervisor software could be some + other standard protocol compatible with the SBI MPXY extension + (such as RISC-V Platform Management Interface (RPMI) [2]). + + =========================================== + References + =========================================== + + [1] RISC-V Supervisor Binary Interface (SBI) + https://github.com/riscv-non-isa/riscv-sbi-doc/releases + + [2] RISC-V Platform Management Interface (RPMI) + https://github.com/riscv-non-isa/riscv-rpmi/releases + +properties: + $nodename: + const: sbi-mpxy-mbox + + compatible: + const: riscv,sbi-mpxy-mbox + + "#mbox-cells": + const: 2 + description: + The first cell specifies channel_id of the SBI MPXY channel, + the second cell specifies MSG_PROT_ID of the SBI MPXY channel + +required: + - compatible + - "#mbox-cells" + +additionalProperties: false + +examples: + - | + sbi-mpxy-mbox { + compatible = "riscv,sbi-mpxy-mbox"; + #mbox-cells = <2>; + }; From patchwork Mon Feb 3 08:48:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957046 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 1D852C02193 for ; Mon, 3 Feb 2025 08:50:22 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MmjXG1RHO6lb6GUsnPZZuiIjsVhqo0gLGNxOUyg/1LA=; b=XefqwxjpIm+rmf eqv82yxQdE8Nwf4Y3jd1eI8ksafCeSVZntv2NbqedynImVsq6CU3vfQRZnUm9lvenkSHj4MfUxMEd ckP14Wuc2E5zV9XM9m+T1+t+3aDoH+rXZbdHNVry1QtEvc7L8OO3JDdfUh9NDkjOdAWWbkolqtuUf Xh9MtNzrQLJ1JCkU++bsfGtq6I9fpMTBqhvN0PpXI4xzydlfpsnyXZQAVILRu1E+kQ0GLftCIw3zr Ycr4Mfpgx36Lsu8KPS77VnKJ/1sg0/S9xHikzw6qrpWU2Aqy1pXcaIyp+yHkMbTTU4M3erriMZpeX Fttdo7oYyhn9/IZHUWvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tes9q-0000000Etxf-0AA8; Mon, 03 Feb 2025 08:50:18 +0000 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tes9n-0000000Etw2-1Tpg for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:50:16 +0000 Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-46fa764aac2so35979881cf.1 for ; Mon, 03 Feb 2025 00:50:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572614; x=1739177414; 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=tCnHAquQUwch4tcFWwygkET+UwWze5YhLFw9G/xcbPA=; b=PLpoTPmv+rBPwYQwlath1N4T4mfctw/NyDpIk9anVKY3PBMcXImdw0TCbxO5Y4oFv8 hSh7wwxJDmzhBJPrXO2AxiKPjux41YstsGg8ZZcsLY7Zx37nkgTksHcjdOwkvz5rX7jn Efgv1iyJ6r6o4gzTToIPWB/VKK1hyhM0AS88azFQq8cZK7uZQsRjywXmSYt7X3BHy/+7 ThIaakU6HjOqvfK0YbDyc2Nv4OxOjAOdb/bv31kyhPzH+P8L//E0/VkUOnc3w2oJIVJO IWA+6intoxCNW7+aHiiafaMMpIyzkdf0/WhXj7jBtj64JNW1YWd9CQw6Wgm4eYlwtmRv 2GHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572614; x=1739177414; 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=tCnHAquQUwch4tcFWwygkET+UwWze5YhLFw9G/xcbPA=; b=tTC81ZqA1rA6khjBmJJReQWHo6y7A73b9BR7f5Z95/LcpIaKGOk5jhM6Yc3I75D9gb jF94yoqstxu6TLl6HM0mBSzYuMi6pKTR/Rb5Q9VINFER+Y4ZhNr0v6KsPZrQHjWvuISC MvLi3/GRcKs6UEUVGJN2P6J3NABOLfI1orqA9RWVy1EK51ONKxxY4OxydTdG9pQ38sdN zCmDAcCrNd9Nj+ZUwgsuCqsiKg4r+Hs6JgQI3QhqCtRNLQUiha+ubuGVcCvibAq1sQ2T imeAlbOyQ4bujCquBsDzxQDdpRMOY4c8kzscMJNFJiW00h1PbED1OsAuo1n2jpLz6Md+ I1Dw== X-Forwarded-Encrypted: i=1; AJvYcCXm1FoAbjZ/3oidGm0rcGIdX5KHeNFYaNqCY4kbRD1S3cPehs2+QGyJGDNNOa4e6TtZ6jqZNj86brMVSA==@lists.infradead.org X-Gm-Message-State: AOJu0YxAv0hZ1UBlDBYnLJblWrfHI9KJJsXG3JXpYymgarpI/ZTrXok1 KXoxCTU4YnZbz6E0Ppu275lRFMdh9qdpS12Mc1/h8CwAuFiiFVUZyGKjOdIZ66Y= X-Gm-Gg: ASbGncs8XM84C/mQipFUgWIhRjCsLM1IO5kv89N4GQTknkR9XSqCJjqWd3LAKf/sYM4 C+Ea9XNF1c3O4n/shg8sbAp3rH8Mxom2TRY3Egw7axRXqgwekRuis52Gjcnd5AYgRRcLi1RnpN3 BV0WVQVD0K3YMSYOJTHOPjfPu9Oc277mDeoxeRFosPAPlOHB9uwX1zr8WIdybzSAKp39Y0TuNRa /GiLUfZJU7qoNEPUJz/QWwFG+Yf1xESWTP+FMGjRKb2IzGdFy9ljG6jm2jVmqiCBg9uskHc9Xo1 +zADcvVYCEb7i+yNq2vaXkuVnbtxrnTTZ4Tdio+TqH/tBndsRYt3h9Q= X-Google-Smtp-Source: AGHT+IGOIuwdSy2AtM7BxpLkRJK1hm6BLxTjmWDlKOGDZZi51/9Wkwiyb7XXsEI/yNOgfLAOZVUrkA== X-Received: by 2002:a05:622a:1803:b0:467:84a7:5147 with SMTP id d75a77b69052e-46fd0b6f794mr281355951cf.39.1738572614133; Mon, 03 Feb 2025 00:50:14 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:50:13 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 04/17] RISC-V: Add defines for the SBI message proxy extension Date: Mon, 3 Feb 2025 14:18:53 +0530 Message-ID: <20250203084906.681418-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005015_389127_20BBAB2F X-CRM114-Status: GOOD ( 10.87 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add defines for the new SBI message proxy extension which is part of the SBI v3.0 specification. Co-developed-by: Rahul Pathak Signed-off-by: Rahul Pathak Signed-off-by: Anup Patel --- arch/riscv/include/asm/sbi.h | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 972eecccfb2a..b730b5159b97 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -35,6 +35,7 @@ enum sbi_ext_id { SBI_EXT_DBCN = 0x4442434E, SBI_EXT_STA = 0x535441, SBI_EXT_NACL = 0x4E41434C, + SBI_EXT_MPXY = 0x4D505859, /* Experimentals extensions must lie within this range */ SBI_EXT_EXPERIMENTAL_START = 0x08000000, @@ -402,6 +403,65 @@ enum sbi_ext_nacl_feature { #define SBI_NACL_SHMEM_SRET_X(__i) ((__riscv_xlen / 8) * (__i)) #define SBI_NACL_SHMEM_SRET_X_LAST 31 +enum sbi_ext_mpxy_fid { + SBI_EXT_MPXY_GET_SHMEM_SIZE, + SBI_EXT_MPXY_SET_SHMEM, + SBI_EXT_MPXY_GET_CHANNEL_IDS, + SBI_EXT_MPXY_READ_ATTRS, + SBI_EXT_MPXY_WRITE_ATTRS, + SBI_EXT_MPXY_SEND_MSG_WITH_RESP, + SBI_EXT_MPXY_SEND_MSG_WITHOUT_RESP, + SBI_EXT_MPXY_GET_NOTIFICATION_EVENTS, +}; + +enum sbi_mpxy_attribute_id { + /* Standard channel attributes managed by MPXY framework */ + SBI_MPXY_ATTR_MSG_PROT_ID = 0x00000000, + SBI_MPXY_ATTR_MSG_PROT_VER = 0x00000001, + SBI_MPXY_ATTR_MSG_MAX_LEN = 0x00000002, + SBI_MPXY_ATTR_MSG_SEND_TIMEOUT = 0x00000003, + SBI_MPXY_ATTR_MSG_COMPLETION_TIMEOUT = 0x00000004, + SBI_MPXY_ATTR_CHANNEL_CAPABILITY = 0x00000005, + SBI_MPXY_ATTR_SSE_EVENT_ID = 0x00000006, + SBI_MPXY_ATTR_MSI_CONTROL = 0x00000007, + SBI_MPXY_ATTR_MSI_ADDR_LO = 0x00000008, + SBI_MPXY_ATTR_MSI_ADDR_HI = 0x00000009, + SBI_MPXY_ATTR_MSI_DATA = 0x0000000A, + SBI_MPXY_ATTR_EVENTS_STATE_CONTROL = 0x0000000B, + SBI_MPXY_ATTR_STD_ATTR_MAX_IDX, + /* + * Message protocol specific attributes, managed by + * the message protocol specification. + */ + SBI_MPXY_ATTR_MSGPROTO_ATTR_START = 0x80000000, + SBI_MPXY_ATTR_MSGPROTO_ATTR_END = 0xffffffff +}; + +/* Possible values of MSG_PROT_ID attribute */ +enum sbi_mpxy_msgproto_id { + SBI_MPXY_MSGPROTO_RPMI_ID = 0x0, +}; + +/** RPMI message protocol specific MPXY attributes */ +enum sbi_mpxy_rpmi_attribute_id { + SBI_MPXY_RPMI_ATTR_SERVICEGROUP_ID = SBI_MPXY_ATTR_MSGPROTO_ATTR_START, + SBI_MPXY_RPMI_ATTR_SERVICEGROUP_VERSION, + SBI_MPXY_RPMI_ATTR_MAX_ID, +}; + +/* Encoding of MSG_PROT_VER attribute */ +#define SBI_MPXY_MSG_PROT_VER_MAJOR(__ver) (((__ver) >> 16) & 0xffff) +#define SBI_MPXY_MSG_PROT_VER_MINOR(__ver) ((__ver) & 0xffff) +#define SBI_MPXY_MSG_PROT_MKVER(__maj, __min) (((__maj) << 16) | (__min)) + +/* Capabilities available through CHANNEL_CAPABILITY attribute */ +#define SBI_MPXY_CHAN_CAP_MSI BIT(0) +#define SBI_MPXY_CHAN_CAP_SSE BIT(1) +#define SBI_MPXY_CHAN_CAP_EVENTS_STATE BIT(2) +#define SBI_MPXY_CHAN_CAP_SEND_WITH_RESP BIT(3) +#define SBI_MPXY_CHAN_CAP_SEND_WITHOUT_RESP BIT(4) +#define SBI_MPXY_CHAN_CAP_GET_NOTIFICATIONS BIT(5) + /* SBI spec version fields */ #define SBI_SPEC_VERSION_DEFAULT 0x1 #define SBI_SPEC_VERSION_MAJOR_SHIFT 24 From patchwork Mon Feb 3 08:48:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957047 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 E92FEC02195 for ; Mon, 3 Feb 2025 08:50:32 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Uu01H7IJ6O9ecavhmm5JwVBzOxH9XSfuuqchQ6uYmWk=; b=hiPP4gm7r/CiGi h82nGzF8pG71WEt65ItRfOOuSRnPT03KV+OsNsr9bOdGUPo4wveRcwr7DEG/c73ds/ygwoQjTY//f MD4wZ8niDO5hBl6qL7bwoO3zz8DvXnDrUeeAlTaphTuVD+t4cMf0x6ik/NAQr66AkEkiaFiF5YrLN HhcPq+HH2Z4cBhIHR5+ehD1fJwYh2zRgwZYSqzZjDJ7rx3FXLv+04xbtONVo8QbFFQd/hA7GL68EE ocAe80qFryRFM5npYNaKs6tBOgdVomA+2ampjpnwzAtnnL/MF8PAsCMSebnxWg+nComTh0nqKItuz yEpfqGHG8OIm4WGQeiRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tesA0-0000000Eu3m-2aMp; Mon, 03 Feb 2025 08:50:28 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tes9y-0000000Eu1j-23RQ for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:50:27 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-4679d366adeso36828131cf.1 for ; Mon, 03 Feb 2025 00:50:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572625; x=1739177425; 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=XdK3RA2/Xw6yVMNVLx3NKCgbGjnJZG+z+r3IIEXb3Yg=; b=ghPx0nZvlbCUXmk43mIRv2hBwXNnZzUr67aGLYXZOrszaIQd+SaeL4yy+jK+/80xN1 whTgoMhczssMbh7cl4n+T5tlcLVC8FtBVVnckXZrNY9dKKygKlfiAm8HdCYdg/sJ1j7Z sTufUwgnwR9R7Q66jp+HSNzycZaL0UurAS/DBzu/DcFqmuxI5/pI//DFMJPuNaT17jtK AQzag6KYEndcAR12BoucNtvAoLnr3V+G91HhO66rnisgStjrVEem+V1QEFM0UvUZOZh1 yMYLOFZuMZPDgrV2Y3u4ysTeQKVsdcX0NJ2V+QTMtdz473Xp5XVasXrcZZ9k8dOVsmCM lfBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572625; x=1739177425; 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=XdK3RA2/Xw6yVMNVLx3NKCgbGjnJZG+z+r3IIEXb3Yg=; b=Sr9TTUXB82J1UCZ6DpCuD34vFQZfGNd8nNi6y3D9ScXUlx8/8mGHO5LJLKu0PeV9iz EBrBMboTOPhQ9v+H50eY3Xtz94Y1gVeYB1zcWL7J/SEVUz0ynDMgJKLXIR/q2yRz2IIz s5VhomL1HYRpurYR+463KLqUlUFWHq1n1mXyNncUy6x+ADFmootd0uPkCef7RYoudLON 2s2hIrNz6bMdVzP69c+4TKsszuYCAKTlQEf3pkdOrJLkmQ86Ukfdzb+k3I++9wZhXsQn BgKePrUhcoHzpyBuploROG+puLXiT4g53V6JvHb+bf6jKF9uLFqzVg1Y0z5EoV6GTW+n ukxw== X-Forwarded-Encrypted: i=1; AJvYcCVO6t93SeQ7G8vc0Is0aieQsu+z/kq1FT2RXyxSa/nManDG7aBW/gqbFtv3xek65f0HOOpNdwWyCihR2Q==@lists.infradead.org X-Gm-Message-State: AOJu0YyLJT4ma819zrmHqD5bSoZLyHHGfIR8vaq06qg3hYXl8aLgATvf D1GUs5K6RjIiKG4AUhUCfEH2ufUw3dTPnZWAP5+pmKuFGdNoh1ZP9TMZQe+XMg4= X-Gm-Gg: ASbGncvxGxSxpusmKbcKPl6m+4DsyTsT6ihaGmC79aKfGTJiS5FWdQuISR9npshUg73 aP6mKjpPELLbu658kuTy/kAXsGfDy4f2nceSwcKJ/xcBO9+xjurly3grBxkS9qwieIemoVBK+76 zA5RhPAiTwNGyp1gUSbIXbda2eLu6ML3GHkmsvjI+XqBSK19q3L9bX5GGDmr8Lz8VkwF9emzPed ls3L8kFAVfHgIt8pi1jtZvSP8jkqZtSC/Gyxkk+dUYwXSFPyUPtnmE2+khZIVVXZ0dKOkeKqhy7 MRzHDaDwY8F714jy7jGU/owBi4/LJ7F1sWWmlYPgy9HuBZ3Ap7sSMLI= X-Google-Smtp-Source: AGHT+IHVI9spQDZrHgsamoDpI1hVc9XGEsTGMyR+0ZZj8QriPFJvFNy8qUlPnrOP5LODn17USjnipw== X-Received: by 2002:a05:622a:1aa0:b0:467:52bd:c137 with SMTP id d75a77b69052e-46fdd354769mr237348941cf.7.1738572625551; Mon, 03 Feb 2025 00:50:25 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:50:24 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 05/17] mailbox: Add common header for RPMI messages sent via mailbox Date: Mon, 3 Feb 2025 14:18:54 +0530 Message-ID: <20250203084906.681418-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005026_530913_63766417 X-CRM114-Status: GOOD ( 16.86 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The RPMI based mailbox controller drivers and mailbox cliens need to share defines related to RPMI messages over mailbox interface so add a common header for this purpose. Co-developed-by: Rahul Pathak Signed-off-by: Rahul Pathak Signed-off-by: Anup Patel --- include/linux/mailbox/riscv-rpmi-message.h | 206 +++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 include/linux/mailbox/riscv-rpmi-message.h diff --git a/include/linux/mailbox/riscv-rpmi-message.h b/include/linux/mailbox/riscv-rpmi-message.h new file mode 100644 index 000000000000..2747a1840937 --- /dev/null +++ b/include/linux/mailbox/riscv-rpmi-message.h @@ -0,0 +1,206 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024 Ventana Micro Systems Inc. + */ + +#ifndef _LINUX_RISCV_RPMI_MESSAGE_H_ +#define _LINUX_RISCV_RPMI_MESSAGE_H_ + +#include + +/** RPMI version encode/decode macros */ +#define RPMI_VER_MAJOR(__ver) (((__ver) >> 16) & 0xffff) +#define RPMI_VER_MINOR(__ver) ((__ver) & 0xffff) +#define RPMI_MKVER(__maj, __min) (((__maj) << 16) | (__min)) + +/** RPMI message header */ +struct rpmi_message_header { + __le16 servicegroup_id; + u8 service_id; + u8 flags; + __le16 datalen; + __le16 token; +}; + +/** RPMI message */ +struct rpmi_message { + struct rpmi_message_header header; + u8 data[]; +}; + +/** RPMI notification event */ +struct rpmi_notification_event { + __le16 event_datalen; + u8 event_id; + u8 reserved; + u8 event_data[]; +}; + +/** RPMI error codes */ +enum rpmi_error_codes { + RPMI_SUCCESS = 0, + RPMI_ERR_FAILED = -1, + RPMI_ERR_NOTSUPP = -2, + RPMI_ERR_INVALID_PARAM = -3, + RPMI_ERR_DENIED = -4, + RPMI_ERR_INVALID_ADDR = -5, + RPMI_ERR_ALREADY = -6, + RPMI_ERR_EXTENSION = -7, + RPMI_ERR_HW_FAULT = -8, + RPMI_ERR_BUSY = -9, + RPMI_ERR_INVALID_STATE = -10, + RPMI_ERR_BAD_RANGE = -11, + RPMI_ERR_TIMEOUT = -12, + RPMI_ERR_IO = -13, + RPMI_ERR_NO_DATA = -14, + RPMI_ERR_RESERVED_START = -15, + RPMI_ERR_RESERVED_END = -127, + RPMI_ERR_VENDOR_START = -128, +}; + +static inline int rpmi_to_linux_error(int rpmi_error) +{ + switch (rpmi_error) { + case RPMI_SUCCESS: + return 0; + case RPMI_ERR_INVALID_PARAM: + case RPMI_ERR_BAD_RANGE: + case RPMI_ERR_INVALID_STATE: + return -EINVAL; + case RPMI_ERR_DENIED: + return -EPERM; + case RPMI_ERR_INVALID_ADDR: + case RPMI_ERR_HW_FAULT: + return -EFAULT; + case RPMI_ERR_ALREADY: + return -EALREADY; + case RPMI_ERR_BUSY: + return -EBUSY; + case RPMI_ERR_TIMEOUT: + return -ETIMEDOUT; + case RPMI_ERR_IO: + return -ECOMM; + case RPMI_ERR_FAILED: + case RPMI_ERR_NOTSUPP: + case RPMI_ERR_NO_DATA: + case RPMI_ERR_EXTENSION: + default: + return -EOPNOTSUPP; + } +} + +/** RPMI linux mailbox attribute IDs */ +enum rpmi_mbox_attribute_id { + RPMI_MBOX_ATTR_SPEC_VERSION = 0, + RPMI_MBOX_ATTR_MAX_MSG_DATA_SIZE, + RPMI_MBOX_ATTR_SERVICEGROUP_ID, + RPMI_MBOX_ATTR_SERVICEGROUP_VERSION, + RPMI_MBOX_ATTR_MAX_ID, +}; + +/** RPMI linux mailbox message types */ +enum rpmi_mbox_message_type { + RPMI_MBOX_MSG_TYPE_GET_ATTRIBUTE = 0, + RPMI_MBOX_MSG_TYPE_SET_ATTRIBUTE, + RPMI_MBOX_MSG_TYPE_SEND_WITH_RESPONSE, + RPMI_MBOX_MSG_TYPE_SEND_WITHOUT_RESPONSE, + RPMI_MBOX_MSG_TYPE_NOTIFICATION_EVENT, + RPMI_MBOX_MSG_MAX_TYPE, +}; + +/** RPMI linux mailbox message instance */ +struct rpmi_mbox_message { + enum rpmi_mbox_message_type type; + union { + struct { + enum rpmi_mbox_attribute_id id; + u32 value; + } attr; + + struct { + u32 service_id; + void *request; + unsigned long request_len; + void *response; + unsigned long max_response_len; + unsigned long out_response_len; + } data; + + struct { + u16 event_datalen; + u8 event_id; + u8 *event_data; + } notif; + }; + int error; +}; + +/** RPMI linux mailbox message helper routines */ +static inline void rpmi_mbox_init_get_attribute(struct rpmi_mbox_message *msg, + enum rpmi_mbox_attribute_id id) +{ + msg->type = RPMI_MBOX_MSG_TYPE_GET_ATTRIBUTE; + msg->attr.id = id; + msg->attr.value = 0; + msg->error = 0; +} + +static inline void rpmi_mbox_init_set_attribute(struct rpmi_mbox_message *msg, + enum rpmi_mbox_attribute_id id, + u32 value) +{ + msg->type = RPMI_MBOX_MSG_TYPE_SET_ATTRIBUTE; + msg->attr.id = id; + msg->attr.value = value; + msg->error = 0; +} + +static inline void rpmi_mbox_init_send_with_response(struct rpmi_mbox_message *msg, + u32 service_id, + void *request, + unsigned long request_len, + void *response, + unsigned long max_response_len) +{ + msg->type = RPMI_MBOX_MSG_TYPE_SEND_WITH_RESPONSE; + msg->data.service_id = service_id; + msg->data.request = request; + msg->data.request_len = request_len; + msg->data.response = response; + msg->data.max_response_len = max_response_len; + msg->data.out_response_len = 0; + msg->error = 0; +} + +static inline void rpmi_mbox_init_send_without_response(struct rpmi_mbox_message *msg, + u32 service_id, + void *request, + unsigned long request_len) +{ + msg->type = RPMI_MBOX_MSG_TYPE_SEND_WITHOUT_RESPONSE; + msg->data.service_id = service_id; + msg->data.request = request; + msg->data.request_len = request_len; + msg->data.response = NULL; + msg->data.max_response_len = 0; + msg->data.out_response_len = 0; + msg->error = 0; +} + +static inline int rpmi_mbox_send_message(struct mbox_chan *chan, + struct rpmi_mbox_message *msg) +{ + int ret; + + /* Send message for the underlying mailbox channel */ + ret = mbox_send_message(chan, msg); + if (ret < 0) + return ret; + + /* Explicitly signal txdone for mailbox channel */ + ret = msg->error; + mbox_client_txdone(chan, ret); + return ret; +} + +#endif /* _LINUX_RISCV_RPMI_MESSAGE_H_ */ From patchwork Mon Feb 3 08:48:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957048 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 7D14CC02195 for ; Mon, 3 Feb 2025 08:50:45 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rNV404KOgmiMJVxWFtTqJrvz6An5iTbQkJPwc1iOLhw=; b=Qk4BuorkmqRuTi XM8ejdsXGBxTWTVCzywuTCbgZVhQE4Q/12oQTeXPLF22VS9sw6JJnLAkB7pWm9aFJwUfX8/QOjp4n jzL1TGFjvlYs0x3w8eC5O/zlcDnomm09mSEz0E8jzjXoXj9FhpmQIlLR8UjU049NPrm+paa82boLs YdqGY+JUpTeygNsevSfQo+PXcd/LQOIkmcKjlmUTP9wgoKzQzdceqIwSY5fpvL1T565Tt0YmdKDIK N0UxSJPYUpR1igjWRz3Gfg1fBX5GPCHsPNzG+wBXRg3uBiCjJzoveP+PDmHch024tf+LY8NGnFo88 uC6GMf+9VRL9ZjpK0Vdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tesAC-0000000Eu9h-0vFK; Mon, 03 Feb 2025 08:50:40 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesAA-0000000Eu7j-0oAq for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:50:39 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-46788c32a69so54859621cf.2 for ; Mon, 03 Feb 2025 00:50:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572637; x=1739177437; 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=bEEke79FPqkO/VnndNMxidgQ7SLPxTG5sIoJEJG0Da4=; b=O7O7D55nFKxYZGS+W4PjjNr5ITNRCrzfhZQhWkg2VEM/iuEGsIq294tM7t5gK31Csv oF7iph9MGSwEz0JxQJk8Ac6u3OnSijmfcLxqKgHjI74erFMj/rRacKrlUTWhbR10+QXs u3Q5+nCs+xD6cQl+m8O5Ci7PXPEFSIKaU4j3oeagPwelIIQOSHfFAuGo7xQQM7NqQVtp Wfz2Fu3EUEi6yB/uWL/+w9SKDv1R+Xi4tQko7NK9d8pqfZfc3/zHzXNOXZJJJT1VExFX 14jSPtQrOIAmFve2pVdXf8PdKxY3JYAZM8v5HRBpPQx7sKF58WdyOvYNi2psxJmCr9Mk paSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572637; x=1739177437; 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=bEEke79FPqkO/VnndNMxidgQ7SLPxTG5sIoJEJG0Da4=; b=W/mNAQHgsAAV8BBMgNvBL7WuH4JLufIf7+buexq6zFpSeeSR/2KzVHucDx9YiV1I5V phmPTEwH19OCRQGB2jAwKOn+IikhadcroqaBABPvFJLPgGMEz7fPhWs1y0ac7ZIBljpy TYWDBXpO47yA7k2l/M6Pauu1Nx5gmbySLw6+RLbL8BRqKLsvv6mhOQLLgNQWchYrAm6N /gfDiFqOFDtSyWnszrgwg+6aH9xxo0IMmDMUStSOFkkrORMMiS0HSIaZq6r66X4ROf5S ibO3oO8zw7ZHdDzoSUUIM6zGULjg5xM9WhzeyL6naIT0wtMPmhBBvuT3gHB7/4AKzkXc eTXQ== X-Forwarded-Encrypted: i=1; AJvYcCUaZjfAcNTU6yg7ADqFxAzEMEsXKOpzna727clRB8By3D9XxD+T43S9Hrg9tfzix3Z6aOfllmTv6syuSA==@lists.infradead.org X-Gm-Message-State: AOJu0Yw7kjK5xZhDSKzhbFgMmjfPd97kgmn/sgR9dzMCiTUCDGf7aaJX RZd+fsNevfXTSzbykdrCrBpmeMs8ASCiJWJfHYdsCtOLJrU1jCZD9uB/nctlq40= X-Gm-Gg: ASbGncuD5jkYYHM2jTSXYvYgeX7C9M/rVYj8v2mMjJVq/Mo38KKQ06hdTgeCE0wcjPA qoJ+flHc9OpYx/A+S7VxKAnC1UkS1u8cbsL7V9EyF20iADW3xl3Nb47klbYN5vIN/uG1XOBLbDI B4OhFo9+xOJXDDAKdCOiJSwhMlBxjUoJ4IyIkRAUJEYYpgRc4jK4equ6QmChZeSblACq02qwhUT 2TRDxpLIICA66tIUa2o0xm4iLXe61M/l9KdFt/N3gK96y6vLLxpJnKst7xWUrQ6OiMmMDe3hPrz 92jsjRoW8uJcoT6Vv+fOQ1xSs1/NohFxDw10BqnojyPpiltS3NlFXgI= X-Google-Smtp-Source: AGHT+IE+IlnE299Q+aB/GfcKf7IAlDPJGgUE1d2TnvZN/4dFlqe7+8HMm41wGojjNhxhbX5xqmUG+Q== X-Received: by 2002:a05:622a:1356:b0:467:87f4:a29f with SMTP id d75a77b69052e-46fd0bce85dmr283644871cf.45.1738572637284; Mon, 03 Feb 2025 00:50:37 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:50:35 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 06/17] mailbox: Allow controller specific mapping using fwnode Date: Mon, 3 Feb 2025 14:18:55 +0530 Message-ID: <20250203084906.681418-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005038_236157_9BCAFAD5 X-CRM114-Status: GOOD ( 19.07 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Introduce optional fw_node() callback which allows a mailbox controller driver to provide controller specific mapping using fwnode. The Linux OF framework already implements fwnode operations for the Linux DD framework so the fw_xlate() callback works fine with device tree as well. Signed-off-by: Anup Patel --- drivers/mailbox/mailbox.c | 44 ++++++++++++++++++------------ include/linux/mailbox_controller.h | 3 ++ 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index d3d26a2c9895..447edd212f0f 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -402,20 +402,29 @@ EXPORT_SYMBOL_GPL(mbox_bind_client); */ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) { + struct fwnode_reference_args fwspec; struct device *dev = cl->dev; struct mbox_controller *mbox; struct of_phandle_args spec; struct mbox_chan *chan; int ret; - if (!dev || !dev->of_node) { - pr_debug("%s: No owner device node\n", __func__); + if (!dev) { + pr_debug("%s: No owner device\n", __func__); return ERR_PTR(-ENODEV); } mutex_lock(&con_mutex); - if (of_parse_phandle_with_args(dev->of_node, "mboxes", + if (fwnode_property_get_reference_args(dev->fwnode, "mboxes", + "#mbox-cells", 0, index, &fwspec)) { + dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__); + mutex_unlock(&con_mutex); + return ERR_PTR(-ENODEV); + } + + if (dev->of_node && + of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells", index, &spec)) { dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__); mutex_unlock(&con_mutex); @@ -423,14 +432,20 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) } chan = ERR_PTR(-EPROBE_DEFER); - list_for_each_entry(mbox, &mbox_cons, node) - if (mbox->dev->of_node == spec.np) { + list_for_each_entry(mbox, &mbox_cons, node) { + if (mbox->fw_xlate && mbox->dev->fwnode == fwspec.fwnode) { + chan = mbox->fw_xlate(mbox, &fwspec); + if (!IS_ERR(chan)) + break; + } else if (mbox->of_xlate && mbox->dev->of_node == spec.np) { chan = mbox->of_xlate(mbox, &spec); if (!IS_ERR(chan)) break; } + } - of_node_put(spec.np); + if (dev->of_node) + of_node_put(spec.np); if (IS_ERR(chan)) { mutex_unlock(&con_mutex); @@ -449,15 +464,8 @@ EXPORT_SYMBOL_GPL(mbox_request_channel); struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, const char *name) { - struct device_node *np = cl->dev->of_node; - int index; - - if (!np) { - dev_err(cl->dev, "%s() currently only supports DT\n", __func__); - return ERR_PTR(-EINVAL); - } + int index = device_property_match_string(cl->dev, "mbox-names", name); - index = of_property_match_string(np, "mbox-names", name); if (index < 0) { dev_err(cl->dev, "%s() could not locate channel named \"%s\"\n", __func__, name); @@ -495,8 +503,8 @@ void mbox_free_channel(struct mbox_chan *chan) EXPORT_SYMBOL_GPL(mbox_free_channel); static struct mbox_chan * -of_mbox_index_xlate(struct mbox_controller *mbox, - const struct of_phandle_args *sp) +fw_mbox_index_xlate(struct mbox_controller *mbox, + const struct fwnode_reference_args *sp) { int ind = sp->args[0]; @@ -549,8 +557,8 @@ int mbox_controller_register(struct mbox_controller *mbox) spin_lock_init(&chan->lock); } - if (!mbox->of_xlate) - mbox->of_xlate = of_mbox_index_xlate; + if (!mbox->fw_xlate && !mbox->of_xlate) + mbox->fw_xlate = fw_mbox_index_xlate; mutex_lock(&con_mutex); list_add_tail(&mbox->node, &mbox_cons); diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h index 6fee33cb52f5..74352c244aba 100644 --- a/include/linux/mailbox_controller.h +++ b/include/linux/mailbox_controller.h @@ -66,6 +66,7 @@ struct mbox_chan_ops { * no interrupt rises. Ignored if 'txdone_irq' is set. * @txpoll_period: If 'txdone_poll' is in effect, the API polls for * last TX's status after these many millisecs + * @fw_xlate: Controller driver specific mapping of channel via fwnode * @of_xlate: Controller driver specific mapping of channel via DT * @poll_hrt: API private. hrtimer used to poll for TXDONE on all * channels. @@ -79,6 +80,8 @@ struct mbox_controller { bool txdone_irq; bool txdone_poll; unsigned txpoll_period; + struct mbox_chan *(*fw_xlate)(struct mbox_controller *mbox, + const struct fwnode_reference_args *sp); struct mbox_chan *(*of_xlate)(struct mbox_controller *mbox, const struct of_phandle_args *sp); /* Internal to API */ From patchwork Mon Feb 3 08:48:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957172 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 5C658C02193 for ; Mon, 3 Feb 2025 10:00: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TaEQECQ58DnqUyrzR4Iko94GSpdejIN+VbYfMOlobVk=; b=VvyYaGZyL8t2Ps bzGUjKVV1mXZ776enE1xZO0cvSsCh0bo8A/uGb994Us2PxddpQimx8ey2IDv6Iv4AK68R63QVZSWR E9Oque+Tm3yNw5+8aQVzoZ/Y1b03s5LhA1JxBlpILMOspiFT/8jkpAAUmLwKQrhdat4dNxDe2G9Uc qW0+hgPlu19KKw4IgNIArAbSHC5rUJhFdneF+emtcyPDKfZRJCTWA8RDIGs/NnRDtZfNhG8zgxMjS z65g4Km7FIlih0Ob45Mt2dF92HcVkFcZu23Z/R+GFXB+5elE0YySeYPngdqov5WNeg57ybgMf7EOG p24dNU2DFFXggR4QZBGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tetG3-0000000F3uq-3g8e; Mon, 03 Feb 2025 10:00:47 +0000 Received: from mail-qt1-f172.google.com ([209.85.160.172]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesAM-0000000EuFp-3CVl for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:50:52 +0000 Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-467a63f5d1cso34401951cf.0 for ; Mon, 03 Feb 2025 00:50:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572649; x=1739177449; 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=zvHOh18eDixZbyCHE3dlSgkntrANMrSYijtX5CJYiyM=; b=nt+eQnVyD6iWBfLu+teKBJo8czBwYw2UeQd3MmHdnx0vkn6VFiebFjUy5GpTBp3K3a +Nka0HvulZibwOGich6r4JUGLpr+UUTnyiqlzRvQ2nhzzDjzgAhzbftKNp7MBW9akOSP Ims0r1dhCyvoibQbOjshpfsBfMYJeut10I+pINBAC9pd/GmYDnAlJ+ItTvYiIrkHIVLY 67pIigbWFmVjsFEKIHhi4FCpOZZArFnS4fW1mw57f8L+eEx5k+JsKEDMVUf4mQN+8NBv lfV1cRUo6UF/RJeTAqzY0hwKlTSlkAtSapi899Ig3T2Qbfimu9UsNOx0q8jayM3p1ZHB 30yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572649; x=1739177449; 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=zvHOh18eDixZbyCHE3dlSgkntrANMrSYijtX5CJYiyM=; b=Atj4iVjuOpxKocAVTSOtemPz9+M3MW/OZvo9MRgW6raACsBx0tP6Ubb9+MOJZZVuxh N8igdHNvdGNomtHNgn2X3px6bX/5tzqxhEIPutlpvOBTfKzX7/Rg6r+KJ9gcQUnvrNaD 9Jy7I7QJGGG48+nU2FrrFxTB2LWX1wQ6oTfHeda74NGRiSGH7Anz8zifFKBxrX5wawbA M0X/OhMK+Q2m+Mn1MHTeht9Ek8I8wXgcRg8agXptKu10+FSLvny6QTvy+MjOTaNHuGL1 wb2hHoCOftz5eEb2ZRFVyav96/Wp1fVgQ6o5U5D3O1icFZVMS0GRzLQvjRTAJBEhmCjF rjdQ== X-Forwarded-Encrypted: i=1; AJvYcCXmeRfwGMe5LItS/eB9a7gVFq12FJBGXiT/thB41zxto4qWq0/uRDpLzWdwx3p5e6mAdbAHNPK0qfar/g==@lists.infradead.org X-Gm-Message-State: AOJu0Yzp1ZN/ht7hJKhnS2xf//qmpBCh12lATiQg+VpD/KoNDkZIw+AF Dvg/v1OU7hNDT8RUc6NN0veqs/Z1m2TtxF7wfY9vrJ1S7KySkYI8p/SO7iVi4fs= X-Gm-Gg: ASbGnctn1potsms8bkbAL4QmZ60TwVvQp3ZxqiDhpZe1HIWcESlJxM4utuSbvO/pPgR 9Ao7GUlS0Cp873ITVZueuH5nU+eD7X/b06PCO1j4GWsamNwtsCVm9jEDRV6eDE0OCdBx72IKLSx qe32g2yXeNjAE+PhotIsgp/k9eBxH+rSI8GCwqoCU0Xf1BXjn5bS0SpHR9aB/qh3ZARoFe8EI/D EdjFrtH8HLOemYJaCEPlN3oXGp4inxA9EPfkN0Xh5bx/9gzFv/btBUDB6bi0hmOSvUXX7hy/vp6 kOWuwbj+6F3fOD1hLYlnm0/PCzd/CLU5tB1NAdRfNJwT/yHwZMrfMJI= X-Google-Smtp-Source: AGHT+IGQuKPwozIE8IJEfy9gUz52REuh1PR//DiqAfFcpK0xQvGmWvPUmAubkWWBZegYEtuMRNKqOw== X-Received: by 2002:a05:622a:34a:b0:46c:86d8:fb7 with SMTP id d75a77b69052e-46fd0b6f3b8mr290653101cf.34.1738572649116; Mon, 03 Feb 2025 00:50:49 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:50:47 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 07/17] mailbox: Add RISC-V SBI message proxy (MPXY) based mailbox driver Date: Mon, 3 Feb 2025 14:18:56 +0530 Message-ID: <20250203084906.681418-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005050_818395_EFDC48AE X-CRM114-Status: GOOD ( 24.99 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add a mailbox controller driver for the new SBI message proxy extension which is part of the SBI v3.0 specification. Co-developed-by: Rahul Pathak Signed-off-by: Rahul Pathak Signed-off-by: Anup Patel --- drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/riscv-sbi-mpxy-mbox.c | 1004 +++++++++++++++++++++++++ 3 files changed, 1017 insertions(+) create mode 100644 drivers/mailbox/riscv-sbi-mpxy-mbox.c diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index ed52db272f4d..cc29a1a1974a 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -330,4 +330,15 @@ config THEAD_TH1520_MBOX kernel is running, and E902 core used for power management among other things. +config RISCV_SBI_MPXY_MBOX + tristate "RISC-V SBI Message Proxy (MPXY) Mailbox" + depends on RISCV_SBI + default RISCV + help + Mailbox driver implementation for RISC-V SBI Message Proxy (MPXY) + extension. This mailbox driver is used to send messages to the + remote processor through the SBI implementation (M-mode firmware + or HS-mode hypervisor). Say Y here if you want to have this support. + If unsure say N. + endif diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index 9a1542b55539..833d72649790 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -70,3 +70,5 @@ obj-$(CONFIG_QCOM_CPUCP_MBOX) += qcom-cpucp-mbox.o obj-$(CONFIG_QCOM_IPCC) += qcom-ipcc.o obj-$(CONFIG_THEAD_TH1520_MBOX) += mailbox-th1520.o + +obj-$(CONFIG_RISCV_SBI_MPXY_MBOX) += riscv-sbi-mpxy-mbox.o diff --git a/drivers/mailbox/riscv-sbi-mpxy-mbox.c b/drivers/mailbox/riscv-sbi-mpxy-mbox.c new file mode 100644 index 000000000000..4021f62ff487 --- /dev/null +++ b/drivers/mailbox/riscv-sbi-mpxy-mbox.c @@ -0,0 +1,1004 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * RISC-V SBI Message Proxy (MPXY) mailbox controller driver + * + * Copyright (C) 2024 Ventana Micro Systems Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* ====== SBI MPXY extension data structures ====== */ + +/* SBI MPXY MSI related channel attributes */ +struct sbi_mpxy_msi_info { + /* Lower 32-bits of the MSI target address */ + u32 msi_addr_lo; + /* Upper 32-bits of the MSI target address */ + u32 msi_addr_hi; + /* MSI data value */ + u32 msi_data; +}; + +/* + * SBI MPXY standard channel attributes. + * + * NOTE: The sequence of attribute fields are as-per the + * defined sequence in the attribute table in spec (or + * as-per the enum sbi_mpxy_attribute_id). + */ +struct sbi_mpxy_channel_attrs { + /* Message protocol ID */ + u32 msg_proto_id; + /* Message protocol version */ + u32 msg_proto_version; + /* Message protocol maximum message length */ + u32 msg_max_len; + /* Message protocol message send timeout in microseconds */ + u32 msg_send_timeout; + /* Message protocol message completion timeout in microseconds */ + u32 msg_completion_timeout; + /* Bit array for channel capabilities */ + u32 capability; + /* SSE event ID */ + u32 sse_event_id; + /* MSI enable/disable control knob */ + u32 msi_control; + /* Channel MSI info */ + struct sbi_mpxy_msi_info msi_info; + /* Events state control */ + u32 events_state_ctrl; +}; + +/* + * RPMI specific SBI MPXY channel attributes. + * + * NOTE: The sequence of attribute fields are as-per the + * defined sequence in the attribute table in spec (or + * as-per the enum sbi_mpxy_rpmi_attribute_id). + */ +struct sbi_mpxy_rpmi_channel_attrs { + /* RPMI service group ID */ + u32 servicegroup_id; + /* RPMI service group version */ + u32 servicegroup_version; +}; + +/* SBI MPXY channel IDs data in shared memory */ +struct sbi_mpxy_channel_ids_data { + /* Remaining number of channel ids */ + __le32 remaining; + /* Returned channel ids in current function call */ + __le32 returned; + /* Returned channel id array */ + __le32 channel_array[]; +}; + +/* SBI MPXY notification data in shared memory */ +struct sbi_mpxy_notification_data { + /* Remaining number of notification events */ + __le32 remaining; + /* Number of notification events returned */ + __le32 returned; + /* Number of notification events lost */ + __le32 lost; + /* Reserved for future use */ + __le32 reserved; + /* Returned channel id array */ + u8 events_data[]; +}; + +/* ====== MPXY data structures & helper routines ====== */ + +/* MPXY Per-CPU or local context */ +struct mpxy_local { + /* Shared memory base address */ + void *shmem; + /* Shared memory physical address */ + phys_addr_t shmem_phys_addr; + /* Flag representing whether shared memory is active or not */ + bool shmem_active; +}; + +static DEFINE_PER_CPU(struct mpxy_local, mpxy_local); +static unsigned long mpxy_shmem_size; +static bool mpxy_shmem_init_done; + +static int mpxy_get_channel_count(u32 *channel_count) +{ + struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local); + struct sbi_mpxy_channel_ids_data *sdata = mpxy->shmem; + u32 remaining, returned; + struct sbiret sret; + + if (!mpxy->shmem_active) + return -ENODEV; + if (!channel_count) + return -EINVAL; + + get_cpu(); + + /* Get the remaining and returned fields to calculate total */ + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_GET_CHANNEL_IDS, + 0, 0, 0, 0, 0, 0); + if (!sret.error) { + remaining = le32_to_cpu(sdata->remaining); + returned = le32_to_cpu(sdata->returned); + *channel_count = remaining + returned; + } + + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static int mpxy_get_channel_ids(u32 channel_count, u32 *channel_ids) +{ + u32 remaining, returned, sidx, start_index = 0, cidx = 0; + struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local); + struct sbi_mpxy_channel_ids_data *sdata = mpxy->shmem; + struct sbiret sret; + + if (!mpxy->shmem_active) + return -ENODEV; + if (!channel_count || !channel_ids) + return -EINVAL; + + get_cpu(); + + do { + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_GET_CHANNEL_IDS, + start_index, 0, 0, 0, 0, 0); + if (sret.error) + goto done; + + remaining = le32_to_cpu(sdata->remaining); + returned = le32_to_cpu(sdata->returned); + + for (sidx = 0; sidx < returned && cidx < channel_count; sidx++) { + channel_ids[cidx] = le32_to_cpu(sdata->channel_array[sidx]); + cidx += 1; + } + + start_index = cidx; + + } while (remaining); + +done: + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static int mpxy_read_attrs(u32 channel_id, u32 base_attrid, u32 attr_count, + u32 *attrs_buf) +{ + struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local); + struct sbiret sret; + u32 i; + + if (!mpxy->shmem_active) + return -ENODEV; + if (!attr_count || !attrs_buf) + return -EINVAL; + + get_cpu(); + + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_READ_ATTRS, + channel_id, base_attrid, attr_count, 0, 0, 0); + if (!sret.error) { + for (i = 0; i < attr_count; i++) + attrs_buf[i] = le32_to_cpu(((__le32 *)mpxy->shmem)[i]); + } + + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static int mpxy_write_attrs(u32 channel_id, u32 base_attrid, u32 attr_count, + u32 *attrs_buf) +{ + struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local); + struct sbiret sret; + u32 i; + + if (!mpxy->shmem_active) + return -ENODEV; + if (!attr_count || !attrs_buf) + return -EINVAL; + + get_cpu(); + + for (i = 0; i < attr_count; i++) + ((__le32 *)mpxy->shmem)[i] = cpu_to_le32(attrs_buf[i]); + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_WRITE_ATTRS, + channel_id, base_attrid, attr_count, 0, 0, 0); + + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static int mpxy_send_message_with_resp(u32 channel_id, u32 msg_id, + void *tx, unsigned long tx_len, + void *rx, unsigned long max_rx_len, + unsigned long *rx_len) +{ + struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local); + unsigned long rx_bytes; + struct sbiret sret; + + if (!mpxy->shmem_active) + return -ENODEV; + if (!tx && tx_len) + return -EINVAL; + + get_cpu(); + + /* Message protocols allowed to have no data in messages */ + if (tx_len) + memcpy(mpxy->shmem, tx, tx_len); + + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_SEND_MSG_WITH_RESP, + channel_id, msg_id, tx_len, 0, 0, 0); + if (rx && !sret.error) { + rx_bytes = sret.value; + if (rx_bytes > max_rx_len) { + put_cpu(); + return -ENOSPC; + } + + memcpy(rx, mpxy->shmem, rx_bytes); + if (rx_len) + *rx_len = rx_bytes; + } + + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static int mpxy_send_message_without_resp(u32 channel_id, u32 msg_id, + void *tx, unsigned long tx_len) +{ + struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local); + struct sbiret sret; + + if (!mpxy->shmem_active) + return -ENODEV; + if (!tx && tx_len) + return -EINVAL; + + get_cpu(); + + /* Message protocols allowed to have no data in messages */ + if (tx_len) + memcpy(mpxy->shmem, tx, tx_len); + + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_SEND_MSG_WITHOUT_RESP, + channel_id, msg_id, tx_len, 0, 0, 0); + + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static int mpxy_get_notifications(u32 channel_id, + struct sbi_mpxy_notification_data *notif_data, + unsigned long *events_data_len) +{ + struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local); + struct sbiret sret; + + if (!mpxy->shmem_active) + return -ENODEV; + if (!notif_data || !events_data_len) + return -EINVAL; + + get_cpu(); + + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_GET_NOTIFICATION_EVENTS, + channel_id, 0, 0, 0, 0, 0); + if (!sret.error) { + memcpy(notif_data, mpxy->shmem, sret.value + 16); + *events_data_len = sret.value; + } + + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static unsigned long mpxy_get_shmem_size(void) +{ + struct sbiret sret; + + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_GET_SHMEM_SIZE, + 0, 0, 0, 0, 0, 0); + if (sret.error) + return sbi_err_map_linux_errno(sret.error); + + return sret.value; +} + +static int mpxy_cleanup_shmem(unsigned int cpu) +{ + struct mpxy_local *mpxy; + struct sbiret sret; + + mpxy = per_cpu_ptr(&mpxy_local, cpu); + if (!mpxy->shmem_active) + return -EINVAL; + + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_SET_SHMEM, + -1U, -1U, 0, 0, 0, 0); + if (sret.error) + return sbi_err_map_linux_errno(sret.error); + + free_pages((unsigned long)mpxy->shmem, get_order(mpxy_shmem_size)); + + mpxy->shmem = NULL; + mpxy->shmem_phys_addr = 0; + mpxy->shmem_active = false; + + return 0; +} + +static int mpxy_setup_shmem(unsigned int cpu) +{ + struct page *shmem_page; + struct mpxy_local *mpxy; + struct sbiret sret; + + mpxy = per_cpu_ptr(&mpxy_local, cpu); + if (mpxy->shmem_active) + return -EINVAL; + + shmem_page = alloc_pages(GFP_KERNEL | __GFP_ZERO, get_order(mpxy_shmem_size)); + if (!shmem_page) + return -ENOMEM; + + /* + * Linux setup of shmem is done in mpxy OVERWRITE mode. + * flags[1:0] = 00b + */ + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_SET_SHMEM, + page_to_phys(shmem_page), 0, 0, 0, 0, 0); + if (sret.error) { + free_pages((unsigned long)page_to_virt(shmem_page), + get_order(mpxy_shmem_size)); + return sbi_err_map_linux_errno(sret.error); + } + + mpxy->shmem = page_to_virt(shmem_page); + mpxy->shmem_phys_addr = page_to_phys(shmem_page); + mpxy->shmem_active = true; + + return 0; +} + +/* ====== MPXY mailbox data structures ====== */ + +/* MPXY mailbox channel */ +struct mpxy_mbox_channel { + struct mpxy_mbox *mbox; + u32 channel_id; + struct sbi_mpxy_channel_attrs attrs; + struct sbi_mpxy_rpmi_channel_attrs rpmi_attrs; + struct sbi_mpxy_notification_data *notif; + u32 max_xfer_len; + bool have_events_state; + u32 msi_index; + u32 msi_irq; + bool started; +}; + +/* MPXY mailbox */ +struct mpxy_mbox { + struct device *dev; + u32 channel_count; + struct mpxy_mbox_channel *channels; + u32 msi_count; + struct mpxy_mbox_channel **msi_index_to_channel; + struct mbox_controller controller; +}; + +/* ====== MPXY RPMI processing ====== */ + +static int mpxy_mbox_send_rpmi_data(struct mpxy_mbox_channel *mchan, + struct rpmi_mbox_message *msg) +{ + int rc = 0; + + switch (msg->type) { + case RPMI_MBOX_MSG_TYPE_GET_ATTRIBUTE: + switch (msg->attr.id) { + case RPMI_MBOX_ATTR_SPEC_VERSION: + msg->attr.value = mchan->attrs.msg_proto_version; + break; + case RPMI_MBOX_ATTR_MAX_MSG_DATA_SIZE: + msg->attr.value = mchan->max_xfer_len; + break; + case RPMI_MBOX_ATTR_SERVICEGROUP_ID: + msg->attr.value = mchan->rpmi_attrs.servicegroup_id; + break; + case RPMI_MBOX_ATTR_SERVICEGROUP_VERSION: + msg->attr.value = mchan->rpmi_attrs.servicegroup_version; + break; + default: + rc = -EOPNOTSUPP; + break; + } + break; + case RPMI_MBOX_MSG_TYPE_SET_ATTRIBUTE: + /* None of the RPMI linux mailbox attributes are writeable */ + rc = -EOPNOTSUPP; + break; + case RPMI_MBOX_MSG_TYPE_SEND_WITH_RESPONSE: + if ((!msg->data.request && msg->data.request_len) || + (msg->data.request && + msg->data.request_len > mchan->max_xfer_len) || + (!msg->data.response && msg->data.max_response_len)) { + rc = -EINVAL; + break; + } + if (!(mchan->attrs.capability & SBI_MPXY_CHAN_CAP_SEND_WITH_RESP)) { + rc = -EIO; + break; + } + rc = mpxy_send_message_with_resp(mchan->channel_id, + msg->data.service_id, + msg->data.request, + msg->data.request_len, + msg->data.response, + msg->data.max_response_len, + &msg->data.out_response_len); + break; + case RPMI_MBOX_MSG_TYPE_SEND_WITHOUT_RESPONSE: + if ((!msg->data.request && msg->data.request_len) || + (msg->data.request && + msg->data.request_len > mchan->max_xfer_len)) { + rc = -EINVAL; + break; + } + if (!(mchan->attrs.capability & SBI_MPXY_CHAN_CAP_SEND_WITHOUT_RESP)) { + rc = -EIO; + break; + } + rc = mpxy_send_message_without_resp(mchan->channel_id, + msg->data.service_id, + msg->data.request, + msg->data.request_len); + break; + default: + rc = -EOPNOTSUPP; + break; + } + + msg->error = rc; + return 0; +} + +static void mpxy_mbox_peek_rpmi_data(struct mbox_chan *chan, + struct mpxy_mbox_channel *mchan, + struct sbi_mpxy_notification_data *notif, + unsigned long events_data_len) +{ + struct rpmi_notification_event *event; + unsigned long pos = 0, event_size; + struct rpmi_mbox_message msg; + + while ((pos < events_data_len) && !(pos & 0x3) && + ((events_data_len - pos) <= sizeof(*event))) { + event = (struct rpmi_notification_event *)(notif->events_data + pos); + + msg.type = RPMI_MBOX_MSG_TYPE_NOTIFICATION_EVENT; + msg.notif.event_datalen = le16_to_cpu(event->event_datalen); + msg.notif.event_id = event->event_id; + msg.notif.event_data = event->event_data; + msg.error = 0; + + event_size = sizeof(*event) + msg.notif.event_datalen; + if (event_size > (events_data_len - pos)) { + event_size = events_data_len - pos; + goto skip_event; + } + if (event_size & 0x3) + goto skip_event; + + mbox_chan_received_data(chan, &msg); + +skip_event: + pos += event_size; + } +} + +static int mpxy_mbox_read_rpmi_attrs(struct mpxy_mbox_channel *mchan) +{ + return mpxy_read_attrs(mchan->channel_id, + SBI_MPXY_ATTR_MSGPROTO_ATTR_START, + sizeof(mchan->rpmi_attrs) / sizeof(u32), + (u32 *)&mchan->rpmi_attrs); +} + +/* ====== MPXY mailbox callbacks ====== */ + +static int mpxy_mbox_send_data(struct mbox_chan *chan, void *data) +{ + struct mpxy_mbox_channel *mchan = chan->con_priv; + + if (mchan->attrs.msg_proto_id == SBI_MPXY_MSGPROTO_RPMI_ID) + return mpxy_mbox_send_rpmi_data(mchan, data); + + return -EOPNOTSUPP; +} + +static bool mpxy_mbox_peek_data(struct mbox_chan *chan) +{ + struct mpxy_mbox_channel *mchan = chan->con_priv; + struct sbi_mpxy_notification_data *notif = mchan->notif; + bool have_notifications = false; + unsigned long data_len; + int rc; + + if (!(mchan->attrs.capability & SBI_MPXY_CHAN_CAP_GET_NOTIFICATIONS)) + return false; + + while (1) { + rc = mpxy_get_notifications(mchan->channel_id, notif, &data_len); + if (rc || !data_len) + break; + + if (mchan->attrs.msg_proto_id == SBI_MPXY_MSGPROTO_RPMI_ID) + mpxy_mbox_peek_rpmi_data(chan, mchan, notif, data_len); + + have_notifications = true; + } + + return have_notifications; +} + +static irqreturn_t mpxy_mbox_irq_event(int irq, void *dev_id) +{ + /* We only have MSI for notification so just wakeup IRQ thread */ + return IRQ_WAKE_THREAD; +} + +static irqreturn_t mpxy_mbox_irq_thread(int irq, void *dev_id) +{ + mpxy_mbox_peek_data(dev_id); + return IRQ_HANDLED; +} + +static int mpxy_mbox_setup_msi(struct mbox_chan *chan, + struct mpxy_mbox_channel *mchan) +{ + struct device *dev = mchan->mbox->dev; + int rc; + + /* Do nothing if MSI not supported */ + if (mchan->msi_irq == U32_MAX) + return 0; + + /* Fail if MSI already enabled */ + if (mchan->attrs.msi_control) + return -EALREADY; + + /* Request channel MSI handler */ + rc = request_threaded_irq(mchan->msi_irq, + mpxy_mbox_irq_event, + mpxy_mbox_irq_thread, + 0, dev_name(dev), chan); + if (rc) { + dev_err(dev, "failed to request MPXY channel 0x%x IRQ\n", + mchan->channel_id); + return rc; + } + + /* Enable channel MSI control */ + mchan->attrs.msi_control = 1; + rc = mpxy_write_attrs(mchan->channel_id, SBI_MPXY_ATTR_MSI_CONTROL, + 1, &mchan->attrs.msi_control); + if (rc) { + dev_err(dev, "enable MSI control failed for MPXY channel 0x%x\n", + mchan->channel_id); + mchan->attrs.msi_control = 0; + free_irq(mchan->msi_irq, chan); + return rc; + } + + return 0; +} + +static void mpxy_mbox_cleanup_msi(struct mbox_chan *chan, + struct mpxy_mbox_channel *mchan) +{ + struct device *dev = mchan->mbox->dev; + int rc; + + /* Do nothing if MSI not supported */ + if (mchan->msi_irq == U32_MAX) + return; + + /* Do nothing if MSI already disabled */ + if (!mchan->attrs.msi_control) + return; + + /* Disable channel MSI control */ + mchan->attrs.msi_control = 0; + rc = mpxy_write_attrs(mchan->channel_id, SBI_MPXY_ATTR_MSI_CONTROL, + 1, &mchan->attrs.msi_control); + if (rc) { + dev_err(dev, "disable MSI control failed for MPXY channel 0x%x\n", + mchan->channel_id); + } + + /* Free channel MSI handler */ + free_irq(mchan->msi_irq, chan); +} + +static int mpxy_mbox_setup_events(struct mpxy_mbox_channel *mchan) +{ + struct device *dev = mchan->mbox->dev; + int rc; + + /* Do nothing if events state not supported */ + if (!mchan->have_events_state) + return 0; + + /* Fail if events state already enabled */ + if (mchan->attrs.events_state_ctrl) + return -EALREADY; + + /* Enable channel events state */ + mchan->attrs.events_state_ctrl = 1; + rc = mpxy_write_attrs(mchan->channel_id, SBI_MPXY_ATTR_EVENTS_STATE_CONTROL, + 1, &mchan->attrs.events_state_ctrl); + if (rc) { + dev_err(dev, "enable events state failed for MPXY channel 0x%x\n", + mchan->channel_id); + mchan->attrs.events_state_ctrl = 0; + return rc; + } + + return 0; +} + +static void mpxy_mbox_cleanup_events(struct mpxy_mbox_channel *mchan) +{ + struct device *dev = mchan->mbox->dev; + int rc; + + /* Do nothing if events state not supported */ + if (!mchan->have_events_state) + return; + + /* Do nothing if events state already disabled */ + if (!mchan->attrs.events_state_ctrl) + return; + + /* Disable channel events state */ + mchan->attrs.events_state_ctrl = 0; + rc = mpxy_write_attrs(mchan->channel_id, SBI_MPXY_ATTR_EVENTS_STATE_CONTROL, + 1, &mchan->attrs.events_state_ctrl); + if (rc) { + dev_err(dev, "disable events state failed for MPXY channel 0x%x\n", + mchan->channel_id); + } +} + +static int mpxy_mbox_startup(struct mbox_chan *chan) +{ + struct mpxy_mbox_channel *mchan = chan->con_priv; + int rc; + + if (mchan->started) + return -EALREADY; + + /* Setup channel MSI */ + rc = mpxy_mbox_setup_msi(chan, mchan); + if (rc) + return rc; + + /* Setup channel notification events */ + rc = mpxy_mbox_setup_events(mchan); + if (rc) { + mpxy_mbox_cleanup_msi(chan, mchan); + return rc; + } + + /* Mark the channel as started */ + mchan->started = true; + + return 0; +} + +static void mpxy_mbox_shutdown(struct mbox_chan *chan) +{ + struct mpxy_mbox_channel *mchan = chan->con_priv; + + if (!mchan->started) + return; + + /* Mark the channel as stopped */ + mchan->started = false; + + /* Cleanup channel notification events */ + mpxy_mbox_cleanup_events(mchan); + + /* Cleanup channel MSI */ + mpxy_mbox_cleanup_msi(chan, mchan); +} + +static const struct mbox_chan_ops mpxy_mbox_ops = { + .send_data = mpxy_mbox_send_data, + .peek_data = mpxy_mbox_peek_data, + .startup = mpxy_mbox_startup, + .shutdown = mpxy_mbox_shutdown, +}; + +/* ====== MPXY platform driver ===== */ + +static void mpxy_mbox_msi_write(struct msi_desc *desc, struct msi_msg *msg) +{ + struct device *dev = msi_desc_to_dev(desc); + struct mpxy_mbox *mbox = dev_get_drvdata(dev); + struct mpxy_mbox_channel *mchan; + struct sbi_mpxy_msi_info *minfo; + int rc; + + mchan = mbox->msi_index_to_channel[desc->msi_index]; + if (!mchan) { + dev_warn(dev, "MPXY channel not available for MSI index %d\n", + desc->msi_index); + return; + } + + minfo = &mchan->attrs.msi_info; + minfo->msi_addr_lo = msg->address_lo; + minfo->msi_addr_hi = msg->address_hi; + minfo->msi_data = msg->data; + + rc = mpxy_write_attrs(mchan->channel_id, SBI_MPXY_ATTR_MSI_ADDR_LO, + sizeof(*minfo) / sizeof(u32), (u32 *)minfo); + if (rc) { + dev_warn(dev, "failed to write MSI info for MPXY channel 0x%x\n", + mchan->channel_id); + } +} + +static struct mbox_chan *mpxy_mbox_fw_xlate(struct mbox_controller *ctlr, + const struct fwnode_reference_args *pa) +{ + struct mpxy_mbox *mbox = container_of(ctlr, struct mpxy_mbox, controller); + struct mpxy_mbox_channel *mchan; + u32 i; + + if (pa->nargs != 2) + return ERR_PTR(-EINVAL); + + for (i = 0; i < mbox->channel_count; i++) { + mchan = &mbox->channels[i]; + if (mchan->channel_id == pa->args[0] && + mchan->attrs.msg_proto_id == pa->args[1]) + return &mbox->controller.chans[i]; + } + + return ERR_PTR(-ENOENT); +} + +static int mpxy_mbox_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mpxy_mbox_channel *mchan; + struct mpxy_mbox *mbox; + int i, msi_idx, rc; + u32 *channel_ids; + + /* + * Initialize MPXY shared memory only once. This also ensures + * that SBI MPXY mailbox is probed only once. + */ + if (mpxy_shmem_init_done) { + dev_err(dev, "SBI MPXY mailbox already initialized\n"); + return -EALREADY; + } + + /* Probe for SBI MPXY extension */ + if (sbi_spec_version < sbi_mk_version(1, 0) || + sbi_probe_extension(SBI_EXT_MPXY) <= 0) { + dev_info(dev, "SBI MPXY extension not available\n"); + return -ENODEV; + } + + /* Find-out shared memory size */ + mpxy_shmem_size = mpxy_get_shmem_size(); + + /* Setup cpuhp notifier for per-CPU MPXY shared memory */ + cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "riscv/sbi-mpxy-shmem", + mpxy_setup_shmem, mpxy_cleanup_shmem); + + /* Mark as MPXY shared memory initialization done */ + mpxy_shmem_init_done = true; + + /* Allocate mailbox instance */ + mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); + if (!mbox) + return -ENOMEM; + mbox->dev = dev; + platform_set_drvdata(pdev, mbox); + + /* Find-out of number of channels */ + rc = mpxy_get_channel_count(&mbox->channel_count); + if (rc) + return dev_err_probe(dev, rc, "failed to get number of MPXY channels\n"); + if (!mbox->channel_count) + dev_err_probe(dev, -ENODEV, "no MPXY channels available\n"); + + /* Allocate and fetch all channel IDs */ + channel_ids = devm_kcalloc(dev, mbox->channel_count, + sizeof(*channel_ids), GFP_KERNEL); + if (!channel_ids) + return -ENOMEM; + rc = mpxy_get_channel_ids(mbox->channel_count, channel_ids); + if (rc) + return dev_err_probe(dev, rc, "failed to MPXY channel IDs\n"); + + /* Populate all channels */ + mbox->channels = devm_kcalloc(dev, mbox->channel_count, + sizeof(*mbox->channels), GFP_KERNEL); + if (!mbox->channels) + return -ENOMEM; + for (i = 0; i < mbox->channel_count; i++) { + mchan = &mbox->channels[i]; + mchan->mbox = mbox; + mchan->channel_id = channel_ids[i]; + + rc = mpxy_read_attrs(mchan->channel_id, SBI_MPXY_ATTR_MSG_PROT_ID, + sizeof(mchan->attrs) / sizeof(u32), + (u32 *)&mchan->attrs); + if (rc) { + return dev_err_probe(dev, rc, + "MPXY channel 0x%x read attrs failed\n", + mchan->channel_id); + } + + if (mchan->attrs.msg_proto_id == SBI_MPXY_MSGPROTO_RPMI_ID) { + rc = mpxy_mbox_read_rpmi_attrs(mchan); + if (rc) { + return dev_err_probe(dev, rc, + "MPXY channel 0x%x read RPMI attrs failed\n", + mchan->channel_id); + } + } + + mchan->notif = devm_kzalloc(dev, mpxy_shmem_size, GFP_KERNEL); + if (!mchan->notif) + return -ENOMEM; + + mchan->max_xfer_len = min(mpxy_shmem_size, mchan->attrs.msg_max_len); + + if ((mchan->attrs.capability & SBI_MPXY_CHAN_CAP_GET_NOTIFICATIONS) && + (mchan->attrs.capability & SBI_MPXY_CHAN_CAP_EVENTS_STATE)) + mchan->have_events_state = true; + + if ((mchan->attrs.capability & SBI_MPXY_CHAN_CAP_GET_NOTIFICATIONS) && + (mchan->attrs.capability & SBI_MPXY_CHAN_CAP_MSI)) + mchan->msi_index = mbox->msi_count++; + else + mchan->msi_index = U32_MAX; + mchan->msi_irq = U32_MAX; + } + + /* Free-up channel IDs */ + devm_kfree(dev, channel_ids); + + /* Initialize mailbox controller */ + mbox->controller.txdone_irq = false; + mbox->controller.txdone_poll = false; + mbox->controller.ops = &mpxy_mbox_ops; + mbox->controller.dev = dev; + mbox->controller.num_chans = mbox->channel_count; + mbox->controller.fw_xlate = mpxy_mbox_fw_xlate; + mbox->controller.chans = devm_kcalloc(dev, mbox->channel_count, + sizeof(*mbox->controller.chans), + GFP_KERNEL); + if (!mbox->controller.chans) + return -ENOMEM; + for (i = 0; i < mbox->channel_count; i++) + mbox->controller.chans[i].con_priv = &mbox->channels[i]; + + /* Set the MSI domain if not available */ + if (!dev_get_msi_domain(dev)) { + /* + * The device MSI domain for OF devices is only set at the + * time of populating/creating OF device. If the device MSI + * domain is discovered later after the OF device is created + * then we need to set it explicitly before using any platform + * MSI functions. + */ + if (is_of_node(dev->fwnode)) + of_msi_configure(dev, to_of_node(dev->fwnode)); + } + + /* Setup MSIs for mailbox (if required) */ + if (mbox->msi_count) { + mbox->msi_index_to_channel = devm_kcalloc(dev, mbox->msi_count, + sizeof(*mbox->msi_index_to_channel), + GFP_KERNEL); + if (!mbox->msi_index_to_channel) + return -ENOMEM; + + for (msi_idx = 0; msi_idx < mbox->msi_count; msi_idx++) { + for (i = 0; i < mbox->channel_count; i++) { + mchan = &mbox->channels[i]; + if (mchan->msi_index == msi_idx) { + mbox->msi_index_to_channel[msi_idx] = mchan; + break; + } + } + } + + rc = platform_device_msi_init_and_alloc_irqs(dev, mbox->msi_count, + mpxy_mbox_msi_write); + if (rc) { + return dev_err_probe(dev, rc, "Failed to allocate %d MSIs\n", + mbox->msi_count); + } + + for (i = 0; i < mbox->channel_count; i++) { + mchan = &mbox->channels[i]; + if (mchan->msi_index == U32_MAX) + continue; + mchan->msi_irq = msi_get_virq(dev, mchan->msi_index); + } + } + + /* Register mailbox controller */ + rc = devm_mbox_controller_register(dev, &mbox->controller); + if (rc) { + dev_err_probe(dev, rc, "Registering SBI MPXY mailbox failed\n"); + if (mbox->msi_count) + platform_device_msi_free_irqs_all(dev); + return rc; + } + + dev_info(dev, "mailbox registered with %d channels\n", + mbox->channel_count); + return 0; +} + +static void mpxy_mbox_remove(struct platform_device *pdev) +{ + struct mpxy_mbox *mbox = platform_get_drvdata(pdev); + + if (mbox->msi_count) + platform_device_msi_free_irqs_all(mbox->dev); +} + +static const struct of_device_id mpxy_mbox_of_match[] = { + {.compatible = "riscv,sbi-mpxy-mbox", }, + {}, +}; +MODULE_DEVICE_TABLE(of, mpxy_mbox_of_match); + +static struct platform_driver mpxy_mbox_driver = { + .driver = { + .name = "riscv-sbi-mpxy-mbox", + .of_match_table = mpxy_mbox_of_match, + }, + .probe = mpxy_mbox_probe, + .remove = mpxy_mbox_remove, +}; +module_platform_driver(mpxy_mbox_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Anup Patel "); +MODULE_DESCRIPTION("RISC-V SBI MPXY mailbox controller driver"); From patchwork Mon Feb 3 08:48:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957171 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 06626C02197 for ; Mon, 3 Feb 2025 10:00:55 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3G/bTZaDkYuRINbOOz1wUnrAzY8Uz3qAIJ47af3xA9I=; b=B3Llib7GgDGbdH odLrBomR6rVbkfOGqbD015u6SdJnsmzZVaPJecAD1S4BNQcOsNiB9kytdPLzgoEJeoeZxFrsfkrqI qLu0Wro6sbmXHgkanoFQx3k1MN47PZ37LIRTusNC+6HDkhrfIVckJDSbJ76/jehSqp5zZpC3LS6WL BsBpzzqBVUZwYW4vNWwGYFlu7XY3TiLnMzoaj2LL0CRqpH/A7zjbCBCjo99tTnwf95LOVvGqRLtFj mSAG52pQR8PQ4iH6PsRIgRLtZw5PQ51CPy4Ibn+/zrPFcZ421WeiyeYyRJHCj2quHInWLgmfLAB+B QRkQwcsT+gBXWU9uuptA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tetG4-0000000F3uv-1nvH; Mon, 03 Feb 2025 10:00:48 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesAX-0000000EuKp-38KZ for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:51:02 +0000 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-467725245a2so38296731cf.3 for ; Mon, 03 Feb 2025 00:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572661; x=1739177461; 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=Uq5bgx7F73e7S2pMGqlkagc7SWpAwEk+Db7gTuqwgBU=; b=lpcD2Yqt0xkY1DRoIHlsUkxVk1btKzBWs8amxu5BuGCCbl5zBfNs/OOVfLm8fUYYNi 55S+Wj4JKjn9RjJxBfnm1ooo51MV8gH3OnaNmew4Rf3LU/j/W96iuN4UBJ4XhUml5oLY 0QI2PIyU9JrPRV4o+vGeXvArfQgm9EZZHvBgQb4E6c2V+n0iqDNKk5h7mO2LOZAUkDeZ ifB13N4nFW2pURIL7pfHJGya+nQJmJxR7fb4Z4aikiwQBbOhebLwrKsowqapzZeIVrsP WtGrcwiA61xkl2kirk5V5DM/Kx1zauMSAbWVHPvKui4F6eh5qKdw6tPZTkyrBRZOd9/z cd8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572661; x=1739177461; 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=Uq5bgx7F73e7S2pMGqlkagc7SWpAwEk+Db7gTuqwgBU=; b=r3TlVcUre42qn2YwYESn1u6VprMRCvuuI/8EWDX9r1OFShBkYv15+xRwLWcuZpIPMR 6uS1fQ+xaTwO/auu8HkwO3e2Q5SkCRgtj9r8d8FvaZJE2vTKb/dYzy5GyJXOkJSBj5zP PYIVapQ+vLW5F3un5aCfi9spxFZc3etvaRKkrABgJ3Y3Jg0ZN4rKng9bUQ8SUMWucRrb y3zAcKhGXBeJ5fX7R1kBdsn4xy2k5wjrlGx24kR/aBq97UOTgt40rzvyE0PdKqakfdkK ZJyEQ2WUU62L7n8k1K6r6Z2Qqpx4eAzdFaIt9o43uTaDfxs2tbIWKVbqhmxBPdk9kWGK ae4g== X-Forwarded-Encrypted: i=1; AJvYcCVeSvycUsbfBUM4Ooma4irrovz14Bau7LjmBYezj79LqpjOTqxrscMPz0YIlHwXH65WOyglkkUsJxICsw==@lists.infradead.org X-Gm-Message-State: AOJu0YyiNLI9Dk2Jy33jfY10KFGmzPT07DgJu5mQUwZWb2hwDboXCrjr TAxJAJMo5JgTW1ZWQ7uVI0QXqSbtuEMotMJHBoA2efYXEbreTkG6ZruDb1362oo= X-Gm-Gg: ASbGncvQtjTaO8N6loZOaPFrkGY/V8MR7ZrV/z6tzVHm6tm8vHO31pZRkROCqO2TYP0 2PxHon+B4DzHZUDKllQZVLOSHrTaHafLhMjoNhjy5MNjlHuBeZjmQrB8lhjsOWF8ifpnNKAKUSc ofoXV7kEl+d+V2JfLEFPxncK3Y7D2BcEjJlSawZfroxgJDgBvus4ZfM/cfzmp9jxQ/Fp0vaBV5L 1IV9L7UoljUV2kqrQqT7LnzDcHuEax/KusIw+VLSGF5SkeN1CBGxix0NXtH29+IcOBnSdUBE4xY t5wFbMgmRzBk011w3moTCgnAjEvayzKtWdwGL6SO4hplRqmajFhfMnw= X-Google-Smtp-Source: AGHT+IHKSWjJnml9P2k8xe3WTZy7gZVOr3y2y3l5W1mAhUBR6IAIbnAkFVzcudNqB834buJx1oU/1w== X-Received: by 2002:ac8:7d92:0:b0:45d:8513:f29a with SMTP id d75a77b69052e-46fd09e25c1mr202526631cf.9.1738572660838; Mon, 03 Feb 2025 00:51:00 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:51:00 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 08/17] dt-bindings: clock: Add bindings for RISC-V RPMI clock service group Date: Mon, 3 Feb 2025 14:18:57 +0530 Message-ID: <20250203084906.681418-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005101_786620_9735B5E5 X-CRM114-Status: GOOD ( 14.14 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add device tree bindings for the clock service group defined by the RISC-V platform management interface (RPMI) specification. Signed-off-by: Anup Patel --- .../bindings/clock/riscv,rpmi-clock.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/riscv,rpmi-clock.yaml diff --git a/Documentation/devicetree/bindings/clock/riscv,rpmi-clock.yaml b/Documentation/devicetree/bindings/clock/riscv,rpmi-clock.yaml new file mode 100644 index 000000000000..c08491c04926 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/riscv,rpmi-clock.yaml @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/riscv,rpmi-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V RPMI clock service group based clock controller + +maintainers: + - Anup Patel + +description: | + The RISC-V Platform Management Interface (RPMI) [1] defines a + messaging protocol which is modular and extensible. The supervisor + software can send/receive RPMI messages via SBI MPXY extension [2] + or some dedicated supervisor-mode RPMI transport. + + The RPMI specification [1] defines clock service group for accessing + system clocks managed by a platform microcontroller. + + =========================================== + References + =========================================== + + [1] RISC-V Platform Management Interface (RPMI) + https://github.com/riscv-non-isa/riscv-rpmi/releases + + [2] RISC-V Supervisor Binary Interface (SBI) + https://github.com/riscv-non-isa/riscv-sbi-doc/releases + +properties: + compatible: + oneOf: + - description: + Intended for use by the SBI implementation in machine mode or + software in supervisor mode. + const: riscv,rpmi-clock + + - description: + Intended for use by the SBI implementation in machine mode. + const: riscv,rpmi-mpxy-clock + + mboxes: + maxItems: 1 + description: + Mailbox channel of the underlying RPMI transport or SBI message proxy. + + riscv,sbi-mpxy-channel-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The SBI MPXY channel id to be used for providing RPMI access to + the supervisor software. This property is mandatory when using + riscv,rpmi-mpxy-clock compatible string. + + "#clock-cells": + const: 1 + description: + This property is mandatory when using riscv,rpmi-clock compatible string. + +required: + - compatible + - mboxes + +additionalProperties: false + +examples: + - | + mpxy_mbox: sbi-mpxy-mbox { + compatible = "riscv,sbi-mpxy-mbox"; + #mbox-cells = <2>; + }; + rpmi-clk { + compatible = "riscv,rpmi-clock"; + mboxes = <&mpxy_mbox 0x1000 0x0>; + #clock-cells = <1>; + }; +... From patchwork Mon Feb 3 08:48:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957173 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 8CC9FC02196 for ; Mon, 3 Feb 2025 10:00: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HCyDXLF/5ZMHGXzXi1Q9kZywrq2D5WjrQkWt6wE+xB4=; b=BbJ3VLfWoEVthC KkHkx+f7U0JHeTVKFULPJsGT30B90ljD4pfXcRuoK06KE6riPOEc9+HC3N32Fn2LsB0uPVezcKiSG igdETqoJWCYodEQbDmwfcqQSFlkGSqWBKImp9iYNxJPxpkvCScahqLCOLUU/LKbVikwaaCGhBe6Z7 gak6bE6IeNJMl9otdxwl4B+3K/RPxKAjzc/UuvHWHoe2qNCEX3lqMwa2MH/3zQ4jNZ68+tClqnB45 ccWytZgaTGO95P8GqX7zck7ZW3796sC2tlByrqnVTHatTNObXLkhuNKWRVdUr0flAWCkFJ2AFAXBg L9AOanl6a4ZxLHJep+xw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tetG4-0000000F3vE-49ph; Mon, 03 Feb 2025 10:00:49 +0000 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesAk-0000000EuPL-3m0L for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:51:16 +0000 Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-46788c32a69so54865671cf.2 for ; Mon, 03 Feb 2025 00:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572674; x=1739177474; 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=mNMswL89rPnF+U4OZQa/pIwmxpLPHsuGFLy4htGB7c0=; b=SUaRt5NVx7/EH9XEDLK5yzTXLHa9lHRiGbBauKKBElT78KzaXepFjZzbsUTBu+yWoG 7Yv29/di5b3Uqofp8A31eTBriwUPt8/h5wqP6cEmRePYDYAUc/k0efkSN+8Cyhhxwexs 6xSK0qCf35IU+teOYewY99veAWedKx5f/2AiJ8swopGrWhVnuz3c54U0p39Ho+JzCP3Y mBMssECpOrWC9bbUBwZ5mYNAnPDYmmc8yrn/L8diCkw8c3Y5WqmZco33g3pKoD+CF99Y He+fKooAfo2Rd2ESu0wPKUPWevW5FbFcyeoY4m2M/tjN2OnpSUj91zhIoU/pBhdwikDY AqGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572674; x=1739177474; 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=mNMswL89rPnF+U4OZQa/pIwmxpLPHsuGFLy4htGB7c0=; b=FrgwyWLvXNunBokNAJWnHCJAvKirJeYyUslsElWvo+dm6RWrigBi2qUwtdtAF7VfRR Y1iSD4/zQwI9oRH2pd/v0HwtFPVK2jJcOSxDh2YAgXC40yTf7xGWphnZ55UNJsmXL4gu Q/mKkus3/R85E4AoQllFPc93mWk1TKAuwRmnIMOF4RTN6S62eIvHbFGgyDtUqPJ10TH0 el5eBcQkncRA14X3ISFDqNg1NxUFNZs4do25PC9oxQRkjDgVr1W+EVLXnYoOJhdnR87d kbau9SDXyP6705VsCHxcxow954LZ3nqsLjFs6d8XMQ/F6299i5VWpnMmtgC6vH1hb2Dp ruvA== X-Forwarded-Encrypted: i=1; AJvYcCWHwRGCP8oEvs6bbLuKaRReUQ/Q40/ALUFZ6Et55mRoWkco2jt1Haz58zAqc9+yAAgM6ljA/2o7d4T2iA==@lists.infradead.org X-Gm-Message-State: AOJu0YwYCb5ryHXNQsz1mMUHhvjwpFqBsZv0N/mOqarDrIKCyVr3pcvn DX61GHBHaLrrx8lnRMAl8iW7BRgtdPSFd0NGswPhtUeEivtzo2HDEmb5cIZ8IDw= X-Gm-Gg: ASbGncunLcyzK+lzF2S8zYfeSK5t4qPR1V/e5e9CtNv/Qnsb9fr5tVX0fkyJJdZpaUV WPFtQ2F6guebQMbb/vSJttm2HwrkEimuRglFcz4MSCm1uew6pMbA5czs+LptDC/hIk1xaTbjFEN zfjEx5KtfcWCTpQTMy0BoicZQXGNLe7+XVdjsgk8BNkqLTv23PdF6Af5jj96VSAhqU9HfWRb8B+ uO2zlxmW7OG1DSmfeh3WD5jpe7xyQzcFCGhpuw5cc8hdN/nEG72JbbGll0/PfLOY/5nL9Z9WHBD VXgI8feaqaQ05GOt+6pb32WwqMz5fd+RfNCdpIQjYrtwfVBOPypC29Y= X-Google-Smtp-Source: AGHT+IH1kXWH/83kat5jYFyTGDIX1wmSy54yG8iehUZRbgobiZDmLjsQ5r1/uyiJd9l4c4LLIWggzQ== X-Received: by 2002:a05:622a:1c16:b0:45f:788:b1ad with SMTP id d75a77b69052e-46fd0ace3f5mr351238861cf.27.1738572673453; Mon, 03 Feb 2025 00:51:13 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:51:12 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 09/17] clk: Add clock driver for the RISC-V RPMI clock service group Date: Mon, 3 Feb 2025 14:18:58 +0530 Message-ID: <20250203084906.681418-10-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005114_950286_D4CD8DF0 X-CRM114-Status: GOOD ( 23.43 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Rahul Pathak The RPMI specification defines a clock service group which can be accessed via SBI MPXY extension or dedicated S-mode RPMI transport. Add mailbox client based clock driver for the RISC-V RPMI clock service group. Co-developed-by: Anup Patel Signed-off-by: Anup Patel Signed-off-by: Rahul Pathak --- drivers/clk/Kconfig | 8 + drivers/clk/Makefile | 1 + drivers/clk/clk-rpmi.c | 601 +++++++++++++++++++++ include/linux/mailbox/riscv-rpmi-message.h | 16 + 4 files changed, 626 insertions(+) create mode 100644 drivers/clk/clk-rpmi.c diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 713573b6c86c..d89308c7f75c 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -493,6 +493,14 @@ config COMMON_CLK_SP7021 Not all features of the PLL are currently supported by the driver. +config COMMON_CLK_RPMI + tristate "Clock driver based on RISC-V RPMI" + depends on MAILBOX + default RISCV + help + Support for clocks based on the clock service group defined by + the RISC-V platform management interface (RPMI) specification. + source "drivers/clk/actions/Kconfig" source "drivers/clk/analogbits/Kconfig" source "drivers/clk/baikal-t1/Kconfig" diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index bf4bd45adc3a..b8588ab789c3 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -84,6 +84,7 @@ obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o +obj-$(CONFIG_COMMON_CLK_RPMI) += clk-rpmi.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCMI) += clk-scmi.o diff --git a/drivers/clk/clk-rpmi.c b/drivers/clk/clk-rpmi.c new file mode 100644 index 000000000000..dcd6da00603b --- /dev/null +++ b/drivers/clk/clk-rpmi.c @@ -0,0 +1,601 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * RISC-V MPXY Based Clock Driver + * + * Copyright (C) 2024 Ventana Micro Systems Ltd. + */ + +#include +#include +#include +#include +#include +#include + +#define RPMI_CLK_DISCRETE_MAX_NUM_RATES 16 +#define RPMI_CLK_NAME_LEN 16 + +#define GET_RATE_U64(hi_u32, lo_u32) ((u64)(hi_u32) << 32 | (lo_u32)) + +enum rpmi_clk_config { + RPMI_CLK_DISABLE = 0, + RPMI_CLK_ENABLE = 1, +}; + +enum rpmi_clk_type { + RPMI_CLK_DISCRETE = 0, + RPMI_CLK_LINEAR = 1, + RPMI_CLK_TYPE_MAX_IDX, +}; + +struct rpmi_clk_context { + struct device *dev; + struct mbox_chan *chan; + struct mbox_client client; + u32 max_msg_data_size; +}; + +union rpmi_clk_rates { + u64 discrete[RPMI_CLK_DISCRETE_MAX_NUM_RATES]; + struct { + u64 min; + u64 max; + u64 step; + } linear; +}; + +struct rpmi_clk { + struct rpmi_clk_context *context; + u32 id; + u32 num_rates; + u32 transition_latency; + enum rpmi_clk_type type; + union rpmi_clk_rates *rates; + char name[RPMI_CLK_NAME_LEN]; + struct clk_hw hw; +}; + +#define to_rpmi_clk(clk) container_of(clk, struct rpmi_clk, hw) + +struct rpmi_get_num_clocks_rx { + s32 status; + u32 num_clocks; +}; + +struct rpmi_get_attrs_tx { + __le32 clkid; +}; + +struct rpmi_get_attrs_rx { + s32 status; + u32 flags; + u32 num_rates; + u32 transition_latency; + char name[RPMI_CLK_NAME_LEN]; +}; + +struct rpmi_get_supp_rates_tx { + __le32 clkid; + __le32 clk_rate_idx; +}; + +struct rpmi_clk_rate_discrete { + u32 lo; + u32 hi; +}; + +struct rpmi_clk_rate_linear { + u32 min_lo; + u32 min_hi; + u32 max_lo; + u32 max_hi; + u32 step_lo; + u32 step_hi; +}; + +struct rpmi_get_supp_rates_rx { + u32 status; + u32 flags; + u32 remaining; + u32 returned; + u32 rates[]; +}; + +struct rpmi_get_rate_tx { + __le32 clkid; +}; + +struct rpmi_get_rate_rx { + u32 status; + u32 lo; + u32 hi; +}; + +struct rpmi_set_rate_tx { + __le32 clkid; + __le32 flags; + __le32 lo; + __le32 hi; +}; + +struct rpmi_set_rate_rx { + u32 status; +}; + +struct rpmi_set_config_tx { + __le32 clkid; + __le32 config; +}; + +struct rpmi_set_config_rx { + u32 status; +}; + +static int rpmi_clk_get_num_clocks(struct rpmi_clk_context *context) +{ + struct rpmi_get_num_clocks_rx rx; + struct rpmi_mbox_message msg; + int ret; + + rpmi_mbox_init_send_with_response(&msg, RPMI_CLK_SRV_GET_NUM_CLOCKS, + NULL, 0, &rx, sizeof(rx)); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) + return ret; + if (rx.status) + return rpmi_to_linux_error(rx.status); + + return rx.num_clocks; +} + +static int rpmi_clk_get_attrs(u32 clkid, struct rpmi_clk *rpmi_clk) +{ + struct rpmi_clk_context *context = rpmi_clk->context; + struct rpmi_mbox_message msg; + struct rpmi_get_attrs_tx tx; + struct rpmi_get_attrs_rx rx; + u8 format; + int ret; + + tx.clkid = cpu_to_le32(clkid); + rpmi_mbox_init_send_with_response(&msg, RPMI_CLK_SRV_GET_ATTRIBUTES, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) + return ret; + if (rx.status) + return rpmi_to_linux_error(rx.status); + + rpmi_clk->id = clkid; + rpmi_clk->num_rates = rx.num_rates; + rpmi_clk->transition_latency = rx.transition_latency; + strscpy(rpmi_clk->name, rx.name, RPMI_CLK_NAME_LEN); + + format = rx.flags & 3U; + if (format >= RPMI_CLK_TYPE_MAX_IDX) + return -EINVAL; + + rpmi_clk->type = format; + + return 0; +} + +static int rpmi_clk_get_supported_rates(u32 clkid, struct rpmi_clk *rpmi_clk) +{ + struct rpmi_clk_context *context = rpmi_clk->context; + struct rpmi_clk_rate_discrete *rate_discrete; + struct rpmi_clk_rate_linear *rate_linear; + struct rpmi_get_supp_rates_rx *rx; + struct rpmi_get_supp_rates_tx tx; + struct rpmi_mbox_message msg; + size_t clk_rate_idx = 0; + int ret, rateidx, j; + + tx.clkid = cpu_to_le32(clkid); + tx.clk_rate_idx = 0; + + /* + * Make sure we allocate rx buffer sufficient to be accommodate all + * the rates sent in one RPMI message. + */ + rx = devm_kzalloc(context->dev, context->max_msg_data_size, GFP_KERNEL); + if (!rx) + return -ENOMEM; + + rpmi_mbox_init_send_with_response(&msg, RPMI_CLK_SRV_GET_SUPPORTED_RATES, + &tx, sizeof(tx), rx, context->max_msg_data_size); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) + return ret; + if (rx->status) + return rpmi_to_linux_error(rx->status); + if (!rx->returned) + return -EINVAL; + + if (rpmi_clk->type == RPMI_CLK_DISCRETE) { + rate_discrete = (struct rpmi_clk_rate_discrete *)rx->rates; + + for (rateidx = 0; rateidx < rx->returned; rateidx++) { + rpmi_clk->rates->discrete[rateidx] = + GET_RATE_U64(rate_discrete[rateidx].hi, + rate_discrete[rateidx].lo); + } + + /* + * Keep sending the request message until all + * the rates are received. + */ + while (rx->remaining) { + clk_rate_idx += rx->returned; + tx.clk_rate_idx = cpu_to_le32(clk_rate_idx); + + rpmi_mbox_init_send_with_response(&msg, + RPMI_CLK_SRV_GET_SUPPORTED_RATES, + &tx, sizeof(tx), + rx, context->max_msg_data_size); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) + return ret; + if (rx->status) + return rpmi_to_linux_error(rx->status); + if (!rx->returned) + return -EINVAL; + + for (j = 0; j < rx->returned; j++) { + if (rateidx >= (clk_rate_idx + rx->returned)) + break; + rpmi_clk->rates->discrete[rateidx++] = + GET_RATE_U64(rate_discrete[j].hi, + rate_discrete[j].lo); + } + } + } else if (rpmi_clk->type == RPMI_CLK_LINEAR) { + rate_linear = (struct rpmi_clk_rate_linear *)rx->rates; + + rpmi_clk->rates->linear.min = + GET_RATE_U64(rate_linear->min_hi, + rate_linear->min_lo); + rpmi_clk->rates->linear.max = + GET_RATE_U64(rate_linear->max_hi, + rate_linear->max_lo); + rpmi_clk->rates->linear.step = + GET_RATE_U64(rate_linear->step_hi, + rate_linear->step_lo); + } + + devm_kfree(context->dev, rx); + return 0; +} + +static unsigned long rpmi_clk_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct rpmi_clk *rpmi_clk = to_rpmi_clk(hw); + struct rpmi_clk_context *context = rpmi_clk->context; + struct rpmi_mbox_message msg; + struct rpmi_get_rate_tx tx; + struct rpmi_get_rate_rx rx; + int ret; + + tx.clkid = cpu_to_le32(rpmi_clk->id); + + rpmi_mbox_init_send_with_response(&msg, RPMI_CLK_SRV_GET_RATE, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) + return ret; + if (rx.status) + return rx.status; + + return GET_RATE_U64(rx.hi, rx.lo); +} + +static int rpmi_clk_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + struct rpmi_clk *rpmi_clk = to_rpmi_clk(hw); + u64 fmin, fmax, ftmp; + + /* Keep the requested rate if the clock format + * is of discrete type. Let the platform which + * is actually controlling the clock handle that. + */ + if (rpmi_clk->type == RPMI_CLK_DISCRETE) + goto out; + + fmin = rpmi_clk->rates->linear.min; + fmax = rpmi_clk->rates->linear.max; + + if (req->rate <= fmin) { + req->rate = fmin; + goto out; + } else if (req->rate >= fmax) { + req->rate = fmax; + goto out; + } + + ftmp = req->rate - fmin; + ftmp += rpmi_clk->rates->linear.step - 1; + do_div(ftmp, rpmi_clk->rates->linear.step); + + req->rate = ftmp * rpmi_clk->rates->linear.step + fmin; +out: + return 0; +} + +static int rpmi_clk_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + struct rpmi_clk *rpmi_clk = to_rpmi_clk(hw); + struct rpmi_clk_context *context = rpmi_clk->context; + struct rpmi_mbox_message msg; + struct rpmi_set_rate_tx tx; + struct rpmi_set_rate_rx rx; + int ret; + + tx.clkid = cpu_to_le32(rpmi_clk->id); + tx.lo = cpu_to_le32(lower_32_bits(rate)); + tx.hi = cpu_to_le32(upper_32_bits(rate)); + + rpmi_mbox_init_send_with_response(&msg, RPMI_CLK_SRV_SET_RATE, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) + return ret; + if (rx.status) + return rpmi_to_linux_error(rx.status); + + return 0; +} + +static int rpmi_clk_enable(struct clk_hw *hw) +{ + struct rpmi_clk *rpmi_clk = to_rpmi_clk(hw); + struct rpmi_clk_context *context = rpmi_clk->context; + struct rpmi_mbox_message msg; + struct rpmi_set_config_tx tx; + struct rpmi_set_config_rx rx; + int ret; + + tx.config = cpu_to_le32(RPMI_CLK_ENABLE); + tx.clkid = cpu_to_le32(rpmi_clk->id); + + rpmi_mbox_init_send_with_response(&msg, RPMI_CLK_SRV_SET_CONFIG, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) + return ret; + if (rx.status) + return rpmi_to_linux_error(rx.status); + + return 0; +} + +static void rpmi_clk_disable(struct clk_hw *hw) +{ + struct rpmi_clk *rpmi_clk = to_rpmi_clk(hw); + struct rpmi_clk_context *context = rpmi_clk->context; + struct rpmi_mbox_message msg; + struct rpmi_set_config_tx tx; + struct rpmi_set_config_rx rx; + int ret; + + tx.config = cpu_to_le32(RPMI_CLK_DISABLE); + tx.clkid = cpu_to_le32(rpmi_clk->id); + + rpmi_mbox_init_send_with_response(&msg, RPMI_CLK_SRV_SET_CONFIG, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret || rx.status) + pr_err("Failed to disable clk-%u\n", rpmi_clk->id); +} + +static const struct clk_ops rpmi_clk_ops = { + .recalc_rate = rpmi_clk_recalc_rate, + .determine_rate = rpmi_clk_determine_rate, + .set_rate = rpmi_clk_set_rate, + .prepare = rpmi_clk_enable, + .unprepare = rpmi_clk_disable, +}; + +static struct clk_hw *rpmi_clk_enumerate(struct rpmi_clk_context *context, u32 clkid) +{ + struct device *dev = context->dev; + unsigned long min_rate, max_rate; + union rpmi_clk_rates *rates; + struct rpmi_clk *rpmi_clk; + struct clk_init_data init = {}; + struct clk_hw *clk_hw; + int ret; + + rates = devm_kzalloc(dev, sizeof(union rpmi_clk_rates), GFP_KERNEL); + if (!rates) + return ERR_PTR(-ENOMEM); + + rpmi_clk = devm_kzalloc(dev, sizeof(struct rpmi_clk), GFP_KERNEL); + if (!rpmi_clk) + return ERR_PTR(-ENOMEM); + + rpmi_clk->context = context; + rpmi_clk->rates = rates; + + ret = rpmi_clk_get_attrs(clkid, rpmi_clk); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Failed to get clk-%u attributes, %d\n", clkid, ret); + + ret = rpmi_clk_get_supported_rates(clkid, rpmi_clk); + if (ret) + return dev_err_ptr_probe(dev, ret, + "Get supported rates failed for clk-%u, %d\n", clkid, ret); + + init.flags = CLK_GET_RATE_NOCACHE; + init.num_parents = 0; + init.ops = &rpmi_clk_ops; + init.name = rpmi_clk->name; + clk_hw = &rpmi_clk->hw; + clk_hw->init = &init; + + ret = devm_clk_hw_register(dev, clk_hw); + if (ret) + return dev_err_ptr_probe(dev, ret, "Unable to register clk-%u\n", clkid); + + if (rpmi_clk->type == RPMI_CLK_DISCRETE) { + min_rate = rpmi_clk->rates->discrete[0]; + max_rate = rpmi_clk->rates->discrete[rpmi_clk->num_rates - 1]; + } else { + min_rate = rpmi_clk->rates->linear.min; + max_rate = rpmi_clk->rates->linear.max; + } + + clk_hw_set_rate_range(clk_hw, min_rate, max_rate); + + return clk_hw; +} + +static int rpmi_clk_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct clk_hw_onecell_data *clk_data; + struct rpmi_clk_context *context; + struct rpmi_mbox_message msg; + int ret, num_clocks, i; + struct clk_hw *hw_ptr; + + /* Allocate RPMI clock context */ + context = devm_kzalloc(dev, sizeof(*context), GFP_KERNEL); + if (!context) + return -ENOMEM; + context->dev = dev; + platform_set_drvdata(pdev, context); + + /* Setup mailbox client */ + context->client.dev = context->dev; + context->client.rx_callback = NULL; + context->client.tx_block = false; + context->client.knows_txdone = true; + context->client.tx_tout = 0; + + /* Request mailbox channel */ + context->chan = mbox_request_channel(&context->client, 0); + if (IS_ERR(context->chan)) + return PTR_ERR(context->chan); + + /* Validate RPMI specification version */ + rpmi_mbox_init_get_attribute(&msg, RPMI_MBOX_ATTR_SPEC_VERSION); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) { + dev_err_probe(dev, ret, "Failed to get spec version\n"); + goto fail_free_channel; + } + if (msg.attr.value < RPMI_MKVER(1, 0)) { + ret = dev_err_probe(dev, -EINVAL, + "msg protocol version mismatch, expected 0x%x, found 0x%x\n", + RPMI_MKVER(1, 0), msg.attr.value); + goto fail_free_channel; + } + + /* Validate clock service group ID */ + rpmi_mbox_init_get_attribute(&msg, RPMI_MBOX_ATTR_SERVICEGROUP_ID); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) { + dev_err_probe(dev, ret, "Failed to get service group ID\n"); + goto fail_free_channel; + } + if (msg.attr.value != RPMI_SRVGRP_CLOCK) { + ret = dev_err_probe(dev, -EINVAL, + "service group match failed, expected 0x%x, found 0x%x\n", + RPMI_SRVGRP_CLOCK, msg.attr.value); + goto fail_free_channel; + } + + /* Validate clock service group version */ + rpmi_mbox_init_get_attribute(&msg, RPMI_MBOX_ATTR_SERVICEGROUP_VERSION); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) { + dev_err_probe(dev, ret, "Failed to get service group version\n"); + goto fail_free_channel; + } + if (msg.attr.value < RPMI_MKVER(1, 0)) { + ret = dev_err_probe(dev, -EINVAL, + "service group version failed, expected 0x%x, found 0x%x\n", + RPMI_MKVER(1, 0), msg.attr.value); + goto fail_free_channel; + } + + /* Save the maximum message data size of mailbox channel */ + rpmi_mbox_init_get_attribute(&msg, RPMI_MBOX_ATTR_MAX_MSG_DATA_SIZE); + ret = rpmi_mbox_send_message(context->chan, &msg); + if (ret) { + dev_err_probe(dev, ret, "Failed to get max message data size\n"); + goto fail_free_channel; + } + context->max_msg_data_size = msg.attr.value; + + /* Find-out number of clocks */ + num_clocks = rpmi_clk_get_num_clocks(context); + if (num_clocks < 1) { + ret = dev_err_probe(dev, -ENODEV, "No clocks found\n"); + goto fail_free_channel; + } + + /* Allocate clock data */ + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, num_clocks), + GFP_KERNEL); + if (!clk_data) { + ret = -ENOMEM; + goto fail_free_channel; + } + clk_data->num = num_clocks; + + /* Setup clock data */ + for (i = 0; i < clk_data->num; i++) { + hw_ptr = rpmi_clk_enumerate(context, i); + if (IS_ERR(hw_ptr)) { + ret = dev_err_probe(dev, PTR_ERR(hw_ptr), + "failed to register clk-%d\n", i); + goto fail_free_channel; + } + clk_data->hws[i] = hw_ptr; + } + + /* Register clock HW provider */ + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); + if (ret) { + dev_err_probe(dev, ret, "failed to register clock HW provider\n"); + goto fail_free_channel; + } + + return 0; + +fail_free_channel: + mbox_free_channel(context->chan); + return ret; +} + +static void rpmi_clk_remove(struct platform_device *pdev) +{ + struct rpmi_clk_context *context = platform_get_drvdata(pdev); + + mbox_free_channel(context->chan); +} + +static const struct of_device_id rpmi_clk_of_match[] = { + { .compatible = "riscv,rpmi-clock" }, + { } +}; +MODULE_DEVICE_TABLE(of, rpmi_clk_of_match); + +static struct platform_driver rpmi_clk_driver = { + .driver = { + .name = "riscv-rpmi-clock", + .of_match_table = rpmi_clk_of_match, + }, + .probe = rpmi_clk_probe, + .remove = rpmi_clk_remove, +}; +module_platform_driver(rpmi_clk_driver); + +MODULE_AUTHOR("Rahul Pathak "); +MODULE_DESCRIPTION("Clock Driver based on RPMI message protocol"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mailbox/riscv-rpmi-message.h b/include/linux/mailbox/riscv-rpmi-message.h index 2747a1840937..f43d0874ad68 100644 --- a/include/linux/mailbox/riscv-rpmi-message.h +++ b/include/linux/mailbox/riscv-rpmi-message.h @@ -89,6 +89,22 @@ static inline int rpmi_to_linux_error(int rpmi_error) } } +/** RPMI service group IDs */ +#define RPMI_SRVGRP_CLOCK 0x00008 + +/** RPMI clock service IDs */ +enum rpmi_clock_service_id { + RPMI_CLK_SRV_ENABLE_NOTIFICATION = 0x01, + RPMI_CLK_SRV_GET_NUM_CLOCKS = 0x02, + RPMI_CLK_SRV_GET_ATTRIBUTES = 0x03, + RPMI_CLK_SRV_GET_SUPPORTED_RATES = 0x04, + RPMI_CLK_SRV_SET_CONFIG = 0x05, + RPMI_CLK_SRV_GET_CONFIG = 0x06, + RPMI_CLK_SRV_SET_RATE = 0x07, + RPMI_CLK_SRV_GET_RATE = 0x08, + RPMI_CLK_SRV_ID_MAX_COUNT, +}; + /** RPMI linux mailbox attribute IDs */ enum rpmi_mbox_attribute_id { RPMI_MBOX_ATTR_SPEC_VERSION = 0, From patchwork Mon Feb 3 08:48:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957174 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 CAE06C02192 for ; Mon, 3 Feb 2025 10:00: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GMYHaXjhzrGJKYb1NmhwfbCYsj3esRQv3P3hbInzoKw=; b=qFDElwmTTNQbXq 94s/nFSOlYQN8Dm9zfIGm25bjHzZIJ23fhRbwNEhjWd7b6greN8GT68OYk7cbJ25rNXF/05FQR8ht abKQFpW5cO/7+84cA99h4QEKOhMyBt2z29zEAE8qeHXAE5ZZ8GqCR9u/2CDSCu8ELnxE7RQIKgAl0 Cz+weAsefDJX7Begvmjw0WfyNktm0hpL/eSEd5Y8jxgFeUqz7zE8VR3/7ENZXEvuASB1pDCa4XE66 kBXD27LD/zXZ0/yMww4lg2yHGuVEZZJAWYzcjll0jFI0loXDA61r7Qdp7Oe8m9XpXIx0zajGewlAy Z0GuWxH2WhdHVWGStyBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tetG6-0000000F3wm-3258; Mon, 03 Feb 2025 10:00:50 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesB2-0000000EuVM-2C4N for linux-riscv@bombadil.infradead.org; Mon, 03 Feb 2025 08:51:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=xvjolPh9gzwNtAL7PAOP6t0zOgR6ztGKXQcTpBeekWw=; b=OzBIqei0W1zKZz6bnaTuB3fzz2 6TyF6+AVWzMZF6T/1sXAFtaBPCVbHdKUpY/15nyP6BpUYnGxJOBq7e4eD+UffQD5bGwlgYI7IcHW2 ce1C83UG1PbWh/0e/Mstkmfl7hSkafHsAEhQPQeloDevamyOjhxv8tKHTcqUxq5IGK+oI09EXTR6e lyCkTQtA1bAAYJ5hnCqNlJbb23+WgZ/2JMElnVsJ2wbyzkEC8MkKtZ7AkkMicCj57cWoMWdJ/XwC9 0BpPIKsRv2P2TXOtiyjsJP+Pd3sBU8plZM3fTLJOkjv4MecOZ/ktzkBvr+0dAElBAyLt/yHFtmhaZ TxDKffEw==; Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesAy-0000000G0wy-3gMn for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:51:31 +0000 Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-4679eacf25cso26960811cf.3 for ; Mon, 03 Feb 2025 00:51:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572685; x=1739177485; 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=xvjolPh9gzwNtAL7PAOP6t0zOgR6ztGKXQcTpBeekWw=; b=cJjkD0evz2yEuf90xPl7WjYKgeRvo8wBaxOgfZ0IUOvV3EIY0OYHuHq9c0UFQvDzFc AJ/CHKgYlrdv4ZG9vNlyS+uNB2xkLV5tHwWvZUraZgTpmF3GI2Gu86eLlqWiT3CtJMQ4 k86dI8ygVwxxgkfEozRBlGRjBCcz/mufrwrl7M976Vv81SX7r9VtFHzyJcDW+4mHsXCI A0YzfKKNjiEGxhZuycvAsz0BDwzw3P5dHuELyhfzIP+mLYfccgK23djL67kGlGBkHrWg uwUYJBQJX8gW7vwSFz7JyMAcHM9IcCtK+nDAQYqkvw2MXey+E8WM6QOjmeUKwoSEfMev e7dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572685; x=1739177485; 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=xvjolPh9gzwNtAL7PAOP6t0zOgR6ztGKXQcTpBeekWw=; b=jKK6o19WkiHxLV2TrRJ8tewLEUVhTekz39hFkXOgJI2KCNJqIsQ2dfcl2EYpaxNpj6 NT0w3mdNHoY5cuhJRAW8D6dPqBf7m99HtliymswX3roUU9vdPvPfdT8cGzQ3otprNxYp aRy8LNIthtmB4ziMqV2ynNtEq2jJ/B0tsJpHSl4efWUQfh83U/NIitu5QIqw0eqHZxkJ XVaby5yyLIhn2qvYfuaf09+5+fBTp04RcVocTJiEsP56NhTp6pjT6N+Z1z3xjjcD/BL7 c7Pzm0s3IrB//25LO8S43SaiAIDK6i6atPnJEnWFQ4P8S36ov3VBKsVp5OA2FsvQiCAh kDrg== X-Forwarded-Encrypted: i=1; AJvYcCVTNZA+rTomYrhro4Vht2xK799kU7kS8WlBPTT4o6VS7PoVEjPCCUjmXJKiXU4GihZf1Y3Trg+iEkB4XA==@lists.infradead.org X-Gm-Message-State: AOJu0Yxs7Gu/7lOVTxsjKADp2MAgYheANjA4FZ396FJyqd9YfNWr5XIY IPMqsO/gq/GXkL0yPjz3Ip9+52LNEhTLB8N1oqrC2FgQI6TbFLdjhWX92g7wfhY= X-Gm-Gg: ASbGncuNB50xbKjscwKl2/2YY2lIpa03yfmINL0tjMkX2w+tqh+5w5BxpP0lZ5SgXON JYhC1xp020lm/ebYlU2NPF9XWdiGq1FzgSbKg3VScXnzC8/gZS18PV/AEsO+4ImBtm7AEEyIKho kuuXn/ezu2jcKK4KlV/0gUoGOQ5WQuXE6Aif9JrPlOp12XMepkJSkfdXhrzeEytIw/o+HAuwn97 h7OYpemzc9ftaRIFbjf65T4YMVyY/vZn2wlljb42b+XECW8rZ47fRt91DUQywUhI1VCNuaTDxHq HMIio/TY4/cvs6CJO2EACd3XeXWdOa3WlNeSctX2VFC8THhoyza4lK0= X-Google-Smtp-Source: AGHT+IFPm/vGjoafGFVBb0pWO9IDvnrcujPXX6jDysAgsWknrhSPZ6VlgmiZ8V/8drmHUDea6Xx6YA== X-Received: by 2002:ac8:59d0:0:b0:467:76cc:622d with SMTP id d75a77b69052e-46fd0a13014mr330274181cf.11.1738572685403; Mon, 03 Feb 2025 00:51:25 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:51:24 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 10/17] dt-bindings: interrupt-controller: Add bindings for RISC-V RPMI system MSI Date: Mon, 3 Feb 2025 14:18:59 +0530 Message-ID: <20250203084906.681418-11-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_085129_133189_0AA244AC X-CRM114-Status: GOOD ( 14.76 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add device tree bindings for the system MSI service group based interrupt controller defined by the RISC-V platform management interface (RPMI) specification. Signed-off-by: Anup Patel --- .../riscv,rpmi-system-msi.yaml | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/riscv,rpmi-system-msi.yaml diff --git a/Documentation/devicetree/bindings/interrupt-controller/riscv,rpmi-system-msi.yaml b/Documentation/devicetree/bindings/interrupt-controller/riscv,rpmi-system-msi.yaml new file mode 100644 index 000000000000..e6c297e66c99 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/riscv,rpmi-system-msi.yaml @@ -0,0 +1,89 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/riscv,rpmi-system-msi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V RPMI system MSI service group based interrupt controller + +maintainers: + - Anup Patel + +description: | + The RISC-V Platform Management Interface (RPMI) [1] defines a + messaging protocol which is modular and extensible. The supervisor + software can send/receive RPMI messages via SBI MPXY extension [2] + or some dedicated supervisor-mode RPMI transport. + + The RPMI specification [1] defines system MSI service group which + allow application processors to receive MSIs upon system events + such as P2A doorbell, graceful shutdown/reboot request, CPU hotplug + event, memory hotplug event, etc from the platform microcontroller. + + =========================================== + References + =========================================== + + [1] RISC-V Platform Management Interface (RPMI) + https://github.com/riscv-non-isa/riscv-rpmi/releases + + [2] RISC-V Supervisor Binary Interface (SBI) + https://github.com/riscv-non-isa/riscv-sbi-doc/releases + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + +properties: + compatible: + oneOf: + - description: + Intended for use by the SBI implementation in machine mode or + software in supervisor mode. + const: riscv,rpmi-system-msi + + - description: + Intended for use by the SBI implementation in machine mode. + const: riscv,rpmi-mpxy-system-msi + + mboxes: + maxItems: 1 + description: + Mailbox channel of the underlying RPMI transport or SBI message proxy. + + riscv,sbi-mpxy-channel-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The SBI MPXY channel id to be used for providing RPMI access to + the supervisor software. This property is mandatory when using + riscv,rpmi-mpxy-system-msi compatible string. + + msi-parent: true + + interrupt-controller: true + + "#interrupt-cells": + const: 1 + +required: + - compatible + - mboxes + - msi-parent + - interrupt-controller + - "#interrupt-cells" + +additionalProperties: false + +examples: + - | + mpxy_mbox: sbi-mpxy-mbox { + compatible = "riscv,sbi-mpxy-mbox"; + #mbox-cells = <2>; + }; + rpmi_sysmsi_intc: interrupt-controller { + compatible = "riscv,rpmi-system-msi"; + mboxes = <&mpxy_mbox 0x2000 0x0>; + msi-parent = <&imsic_slevel>; + interrupt-controller; + #interrupt-cells = <1>; + }; +... From patchwork Mon Feb 3 08:49:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957177 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 1B960C02198 for ; Mon, 3 Feb 2025 10:00:57 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xQWaaatQCekCJ/Qvia/bxH82rMk1xW8B3dEMgg8LdzA=; b=PxGZUs5G8/m5I9 O3BYVrJ81UTG5APpYUyhIm4hOwfoo8MCK/UWOhivx9AlS0hZpvbA816wpUGGA3RxZDvwbcRk7Azz2 7wG//hfKMDvjnsb5mf+uzFiAgTI/yX2T2IOu6KKbwTik7AUQBmL45hTUVEOJREN3MhVbhxMjDDvUj RZdJJi/ojyymbjZPWOZA4nCI6BkbiQ873GRfsblGDc5p5NUVvaQiCEkO+wjaKqIN+f6vuzKGov+Hp LHEvT1bb1IQu3I23jmTkd+M8PtF9/c6DkRGRcuMQfx/y/Ym+X6wN8rrbe3h9Q5oU/KKdSeKaNuVTR R2ep6VTKTRDa+WXCb+BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tetG7-0000000F3xC-1MS5; Mon, 03 Feb 2025 10:00:51 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesBD-0000000EuYE-1WTy for linux-riscv@bombadil.infradead.org; Mon, 03 Feb 2025 08:51:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=za34CkI9FT1rB9oDtYlDukqoAc5AmHLtrlnO18JC4mE=; b=l/3qrXyqLkS+Rp/cvdxFae6l1K vDNwOlHPhTxmaQ7saymFQXzs2+H2sZ2ST6w7Ew7QAhdQtE14G5ZoNOUI2C/zzKUN12GpCRL3IUXYH 9nO1+wUEfqjFfwkxxzxj25Q1gD4gTCP73dT3mED+a5RiDUIwxC8OqLo492qFpvmUi1juUOB9+zG7v Vl6Tcl/u0CNVWGvQ+SPBTagkMaQ9IBzkmDw6x6ABk+IdGtNYW1y3NCiHXkP1h6r0IYIP2rI6P/R6p oqtnn/F0aT2tm+lI++BS/fcbYNHa8JDjR6dA2EACQ1fxAzXDvoUNXQwMQzcNViUdZG1FVXb8UD1p9 hXyPa/mQ==; Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesBA-0000000G0zL-1Yeq for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:51:42 +0000 Received: by mail-qt1-x835.google.com with SMTP id d75a77b69052e-4678afeb133so44180051cf.0 for ; Mon, 03 Feb 2025 00:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572698; x=1739177498; 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=za34CkI9FT1rB9oDtYlDukqoAc5AmHLtrlnO18JC4mE=; b=UDt7DpoZpeexH/NNka1bCBQ64Co8EjEr9bozRvY8BtLVtFoDAdfF5D4oVjUV419PXT edBCsvZWwKWg2g/1b38lvPRpLzlFiBknxWihkd0Wh5I02VGqw/SQdWhgYum8NchSgvbG XOiFieZPonMEs8wyW1Vio9VFmqLcpjwvVsbbD4NzQA6R0u6ax+0BrrBUxHX5ntuOK1Zx q1OAbEt3zbl3gI+cQb87++Yczb2GaZjRp3ylFcmumNhXzI/AvywHneKSaVTLZWf5knWs KpiDwYQG8iO+NwM0t/WPnm34QI0QFwKb8mqwnNCGZP0kAOocKSmPkyKciKh+KuA2hdgO kgIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572698; x=1739177498; 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=za34CkI9FT1rB9oDtYlDukqoAc5AmHLtrlnO18JC4mE=; b=srVPVKHdNE9xohgdyX9o74QNxI8PHPbK6gxLoyn7FPQAlMQI2kg8gONDWhxoRcED56 4SknL9hLcD4Owfu4ytcsiIP1T1yP9ZO9ji+JXuxCB1PQUmwd6tZvMF7pJvCHGExoEprT HHE3AN8B/g/Rg41K+2eEO+BNVWzeKxUIqkT6LD2efssiQsFhL0D9BMRQMKljzP3GOWuG p3h/808lamsBJTIEZc0qQuzMW2gUAMZc/REiYd5RCYtWsfVtFr8uuEZN7xiEYA+USpe7 +/NSNPCxb0uNnyEr2ing6yFFr3BiObYMm/fpFdHXbp/WWfil+x03wZhIu6K31646ZsvQ HHyg== X-Forwarded-Encrypted: i=1; AJvYcCW4vvMx7GukUqzKTF1jgoWZuYonRyzUxCt4DE7/XCG6yO/iuzyImM0XV0zrv3ZjjgPD831qtcZ0Z+1Q8Q==@lists.infradead.org X-Gm-Message-State: AOJu0Yx5kdMISHAaKFnpM2wA0pVjm4nHpWZbl5VT6d7yFeMYfPwf7SSU c00CLsWrBPlMGkROl2eSdqSc0o0B7GSQtUTHp7qU+npc0OZUibznB+rfPQUT5lI= X-Gm-Gg: ASbGnct9c39JoN9tjOjifvc7mgV8Hv5uQLeOKSj+/DtS2QTr7qcWlYyDmUhqzQxOzf8 KQmOdJDt3TYFhbu9kTY3uK4+bAEINNz8mn1oi0GFiRynyZOWAX5KmwXanxXANDE5YcHHyL/YyDR s2r/YVhvAwcnPrxlcFcNxr4F+nXix3m5HOUh9ThA5NydGpyghbAc42+PD51NAyfSHSDSxwoL3Yx /kLCT4dArDdbgHOLIDAzp3cz3uqa7ymWw81Mw6A8lrOzG4nMRNQLmaCf9zYmb0TPlMv0odBgfYD Bj5zlMEJF9iXfKR17ioGzdBJMCRibBIp4noiVUAmLAqYHelvkaRN7fA= X-Google-Smtp-Source: AGHT+IEoObq3l1eHc/KzGX6ro+9oImA6MqQqrEasNZYsOOAQgB+gfdqPDc6JsUyC/VlMlSWe4speGA== X-Received: by 2002:ac8:5a8d:0:b0:46b:1c07:12c5 with SMTP id d75a77b69052e-46fea0f1ef8mr149763641cf.17.1738572697937; Mon, 03 Feb 2025 00:51:37 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:51:36 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 11/17] irqchip: Add driver for the RISC-V RPMI system MSI service group Date: Mon, 3 Feb 2025 14:19:00 +0530 Message-ID: <20250203084906.681418-12-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_085140_624938_149F6CE0 X-CRM114-Status: GOOD ( 28.31 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The RPMI specification defines a system MSI service group which allows application processors to receive MSIs upon system events such as graceful shutdown/reboot request, CPU hotplug event, memory hotplug event, etc. Add an irqchip driver for the RISC-V RPMI system MSI service group to directly receive system MSIs in Linux kernel. Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 7 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 283 +++++++++++++++++++++ include/linux/mailbox/riscv-rpmi-message.h | 13 + 4 files changed, 304 insertions(+) create mode 100644 drivers/irqchip/irq-riscv-rpmi-sysmsi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index be063bfb50c4..2ae44354735b 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -597,6 +597,13 @@ config RISCV_IMSIC_PCI depends on PCI_MSI default RISCV_IMSIC +config RISCV_RPMI_SYSMSI + bool + depends on MAILBOX + select IRQ_DOMAIN_HIERARCHY + select GENERIC_MSI_IRQ + default RISCV + config SIFIVE_PLIC bool depends on RISCV diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 25e9ad29b8c4..7164aae58b47 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -101,6 +101,7 @@ obj-$(CONFIG_RISCV_INTC) += irq-riscv-intc.o obj-$(CONFIG_RISCV_APLIC) += irq-riscv-aplic-main.o irq-riscv-aplic-direct.o 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_RISCV_RPMI_SYSMSI) += irq-riscv-rpmi-sysmsi.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 diff --git a/drivers/irqchip/irq-riscv-rpmi-sysmsi.c b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c new file mode 100644 index 000000000000..3022f0924c94 --- /dev/null +++ b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c @@ -0,0 +1,283 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2025 Ventana Micro Systems Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct rpmi_sysmsi_get_attrs_rx { + s32 status; + u32 sys_num_msi; + u32 p2a_db_index; + u32 flag0; + u32 flag1; +}; + +#define RPMI_SYSMSI_MSI_ATTRIBUTES_FLAG0_PREF_PRIV BIT(0) + +struct rpmi_sysmsi_set_msi_state_tx { + u32 sys_msi_index; + u32 sys_msi_state; +}; + +struct rpmi_sysmsi_set_msi_state_rx { + s32 status; +}; + +#define RPMI_SYSMSI_MSI_STATE_ENABLE BIT(0) +#define RPMI_SYSMSI_MSI_STATE_PENDING BIT(1) + +struct rpmi_sysmsi_set_msi_target_tx { + u32 sys_msi_index; + u32 sys_msi_address_low; + u32 sys_msi_address_high; + u32 sys_msi_data; +}; + +struct rpmi_sysmsi_set_msi_target_rx { + s32 status; +}; + +struct rpmi_sysmsi_priv { + struct device *dev; + struct mbox_client client; + struct mbox_chan *chan; + u32 nr_irqs; + u32 gsi_base; +}; + +static int rpmi_sysmsi_get_num_msi(struct rpmi_sysmsi_priv *priv) +{ + struct rpmi_sysmsi_get_attrs_rx rx; + struct rpmi_mbox_message msg; + int ret; + + rpmi_mbox_init_send_with_response(&msg, RPMI_SYSMSI_SRV_GET_ATTRIBUTES, + NULL, 0, &rx, sizeof(rx)); + ret = rpmi_mbox_send_message(priv->chan, &msg); + if (ret) + return ret; + if (rx.status) + return rpmi_to_linux_error(rx.status); + + return rx.sys_num_msi; +} + +static int rpmi_sysmsi_set_msi_state(struct rpmi_sysmsi_priv *priv, + u32 sys_msi_index, u32 sys_msi_state) +{ + struct rpmi_sysmsi_set_msi_state_tx tx; + struct rpmi_sysmsi_set_msi_state_rx rx; + struct rpmi_mbox_message msg; + int ret; + + tx.sys_msi_index = sys_msi_index; + tx.sys_msi_state = sys_msi_state; + rpmi_mbox_init_send_with_response(&msg, RPMI_SYSMSI_SRV_SET_MSI_STATE, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret = rpmi_mbox_send_message(priv->chan, &msg); + if (ret) + return ret; + if (rx.status) + return rpmi_to_linux_error(rx.status); + + return 0; +} + +#define rpmi_sysmsi_mask(__priv, __msi_index) \ + rpmi_sysmsi_set_msi_state(__priv, __msi_index, 0) +#define rpmi_sysmsi_unmask(__priv, __msi_index) \ + rpmi_sysmsi_set_msi_state(__priv, __msi_index, RPMI_SYSMSI_MSI_STATE_ENABLE) + +static int rpmi_sysmsi_set_msi_target(struct rpmi_sysmsi_priv *priv, + u32 sys_msi_index, struct msi_msg *m) +{ + struct rpmi_sysmsi_set_msi_target_tx tx; + struct rpmi_sysmsi_set_msi_target_rx rx; + struct rpmi_mbox_message msg; + int ret; + + tx.sys_msi_index = sys_msi_index; + tx.sys_msi_address_low = m->address_lo; + tx.sys_msi_address_high = m->address_hi; + tx.sys_msi_data = m->data; + rpmi_mbox_init_send_with_response(&msg, RPMI_SYSMSI_SRV_SET_MSI_TARGET, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret = rpmi_mbox_send_message(priv->chan, &msg); + if (ret) + return ret; + if (rx.status) + return rpmi_to_linux_error(rx.status); + + return 0; +} + +static void rpmi_sysmsi_irq_mask(struct irq_data *d) +{ + struct rpmi_sysmsi_priv *priv = irq_data_get_irq_chip_data(d); + int ret; + + ret = rpmi_sysmsi_mask(priv, d->hwirq); + if (ret) + dev_warn(priv->dev, "Failed to mask hwirq %d (error %d)\n", + (u32)d->hwirq, ret); + irq_chip_mask_parent(d); +} + +static void rpmi_sysmsi_irq_unmask(struct irq_data *d) +{ + struct rpmi_sysmsi_priv *priv = irq_data_get_irq_chip_data(d); + int ret; + + irq_chip_unmask_parent(d); + ret = rpmi_sysmsi_unmask(priv, d->hwirq); + if (ret) + dev_warn(priv->dev, "Failed to unmask hwirq %d (error %d)\n", + (u32)d->hwirq, ret); +} + +static void rpmi_sysmsi_write_msg(struct irq_data *d, struct msi_msg *msg) +{ + struct rpmi_sysmsi_priv *priv = irq_data_get_irq_chip_data(d); + int ret; + + /* For zeroed MSI, do nothing as of now */ + if (!msg->address_hi && !msg->address_lo && !msg->data) + return; + + ret = rpmi_sysmsi_set_msi_target(priv, d->hwirq, msg); + if (ret) + dev_warn(priv->dev, "Failed to set target for hwirq %d (error %d)\n", + (u32)d->hwirq, ret); +} + +static void rpmi_sysmsi_set_desc(msi_alloc_info_t *arg, struct msi_desc *desc) +{ + arg->desc = desc; + arg->hwirq = (u32)desc->data.icookie.value; +} + +static int rpmi_sysmsi_translate(struct irq_domain *d, struct irq_fwspec *fwspec, + unsigned long *hwirq, unsigned int *type) +{ + struct msi_domain_info *info = d->host_data; + struct rpmi_sysmsi_priv *priv = info->data; + + if (WARN_ON(fwspec->param_count < 1)) + return -EINVAL; + + /* For DT, gsi_base is always zero. */ + *hwirq = fwspec->param[0] - priv->gsi_base; + *type = IRQ_TYPE_NONE; + return 0; +} + +static const struct msi_domain_template rpmi_sysmsi_template = { + .chip = { + .name = "RPMI-SYSMSI", + .irq_mask = rpmi_sysmsi_irq_mask, + .irq_unmask = rpmi_sysmsi_irq_unmask, +#ifdef CONFIG_SMP + .irq_set_affinity = irq_chip_set_affinity_parent, +#endif + .irq_write_msi_msg = rpmi_sysmsi_write_msg, + .flags = IRQCHIP_SET_TYPE_MASKED | + IRQCHIP_SKIP_SET_WAKE | + IRQCHIP_MASK_ON_SUSPEND, + }, + + .ops = { + .set_desc = rpmi_sysmsi_set_desc, + .msi_translate = rpmi_sysmsi_translate, + }, + + .info = { + .bus_token = DOMAIN_BUS_WIRED_TO_MSI, + .flags = MSI_FLAG_USE_DEV_FWNODE, + .handler = handle_simple_irq, + .handler_name = "simple", + }, +}; + +static int rpmi_sysmsi_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct rpmi_sysmsi_priv *priv; + int rc; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + priv->dev = dev; + platform_set_drvdata(pdev, priv); + + /* Setup mailbox client */ + priv->client.dev = priv->dev; + priv->client.rx_callback = NULL; + priv->client.tx_block = false; + priv->client.knows_txdone = true; + priv->client.tx_tout = 0; + + /* Request mailbox channel */ + priv->chan = mbox_request_channel(&priv->client, 0); + if (IS_ERR(priv->chan)) + return PTR_ERR(priv->chan); + + /* Get number of system MSIs */ + rc = rpmi_sysmsi_get_num_msi(priv); + if (rc < 1) { + mbox_free_channel(priv->chan); + return dev_err_probe(dev, -ENODEV, "No system MSIs found\n"); + } + priv->nr_irqs = rc; + + /* Set the device MSI domain if not available */ + if (!dev_get_msi_domain(dev)) { + /* + * The device MSI domain for OF devices is only set at the + * time of populating/creating OF device. If the device MSI + * domain is discovered later after the OF device is created + * then we need to set it explicitly before using any platform + * MSI functions. + */ + if (is_of_node(dev->fwnode)) + of_msi_configure(dev, to_of_node(dev->fwnode)); + + if (!dev_get_msi_domain(dev)) + return -EPROBE_DEFER; + } + + if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, + &rpmi_sysmsi_template, + priv->nr_irqs, priv, priv)) + return dev_err_probe(dev, -ENOMEM, "failed to create MSI irq domain\n"); + + dev_info(dev, "%d system MSIs registered\n", priv->nr_irqs); + return 0; +} + +static const struct of_device_id rpmi_sysmsi_match[] = { + { .compatible = "riscv,rpmi-system-msi" }, + {} +}; + +static struct platform_driver rpmi_sysmsi_driver = { + .driver = { + .name = "rpmi-sysmsi", + .of_match_table = rpmi_sysmsi_match, + }, + .probe = rpmi_sysmsi_probe, +}; +builtin_platform_driver(rpmi_sysmsi_driver); diff --git a/include/linux/mailbox/riscv-rpmi-message.h b/include/linux/mailbox/riscv-rpmi-message.h index f43d0874ad68..9bf3f20c5e70 100644 --- a/include/linux/mailbox/riscv-rpmi-message.h +++ b/include/linux/mailbox/riscv-rpmi-message.h @@ -90,6 +90,7 @@ static inline int rpmi_to_linux_error(int rpmi_error) } /** RPMI service group IDs */ +#define RPMI_SRVGRP_SYSTEM_MSI 0x00002 #define RPMI_SRVGRP_CLOCK 0x00008 /** RPMI clock service IDs */ @@ -105,6 +106,18 @@ enum rpmi_clock_service_id { RPMI_CLK_SRV_ID_MAX_COUNT, }; +/** RPMI system MSI service IDs */ +enum rpmi_sysmsi_service_id { + RPMI_SYSMSI_SRV_ENABLE_NOTIFICATION = 0x01, + RPMI_SYSMSI_SRV_GET_ATTRIBUTES = 0x2, + RPMI_SYSMSI_SRV_GET_MSI_ATTRIBUTES = 0x3, + RPMI_SYSMSI_SRV_SET_MSI_STATE = 0x4, + RPMI_SYSMSI_SRV_GET_MSI_STATE = 0x5, + RPMI_SYSMSI_SRV_SET_MSI_TARGET = 0x6, + RPMI_SYSMSI_SRV_GET_MSI_TARGET = 0x7, + RPMI_SYSMSI_SRV_ID_MAX_COUNT, +}; + /** RPMI linux mailbox attribute IDs */ enum rpmi_mbox_attribute_id { RPMI_MBOX_ATTR_SPEC_VERSION = 0, From patchwork Mon Feb 3 08:49:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957049 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 56995C02193 for ; Mon, 3 Feb 2025 08:52:02 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TQpt4saFQ+LjMjvzY9M2+/Y4LtoD+cj9Zb7Z1y+xlis=; b=y8skXpmUL/hN/3 mJAccBBQbFRgSX9tv3M4fiHPhrUMSptQVIPaCEyq2Q3fpHVc8synIe6fWgE8dNU0XXcx9VjiL6Jzf C5wQktogmUZMa6pEDuvEMZewYdt1yyDKSafM7Ow47KJpM9RDAUOMjmcPjvUlN5rdveppQc3lAOmvN VhhloXOU6+MONx33+SpEmrCHjUk6zG/1XRcz3lnFvQQWl40bihZrHN3dDIlEVsJwxo+nmtdEpxUSf GCvATdKxHPkkbdziqtzfN8ykvfsARCmSClN5sQuteJGNUtc3UN0MMC43HsRVsscZzjCA6JMTrH85y lS+KV8jyRG0JAklNBHDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tesBQ-0000000EucN-3CX0; Mon, 03 Feb 2025 08:51:56 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesBP-0000000Euby-3jv5 for linux-riscv@bombadil.infradead.org; Mon, 03 Feb 2025 08:51:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=xKPU9Sa0XErJQ269iR1m+yFQ6vBRkGcfLU2YVNEM1yU=; b=Z/JdWjNxXp7yqjFXVXkrkeGIje jrXXN6KrCS9sqvogFrJIZpUNVTDsDVOx8ixB8CvY+frpAUaqxx/K7Q+ch7gwwPvq042beHZPHIoES wdZDOqoXVIDDUZez3I2vIuT1zO0FDuBy4tT1iwvArpGN/ohLPATi/hjrC8d2ikK3lfPsxV52/E8lw 33fzCuk+lEEQUzi4wR32xWTaM/zSBa3eFhuWFieV1sb/HSi1vMsA7DeA46dROqTqoeOQktNiEuxEP YuGwbJ9AZgNfzxpDD4nsvG5hi51+j5rQarxbt+XfRsSB2dkkxuTEGcjrA2jSu7hLhhbYNDaEA3cZ4 UHP1s0NQ==; Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesBM-0000000G10u-40Hx for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:51:54 +0000 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-46e28597955so37555951cf.0 for ; Mon, 03 Feb 2025 00:51:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572710; x=1739177510; 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=xKPU9Sa0XErJQ269iR1m+yFQ6vBRkGcfLU2YVNEM1yU=; b=BAyWcA2KsMDUOC0kWNyfQ0e9T+PrZrxY/GUotHT7ShB/8Je5J+jquKhynXm3xXDwQ6 whO6v0GZH+MyXxNDIiADCdkDYxPeHCbEAp19IOBh6MtTMOD9vB9s1AzDoys9d1YLmy/a f+s26rZcaDGznYEtA0WOFCNt36m18/KgRKxImCFgunieVNAqaaUnA+qQS4kdMqSke0sy xkEoisItnvN2vgTZuEMP/VfKcUABFYsSfoZbZQ2Z857++cuefLA92WJ/tqhfdKHfndDT 5W6cCvWRilhs0kBFwcM5h9/I57C2dNRuUt2WFbInYQ4yP8KZljFD2mRoLVAOTBV+Q4dz OrtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572710; x=1739177510; 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=xKPU9Sa0XErJQ269iR1m+yFQ6vBRkGcfLU2YVNEM1yU=; b=DemG3KIjnJ17M0UFP21IJT8mOP5+3621hLo9Tpprdg3+y2K0MdDAKA2RqZfq4ZY0V/ ZjzkM7z0LZhhK5JlFumdn7gRNOzuu13jO7WX0Z1tMNWtkU9W6Q+Jv8YrHqAS+XDaCOLP aaALamCim+2T4sGur7eC0HI9s0Gw91fh1DWbe6ubr8r/vVfTZ9uYvFYgyXo7ZSDtEtkU 2w5QitT7yCymc8pO+wSlPUjz2/aGKSCNrr506rBLgjJOwmDchDfAGC/ClQXdaPId4oc3 Hg7NaSyQc9oXOsuoo6IcuwOB6WqVbS0hrc+NrBmUGZ4+PeTYcFuZBN37NZlaZZelYPM9 TfwQ== X-Forwarded-Encrypted: i=1; AJvYcCUNoQKA7j1XHIxvMZgoV0FrqMcbGSTaHo9SJc/Q7k52PT+C8ZOJ0zXm0XEud3ZIKjaPchZQSHTO4mrJsw==@lists.infradead.org X-Gm-Message-State: AOJu0YzwLotijFPFT38QReuda7h0OMoTKDfDhvNzcVvE4z82CGC670am xxg0pMQWTJc9P6MFFD0zIHQRtuhawdJHibN8XNM97E0VtbvkC5EI1Tx/xJeHDRo= X-Gm-Gg: ASbGncsoQ8ad3X4QMR6o/RkQjEjLoJNlJv5nXe7UvJm/t6bow0aELsAxbt764qN1frN ZXZlCqKqT+L+fHLREmDhHT13JpJvaNkyEzjfNHzu5CmroHPI3L+V0bXJKTl8v4MJ8Nsh1k1olOv sVAmytvqFtSZTKC+URrjbZ4ukgN1q89JEycgapqEgLygB58mkgBCL7AHTP3tfngYKCwrEwSdbnH 2Zn48lp+f8mzB2r7fNtvjdY8QoLt2KzCgtsWUqy5lbEUo9grRq8mljH8yOVhBXz7zq3B677e8CJ Gc3N8o1B5mnXOEMiCbxj/Q259usizcbgQH9cZNm2q37HMWhgp8slmVg= X-Google-Smtp-Source: AGHT+IEAlKOfPcFGtQpuphtMUGEmXxc2P48rleG0cvQ2g1VY6q+JOVmQhLQFN1AJS8GBnyiR7yIR5Q== X-Received: by 2002:a05:622a:5a07:b0:467:5f95:679 with SMTP id d75a77b69052e-46fd0b6b509mr303055821cf.42.1738572710457; Mon, 03 Feb 2025 00:51:50 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:51:49 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 12/17] ACPI: property: Add support for nargs_prop in acpi_fwnode_get_reference_args() Date: Mon, 3 Feb 2025 14:19:01 +0530 Message-ID: <20250203084906.681418-13-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_085153_193175_41C09222 X-CRM114-Status: GOOD ( 17.30 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Sunil V L fwnode_get_reference_args() which is common for both DT and ACPI passes a property name like #mbox-cells which needs to be fetched from the reference node to determine the number of arguments needed for the property. However, the ACPI version of this function doesn't support this and simply ignores the parameter passed from the wrapper function. Add support for dynamically finding number of arguments by reading the nargs property value. Update the callers to pass extra parameter. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/acpi/property.c | 15 +++++++++++++-- drivers/gpio/gpiolib-acpi.c | 2 +- drivers/pwm/core.c | 2 +- include/linux/acpi.h | 12 +++++++----- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 98d93ed58315..ddea5dec70bd 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -887,6 +887,9 @@ static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *f * @fwnode: Firmware node to get the property from * @propname: Name of the property * @index: Index of the reference to return + * @nargs_prop: The name of the property telling the number of arguments + * in the referred node. NULL if @num_args is known, otherwise + * @num_args is ignored. * @num_args: Maximum number of arguments after each reference * @args: Location to store the returned reference with optional arguments * (may be NULL) @@ -919,13 +922,14 @@ static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *f * Return: %0 on success, negative error code on failure. */ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, - const char *propname, size_t index, size_t num_args, + const char *propname, size_t index, const char *nargs_prop, size_t num_args, struct fwnode_reference_args *args) { const union acpi_object *element, *end; const union acpi_object *obj; const struct acpi_device_data *data; struct fwnode_handle *ref_fwnode; + struct acpi_device *ref_adev; struct acpi_device *device; int ret, idx = 0; @@ -1012,6 +1016,13 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, element->string.pointer); if (!ref_fwnode) return -EINVAL; + if (nargs_prop) { + ref_adev = to_acpi_device_node(ref_fwnode); + if (!acpi_dev_get_property(ref_adev, nargs_prop, + ACPI_TYPE_INTEGER, &obj)) { + num_args = obj->integer.value; + } + } element++; @@ -1565,7 +1576,7 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, struct fwnode_reference_args *args) { return __acpi_node_get_property_reference(fwnode, prop, index, - args_count, args); + nargs_prop, args_count, args); } static const char *acpi_fwnode_get_name(const struct fwnode_handle *fwnode) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 1f9fe50bba00..de8e4d081539 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -839,7 +839,7 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, int ret; memset(&args, 0, sizeof(args)); - ret = __acpi_node_get_property_reference(fwnode, propname, index, 3, + ret = __acpi_node_get_property_reference(fwnode, propname, index, NULL, 3, &args); if (ret) { struct acpi_device *adev; diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index ccd54c089bab..7afd78061e6e 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -1790,7 +1790,7 @@ static struct pwm_device *acpi_pwm_get(const struct fwnode_handle *fwnode) memset(&args, 0, sizeof(args)); - ret = __acpi_node_get_property_reference(fwnode, "pwms", 0, 3, &args); + ret = __acpi_node_get_property_reference(fwnode, "pwms", 0, NULL, 3, &args); if (ret < 0) return ERR_PTR(ret); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 4e495b29c640..b9fd3c812e1f 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1296,8 +1296,9 @@ static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) int acpi_dev_get_property(const struct acpi_device *adev, const char *name, acpi_object_type type, const union acpi_object **obj); int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, - const char *name, size_t index, size_t num_args, - struct fwnode_reference_args *args); + const char *name, size_t index, + const char *nargs_prop, size_t num_args, + struct fwnode_reference_args *args); static inline int acpi_node_get_property_reference( const struct fwnode_handle *fwnode, @@ -1305,7 +1306,7 @@ static inline int acpi_node_get_property_reference( struct fwnode_reference_args *args) { return __acpi_node_get_property_reference(fwnode, name, index, - NR_FWNODE_REFERENCE_ARGS, args); + NULL, NR_FWNODE_REFERENCE_ARGS, args); } static inline bool acpi_dev_has_props(const struct acpi_device *adev) @@ -1400,8 +1401,9 @@ static inline int acpi_dev_get_property(struct acpi_device *adev, static inline int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, - const char *name, size_t index, size_t num_args, - struct fwnode_reference_args *args) + const char *name, size_t index, + const char *nargs_prop, size_t num_args, + struct fwnode_reference_args *args) { return -ENXIO; } From patchwork Mon Feb 3 08:49:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957175 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 641F3C02199 for ; Mon, 3 Feb 2025 10:00:57 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cPUnndRT7OFxugojQgzVItydhBRCAUpG9tmASKID0U0=; b=J3IInrS4hOpSsk amiPZdtJEVrXnuLNvfGAE3BmaRyYDBkB1vCpn0gVTRqXRUrPeXxGZgYm6utGkX/nYxg+Vto/o+NiB tfVKCpH2QcA0gzN9653hMuhoiH/JjdA46aZ4kDj0y08X4wyLiNsbbvE9bfJCfByeStPWTtOA7aaQ6 oH5wElDqrhvHpnVxlO/kOdAUxFjCM+m3ZLc2mB6V9h1vI2wtP9JA9Ip2c6W/ynBZYTE5oEQEwFPNR xD63lipcJ9I9Fpfdor4yYHK8YLANkfXbq3polBtjIhJoC75CwMMPfBzyS7O4EkOS9RKnG2q6O0SNa ACPr8OTFR+JucPT12/7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tetG7-0000000F3xm-3lc7; Mon, 03 Feb 2025 10:00:51 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesBd-0000000EugB-2tD9 for linux-riscv@bombadil.infradead.org; Mon, 03 Feb 2025 08:52:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=QqHKfwEB4phXeApzs0j4obzgLpliUPZiImb73QFVqNg=; b=im6QtQJzsdgE0Sic33MOcSaNJQ p37OjsTUx4/5idqCI6y7qVEExs6FekZDQAB82bbnJKFuSuDCmt6+OOEi6/0e4tGtywdev0iYqyBjA o1d7Cyf3ZlpgSBDU5kk8hXXctjaiuWqwXWs7olNtGFu3Do7XJr2e1Z8vBxylL1osCxwdTJRGfF7/J H3r91HUFANbPbrYFwn1zOPQEpEy/vcGkOWacTiZr9PoY3792D5PaiY97YbfVKwhyfWoPbNFbweJUA OUWoKCpjU1ZGbYTHOuIcPQrkNYO9+Ry58sVlF1oSCQCITtgCbT7F3iMEEjzNw6qS3Xfjeg2QOLsRE xrRIqC4Q==; Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesBa-0000000G12T-2qhb for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:52:08 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-467a1d43821so47867231cf.1 for ; Mon, 03 Feb 2025 00:52:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572724; x=1739177524; 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=QqHKfwEB4phXeApzs0j4obzgLpliUPZiImb73QFVqNg=; b=KHSCjwLmALWtQ8KigDSZDDAOQNrk1yVowjqbKmPT9RCBxLwdoAlPbkbvjAiegeCbJ3 hm1Dqg/7ynd0nG5IcwCzYthqhN3RoIb59EPsPalSTvJMttqPxurAbpySyrWFxuOIErCH 19tJULAtZmX+KJ9fJjPhFRqn4uu4oFFz8yiihcKFEJX8N7B1o19F0HNTsmCSsTZCycMI bjOx/QuQp30dY1O8LAd+Dbk1pBMj9b1sNDFVga6mqKMg8WZMiHcaK0dxSbDWOmN4+60/ 6wAmysVCpT6I/iFpEeRkAUR+Kd0uDmxMe9lJXu1x9ly31NNSfUdmkRCuYPcJN6uCNbDi 30pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572724; x=1739177524; 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=QqHKfwEB4phXeApzs0j4obzgLpliUPZiImb73QFVqNg=; b=UK+M7ujWfii5ZGMuTogXyvw2yOM4V5zq+T6D2tCjPSKLFUNXnP1UpEWGeg/oDVZY6U xoB+jXipUFLYFQKu8NmtG82KFrJF2YtV3t2nIxIeq7MlqnD9FmHs6m3jWHucXAd2/l5q 5UtKnks3LHNzLbOtW3Gvs9tJFqGQM7jsZWxpvSCI6EBQV47lm8jMQbcZnIf3Jt1IpVYd 12PdGspj5Vv7mkrwT5cU3LyJoQxxpfYe1iUzzN0WazEMSEkepRO++9eAmitgeF7w2QH0 y9Qhy3oMSVmVNeYqzkU1Z/DsvUnDobxGwOdu+OPDIyN8KAnJXLWIAd76JUIW8LdkEc5W u/jw== X-Forwarded-Encrypted: i=1; AJvYcCVQVtbiz0HZ3kB9LF43Ac2vGOEycBxRkorbGX6cyxMS79fzMqpdVCjbXrvNt4wIl7jybm0Ii7WH6it5xw==@lists.infradead.org X-Gm-Message-State: AOJu0Yw9fac+c/E9+VThdSRxWCTfRy1IMy0pAuiynDcIBInHtly2aZGy 28cqJy/Phoy1xCO7ykL/WzNUnLeioc9+r1kKc1cp+3/P67RJ8e7tk5mENHapLaY= X-Gm-Gg: ASbGncu4exjuXthZ+78u1Jtk0SSsM+LceIl2cGbuvyLa0U+Urs8hwVhCMnfQJFIsXvB bveMk2aPgatTXgYH8ZTMZNj70N6u7NLFjBO6riTwIi58zuVxlO/Yk1KPR95K36ONfK8qWveVJDc 8SJrrL8MzmT74GWcB3y2TyG7NLQe37do8145McR6zyqWEVDp9BSl8kSIbjlDMeM2KT+6zePibS2 DnddMqWm895i8kuiuvFsdciZB+TzHaqN3Ka+wt+r1mwttRgKzi+/Cbis0QHPlKzaEf1eGDgXh9z CgMP54PvEGceY46N+ucr/ui75kv9/VOE+dS1NyQA0aVWg9rFbrrS1I4= X-Google-Smtp-Source: AGHT+IGWVNCE2D8XvH1GGSIfS5LXa9bxJFfSjFmLfIb7zNeOXcqdzBvLSHp2sbBS6h1VqkAcm9r5rQ== X-Received: by 2002:a05:622a:304:b0:461:7558:892f with SMTP id d75a77b69052e-46fea0ab7d0mr150479241cf.15.1738572724220; Mon, 03 Feb 2025 00:52:04 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:52:03 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 13/17] ACPI: scan: Update honor list for RPMI System MSI Date: Mon, 3 Feb 2025 14:19:02 +0530 Message-ID: <20250203084906.681418-14-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_085207_007512_9299CCE3 X-CRM114-Status: GOOD ( 10.62 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Sunil V L The RPMI System MSI interrupt controller (just like PLIC and APLIC) needs to probed prior to devices like GED which use interrupts provided by it. Also, it has dependency on the SBI MPXY mailbox device. Add HIDs of RPMI System MSI and SBI MPXY mailbox devices to the honor list so that those dependencies are handled. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/acpi/scan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 9f4efa8f75a6..e490b4160612 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -858,6 +858,8 @@ static const char * const acpi_honor_dep_ids[] = { "INTC10CF", /* IVSC (MTL) driver must be loaded to allow i2c access to camera sensors */ "RSCV0001", /* RISC-V PLIC */ "RSCV0002", /* RISC-V APLIC */ + "RSCV0005", /* RISC-V SBI MPXY MBOX */ + "RSCV0006", /* RISC-V RPMI SYSMSI */ "PNP0C0F", /* PCI Link Device */ NULL }; From patchwork Mon Feb 3 08:49:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957176 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 D892BC0219A for ; Mon, 3 Feb 2025 10:00:57 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WYADX7LiFcTJxVdE6uTLHT5jblfvZxqmuHGjIfKOKSs=; b=qR42YRZ2VfyO/a sA2A6w4rirF2zyZWl0aD6WcvcQBr7Y5Ra34Mc8lZaUQNg93K0WDohDU74CyytfpQb9DhI4k1XTOcy +coDfxbcKkLoCCZy6DT/HH2yqlYQHAp5W+bbJtdfCUlr/dVtKPi20YswnSJ81TMu7njnMmDR5G/0j tJhBUMKFJEmAff0fEkPxO/LruibC8E/mZz385nWK/cR+CmHwFYz37sxdB08156EU8ZfM+AdjmAG9+ ku2YwqURUieykHhOIrtwMGKofi2mJ2qut3gKUExG6MQy9u0A+609Buf/wFDzAYSlFdqod0k5O5oRD FVsaFa2kHCDvw9BGGdfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tetG8-0000000F3y8-275N; Mon, 03 Feb 2025 10:00:52 +0000 Received: from mail-qt1-f173.google.com ([209.85.160.173]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesBk-0000000EuiV-3Ra8 for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:52:17 +0000 Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-467b086e0easo17821441cf.1 for ; Mon, 03 Feb 2025 00:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572735; x=1739177535; 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=xtaZk8L3qjlS8UU58qulSnorfsC0dbtiDK1e5t15IP8=; b=S1mtLWTUOWbCljsIdCH5zxmLLRH6iaHLdRW7Ed7E/PjRrodFkPEiH0XLjp/kWTTike q0cYf/pIES4qOfi38CCTGULBFQipQ7WEtXYvlWzyfV1tIUcpKhZK/xKldVkpphyRjtNc 72d6PmV8mTJnQx8ya6Nux431V1DpKy+gOmm4OxE1pAu3BACfIYuDARFChqvIan2j+mDN RFFLcWRx4XYJii+q+t9vLo/KIvXz2oTMqjsevgKhuhqOycqs2Kb/KsS4aZqWf9WbBQE+ SBciSvtEwcLfdO5uxO9WmOR7j7ZeRfch9z6Y62S64/6ygyBegeCbz15kb4drqRMc17FG uuJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572735; x=1739177535; 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=xtaZk8L3qjlS8UU58qulSnorfsC0dbtiDK1e5t15IP8=; b=SvW64bi9uIHc2qvW+pTGQanyQjH+F2Aw0uedO4ulXoOUZ9YBk0fwxgLvtODJwIjrvu mSRUkO2OuhFf0w3bIZInCjzBdrqv+L+WxKd6+meUVRWr1rTtVBfMzXWSJQsEGiIlmeDG fCcxGVbVT4APQNGm5pBDNo/ph5mZAGWTwwjLq+navYvBnuuaPoCdDcw2IGTPqLbYhJbq JaqjBug2ftUzOUx7xUNwW1w1S2yf2FtKNcUSfx2vsQQLm62mDvWRqaiHafzIjJZviyx6 IhK7Zmo4rxAq9xJyn0kSh9bvi3wd2qXfXfLTKWUOxJrhwgV+zvgEr5n0WVRuDEUW4vPu Kbrw== X-Forwarded-Encrypted: i=1; AJvYcCUaXMH61pF9sAQ6AM+1ISaV5WgY4Sf4w6ofBArbbS0LzYSRyma1LCfdVdpscgRIGI6JITZjUjTYlHVz/Q==@lists.infradead.org X-Gm-Message-State: AOJu0Yz3r4gfN4S4jsxH7GjcB6Vh1dYKU0pHoDB9HKouiTeWG4tfXZJ4 W/YaIFVI0G50hL3ANVVIFMhNNeT0RSzrB34/wTYgDc+6oSy1KyeOzRoVIJbOVzw= X-Gm-Gg: ASbGncsmCjJFW8KIEzcMSpM9RsyFrxf6d5sBFhSBUPFfCpGYr1zd+v25Yh3UFAUoXgv Q8YgVb6RGdriWK1/QAmpKme36QI3xjKJmV5BcfIKcu3eluvDPfHw8j0tfMHXwVVzg+yRVjxflUT BYd2t1qlAVrOUHq3Z72qjqtcN1Va73VTav5UOVOxxL3iF7W4CBoRVhgZ1ArLBg4JIJLQeDjRxEw qirTcHoSEh8YC00k5fkDpYEMyO1YGvd2/X7YWF5ZmZJ/vYVc5d4p9ZyrLD9dHbxcnj7xdoiwEig wtAtL2K5r3rVTAPTcDyyVdIDHVwhUsLZHwXc3xOZfwJRql92ZzBUN88= X-Google-Smtp-Source: AGHT+IHyOsiVqCAtnNa8Q481eo/B2M8Ztab6qXUkekooWXnznAT6Se1XFkIj6MwCVgjL4f2KC2DyyQ== X-Received: by 2002:a05:622a:4108:b0:469:715:d94c with SMTP id d75a77b69052e-46fd0a123abmr298052801cf.6.1738572735411; Mon, 03 Feb 2025 00:52:15 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:52:14 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 14/17] ACPI: RISC-V: Add RPMI System MSI to GSI mapping Date: Mon, 3 Feb 2025 14:19:03 +0530 Message-ID: <20250203084906.681418-15-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005216_860321_628D0EE3 X-CRM114-Status: GOOD ( 13.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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Sunil V L The RPMI System MSI device will provide GSIs to downstream devices (such as GED) so add it to the RISC-V GSI to fwnode mapping. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- arch/riscv/include/asm/irq.h | 1 + drivers/acpi/riscv/irq.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 7b038f3b7cb0..144f97189112 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -30,6 +30,7 @@ enum riscv_irqchip_type { ACPI_RISCV_IRQCHIP_IMSIC = 0x01, ACPI_RISCV_IRQCHIP_PLIC = 0x02, ACPI_RISCV_IRQCHIP_APLIC = 0x03, + ACPI_RISCV_IRQCHIP_SMSI = 0x04, }; int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index cced960c2aef..c141975c62b3 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -129,6 +129,36 @@ static int __init riscv_acpi_register_ext_intc(u32 gsi_base, u32 nr_irqs, u32 nr return 0; } +static acpi_status __init riscv_acpi_create_gsi_map_smsi(acpi_handle handle, u32 level, + void *context, void **return_value) +{ + acpi_status status; + u64 gbase; + + if (!acpi_has_method(handle, "_GSB")) { + acpi_handle_err(handle, "_GSB method not found\n"); + return AE_ERROR; + } + + status = acpi_evaluate_integer(handle, "_GSB", NULL, &gbase); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to evaluate _GSB method\n"); + return status; + } + + /* + * TODO - find out number of interrupts from ACPI method + */ + riscv_acpi_register_ext_intc(gbase, 4, 0, 0, ACPI_RISCV_IRQCHIP_SMSI); + status = riscv_acpi_update_gsi_handle((u32)gbase, handle); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to find the GSI mapping entry\n"); + return status; + } + + return AE_OK; +} + static acpi_status __init riscv_acpi_create_gsi_map(acpi_handle handle, u32 level, void *context, void **return_value) { @@ -183,6 +213,9 @@ void __init riscv_acpi_init_gsi_mapping(void) if (acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, riscv_acpi_aplic_parse_madt, 0) > 0) acpi_get_devices("RSCV0002", riscv_acpi_create_gsi_map, NULL, NULL); + + /* Unlike PLIC/APLIC, SYSMSI doesn't have MADT */ + acpi_get_devices("RSCV0006", riscv_acpi_create_gsi_map_smsi, NULL, NULL); } static acpi_handle riscv_acpi_get_gsi_handle(u32 gsi) From patchwork Mon Feb 3 08:49:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957178 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 5776CC02197 for ; Mon, 3 Feb 2025 10:00:58 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=orwM/xYthxJLGjwqL1MpWEDVyNZ5gF35B4haGLCteNA=; b=FseTAHDlqGdaCL yDp1HeAHqBQRWC1lBzADddEHLtoX4nt01OENy8CkvIPgQsn0KFba2IBP8g67orP9GzbQwsDbrx02W tAkYhX/xs18tiOsoKasiUZdM1k1x7MjRMsX/uXwGztZgO+urK5SwjyEdRk79x5QGeZyZjNjv/w55j pLtGK/oboHsD0e8VvSyljqD5drRtNKcyShE52kbPshqL8MRsONWxd0JYnMkCX2R8b5Z/Oy3bv4G62 Lv/417RRwSYX9x6yx5unY0EvBAD0rM4hAYklp5NN+ezW9yXVAg7/iXti9BtXvXM5pOQTcP4atCV8B 9x5OBmkL1rEMSvMvDLlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tetG9-0000000F3ym-0imy; Mon, 03 Feb 2025 10:00:53 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesC0-0000000EumT-1k47 for linux-riscv@bombadil.infradead.org; Mon, 03 Feb 2025 08:52:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=gfhx+B7bNZPEhRIXiDYGdJlXqpYXlIrkdnjsDcgJm/w=; b=CSh2CAfpXwb5ULgt54bfyOccb5 jZfTwYtNzijA5nuLdJwUCsD//0pDuhHzbYCrfeEqWBX/5dmSmOidECtQ2nu3iHonrwk+px1MOTXEU rLD3Jp79nOgG0UXPghN6s4gRFsFn43pZN9ASBJwhHs/50VTDFmVMg/jNmtp1TQGAXSED52bEmU4WF mXifH93L3ciNYLMZHH7wtqC0iMUZHrUotztLiHPpbIFjWWBzQ6Ofv4LaXR6IsG5ikzJ8PBxr50SE1 Lh0BRD2dX9DhlNDvnYyO45WnG13QRPqGuBzYvr/Wc3IDrZ3S/ljXj0qU6Kf8jcpSbL3f2nZwVFKXB IFNGWMbg==; Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesBx-0000000G15G-2AFu for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:52:31 +0000 Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-467a1d43821so47869221cf.1 for ; Mon, 03 Feb 2025 00:52:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572747; x=1739177547; 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=gfhx+B7bNZPEhRIXiDYGdJlXqpYXlIrkdnjsDcgJm/w=; b=ZnzKXYCXwxbym6xOt6vH2SuCvZfWZJXYWieyiAgLXfFqImKLc58tM42yL3Sdi0GgWd ejeoeKEcqNfHgZRZcSCWTfLwR4FuOG4EK6KnsI0o57svPbzU6VSWCmfVPYThmnX4r5AL GGxTHqP8CRRzx+HkaNiCTTz2JLju1qgYmaFOrdCVyxfNANTiXPu45NU9VurCBTC5DrDR yHEfbNvv0dh+3ggLhvbhT7ewS2UsxiXw3OP4qfcAREIh1qNa9RwrcMSr9fHy5kFedu2h 1lgCFRfHj5T3dKIRWOU6YLMrmmH30ouIrL9MErUB+mv0WZSd0BNe0F6rYRHHT04NveYf qYiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572747; x=1739177547; 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=gfhx+B7bNZPEhRIXiDYGdJlXqpYXlIrkdnjsDcgJm/w=; b=MO2/dS7m9R2foYDfYcgnG5JlrjtWk0aK0qfAYMqUiuOn2jDbq9riEymz7Gr1POquBz srfB1Res9DyjolVByyGjnhjTw0T1JTwdtdvumsVNFaXUYwc9fIHe+OaIABi95A/O6KFc ydPnrI7r1V3y7Zh6WTiNJdxiLIW4rEngSb0nS52/dFcKNxThpASnKQyBjDLXH34axx+Q AFnvhJFsLd9qzTJAwkxb7EZD1XWmtjSMMIqhbbV4SWmKRvsQXhD22jDJgf6A/p7NqC1e +Mumg3KaUb4uDZgOXI4yQ/6ZngnZTS5HjRO0i58uCEnKNs10txvPT6KSqk4a/2CYxzCK HuDw== X-Forwarded-Encrypted: i=1; AJvYcCUynUccXDWvrlAZO8xCw++dhYHVRTQG/bmj35C4yyA9kUX6TfyEUNT3qJkFPnVweFrZAZMmWwEmuMKmKg==@lists.infradead.org X-Gm-Message-State: AOJu0YxR8e9ua7GFIpl2SdB/FbRKZfMCkjNZHtSaTPmQ7vVs2/glvWI6 lTy+6bSM6aMmLtXHRiW83A8nUPuhWwXGxeJ8Cs4L/nWrxSwbQ4hNSBzpjccnpog= X-Gm-Gg: ASbGncsHF77Dstz4kfxJjENgk7ayZatNumzkwusbyClqrvkoBeypEmV8gHEm8+pJ3/g BGjhHbEwZo+jCfYeaqUUGSoaficNWinK8sDE3rZ+3SpzcBKE66rODZvWM7O9MJx5bl8VIv8hCl9 NC1T7ZoOOYMvdfyXPU7JuGRIVfSueQtJGDf+qaKLQgUQm0ixx4aQe9S5UvL72tjN56RnpbSxgpJ Be16NXI4lfm54fECl7lIAEEWhklgAv2+Dzdd1WJBYy9O0d8uLuKoAkVodSdYr5ZOdnIxyaGzucX SJMzt1df3xJ8MfjexX9JgzjuSrtzxIjl/KyiAsNhOPMjZM0tR3awQk0= X-Google-Smtp-Source: AGHT+IEPC0fQonm+ZMRdOw/pHD+LkJDG4oWSy8Qrtuwi5pVXg6DvO84+wFFDLfBj5S0Srs5BOrRNug== X-Received: by 2002:ac8:5990:0:b0:467:7076:37c7 with SMTP id d75a77b69052e-46fea10ace0mr175509171cf.22.1738572747168; Mon, 03 Feb 2025 00:52:27 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:52:26 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 15/17] mailbox/riscv-sbi-mpxy: Add ACPI support Date: Mon, 3 Feb 2025 14:19:04 +0530 Message-ID: <20250203084906.681418-16-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_085229_731092_97F1286B X-CRM114-Status: GOOD ( 17.29 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Sunil V L Add ACPI support for the RISC-V SBI message proxy (MPXY) based mailbox driver. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/mailbox/riscv-sbi-mpxy-mbox.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/riscv-sbi-mpxy-mbox.c b/drivers/mailbox/riscv-sbi-mpxy-mbox.c index 4021f62ff487..0ce89970c5bd 100644 --- a/drivers/mailbox/riscv-sbi-mpxy-mbox.c +++ b/drivers/mailbox/riscv-sbi-mpxy-mbox.c @@ -5,6 +5,7 @@ * Copyright (C) 2024 Ventana Micro Systems Inc. */ +#include #include #include #include @@ -12,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -924,8 +926,16 @@ static int mpxy_mbox_probe(struct platform_device *pdev) * then we need to set it explicitly before using any platform * MSI functions. */ - if (is_of_node(dev->fwnode)) + if (is_of_node(dev->fwnode)) { of_msi_configure(dev, to_of_node(dev->fwnode)); + } else { + struct irq_domain *msi_domain; + + msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + if (msi_domain) + dev_set_msi_domain(dev, msi_domain); + } } /* Setup MSIs for mailbox (if required) */ @@ -970,6 +980,10 @@ static int mpxy_mbox_probe(struct platform_device *pdev) return rc; } +#ifdef CONFIG_ACPI + if (!acpi_disabled) + acpi_dev_clear_dependencies(ACPI_COMPANION(dev)); +#endif dev_info(dev, "mailbox registered with %d channels\n", mbox->channel_count); return 0; @@ -989,10 +1003,19 @@ static const struct of_device_id mpxy_mbox_of_match[] = { }; MODULE_DEVICE_TABLE(of, mpxy_mbox_of_match); +#ifdef CONFIG_ACPI +static const struct acpi_device_id mpxy_mbox_acpi_match[] = { + { "RSCV0005", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, mpxy_mbox_acpi_match); +#endif + static struct platform_driver mpxy_mbox_driver = { .driver = { .name = "riscv-sbi-mpxy-mbox", .of_match_table = mpxy_mbox_of_match, + .acpi_match_table = ACPI_PTR(mpxy_mbox_acpi_match), }, .probe = mpxy_mbox_probe, .remove = mpxy_mbox_remove, From patchwork Mon Feb 3 08:49:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957050 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 E4D15C02195 for ; Mon, 3 Feb 2025 08:52:45 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=APB0al3fEhGNhLIhBvu/Kxax8EvWWLOVQ6GGAFJBjNI=; b=Zb1EOnc5o6SlGN g1+7zY7Hr9uiwIgYmsD5pPvFIHFepwoBrhJKmF+Y1zVy7+K9lR/vbI9bGYhE+J4bJUqDsKaYGVSS9 lKyyaBmzGORhL5LekKJNd8sA4Fy6BuJLWs6WV8KNXr8mE3WB70n2ya53sD5hfbOpu4SA83+MkooSS oV/iz88yHazzcVM0plmPjNQIzr7m1eu90h0ht0WbJKCdeVwZ56vdX295iA8rcYOjDIwgZ1uNsj8qk 6OTghVNzGSiDdlf3qfB4/ZN/apFm/y/1wWVzxNwhGkNCReAXLgcum+zk0Xt3hEq8Itxs6caKrrD9y iND0U+pUrbYOfnjvIkqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tesC9-0000000Eup1-2DPi; Mon, 03 Feb 2025 08:52:41 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesC8-0000000Euoa-02ZG for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:52:41 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-46c8474d8daso30064591cf.3 for ; Mon, 03 Feb 2025 00:52:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572759; x=1739177559; 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=bMc6tRRbVVjIuFrimhD5cbba2O5fSdoBYlM+WudqAOg=; b=E4cLqZJm+OqcNMoMPyex9eXvLZvxX8QoSE0shPjBO6VaTX68A/YJ6dt0yXI918qteo 7rCibIQ5b9wH/dlgSCGiSKegucGUJbD7Gx3X5Nd/JAF6CScbmc1pLEv4VL27oC9v98Fc E5Pa1Qnp79vxOa/vMFaIxrnFii8CBK9xyfw6ZSNB1HtxMFuKwKcd3uQVZCkQaa4/Dv67 E87+UDQeMexHo1/cWKDq3KALNbvBQBZsAbJfI25NYTxKMZrrwE5hMHS/0/1T/t5SIfj2 AcoMrKUVKV9F9pVZer4camH5X3bBfFJjGo/1DGYbWh3NZukgazf6Bnk8u+QJNkjKtXCg Oj3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572759; x=1739177559; 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=bMc6tRRbVVjIuFrimhD5cbba2O5fSdoBYlM+WudqAOg=; b=L+tHtljQrRyfeqPn4skrFwoloXbdzXPNscgCL5efHNXK6fsNqey0OGo5mytfbk2u/X xTcR9Eky5nUdY5kwcsBbozo2jA499A6txPJvWtHHhaL2ofGxJNZkPkxit/YD4gEzADfJ k8y7wag/XjDbNMgo6O2QXBuGkN2E6XeS27OsbP2XrTC5UFGPR85nxrGkEp2J39VkwXrw kAS07PmUosiRKgrMSze5qtsAMxP1QbauoEAQnWSaALgIxeesG6+LwgVoVx50eiL4d95U wc9sddG7AHcGDXANvr/hdd405052Fo/YemJbWSUHHJkMPr+YxGpMe+vQHeXAVvl51GO/ cYtg== X-Forwarded-Encrypted: i=1; AJvYcCWar1BXRUj8lKks1XkLphTgUWU1nyigw6+J4QKpSwPP5xvbsCyfj7CXJs4pRrSjHrftLXrxNx5RgiozkQ==@lists.infradead.org X-Gm-Message-State: AOJu0YyC+dehaGCEVIKzE6POCxDaADyhTTdTCng56+cbUQg9m0ecRbIm YaPT7dLpg6SvCYgDT+oOoZ6AAbUOpQxkkDs8+Qs09WOzACwzGIO/rTeHrcRzzbo= X-Gm-Gg: ASbGncugztGMt+ed8VLYZkaOBkQoeC5SdMgAxFNYYK2Myj7ET0vNCW3CUlBNQU2GegY XeOioaG+MebSovdl1Jx6M6F5k7JYhsMPRpvWuS2AoUu+MiPH2A6mYwXZbbAjpXDGAlfYgnCmacO sHHXkMFRqwHruk4qBtdatRSDTqVN/CLzy6LT8x0CqtXZ7OjTRzRekAJwhGnBuKROe0RbdIazUy4 5q4B4PmCOeDMqga6Kv9pyEwv+EC+89h7B9e/yeBZ25GXvFaNCapGoQPxgagLPi6YWeqjD3p7CRR jF5SYZOqwkkbFRjaNKTe/q5vk6K1fL6M4rnjt02jIXv+s/BpClsCUXs= X-Google-Smtp-Source: AGHT+IFAdiGU/iUBycYCxgRM5DsqzJFg3ES5gi2sqFYcXQtsQPK6UBgEZ5OP+FdlHA0Q+Cdlc8Fv6A== X-Received: by 2002:a05:622a:134e:b0:46c:7152:317e with SMTP id d75a77b69052e-46fd0b753famr297039461cf.42.1738572758960; Mon, 03 Feb 2025 00:52:38 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:52:38 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 16/17] irqchip/riscv-rpmi-sysmsi: Add ACPI support Date: Mon, 3 Feb 2025 14:19:05 +0530 Message-ID: <20250203084906.681418-17-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005240_053700_1E686D01 X-CRM114-Status: GOOD ( 20.61 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Sunil V L Add ACPI support for the RISC-V RPMI system MSI based irqchip driver. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 2 +- drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 34 ++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 2ae44354735b..cf96382113ce 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -599,7 +599,7 @@ config RISCV_IMSIC_PCI config RISCV_RPMI_SYSMSI bool - depends on MAILBOX + depends on RISCV && MAILBOX select IRQ_DOMAIN_HIERARCHY select GENERIC_MSI_IRQ default RISCV diff --git a/drivers/irqchip/irq-riscv-rpmi-sysmsi.c b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c index 3022f0924c94..1f03241920bb 100644 --- a/drivers/irqchip/irq-riscv-rpmi-sysmsi.c +++ b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -215,6 +216,7 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct rpmi_sysmsi_priv *priv; + u32 id; int rc; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -223,6 +225,15 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev) priv->dev = dev; platform_set_drvdata(pdev, priv); + if (!is_of_node(dev->fwnode)) { + rc = riscv_acpi_get_gsi_info(dev->fwnode, &priv->gsi_base, &id, + &priv->nr_irqs, NULL); + if (rc) { + dev_err(dev, "failed to find GSI mapping\n"); + return rc; + } + } + /* Setup mailbox client */ priv->client.dev = priv->dev; priv->client.rx_callback = NULL; @@ -252,8 +263,16 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev) * then we need to set it explicitly before using any platform * MSI functions. */ - if (is_of_node(dev->fwnode)) + if (is_of_node(dev->fwnode)) { of_msi_configure(dev, to_of_node(dev->fwnode)); + } else { + struct irq_domain *msi_domain; + + msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + if (msi_domain) + dev_set_msi_domain(dev, msi_domain); + } if (!dev_get_msi_domain(dev)) return -EPROBE_DEFER; @@ -264,6 +283,10 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev) priv->nr_irqs, priv, priv)) return dev_err_probe(dev, -ENOMEM, "failed to create MSI irq domain\n"); +#ifdef CONFIG_ACPI + if (!acpi_disabled) + acpi_dev_clear_dependencies(ACPI_COMPANION(dev)); +#endif dev_info(dev, "%d system MSIs registered\n", priv->nr_irqs); return 0; } @@ -273,10 +296,19 @@ static const struct of_device_id rpmi_sysmsi_match[] = { {} }; +#ifdef CONFIG_ACPI +static const struct acpi_device_id acpi_rpmi_sysmsi_match[] = { + { "RSCV0006", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, acpi_rpmi_sysmsi_match); +#endif + static struct platform_driver rpmi_sysmsi_driver = { .driver = { .name = "rpmi-sysmsi", .of_match_table = rpmi_sysmsi_match, + .acpi_match_table = ACPI_PTR(acpi_rpmi_sysmsi_match), }, .probe = rpmi_sysmsi_probe, }; From patchwork Mon Feb 3 08:49:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13957179 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 28101C0219C for ; Mon, 3 Feb 2025 10:00:59 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qlPZT3/nwFa6O9Qw84GV3kTrGIpE7oTjsk9v7DTnRq4=; b=ER25fl8REi10Ml EqsdcZkTYhwGEfahXlYb7Sw9TS0A9b20XLdWWE6SImepO27S4sNLbE04WyTXMqFPwNWjKJDILnb5L +CKW72e18ebw2SvTB+/5wgxKyxT4w79TTbnwE2AyBq6KvwxblE0qiTBD5jDpbfL05gbr+de4Vcg0z elxmgvDH/H/aykjVi3K8CN5OgCimegSDIFCPqHwTmiqeE32XrEyHIJ8ypPgd5dxp+B4e+7TeIVkUs nx+/+tFu13KdMsX+4gEKZXlzNb5a8bh3j/G1DDloJ2qoyOOGLZAe7MfM8LFDqpgbB8KwRB3/t+e0U Vc//PSqfQLSrnxHvI9BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tetG9-0000000F3zr-3V7l; Mon, 03 Feb 2025 10:00:53 +0000 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tesCK-0000000Eurp-2lLR for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 08:52:53 +0000 Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-46783d44db0so38916961cf.1 for ; Mon, 03 Feb 2025 00:52:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572771; x=1739177571; 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=lrS6UZq8voK5d6I6M8hMOQP+PQdCTVat6aZNVhGKd/U=; b=FhA53F0TznAV1o3hcHosWIm3wBFSwaU2GNPbZRB8gfZ0lc3mMUKa0Nla+H3GM3zXSy XE1yHpgbJ5UItHqGW5sFFqdEC+MBwmI13tDSKe10v3YykaR/JSiO8I4PeES29J8uOUcU xaEcJ9qfGDL2q5LiYnZ8TyAdRvts8qKdnFZqfKnGu3DEhPJNZOb3sSoqiv0OGyazcKvq WRFAHLZx0ybkzej8XVhZFUT3nQm28FeBHyrkGtPr3CRpwWKNkvmAgHRs07SaVLiGKbvl aR1PPB2S3wZ2cDrLhI/u5Hi08+ABMi6ytquiRG+UEjAjFguSoxIg1EnXp5vBLyUK9rNu s9fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738572771; x=1739177571; 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=lrS6UZq8voK5d6I6M8hMOQP+PQdCTVat6aZNVhGKd/U=; b=nKdjRms8ftscVCxOa0m3jIjI7pIoUNJiJfxzWEDbG38ZlE/M5fixvnNAjNuluaBPZv HVx/GlzcOuXgmFePpfm1pmVS4shl0L5vHUM4X04rAvWWi6NYaiq/37Y7xtaWpVqZWGHO HtYroioZGm0ajXeiFK49MWKoUWNwCDqEvHaBEnV6c1kYRb4GCnRe0AjmGW100T/Nqzku F0+mLHEDnst5/FgBZ8UJ4KgX4Cu9OuiNwRNZcSrhtusxfx8yHKeMkUDILal5lazVRITI GoFxoR6ULTKEtFhdQtURaglmVCfbNQV5ZJm8RosEi8C3EUO528XLJvngf9Ey4vIPSNy7 N6UA== X-Forwarded-Encrypted: i=1; AJvYcCXJf3n17NljMwNh7uW80MjkVdcba/sqS7Umo1n0MRG8eouTxRJZ6qkRrwmYBa8AHD1JQU92rUEYVWMNJA==@lists.infradead.org X-Gm-Message-State: AOJu0YwEwfPX6F8QFkTsegVyBdAXPTyzmkx6yFsA5CIjKSuRU96gsUXL A5LKqxEAkjW6sseCi9UUivDLOyNj+/vVjpSHrzZEYIeEmnuPw2G+I0q92WXNIeE= X-Gm-Gg: ASbGncvGE1OIpfcXID18n+dbv6jUuaxA/pTNJvn8YmhAwgnNKGn1CJQkFRTnlOLE0TK NPrs8/ar+6ue/E63sP3ro5SY6snlnRsZz5frZ5Lm3dP4YAon8iO6HJ9ED4ckfzy9ww0EKvj70VE 3SdnbeOjAabSOpTe0DmmpRKwsuGvKdTZT5X0DoZo3RrcDMlQlJkZ2sNCUSucDZKAUr9VoPwueYe Vb71JULXZ8M+ObWdmDGVYPXzSzz0hOUuJFLUJh8Wcaq9jijvqH/f51c2dWyyKIaHu1p/okxmfZU +O1/cg7/e1/aN3xttgohARoVmwj3Bb/giu8DqijS0k5owa9NQiwnFs0= X-Google-Smtp-Source: AGHT+IHCJxve5T10aPiQPDTrvWu69tjDV21FWaMmTfndSVMbeYY2fptctuonpJUVJro58XKkYYFZeQ== X-Received: by 2002:ac8:5f8f:0:b0:467:672a:abb6 with SMTP id d75a77b69052e-46fd0acbcebmr285604751cf.23.1738572771412; Mon, 03 Feb 2025 00:52:51 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0e3089sm47657911cf.46.2025.02.03.00.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 00:52:50 -0800 (PST) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [RFC PATCH v2 17/17] RISC-V: Enable GPIO keyboard and event device in RV64 defconfig Date: Mon, 3 Feb 2025 14:19:06 +0530 Message-ID: <20250203084906.681418-18-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250203084906.681418-1-apatel@ventanamicro.com> References: <20250203084906.681418-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_005252_695868_4A71F63C X-CRM114-Status: UNSURE ( 9.39 ) 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: , Cc: Anup Patel , devicetree@vger.kernel.org, Andrew Jones , Leyfoon Tan , Anup Patel , Atish Patra , linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Len Brown , linux-clk@vger.kernel.org, Rahul Pathak Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The GPIO keyboard and event device can be used to receive graceful shutdown or reboot input keys so let us enable it by default for RV64 (just like ARM64). Signed-off-by: Anup Patel --- arch/riscv/configs/defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index 0f7dcbe3c45b..06265b6febba 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -142,6 +142,8 @@ CONFIG_MICREL_PHY=y CONFIG_MICROSEMI_PHY=y CONFIG_MOTORCOMM_PHY=y CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_EVDEV=y +CONFIG_KEYBOARD_GPIO=y CONFIG_KEYBOARD_SUN4I_LRADC=m CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y