From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E30A17BD3 for ; Mon, 3 Feb 2025 08:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572581; cv=none; b=DzC7HuxPbMrwJZ0ubwNhleNMt2Y3GoduNX+VF2IGzOp3Z2kq3Guuwxpy5RVbVqwIRJARiziebenGHfIhkJytNn2vyyNF/Zt4SEJvVWIeDmQVUOhyQuXYK2T5uN/138JYkDX4FHzQYD1UBeVQ11N8UqqyBHkLY48asPzjxJ12G7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572581; c=relaxed/simple; bh=kwBh8tuwy6HyveKbcfC341s6VUevxlvDE+A5AE+gDro=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SS/Wj4rPxNh7VR4K58nlgHdNGs4OxQyBfD7wdPrUbfVV5z455ouYfixNsMxwTEQLraPwnEcB6FRoUWTQwkPkgRPWMNXu9LvNJaAIdYGZ0owf4AID7rLU1Ed0w/TF2w6bPOq68l1lOAm2b78Rs1p80yfIwTScIpRw/zociEIx4sQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=kh48cjM+; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="kh48cjM+" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-4678cce3d60so42824141cf.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=vger.kernel.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=kh48cjM+02rnabzQAlZPjhErOBpuDsca/8rncBDf4LfzMmC97S9QeBy+YCsy0WU/sv 38WzuUKR5L6AjaL1ejgXbOe5fDN1gMJP4wQiVFOxNfPIyiR2qp9QtzV9DVbCmIIDvwc7 YYohCbI83akMvIoID5O6K3tJKabB0CpRISKQWJJhygPWOBVhxrWmegEUx9qvZzPi7oHD h/pOK1Dq2gmws1JKlfehd3kb5BE4fs6IXCFqTaqGubiazb+DzxD/qPM4TUfFPV5nK1Zt aXdmfE4O8oQKyrtRtePpe3p8R+7JTcxhEBIlTwPmdZfLFWKSiqEPn4/lYM4GaD4vKYKq In3A== 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=IEfjCEPCJZ0iQ/HbUNf73cC2sJ/dFfxFZfLXL5uADm7DgEWKZF7xoI0KZ5YpoBqQ0K 1CdeiG+rOOvBEEHSj5Se7yWxn34w9kJ7COpUlEIE369vvjzr0K0ByxFliJBsB6R1rD7K 7RxelTQnh3gvr57srFyCLBrltFbIjZZ8V7bcQBheqo2Et4tDx29nRrd4Db7W9TbyPJLH ts33S4N2Mqal3KsDucr4sk4QhcIZHC4k19V6RvQxJu5Hr8XVibIk8i6Ojxf5ghxYUMWX amPKPhr7Ffqvd3i8eVI3sTVDBCodE2R03DIjr09GUKpUGbvjFcoqlAXnNJHxUmYki6f7 HNmA== X-Forwarded-Encrypted: i=1; AJvYcCVfCm56S86ff8Rj69t29jgHuZZXxPsRXEp68aIFgfoX/fBbyoScAgdhvL9P+saN9hizXciTEZtK9raGF+g=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4xPuizlBfbDV9rmi4qZDIEMwmGOsA3wWti4QARUSiSrKg9jBH moFNjSn8YlOn7y7gpGKPib5xH8BomaI+9w4v3ErMEWsZr5wQOpLnhfjwHwFYyqk= X-Gm-Gg: ASbGncscqhwubtqERNaESXt2No2FtBpMJl+0Okj/rUhd8nVqlPFUiQi+wZlDxmTnpwT OIln33K0c9oFBezUaipW+LnQYqTEi/+H53uEhHRPrjdSeZGr1+YDLnhF1lE3TSP8sRLaFgydNWM LnIkIARYF2hiv9setGJUFf51NpG6tC/6HWbaxgPWQZHQtB4L1PbxTew6YHm8uRrmqp1OSPEho7L bnl0IQi2uB7S9WDH/0SWk32WG9aToa9Rehe0IJM2Xmz0jze+ggAk/En2o+UkEKeIwTAuttHTvh6 Er4K8xWQAdHnSFa3I1A5bx6cpsKcXoc4e0jMiLlT9HPJuy+wLkRXpvs= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 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: --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D0651FCCFB for ; Mon, 3 Feb 2025 08:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572593; cv=none; b=ZunAfCrEDuHL9uA2yILrQ0eDUdmtKsc6qSyEIO15Bu8hijgNTquGQfksCVVuoxne5A0gFUrZsYSbrS7RjVEqBtUyVipv6TgW+zjnOubjvfHrXHaTMuatCOaZV0aFH4DyOoRKGVoyFjw6dtwg7g+wTheyA2YP2KKLrO0Jp4U6Oys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572593; c=relaxed/simple; bh=r+JxCWQ+jyLorjrIiBewIuh3h00Bk6D4rc4yzMNvnkg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KeSUQEMRGiLZchTUiZinFaqG2DBlHdmLRNu/QQjcXtqfLGI94QXA5ehlxNrr0t85Eo3peGIdLjUFdNdYStHK2ursS+Bm2Gkhixyix9+cb+heRBWVu1sTsv3M8qfHHdWiuTJNasPmz+MKSlDULQeWwsBOx6GwgsUnDeZEpxeCDn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=fgW8L/rU; arc=none smtp.client-ip=209.85.160.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="fgW8L/rU" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-46fa7678ef3so39862351cf.1 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=vger.kernel.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=fgW8L/rUPNZjf4RkvujjIbTBFcqb/n08Py7O7Va+lz0ozFRjHU7iiEOwT9BOv79eix 2Z8N4O4u5odf6LATjerfMP5vxsfFzu+jX46BP+phBtQ01P6rNjZK7QxSgcRcKThvNR9P rgtvSYu7DuMCGqSjHNXtQS1yluNhKjUqePYMmV63eD9BuG8IuoAznY7hYwZrKVIHgXGQ KBt8f0SWK0VjrpGfXULHQ74a24UGJ3byT/3Y6o+Zt5ny3j9EqAEPs8FvHTN8mv1Rm2s0 ZvLfIsq969n3IMnEJmwGPuhmlvXUCX95p8/B3cZC9OPxJYk2+o5N5k7DgStyADCP6h6F EsSg== 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=px4DjhgK5cO2QUIK0VGPwbIihNvLW9uL5q9Ng5me9waF6MvvLBTc6ncqMDsZtEyo2i kFBciO2O7HcJP0J5w7E0fTbu+AusPRypTcdFX4Z2KaqevQus59z4xVU4Kh1CHTb5lQp2 BusRhBpOFnnJNTCsSVD0Lj5z5bKbtPZAkYqZpIcerVDrdFVRr1sHS7fYJHsrnMrove1Z FoHQ2V4DQ154/aALXW8mwVPA76gXPwY0xoFW1s98TuaeA9wTIxVJsJ6gyimXbpP8krmp wxdVQqhjQoCeMs1DZgqNO4ss6gKqx9FVDMPQev45n3pRmZnVtGv9ZoNPdciKOvsbqf1a LwAQ== X-Forwarded-Encrypted: i=1; AJvYcCVWe2kfybCZ6Ll6wVl7pbLubB+hcXKiL1OqVVSQ61ap8HP1bBptZHDNz5GuT4lhD8aX7+2GsJhoCCfj/Aw=@vger.kernel.org X-Gm-Message-State: AOJu0YzbOL4/bouAFZ2Re21dgMTsbeTKH5TxVrBT+KzmXEAxax8DiQLO FBMwMMqjcB5LMz65wTqx7ZIOTrJTaURnfr4/K4Vk53NimbuYo3eHUosDT9JINAE= X-Gm-Gg: ASbGncvSADbvnnu/dRxOsGL2TZqQ+i1rraX6ZDaGTscemk/zSdUn7Paah+iei3XSW6s /j6SDEXDo/EmxmLMbZnCbsrs2lauW8llzCiMpIRmHjANmN/bfrTu1MTSVLrFHX5aF9CVIqQWNIf ilMsCBIIcYRiHBq+7CK+foeYYAg4UejaU1sLzvva2TDOhU14FONJxrOLTy5yp3bpOLO8y8HeR9/ gpxSbxHsz+eYGWc5GdTi2C5mxhKa0uBPrA/I6gdCXNj1AdaWXQ5BDnlauCQ4vhOoCdbXj8+AwuY ITO0IoJvEkc67RM2h1hgQ0pAruk/Z7EIwLydRQKNjBNNTVj93aWvT2g= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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-sh= mem-mbox.yaml diff --git a/Documentation/devicetree/bindings/mailbox/riscv,rpmi-shmem-mbo= x.yaml b/Documentation/devicetree/bindings/mailbox/riscv,rpmi-shmem-mbox.ya= ml 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 sha= red + memory based RPMI transport. This RPMI shared memory transport integrate= s as + mailbox controller in the SBI implementation or supervisor software wher= eas + each RPMI service group is mailbox client in the SBI implementation and + supervisor software. + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + References + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + [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 th= is + 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 bi= t). + + 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 =3D "riscv,rpmi-shmem-mbox"; + reg =3D <0x10080000 0x10000>, + <0x10090000 0x10000>, + <0x100a0000 0x4>; + reg-names =3D "a2p-req", "p2a-ack", "doorbell"; + msi-parent =3D <&imsic_mlevel>; + riscv,slot-size =3D <64>; + #mbox-cells =3D <1>; + }; + - | + // Example 2 (RPMI shared memory with only 4 queues): + mailbox@10001000 { + compatible =3D "riscv,rpmi-shmem-mbox"; + reg =3D <0x10001000 0x800>, + <0x10001800 0x800>, + <0x10002000 0x800>, + <0x10002800 0x800>, + <0x10003000 0x4>; + reg-names =3D "a2p-req", "p2a-ack", "p2a-req", "a2p-ack", "doorbel= l"; + msi-parent =3D <&imsic_mlevel>; + riscv,slot-size =3D <64>; + riscv,doorbell-mask =3D <0x00008000>; + riscv,doorbell-value =3D <0x00008000>; + #mbox-cells =3D <1>; + }; --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73C521FC7E5 for ; Mon, 3 Feb 2025 08:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572605; cv=none; b=lAzy67PhCQhtagpFGyGAPuHU02d1QggRyQRANndMwD23R0Ck1qIMCL9Qt8G/DZfEiylz1FoHNHDNiMK3uXfMJehTeSpL94J8k5UiKVKWE2UIQzYiYfsE2zr+vpLqKjAyQJK3xAd2YoENEbmRhExYBJGsuxmVIpH3+vJ0ADyhS/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572605; c=relaxed/simple; bh=QiMGpDjHJVbEJ7WtU+aAmU5WmhVGH1iQ/fXC0sMtGgc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fSWhEcZj+22K6pImuJD3ZLwB1XOyDytnnwRhSe8XcMH/vPGR8odTwPkw8oJ1MkORvApY37mYl9v89ChdY6KAzWICl6xP6oOBv1mBzlsTmQboUGonTqf09P2qqVOKTZZ2wzfZwauaw59d4l0CXJzGjNyvnqeXsNAAGi+K8bzqGd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=HEKQwqUg; arc=none smtp.client-ip=209.85.160.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="HEKQwqUg" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-4679eacf25cso26954431cf.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=vger.kernel.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=HEKQwqUgZdXjfzfNgrR+BXnA5UxePw+MHAYyIwDuBdXZyLIwl0OyTQFJ4OOdBGLmDG 2pdwNm8izip6EBPh40HaU/Pr8QlcH+z9NSPf+im5LeLPeuB2nYqWaMyEd7Ws6iLAoWaH UE3XGhKsg1LIFN3ZsWUOdwoUH4I7zKywNXN+V02eb4gUbr+r25lgbuC1m12OHcAsE4dv B1K5NyUFhpmCvFUhQNzS6VkI96lVTgX/sHvQPLPColhfBJMu72cYDJ/rSO2HfTWoMm/r PU8f9zTEKQVrjDgAJ+NP8taHuMF6DqjXChDSBV8x5YxW/KW8lFy/YHIRuLdQ/owRKEP+ Czwg== 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=ul29L7nPnaPPT6/YxYy0JdVk2g/0hmGaU7A+HuiS1fFlxlRHNvDnt3XeFT1t4izO/D vdbAhs+iAwA85sMOm8EZDoFCNQyRZ1QWqh+wKrlc/V9SC9cOG9GURIKE/tSkppzmpsrr Y05lIoXoq8gd3OgOzWJ/iooRLptyHwsU1uhu9hYK0ZD/Tz2aYo9CblEr7fE/5ffDwoYL Y2ve6On1Yge4C11ejhCKyUkOH2EURQM3iPAO24SAXhVNwqAP8spK0beyo1JA/biATjQs KIvCmqArEeYF4lE2fBRJLiQckrMBG249oGxpFElEi3qifMmCysUixKWnCxb2rWKsHjeV aZ8A== X-Forwarded-Encrypted: i=1; AJvYcCXwM6LoB7Hjop2Xb40tlpy+SPMEIprGyPGa3RI/nBCAiW8TQbrzegoMireW9QHx/f72uJX/H3AvUCnmQoU=@vger.kernel.org X-Gm-Message-State: AOJu0YziFMx30qvTXs2zNLciwR0SK0FaMvM+fSBKtSn294v/edZna4iS Q2NRqcuxNpmFoMaTGBpl2paiLtbPyUvrhkWoStsdb7TvIpgYJLP3p2ZHlsVLsG8= X-Gm-Gg: ASbGncto5xg/Q9MBk2AdrbrrhjsUgai3K1aor2Z+Mg3JF5FPFmTFc+yJtNxjLLgKf98 4IvIGV25J0eafVvvxQW86psoFWf6qWtB+YcpaB5PyfeprSR8OB2FC5xVhJzzUyP6g9Ldrr2c1lT tXfOUievM/gRIRoeKYYPj8GoZcSAoxOgi7srDo2RSD3YPETzigsT/O+sUvqQn4J7UrUX4YMnwg9 IsafXf58qf+ku80/3odqKNA1nnxY9psmYb+qhgJ63nO4g4nxB80bhS0ZHhghtB/ooZ9bp4atkyZ 6tpAMgLlec1aBBpWVpbnOBf3QONbJ0MoCbNljAj77AHcirEna0lJ6MU= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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-mpx= y-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]). + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + References + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + [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 =3D "riscv,sbi-mpxy-mbox"; + #mbox-cells =3D <2>; + }; --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CEF41FC7D6 for ; Mon, 3 Feb 2025 08:50:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572616; cv=none; b=oRqM6U7o5XKRzhINRrChQo5oSinhuE0hEmh4+WxgOqP+1w0wyjDae2B0HmP6wL1V34/+hQhv9kI+ZIg2GMptwJ8rl6A1VEBSHAd1NRm64mUZoUODkXn9SR40A18Z7mUX0a8TGL7QUgMmujiPHQjg576Svcc0+9GyC8eJx6EpXUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572616; c=relaxed/simple; bh=YMpqZIPonInsMHgzcVOEUu7z9BcpSX3NDENvMdGdBxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pbHYp6m4G2lVdcOuOm9ItVojshBkADP+V83ft1Nkx57FhLBcEWxUORD72BTTtbIPbainv+FlhtUh1S2Jvp6c1Bwg35MIH66qrP+OBUmfaUCGqKkcsSZ2vPFdVKNIocSBK5Wp4xYdh6eZIZrjKZ0IVHaynxjdEfywzyHlmc1r8WE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=nIg2SSZO; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="nIg2SSZO" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-46fa764aac2so35979861cf.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=vger.kernel.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=nIg2SSZOdo75eKmDbOKv4xsmeJ7LqtvO3Cz83tWu+QMEThdSjmmGtq8UwFFNM21UFZ CUb+BsdkB3jhlBfNcrUXUkIBjiKx9EC/uEX1FuyYj17n2EKNBRCuSNcLK7Vy0rPpCiBn 0Qsp96lwJaCtkQZeLKOGaBjswmwJHQN2BzES84IgIoZeXkPBc/IeOTflTK7qsojVV5/L Wu40bz65p2Z7QmBIZHUS5warF/ZvYyfanE7T45cD5wBd2rdw4B/4H/aztzz6Fyr7x6qR dpWyJHF914wIGNnTV2yURW8v0Q/j0xH7oc8ks7P37WPLLUteyOfalYhYCQltuNgh2S8K BnVw== 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=G4m86KFO1on/0wsmSnuPMQq31KZV8to+Gr8byPvZ1TLFLdZcezzy/xrI/8kIyu2aIb uMAXb6ASJ1ZEj5s8jdqNu/hT0Md/Wh/1mzjM6TuoFbuzQmPCbDeQLNPkO8eBUeRm/v2+ Sndgsska9YYNM7Vya2RM9FSBFlVz/iBbUt7GthtzOAGpZEiS+Yfk6BcuL4QPOmDpHz7M QYamVcBBAX6m5YnxDSK6nwEntwj/ZodhS6m513gBOIxE5dvn7bU2PGSvPVK6KRocxid1 Al1X6yibNrhS7nX/K+O228AlY0UFuaGwmKFQ9n86gxTlYl4dg6zm9PEf9mwi6ZWVIdiU ON4w== X-Forwarded-Encrypted: i=1; AJvYcCXtpmywLQ3wHJQY/q6I/Ld73TTE2cIHOeV38XVxr6pDIn4AlQr1gfeeFSZ7R3FHvrqISv0xDEz+WFu4U08=@vger.kernel.org X-Gm-Message-State: AOJu0Yw52XySiEoWEQHbYW0O0upkopsw4NRoywetdMIh6iY7P3piy5Ur vTWgAtHUrmP5+UysJgP+9ZdltgauAuQ6gwjt+CWYtZDPwBIsAY4nmkDJK/aL6Cs= X-Gm-Gg: ASbGncul04xHc3R7V9rVW3Q5L/fX3e+wbOZjI8vw6ApwFoLflJ6sSOZ1AWk+1uFr6hK WNkTESDdjt2w+EHmg08W7pYkjyzQCU8t8lNtjg284uX+XXDXIXDF1Mja2b/XUfFfURo1NG3yWdm MoFj75OTB/cBhw7dGJxswaZd3g6DUdN22GvyMaWwIvwKvwGwtuU95JSb1loeeTRirvwInZX51Y/ NIRnt7+ane8y6A1Fn8j+FPBUVmR9nayL1BrzUHP/r0eOkX8UsHYIw7DBPYajRP8vPCzTNFa4Gdc WbFsgdj5zQl7jjHnHUpbXrcXFnANhtobe9haaiqUiDsQVm/0vO5smBc= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D 0x4442434E, SBI_EXT_STA =3D 0x535441, SBI_EXT_NACL =3D 0x4E41434C, + SBI_EXT_MPXY =3D 0x4D505859, =20 /* Experimentals extensions must lie within this range */ SBI_EXT_EXPERIMENTAL_START =3D 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 =20 +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 =3D 0x00000000, + SBI_MPXY_ATTR_MSG_PROT_VER =3D 0x00000001, + SBI_MPXY_ATTR_MSG_MAX_LEN =3D 0x00000002, + SBI_MPXY_ATTR_MSG_SEND_TIMEOUT =3D 0x00000003, + SBI_MPXY_ATTR_MSG_COMPLETION_TIMEOUT =3D 0x00000004, + SBI_MPXY_ATTR_CHANNEL_CAPABILITY =3D 0x00000005, + SBI_MPXY_ATTR_SSE_EVENT_ID =3D 0x00000006, + SBI_MPXY_ATTR_MSI_CONTROL =3D 0x00000007, + SBI_MPXY_ATTR_MSI_ADDR_LO =3D 0x00000008, + SBI_MPXY_ATTR_MSI_ADDR_HI =3D 0x00000009, + SBI_MPXY_ATTR_MSI_DATA =3D 0x0000000A, + SBI_MPXY_ATTR_EVENTS_STATE_CONTROL =3D 0x0000000B, + SBI_MPXY_ATTR_STD_ATTR_MAX_IDX, + /* + * Message protocol specific attributes, managed by + * the message protocol specification. + */ + SBI_MPXY_ATTR_MSGPROTO_ATTR_START =3D 0x80000000, + SBI_MPXY_ATTR_MSGPROTO_ATTR_END =3D 0xffffffff +}; + +/* Possible values of MSG_PROT_ID attribute */ +enum sbi_mpxy_msgproto_id { + SBI_MPXY_MSGPROTO_RPMI_ID =3D 0x0, +}; + +/** RPMI message protocol specific MPXY attributes */ +enum sbi_mpxy_rpmi_attribute_id { + SBI_MPXY_RPMI_ATTR_SERVICEGROUP_ID =3D 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 --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5ABF1FCD0F for ; Mon, 3 Feb 2025 08:50:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572629; cv=none; b=lmuVZziEX/hHwxwZ1iOyPhO43ycY18dGeGAn64w1yP4kcW5bnXR/8JvGQQNOyFtPwM12zwxftbjzAfup8umViO7/84lzOzrqdyJBsOCekqHmxPw59n5DQYVAXGFH313NLX0TwNP84IhADakugUfsPAVDjTrpg5X1bqSetd9VNUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572629; c=relaxed/simple; bh=JhXfpKKCbktH8tF1HsRyWnAzeCC6NiI2ESy73c57R2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cMS5HW5f0L00GNmVJRN5igIH7JllRnLC+7xLWNFXqHegB64pX4bjAjf6XtarjzsT3m8XMZHsKgx0Mr7jWmqE5pWg9AJy+Ul4d8tHbd2p9GozTMSiNjIy/69zagOLmuHQTljBCKvR9EoRdo/Y1LPgdBMpDRBwMLcipvv21jrR4Go= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=Joj1gEXd; arc=none smtp.client-ip=209.85.160.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="Joj1gEXd" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-46b1d40ac6bso35420091cf.0 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=vger.kernel.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=Joj1gEXd7lTJtHvJ4VxMKqgMGu/E1yhoyUG93oHP4Cx2b9Xn+fUdZSU6irSAsHBuke m/gNddli0BHnqGe54MamupT8R9Rbe67fwk5buuebhnWSRNA4A9lOn7SJi7yLE8Pq4lMf L1QhvHrnJyuDa5REWyBe20ZsLDg5E4QjC26lWAi4iXFwbyHJUdLcDXcEHRFZckdhbOMR 83tcM4YT1VQ8wRKTZ/G4LDlHDaZtgzyqmneaTERVjyLmJYlpQ0xvny72AX9GACV6ER9Q IA6pPO4Q+nc/Acyd7ed3QGDp5BNsitZ0FMSc7KU82E/tucdF9Uk8jn7wdS5SbwQfvo8U TMCQ== 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=wsAF5TUUcUAVW+DOs6Tvpt5oMShMO2vLWeff6oxga20kkzvfCKXJV/Uttuo6Mj2rOh ZOB13YJjbpeJtCfvxo82qYmj9Rds5rjH8ljxtxSg1iGLZI7Vesd/Xx3zY4Gdpp3DTDZc /cypBTRcgNRXXQcZkm3Got7L/VAY1NZDgQXi8bDfLD27XaIBfdv92FshgBK14CyIiwiG 6OzRSo7j9IwijfmW8ZFrsyi8vclg5ilkm+pstHrZVlpQ5PkySet/kt261OwFebb5Cb7K bhNx7as0OqEtA15jSUAgM+oiJEDAtA4dWNa9hOs7y3DhL9ScLKvBQ1yDNrZ/RB53NtIK oIVw== X-Forwarded-Encrypted: i=1; AJvYcCUG+iLnsjlgwX76fBSrpf/brn10JfZRBT6+b3TeOmfLUv2wcRv4U8maU9zd5jOfXHI/9Wr1S6sX9IKDijA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8U/1x7LDLfSzEkpPVH72aZJDpE9x1JK7pn2oBkjdvmJA5Bjv9 A/gDLwaMj79ffdonZudGB5OR1jGGG2h/oTrYNLOl3ay3VisEHt2RxjbtzxcpcNI= X-Gm-Gg: ASbGncuoo9ormD5hw+e73UCR5DZMSvdjleQYpJeuLCEkmLsifNLfSSAoBUsKSSDPtND +/+SW+pAPHWhmWQJlRmYVodM3ClV8Ve7RMZs2LytB4Od6Ga2zOnhcoAB+ySQD70K+ThwrY1Mwna uH327T4QtRxxOHDkZul78ccUtFfgG4u7L83fkrlcBWpWZQBtFRS+9B7DfHDKp8C0JKF5fsXnEmg 9R6f2dsKGRRi8xfpHh5Qo1IhhfXD9PC3h4RJ8vgMuK2skqAGz/BD9aDIhZ1Sey3GO1pvxklLnU/ pHMJ+SqI47aYA5Y0HBzUztPHmyokYj5SxPyhTrtkzFW+8BoLFkogxP4= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/mai= lbox/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 =3D 0, + RPMI_ERR_FAILED =3D -1, + RPMI_ERR_NOTSUPP =3D -2, + RPMI_ERR_INVALID_PARAM =3D -3, + RPMI_ERR_DENIED =3D -4, + RPMI_ERR_INVALID_ADDR =3D -5, + RPMI_ERR_ALREADY =3D -6, + RPMI_ERR_EXTENSION =3D -7, + RPMI_ERR_HW_FAULT =3D -8, + RPMI_ERR_BUSY =3D -9, + RPMI_ERR_INVALID_STATE =3D -10, + RPMI_ERR_BAD_RANGE =3D -11, + RPMI_ERR_TIMEOUT =3D -12, + RPMI_ERR_IO =3D -13, + RPMI_ERR_NO_DATA =3D -14, + RPMI_ERR_RESERVED_START =3D -15, + RPMI_ERR_RESERVED_END =3D -127, + RPMI_ERR_VENDOR_START =3D -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 =3D 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 =3D 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 =3D RPMI_MBOX_MSG_TYPE_GET_ATTRIBUTE; + msg->attr.id =3D id; + msg->attr.value =3D 0; + msg->error =3D 0; +} + +static inline void rpmi_mbox_init_set_attribute(struct rpmi_mbox_message *= msg, + enum rpmi_mbox_attribute_id id, + u32 value) +{ + msg->type =3D RPMI_MBOX_MSG_TYPE_SET_ATTRIBUTE; + msg->attr.id =3D id; + msg->attr.value =3D value; + msg->error =3D 0; +} + +static inline void rpmi_mbox_init_send_with_response(struct rpmi_mbox_mess= age *msg, + u32 service_id, + void *request, + unsigned long request_len, + void *response, + unsigned long max_response_len) +{ + msg->type =3D RPMI_MBOX_MSG_TYPE_SEND_WITH_RESPONSE; + msg->data.service_id =3D service_id; + msg->data.request =3D request; + msg->data.request_len =3D request_len; + msg->data.response =3D response; + msg->data.max_response_len =3D max_response_len; + msg->data.out_response_len =3D 0; + msg->error =3D 0; +} + +static inline void rpmi_mbox_init_send_without_response(struct rpmi_mbox_m= essage *msg, + u32 service_id, + void *request, + unsigned long request_len) +{ + msg->type =3D RPMI_MBOX_MSG_TYPE_SEND_WITHOUT_RESPONSE; + msg->data.service_id =3D service_id; + msg->data.request =3D request; + msg->data.request_len =3D request_len; + msg->data.response =3D NULL; + msg->data.max_response_len =3D 0; + msg->data.out_response_len =3D 0; + msg->error =3D 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 =3D mbox_send_message(chan, msg); + if (ret < 0) + return ret; + + /* Explicitly signal txdone for mailbox channel */ + ret =3D msg->error; + mbox_client_txdone(chan, ret); + return ret; +} + +#endif /* _LINUX_RISCV_RPMI_MESSAGE_H_ */ --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 824F71FCCFB for ; Mon, 3 Feb 2025 08:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572640; cv=none; b=PuMe6XH7IYivoaJABw3crviIzzVXkJQn/YHJ/H4qMj++VXDoiWFUnxfufvqD5rQvwmNsgZRWYy/1vB+yHeYk0uxqMGL0iw9/V2qHoBbY9Lc/ICyRQgzdVCvRS8DeN1QtcCy/XhiMjPlVPoIMyMtg0TMjhx8Ugi4jwf/3l22z4KQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572640; c=relaxed/simple; bh=9w8wGjwMumRcEE6hnGXig5P3qw6fsQCcwbQXfbC5A90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MPzo8nQzOTm/epys/HWsQ+zR1upp6F6tsYrIM+nP0L5Ruk6TQS9aJFeTkl+aUSySKcNoyShEB5tgGowAirTQAA0v/i7DpNIiJUv+mHQaOH9OI7ftiFBQtmf/0ctNuR/TU1Vp8XuK8vMYLyuA8LCkauKxHubDttyNAMqFjtqhTaY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=h1CcQ5a3; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="h1CcQ5a3" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-467b955e288so45741031cf.1 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=vger.kernel.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=h1CcQ5a3Ue7AjWcaJS2dYurxN8ukUAiZETzRHYTPBRPo+E4LrDK8xO6DxgJEzVSDv/ 19cM4WrgvRircYE4HbBmUcnwBi49mUxtOi6lbqQGV0RYebQz7cYwojdggSO7/eINI32O LPJP/6tP7S7ApvneKacdoBChPWeRhjVfkDQ7+pAYXw4WHrVPNqkWetvMmoq9LvRmMBh2 BkidAOM7l3uStGAQjE+iNQIHrwaDVxVBJaSWhP9dmVo8sAUn3NJCVom24+MQ876pJGA6 LlfgmVwVruf1DTzZ3GZo1B1WlF7UHY2d6xoa69//8MW9agxnPEwvHqQQ2SAFwO+og+sO KNiA== 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=UIhmfk15etiVFlJuWqaYMpUTxXILmi1P6mB2OC9Jt99ow8tXRFwBfTTYt8lZxiiJJ0 PQn/slWavtad7BOgkrkFq0QBPxSwGgd1qP3z2FlX3aB8IHXUW0/9q/NxPSNm2FAG0aEE CCByO5cb1PAzPHq+3suDrDRz0dSh9x72DgovFpnuKCAKV3hTr0Hm0yOfkOS1FRrqjKjX vt9IzW9cZZVuRIFqHT8XQLQAvVkLnUqCeeS2272bRxvj4bCeqRs65PjA+reg7z0IDMtu ZJQaxexzbMa2gFFW8TIONTP+k3oLtUHGC99jaMwqVkzuwWDnowBPb2tFa92pzedzZNLf s8qg== X-Forwarded-Encrypted: i=1; AJvYcCUb0BFku+l9u9cmWk6vdSbLv8EICd9a+F+tqhnm8JqNbmtYku04+C68tEH4d2SyQbF/5aN0FecRZaXiVzk=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0iIyADdJmxiBCTxc26/1YjVkOQ5EDUJxIt/Nodfg6PRwLLLt/ Z1xFyRXNtVkH5A1B7DxwhAYl5GlPb0LNnl4mcDoDzumhavcRen4p61QQv9P8leQ= X-Gm-Gg: ASbGncu14AoKG+SbeOrGznGoxhwIi65m6kztRmwFXwHu6UjIYWHXCrQc1pF66viBN9u PbDmoXXR8SriB3K0xxnw0satBgmznX1nE9/vMw8B2tzHTUSlw/b2d4xh0CIrI75YB690RVktY50 YjRVM8xbV36Xdf19Lkf/v0lf6A48vkSCNb1EF0wBnEq6xUBYFHA15zpYesbT9e08lBboe3kjzKD nCwbD3XvcPdz6VK5x/uREJxw6tQ5kgh1OGF/YgXY2XTUVHbrSVVmWv12/KxESqHI6GkJcjLSwvV cxp7EHI90K9hjeKDmuHFD+MtdAE5e3h+tTzCSIub8yMdArMVWW5un4Y= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D cl->dev; struct mbox_controller *mbox; struct of_phandle_args spec; struct mbox_chan *chan; int ret; =20 - 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); } =20 mutex_lock(&con_mutex); =20 - 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_cl= ient *cl, int index) } =20 chan =3D ERR_PTR(-EPROBE_DEFER); - list_for_each_entry(mbox, &mbox_cons, node) - if (mbox->dev->of_node =3D=3D spec.np) { + list_for_each_entry(mbox, &mbox_cons, node) { + if (mbox->fw_xlate && mbox->dev->fwnode =3D=3D fwspec.fwnode) { + chan =3D mbox->fw_xlate(mbox, &fwspec); + if (!IS_ERR(chan)) + break; + } else if (mbox->of_xlate && mbox->dev->of_node =3D=3D spec.np) { chan =3D mbox->of_xlate(mbox, &spec); if (!IS_ERR(chan)) break; } + } =20 - of_node_put(spec.np); + if (dev->of_node) + of_node_put(spec.np); =20 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 =3D 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 =3D device_property_match_string(cl->dev, "mbox-names", name); =20 - index =3D 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); =20 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 =3D sp->args[0]; =20 @@ -549,8 +557,8 @@ int mbox_controller_register(struct mbox_controller *mb= ox) spin_lock_init(&chan->lock); } =20 - if (!mbox->of_xlate) - mbox->of_xlate =3D of_mbox_index_xlate; + if (!mbox->fw_xlate && !mbox->of_xlate) + mbox->fw_xlate =3D fw_mbox_index_xlate; =20 mutex_lock(&con_mutex); list_add_tail(&mbox->node, &mbox_cons); diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_con= troller.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 */ --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84ABB1FC7D6 for ; Mon, 3 Feb 2025 08:50:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572654; cv=none; b=qrbfV76pVQc4krrC5UyHTVVUo9H4s/fUuC2nmLmqRG7yGsDcv2G4/GYvvBIIn7PMSIMx5l7E5z13yCNnuNysP6OhWUj8Y4IaAytpACBnHFqfZWf/In4uyQYkq9ZJ/MxVBoPcTmsGS8hApoKKAJLUrpXlqOeIc0VDUd80UoKJmFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572654; c=relaxed/simple; bh=XMi7bmnwbp9Fu7EagEQUf3Gjeui8FpIBNU02qxZmwOY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aCkplHRrijjz7lw3Bsa78jwvK1CXoPrU+q1vDQHY/e/uUOqlHm/xEwsmQIaRhSzhzpabUuopxvS47uHRzUJLH17Ph/wOd852nnmtD0rF2yeUf0B6LNKIeEn5fagQXLy2PafAg9RBvkw7P711q+cPKN8/LmCAD2vUwmj9ufVZx8g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=ZMylqas+; arc=none smtp.client-ip=209.85.160.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="ZMylqas+" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-4678cd314b6so39182941cf.3 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=vger.kernel.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=ZMylqas+RAqp9EYGCFEeeBn38oE2Ik9CVaB9hUO0ufgLfAAQcN6f0Z0/+tAVKzHkmu 5cY4jA6nXSzBFvhb1JhXjUQGwtHb9tzZhjlb0Ox5qSxOCgOtulcjRDrPfIZN66I4PGpA oQA23uA/jgsXT2DI3ZxpvCV7NJZ2QC+eznrr9eUS/HyzF9x0ewA431oFZwkqWq9Azfv7 jVbtzNRzvILcb2PDocevPrKYus4kQNG+mN7Yl3Cl9fH4Ht5XJ+i+4q/a79TFiNXp8+LS gjswgS8ixTKBOhq1fRaCrbn45cSGsLACuQroGJDhXjCPwKaM+Ez6svfBDvHaGSnlwfiJ GwwA== 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=xH+VWKPzDcYK8MSukclhVYiP6CG3Kj7BUAUDTl7HCVLB3NXZGIh5v4F79UVf5E0qeL Ul+yX7pQ2xNmRvD/RCaIEdUEHsQRm77ak9VAJe2x3dMKANrr3zcP41pdqurgVapeSTyI pHuL5D+SMuPP8Ze9MgVHi51xlEg2YMMhNEfIitvGLSvr4SsBTS0Kysu7ioHNf66eeL7r y0koYpE9qrbRBMKx8hOU5ZnbjrJhDR5pA/1RncLEENic0FhDMBSY4Z1cVozwhwtYX+f8 Rggy88X2I4NWd4S26vuCXbN2UR5fZb8Nm10ayhuouHSiBFcYmBou0CdscoZY+jNdQpHr ZV1w== X-Forwarded-Encrypted: i=1; AJvYcCU9SgZTEccjMc4qxroJHWUT29N0uHg2MiTVY48FCk175DrX/ShOVQyvQOzquM1mDBUOV6oH4pOQDOjVfu8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1xflER/jlOYPvGC6KAfQ+uavFAr14j7bLkEerd7FEDoh1hg3m h6g9cztBNxRQNQ2oT+D/Vbse1g5rJ71mdRtwg1Iq8ErGLTQ7Ha9wke+KBatO5m4= X-Gm-Gg: ASbGncvHJSDkshEX0MQCCf/Al+tFPOKsvF3GUBy3QdrRZlkmA2oFbrvq4YfGuJjajGh 1Xo8wTjN8gLuiUSzkgfAb3cVJNy0uXJA1D2+CnmyXH23s9QATW0vHu3ttBHGQo/X/nqhmIUqbCm 9PWLoJEf2V+hW9rY3lUJNuNDiwC34nyEYhgQNTFe+Ldk6h1WK8JGbiLPj8wv39skW3eZLI04LJj HAn9lME9sHzlQGlLQEewABjcXQvbS3twS5N9B/XKyA/PTexDWBFK9mptZKQxXxQqL97v70DCpl6 Xu3m1LcuyX0FlaVGnr/EhO3t/LMTyFXOMRTCSjffNP676sU+Cb3rt4U= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. =20 +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) +=3D qcom-cpucp-mbox.o obj-$(CONFIG_QCOM_IPCC) +=3D qcom-ipcc.o =20 obj-$(CONFIG_THEAD_TH1520_MBOX) +=3D mailbox-th1520.o + +obj-$(CONFIG_RISCV_SBI_MPXY_MBOX) +=3D 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 + +/* =3D=3D=3D=3D=3D=3D SBI MPXY extension data structures =3D=3D=3D=3D=3D= =3D */ + +/* 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[]; +}; + +/* =3D=3D=3D=3D=3D=3D MPXY data structures & helper routines =3D=3D=3D=3D= =3D=3D */ + +/* 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 =3D this_cpu_ptr(&mpxy_local); + struct sbi_mpxy_channel_ids_data *sdata =3D 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 =3D sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_GET_CHANNEL_IDS, + 0, 0, 0, 0, 0, 0); + if (!sret.error) { + remaining =3D le32_to_cpu(sdata->remaining); + returned =3D le32_to_cpu(sdata->returned); + *channel_count =3D 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 =3D 0, cidx =3D 0; + struct mpxy_local *mpxy =3D this_cpu_ptr(&mpxy_local); + struct sbi_mpxy_channel_ids_data *sdata =3D mpxy->shmem; + struct sbiret sret; + + if (!mpxy->shmem_active) + return -ENODEV; + if (!channel_count || !channel_ids) + return -EINVAL; + + get_cpu(); + + do { + sret =3D sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_GET_CHANNEL_IDS, + start_index, 0, 0, 0, 0, 0); + if (sret.error) + goto done; + + remaining =3D le32_to_cpu(sdata->remaining); + returned =3D le32_to_cpu(sdata->returned); + + for (sidx =3D 0; sidx < returned && cidx < channel_count; sidx++) { + channel_ids[cidx] =3D le32_to_cpu(sdata->channel_array[sidx]); + cidx +=3D 1; + } + + start_index =3D 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 =3D 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 =3D sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_READ_ATTRS, + channel_id, base_attrid, attr_count, 0, 0, 0); + if (!sret.error) { + for (i =3D 0; i < attr_count; i++) + attrs_buf[i] =3D 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_coun= t, + u32 *attrs_buf) +{ + struct mpxy_local *mpxy =3D 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 =3D 0; i < attr_count; i++) + ((__le32 *)mpxy->shmem)[i] =3D cpu_to_le32(attrs_buf[i]); + sret =3D 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 =3D 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 =3D 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 =3D sret.value; + if (rx_bytes > max_rx_len) { + put_cpu(); + return -ENOSPC; + } + + memcpy(rx, mpxy->shmem, rx_bytes); + if (rx_len) + *rx_len =3D 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 =3D 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 =3D 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 =3D 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 =3D 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 =3D sret.value; + } + + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static unsigned long mpxy_get_shmem_size(void) +{ + struct sbiret sret; + + sret =3D 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 =3D per_cpu_ptr(&mpxy_local, cpu); + if (!mpxy->shmem_active) + return -EINVAL; + + sret =3D 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 =3D NULL; + mpxy->shmem_phys_addr =3D 0; + mpxy->shmem_active =3D false; + + return 0; +} + +static int mpxy_setup_shmem(unsigned int cpu) +{ + struct page *shmem_page; + struct mpxy_local *mpxy; + struct sbiret sret; + + mpxy =3D per_cpu_ptr(&mpxy_local, cpu); + if (mpxy->shmem_active) + return -EINVAL; + + shmem_page =3D 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] =3D 00b + */ + sret =3D 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 =3D page_to_virt(shmem_page); + mpxy->shmem_phys_addr =3D page_to_phys(shmem_page); + mpxy->shmem_active =3D true; + + return 0; +} + +/* =3D=3D=3D=3D=3D=3D MPXY mailbox data structures =3D=3D=3D=3D=3D=3D */ + +/* 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; +}; + +/* =3D=3D=3D=3D=3D=3D MPXY RPMI processing =3D=3D=3D=3D=3D=3D */ + +static int mpxy_mbox_send_rpmi_data(struct mpxy_mbox_channel *mchan, + struct rpmi_mbox_message *msg) +{ + int rc =3D 0; + + switch (msg->type) { + case RPMI_MBOX_MSG_TYPE_GET_ATTRIBUTE: + switch (msg->attr.id) { + case RPMI_MBOX_ATTR_SPEC_VERSION: + msg->attr.value =3D mchan->attrs.msg_proto_version; + break; + case RPMI_MBOX_ATTR_MAX_MSG_DATA_SIZE: + msg->attr.value =3D mchan->max_xfer_len; + break; + case RPMI_MBOX_ATTR_SERVICEGROUP_ID: + msg->attr.value =3D mchan->rpmi_attrs.servicegroup_id; + break; + case RPMI_MBOX_ATTR_SERVICEGROUP_VERSION: + msg->attr.value =3D mchan->rpmi_attrs.servicegroup_version; + break; + default: + rc =3D -EOPNOTSUPP; + break; + } + break; + case RPMI_MBOX_MSG_TYPE_SET_ATTRIBUTE: + /* None of the RPMI linux mailbox attributes are writeable */ + rc =3D -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 =3D -EINVAL; + break; + } + if (!(mchan->attrs.capability & SBI_MPXY_CHAN_CAP_SEND_WITH_RESP)) { + rc =3D -EIO; + break; + } + rc =3D 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 =3D -EINVAL; + break; + } + if (!(mchan->attrs.capability & SBI_MPXY_CHAN_CAP_SEND_WITHOUT_RESP)) { + rc =3D -EIO; + break; + } + rc =3D mpxy_send_message_without_resp(mchan->channel_id, + msg->data.service_id, + msg->data.request, + msg->data.request_len); + break; + default: + rc =3D -EOPNOTSUPP; + break; + } + + msg->error =3D 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 =3D 0, event_size; + struct rpmi_mbox_message msg; + + while ((pos < events_data_len) && !(pos & 0x3) && + ((events_data_len - pos) <=3D sizeof(*event))) { + event =3D (struct rpmi_notification_event *)(notif->events_data + pos); + + msg.type =3D RPMI_MBOX_MSG_TYPE_NOTIFICATION_EVENT; + msg.notif.event_datalen =3D le16_to_cpu(event->event_datalen); + msg.notif.event_id =3D event->event_id; + msg.notif.event_data =3D event->event_data; + msg.error =3D 0; + + event_size =3D sizeof(*event) + msg.notif.event_datalen; + if (event_size > (events_data_len - pos)) { + event_size =3D events_data_len - pos; + goto skip_event; + } + if (event_size & 0x3) + goto skip_event; + + mbox_chan_received_data(chan, &msg); + +skip_event: + pos +=3D 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); +} + +/* =3D=3D=3D=3D=3D=3D MPXY mailbox callbacks =3D=3D=3D=3D=3D=3D */ + +static int mpxy_mbox_send_data(struct mbox_chan *chan, void *data) +{ + struct mpxy_mbox_channel *mchan =3D chan->con_priv; + + if (mchan->attrs.msg_proto_id =3D=3D 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 =3D chan->con_priv; + struct sbi_mpxy_notification_data *notif =3D mchan->notif; + bool have_notifications =3D false; + unsigned long data_len; + int rc; + + if (!(mchan->attrs.capability & SBI_MPXY_CHAN_CAP_GET_NOTIFICATIONS)) + return false; + + while (1) { + rc =3D mpxy_get_notifications(mchan->channel_id, notif, &data_len); + if (rc || !data_len) + break; + + if (mchan->attrs.msg_proto_id =3D=3D SBI_MPXY_MSGPROTO_RPMI_ID) + mpxy_mbox_peek_rpmi_data(chan, mchan, notif, data_len); + + have_notifications =3D 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 =3D mchan->mbox->dev; + int rc; + + /* Do nothing if MSI not supported */ + if (mchan->msi_irq =3D=3D U32_MAX) + return 0; + + /* Fail if MSI already enabled */ + if (mchan->attrs.msi_control) + return -EALREADY; + + /* Request channel MSI handler */ + rc =3D 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 =3D 1; + rc =3D 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 =3D 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 =3D mchan->mbox->dev; + int rc; + + /* Do nothing if MSI not supported */ + if (mchan->msi_irq =3D=3D U32_MAX) + return; + + /* Do nothing if MSI already disabled */ + if (!mchan->attrs.msi_control) + return; + + /* Disable channel MSI control */ + mchan->attrs.msi_control =3D 0; + rc =3D 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 =3D 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 =3D 1; + rc =3D mpxy_write_attrs(mchan->channel_id, SBI_MPXY_ATTR_EVENTS_STATE_CON= TROL, + 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 =3D 0; + return rc; + } + + return 0; +} + +static void mpxy_mbox_cleanup_events(struct mpxy_mbox_channel *mchan) +{ + struct device *dev =3D 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 =3D 0; + rc =3D mpxy_write_attrs(mchan->channel_id, SBI_MPXY_ATTR_EVENTS_STATE_CON= TROL, + 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 =3D chan->con_priv; + int rc; + + if (mchan->started) + return -EALREADY; + + /* Setup channel MSI */ + rc =3D mpxy_mbox_setup_msi(chan, mchan); + if (rc) + return rc; + + /* Setup channel notification events */ + rc =3D mpxy_mbox_setup_events(mchan); + if (rc) { + mpxy_mbox_cleanup_msi(chan, mchan); + return rc; + } + + /* Mark the channel as started */ + mchan->started =3D true; + + return 0; +} + +static void mpxy_mbox_shutdown(struct mbox_chan *chan) +{ + struct mpxy_mbox_channel *mchan =3D chan->con_priv; + + if (!mchan->started) + return; + + /* Mark the channel as stopped */ + mchan->started =3D 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 =3D { + .send_data =3D mpxy_mbox_send_data, + .peek_data =3D mpxy_mbox_peek_data, + .startup =3D mpxy_mbox_startup, + .shutdown =3D mpxy_mbox_shutdown, +}; + +/* =3D=3D=3D=3D=3D=3D MPXY platform driver =3D=3D=3D=3D=3D */ + +static void mpxy_mbox_msi_write(struct msi_desc *desc, struct msi_msg *msg) +{ + struct device *dev =3D msi_desc_to_dev(desc); + struct mpxy_mbox *mbox =3D dev_get_drvdata(dev); + struct mpxy_mbox_channel *mchan; + struct sbi_mpxy_msi_info *minfo; + int rc; + + mchan =3D 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 =3D &mchan->attrs.msi_info; + minfo->msi_addr_lo =3D msg->address_lo; + minfo->msi_addr_hi =3D msg->address_hi; + minfo->msi_data =3D msg->data; + + rc =3D 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 =3D container_of(ctlr, struct mpxy_mbox, controlle= r); + struct mpxy_mbox_channel *mchan; + u32 i; + + if (pa->nargs !=3D 2) + return ERR_PTR(-EINVAL); + + for (i =3D 0; i < mbox->channel_count; i++) { + mchan =3D &mbox->channels[i]; + if (mchan->channel_id =3D=3D pa->args[0] && + mchan->attrs.msg_proto_id =3D=3D pa->args[1]) + return &mbox->controller.chans[i]; + } + + return ERR_PTR(-ENOENT); +} + +static int mpxy_mbox_probe(struct platform_device *pdev) +{ + struct device *dev =3D &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) <=3D 0) { + dev_info(dev, "SBI MPXY extension not available\n"); + return -ENODEV; + } + + /* Find-out shared memory size */ + mpxy_shmem_size =3D 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 =3D true; + + /* Allocate mailbox instance */ + mbox =3D devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); + if (!mbox) + return -ENOMEM; + mbox->dev =3D dev; + platform_set_drvdata(pdev, mbox); + + /* Find-out of number of channels */ + rc =3D 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 =3D devm_kcalloc(dev, mbox->channel_count, + sizeof(*channel_ids), GFP_KERNEL); + if (!channel_ids) + return -ENOMEM; + rc =3D 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 =3D devm_kcalloc(dev, mbox->channel_count, + sizeof(*mbox->channels), GFP_KERNEL); + if (!mbox->channels) + return -ENOMEM; + for (i =3D 0; i < mbox->channel_count; i++) { + mchan =3D &mbox->channels[i]; + mchan->mbox =3D mbox; + mchan->channel_id =3D channel_ids[i]; + + rc =3D 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 =3D=3D SBI_MPXY_MSGPROTO_RPMI_ID) { + rc =3D 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 =3D devm_kzalloc(dev, mpxy_shmem_size, GFP_KERNEL); + if (!mchan->notif) + return -ENOMEM; + + mchan->max_xfer_len =3D 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 =3D true; + + if ((mchan->attrs.capability & SBI_MPXY_CHAN_CAP_GET_NOTIFICATIONS) && + (mchan->attrs.capability & SBI_MPXY_CHAN_CAP_MSI)) + mchan->msi_index =3D mbox->msi_count++; + else + mchan->msi_index =3D U32_MAX; + mchan->msi_irq =3D U32_MAX; + } + + /* Free-up channel IDs */ + devm_kfree(dev, channel_ids); + + /* Initialize mailbox controller */ + mbox->controller.txdone_irq =3D false; + mbox->controller.txdone_poll =3D false; + mbox->controller.ops =3D &mpxy_mbox_ops; + mbox->controller.dev =3D dev; + mbox->controller.num_chans =3D mbox->channel_count; + mbox->controller.fw_xlate =3D mpxy_mbox_fw_xlate; + mbox->controller.chans =3D devm_kcalloc(dev, mbox->channel_count, + sizeof(*mbox->controller.chans), + GFP_KERNEL); + if (!mbox->controller.chans) + return -ENOMEM; + for (i =3D 0; i < mbox->channel_count; i++) + mbox->controller.chans[i].con_priv =3D &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 =3D 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 =3D 0; msi_idx < mbox->msi_count; msi_idx++) { + for (i =3D 0; i < mbox->channel_count; i++) { + mchan =3D &mbox->channels[i]; + if (mchan->msi_index =3D=3D msi_idx) { + mbox->msi_index_to_channel[msi_idx] =3D mchan; + break; + } + } + } + + rc =3D 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 =3D 0; i < mbox->channel_count; i++) { + mchan =3D &mbox->channels[i]; + if (mchan->msi_index =3D=3D U32_MAX) + continue; + mchan->msi_irq =3D msi_get_virq(dev, mchan->msi_index); + } + } + + /* Register mailbox controller */ + rc =3D 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 =3D 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[] =3D { + {.compatible =3D "riscv,sbi-mpxy-mbox", }, + {}, +}; +MODULE_DEVICE_TABLE(of, mpxy_mbox_of_match); + +static struct platform_driver mpxy_mbox_driver =3D { + .driver =3D { + .name =3D "riscv-sbi-mpxy-mbox", + .of_match_table =3D mpxy_mbox_of_match, + }, + .probe =3D mpxy_mbox_probe, + .remove =3D 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"); --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02DCE1FECC0 for ; Mon, 3 Feb 2025 08:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572663; cv=none; b=AWbe0uNMR8AY2Ox2KkIunb3qviiEsF3T178sS3M/DSYs3FWzoMlDuuY3hQmusTO/UXTofldOyuU1S0xYIXLdbs4vQiVFPzVVtVXsUZgMQoSRfT3yHkWbJh/1Tnr8mQrsHU6Tmw7kWGxnkHsuz8mf77SI3OholPhdAOSUoGgUdg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572663; c=relaxed/simple; bh=PKCozwgCuABhJm3FGiso9S7XEa6OmbDF8ANr4JIaqWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AqUEInwwvYXmycZYoJBxhEFDXiWq794JcxzYpJ08rFZxeVXJ5WOkGOcn44PlfgMxN0i3m+F33YA7RVY6/rjeFt7CtKDQ6Wzewx+alz2t0FchailKBEx4Qw/mRu4cB65TTOw88gCW0QFNCrVjKbpxp5hHcr+GueuCk2+yO9gXhrs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=XkLbecf4; arc=none smtp.client-ip=209.85.160.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="XkLbecf4" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-4678cce3d60so42833481cf.2 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=vger.kernel.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=XkLbecf4xRPUphzZm9AErUDJM1oxk9IVUbqliV5/il4hwLs5PvcnduTGUlBsCR38a/ BcHWG7XX6QE75WgCOYlJ1UmgFU9RGapQQHneIEltqp1RkIfGEtAL8MalPnEGUqJbab9l poN91SzCSiW7Z5LCBrNgfBNsXKqdd9mFGlDNkXUMoJVrH9KNoHZc68OkLXpC98H7EO/9 VvWesxl45ve2eVWeEMjqWv3Zypi9ipcq6Pd2k/pIlRtsiJHx1PMlJevTnccBxoC2OmSS Cwq/PZqZ+In66K5OM+r2AI3h/wJNB4nlKA/4Kj1ANDJMoSx6HfBk264+BMgejAvxcRK8 s6Bg== 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=hb1WI97cScAco9I63h8fT0LwromaSGWEmPKDuED7gd+FzJUmcvU2cbi6eJoTI7uF/x gNsIILTOW1Hyu6wdrg9yDciG1BORgqsjV9eaIXI8/esiD+GnzxHJYU/y5PKqK6bBS/QK XVyDE2Rz9XCTOheT9eWBOxGumXhlj3RiurbdTQ6tbjm6wfR/sa3nN5hWlHk6xKxRrIZ4 4GRic0//MmkZwReI3ALge3yKK6GByEqBc1Jy14oaE33YAAe6uzFC0AZLt+YNsZpZRqbq tzQ97hbIsRuAUnpgA9h3eHyyveJyRkoftflGzxGr3meJYNZ9nD6GKy348i6VKrRzJR4o 9+og== X-Forwarded-Encrypted: i=1; AJvYcCUg5HusPVRi63FisgORgI+OLt09rb+tekP/CbRlHjul8mR4z+tbqB7WsMaHrKB7CKu4ik/NGm6DaaRbhFo=@vger.kernel.org X-Gm-Message-State: AOJu0YyYFMlcyOXYf9lId8HqnTTjFWBe2w2aEoLjzYaMk/zPOaI+d8Sc ipM2YJZ4GAiuUAeh1Crrp+wjl1x4059T9taTFv3EKN46bKRPgkjQEW7767xw8TM= X-Gm-Gg: ASbGncuhtbdHgcjWL/T7AkapkzfKfW/JbydIv0dRG9DVr/TDKEJ29O+3esHzgr4K+i0 14ceOBVc1AtvOLfakQO580uF2UqhXZcUpeMjX9tmCjHg53Ir/UEIPTO4Ptc7khcRe9G/Y3wEKLs vz+xjD9RdYii6xEELUZmQ5nb94a9zMKVrletbgsGk/XkWiOemYzpr6N5MFV4CChv+MOWhNsUpNd +4HsyfETa5rSIgqmfdXzgsWuqSnwZUEABW8tbgKTHRsN+Ue+3flw7VIiOlb9HcyuL3B/vXaQbL5 8lk9iyprP1nNdIud1LIFMJwfkaVxDISjxHSMBdeAsfJxk3dkRmyjwV8= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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-cloc= k.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. + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + References + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + [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 prox= y. + + 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 st= ring. + +required: + - compatible + - mboxes + +additionalProperties: false + +examples: + - | + mpxy_mbox: sbi-mpxy-mbox { + compatible =3D "riscv,sbi-mpxy-mbox"; + #mbox-cells =3D <2>; + }; + rpmi-clk { + compatible =3D "riscv,rpmi-clock"; + mboxes =3D <&mpxy_mbox 0x1000 0x0>; + #clock-cells =3D <1>; + }; +... --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6AB21FCD03 for ; Mon, 3 Feb 2025 08:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572677; cv=none; b=FZaTMFU7JvtWcvlZawiHz8Ogekyabb/aBRjTHp8EjFdh37hoTqWK059iJIsGMxUhGQ5HnnzM/aNrkgb3dqYPUWffmLPBHL1cvyrPZMp1DLS7MWcvZjOhwU60rC0ek+mnMH+eAW14BLfLTOrtABz8G3+dc5EoYxwJHQCH/zdIyUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572677; c=relaxed/simple; bh=XqSthx6VTt7n3fyQoLTf3dXVRkOaLR1QuK16hj+NqF0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ayRA9GQd/kvoAboJFk1kKEGR3KpgcZKQM5JIwx8xwtuERgUkxT7CVMW4njBQsAIk+MgbWFcoKPR1lMAW2f63yswmgmb5Y1ajesgmouMfiDYD5IISY/Q11TBAopjpGLP+9/vsRofG07AoebAFtW/Ao9ut6BKAB9J5CvRYahXW6Q4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=XCmN/s4r; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="XCmN/s4r" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-467b955e288so45744521cf.1 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=vger.kernel.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=XCmN/s4rJYmgSBy3ScS+d3r4bZa4BR+Xh3Vkh3wiV81Q/lpJa0YzGf2R8Zlhfu6Qib B7Pnm+JutEAqkjCyrvwAQefXOj7F3XiUYU7AsbeQbLiFNt/D8GP0RGyoCjqAXiC4d4dL BlI8GmP7xIOBhO6Ni9QzbQWBs9DLxuwMbkHlt9MIwtDmAxSGTXBmRs5ZOw/Qfm9DarqY YCOrF2LJ06Ng4G0JnhDo7cyWCM14Np36HvkxWqOrHYPkVjxnZZLrLPChKL6GUt/qBrzF TV+gPR9GF3yaFupcZE8hQIYJB4VzL5+HpH0u+Ur34zKAWkNLOHrphIsfx7MEHj17kN+d dx0A== 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=EJaGGXbswlK7JeihCDrU5MNq8iFukuOYt94LRB6zff/nZ0hytBKnUw6sY4iT9OmgDs NIcAUT3Cyce8Hr8Bl1vCcvatttOd+XN0oc1VYrnBvk22XoYDwSQpzJxtSMyBWrGYMyqs z6A64CLMN5/SkMCDPm/xrVtF/g7UYJsCLZH7gOkADEjxQh6SzDAnJQSe+QQUgnnfVv7t s6hriP3n1JcPPET7XkTUjeXJ+zQsT2MY+GLoyTufCyD4l2xaZb3UYCjUUiCo2QxIIS8A AGFeBx14P4piWek+B9KOcxV1sO57jRru7hHed9BKseZzQOctRIZAhp59QQMkJsWZ0sY6 28mw== X-Forwarded-Encrypted: i=1; AJvYcCXDef7Nr18foUJ98l5wueXOo9h/pMrhYTZvYOCOAbKNj84FwsFy2p0UJq+VLGYdZ0HsVihwkE1+n/sYHSc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6OHEJy1QUzHqG1N6uMRbfP2rvo5N0Oj9KEEHmE1YD0V3R5qjT pjnZgy7cgqIsKLuekwUodUesYAii22BbsRBzepbT4Oa0CI6vRnw9GcahL5i3/Fg= X-Gm-Gg: ASbGnctqL2GcTOYYzwGnCegm9kGjFc4ZrKK6J5KtPnAlJdYCtj2zs1KWq+tHxesQw/x FuxCrAg6Rp/6aR/nUPpEaDIXzBcG7mw6kG3KRSuLnvtnAA8vnT8DX79zsy5IyrUJsiIZjr6IzyY SRkqfILq+g7nFIaNFj/T0Izv9NsdNLWwcFmB9epbQUG+zGIlBjKwO/lmvi+r0pl63f1fgHxl7pk dF/XLbLk2FfifcAJ2EyB45JvuESU52h0NxWVvUuT8fzbAvO+WQypSYtBJ6oN51ITi4KTqBjzrZY S3+szkz9k6HKphxTZ3p8NXkwZ5AxE/2/sDfCdPLLfkgmPpc8uks7cpg= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. =20 +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) +=3D clk-plldig.o obj-$(CONFIG_COMMON_CLK_PWM) +=3D clk-pwm.o obj-$(CONFIG_CLK_QORIQ) +=3D clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) +=3D clk-rk808.o +obj-$(CONFIG_COMMON_CLK_RPMI) +=3D clk-rpmi.o obj-$(CONFIG_COMMON_CLK_HI655X) +=3D clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) +=3D clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCMI) +=3D 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 =3D 0, + RPMI_CLK_ENABLE =3D 1, +}; + +enum rpmi_clk_type { + RPMI_CLK_DISCRETE =3D 0, + RPMI_CLK_LINEAR =3D 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 =3D 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 =3D 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 =3D cpu_to_le32(clkid); + rpmi_mbox_init_send_with_response(&msg, RPMI_CLK_SRV_GET_ATTRIBUTES, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret =3D rpmi_mbox_send_message(context->chan, &msg); + if (ret) + return ret; + if (rx.status) + return rpmi_to_linux_error(rx.status); + + rpmi_clk->id =3D clkid; + rpmi_clk->num_rates =3D rx.num_rates; + rpmi_clk->transition_latency =3D rx.transition_latency; + strscpy(rpmi_clk->name, rx.name, RPMI_CLK_NAME_LEN); + + format =3D rx.flags & 3U; + if (format >=3D RPMI_CLK_TYPE_MAX_IDX) + return -EINVAL; + + rpmi_clk->type =3D format; + + return 0; +} + +static int rpmi_clk_get_supported_rates(u32 clkid, struct rpmi_clk *rpmi_c= lk) +{ + struct rpmi_clk_context *context =3D 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 =3D 0; + int ret, rateidx, j; + + tx.clkid =3D cpu_to_le32(clkid); + tx.clk_rate_idx =3D 0; + + /* + * Make sure we allocate rx buffer sufficient to be accommodate all + * the rates sent in one RPMI message. + */ + rx =3D 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 =3D 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 =3D=3D RPMI_CLK_DISCRETE) { + rate_discrete =3D (struct rpmi_clk_rate_discrete *)rx->rates; + + for (rateidx =3D 0; rateidx < rx->returned; rateidx++) { + rpmi_clk->rates->discrete[rateidx] =3D + 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 +=3D rx->returned; + tx.clk_rate_idx =3D 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 =3D 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 =3D 0; j < rx->returned; j++) { + if (rateidx >=3D (clk_rate_idx + rx->returned)) + break; + rpmi_clk->rates->discrete[rateidx++] =3D + GET_RATE_U64(rate_discrete[j].hi, + rate_discrete[j].lo); + } + } + } else if (rpmi_clk->type =3D=3D RPMI_CLK_LINEAR) { + rate_linear =3D (struct rpmi_clk_rate_linear *)rx->rates; + + rpmi_clk->rates->linear.min =3D + GET_RATE_U64(rate_linear->min_hi, + rate_linear->min_lo); + rpmi_clk->rates->linear.max =3D + GET_RATE_U64(rate_linear->max_hi, + rate_linear->max_lo); + rpmi_clk->rates->linear.step =3D + 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 =3D to_rpmi_clk(hw); + struct rpmi_clk_context *context =3D rpmi_clk->context; + struct rpmi_mbox_message msg; + struct rpmi_get_rate_tx tx; + struct rpmi_get_rate_rx rx; + int ret; + + tx.clkid =3D 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 =3D 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 =3D 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 =3D=3D RPMI_CLK_DISCRETE) + goto out; + + fmin =3D rpmi_clk->rates->linear.min; + fmax =3D rpmi_clk->rates->linear.max; + + if (req->rate <=3D fmin) { + req->rate =3D fmin; + goto out; + } else if (req->rate >=3D fmax) { + req->rate =3D fmax; + goto out; + } + + ftmp =3D req->rate - fmin; + ftmp +=3D rpmi_clk->rates->linear.step - 1; + do_div(ftmp, rpmi_clk->rates->linear.step); + + req->rate =3D 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 =3D to_rpmi_clk(hw); + struct rpmi_clk_context *context =3D rpmi_clk->context; + struct rpmi_mbox_message msg; + struct rpmi_set_rate_tx tx; + struct rpmi_set_rate_rx rx; + int ret; + + tx.clkid =3D cpu_to_le32(rpmi_clk->id); + tx.lo =3D cpu_to_le32(lower_32_bits(rate)); + tx.hi =3D 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 =3D 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 =3D to_rpmi_clk(hw); + struct rpmi_clk_context *context =3D rpmi_clk->context; + struct rpmi_mbox_message msg; + struct rpmi_set_config_tx tx; + struct rpmi_set_config_rx rx; + int ret; + + tx.config =3D cpu_to_le32(RPMI_CLK_ENABLE); + tx.clkid =3D 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 =3D 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 =3D to_rpmi_clk(hw); + struct rpmi_clk_context *context =3D rpmi_clk->context; + struct rpmi_mbox_message msg; + struct rpmi_set_config_tx tx; + struct rpmi_set_config_rx rx; + int ret; + + tx.config =3D cpu_to_le32(RPMI_CLK_DISABLE); + tx.clkid =3D 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 =3D 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 =3D { + .recalc_rate =3D rpmi_clk_recalc_rate, + .determine_rate =3D rpmi_clk_determine_rate, + .set_rate =3D rpmi_clk_set_rate, + .prepare =3D rpmi_clk_enable, + .unprepare =3D rpmi_clk_disable, +}; + +static struct clk_hw *rpmi_clk_enumerate(struct rpmi_clk_context *context,= u32 clkid) +{ + struct device *dev =3D context->dev; + unsigned long min_rate, max_rate; + union rpmi_clk_rates *rates; + struct rpmi_clk *rpmi_clk; + struct clk_init_data init =3D {}; + struct clk_hw *clk_hw; + int ret; + + rates =3D devm_kzalloc(dev, sizeof(union rpmi_clk_rates), GFP_KERNEL); + if (!rates) + return ERR_PTR(-ENOMEM); + + rpmi_clk =3D devm_kzalloc(dev, sizeof(struct rpmi_clk), GFP_KERNEL); + if (!rpmi_clk) + return ERR_PTR(-ENOMEM); + + rpmi_clk->context =3D context; + rpmi_clk->rates =3D rates; + + ret =3D 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 =3D 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 =3D CLK_GET_RATE_NOCACHE; + init.num_parents =3D 0; + init.ops =3D &rpmi_clk_ops; + init.name =3D rpmi_clk->name; + clk_hw =3D &rpmi_clk->hw; + clk_hw->init =3D &init; + + ret =3D 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 =3D=3D RPMI_CLK_DISCRETE) { + min_rate =3D rpmi_clk->rates->discrete[0]; + max_rate =3D rpmi_clk->rates->discrete[rpmi_clk->num_rates - 1]; + } else { + min_rate =3D rpmi_clk->rates->linear.min; + max_rate =3D 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 =3D &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 =3D devm_kzalloc(dev, sizeof(*context), GFP_KERNEL); + if (!context) + return -ENOMEM; + context->dev =3D dev; + platform_set_drvdata(pdev, context); + + /* Setup mailbox client */ + context->client.dev =3D context->dev; + context->client.rx_callback =3D NULL; + context->client.tx_block =3D false; + context->client.knows_txdone =3D true; + context->client.tx_tout =3D 0; + + /* Request mailbox channel */ + context->chan =3D 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 =3D 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 =3D 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 =3D 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 !=3D RPMI_SRVGRP_CLOCK) { + ret =3D 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 =3D 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 =3D 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 =3D 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 =3D msg.attr.value; + + /* Find-out number of clocks */ + num_clocks =3D rpmi_clk_get_num_clocks(context); + if (num_clocks < 1) { + ret =3D dev_err_probe(dev, -ENODEV, "No clocks found\n"); + goto fail_free_channel; + } + + /* Allocate clock data */ + clk_data =3D devm_kzalloc(dev, struct_size(clk_data, hws, num_clocks), + GFP_KERNEL); + if (!clk_data) { + ret =3D -ENOMEM; + goto fail_free_channel; + } + clk_data->num =3D num_clocks; + + /* Setup clock data */ + for (i =3D 0; i < clk_data->num; i++) { + hw_ptr =3D rpmi_clk_enumerate(context, i); + if (IS_ERR(hw_ptr)) { + ret =3D dev_err_probe(dev, PTR_ERR(hw_ptr), + "failed to register clk-%d\n", i); + goto fail_free_channel; + } + clk_data->hws[i] =3D hw_ptr; + } + + /* Register clock HW provider */ + ret =3D 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 =3D platform_get_drvdata(pdev); + + mbox_free_channel(context->chan); +} + +static const struct of_device_id rpmi_clk_of_match[] =3D { + { .compatible =3D "riscv,rpmi-clock" }, + { } +}; +MODULE_DEVICE_TABLE(of, rpmi_clk_of_match); + +static struct platform_driver rpmi_clk_driver =3D { + .driver =3D { + .name =3D "riscv-rpmi-clock", + .of_match_table =3D rpmi_clk_of_match, + }, + .probe =3D rpmi_clk_probe, + .remove =3D 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/mai= lbox/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) } } =20 +/** RPMI service group IDs */ +#define RPMI_SRVGRP_CLOCK 0x00008 + +/** RPMI clock service IDs */ +enum rpmi_clock_service_id { + RPMI_CLK_SRV_ENABLE_NOTIFICATION =3D 0x01, + RPMI_CLK_SRV_GET_NUM_CLOCKS =3D 0x02, + RPMI_CLK_SRV_GET_ATTRIBUTES =3D 0x03, + RPMI_CLK_SRV_GET_SUPPORTED_RATES =3D 0x04, + RPMI_CLK_SRV_SET_CONFIG =3D 0x05, + RPMI_CLK_SRV_GET_CONFIG =3D 0x06, + RPMI_CLK_SRV_SET_RATE =3D 0x07, + RPMI_CLK_SRV_GET_RATE =3D 0x08, + RPMI_CLK_SRV_ID_MAX_COUNT, +}; + /** RPMI linux mailbox attribute IDs */ enum rpmi_mbox_attribute_id { RPMI_MBOX_ATTR_SPEC_VERSION =3D 0, --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93C0A2045B2 for ; Mon, 3 Feb 2025 08:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572689; cv=none; b=pWg4A0xJcLOivc4w9dSDo0IJtMPUNSpVPRo6CCcjCjiZ9yRmSLOhlDqFP6Xy6vme667X06ZENCnlf0jQKgSol+AAuW6G47FqlQmRr3siULuwuOx5sWTS4t1+e5yxoFBxkJRI9oNE0Mt2qmbkda4+g00dqtWS5Xz5jaYYeaIcSHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572689; c=relaxed/simple; bh=jXo7IkWXMmnQanNQDO6EVHZ2aM7G0ET88p0IIgenlSc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uK90M5SsYiYeiQQSOZDyCdhKxgBZ6r8aV8p/7OxkzcHfKfmGQFIG+2zPz0gyRXQ1omupbR0xkcm+Qtw3by1TQ5bHRpZYQxdXssIMKjUlHTpbrb87H1Q/m8xQLdP0dn/5rL3UkDfGEnOl/Kf14PXsMP7o8tu0eil3Rz6MDRXKqaA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=UePnpHCJ; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="UePnpHCJ" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-4679eacf25cso26960821cf.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=vger.kernel.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=UePnpHCJpTMtctB4TlIhrd3K6JvkmYBWEE081Lli4mRaZO9oB6inJiND4HsEH78wEW itW+Phg7unlOGaMP10zOyWXAF7LGG8rVoGmYLHUO0Ok20bymp/YjWrvdACHOK2cFzCDD DnRECR1GHBY5nRkxSRPh9D5aSIMK7Q6xcGjlqGVOrhbZ8ZwKyxNa1S788otNI3QgbLzR j3Vs4n59Oz3ztxRSvLMX0KM9ndUWAjZ0/AqhJV7kgXjRruy4g6JaUw2yw3ET87LcQMOL +Olt/5kQlStFClO2mMQAcMn5ZXDtdIbVTKcEkjbjA41QHyJ8j4sPIZ7yhGi00wntLk+Q 93aQ== 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=NSXAMrETvG5NXZyYPPTxgtWT//muikUcoiC0J3rBy9/2p8MGwBvmGwztakCGJCSt5U tSJxG3GLKe/O+hGkedJGGMsfGbkNLk5rMmDZjKAKErQNuwMYvoDfSqirZMWKl8oF+ho0 98kEqcwoM33dk+WD8v1FMZOuO9tKFdMzWdSaJuc4hXIBGbWSJc81PeR2ObzfCcM/Ca7r PETAk0zx1T93hs8fxu9sIncW9YcMZjSwDPFXppeDfA6QbMbq8clvdW06sweO2UpVijWs entVSheWH/OGz8vfih1P7A6duFbKwkNMqrXL3/La2vq94R2FzLaLpHVypuPZnUxcpiAy siog== X-Forwarded-Encrypted: i=1; AJvYcCXgF4fsgCDHEM8FBEg2m/CDyi8KAAQ2t975DQzBtDKrcrOfD9Q8T2zBe/Le9iFvxfO5ZLdiplC0qw632j0=@vger.kernel.org X-Gm-Message-State: AOJu0YyHaG3yVEkrUU9fBWWrQXsC8FV4JCu5wzjsWj8GVEEm/CkLQjXR ejS9szg401o+BF9MXq/jlJaizoYoMCLaKqle9OU/TWxqm4xCe4Sj8E2iYIr5UJk= X-Gm-Gg: ASbGncsB06Ig491PxoF9DeJangnk6TqZwhrajYKy2CmR5zCo3LLqQJKtopMpZCTAqAO Qg6X5E1nkHX01fI7ZdswinPo/wlWsSTCRZAIikxxSUDunMu/libxl2iyK+/jneDJqIJ+aYk/Qnh sK6YXyqg+SDDdY8kInEa5WIe1Ls1GDLCa5ymIc0bTDMGdL5rQNVmHTnvRQdqLvOEA9Y/ViRxf2z ztpDowMMQN9asBNYsd3vDv6dbQ3oxviU6tUcbzI+GH/ZHR1cDXSPAdxnYsCbmP4+Jr1U0WNdspj 0jyZccpCxp94N/o43hnP5lr2akn1ugL4U/vhd/VA/no+8Zl7IAIWh7Y= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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,r= pmi-system-msi.yaml b/Documentation/devicetree/bindings/interrupt-controlle= r/riscv,rpmi-system-msi.yaml new file mode 100644 index 000000000000..e6c297e66c99 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/riscv,rpmi-sys= tem-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. + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + References + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + [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 prox= y. + + 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 =3D "riscv,sbi-mpxy-mbox"; + #mbox-cells =3D <2>; + }; + rpmi_sysmsi_intc: interrupt-controller { + compatible =3D "riscv,rpmi-system-msi"; + mboxes =3D <&mpxy_mbox 0x2000 0x0>; + msi-parent =3D <&imsic_slevel>; + interrupt-controller; + #interrupt-cells =3D <1>; + }; +... --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D8561FCCFB for ; Mon, 3 Feb 2025 08:51:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572701; cv=none; b=rcBv+Is1RqBwq+f884iQV9Z3JwWnnu7jboGoG/pDM37Byp2QWJHb+1J8jodVy7RR2HP4uc+f83JIkr7hYXZlcXVt2teK/+Rh8DxoWKUVgnzWML1SAujWOmagyRB0ISgI5zJwQaMmOz5iSns56zOH0Wy3eOOggG0aCdojf8STi0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572701; c=relaxed/simple; bh=ooOT2rKH01xRVfhY+LiqQ3NcHKveDaejDZwyLiH3c8w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=svDRU8A1TxowZOYKKucZq5qcKDJnDuLScz4fN1ikmZ+IBWTJXZMK982mkAobW4DGEOCip3NhSDZFKIVc6WjeuFis2FetGnfJOioBwhGo0VEY271gSDtF4Cr9QFONzCbLhqVYLcVmZtrGZgw17x807ZSJ2rsotind7Tb+FpBf5RA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=VAawBuQ/; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="VAawBuQ/" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-46b1d40ac6bso35427471cf.0 for ; Mon, 03 Feb 2025 00:51:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738572698; x=1739177498; darn=vger.kernel.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=VAawBuQ/Issl2K3JgPf+lQDI15527dwg3oiG7YLxnYBM/SHVwt8u39/3RWi5ChGw3W kYGktmkRvVbpMozvwAQeGW9DvVK2iut86BIrsXDaQFfcFW542xUl4lV0CPphd5MCSWHw c9cAWl+Evy6syUpSNMZe/VVfhsN9DgsbW4py6rSz1JG+fZfd1e9B46i+mfr43hwYbBVE g3Qj3hHGPewOkt5IDmfnmlQ1SosKAa3Ed6g8/K4GfMNswdDSjQAU662UnnbhiAjG1+j4 FXkzpVyjY6lC1L0iLHhnye5P/2IMeHvbL1JWXcjWYmSBUqxxmGzmO3IOG020xg/PGuz0 DvQA== 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=iPOUm9LCabLuqhRHa+oaU7DsL/WhumD4tTkH/zmo0nOYQ9hFZYP5ma6UeY/7HSTIYf 1KJcocd//pW6SskUBTLc9BArpfc04aKKmSoUCB4cdc8Ks0LU3T4fOrOf+0GzxCPJZO0N 4tpXpXvUTWikT8AQRI31nEzWifsQskR94s4yI0LfqdfBKPKBD87UTrm7BIv3eZRBrpNA ApuZeWlFgvpgqge8rTJcykbP0VTl1TOVb/2Lg6+9c+9UhWANXo8aWl2kGatTy7hWyD15 e1aex7Xm/rJptNEUFQ2Ru6TgVDVWXhBtL6ysN79jbGYIwW8W4t+IrJdO54k5HeP8BhXz VIQQ== X-Forwarded-Encrypted: i=1; AJvYcCVM5mtyvhER5lHZitTJjs/xv0lMmurfHWi6CRrf6Bs9bDZqiKs7SJpX9eT/IUTEleIgWJmdHh7Ya/4b2zc=@vger.kernel.org X-Gm-Message-State: AOJu0YywX4YsBMcYTf0/AVo1hZjlBCfGK4zgTqSlUjkypn2FI4WAM8LA OwAYliY+ypP8Z4CtOQZycmNJ/yx85va9u1Xm3PwDWER+2UkrKzsKdpBSsJKdPog= X-Gm-Gg: ASbGncsHX7lSIsioVyX/ib6iat/QnbAMcITp9tuvmHJLnLlBxVUAExAC1AMOV0OREz3 4H0JOrzRQOD0KbUXNk8kDvrzp1ABN88uvyLHN2TJkH+34h//UO1uFTXmpbIGknI3ShRQ45SdWxc Y6w+JfHR7RLqzMBONycB1jgPqqT+CWcBDckGKuDsZtPpkufoHFYEyYSe1U3vYVzeRBjt5ABIJns zzCRgwfLkKJLV35BnVImZUgc0E51weXL0jxhq4YfZVoqtgZTPgXJgLXGmTA3Zjd+F80FXaDqZ32 IzRNO6i/74sWCzK9wxPBxMxo7vUOCOKv5LGIlywQbK72+YfuwvU0kE4= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 +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) +=3D irq-riscv-intc.o obj-$(CONFIG_RISCV_APLIC) +=3D irq-riscv-aplic-main.o irq-riscv-aplic-dir= ect.o obj-$(CONFIG_RISCV_APLIC_MSI) +=3D irq-riscv-aplic-msi.o obj-$(CONFIG_RISCV_IMSIC) +=3D irq-riscv-imsic-state.o irq-riscv-imsic-ea= rly.o irq-riscv-imsic-platform.o +obj-$(CONFIG_RISCV_RPMI_SYSMSI) +=3D irq-riscv-rpmi-sysmsi.o obj-$(CONFIG_SIFIVE_PLIC) +=3D irq-sifive-plic.o obj-$(CONFIG_STARFIVE_JH8100_INTC) +=3D irq-starfive-jh8100-intc.o obj-$(CONFIG_THEAD_C900_ACLINT_SSWI) +=3D 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 =3D 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 =3D sys_msi_index; + tx.sys_msi_state =3D sys_msi_state; + rpmi_mbox_init_send_with_response(&msg, RPMI_SYSMSI_SRV_SET_MSI_STATE, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret =3D 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_ENAB= LE) + +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 =3D sys_msi_index; + tx.sys_msi_address_low =3D m->address_lo; + tx.sys_msi_address_high =3D m->address_hi; + tx.sys_msi_data =3D m->data; + rpmi_mbox_init_send_with_response(&msg, RPMI_SYSMSI_SRV_SET_MSI_TARGET, + &tx, sizeof(tx), &rx, sizeof(rx)); + ret =3D 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 =3D irq_data_get_irq_chip_data(d); + int ret; + + ret =3D 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 =3D irq_data_get_irq_chip_data(d); + int ret; + + irq_chip_unmask_parent(d); + ret =3D 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 =3D 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 =3D 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 *d= esc) +{ + arg->desc =3D desc; + arg->hwirq =3D (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 =3D d->host_data; + struct rpmi_sysmsi_priv *priv =3D info->data; + + if (WARN_ON(fwspec->param_count < 1)) + return -EINVAL; + + /* For DT, gsi_base is always zero. */ + *hwirq =3D fwspec->param[0] - priv->gsi_base; + *type =3D IRQ_TYPE_NONE; + return 0; +} + +static const struct msi_domain_template rpmi_sysmsi_template =3D { + .chip =3D { + .name =3D "RPMI-SYSMSI", + .irq_mask =3D rpmi_sysmsi_irq_mask, + .irq_unmask =3D rpmi_sysmsi_irq_unmask, +#ifdef CONFIG_SMP + .irq_set_affinity =3D irq_chip_set_affinity_parent, +#endif + .irq_write_msi_msg =3D rpmi_sysmsi_write_msg, + .flags =3D IRQCHIP_SET_TYPE_MASKED | + IRQCHIP_SKIP_SET_WAKE | + IRQCHIP_MASK_ON_SUSPEND, + }, + + .ops =3D { + .set_desc =3D rpmi_sysmsi_set_desc, + .msi_translate =3D rpmi_sysmsi_translate, + }, + + .info =3D { + .bus_token =3D DOMAIN_BUS_WIRED_TO_MSI, + .flags =3D MSI_FLAG_USE_DEV_FWNODE, + .handler =3D handle_simple_irq, + .handler_name =3D "simple", + }, +}; + +static int rpmi_sysmsi_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct rpmi_sysmsi_priv *priv; + int rc; + + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + priv->dev =3D dev; + platform_set_drvdata(pdev, priv); + + /* Setup mailbox client */ + priv->client.dev =3D priv->dev; + priv->client.rx_callback =3D NULL; + priv->client.tx_block =3D false; + priv->client.knows_txdone =3D true; + priv->client.tx_tout =3D 0; + + /* Request mailbox channel */ + priv->chan =3D mbox_request_channel(&priv->client, 0); + if (IS_ERR(priv->chan)) + return PTR_ERR(priv->chan); + + /* Get number of system MSIs */ + rc =3D 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 =3D 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[] =3D { + { .compatible =3D "riscv,rpmi-system-msi" }, + {} +}; + +static struct platform_driver rpmi_sysmsi_driver =3D { + .driver =3D { + .name =3D "rpmi-sysmsi", + .of_match_table =3D rpmi_sysmsi_match, + }, + .probe =3D rpmi_sysmsi_probe, +}; +builtin_platform_driver(rpmi_sysmsi_driver); diff --git a/include/linux/mailbox/riscv-rpmi-message.h b/include/linux/mai= lbox/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) } =20 /** RPMI service group IDs */ +#define RPMI_SRVGRP_SYSTEM_MSI 0x00002 #define RPMI_SRVGRP_CLOCK 0x00008 =20 /** RPMI clock service IDs */ @@ -105,6 +106,18 @@ enum rpmi_clock_service_id { RPMI_CLK_SRV_ID_MAX_COUNT, }; =20 +/** RPMI system MSI service IDs */ +enum rpmi_sysmsi_service_id { + RPMI_SYSMSI_SRV_ENABLE_NOTIFICATION =3D 0x01, + RPMI_SYSMSI_SRV_GET_ATTRIBUTES =3D 0x2, + RPMI_SYSMSI_SRV_GET_MSI_ATTRIBUTES =3D 0x3, + RPMI_SYSMSI_SRV_SET_MSI_STATE =3D 0x4, + RPMI_SYSMSI_SRV_GET_MSI_STATE =3D 0x5, + RPMI_SYSMSI_SRV_SET_MSI_TARGET =3D 0x6, + RPMI_SYSMSI_SRV_GET_MSI_TARGET =3D 0x7, + RPMI_SYSMSI_SRV_ID_MAX_COUNT, +}; + /** RPMI linux mailbox attribute IDs */ enum rpmi_mbox_attribute_id { RPMI_MBOX_ATTR_SPEC_VERSION =3D 0, --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95F991FCCFB for ; Mon, 3 Feb 2025 08:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572713; cv=none; b=oB7mq8g7MzmNTu7IL5CZrIGxvldk6vbJdbnAecTuAN6Ss7Lp+JfPEOoXTZKdTssY9Trtcf2PrsrDvlpKJCjoTiJQYNmjMvrbBvcV/XwME4KGJfUfIv8lCpOE992nXyqu4zfIS8Iq1tOpGfQaFLm41YNhq4/JY8QkVL+U6hrA0jQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572713; c=relaxed/simple; bh=wtPyGsOnqo6rqZA5cXIzoByAuggYFekUK7cyyDI+8fs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IUu08fIx9dQuZ8+gD5w0p8oiDMeeFYVrJfhElg/EpNX5cFthkX7RSqHTTVLDGyP+J08dbfaFOar+ddxFRgFM0lLSZnsteDP2FKZOQLChCe/bwalYDnJGeO3QHBQ3SrwdYtdfIqeEjNvtQir8z2OjjHFo1asRULkemM5ARJOZwdg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=dfOT3F22; arc=none smtp.client-ip=209.85.160.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="dfOT3F22" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-46c8474d8f6so31698981cf.3 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=vger.kernel.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=dfOT3F22kpPkp+a2O3Lg9rA+CWoyG0fKLGyh+C2JVXBLC4djr7VQNqdwshOZrsrsnc HaAog7Aw5rjKcf0qVVGLOMgjlsfzXAozRtblaMIISzv0d8wTBIJYi0lMgyV6NYbTT+MI 8tL5kQDXkcxmYhxwjdrv195Z3dwqokNuyRAtnqjq2OkxUUI3/ZxQQMlRzpV+HkUv02Ef VBCGQ9++2+qJoDP6SUwPZAEjmZsNMSzEzZke+sY4PNMWIkbveULUtntVe25IFYABQJI6 zpCGJ9DiRhlvE/IJV/ESfMw843DnYdnU7SccbXR3p8VgfwZK7psLYSBohnTPv5Px/HHZ LgAg== 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=QT/ackXkg3H+jK6mfSix8y5VQuR1YooaGBygoplklbGYrsjmVBO0vKkxaQLJzAUxI6 d+3SeKD7twrzV+sgE72KyDjc2k6AsuZgAfGO6ZBMe6ejsiTg1sEoZN0EdYQancwGi6Fm pG3s+oDSd9Vs+dfR5P4mnXNu+KzeBQCz9MKPyh32cvsKpcAxJnnHuHE2M61EDLvHwCoZ 6onpKfqAKUrhks/CgvrcqZfgqr1oE/ENGLZ084tGxlqLIvPbaaC3jfhTqQUeMhdwFUI+ KVGOq7DgLTDIfFY+3AUwgt31276Fy7B0C6Hrz0mxrhxkknJgbB6XGjHxilXrHv18K2g8 ki/A== X-Forwarded-Encrypted: i=1; AJvYcCX9yQ/u4h7u/GLBmwL75zGIjZgLmyRHlrIg6G0oq9s/e1SMFtTgvd5/TMAW6YCJ073ZWbQdmqrTEgIDuII=@vger.kernel.org X-Gm-Message-State: AOJu0YwsFepBq9y86hwf9G9EN8RTs+rtgHiLiMQ/WdDjuXMy5z36fxvH 8rvDMkA95QK8tAHa+HfkWYW3n6dsVreeMyF41syJkqe4qohbM7qgn/m5IlI2mPA= X-Gm-Gg: ASbGncvw/Lp3tdHGGGcHB0PISJY5fg8PJdOIk8rNKF9+k3igTnvr/i2RujaQL7MkiQj 5Ujep6gH7gWPY4WC7h+lyqptdo/gckS/lBoxQ4qlM2jfyBPm8gJZ558+e6VjCHRXIQY6BE5W7MT UWPukE8tQimYGHZuweTu5Pb0BV9wzvSVa2YRIeSuOxA7s0fNBT4TZ5b6KDpgUOLCby5oNOYgTNv Yev1RmbaSOZyT1KiGMeeZz516iXRkt/+1K8ZZ/MAc9RKsB2DkIPCV4qnVqlAt+FSYzY+y+NFHUu 8xTZseK6Phh1AcNd470PmUfjkmSbBYRoUqZ2SmMy59R+9PbUCNEG8GI= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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(cons= t 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(co= nst 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_ar= gs, 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 =3D 0; =20 @@ -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 =3D to_acpi_device_node(ref_fwnode); + if (!acpi_dev_get_property(ref_adev, nargs_prop, + ACPI_TYPE_INTEGER, &obj)) { + num_args =3D obj->integer.value; + } + } =20 element++; =20 @@ -1565,7 +1576,7 @@ acpi_fwnode_get_reference_args(const struct fwnode_ha= ndle *fwnode, struct fwnode_reference_args *args) { return __acpi_node_get_property_reference(fwnode, prop, index, - args_count, args); + nargs_prop, args_count, args); } =20 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_hand= le *fwnode, int ret; =20 memset(&args, 0, sizeof(args)); - ret =3D __acpi_node_get_property_reference(fwnode, propname, index, 3, + ret =3D __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 f= wnode_handle *fwnode) =20 memset(&args, 0, sizeof(args)); =20 - ret =3D __acpi_node_get_property_reference(fwnode, "pwms", 0, 3, &args); + ret =3D __acpi_node_get_property_reference(fwnode, "pwms", 0, NULL, 3, &a= rgs); if (ret < 0) return ERR_PTR(ret); =20 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_d= evice *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); =20 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); } =20 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_d= evice *adev, =20 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; } --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5748B1FCD03 for ; Mon, 3 Feb 2025 08:52:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572726; cv=none; b=cZxNMcjwHLOXXnRjmeQbkzgqGEdzpU2nkoXfbwxW5nvC4sb3yzbCHrkrsrPz9DMxD1FQ4L4WUtIu95ignV6jojmf/NUomdd/AHCsnlDF5Av1oRVvFh55veKrPuyTlYGV8+BmnWd4a63edl1XqgRAjZGcBNSqbybugmaMCdVAdP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572726; c=relaxed/simple; bh=DJLPtY9fSqVBTgjSnM4FsYGiupFf6DQ6YZNtl53ByuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X1sFEglQC34VMxqqrauFZ6YohtUSpEzRJh/w4MHdUcOIgGU+yhczekbBRhPucJOLi97Knb6M1cn4NTWd+4DsEY7NJnE9Lmmkw1zlwJG9FX7mqO/VxPxwQVjiIHa95QSeyzBidei+3chv3eDLS42MtF6RVxG9AzzmkzHrBJ8uR+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=QHD2r9Kh; arc=none smtp.client-ip=209.85.160.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="QHD2r9Kh" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-4678afeb133so44182881cf.0 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=vger.kernel.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=QHD2r9KhgzYkpj+Ek3lp23DEggbnvfBWsrkIBgs+4F2MatGM69ZlCUJ2TI/ZHwO5kc tPrY1WKHAj+EGj/eyZDOptlXagzEgbfjJ8coXuMHPKHyATSgRPXR6foaYSsNWjbiD/Sd V2CHLFjMEFbuPjMFjCZjx+u3GRA19FrPwQtg/F8Mw2AHTrWCzBm9KSY/MnujKEk672x3 ieL3VFHElVkAPQjzLSQbizfVLhlXzkJll4c25fHPMjbIdDf46BufXOyhzahSkjk5Oo/j T2e4c+1PZuCmQVhAEWQeKBT3PUIR2KXHxaZGiq0R+iNANuFOQln6ITAdkkZcRisqfj6X Hd4w== 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=ciI40lAOOzsC71SK5GbtWIg0jOeMVXXUds60bU+zdtfVF6if/DSUy1+UGSQREDtXyH k9FPx/MRzNzlWhrTfWb6laQsj9kNlSx+Vdl+Q3pgncntAVlFW8fm0FeL+huH8EFfmw74 zRkmEp4xVc9kmM9BgC8RN+S/u4u9K8uPbdhaElpFf7o6xChHzHBiJG2zUvIQeSQkSlM8 KziJpbGc6fQxQ0pYymaArNpAoPTl01x/sAUSNQOPdfz7KuM4jy+AFDEeSC185YYWzD4u N7xkCZBMdre5qhEBN9n2Uk0tlWTo6YEK+t9scIx5S2JK72i0wCQm+vidGg8aeBfcWqfp PYEw== X-Forwarded-Encrypted: i=1; AJvYcCWUeEGLCLscxkCsbwETCnkMRWjKnIup7/wmTznnc8PNmNJOaF+9mOfnAJZgtBx7tv4m2WT6L7SkuyJQviQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3IXwjHtoZudLRQvqcbCVJ2VJBnm9LEb+c/oD/3VkSAqAXFuhQ J+zpDIPb09wcwK435Sgq22WWWrO7c7lLu4Foq3k/7jQVVt0R0HWBkFGAV1AEWLY= X-Gm-Gg: ASbGncvl6DW7RgYvOn45kaY9DK31x+vc/Xf2KN1SpUlYrMI7g9wKMvlZTbgfP3hIzTn l3GwVTSNRM1+DVRzN87OQzo5C9+K7NzFJypmUm5azf39F1wdo4F92qL+oIMnWmYq4RcSjVi5dTx 5VZer+uDLjvZ7e/c6CTG11nOSm6z6kxhDUM73QIjPfrvSS3lpQb4AbIWOt+PmJtXNHJE6dZYUTt /qhbH9uBbYxuyqUzkJag5uGJVRCDRh9htBT69jkUfHVJ2Cwf86MBpGOiycrObXO6BHcFVKPJO/8 FjXfaXq42Ab8yjuuQVOblKrVMQGfdlwUD0D8WSyLurjO//zlH8uKPrk= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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[] =3D { "INTC10CF", /* IVSC (MTL) driver must be loaded to allow i2c access to ca= mera 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 }; --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D2E91FC118 for ; Mon, 3 Feb 2025 08:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572738; cv=none; b=eaZG04gy5ApEVMugRbedXiiY9sY1REBQV/1VBxhRBcj8LNvydY5GjBh72G9iDAgJgGtCPmPYbI24Jway7QDx2cbIq+Y9rDGePfCXzITar3eItxJLccRvPHBXIgjBvDzKIw3PrCdfYLCLLuXoaHmGjd+/Z9F7fLBkwjWvbLOqc9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572738; c=relaxed/simple; bh=XvE6Vcit10jj+EGi7W0UE9JcLMFnOwfkX8uYHZdyz0U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gxEN6KlGszfpVw+sXdIMBvUew9iVBMxnySQYKHP1wgwphVFwkvHQhtrx3esMZbVXp6QX7adQRAFpuSmejHqm88zgCZBpyBi+woY47ta7K5CYeevefj/u/hFJJA+67/3vcr5X9O/UXaE6AxIOFOR9+ZrXg1SzGJ+jzYx0wAkMN2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=QfoqgTyz; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="QfoqgTyz" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-4679eacf25cso26964831cf.3 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=vger.kernel.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=QfoqgTyzLrOvVtcHhcX92iOfZ3EAVZX9HJ575jqQdzqlYeNGNb/OUa249VRxtu/zy6 meIz/rHELUHMZvIY0tHu/9w/jLdrbyV1iBV7iOku0GBrljU6n/pSoQYBrMZZoGQJk3A7 n8WofZup43BaUxXe6w5GKeIPp2xYBSsq+V73937mNnR8Qc0vxwgqbSRn4MIa/NbmFW9L IuzdSax+ffAD39SW8O1PTLWr/6R8ENAc/eF2xdsfH4nFpRu2R2usru0kmw7NOOfYqfDa LxOOHZo8kFBX722Q6lvThAHkgfUWmSKIRJd52SXDAD14IWy51YmzXawQc1KuGl9lv2jF M4Uw== 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=dHMyf+5vclbpTUb9h7Q6HHnB/qWs7t9UFG4dj9vsC1GcJLH3DAsHl9XvRIQKSoBu9i ZpZ7zTGYvdNMnT3A8MRCSekb9Mhc0CxS61FMu+3lmrk9xPqW3cIRUH0I5l7vg181m7+E AXhFbTMsTfdH12YUVykSvX2951UKrSiQOLLYF0E2mXd+CSA1lObMDtXo0LZ3oWCjnySh bNKVpdroJyEup7/koNhGx+xzRFXB2ko3RLPDpV8oJ71FM5LcHyEPFYL9mt+Pq24YhQQk MTXqN/gsrEBNxPenHzSTSihO/wqd7AIJN762Ovv1X3zFm4kDi409LFsBIpn+Dvd2fLgI CGVw== X-Forwarded-Encrypted: i=1; AJvYcCXsg5l7OWUAVnaRHdAc+UiRilyOHhkk5TNt6DtQwb8PxYBpy2pxncuYdHry4sAbehR1uaNDtqGOS21OK0A=@vger.kernel.org X-Gm-Message-State: AOJu0YywYqExn1UNtFFcQNKc8pqzsxyhbi7YmEWLNgBofzf7IbpjS3Nh BNkzxXgV73F8tztlGXmyr4af/oEjVg/pzyA0NCWpYPQI5mzpuHdSq2N7Sf4Bre0= X-Gm-Gg: ASbGncvsvPA3vRA54dFh4Z9sawP1MQ7vLcAPCdDMqqwa/ZjreVLluLBg9YHA5214V+M YUE01GswAMO7dCvsCo0iLFhhKaJI20tkHR/ia3qrNGcSBZ/T5vSjgv84eqpYm7iHuIjXZ60rtkx I4YX1IZBGAmZPc2GlnraaGHwNT93vxLKS5eIS12S0uHadvSWhIRnrHq6AFbavIHWzT+6uhw8OXL U8TqT3sRzwH4+FtU4ipqBWrn2EYkr27cLEzrgv2jTuBjSYwB5S7apW+JNRWLLiPKiltoDr6RcXW 5qMn6F4C7LhBcxXppVc7EleHcjHXNkwmWtWe1q6x97y9cYrPE2WDn+Y= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D 0x01, ACPI_RISCV_IRQCHIP_PLIC =3D 0x02, ACPI_RISCV_IRQCHIP_APLIC =3D 0x03, + ACPI_RISCV_IRQCHIP_SMSI =3D 0x04, }; =20 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; } =20 +static acpi_status __init riscv_acpi_create_gsi_map_smsi(acpi_handle handl= e, 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 =3D 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 =3D 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, u3= 2 level, void *context, void **return_value) { @@ -183,6 +213,9 @@ void __init riscv_acpi_init_gsi_mapping(void) =20 if (acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, riscv_acpi_aplic_parse_ma= dt, 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); } =20 static acpi_handle riscv_acpi_get_gsi_handle(u32 gsi) --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5172F1FE47D for ; Mon, 3 Feb 2025 08:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572749; cv=none; b=lO204Dxbf8QEvLIP9U+Wjqr3sxm2YVnQR35JGgCaxTIxV40psn89D1F028k9Xy28JIXrouJQtTwuYapAY5BxYN4Q6zfWmbeyesW0J9V8FHUfLeO7QeVP7qsGU956/h9JSz1brsXXc3zU6vrHQRKtgC/A8toOsuKGpULK7amFoJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572749; c=relaxed/simple; bh=bNb2YKEFylNNDD7bzm+MM1t8jVyNKnLY+GSkRRkWRu8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZNBauAfeqyu+Hb0HYC7q7HkWRz/cUEJuDND1YOdr6ZPwwfSn4FuqHQ40xACn4efOolXX7iLAStSQyI0G89ZNaEaT5FUAAsz1czMEwdTN7VgWwRRRpeYbA00nHEM0IbaCthdrZoLMLHskQ50O9ODHCnZHiSrankPHe+sBGz+emQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=FgZAcEVZ; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="FgZAcEVZ" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-4679d366adeso36839771cf.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=vger.kernel.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=FgZAcEVZ2cpnNGnOIVgbPzPhDFCpKwfbm2tdrG7UIJv4je6Qejwoef1QISuMKCUCRn ECS3QOU+EuYhT6S1mYs5i31LBNnE7pWLZb2IyTpavUDZ8z2dGBlbaIlqd4zMOu4QXrYt BhrDrfTv+oKaEZvZrn9PjXhmRTN9X0v5sr3i2rBDX1/v0SGAuT112RlHHkfoMYIcqIQD 73ynV5nMNhgAhT8guLj27ZHiaxp5YFwwavkusPoCh/8lHoaHM7Ogaa4ZcQTH5CrOjjMh Xy20oKMosDdDLko7qDRAgHtG0ZT15q/jrp2jL+UKM1mN8CuxIwjbsxyYZF2pnDH36GoM MsyQ== 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=kotI0Hh7xFcpOlWjhBQay6miD/JDqbNOeNpoPhNAR2amuy4klHq9ceUHZGQxXgoJBu pjLPBP0TWXsCzapG7EFtK+Mbs5f5pxC1mHy5rJXuSz+QW3J/XxtypkEWXybNJcMw0Jbh 9VGR28cvQaNzf5zClEYJNFYNMQd5REws0LPEz0gOvr3PM83UQFBSUzz30SSytFRxqZpB q/fiHYDg1lP6UNgCd9hc8XGQITDGcRUA3KhANpU8W2CuBaVg3xCfkIbcCbF9SsI05v9c ClweWwiY5kbqUAiar+T82Zro/W6hnZeVDQZKDGRlyRoKLCedDCtKc1LXUm1QfgiH16Kz xn3g== X-Forwarded-Encrypted: i=1; AJvYcCVYqtYwku8WcwTfPWvTUBpWZctCYDqly/vUxBPUB6TDAbtHBAo+/bA6YoWpikHP/yiWuSTY+FBjmK92aIo=@vger.kernel.org X-Gm-Message-State: AOJu0YxqoHkRAQSP9JtUnQGfneGwtFNvP8MLXhilgFcOl3H7oMBmKowj NJOtR4XTT/cv7wogyJ2o5g5yx6M8I8m+aQs80QX8SZsmhFbXbxjUyrPwZ4oIQuQ= X-Gm-Gg: ASbGncuuc4KxOQAoKtL4lEPkgYVpIfbe2fZr46bRDDkJERKOoWwEmaFDATa8G7RuFLs KjuWorf3rTWTdDwVCmPZ6zVoA5NzsTPqJMLl0UFtTFw+zPgaPi1/NDalT2IJ1GGHcxDf9dlMdEd z18sGi/XNi0QQoEgrINXeVAUeqGxAuAr7oERMbPX4T6DF4Xf6FG7PWbCjBBKQbmrH8gk1916p42 68VV2UuDM4EZ2qAIRmq1xOqi76eRNOxLJdvP5rRzBM41H66DkSx5gxMuH+BYpsiWuCWUZFkVzab GaerR0Qd+pj2479WJ6vlwbEtqfkReRFs6pg9EduNkLIjUSXO7qSz3Ko= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. */ =20 +#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 *pde= v) * 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 =3D irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + if (msi_domain) + dev_set_msi_domain(dev, msi_domain); + } } =20 /* Setup MSIs for mailbox (if required) */ @@ -970,6 +980,10 @@ static int mpxy_mbox_probe(struct platform_device *pde= v) return rc; } =20 +#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[= ] =3D { }; MODULE_DEVICE_TABLE(of, mpxy_mbox_of_match); =20 +#ifdef CONFIG_ACPI +static const struct acpi_device_id mpxy_mbox_acpi_match[] =3D { + { "RSCV0005", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, mpxy_mbox_acpi_match); +#endif + static struct platform_driver mpxy_mbox_driver =3D { .driver =3D { .name =3D "riscv-sbi-mpxy-mbox", .of_match_table =3D mpxy_mbox_of_match, + .acpi_match_table =3D ACPI_PTR(mpxy_mbox_acpi_match), }, .probe =3D mpxy_mbox_probe, .remove =3D mpxy_mbox_remove, --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 448971FE47D for ; Mon, 3 Feb 2025 08:52:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572761; cv=none; b=c8iGbvrwHJTY6zGTf4duWsV4lLSaOGReWa3x9HX1Agbtuj5WwjnEcBMqmeuHoJEY26m16Yz6OHM8/LcgcEGPhT6ku75eKBp6LqbkXwcpRDiNxrOLGk5YenGUK0PPyBKZNZfpiBahxtKwitPUW54wjovNJDYUz2rb+8wzI+mQIkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572761; c=relaxed/simple; bh=UfWFl+WiF9wnff9ghcAYXQF0BAfAo8SLYSUuLg3w0YA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QiHg8syTvN+WOlllDyA3/FfHk5asdOHFmlw7K0xseb+QnxbIGMvBzQFd48AHCtT6pI8dAT/F4m3EjJSRH55Jd6V4v4M065yKSOAi5md5L9OZt8PczQ4kzVs5wmfyiYvuBfj00ZV1jB1qIXA35bYb4iw+S1oOWsRHneiw0kLZN8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=XBegWBXx; arc=none smtp.client-ip=209.85.160.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="XBegWBXx" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-46c8474d8daso30064581cf.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=vger.kernel.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=XBegWBXx4f7ewx3i5gr5Ehb6or6t6WJN33pqhdut/6stElAgOHoRKiI1uUc0ZbORg1 VTUGRfBwRz73ERF7mAgbzwN5AjPIJr6AwOUNjOVC7EHUMu8vWipW7XyLqePdpC4QYu5Z XHGOvcyZoZGK0o+L3EFEcCsVofJS3XhpBe1GLWk2K93OQzdYFNE9BNwKwiNVzt7oDUID JOJCGLCVAWHzfE+Nj5cJt+iThZ3yhrpUo5r1G7Xa2OuT1AoI9Cp3DGmgdDqRyy7994uM VxFVemk/hqL6je3nnQHGiaK8Nl8aPsTynTs4T1FaTghQhO7KNxNJ7Wer7pJAJL0V0TYJ RBTA== 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=M4Uq0BKPIQTIu+QQVBhnhFPAKIkunrizWG5CizLNlbino726X7wz4yB2g7dZizzdIR XP46df1HMfRTwL0g879yKOVcNpzEnpXPR3FN774VOadru9JpStNi4PCDwEtapxCQ00Ao mJeMwYmddslNiULs7xXCFTbx7XTs51aFS13L5TwSSgP1yJWug940srQYJXpqYo11tGN4 IsOE/ia7QcM4VJy/x3W8Iyo/jBrlNZR5fYOht1ErTFJBaG8BrqpWsTq58Fbw2jAfwZXd ysMB4V/3QYNKAIOflvZXMPmYl0rRbDK4W6kTK9LaPjuDeuu7ZJ7hZ1YyRWA2EjlFrwdb LKJA== X-Forwarded-Encrypted: i=1; AJvYcCUYQRhTh2Tey8TT6SjC0EuaKwedKDoslz89g8o4JeC9aa3mZys10YXsccrau3yuOHUVnxTV1D4cb2CEA+s=@vger.kernel.org X-Gm-Message-State: AOJu0YzSUxw6jvkVnGOg0PMblmX1ci47SnncYTNouICtOG5QS3uwSgEC LqDUrYxJIuAGsihI2CcRA+daaKdssjkaUnzX6NfO/mmLHGKdMalC1OvwXTZLHnQ= X-Gm-Gg: ASbGncuDUwNB9nHL6wuidZ78en7bA5AVidDHZesJqsyipZSO7HpbHc8oQYoN4iKIr42 RbxuZs9V20CxOTOu+XzBkLnElgGUhv7+BE3WiITO3ueUBpOFiIlX9Xntvnuh3Rnid4pcjihsRrC 1qDbiw9+i05IzLFZv88WT1daVqF/2oF8q8SS6XR9Y0rKxF5/NyT60CaSIJKba1Aue39Qa1vVFNo oEFpuRAI9ngaW2Wnu4PznRB1gYjYGVopB3/3JE+UxsyXvdP7wtew3J6snhl6X85wXpmLZJyJFP9 +Hdcv7tmVmelH8D9YhbWuDSlRI9o1m9B9qTp+sV52xFuyHNtRQ1fGIA= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 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 *pd= ev) { struct device *dev =3D &pdev->dev; struct rpmi_sysmsi_priv *priv; + u32 id; int rc; =20 priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -223,6 +225,15 @@ static int rpmi_sysmsi_probe(struct platform_device *p= dev) priv->dev =3D dev; platform_set_drvdata(pdev, priv); =20 + if (!is_of_node(dev->fwnode)) { + rc =3D 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 =3D priv->dev; priv->client.rx_callback =3D NULL; @@ -252,8 +263,16 @@ static int rpmi_sysmsi_probe(struct platform_device *p= dev) * 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 =3D irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + if (msi_domain) + dev_set_msi_domain(dev, msi_domain); + } =20 if (!dev_get_msi_domain(dev)) return -EPROBE_DEFER; @@ -264,6 +283,10 @@ static int rpmi_sysmsi_probe(struct platform_device *p= dev) priv->nr_irqs, priv, priv)) return dev_err_probe(dev, -ENOMEM, "failed to create MSI irq domain\n"); =20 +#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[] = =3D { {} }; =20 +#ifdef CONFIG_ACPI +static const struct acpi_device_id acpi_rpmi_sysmsi_match[] =3D { + { "RSCV0006", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, acpi_rpmi_sysmsi_match); +#endif + static struct platform_driver rpmi_sysmsi_driver =3D { .driver =3D { .name =3D "rpmi-sysmsi", .of_match_table =3D rpmi_sysmsi_match, + .acpi_match_table =3D ACPI_PTR(acpi_rpmi_sysmsi_match), }, .probe =3D rpmi_sysmsi_probe, }; --=20 2.43.0 From nobody Mon Feb 9 00:25:38 2026 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 816DF1FC7D6 for ; Mon, 3 Feb 2025 08:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572774; cv=none; b=aTRzPUvJbF30z7x6M4iWD+8uXNTEaF8HKoDwiQNoR0eftfVHo/iDOok5s5wuwCk5bcFLtJLPSJvwg169bZXcPTguXeO5/rxUo3/MBTeD8E04WfLhuNqMUkA8ocyB8ICtcU2uxTZsmaUD8+adIalaeVXGNKzSC3qX3Z0doeU7pyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738572774; c=relaxed/simple; bh=22AgTEVKq+xXA4vNaqP0QKEUOoUwv4sTkP/v4MXPynA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jZ0CVzMWpJAh3qKVTAlLs+qKXyrMbNpKk+/VAzVafRORoO0W0q7CZ+Dz6+pV1Rwq6+3e2lIkoiX0oSA8uaChKRvGNTTyDp8dfpBQ76ujt01z2a1Lr7jNcKE54shdLkumuZFW6olxJXV8Rsjrl/Sv+wzeRr+gLxGHrKl2aHOwxkE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=dUANwQF4; arc=none smtp.client-ip=209.85.160.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="dUANwQF4" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-46783d44db0so38916951cf.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=vger.kernel.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=dUANwQF4WM1HeceqvS2bUw+eqQiPF5DsiLySq1rPsHRCOEQU59r++p2bF/aSpadXyy BPcCpv0fhgAYy+yVwm4zp9fy0YkGbxUkA97jXrPAJs/rptxC8OjqvG8pqvFqi7Ou7LSy fa56H/seQ5tnGEdApiTcCo8moYGVEgCMZjIMesiKlbwO167f7oy5Uk+Nf4/heCjIINZY RvcmBgZk+h7j2Hxz7WyHZSSkUVk6tPe5tNrF2bg11wOMkwu98/vQ+qmDsV+EN/UKqCJr V0KfwKAM95lIwG0gd17xZFxynfYBMM/QOW+JgST/xZeY9CJ5zFk24UAwn39/2a4e6ljG Oa2A== 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=tlMfT9VwFPQcVPqmH1rI7hHRHFY2t3LPZjTTZ7hwB4Ou/V34l6LVPsoCMA0dfSTIBy 1Vgow2vlnVLFfwncmbsqUvMkaxFua3tV7auzl/pxeXnr6hhfFkU0CKmaDzJtoUu32g+/ U99G4KZzikYc+d6rg2lS95u9ZF7p27tK+YKaSG/6L2QecaO9CQG1TfXx6E4oKWDcL2al iM7EFZgX0RSZ2iMG+LI8+H+sK9eZGnjqHeNTHJfkjkddJgxXxRcuLV3hyUWni3D2FvAL Vvm8h2l3vIAUuwq2One3AlSzzweHRYST2d6biK8lnYR2k92CW0BhxOB5SD8mrZSeuaXf V5+Q== X-Forwarded-Encrypted: i=1; AJvYcCXi1V9JfH+vg+HQsxT5LhWK4yM0N2yKMbwIc3UoSttptDa0hNMQ77w6jCLaG3tzJEpykRSJVM1ucM/UUkA=@vger.kernel.org X-Gm-Message-State: AOJu0YxlE7A4ShSLbsB6AeTmqBSafBW/ERl1cwDxT0w0Woatz0ZW34/y +6QoGNINsCOgzAsbJpz1yXN9MTbWd4xj8xNoJseyQzOgRfDMTTVWzeLH/jAxqmg= X-Gm-Gg: ASbGncsgIBhRlecgKbg85lR4sMRhyEK6RT48Df4nuqr9dQHNV8KwfzUxOuv3kJxeyXK pGU2arZDfGx5CtHvJ2hxrauVtJ+iUBIb/QnrP5LioW/Ya6uGqEQZKJuWdsvjG+VrxaTqFH/f1CR ewtjhVUK3+VEAXwI62qizU0Pfa0GSPW2STNkbBp0m9aePswDgHh+NIBH/nw9SKf/+ibGTg5Stks 0jHQHezIMRpFw5WjoPogRgFlOa2SN+SLQry7BigocQrqLYAwuz9IZX+wNSBgX+wE2u/MODgx6mn LTzjOawpQAUsYfPgONb3NvAAsHmg5xNtMatGj9eIOtOz/JUuG78zDT8= 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=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3Dy CONFIG_MICROSEMI_PHY=3Dy CONFIG_MOTORCOMM_PHY=3Dy CONFIG_INPUT_MOUSEDEV=3Dy +CONFIG_INPUT_EVDEV=3Dy +CONFIG_KEYBOARD_GPIO=3Dy CONFIG_KEYBOARD_SUN4I_LRADC=3Dm CONFIG_SERIAL_8250=3Dy CONFIG_SERIAL_8250_CONSOLE=3Dy --=20 2.43.0