From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.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 9DCD021B90B for ; Wed, 11 Jun 2025 06:23:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749622984; cv=none; b=YI3BJgTaaH43JFMIflMcuyEXtHOMGu4TLznzdS5Yqmc9+vbwmWRFEfZbnJ4VQ3vm6JYXmRCBdc4lLOUV8nYN1Gg0Hn1iJjf2W6UiFv6Wcn0ElV2ECLzvMkrpjiYoh6cJ8Yrk/FSjMg3BAeXHi1u+E78IX+KrIbyFGbvXpzTfng8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749622984; c=relaxed/simple; bh=8d/8mwsmm2Bj8oUzbynlYQ99Qu9ru7hjPXyeNTbxR2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BItyCHy17gydGLtkUVAiRWVJVQTd0rz96kf62SYHKANyfUjuzJOlwxqnI+Vyici5QtZKz9UOwsn0rI6VxDe3L9zZYeR4cLpIM9LYnsx4/3avOJc7GUy8EpBAXmlMm5O51wFMA3oWEbJuC+TamQWoTH3phoWCtQDNluDid+YxT/Y= 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=C8GQq+W+; arc=none smtp.client-ip=209.85.214.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="C8GQq+W+" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-235ea292956so60109325ad.1 for ; Tue, 10 Jun 2025 23:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749622982; x=1750227782; 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=FCnkfIAKufTtsXTirgU1KTm9z6frMQCb5vfgSfK41j8=; b=C8GQq+W+Z7V+j+Qzx3kBTT3M8nxyp1d8bx/gv0rQc84oxbx2uHB10qv0s2yqG7BlXS prnyDwqIAuJqx1o73SAw1JyKPhwEB2Mf7YciRmAgMrfC4TEGjP5CN/eEtz82nPU5XU0M NsZVOqIFvauq/O+ejdLYDM/6FPYSiBgs4BByYE5HMCMNSQrHo/v2eJCjxGr+iqtZOz2D J3xBBkIgYLYfT/NO8OQvyVMohvw1/9N+FuU2ql/D7+25EQObuEO1OoJ5yx/mnMzDCf1d EXKiI/v6X/0/m8KAL5dIXIxTLo6xWPYNwCwIMMF5GrnehLYkKEpfj9WaHpPBMFyjcQk8 eEeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749622982; x=1750227782; 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=FCnkfIAKufTtsXTirgU1KTm9z6frMQCb5vfgSfK41j8=; b=AmkHwPpAR74D0YyQ7K83lHu9N0sMRBLbYdlgGDPj1b1oLk21Xk6+Dj+gomWMOeMGc5 z7zzraM+cbVUsIwe4sFto0mfEMYH5CXatWCZmX8Xzn9eS/HRbTlKY26H/aMtKCDeksvw JTGS08qxoCpffb1mrBX5ET53S7HRf2czYpDZmMgeRbPbSwJ+WpOJMoEOrDYYeIG1bzK1 jtgGs3Wb7TQZ86xx4T82XwWWOeemotBKDyatEeF5gZq9JWe/2PTfV3k3eXXbQqDvl0BM UfQOSxGJwdz356/vwgw3fC1z9HF7yeVYR7ea0x7HPO3MwnivaZNWP1pbrhUscAHUMQFq c38w== X-Forwarded-Encrypted: i=1; AJvYcCV1lBta6wx8vxD5fkdX5vTW7VcHZAJl4d3dyhOSbMV0YKK9dafOpENdTs+r4bcj/r4tY2je0m9FYkaa81Y=@vger.kernel.org X-Gm-Message-State: AOJu0YynatIrHaSM1xDJ/S0T51+3Nnb6X7z0BqkI1zG70wdLWwrIuBMM lMnkc789iueEwRt+deZ57y2JAEknUb4V8L6eNiwIiGriZhh5h0cbBPH6yIGKZqEE6Yk= X-Gm-Gg: ASbGncuF6HSsDLTcU5XPaDG9UykBVhUf2RN96tht/J3CXI9knlcfExaNIpieB0gv3b4 u0XZW8k2HKxdPrc4sQM84jXmBqZQQZx1wqz/bfgSc9KdrQj75JYap5tEdfCpZqwbPTpPQE9JYMw gN+dOl/JXeoqqDUfbiSeJI+BwaQCy2i69/Opf2e04Q0k5rto+hydUfo/2ikP9Pr40WBQO8MPsWB UZQVqETkAqr74wG1p7EyoETViFYvdOkdPQNJmaRlv+gTDTTUnaQy4QnB9PwKacC1hhdj1vJ/ceu uBgialyMGE6ejYsJ0TGqnXNcgJzcYhe1o5OZ/6fOJn314JsWM939OVToQkFSfgXWQsOGZ/l84Bm FKbeIyf87T4z8D4KmUvKmp3FeCQ== X-Google-Smtp-Source: AGHT+IFflCobAzZ7DXGfkuM4PqfzrltZgkya36IU2M6LH+WC7zfTuPjuPy+rud5tVoTqrkTwZZw4yA== X-Received: by 2002:a17:902:d4c1:b0:235:ef87:bd50 with SMTP id d9443c01a7336-23641b16639mr27978465ad.45.1749622981638; Tue, 10 Jun 2025 23:23:01 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:23:01 -0700 (PDT) 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: [PATCH v5 01/23] dt-bindings: mailbox: Add bindings for RPMI shared memory transport Date: Wed, 11 Jun 2025 11:52:16 +0530 Message-ID: <20250611062238.636753-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 | 124 ++++++++++++++++++ 1 file changed, 124 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..3aabc52a0c03 --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/riscv,rpmi-shmem-mbox.yaml @@ -0,0 +1,124 @@ +# 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) v1.0 (or higher) + https://github.com/riscv-non-isa/riscv-rpmi/releases + +properties: + compatible: + const: riscv,rpmi-shmem-mbox + + reg: + minItems: 2 + 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 + + reg-names: + minItems: 2 + items: + - const: a2p-req + - const: p2a-ack + - enum: [ p2a-req, a2p-doorbell ] + - const: a2p-ack + - const: a2p-doorbell + + interrupts: + maxItems: 1 + description: + The RPMI shared memory transport supports P2A doorbell as a wired + interrupt and this property specifies the interrupt source. + + msi-parent: + description: + The RPMI shared memory transport supports P2A doorbell as a system M= SI + and this property specifies the target MSI controller. + + riscv,slot-size: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 64 + description: + Power-of-2 RPMI slot size of the RPMI shared memory transport. + + riscv,a2p-doorbell-value: + $ref: /schemas/types.yaml#/definitions/uint32 + default: 0x1 + description: + Value written to the 32-bit A2P doorbell register. + + riscv,p2a-doorbell-sysmsi-index: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The RPMI shared memory transport supports P2A doorbell as a system M= SI + and this property specifies system MSI index to be used for configur= ing + the P2A doorbell MSI. + + "#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>; + reg-names =3D "a2p-req", "p2a-ack"; + 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", "a2p-doo= rbell"; + msi-parent =3D <&imsic_mlevel>; + riscv,slot-size =3D <64>; + riscv,a2p-doorbell-value =3D <0x00008000>; + #mbox-cells =3D <1>; + }; --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 3397222B5A1 for ; Wed, 11 Jun 2025 06:23:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749622992; cv=none; b=r0g4/DtlR/JOXJXqyzSu9e20eTEHsUTRikOGAbhg6KjU3cmL2dWQpPO0JzuKfqfCzfkMr2pvl8J92Z8Vd1GnM2PlVs54EoLHVZB5QsRkeKWNKnuTdA+LvkksynS3R6UkbrrKrvvsj63L73299nxOzKsm1FJzTotJVgbaap3m/pQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749622992; c=relaxed/simple; bh=kRcGg70RKkFO1mUlmdFiMNEl7ognGFDZDE0zZUh7mcs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A8t/sixUNzC96hcuZpaYVt73YaV2GitY/yW4y0QnxRNUeuhhEHSHheC4WTcRHVlVs1Zu7nf+EA2zp/YHarXNvl+1qf8cRaAOFGhcH3A/LPbc4wrBW+TeglHp2+189e/Ru9U0zIuI+bfiYj9kS0mDyEsboorVP4PLLDw27gcXIBU= 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=lJFyikr6; arc=none smtp.client-ip=209.85.214.176 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="lJFyikr6" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-235d6de331fso73675485ad.3 for ; Tue, 10 Jun 2025 23:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749622990; x=1750227790; 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=1hhJCf0S1HrMwLYRdGRFvzVPJDaWXTpl7/BKK1v8w+s=; b=lJFyikr6XZdt9Fflty257mmsUfydvK77z41XCZLbndlglaIU9i449+NjcO5t++mzFU jMX4QsCfg1lNEeFcxHS4slntMBWW66j7HgMtORsbyuQ1zXOrsckaR2S7K42gT5LrSA76 UpEorSsLKiDLjOX6JDRyG8hTnvmBHkPcHn6UdUQlhdZihnqAj4MyONwcpm/TJKIKRZuB +5MfnSrVX9fDjBleMlwt2EDb4FYgIAkFhpDYogpNo58K4hzp3M/4KW5xnfiuxhwWBcx8 ByQCF8Z1aLl1NYzXu4mHLaf7/6cVc8IRF8GtrAosNB39+jpc64Xi90ni0A0/4qb1mJaE whvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749622990; x=1750227790; 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=1hhJCf0S1HrMwLYRdGRFvzVPJDaWXTpl7/BKK1v8w+s=; b=naNURDlR5EgueXzNj/xQkTIAEeNoFxVcThFVQVaApkCvjNTWk6uKpHsOO4NXCAdbOp kp3xjEDzYjFEaNQ3B1ukR02fdDtlS27XouhJCsQYa5/UmpOdcC2GZ5AzTw5P4CnnI1KB 534OjwZR+vff+fSHOT8r6UMJ3NnQoz8oyUxcoHcCRUId2vUvcd3UsV/5BNY297VLuQ4s KoeNsCx129+Z64fzNsQbzrdUmFtcp6VdZ0IqgPSePCr1pFSV5TkzYa7Cxzpt5ApKFSpu d5H4shuotEEdubcU/zu/F9az6aYm0A48v8YqhL8/FvyVQq8YINBIeNi7J3t0dnLCoiGZ N6dg== X-Forwarded-Encrypted: i=1; AJvYcCWRcFjfNzRHBEGuw67k16ephMx6HAcEJSktlr6zATvEfwON5h3R5q5rANhgskr9uGXmdraYbon134+v05Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yxhk4/fj5u+PxEG8+nLe4ivJHXq+2oW3RqTWhfwDkTyjR2Bppri hEgqCqAztnZt1iTTIMnssiC/ad4kA5fMfGidIjvZjohRP8O+wHCxT3RJ48AQVQdRXP0= X-Gm-Gg: ASbGncsaMwwbZgq8Hg49ejLHAvCr72KRokv78arbHUOixbRSBPtmgk0Ze011DBbr0uz SkUYgAzSVO3G91xKbFzrFM6Yk6//QfFPtCmpFilrE4rLQiYb15xrggtcBo650v9LEi42T/07X/j gb4Rz4mv+SAZRRktTzosN62/rroXMFkLp29/RdiqWLcWYvBUV6nRAJolsJyAjc8IXKf9L91Fv6l O+WUQsrnTouwRlxtE4GWinCtuWpgsbO0vH6dn6O7VePWTwFbWiI8cEQk8N9D/ThVEuhL0mIrIm/ e63iv63B/m2+9yqhQfMIpnOsBu2iog3BccfoGJVPDOAtdTReTPmMWmcrnAOnw7Flp6LIb6Ona0T BpyICcZCU5RhncJPM4So2O2180w== X-Google-Smtp-Source: AGHT+IGYvPF8a0ieyfCcXWkb9basvXu1C61BkUa+573NYbGt/torEkQigxWEXo3WPB2gMuuh/gndlw== X-Received: by 2002:a17:902:ccc8:b0:234:8eeb:d809 with SMTP id d9443c01a7336-236426b57a5mr26776185ad.43.1749622990453; Tue, 10 Jun 2025 23:23:10 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:23:09 -0700 (PDT) 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: [PATCH v5 02/23] dt-bindings: mailbox: Add bindings for RISC-V SBI MPXY extension Date: Wed, 11 Jun 2025 11:52:17 +0530 Message-ID: <20250611062238.636753-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 | 51 +++++++++++++++++++ 1 file changed, 51 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..061437a0b45a --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/riscv,sbi-mpxy-mbox.yaml @@ -0,0 +1,51 @@ +# 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) v3.0 (or higher) + https://github.com/riscv-non-isa/riscv-sbi-doc/releases + + [2] RISC-V Platform Management Interface (RPMI) v1.0 (or higher) + https://github.com/riscv-non-isa/riscv-rpmi/releases + +properties: + 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: + - | + mailbox { + compatible =3D "riscv,sbi-mpxy-mbox"; + #mbox-cells =3D <2>; + }; --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.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 154AB229B27 for ; Wed, 11 Jun 2025 06:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623001; cv=none; b=qhJhx60zbIQC7RG3sPVO5ZNo7ZloZbuelbokBCrT6pgQs29pXJz8mNUzOkWxHq7UUXNpnVeWjj/PBDbQrAJtkLq5ik9UYnW8HHcTk61qgm3gvlUJ2yx40dUR+vk6Ktn2qrVibUW9nxtCYNKpsiikoyuTB/5hkE2ZMZaYDMwzdu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623001; c=relaxed/simple; bh=Ye4ZfiaWihO02YpFLTTLPq3t5G3QxU79yUJd03niZWU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G2WkQe3sR2V439iKCPdcGusb8aCLOabEAPztiwUH89XJ4pOGxxJ5XZ/Q9zcVO/r+RT03cFXKd5EVwM67R0eq/uOew3dWSwZpBXdONcydDKdZYwu4m50cY6T/cR/Af9KKepIvOIeJnd2vug5ZZGCFfjUGI03E3mqcEdcwKW4baD4= 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=ZQUZxqjR; arc=none smtp.client-ip=209.85.214.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="ZQUZxqjR" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-23508d30142so79207155ad.0 for ; Tue, 10 Jun 2025 23:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749622999; x=1750227799; 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=3K28ccsWlxMwqCRbaP9oqvPlrdelc8/pGL6q7Sf+y0A=; b=ZQUZxqjRZemVSFwQHx5IMUUa5M2XwvCOq7a3X2lY+EVNTyCnkPvv+xAZ0B3O3T4nt9 /tVpkytAOeZSj8dWmSVbQU8jRyefdTNxXAHUtJ0MNVDMph4n05MBL4/60ceb3pWohN5a cYGFk1N1dZjytv95FvDmCXyEsHvS/CeKbEZidZELQj59I2meHw89tEHcw6Cw7yHjPCGR RuIsPpT+Wm+KFivkDVaUavmVSxrJYil4jA8s0TxNHWWkKEZRQEmY8WWBzOa49FkruhY/ LZ6ge3FYgYj0u3sJzMrc2a7p+67eNQbK6IZprWYd2vVgDArrx4tl7DV/rJKHpdIKDzRF Ys8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749622999; x=1750227799; 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=3K28ccsWlxMwqCRbaP9oqvPlrdelc8/pGL6q7Sf+y0A=; b=YJjlU+USA2zqjlO0h+CxLZbZfoUJttMo2J1yekxJXXkWzWODrw2dpG8pKl6OqzlDfh /6DClB7xglqF/Qyhx7kAho607Awqgxz95/+GQW7snswTcDJf6Rz4zi/aHdhTXCGv3kuF Tt6Pe7osLKVpuyeuuSHAch+DhPsPxNXj8B0ZGn1nC8AMpEHfppAkkCiL2/DU/ediwsr2 OZGLe3b+7aN9gnOg6NVL/VQFMFrVy5YNVzV+kmNhy5Ffcco6mqC5SueUVzabijXPvPZF ec6XC70uIbOKrKVRhZ5ftGIU54WoBvXA93qSQESMfKVKW7AzCZVUzsjZPTkF1eVdxiXl m74A== X-Forwarded-Encrypted: i=1; AJvYcCXTyb4bint2W6QJfx43aeRshARAGPx3AjDp/e1zrspiO2w5GZ3BqNZFyIX840J588Aci096BWxhJXFULyw=@vger.kernel.org X-Gm-Message-State: AOJu0YyE5QjgEqmAE1H7qc7Sp/6lNiXLf6QZsBGPPCyyengZ2TWim218 AcErMvizbtfyulxrmogzPoztnMciynD+a3tyxh+/Y+apatJ85h38PfKf+tuywbRPpKI= X-Gm-Gg: ASbGncuhp3Bnbb3dPavkLrhgzc48FovT0m+lHKjjjTU9Je3EfS78oHTGywCbct89VUP yNpxGlS8Lsj6OudZp7l0lqJwUyqpzQt8gxVy5l+2mv/AvP8+JLYhAT1J8s51OMCEEG2lr27dVGG rupntSYzLncERxOJvlwJAWUa5JNisCtavzJ+3V9OcL8YVsQArCEDH1JRBRWHbdyyysGf8yRy8C8 Avb2WSXgEpYiQcSPB04Zl8+zss4MO+SV32JOCF1AyNlANpnkc3xyncCPH7CaX9vvN9iFNzGuPsw uhMuSFuSwbW2WSn6UToouaz4ZhC4HtH3HvcmA/eNi7E6mlP7q6nUJZNlIMblvsoTZ18XefwRvGg RVR7r9m4HHiLzuzMFndVsTizh+A== X-Google-Smtp-Source: AGHT+IHLDZwFxM0MKNLl6ed9TvPphtVlyXYtS+o1/xlJG/p+4dis78BCknfh/vBsGOTDe6Pt8koHtA== X-Received: by 2002:a17:902:f645:b0:235:2403:77b6 with SMTP id d9443c01a7336-236426b4fb1mr22190665ad.37.1749622999268; Tue, 10 Jun 2025 23:23:19 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:23:18 -0700 (PDT) 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: [PATCH v5 03/23] RISC-V: Add defines for the SBI message proxy extension Date: Wed, 11 Jun 2025 11:52:18 +0530 Message-ID: <20250611062238.636753-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 | 61 ++++++++++++++++++++++++++++++++++++ include/linux/wordpart.h | 8 +++++ 2 files changed, 69 insertions(+) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 341e74238aa0..cb89cd784a4d 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -10,6 +10,7 @@ #include #include #include +#include =20 #ifdef CONFIG_RISCV_SBI enum sbi_ext_id { @@ -36,6 +37,7 @@ enum sbi_ext_id { SBI_EXT_STA =3D 0x535441, SBI_EXT_NACL =3D 0x4E41434C, SBI_EXT_FWFT =3D 0x46574654, + SBI_EXT_MPXY =3D 0x4D505859, =20 /* Experimentals extensions must lie within this range */ SBI_EXT_EXPERIMENTAL_START =3D 0x08000000, @@ -430,6 +432,65 @@ enum sbi_fwft_feature_t { =20 #define SBI_FWFT_SET_FLAG_LOCK BIT(0) =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) upper_16_bits(__ver) +#define SBI_MPXY_MSG_PROT_VER_MINOR(__ver) lower_16_bits(__ver) +#define SBI_MPXY_MSG_PROT_MKVER(__maj, __min) make_u32_from_two_u16(__maj,= __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 diff --git a/include/linux/wordpart.h b/include/linux/wordpart.h index 5a7b97bb7c95..ed8717730037 100644 --- a/include/linux/wordpart.h +++ b/include/linux/wordpart.h @@ -31,6 +31,14 @@ */ #define lower_16_bits(n) ((u16)((n) & 0xffff)) =20 +/** + * make_u32_from_two_u16 - return u32 number by combining + * two u16 numbers. + * @hi: upper 16 bit number + * @lo: lower 16 bit number + */ +#define make_u32_from_two_u16(hi, lo) (((u32)(hi) << 16) | (u32)(lo)) + /** * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long va= lue * @x: value to repeat --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.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 EE5BE229B27 for ; Wed, 11 Jun 2025 06:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623010; cv=none; b=YwEFvrp2+tL0a34gcNPGA+jtGBy8pybebi4Sr5zElEmEMHJWfv99eWsEdBYskSzvWYZ6IYuwbjrO8/f5ExsytAa+cxr7SPVRSx7Ur+ZaEpLVjg18/BHxNvuqouVaEx2vmMqNxcFhdUg7lKKKFq8OnHm6QG6hsXQiWYhdJRY+Sww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623010; c=relaxed/simple; bh=23vqG+UdB8CmOAk6yqbizlK8J50uIljCuXq5sZaUi5w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qegYrP56LabY/kSn/BEr+LSStNY2ozBuUPGuh9HdnTYHKTzlzp8xDSoDcNdf76GzKHigzDMtR/vjpGd6VgXypkCLufcF8f1EJzALVIIZ22U+Xmohf/RG98nzUpJJzDAElLkgxkEgB8v0bQZRFw3Xj6z+QHrqUhSC8opZAyRRzoI= 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=MYcfgFtu; arc=none smtp.client-ip=209.85.214.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="MYcfgFtu" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-234d366e5f2so71472425ad.1 for ; Tue, 10 Jun 2025 23:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623008; x=1750227808; 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=aEk7l982A/3iNmfI4ADDZgvcRJ/gPBy9EnX2Zk0GAIw=; b=MYcfgFtu1EKkHSd5nUT+bANL0+NdAFrY+hUKF0Usa28QtaIReLCTppmbVKfeW8ynfP bTxftt5AgG435PzLXqG3qKG5gWYwJiN0N2eqAP8eyZIgTkL4StGqoleCqdfq1Cq721Zq hm5FxRwescxKbpGuBNlfAMXDVVm55AHo19X8Trg2VgZbIhX7UlK5iZwcwUxe/s7nlEMo dO57qQ4skIbBwTq01eO7+fXcUQ3cDb49w227kHbQWRn468C9aMv8EaKq+H0rgpzvjkaO jDLVl7T+MkacleNpyoo6qwLpTgiKYgBGuPecwKMGLsmxkq5U7aEWFye2kRP3wlWjbp/S OyRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623008; x=1750227808; 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=aEk7l982A/3iNmfI4ADDZgvcRJ/gPBy9EnX2Zk0GAIw=; b=FZom5ex0IDVwuP503lFGJktTPc5B07VztowtjLKLJ3BSY5SY0lPePZbkpS1c4Wxafi RNMahNQINM+3lwAl0ert5k3LgmsAtu8W5rd2lxsfXYhMa/wtDb/ZhYg+xREdAFU5Pr1Q YrAlcuPUKM5Tp0gLucCR/YGyRMGhmEFUk7qFsE/Y05Mxn6J5+64YhBpLzr0MHHUXMldS Xfh03JQyBqhYCBI3hJsYWLZtQZUFHJpqsIeohoNSy/jJjc6bLajkqgMEEf+E5sq3CApc lKPGLDWU2nDO5H/mGfOa7tgfezBucAm4Oa8eqTCp578CvBwXH7rknrqxoSRdT1SYR5CC X2lg== X-Forwarded-Encrypted: i=1; AJvYcCVTicCa/AUfr2wOc/FP9Tb0uYiw/EmwY6vRuqOzdQGYSXjVhfwkL6CRfgfgIrZI+KrHOft8LnW0/R/M9rQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9yxPakv6LBbKbKoFsfih91E/ySegSBU2a667jLhXQC5ad3aX7 se7qvAQdJi+YrWWa6DUJyeDTirk5PANWNEmDFGZgxrm87vXKlzYAv93EeZlWUGO3HLE= X-Gm-Gg: ASbGncvgDGXJbQSDU+GEAhNg+9J540HcGo8TdNDZ5G0mNg8wOcduFp3YNFZ0MznEbVh YvPY6GBz4lyGfc1B5a8+UaM8FBqomGogutEHa/u6kSvOSElDfTxGjyzHEYHE17NAxecwC9Ufryz zNq8WgU3cb+oA7oQQjKWGf7NX5b+7oPrkZaed1qs9QZSllOJQqG7ti3IkXrX0aPgUsabJ2gI4IQ ZLOD10VBsIZHPGpF1Ic/yjj26dr0Cb5dPoklx/CcZlrt1jzmFHwQyslU25SJ54XF94p/0+o/pKB y4EzTsvbQMD1utlcFsI3A76rvFPocaViQCY9pEH4pHl1dgR1CpSuqfyg/JZedIP45CPcpT5Iqms PFOOWFjJwWverfd4pn+T9B26faQ== X-Google-Smtp-Source: AGHT+IGmMjAxKFfhQNXGR6+5ZNDeO/fKZhgBO21zoWdzah1Ay1ynpmgVEmCXF7UyFGfhGCa0JX+ytQ== X-Received: by 2002:a17:903:32cc:b0:235:ef56:7800 with SMTP id d9443c01a7336-23641af0815mr26335535ad.30.1749623008101; Tue, 10 Jun 2025 23:23:28 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:23:27 -0700 (PDT) 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: [PATCH v5 04/23] mailbox: Add common header for RPMI messages sent via mailbox Date: Wed, 11 Jun 2025 11:52:19 +0530 Message-ID: <20250611062238.636753-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 clients 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 | 207 +++++++++++++++++++++ 1 file changed, 207 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..fca1f18d93eb --- /dev/null +++ b/include/linux/mailbox/riscv-rpmi-message.h @@ -0,0 +1,207 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2025 Ventana Micro Systems Inc. */ + +#ifndef _LINUX_RISCV_RPMI_MESSAGE_H_ +#define _LINUX_RISCV_RPMI_MESSAGE_H_ + +#include +#include +#include +#include + +/* RPMI version encode/decode macros */ +#define RPMI_VER_MAJOR(__ver) upper_16_bits(__ver) +#define RPMI_VER_MINOR(__ver) lower_16_bits(__ver) +#define RPMI_MKVER(__maj, __min) make_u32_from_two_u16(__maj, __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, + 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, + 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 Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.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 B32ED22A1F1 for ; Wed, 11 Jun 2025 06:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623020; cv=none; b=D5dE37K0rUyVJ2QuHgDq7rkZAtNcD8qfsyaWLVj828C2cU2WT5lyefDaq/lg49KVJ94tWHVQRf+NUcA5o+5iZS1fRUhpQAAZsE0qLFzlS8A9Wq49EaCE1B24iXSoKh05+XvQ+X06d3280MTi7/Df2cUunA//a6GVkrdw64jPE+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623020; c=relaxed/simple; bh=st3O+ijFgGFNKVMxzm55tlaSGPlHlP9D9YyRi1Zj5U4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OteeXoKVjUAdWrIYoNud8wN0HEUL7ep/tHO7TiOFlgGb8WMKda5L0PYRCGAYd/HwOV2+pMI4KROV1dE26C/dLQNdfZp6chfeIHUX3vpOww68zguAN+INiGpckukTP3cLFaQ4cA88J0huiJ6sPTKwX0pc7vsGzzBM9GatSjGuM1U= 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=ESV6NoGh; arc=none smtp.client-ip=209.85.214.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="ESV6NoGh" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-236192f8770so4360905ad.0 for ; Tue, 10 Jun 2025 23:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623017; x=1750227817; 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=Oq58nUDRWeIOl1x38zmkh2+ZPHCgo0OptvyvyNxudhg=; b=ESV6NoGh1En3AvF5RK5spQArA54hQPkqbYJX8P562w2rQzb91s3qEeIUTUwwecSTiR eD6qLRmG8VQrLInkMlp1bq+mc8YZVsIUyk0au3JzToDGN98a1a2/TAVs3qrHJguAK4Q8 SbE6iFGMWedgnOanHLb+bf8sr8m3PjgZN7q9lmCjYx9bPL8PXbgddE/oKanMClv1hzEl MSAZNABU0wi6KOMZpXYDUUY36u/T+JCh6P/5fCIuzjPwEhZ6zXVDrPAWx0LDQY5MCP0U syOw0QBi5dGcMJxG1kjgKfwRaDXTTudu4uqXiJxd4jctNdPFfZ0oB0War+lQfFexLdB+ mxrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623017; x=1750227817; 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=Oq58nUDRWeIOl1x38zmkh2+ZPHCgo0OptvyvyNxudhg=; b=pZvUnPz6xwbiiExXELsaW0uzK5rKcbtp36fKX+jLxUKDBSUn9ZTetbGvASk1F5fZF+ lAt63EatjTlSYU7Fm80AlnHQjPfxePyo5ks50qqKeFddESQQhO2p+wsn8xG8u79lLC2f 4iOwY2RECWcEaoj7B5UFkrOqon9f+fC7zDjCg3mTp88/fTfrjnHK01Q+q/nB5FUknaSA nX5L6+dkTDrgYa0eMxc8IaxfOw/0s8ogDVFfyemQnsx+hWYYpjcPUCORbCgbAvZRqOM8 Bi4P8J+K+qJiy9SBe9hNe1ZLHAGjl6f7hVtMmFODJYv1SnP8l1t+nw1tRASbHnAi84r1 ldyA== X-Forwarded-Encrypted: i=1; AJvYcCX4M68oB+Zi4ulbVe2uAACfprClFqmeCfRNrgzWWCVbgsfGtMcYJdP9qL7sqz0RdRnFNw2ZsUGIrng89kk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/PluuAcZzE/LUdeXXQU/A36yaoFfdUA0+h60Q/VTXpdPhSOzF XBs+fGdFAr8YMEFG1ggNXn3ouF4dEuU8aeFqkzgcIKmt4M4rk9HyEbweB4EdTv0iUS0= X-Gm-Gg: ASbGncvGkM+vK4d/EbUIjUJMHtGVp/XN05pN3tQvO2jHVo9o46Pyh0XcAYpnxBHPpM8 5YMM0l+F6QlNoXYuTW4OceuQGNYFESiRVU0BL7aUGCtJrmMfLt2OtJo+s1f9Jx4KOneMaeI5BBP 8LVTHiOymOwUNcQPPaakwRsK0Wt3nOZW/sHIl4i7a7lhnAObnyhH20CsUwS+fPy07iwjuj441jh TPlHaeaPtSVCHIh+rtesyavLILm3TzO3RaxV3qhIqTy9tvuLdTGBoGqFAz5n3YweTxpGVSrHJ7R HRzFrSYhz/UIF9cMnofDlgHqTofidkNd1y6W7bOI/qZ7UutHi2NBShrG2z4dH2uhFa1i+Z14gLK O2zYuuJLBJ+lWGi/8ORyPr/rD/k3zc+IYQXzW X-Google-Smtp-Source: AGHT+IHtGB2PUpXqZ9bfGLD+kJcw/Vmqw/rX+F5NwlfdOTouRiwUdlxzNr+s19qiVuX1b57i0EotKQ== X-Received: by 2002:a17:903:3203:b0:21f:5063:d3ca with SMTP id d9443c01a7336-236418343e6mr33134145ad.16.1749623016901; Tue, 10 Jun 2025 23:23:36 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:23:36 -0700 (PDT) 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: [PATCH v5 05/23] mailbox: Allow controller specific mapping using fwnode Date: Wed, 11 Jun 2025 11:52:20 +0530 Message-ID: <20250611062238.636753-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 | 45 +++++++++++++++++------------- include/linux/mailbox_controller.h | 3 ++ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 5cd8ae222073..d1840eace725 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -15,6 +15,7 @@ #include #include #include +#include #include =20 #include "mailbox.h" @@ -383,34 +384,46 @@ 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; + unsigned int i; int ret; =20 - if (!dev || !dev->of_node) { - pr_debug("%s: No owner device node\n", __func__); + if (!dev || !dev_fwnode(dev)) { + pr_debug("No owner %s\n", dev ? "fwnode" : "device"); return ERR_PTR(-ENODEV); } =20 - ret =3D of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells", - index, &spec); + ret =3D fwnode_property_get_reference_args(dev_fwnode(dev), "mboxes", + "#mbox-cells", 0, index, &fwspec); if (ret) { dev_err(dev, "%s: can't parse \"mboxes\" property\n", __func__); return ERR_PTR(ret); } =20 + spec.np =3D to_of_node(fwspec.fwnode); + spec.args_count =3D fwspec.nargs; + for (i =3D 0; i < spec.args_count; i++) + spec.args[i] =3D fwspec.args[i]; + scoped_guard(mutex, &con_mutex) { 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 && dev_fwnode(mbox->dev) =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); + fwnode_handle_put(fwspec.fwnode); =20 if (IS_ERR(chan)) return chan; @@ -427,15 +440,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); @@ -470,9 +476,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) +static struct mbox_chan *fw_mbox_index_xlate(struct mbox_controller *mbox, + const struct fwnode_reference_args *sp) { int ind =3D sp->args[0]; =20 @@ -523,8 +528,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 scoped_guard(mutex, &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 ad01c4082358..80a427c7ca29 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 Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.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 C52EF229B38 for ; Wed, 11 Jun 2025 06:23:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623031; cv=none; b=f0N5a1sfVa+pFTp2SBT8n2g4B1qIuxzYEiKVdfTkLZ+WQI2IGPpiuxjCyWIPl5vnTIyGpMp1su+ygC3alAfDzCOZnpJFULTEtok7vdwNGnNEqTtSxGyODo9pIbZzjS+C8Ip1CZVYXFG9s7ojZEQI2WChIgp7lz1tIyMESuetUb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623031; c=relaxed/simple; bh=FapBFR2Wc06RZFzKzhClXz6Ojx90PnCpJ5OLlpR3INg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IoDPKYyt7M/NBR0ZdW9GCvzBcihOoc5E7dDRhDomncG+kbp4S7htKCHoTaVgS+LbRx3EuQfcKCdVkV4cbnWOXU0cn7pmiEF7e30WKRoN/ZI3TmOBa0TMKnjySunleLV20AyB9mHxBi8Pb08pXncfmxByg5oq3r2fdVQe3xiaez4= 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=ebriTWfm; arc=none smtp.client-ip=209.85.214.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="ebriTWfm" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-234fcadde3eso73725695ad.0 for ; Tue, 10 Jun 2025 23:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623026; x=1750227826; 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=+/e4CWrNvqLUAPndJMuwHB2eXanAAt87RTQbDIBK0Lc=; b=ebriTWfm2WUvSi8C50p++V6YzVT/2763+lxFYDvMHEooQjJp6tpVTjxUSdG0XF0EvD 4mBikheV51iWxfcsQDXjClgYTH7MtCqIo65jdccvfaGGdXx7lXT/PYN4lNjv1X/UNmJW gUL0shROwu2NV3PAlXw77cYeuzpvQka4nZAKHCkGRy/GvCiLVYZE4pptgzKvm05nplt+ z9qBosMw+czEYhmh0nv/+j/p3juwZO8SoPl520IV2A2r80Pbv2cSr6/jMAEAQgnHU6Fn FJcQEllppuAGKtgUM8/ADw4uzF6IGNG/RAGIN6Sl0qk3xrDpwIc/gMTeQr27q4J2leN5 aobg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623026; x=1750227826; 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=+/e4CWrNvqLUAPndJMuwHB2eXanAAt87RTQbDIBK0Lc=; b=b+Rp+MLJ5mA5N2xAF5Gn7SYj9cUgDavDy2cfssuoDq27zeNxicqzpO05TDCby5F3XT a69dPj+b44w9OR8MZg2nQFHwdmhTdocW1hQC5vs3qfGJYmfBNk8zAFLkOQwrzErVhHVu +fg+pPaGp5VxjdTYE70DfEHwd8kx0PaoVxYXoR37h7PDaiNoETdmecFedv2y09DCuUji QqmCVrXokULzurWTk8ipveFDLJUx2m4SCOuuZUtoT0xhUdGP7JxcT1tacAVu7RaKpEFS Wb7qD/2OtdrCIFksqPzfvmiotKpAID9niUCYJwUwcgnB2Vg12DyWql/xou7kPR6sH6Cf xz6A== X-Forwarded-Encrypted: i=1; AJvYcCVRII5YitMCAVT3WSWurJTQCmtN+ZpO+7KhpOU99IT13S10dS8O/AE5kTDrIdZhY0vYBXXNL+aQqYNm8W0=@vger.kernel.org X-Gm-Message-State: AOJu0YyCZYxcVgM1mEc1yoqmrH/nsMdpOudQuw40EWReGlalFf9pUnar gYMSX9pkGINtWIn1+X3lGsmWYHk+563eDzQatwHky7L/1ZdGY+flZUb+pAENQ3UvsGo= X-Gm-Gg: ASbGncvKazJsIPIrCKbI4jWGcN6wUmWnOlaLAFlFy0Uye/sMVS6x5tEQ5XERthiYxX9 D06vgB0ysDcUsoYlelLi+NqjRRhN+7xDjp5+Nbmr0sQD3cQf9i0LMr6/9re66Z7o1shAHy6uzd1 y6Z7mAwGN+GuqXyuqNb6a1HPk7nPvEfHduQ+lOVkbaSCHlUUFfIgFADUuu3VrgjANKKn+7l5G3a Dl2dEmhwY3GDRNLASQ9Jbni7C9GqzM2P1msBAlNgB2dAtTOp7mCe8MuCXOCPWwHEERQ+IZzYsts fmjlOW7eflWGxqyDEjNnEZU654UhwDd82UzYNHTZHBGiQJRdSO9gd1oRi90tav2bjZIRn3jAMUf WvjrlSzLC5YKopFITEgvdEIx6ZA== X-Google-Smtp-Source: AGHT+IGDemqQRbqUXm+Er6MGEO+RQiUHCEQK+/9Z4APqs7xHGQtLQ7AXcnudMHnwP4dbltzeaKIwZQ== X-Received: by 2002:a17:903:1448:b0:234:d292:be83 with SMTP id d9443c01a7336-23641a8ba75mr33353625ad.10.1749623025775; Tue, 10 Jun 2025 23:23:45 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:23:45 -0700 (PDT) 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: [PATCH v5 06/23] mailbox: Add RISC-V SBI message proxy (MPXY) based mailbox driver Date: Wed, 11 Jun 2025 11:52:21 +0530 Message-ID: <20250611062238.636753-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 | 978 ++++++++++++++++++++++++++ include/linux/byteorder/generic.h | 16 + 4 files changed, 1007 insertions(+) create mode 100644 drivers/mailbox/riscv-sbi-mpxy-mbox.c diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 68eeed660a4a..eb5e0384fec6 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -340,4 +340,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 13a3448b3271..46689c1277f8 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -72,3 +72,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..ead67345456e --- /dev/null +++ b/drivers/mailbox/riscv-sbi-mpxy-mbox.c @@ -0,0 +1,978 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * RISC-V SBI Message Proxy (MPXY) mailbox controller driver + * + * Copyright (C) 2025 Ventana Micro Systems Inc. + */ + +#include +#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) + goto err_put_cpu; + + remaining =3D le32_to_cpu(sdata->remaining); + returned =3D le32_to_cpu(sdata->returned); + *channel_count =3D remaining + returned; + +err_put_cpu: + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static int mpxy_get_channel_ids(u32 channel_count, u32 *channel_ids) +{ + struct mpxy_local *mpxy =3D this_cpu_ptr(&mpxy_local); + struct sbi_mpxy_channel_ids_data *sdata =3D mpxy->shmem; + u32 remaining, returned, count, start_index =3D 0; + 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 err_put_cpu; + + remaining =3D le32_to_cpu(sdata->remaining); + returned =3D le32_to_cpu(sdata->returned); + + count =3D returned < (channel_count - start_index) ? + returned : (channel_count - start_index); + memcpy_from_le32(&channel_ids[start_index], sdata->channel_array, count); + start_index +=3D count; + } while (remaining && start_index < channel_count); + +err_put_cpu: + 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; + + 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) + goto err_put_cpu; + + memcpy_from_le32(attrs_buf, (__le32 *)mpxy->shmem, attr_count); + +err_put_cpu: + 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; + + if (!mpxy->shmem_active) + return -ENODEV; + if (!attr_count || !attrs_buf) + return -EINVAL; + + get_cpu(); + + memcpy_to_le32((__le32 *)mpxy->shmem, attrs_buf, attr_count); + 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) + goto err_put_cpu; + + memcpy(notif_data, mpxy->shmem, sret.value + 16); + *events_data_len =3D sret.value; + +err_put_cpu: + put_cpu(); + return sbi_err_map_linux_errno(sret.error); +} + +static int mpxy_get_shmem_size(unsigned long *shmem_size) +{ + 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); + if (shmem_size) + *shmem_size =3D sret.value; + 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 0; + + 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 void 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; +} + +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) { + mpxy_mbox_send_rpmi_data(mchan, data); + return 0; + } + + 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; + + do { + 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; + } while (1); + + return have_notifications; +} + +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, NULL, 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) +{ + u32 i, *channel_ids __free(kfree) =3D NULL; + struct device *dev =3D &pdev->dev; + struct mpxy_mbox_channel *mchan; + struct mpxy_mbox *mbox; + int msi_idx, rc; + + /* + * 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 */ + rc =3D mpxy_get_shmem_size(&mpxy_shmem_size); + if (rc) + return dev_err_probe(dev, rc, "failed to get MPXY shared memory size\n"); + + /* + * Setup MPXY shared memory on each CPU + * + * Note: Don't cleanup MPXY shared memory upon CPU power-down + * because the RPMI System MSI irqchip driver needs it to be + * available when migrating IRQs in CPU power-down path. + */ + cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "riscv/sbi-mpxy-shmem", + mpxy_setup_shmem, NULL); + + /* 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 kcalloc(mbox->channel_count, sizeof(*channel_ids), GFP_KE= RNEL); + 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 get 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; + } + + /* 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 (dev_of_node(dev)) + of_msi_configure(dev, dev_of_node(dev)); + } + + /* 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"); diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/ge= neric.h index c9a4c96c9943..b3705e8bbe2b 100644 --- a/include/linux/byteorder/generic.h +++ b/include/linux/byteorder/generic.h @@ -173,6 +173,22 @@ static inline void cpu_to_le32_array(u32 *buf, unsigne= d int words) } } =20 +static inline void memcpy_from_le32(u32 *dst, const __le32 *src, size_t wo= rds) +{ + size_t i; + + for (i =3D 0; i < words; i++) + dst[i] =3D le32_to_cpu(src[i]); +} + +static inline void memcpy_to_le32(__le32 *dst, const u32 *src, size_t word= s) +{ + size_t i; + + for (i =3D 0; i < words; i++) + dst[i] =3D cpu_to_le32(src[i]); +} + static inline void be16_add_cpu(__be16 *var, u16 val) { *var =3D cpu_to_be16(be16_to_cpu(*var) + val); --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.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 5AAAA22A7EA for ; Wed, 11 Jun 2025 06:23:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623036; cv=none; b=DPftHp6rgVgusXQXX2CyGd7zm8ty1mFADmqkm4lR4EEPd1n/M71yQiCpT7ygc49lmV+mTYZvMmlRS3hhZbY0ULYxbuaBF+Dkt0LhtSNvQxHjk+NbKWqHu2LecbGibqY3jNdkTpo+WkAEK+nEMJDpGBnj6+aacZ3sFooGH+cp+Ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623036; c=relaxed/simple; bh=ixtMiU2D4CI1HtrYrYpElhcrFaz7rwFs2Q8kTElmxqw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q8TOMxfwRyyk5BcE+VojIv2RxJnGLKoqzimt8eVtR7sSjhsECj8WbEm4zxEFR4cgGiHvvElo4oxidETF4/ZZxxQOD1tV+cpBhS5O1vafpCLcLjKCve0OtHBN3kxK7h9f/lDRWttf9HhQeg8uZHGyHN5tHcJqQr62xBbb3YkbRhg= 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=kwD1nFQl; arc=none smtp.client-ip=209.85.214.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="kwD1nFQl" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2360ff7ac1bso29899975ad.3 for ; Tue, 10 Jun 2025 23:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623035; x=1750227835; 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=cwcoSzaHJb2ZCurp/5PmtA9kG6Ysfjka/p/8DDzX1ZM=; b=kwD1nFQlke8qAryYMGsggQ3VsGwfpOZ0QD1iUSx+cs5djaanqnCpWtVdnlMhgGQgDE K4qcaEE20UiAAs641m/KDHhPDIZeOsoRGTcUNNey5kyYAniFjn/n6vqiri+w2wXYcqiY LtuBQ/rftbuG+r9r7qQpEKvORj4nTJcxUI+F7bsxEI/BQXaUehqZa7FP+NcZHL4Og5jg Jl2BO6aaglx0hROdfb6qeZKZpy3OKf6ijz3k6P3rexeb6YOHpfFsPu4vk8l9k5I+zCc6 4XCoufjMVEiB2eVk+I2udVeqnMdfPfNUbWMmUxiEpZW1XjDvUM3RplJ0ljgFuzv1aAXV LfuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623035; x=1750227835; 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=cwcoSzaHJb2ZCurp/5PmtA9kG6Ysfjka/p/8DDzX1ZM=; b=VEEPLm1l/5HIyz60PKNdMLbny4SM3g0tRQibUg8iBD6u9cL7TlhUTo2PfSpxP8ojy8 HFubD0QC/Neef/lNVtjxMtejUs4DUAdoqi4L8lMP+vZShkzCBlvtzJ8crQwfNVrRPU3q PnvOqxggacHtLDQWLE1Qq9sG6ECc+yRwly7UGW0Yazuz9Ac5TzECEx11bDS3DAPejsEf nOA0vtrKF/BVwGb2rsd8SULYCxcGbzBlUK2hG86XxWcr99AZaQwkL5AXZ3bNe6Wgv0tX D+axxeE5/3bFVEE80cTRa4aw/qT0Ubf71pV5Z+fLCsNKHwPQBjPfCzCMXFw+O4D/Kh28 XP1A== X-Forwarded-Encrypted: i=1; AJvYcCWvSjJniGPqsPi6AIUe1yzOkTFrZAwxCsgrzbpy9v/YFqpniZsswYZOa3YiZubz873IG67Vf6AVvBh5Iwc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9ZUswuUAtCh0yokW+dm80i+c1Afky5R6Zb8DeNXd+1cJiICAX ZCgKeEnJDdbwfaHJpV5bjJwlEM5nhxcwAJLobI9VtAwhfPfb0/dD8bnhCnJKzosLn1w= X-Gm-Gg: ASbGncsk2JkQFSeIe4/i2ATkribPh4hUNpIhUPNe7aACQgaNzpSnuiiEclsjTSTFOu4 3w6dDDh7cCl24bMF/bLnOBzswSmL/oNu3s0q90rETJ1O+vzlqowSwfqkVTeZOwwYdjFpv5H2tz7 z46dDeIDdWUQPkwk3SRS01p52XiUsEyMyXnataO3KL0aJlbBvx0Dur2YnrWHO0OUgSjhuaj70lN 3IdxKjiLxcWO35B2LINMhXQ8dTi6Iep7L/5tyerzf8y/rpryrtVoyDJAQC3YLwnllgZbkQDw05a W0mXcPpo7z0dhisKIQWNSGQWsPHhUiUZIkYLZrsV+g0iTmoKQ+e3+oHXHWRWpOeDy5zbjfZeBet xYXdrcEBosTzg4LINRl8XUvhcAvBlApLW4pmP X-Google-Smtp-Source: AGHT+IG9id6m8Zy9UeNhLHSX7++7xXKKHDlsuc22eIa03d0VgxiugN4v4fTC06zY+RU03tXIbah2jg== X-Received: by 2002:a17:902:d552:b0:224:1af1:87f4 with SMTP id d9443c01a7336-23641abe7c2mr35316405ad.22.1749623034551; Tue, 10 Jun 2025 23:23:54 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:23:54 -0700 (PDT) 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: [PATCH v5 07/23] dt-bindings: clock: Add RPMI clock service message proxy bindings Date: Wed, 11 Jun 2025 11:52:22 +0530 Message-ID: <20250611062238.636753-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 RPMI clock service group based message proxy implemented by the SBI implementation (machine mode firmware or hypervisor). The RPMI clock service group is defined by the RISC-V platform management interface (RPMI) specification. Signed-off-by: Anup Patel --- .../bindings/clock/riscv,rpmi-mpxy-clock.yaml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/riscv,rpmi-mpxy= -clock.yaml diff --git a/Documentation/devicetree/bindings/clock/riscv,rpmi-mpxy-clock.= yaml b/Documentation/devicetree/bindings/clock/riscv,rpmi-mpxy-clock.yaml new file mode 100644 index 000000000000..70ffc88d0110 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/riscv,rpmi-mpxy-clock.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/riscv,rpmi-mpxy-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V RPMI clock service group based message proxy + +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. The SBI implementat= ion + (machine mode firmware or hypervisor) can implement an SBI MPXY channel + to allow RPMI clock service group access to the 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) v1.0 (or higher) + https://github.com/riscv-non-isa/riscv-rpmi/releases + + [2] RISC-V Supervisor Binary Interface (SBI) v3.0 (or higher) + https://github.com/riscv-non-isa/riscv-sbi-doc/releases + +properties: + compatible: + description: + Intended for use by the SBI implementation. + const: riscv,rpmi-mpxy-clock + + mboxes: + maxItems: 1 + description: + Mailbox channel of the underlying RPMI transport. + + 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. + +required: + - compatible + - mboxes + - riscv,sbi-mpxy-channel-id + +additionalProperties: false + +examples: + - | + clock-controller { + compatible =3D "riscv,rpmi-mpxy-clock"; + mboxes =3D <&rpmi_shmem_mbox 0x8>; + riscv,sbi-mpxy-channel-id =3D <0x1000>; + }; +... --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) (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 CB2B622CBF9 for ; Wed, 11 Jun 2025 06:24:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623060; cv=none; b=hVIWIK2W7USZ+7eXbFChqgX3MR2baDWKKVL6bWLxJC9/zwkM5VZ4wPBU3eFis9hwhjfvvjcGW8Yf5oARD4KpEazEWHOrrp9UFTcUErM2tlp4UqNF38BJw7hI3jxMRI2XRSElWxcc25AN0LgY3vjzdxShKcgfafcvR2LtpWRrmz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623060; c=relaxed/simple; bh=kiEk/ZTgWEHqlvZDH0biu08pH7LpqLelaz9eTEzcvxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=paHFsv+w5FU8kQWf19t5Ia0VQdXP4q1yRncC3E3NyLBqEFmMbg9wu+8uiSQQlmWM2Th14KZpv3p9Csh9lqc39CiuJpM0irrMjPOceuhg4/JUJK5oR0Z1vpM+E9BQF3b2PgTapCRvGnOcL0ruHbbWu7lQ2Eite01MptnL95bzDQA= 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=gRh0O3AQ; arc=none smtp.client-ip=209.85.166.44 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="gRh0O3AQ" Received: by mail-io1-f44.google.com with SMTP id ca18e2360f4ac-86a07a1acffso517340539f.0 for ; Tue, 10 Jun 2025 23:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623055; x=1750227855; 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=Qbog2jwuTz9DCLB0jUubllQdhYVAN+AQfO1Y2vWOezM=; b=gRh0O3AQ+vatfZUdj9xuxO6Ws9Y1f2PxpeP0a1yDJc0bzJOaom2EvItJ6X/2XEYYJY ylKnBjOeNxAKli1OuQTC1PMKlOhSEYyIEp5s5BET4uoVNqB5fMvOoNzmgaSLNmfekWeU cfv9Y40prMHc3fzm/pxyHxP8l/G6NNPtpUexa5O/eaEEZUg9qmF8troHNICBK0GpWmbM E4HisxRWWA+I+TqJJnZA5GT/J0kKY+5Gzm0Ef5c26J/HUqu+4ueZyrTKKXkklmoink/R iS38ol7RRybrrAxb1upnhkhMFjjiaHZU+F+hvHSAznz6d9PQrdEGeI5J0hef80Nea0K+ q0rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623055; x=1750227855; 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=Qbog2jwuTz9DCLB0jUubllQdhYVAN+AQfO1Y2vWOezM=; b=SbZGkvWGlnG67Y5LqB9N5hkofemnhVl+dleegN5Zpktc1mVNT1/1G08B9WX/jGyWdQ 0ZlAm6ipXNojAuHu28NvrGRNDx9UXLq6uS1wn2AxNuNIuRQ3d9SP1OdTeGe1bbz1BzZF P9Is1AF13lXTloZZgyeEFjZH/MYOfQ/MvcaTp6xg5mU5MguCVADdNVNpeodZii5xEoHb Uj6kpuA+9YF2ps0xncRUVTK1FVCEoeNcltQg2INw4RgmgchobrZwk7363g3d5XIm7br7 VyKC2diWjXHR1Wr5DaUaduvxMAbc+wVqrSVgImtBbAoQzhMxd/ogrqNGvaQqZmIeHMnF WAzQ== X-Forwarded-Encrypted: i=1; AJvYcCVWLT6h4qdiDsKc7jHchlZfQODjOFWL8yI07RK8+TzsRMQ6EZLrZ+tmHwl95y0Rn5BSBgykZNmeK7gCI+A=@vger.kernel.org X-Gm-Message-State: AOJu0YxZCtF77FrJp6RgByqx9fFLJNF/SBtys9yrSy9Ei0SJC4ZUiJ3f gU3PD/6rEyD4JMwhUlv5Nh8YW4lpTZSYYJZULyHVvmCAdfj8jOqKm6wtlHOgxlQwve70FO08HtR pqt+HSSg= X-Gm-Gg: ASbGncsERUDMPk4JOGXuNbkELVvVxV9QToe4sKj2SRHxgviIsX7BUH3EDU2+RFJ8sat 8yq+I6NN5/EWIFym5BbPxpa9KyS8Tr2712W0sybrzoMYDUYcuKLtdKXAixLeqADLCigp3gHYWhw /kyBUD2C8tEJ0yisfTy4oxfWx5e5WsxHzExlEAgkP6HfNxtv6OvoVF5xSCmWO0b0ynIiFK+zXlt O2/LTv6i7gDRw9ArqixLF3wn801dAWy4Ue4kf3QDQvSRCrROMB19YCcRwBuFixtsce1wCFUiJzL 9s5N2ONkv+Xb4NIkH6kPZ38fT8/VjuGmpifk28e7ZmU8KbFvTtGfRyY9CAhpXzkMP1JmMWQ8Iho 5z8e4F+mecLkS6SaRUc5HlHKAgg== X-Google-Smtp-Source: AGHT+IGE45Nw6cMjQHpSv5lLGxPQof36xcySb3y/f0xaMoClmIInPuw4tRKfvCta688qmeWHkxBrmg== X-Received: by 2002:a17:902:d2c6:b0:234:db06:ac0 with SMTP id d9443c01a7336-23641b16ccbmr26600515ad.45.1749623043547; Tue, 10 Jun 2025 23:24:03 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:24:03 -0700 (PDT) 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 , Conor Dooley Subject: [PATCH v5 08/23] dt-bindings: clock: Add RPMI clock service controller bindings Date: Wed, 11 Jun 2025 11:52:23 +0530 Message-ID: <20250611062238.636753-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 RPMI clock service group based controller for the supervisor software. The RPMI clock service group is defined by the RISC-V platform management interface (RPMI) specification. Signed-off-by: Anup Patel Reviewed-by: Conor Dooley --- .../bindings/clock/riscv,rpmi-clock.yaml | 64 +++++++++++++++++++ 1 file changed, 64 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..5d62bf8215c8 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/riscv,rpmi-clock.yaml @@ -0,0 +1,64 @@ +# 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. The supervisor + software can access RPMI clock service group via SBI MPXY channel or + some dedicated supervisor-mode RPMI transport. + + =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) v1.0 (or higher) + https://github.com/riscv-non-isa/riscv-rpmi/releases + + [2] RISC-V Supervisor Binary Interface (SBI) v3.0 (or higher) + https://github.com/riscv-non-isa/riscv-sbi-doc/releases + +properties: + compatible: + description: + Intended for use by the supervisor software. + const: riscv,rpmi-clock + + mboxes: + maxItems: 1 + description: + Mailbox channel of the underlying RPMI transport or SBI message prox= y channel. + + "#clock-cells": + const: 1 + description: + Platform specific CLOCK_ID as defined by the RISC-V Platform Managem= ent + Interface (RPMI) specification. + +required: + - compatible + - mboxes + - "#clock-cells" + +additionalProperties: false + +examples: + - | + clock-controller { + compatible =3D "riscv,rpmi-clock"; + mboxes =3D <&mpxy_mbox 0x1000 0x0>; + #clock-cells =3D <1>; + }; +... --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 344D722A7EA for ; Wed, 11 Jun 2025 06:24:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623055; cv=none; b=JFcP6cSYujIWd0l9poWEbpW1G9sXUpPygom3oYxzQfgZQSFqO4lLNchwKdomqHgKCjpbrFl5VqtyZXzlYXvAwDozgDSx2YXKcSQrZ5eQGQ+efGPx5oCgG7ze+MFUACoJllO8dtC/E2bDisCtBhSXue6XmZ3Jt+sHDkKv/Z7b344= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623055; c=relaxed/simple; bh=qRUOoQn29q8euP6DvdAbGGR2ijys85RAIdL1gthkaEQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U8fpLPBWZKzTB+arss1hrvi/23ywN+MCzLqf1RvSK2LEogiuAfFL8zd3F0hdUTNhYCbLORKZkTU3UMISKBHK2tepYLluwyAuhENZY1C0JqFVzXC0/RDZCo0qzw1Yayzn6ScCrmTDROFgBh7c3jNevTi9tG4UP0ykuzjz1ADKilw= 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=iEAZzvYk; arc=none smtp.client-ip=209.85.214.177 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="iEAZzvYk" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2353a2bc210so54791675ad.2 for ; Tue, 10 Jun 2025 23:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623052; x=1750227852; 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=DvYqEbFY8I23pm0rhV4+IN+0B5WEBt2DfCgF297594M=; b=iEAZzvYkmvNgi1w3Z3rOJ1gDThgPDgH2V9MB4bbdL6JAcbCuIgy7cbrlhpMyVf8L18 vuiDXdPQI9Qc4Lj/jNvpbwilkf+ppld7LrQg7DhTJQywuNZcYj+XM4Beab7GBZC6uHGa q5+8UQTuX8J7DxLii69N1bdL60z3xVjSb66UxdZMA+XZw4w303GEGbbx/dgN65zmbON6 2a+HMlfBB16bXYlUr2X8LJwHsNJfF8mHfwWGoqndAg1LXAJDHfZ7jjPkcd/MRPc3KvIM L4WZt5yinf+p3VnxRcZgj12Y3JINdd57ksdB8DongAVevD2UT+r3547Qf/+0bIwhdFVk hZ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623052; x=1750227852; 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=DvYqEbFY8I23pm0rhV4+IN+0B5WEBt2DfCgF297594M=; b=KUDO1diLOu2bCkYkw60s2HI1sN2hQtstprRwmAf/wAk0PXpCqdmWXDVI0RdSPr0BWL mbCBqsOideD2PemFY9/ki4SFdKp27zjEfG1PVkbrqHD8hrcbI5POUMcCQRo6sjp8ksKX qvWMFIjHV4FjLIGn9dcMRLdWG+3frskTQXCWFSPqaVf/rC3629VIgmFR4jLgnUhVIDOp MTbfGo2F3Zd3fymbBFnvvB3+g6fuVctSGKWcaJTMFcSP25ufHcT5tSVSJ3cumg+Pymg9 hUkuzhM+tSTYSxWNY4RFXTsbNsreC8UauyJOUH/k+NuB3vObE6nnyeqYtd+jTrDh6/Zr dG0A== X-Forwarded-Encrypted: i=1; AJvYcCULVVR7nb/g/qU5UjGPWqXV7uD8nMEg6C04zWuPTIrHIu+SI+c5memsobpNERIZ9T23kXa0F/4btGWefD0=@vger.kernel.org X-Gm-Message-State: AOJu0YxqC+HqS0L6f3zErCRkOCjYBDbf17JqtKBpvcTxKodYygDeyTxX nO9TQWHXv7AAgmRWMFMpl+BsD+Y96PmHC8FS/cirCUkJY4/tjvZOmMG1vC4/1Px1Uag= X-Gm-Gg: ASbGncu/jFZ2dhMMUyXd+gzJMhveLRU2y0h9jTTxHBhbhiZVzgIggVNz/jAooXjF8ZJ 67uMcp3NVBOIL/13HiQDwL/KkWqCL7ZCZ5dTg3/4BJI/bdkSIYHoxJ8XGi9MxfuIsds55Q/ytE5 l3D1lPZ9uUEHjwbiTIVg9z4rIqDaSmUhbBLgkGv05rbivkokSwyZzsHDKdKT14g2wd1Um5upa9c mt+6BxPxzy/iQ8l1WgqDevQdpDLZfw0sIA6Jc6wxJm3aZimSY+mfg/baopkSIKVaOLMh5dVAZFF p0ukZ50mcPFY3rJUq9faPch/T4+ol/URfdbUYv4lIRualbeT8NVvawFP3t3gw/7bJys5ahtpmFi xG0Jr4eHj67kvb+bm4iwzlrhBnQ== X-Google-Smtp-Source: AGHT+IEg87o1wwncGB2Cm+sPAB1o1MDiedH6xVW3S7RiXlY7h9OYc4WI6S7gB3LmNILeQa8LxUnSfA== X-Received: by 2002:a17:903:1acb:b0:235:27b6:a897 with SMTP id d9443c01a7336-23642683e40mr25287935ad.34.1749623052381; Tue, 10 Jun 2025 23:24:12 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:24:11 -0700 (PDT) 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: [PATCH v5 09/23] clk: Add clock driver for the RISC-V RPMI clock service group Date: Wed, 11 Jun 2025 11:52:24 +0530 Message-ID: <20250611062238.636753-10-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 | 590 +++++++++++++++++++++ include/linux/mailbox/riscv-rpmi-message.h | 16 + include/linux/wordpart.h | 8 + 5 files changed, 623 insertions(+) create mode 100644 drivers/clk/clk-rpmi.c diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 19c1ed280fd7..2e385b146f8b 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 42867cd37c33..48866e429a40 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..61c27ef2840f --- /dev/null +++ b/drivers/clk/clk-rpmi.c @@ -0,0 +1,590 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * RISC-V MPXY Based Clock Driver + * + * Copyright (C) 2025 Ventana Micro Systems Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RPMI_CLK_DISCRETE_MAX_NUM_RATES 16 +#define RPMI_CLK_NAME_LEN 16 + +#define to_rpmi_clk(clk) container_of(clk, struct rpmi_clk, hw) + +#define rpmi_clkrate_u64(hi, lo) make_u64_from_two_u32(hi, lo) + +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; +}; + +struct rpmi_clk_rate_discrete { + __le32 lo; + __le32 hi; +}; + +struct rpmi_clk_rate_linear { + __le32 min_lo; + __le32 min_hi; + __le32 max_lo; + __le32 max_hi; + __le32 step_lo; + __le32 step_hi; +}; + +struct rpmi_get_num_clocks_rx { + __le32 status; + __le32 num_clocks; +}; + +struct rpmi_get_attrs_tx { + __le32 clkid; +}; + +struct rpmi_get_attrs_rx { + __le32 status; + __le32 flags; + __le32 num_rates; + __le32 transition_latency; + char name[RPMI_CLK_NAME_LEN]; +}; + +struct rpmi_get_supp_rates_tx { + __le32 clkid; + __le32 clk_rate_idx; +}; + +struct rpmi_get_supp_rates_rx { + __le32 status; + __le32 flags; + __le32 remaining; + __le32 returned; + __le32 rates[]; +}; + +struct rpmi_get_rate_tx { + __le32 clkid; +}; + +struct rpmi_get_rate_rx { + __le32 status; + __le32 lo; + __le32 hi; +}; + +struct rpmi_set_rate_tx { + __le32 clkid; + __le32 flags; + __le32 lo; + __le32 hi; +}; + +struct rpmi_set_rate_rx { + __le32 status; +}; + +struct rpmi_set_config_tx { + __le32 clkid; + __le32 config; +}; + +struct rpmi_set_config_rx { + __le32 status; +}; + +static u32 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 || rx.status) + return 0; + + return le32_to_cpu(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(le32_to_cpu(rx.status)); + + rpmi_clk->id =3D clkid; + rpmi_clk->num_rates =3D le32_to_cpu(rx.num_rates); + rpmi_clk->transition_latency =3D le32_to_cpu(rx.transition_latency); + strscpy(rpmi_clk->name, rx.name, RPMI_CLK_NAME_LEN); + + format =3D le32_to_cpu(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 __free(kfree) =3D NULL; + 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 kzalloc(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(le32_to_cpu(rx->status)); + if (!le32_to_cpu(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 < le32_to_cpu(rx->returned); rateidx++) { + rpmi_clk->rates->discrete[rateidx] =3D + rpmi_clkrate_u64(le32_to_cpu(rate_discrete[rateidx].hi), + le32_to_cpu(rate_discrete[rateidx].lo)); + } + + /* + * Keep sending the request message until all + * the rates are received. + */ + while (le32_to_cpu(rx->remaining)) { + clk_rate_idx +=3D le32_to_cpu(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(le32_to_cpu(rx->status)); + if (!le32_to_cpu(rx->returned)) + return -EINVAL; + + for (j =3D 0; j < le32_to_cpu(rx->returned); j++) { + if (rateidx >=3D clk_rate_idx + le32_to_cpu(rx->returned)) + break; + rpmi_clk->rates->discrete[rateidx++] =3D + rpmi_clkrate_u64(le32_to_cpu(rate_discrete[j].hi), + le32_to_cpu(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 rpmi_clkrate_u64(le32_to_cpu(rate_linear= ->min_hi), + le32_to_cpu(rate_linear->min_lo)); + rpmi_clk->rates->linear.max =3D rpmi_clkrate_u64(le32_to_cpu(rate_linear= ->max_hi), + le32_to_cpu(rate_linear->max_lo)); + rpmi_clk->rates->linear.step =3D rpmi_clkrate_u64(le32_to_cpu(rate_linea= r->step_hi), + le32_to_cpu(rate_linear->step_lo)); + } + + 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 rpmi_to_linux_error(le32_to_cpu(rx.status)); + + return rpmi_clkrate_u64(le32_to_cpu(rx.hi), le32_to_cpu(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) + return 0; + + fmin =3D rpmi_clk->rates->linear.min; + fmax =3D rpmi_clk->rates->linear.max; + + if (req->rate <=3D fmin) { + req->rate =3D fmin; + return 0; + } else if (req->rate >=3D fmax) { + req->rate =3D fmax; + return 0; + } + + 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; + + 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(le32_to_cpu(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(le32_to_cpu(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(*rates), GFP_KERNEL); + if (!rates) + return ERR_PTR(-ENOMEM); + + rpmi_clk =3D devm_kzalloc(dev, sizeof(*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\n", + clkid); + + 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\n", + clkid); + + 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) +{ + int ret; + unsigned int num_clocks, i; + struct clk_hw_onecell_data *clk_data; + struct rpmi_clk_context *context; + struct rpmi_mbox_message msg; + struct clk_hw *hw_ptr; + struct device *dev =3D &pdev->dev; + + context =3D devm_kzalloc(dev, sizeof(*context), GFP_KERNEL); + if (!context) + return -ENOMEM; + context->dev =3D dev; + platform_set_drvdata(pdev, context); + + 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; + + context->chan =3D mbox_request_channel(&context->client, 0); + if (IS_ERR(context->chan)) + return PTR_ERR(context->chan); + + rpmi_mbox_init_get_attribute(&msg, RPMI_MBOX_ATTR_SPEC_VERSION); + ret =3D rpmi_mbox_send_message(context->chan, &msg); + if (ret) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, ret, "Failed to get spec version\n"); + } + if (msg.attr.value < RPMI_MKVER(1, 0)) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, -EINVAL, + "msg protocol version mismatch, expected 0x%x, found 0x%x\n", + RPMI_MKVER(1, 0), msg.attr.value); + } + + rpmi_mbox_init_get_attribute(&msg, RPMI_MBOX_ATTR_SERVICEGROUP_ID); + ret =3D rpmi_mbox_send_message(context->chan, &msg); + if (ret) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, ret, "Failed to get service group ID\n"); + } + if (msg.attr.value !=3D RPMI_SRVGRP_CLOCK) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, -EINVAL, + "service group match failed, expected 0x%x, found 0x%x\n", + RPMI_SRVGRP_CLOCK, msg.attr.value); + } + + rpmi_mbox_init_get_attribute(&msg, RPMI_MBOX_ATTR_SERVICEGROUP_VERSION); + ret =3D rpmi_mbox_send_message(context->chan, &msg); + if (ret) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, ret, "Failed to get service group version\n"); + } + if (msg.attr.value < RPMI_MKVER(1, 0)) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, -EINVAL, + "service group version failed, expected 0x%x, found 0x%x\n", + RPMI_MKVER(1, 0), msg.attr.value); + } + + rpmi_mbox_init_get_attribute(&msg, RPMI_MBOX_ATTR_MAX_MSG_DATA_SIZE); + ret =3D rpmi_mbox_send_message(context->chan, &msg); + if (ret) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, ret, "Failed to get max message data size\n"); + } + + context->max_msg_data_size =3D msg.attr.value; + num_clocks =3D rpmi_clk_get_num_clocks(context); + if (!num_clocks) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, -ENODEV, "No clocks found\n"); + } + + clk_data =3D devm_kzalloc(dev, struct_size(clk_data, hws, num_clocks), + GFP_KERNEL); + if (!clk_data) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, -ENOMEM, "No memory for clock data\n"); + } + clk_data->num =3D num_clocks; + + for (i =3D 0; i < clk_data->num; i++) { + hw_ptr =3D rpmi_clk_enumerate(context, i); + if (IS_ERR(hw_ptr)) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, PTR_ERR(hw_ptr), + "failed to register clk-%d\n", i); + } + clk_data->hws[i] =3D hw_ptr; + } + + ret =3D devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); + if (ret) { + mbox_free_channel(context->chan); + return dev_err_probe(dev, ret, "failed to register clock HW provider\n"); + } + + return 0; +} + +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 fca1f18d93eb..476a2d64d972 100644 --- a/include/linux/mailbox/riscv-rpmi-message.h +++ b/include/linux/mailbox/riscv-rpmi-message.h @@ -90,6 +90,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, diff --git a/include/linux/wordpart.h b/include/linux/wordpart.h index ed8717730037..5cad9c244bf2 100644 --- a/include/linux/wordpart.h +++ b/include/linux/wordpart.h @@ -39,6 +39,14 @@ */ #define make_u32_from_two_u16(hi, lo) (((u32)(hi) << 16) | (u32)(lo)) =20 +/** + * make_u64_from_two_u32 - return u64 number by combining + * two u32 numbers. + * @hi: upper 32 bit number + * @lo: lower 32 bit number + */ +#define make_u64_from_two_u32(hi, lo) (((u64)(hi) << 32) | (u32)(lo)) + /** * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long va= lue * @x: value to repeat --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.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 665DE228CB2 for ; Wed, 11 Jun 2025 06:24:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623064; cv=none; b=LVXtYZQmiP4dzoMqKCJnnenkj/OYT2qtQukkxWO1p0Pav2dTugimzVAPFQo4Qo+fO3JpX3Bt9Y2vhmX0PgH0MQJnc6H5PQkj1nx6hqDk2RqGX9AUpPnbv97eiVtgWSHrAr9LJwVNAq/mn0LZ5t2MXJi401PcHuR5Y1RKyB3m/SA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623064; c=relaxed/simple; bh=mi0izh3V1w9zIu9t+K/AZ06nOfi2ewD/Fyi9Z/NlWW8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AVSyLWKwaAsH43+6JTFW77+f+YM0iBcb90YNBaAvPdnL7fETYrLD0thdMQJkDdm0LxsfnsoNCoQSRsgHQ2ZqkAuhVccKWJZFOjyCEIzxeLlWAvV+tYoK60PKBJcdGWEWlKLOnc8HSL2VyTutfk38RUfVDABaNeq/J1+QuVToR6o= 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=BQURl9rx; arc=none smtp.client-ip=209.85.215.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="BQURl9rx" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-b2f1032e1c4so5830263a12.3 for ; Tue, 10 Jun 2025 23:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623061; x=1750227861; 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=ouV1lfFQuaSRkTiMApd+jhohkzp55I7SRD5LPqlFAqQ=; b=BQURl9rxH41i8jWffVV62xJwi0LH0e93chV92Nwbv8C6uKn5BGyPPqW9GveJAFfVh4 1uzcI0mAEecmCtkFbLMTAam3tWip1swqn4kl45h+d2aEFvcyMm1c6WqeJKTiYFxwIxME Lq+yotyqOzsH3ntxdemRijB866dWHv3Jmvjul/xKQ7RZg1KyJ5AC6p1RYqFIZVngGc1a XwXWkM3pqZSE0z1zRgJlTSm4YzYKQjXfg9EJgNaCfJ5VWdi4GquZYmyC1eT9GKWnIQIB PraHXFXgfV4ihkDQIrZjh6W/TWQ2oHsyk5tOQ5XrI5ne/ypRX9luz4RmGiehvBZ3LHvU 7BmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623061; x=1750227861; 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=ouV1lfFQuaSRkTiMApd+jhohkzp55I7SRD5LPqlFAqQ=; b=i/NAUuR9HKghgDZhYm8oqx2BoESKsX6DvAx9kPpeRPX7J3Xtv12XertYnWhV3Y9sGk 4UtBW2jZOdMVfrc7kIHmotcmOdevdCQZ6q+mBAMJEogp4OsCDfPfDbci7LsTaMFRbPfX x1v9jsbtJtvYBIIwl4K/x4IwETX8syDfTnBa5vfp2TQcKz33bO1NHU9pGBS4e+p7uVJg G1WMHCY2tERZXvgnawU3spKOn5xmjhkMHmeRJrD8pvPuv9jTFvSAAEfqfHhdaeO6Pl+L 1PiWYXaYz4v4E4ITJ+QeAGaqgcg3muuveUKDcYDJa1u569ap9C8cwO6X4zMvlHZcfQCL t32Q== X-Forwarded-Encrypted: i=1; AJvYcCVvDkVH2Wq/oArCvcZOG74P/IRoz4MRVTvRpeVvhQjgrHNPqJO70mF/K5abvIHQQSRFzJ1S4dAgaW+aGJ8=@vger.kernel.org X-Gm-Message-State: AOJu0Ywziu4xsar7YEmCg0FUgum8SwGFRTIfb0eH+jx9ofuaGae6zisA QnwP69Y2a1wfatoBaPWAHmWUpCHREsZ+poCiR+GWDWCSs5ScePTYk6HpiIkJcUnL1+4= X-Gm-Gg: ASbGncvwvBDzfpjVA7cWr1oodcWicTDKhuuOC008zE2py1Uxt0wzxF6QVbGyxvqmhaa 5wFUReA8ZVz0p8ZvbqDC+dHl1x2o6vmcvVB3385hAzbs0qFdKSPCFahuHjme+hLZ1hDx+0+gisH LCx51kMysxAbR1MxxWSIVpX41e8tqbwt+C9a+hS/5iMEJEIGtAp1bDX4o023gQS8hcVx2VyyRgH G1spNNoZRzgFA/sM7kl8E2OEXHCYl9mYw0SrQkXtho8YpIhdFIimUX34dZAo3V1wg/Lc3MkYgML OMUvrBCNxClNEEoFuDfMUfwddp8c+1hw0Z56iu64NDt2Uu+dfMjE2HFmr3wUOvEMPfiWAALVbL0 +uqbmfsQNfkcoJTuPeQT8Iu3vyA== X-Google-Smtp-Source: AGHT+IF5xkQyWQjwsl09XW4wn7LAnApaVtCZljCguqKxttJEhx2sYRFEJxu4xU+pC+wX1ttAHSWSbA== X-Received: by 2002:a17:90b:1dcf:b0:311:d28a:73ef with SMTP id 98e67ed59e1d1-313b1ef5898mr2232034a91.10.1749623061442; Tue, 10 Jun 2025 23:24:21 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:24:20 -0700 (PDT) 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 , Atish Patra Subject: [PATCH v5 10/23] dt-bindings: Add RPMI system MSI message proxy bindings Date: Wed, 11 Jun 2025 11:52:25 +0530 Message-ID: <20250611062238.636753-11-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 RPMI system MSI service group based message proxy implemented by the SBI implementation (machine mode firmware or hypervisor). The RPMI system MSI service group is defined by the RISC-V platform management interface (RPMI) specification. Reviewed-by: Atish Patra Signed-off-by: Anup Patel --- .../riscv,rpmi-mpxy-system-msi.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/= riscv,rpmi-mpxy-system-msi.yaml diff --git a/Documentation/devicetree/bindings/interrupt-controller/riscv,r= pmi-mpxy-system-msi.yaml b/Documentation/devicetree/bindings/interrupt-cont= roller/riscv,rpmi-mpxy-system-msi.yaml new file mode 100644 index 000000000000..1991f5c7446a --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/riscv,rpmi-mpx= y-system-msi.yaml @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/riscv,rpmi-mpxy-sy= stem-msi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V RPMI system MSI service group based message proxy + +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. + The SBI implementation (machine mode firmware or hypervisor) can + implement an SBI MPXY channel to allow RPMI system MSI service + group access to the 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) v1.0 (or higher) + https://github.com/riscv-non-isa/riscv-rpmi/releases + + [2] RISC-V Supervisor Binary Interface (SBI) v3.0 (or higher) + https://github.com/riscv-non-isa/riscv-sbi-doc/releases + +properties: + compatible: + description: + Intended for use by the SBI implementation. + const: riscv,rpmi-mpxy-system-msi + + mboxes: + maxItems: 1 + description: + Mailbox channel of the underlying RPMI transport. + + 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. + +required: + - compatible + - mboxes + - riscv,sbi-mpxy-channel-id + +additionalProperties: false + +examples: + - | + interrupt-controller { + compatible =3D "riscv,rpmi-mpxy-system-msi"; + mboxes =3D <&rpmi_shmem_mbox 0x2>; + riscv,sbi-mpxy-channel-id =3D <0x2000>; + }; +... --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.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 7AB0A22A7E7 for ; Wed, 11 Jun 2025 06:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623073; cv=none; b=fpSeglBkmRGueqtoNyG43mX21TjXkm0607i7+z4/p+MOedYlBtBI40guGgiDxZJEYUcB37hOKI3CfzrqxNcXcNSqCP46KZhj1pMLMyBadDMgthmcmX6rjwodvCCA/ql9u4JwTu0eUqdqySSZjchyhgd6yTHcp1YXf8FeFJHx2Qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623073; c=relaxed/simple; bh=8kvFLEv/hykXIxvvHlFxYncEhD8VC0PQqlwZgaO68IE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gJx71WCNYhAXwNMINmNbx31v0vhCAYvpWpm3rJZXhwszeSYihJb/MGl+cEZsi4X+ALrvtqTRhINazCCiNBWR5iHEIerfiHv2pQP6qqHZPlf8CgCP+ZyypmBLyyjGgOM1eWbuD4MqAi434Mcwc7ntJ055NLGefqB/axKduaCBfj8= 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=YhNIoPCH; arc=none smtp.client-ip=209.85.214.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="YhNIoPCH" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-234d366e5f2so71482885ad.1 for ; Tue, 10 Jun 2025 23:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623071; x=1750227871; 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=pIz85jrszx9X2n7VJMwt6ECwmZMzZVLMduOipCTmFkU=; b=YhNIoPCHI27jgGe0L83ONZEY8nSfvRjg9rbB1JWZWWQaSYBRDlqfxpJx2DyCSNg2lI XoWhPSMqxljJH9S4ednZbFc2yBBNKJVm/flB34ny8PvalTMQ7mwMLJPToFhMzL4yncnY vcg70HtoQRuQyXck1ZkiV9OG+V/F+Kc9yomw4Ays4sBVlnBTNsfKaHwmeWzaCBenu7+H 7JGB7w633l+hNpaR9udMRG9MStAtn66IAKGsAq7LDTu4hiJiNctfsKoE0x+gh+hlaRrm EoeppGYpsvZcdB0m2KYxzJbfpVTQSgcScSeXcVMCZg/wRvsgA5Ynml5DDrWxrUIqx5/l tnfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623071; x=1750227871; 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=pIz85jrszx9X2n7VJMwt6ECwmZMzZVLMduOipCTmFkU=; b=axjSPqFJs7TNhCRF8+9vg0FhHX1uTuilOTlpGLwnJZTScXAyHFqsVuBCZPRhv/X1AB spdY6SrM8Hez+hDihJ76fsD4ozqrjmnNaTJs0mMe6CHBpDA6C1rsXHyzroK2kwvRxu7H sUF4kF50ZAiHueUA53KkPdRSZ6YlF3IHPiK4F53TftSkR7x+ZbvqH0IjrDA6aA7Kcd50 K+0izSWO2Kb/Rn+t68Z4Wrehaf5bGbSiHHPLPa6BwbRJtKq8nQ4MRmCcEYFAnFvrnVBO Cn672nFeNovq2s8BJQYXFYR4U3U4oSlT7LqSHip2eFTQm/AXt6JITxQ3clnnIHeL8hNq t0zA== X-Forwarded-Encrypted: i=1; AJvYcCWt9GcnDvz5sXjrLGbDZnhEpvrpIs52jiOhGcMKoyhaX5fsW4s374EIAR7ab1kixx//seePguRufMQQy0c=@vger.kernel.org X-Gm-Message-State: AOJu0YyRQ026IRQNnPldXjrnYSepM/FqOdMKQYJ709lCakEo4H52HacD d9ZalZy3DUqdKS9z3ZOgWqLbLTFdueTFreHwJPAkPfxZMJLFkoGdYONjVNj9j4WDPSg= X-Gm-Gg: ASbGncvx1Bdyc5agYaF8mVvlhjjYAGlsiioh0QjYzCc/vIbHzOeUrE8Tyy3Pkp1IwuA +h/8/S+W9uTu3MfJGxA8PSl9YpTJw1Q3GHMhbr1AoxRAB5YWOvULW1MbkxVQHga8yFEvLpKSGCB 0E7K/Gx/c2pZ4RkG+zVv3BuBfTXyS9qod21mN62IE11AlMuH0JPDfkAtGCe10Ytlx28oyhTKyAl 2YwJEh8YePyqUvWgyrEPObeXT1+i/azYG+sfVEgFCAg+pr7rqsruu9syMmwpD2Ck7hXRlnwr3pb NqzauHrET3zYtWx3hL5XpOxiH8rJ8/AsH7DCekyUSdzjD0xdfBVVi2mjqO6tja/okp6ZLOZa+d/ 8jx5Szhej3uroGEQlty1LJ5a5xk68k1io+WZo X-Google-Smtp-Source: AGHT+IHC5ty5QP/q1J3Y57ZfLhayT8WeAP8B2wlbdhm3ivVDvErbI2rY6NWs1ziwWXlteWWsGN8o0g== X-Received: by 2002:a17:903:41cb:b0:235:efbb:953c with SMTP id d9443c01a7336-23641a9a43bmr26770115ad.13.1749623070681; Tue, 10 Jun 2025 23:24:30 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:24:30 -0700 (PDT) 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 , Atish Patra Subject: [PATCH v5 11/23] dt-bindings: Add RPMI system MSI interrupt controller bindings Date: Wed, 11 Jun 2025 11:52:26 +0530 Message-ID: <20250611062238.636753-12-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 RPMI system MSI service group based interrupt controller for the supervisor software. The RPMI system MSI service group is defined by the RISC-V platform management interface (RPMI) specification. Reviewed-by: Atish Patra Signed-off-by: Anup Patel --- .../riscv,rpmi-system-msi.yaml | 74 +++++++++++++++++++ 1 file changed, 74 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..b10a0532e586 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/riscv,rpmi-sys= tem-msi.yaml @@ -0,0 +1,74 @@ +# 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. + The supervisor software can access RPMI system MSI service group via + SBI MPXY channel or some dedicated supervisor-mode RPMI transport. + + =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) v1.0 (or higher) + https://github.com/riscv-non-isa/riscv-rpmi/releases + + [2] RISC-V Supervisor Binary Interface (SBI) v3.0 (or higher) + https://github.com/riscv-non-isa/riscv-sbi-doc/releases + +allOf: + - $ref: /schemas/interrupt-controller.yaml# + +properties: + compatible: + description: + Intended for use by the supervisor software. + const: riscv,rpmi-system-msi + + mboxes: + maxItems: 1 + description: + Mailbox channel of the underlying RPMI transport or SBI message prox= y channel. + + msi-parent: true + + interrupt-controller: true + + "#interrupt-cells": + const: 1 + +required: + - compatible + - mboxes + - msi-parent + - interrupt-controller + - "#interrupt-cells" + +additionalProperties: false + +examples: + - | + 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 Sat Oct 11 10:27:59 2025 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.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 A3D5522FDE7 for ; Wed, 11 Jun 2025 06:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623082; cv=none; b=VNUG+hftjLZojAIZBrQB68wgY5XpK3+sd8tek0/qQVKJ07Y5fSmBhPjzFZ31H5Fv/0I9oQ6K0TYDAUt8mxNNs5b5gV2OLtzuBMOeISFqupmwEtvrhxaEZS6wIk4Oy97avpCKgdMCEF4xhoScHDLrzksLlPPSFHQTGN51667gvek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623082; c=relaxed/simple; bh=IoR5ZMNsRnknwZIs+ARo/sl8063ru3iORRd0xoWZPeQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cg4HI5NwKhVDmRcSSp4LSzD8qVBpAcRatn2J1075WKUp0xLieNuJEWNuX7ZQLYfOq1HD0mtt14v1eAV5r5PKXATwMdJjn3Kp0/xeawzjt6+KN3jOZRqu4mHLBjc+c8rWNWcv9BiXMGL5LaXdIS3a1a576ZkQ74oxhIub/6Rd9qw= 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=DC1YoMec; arc=none smtp.client-ip=209.85.210.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="DC1YoMec" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-747abb3cd0bso402564b3a.1 for ; Tue, 10 Jun 2025 23:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623080; x=1750227880; 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=S3JyeV8G49CASlX9Q3aBRXU8M3xdluRAzP3zJpwMH4Y=; b=DC1YoMecMiXzISUrRL0vL8D0Sl4TV9ELbfG4/WPyTmM0WDFEdv+xCIJfmdLynuMqkI FEGAF0UYgOVWxHJtdMZMHbIXdjCCtNdaMLkeDbxzdenD9JzxbPjTUYGtxt2llxUVNMg0 zQEl7U0TeAzUNsHH8p5Sz2cInZPN/pRXlZlwkgTWWVjlZHBFmngzgybWtTU2LiDCAU4e fcZT+RWwL7KeJU5uGL7qGJQLeZ5e7NYfoguCJfJUZP4UWBfeYO4lsdOLppXY5QyVXxE5 iMY2eJFLQzOk5NTbuXRNMqgXYjqPbhbtRrqBJFCAZkpT94XQFpyAn083RWFk/B+crdIz hNJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623080; x=1750227880; 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=S3JyeV8G49CASlX9Q3aBRXU8M3xdluRAzP3zJpwMH4Y=; b=JDrxdeQkrASJl6m8bgdntzN/Rf3JcUtrKzDIRMqL2yyOCRZ/LGmB/cp7avEosXiVIO rDHivIuC8jsm7wEj+ilEt3w+SWAEW6aq5B80B14XFm4ZvqJShwabny9uM4q3iv8bEHnz lIkK/U7c7edrqkIJ8ZzIrnjlPfNaFQkvU/v/RFLwNpooahPapMdztZiPIGnXdEMynWet 7ITDhRgY+RzyJoUx97HuhDSIIAphGQ7SaDZ/YlfZeV6uALxJrLqrK6vh70HpsqYjSNN/ q8hRPvsU0+hZLLNVsDKkBjJ8HzMqPkAoco9M8vqq2PXilix7fngN0dp5DTex4PXVFIa2 5tqQ== X-Forwarded-Encrypted: i=1; AJvYcCU7v6+Rz9mNrENQR4vmUvbnSICmq8uX+GE6X85rwjs4iYcu5lr0dbeQ0ugeceidZyQM6KTtcTiHbDpB2iI=@vger.kernel.org X-Gm-Message-State: AOJu0Yxq0he+HimkjDtHE33MO+XnUfBkeWUkoJp8gD4KFZ9yDKfjZ/DN fEnvKB1M9kidyrALckqy9hyuFtCkzL+Xd6gjIeIpp2REp+JkN3fXjrCxgpn+u4biDOw= X-Gm-Gg: ASbGncuGStZDdbqJLAgmpj2zcuZbBXdeDWemEJ4FejHQzxu6T/am+vN+AzUzVIQUFED A2FGiNohaAWKx6X9Dlj9phjeICjM9Am5TBy3Q3o9d8g/bSw34rRoVq7I8cO3hYHXgkvw+/HATzM 5QvsUlq/gkKmUYa/F3U5f5liFXiM88IaygC9LH04l1g/UMGEL+M3NyQWGDJY7dHUlggYb4BaKFC e2fwmU1xAhmK0A6CT4Z8TdPJlyoHw3HAE675DTZVcuZo/rSKEXRodtM25Bdv/02SR2LcWCv2i6b acXpBZdIha7xQrOtglarZfPUkhjw0YDUJdP8/aADWhMjV5Si7Xyz27mxe8FbLeI43MhEtUOuw/D X86KuMtsVRL/3BilW7cv3H54KcQ== X-Google-Smtp-Source: AGHT+IFU2Om0xJWrBw9LyeL4gGNh8fh1PAt+0haWsZIS+6rWc7/q4ECZDWUUrQpSpgIpJR0rYtGlRw== X-Received: by 2002:a17:90b:2692:b0:311:be43:f09a with SMTP id 98e67ed59e1d1-313af92562amr2619250a91.9.1749623079449; Tue, 10 Jun 2025 23:24:39 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.24.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:24:38 -0700 (PDT) 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: [PATCH v5 12/23] irqchip: Add driver for the RPMI system MSI service group Date: Wed, 11 Jun 2025 11:52:27 +0530 Message-ID: <20250611062238.636753-13-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 Reviewed-by: Thomas Gleixner --- drivers/irqchip/Kconfig | 7 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 285 +++++++++++++++++++++ include/linux/mailbox/riscv-rpmi-message.h | 13 + 4 files changed, 306 insertions(+) create mode 100644 drivers/irqchip/irq-riscv-rpmi-sysmsi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 0d196e447142..96bf6aa55681 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -617,6 +617,13 @@ config RISCV_IMSIC select GENERIC_MSI_IRQ select IRQ_MSI_LIB =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 23ca4959e6ce..4fd966aa78ab 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -103,6 +103,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..06f64936802a --- /dev/null +++ b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c @@ -0,0 +1,285 @@ +// 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 +#include +#include + +struct rpmi_sysmsi_get_attrs_rx { + __le32 status; + __le32 sys_num_msi; + __le32 flag0; + __le32 flag1; +}; + +#define RPMI_SYSMSI_MSI_ATTRIBUTES_FLAG0_PREF_PRIV BIT(0) + +struct rpmi_sysmsi_set_msi_state_tx { + __le32 sys_msi_index; + __le32 sys_msi_state; +}; + +struct rpmi_sysmsi_set_msi_state_rx { + __le32 status; +}; + +#define RPMI_SYSMSI_MSI_STATE_ENABLE BIT(0) +#define RPMI_SYSMSI_MSI_STATE_PENDING BIT(1) + +struct rpmi_sysmsi_set_msi_target_tx { + __le32 sys_msi_index; + __le32 sys_msi_address_low; + __le32 sys_msi_address_high; + __le32 sys_msi_data; +}; + +struct rpmi_sysmsi_set_msi_target_rx { + __le32 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(le32_to_cpu(rx.status)); + + return le32_to_cpu(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 cpu_to_le32(sys_msi_index); + tx.sys_msi_state =3D cpu_to_le32(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(le32_to_cpu(rx.status)); + + return 0; +} + +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 cpu_to_le32(sys_msi_index); + tx.sys_msi_address_low =3D cpu_to_le32(m->address_lo); + tx.sys_msi_address_high =3D cpu_to_le32(m->address_hi); + tx.sys_msi_data =3D cpu_to_le32(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(le32_to_cpu(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); + irq_hw_number_t hwirq =3D irqd_to_hwirq(d); + int ret; + + ret =3D rpmi_sysmsi_set_msi_state(priv, hwirq, 0); + if (ret) + dev_warn(priv->dev, "Failed to mask hwirq %lu (error %d)\n", 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); + irq_hw_number_t hwirq =3D irqd_to_hwirq(d); + int ret; + + irq_chip_unmask_parent(d); + ret =3D rpmi_sysmsi_set_msi_state(priv, hwirq, RPMI_SYSMSI_MSI_STATE_ENAB= LE); + if (ret) + dev_warn(priv->dev, "Failed to unmask hwirq %lu (error %d)\n", hwirq, re= t); +} + +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); + irq_hw_number_t hwirq =3D irqd_to_hwirq(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, hwirq, msg); + if (ret) { + dev_warn(priv->dev, "Failed to set target for hwirq %lu (error %d)\n", + 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 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; + + /* 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); + if (rc) + return dev_err_probe(dev, rc, "Failed to get number of system MSIs\n"); + else + 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 (dev_of_node(dev)) + of_msi_configure(dev, dev_of_node(dev)); + + if (!dev_get_msi_domain(dev)) { + mbox_free_channel(priv->chan); + return -EPROBE_DEFER; + } + } + + if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, + &rpmi_sysmsi_template, + priv->nr_irqs, priv, priv)) { + mbox_free_channel(priv->chan); + return dev_err_probe(dev, -ENOMEM, "failed to create MSI irq domain\n"); + } + + dev_info(dev, "%u 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 476a2d64d972..06d2f8b38969 100644 --- a/include/linux/mailbox/riscv-rpmi-message.h +++ b/include/linux/mailbox/riscv-rpmi-message.h @@ -91,6 +91,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 */ @@ -106,6 +107,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 0x02, + RPMI_SYSMSI_SRV_GET_MSI_ATTRIBUTES =3D 0x03, + RPMI_SYSMSI_SRV_SET_MSI_STATE =3D 0x04, + RPMI_SYSMSI_SRV_GET_MSI_STATE =3D 0x05, + RPMI_SYSMSI_SRV_SET_MSI_TARGET =3D 0x06, + RPMI_SYSMSI_SRV_GET_MSI_TARGET =3D 0x07, + RPMI_SYSMSI_SRV_ID_MAX_COUNT +}; + /* RPMI Linux mailbox attribute IDs */ enum rpmi_mbox_attribute_id { RPMI_MBOX_ATTR_SPEC_VERSION, --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.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 6920A228C9D for ; Wed, 11 Jun 2025 06:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623090; cv=none; b=slCwtjoE6L1AW5JQEkf0NGU5lGcgihfC6h/9d0YRyn328QdP+aEY/cEF0Np9vvHebjilK+F/sNuP+mnEpwMEeJ0+ZSZjkPldNqiarhisZNrF2sOIeFP3rQeaow08tOJw7b27gkw3LfsyOVPH7qG2P7Uu5KZGYr3Jyj7/015Y0T0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623090; c=relaxed/simple; bh=SBjQlH46dBB3U+TixQzZp78z+Lc9Dr3istOOhSNwHTo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rIXtueGlIutd03XKOt3CQGTIjHjJS56IiEzIjUolW5W1TlpBhU78SvJHMn41X+oFAIAUucM5UrrwppkhNhZHsTY+QcZX2lYwCvrRVB3pHwGmkzQvTEomRzlZIJk97KeYn4WmjIzfOqrb5aIxKBdM/glatHWX05B1TUVnizMXkCc= 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=jbffSyUt; arc=none smtp.client-ip=209.85.214.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="jbffSyUt" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-23602481460so43201155ad.0 for ; Tue, 10 Jun 2025 23:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623088; x=1750227888; 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=t/zEjMktz2Q+rhDOD+xT+f8Y23symCCnfKy+4Q372EY=; b=jbffSyUtgDTyFJL9DdORdQcLQ/JI9ItEc+D0QTU8LmNiSEO8/zffSOjrAA7lhA0px5 QI56ympjlWhNG9TmsQNkfygQX51u45AKB1y5l9HkL5BoOHHV2zxrrFvuLkI/cuzITc/4 NGE/b0Pn1tx/XrfzMrbrpHurrVJsCaTuUsOH/b5y6Aqifs8M75EPo5TzZSF8o+Q2dC2u LP+eXjTjwwPDe1cKYthGcFJk83KJTAxdMTyqyQfvZahO3x8cCezCX/XJQ+dMLpuTymMr WaUiakDqawfM6fQXSTYVIdv4HPwHFfcKiQMbDo4YiZsxeEE2VZpoYu76GsQe+iU6Ht86 k1rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623089; x=1750227889; 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=t/zEjMktz2Q+rhDOD+xT+f8Y23symCCnfKy+4Q372EY=; b=MgGQaMDc5uhTAmqmo7CH7YJELg8U7mlax8I9Q8wEwhWBTaHrQUK956Q2HRk0wYtRj6 iEzun0YOjz9nKc5jMcSOzeTBXlflq4ow7LMdSL7AFwHmueJbYOQtId9IyaNVNcfSWbLZ GSAAL7QF8GmRYvKuSK1RlSKLkSf5mjCc5zGliHgKfZUlNxlaoTt5KECeJd3LLexAfcFM G+KplHhvGXelUF7FgKowK6M1jpvIYYdyEHufPfhWwYE1Fx05qR2g3imQxESDq/Ty1gDb 62njf6WwVF8ymQ6XDIsMA05zhdgPe+9eXn5D6T0AP3Joca7sW+QlGeaTu0dIuPo8Zbnk GUgA== X-Forwarded-Encrypted: i=1; AJvYcCWbNnlaS1bueI0/cKdcY0yi6v9UEKGdUdxa7OJEy/4szj695sxyscR9caCgyY50KrOJY2wpmRuTOvhu+AA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9r0iMqmI5FF/+oYPyyCzTOxXyWfbiUnscHlejv0FMYSjEBwVk TvmCJrCMqvNWa7tNUP4N5PMRSAPoOqPslpmFmX8CImtM/F4IUnAJ4AdsxbCUzBQR8o0= X-Gm-Gg: ASbGncuzh1XgQ6rHL9OEps7jqxfos5kk1rQYvlGsYkBnXAnSZbSC75erpPZGwaIWoXc oJJ0LvrsBlrA56mNyaFfdNqFxUPYU5eL3z35aG52xCJvHemKdjanb5WXAEPUQkSqq+HhwTLI9Ki JxGIXlSaNv1uZwlFkclnzF5aGGp3Mi8gKGopUFZBaUZ56VOHRz6iDb631C68U2isINsynXcTI3k E2BYGwjMVINRgLi12hJgL0qA+ohCkghkyhpgSTklO5LI/HI0pOcKFV6CIIZBiuy/dGu8mN3S5SG 2PU/7ejTJmJSXIoXl5d+spdsuQSAUbIODG7J0zx7jS8/tLizqJEP8UbeZjSyEtMN76o0eWZA842 eTsBGY6+iMLRk/63Kz+OR9eb2KA== X-Google-Smtp-Source: AGHT+IGFgz5cLpjWkfSw+TNcCIGt07x932rHAD6olqu1+yonZJ7rvYlMViTlSj6mMRDGXjbPoi/gVw== X-Received: by 2002:a17:902:f70f:b0:223:7006:4db2 with SMTP id d9443c01a7336-23641b1988emr28560705ad.31.1749623088442; Tue, 10 Jun 2025 23:24:48 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:24:47 -0700 (PDT) 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: [PATCH v5 13/23] ACPI: property: Refactor acpi_fwnode_get_reference_args() Date: Wed, 11 Jun 2025 11:52:28 +0530 Message-ID: <20250611062238.636753-14-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 Currently acpi_fwnode_get_reference_args() calls the public function __acpi_node_get_property_reference() which ignores the nargs_prop parameter. To fix this, make __acpi_node_get_property_reference() to call the static acpi_fwnode_get_reference() so that callers of fwnode_get_reference_args() can still pass a valid property name to fetch the number of arguments. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/acpi/property.c | 101 ++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 436019d96027..d4863746fb11 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -882,45 +882,10 @@ static struct fwnode_handle *acpi_parse_string_ref(co= nst struct fwnode_handle *f return &dn->fwnode; } =20 -/** - * __acpi_node_get_property_reference - returns handle to the referenced o= bject - * @fwnode: Firmware node to get the property from - * @propname: Name of the property - * @index: Index of the reference to return - * @num_args: Maximum number of arguments after each reference - * @args: Location to store the returned reference with optional arguments - * (may be NULL) - * - * Find property with @name, verifify that it is a package containing at l= east - * one object reference and if so, store the ACPI device object pointer to= the - * target object in @args->adev. If the reference includes arguments, sto= re - * them in the @args->args[] array. - * - * If there's more than one reference in the property value package, @inde= x is - * used to select the one to return. - * - * It is possible to leave holes in the property value set like in the - * example below: - * - * Package () { - * "cs-gpios", - * Package () { - * ^GPIO, 19, 0, 0, - * ^GPIO, 20, 0, 0, - * 0, - * ^GPIO, 21, 0, 0, - * } - * } - * - * Calling this function with index %2 or index %3 return %-ENOENT. If the - * property does not contain any more values %-ENOENT is returned. The NULL - * entry must be single integer and preferably contain value %0. - * - * 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, - struct fwnode_reference_args *args) +static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwno= de, + const char *propname, const char *nargs_prop, + unsigned int args_count, unsigned int index, + struct fwnode_reference_args *args) { const union acpi_object *element, *end; const union acpi_object *obj; @@ -999,7 +964,7 @@ int __acpi_node_get_property_reference(const struct fwn= ode_handle *fwnode, =20 ret =3D acpi_get_ref_args(idx =3D=3D index ? args : NULL, acpi_fwnode_handle(device), - &element, end, num_args); + &element, end, args_count); if (ret < 0) return ret; =20 @@ -1017,7 +982,7 @@ int __acpi_node_get_property_reference(const struct fw= node_handle *fwnode, =20 ret =3D acpi_get_ref_args(idx =3D=3D index ? args : NULL, ref_fwnode, &element, end, - num_args); + args_count); if (ret < 0) return ret; =20 @@ -1039,6 +1004,50 @@ int __acpi_node_get_property_reference(const struct = fwnode_handle *fwnode, =20 return -ENOENT; } + +/** + * __acpi_node_get_property_reference - returns handle to the referenced o= bject + * @fwnode: Firmware node to get the property from + * @propname: Name of the property + * @index: Index of the reference to return + * @num_args: Maximum number of arguments after each reference + * @args: Location to store the returned reference with optional arguments + * (may be NULL) + * + * Find property with @name, verifify that it is a package containing at l= east + * one object reference and if so, store the ACPI device object pointer to= the + * target object in @args->adev. If the reference includes arguments, sto= re + * them in the @args->args[] array. + * + * If there's more than one reference in the property value package, @inde= x is + * used to select the one to return. + * + * It is possible to leave holes in the property value set like in the + * example below: + * + * Package () { + * "cs-gpios", + * Package () { + * ^GPIO, 19, 0, 0, + * ^GPIO, 20, 0, 0, + * 0, + * ^GPIO, 21, 0, 0, + * } + * } + * + * Calling this function with index %2 or index %3 return %-ENOENT. If the + * property does not contain any more values %-ENOENT is returned. The NULL + * entry must be single integer and preferably contain value %0. + * + * 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, + struct fwnode_reference_args *args) +{ + return acpi_fwnode_get_reference_args(fwnode, propname, NULL, index, num_= args, args); +} EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference); =20 static int acpi_data_prop_read_single(const struct acpi_device_data *data, @@ -1558,16 +1567,6 @@ acpi_fwnode_property_read_string_array(const struct = fwnode_handle *fwnode, val, nval); } =20 -static int -acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, - const char *prop, const char *nargs_prop, - unsigned int args_count, unsigned int index, - struct fwnode_reference_args *args) -{ - return __acpi_node_get_property_reference(fwnode, prop, index, - args_count, args); -} - static const char *acpi_fwnode_get_name(const struct fwnode_handle *fwnode) { const struct acpi_device *adev; --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.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 2BDCB228C9D for ; Wed, 11 Jun 2025 06:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623099; cv=none; b=sxMzxSrP5Q/EBPDlpN5kWBeMJdOH0TBk6Kwuglqnpgn/0SBlmneiirkOVw3Pld8PgqvW5MRa47r2UbCb+l24LcjpHQcDUy/2aBKMsZ3f271Ii58lBN+KfIriAVUjxHlzBlI/Y2B4X41ffDsYO4u7FwRQ7ssZVxdNTWjN2Fl7oLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623099; c=relaxed/simple; bh=uYspFdcUP7K03KSkIbLSgQUq1PmFh7JvyJFUbmFVifk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u5jZ6UD+FKiH9/NId5HgNowCtVEpYhpwJAnLSrJBIP6j56Y8nYXHJfzsKjf9wVDBSVY0Tngv46iAcegySm8xrvshJsEzE2C6BQ9QrWo93L0VyXmPWgVMPtQq6ZoW8UUP5wX8WI2sMOoDCHWXYfC6oxHwG6opkf6QWo6bPID4Ce0= 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=pUVeUBdB; arc=none smtp.client-ip=209.85.215.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="pUVeUBdB" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-b2c4e46a89fso4640246a12.2 for ; Tue, 10 Jun 2025 23:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623097; x=1750227897; 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=iK7PqVF4zZIJUvApimJUz6BsykWi/7ZoxPUCnW7EQA0=; b=pUVeUBdBcFwfkVBe4KtaY0TllD5VW6Fb1o/2qSlUUmihhOku8MVKCSzULMdxPtchBV zO72EqA2uBQI6xEY7Ke8L1oKsmWfgM2fj5uTRHUGGgml2+551UKn95d1FlSrgyW/wM0D 6Obp5U7YsZkXRhUrfW8MeZtpO/l2YhCum2nKGk4QdtoD5vBF+S2DMB2eJfH97hNLe6RX HOmd8kL6F+FMUVHbcoRzlsPvCe7xvAk+3MIEQhMnny19MTceXZJtYDa8Kh10D/i+8X5q 2jskAO/Jcj6HDhZQ/+eulkE/3Al/5eWNkJI013qbB7gnh0B+RiLy56/zOVo2IiWayP3O Tpgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623097; x=1750227897; 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=iK7PqVF4zZIJUvApimJUz6BsykWi/7ZoxPUCnW7EQA0=; b=eE3ZqZUOJlqAAiQBvF6TfWO1bKfpubr5vWsjH41F1t6GykZO3QEcVH3+diJTY69dzj SHG1RQ1gDEm9qWktnGDDRSJqLqWoS4DS8pecXRC+PxQkmw8o3MRBe/xblKgEg8OmpNZR Nketcc0IhtJZne145CgQCBFrMO6dVZ1kBHSSjjygZwWvWnsy3XE+7fX2iGCbJz44Ff0B 01P83RSMjYU9SQXq7IIerIyafkTVRR8U1wc1MxyE0GCfiybqGWshfiGbvt9ABP/sjUH4 dhdikjn8zx8jHsjHa6RFTlwabS8eLiXLTNtVlPV47hEtZhJ2VMA0xR8OfcH8I7dlUWfA /TiQ== X-Forwarded-Encrypted: i=1; AJvYcCUxDCfdqKDSutDVeqDuMfni28HNnJ23XJma/3e2Chd/ZBhQAmlihF05ozj+QIJaG73wAa9q8HIPxJO4LuQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyR9tm/GESwMkf497NuNkLhZ9raVVd+VE/aDDlP65bMCLT3gdcf /gmXjUtB2c2hRggbB1NuM5yf/c81VkQDpvH07Z6Bvmnvm1igXuXdLO0IrmGdU538NuU= X-Gm-Gg: ASbGncuO5nOFTonOTckwuT9U9rwF/S+nex/bj64mSMfCBbJz+gR/Rky5bZ5TI5kwfHJ g1PtFGUA5YfI/KfoMopwlxF216rVj2I9WkIfTpahFBU859GAcwTbzNqVP9w+Cka+JVGc0rD5Rdp edamXw8Q/UUk8mVc7fan7oh9GKHRTfdYcAYnoxyBBGRDonE3t2QdmmiJvF1vW8lQdPWxVOqzXbo 7sTvLcW3utsB6CNaXpbj49p7ARqTvXG/jfhHUBeTYk+wztnd1OhFELUOeJpIabbWa/ghMxadwVZ nV6hIiRS6KAabeArh0tIjcGLE8zE37RH9whAwxP0DC8ZCFbGJkftrrPs1nmjHSEctrA8IYw3ELq q2q9Hgy9tTOGMN9y0pYWbDUyueAvS0SJo5mlN X-Google-Smtp-Source: AGHT+IFO98j1k8g1ruMfGzMTu/XxzcdDJxwpWrw5N+bAJb9t2eF6IOtYLbrNxbahMkEVQkOEVuOivQ== X-Received: by 2002:a17:90b:3c11:b0:311:fde5:c4be with SMTP id 98e67ed59e1d1-313b20072e3mr2122681a91.35.1749623097312; Tue, 10 Jun 2025 23:24:57 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:24:56 -0700 (PDT) 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: [PATCH v5 14/23] ACPI: property: Add support for cells property Date: Wed, 11 Jun 2025 11:52:29 +0530 Message-ID: <20250611062238.636753-15-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 Currently, ACPI doesn't support cells property when fwnode_property_get_reference_args() is called. ACPI always expects the number of arguments to be passed. However, the above mentioned call being a common interface for OF and ACPI, it is better to have single calling convention which works for both. Hence, add support for cells property on the reference device to get the number of arguments dynamically. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/acpi/property.c | 22 ++++++++++++++++++++++ drivers/base/property.c | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index d4863746fb11..c9c3d6920326 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -882,6 +882,20 @@ static struct fwnode_handle *acpi_parse_string_ref(con= st struct fwnode_handle *f return &dn->fwnode; } =20 +static unsigned int acpi_fwnode_get_args_count(const struct acpi_device *d= evice, + const char *nargs_prop) +{ + const union acpi_object *obj; + + if (!nargs_prop) + return 0; + + if (acpi_dev_get_property(device, nargs_prop, ACPI_TYPE_INTEGER, &obj)) + return 0; + + return obj->integer.value; +} + static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwno= de, const char *propname, const char *nargs_prop, unsigned int args_count, unsigned int index, @@ -960,6 +974,9 @@ static int acpi_fwnode_get_reference_args(const struct = fwnode_handle *fwnode, if (!device) return -EINVAL; =20 + if (nargs_prop) + args_count =3D acpi_fwnode_get_args_count(device, nargs_prop); + element++; =20 ret =3D acpi_get_ref_args(idx =3D=3D index ? args : NULL, @@ -978,6 +995,11 @@ static int acpi_fwnode_get_reference_args(const struct= fwnode_handle *fwnode, if (!ref_fwnode) return -EINVAL; =20 + if (nargs_prop) { + device =3D to_acpi_device_node(ref_fwnode); + args_count =3D acpi_fwnode_get_args_count(device, nargs_prop); + } + element++; =20 ret =3D acpi_get_ref_args(idx =3D=3D index ? args : NULL, diff --git a/drivers/base/property.c b/drivers/base/property.c index f626d5bbe806..6a63860579dd 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -578,7 +578,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_property_string= ); * @prop: The name of the property * @nargs_prop: The name of the property telling the number of * arguments in the referred node. NULL if @nargs is known, - * otherwise @nargs is ignored. Only relevant on OF. + * otherwise @nargs is ignored. * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL. * @index: Index of the reference, from zero onwards. * @args: Result structure with reference and integer arguments. --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.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 E9D0922F751 for ; Wed, 11 Jun 2025 06:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623108; cv=none; b=qqt8oMK2DHfiy4wv/st/sJ5PokDjKViTWfQDsggVEYYnakVhw7YVm8M9W0HIOPpVg7MSh9UWsP6UZBSGln59OSvGdkpTPjAng7npFIf2mUh+upq5UeTpukiOdviKg1f7BldVYhiyZGs7gAnKvYwB78pxQZNFS26DW8gq4cIGDLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623108; c=relaxed/simple; bh=BiKDpKKLxE/k6ZY8kMmrwXJi+9HFJObjqUV7Aozt30A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mM2UOKEN5Y8ed6EEieY496GQ+I2T0QnaVMvM++GaZ1ANCThZ/Ph9EjFoZwvRZx+dxbJ6ikEpm7OQhyWYJc8OhXr50uvsPHgop9WjG01eeYIdU7eJHlpOz0EW0NSmGTqKiVvbFAMisY1oFNVPesWZCABy4DPqJh985ZxFSa/nHlg= 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=A97qx1DA; arc=none smtp.client-ip=209.85.214.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="A97qx1DA" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-23633a6ac50so28508865ad.2 for ; Tue, 10 Jun 2025 23:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623106; x=1750227906; 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=SXNxvUrDvrPEDXD7o9bAHtY/zIDAmgnS5reR+x10ajU=; b=A97qx1DA/K+L04xx6PF3Wu7xkBcvmuzPaPjyVaC4jMtAPWLcnBYxr9ytGAf9GRLkQe 5Hra3qT2E/CtwAmeZb5Zp9Y/XnuzTdi+m8eEf1tqx2k0uW/7tBSCScvGAhdBg//7uEdr na6f+7XfcyKfsjqoIFAHXlSPMfqtAUaVJmoUYutq0oUstCAnlfRUmNCvk9WcF3FW0HGX /fyQ0zpWsnxzI/js5P8rEBJzhfYo1vDZTD9zjxRruOKNgprOlI9HiGcmVnJe7LzSxE5y iRN/Y9Yz2FjutiLa3VKGN9m6W76fBMO2w2Fkh4JDgfpSY3D7J2gplyeiz20GfbxjjkW7 DvSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623106; x=1750227906; 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=SXNxvUrDvrPEDXD7o9bAHtY/zIDAmgnS5reR+x10ajU=; b=COQrZd3uYmW37nyb7QFzM689lJ+PiixtRkjMaXFKDx3sQZYRQhXfsFzlaJvXxPpkSV VH72XZca5J2OSOWDJHaqe2ShcegJXLZAhjJsOpriAKFXwXNf6PfRxRxk88NqyEV9MwVq ipa0Wi0k3BFCtLUmnrx/WdKW+kaoatSk51ra8w/FJ5UxAxADDx9LB+Fkk6q+fG0wfqZ4 t+P6v5bobfUSImkTroLn1mqytqQKv3L6O21GVayWb5rvkNkZvy4yBXef+CmUcAy0COdc PjTG1fv0FceKAXT8Ulyfhxiy/r6gg7kBY02SSlJAyzgukB9IM4rHdUAK5YcXMh0a4Eyv j7Dg== X-Forwarded-Encrypted: i=1; AJvYcCUXxLNJvff60Vw9mWAAb9AUz4A8itCmHBBfQylnxKp3AX/mykPU/kzeqNDyzllcIEt9EdadawP0/jvyg7g=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4KF+kWdUICFm22QY6WNiCoqh5wiXGveEsj40K+HvThrkxA59B C4lT3WrPqiu1wsyIxrygtO5lINMDmQbPLOpoxMofYzgB0YUzvdfI0pLf/T6n/A16DKs= X-Gm-Gg: ASbGncvwzJUDj+2mVD1WlLq6PTcs4sjDcMIWrs6MsQ7TpbRS5pS2l2Dk4nWJu6GU4by OZCxjBkTXVcPb1UO+SuAuC4LyyxNIP3dCwQyZLCdqtn2JRj29zi2c3hrudzAsVogIdHHxWyzhow uFS+1/1ZUvzcv0bIxQmE1nJ4V5syjUMa0ZPz03zI7kbzSP8jj4FzNTPVEf+e7EgweGRvFsw4xP1 N4eR0vWXTQsnUpi1b4iV0CZ8Z/CPBeEQQ+wEyr9H3FluMZQI+j4DabqfVYi1mgAUfjwdvlzHSpV gmNbqVSNF+k3hhpjhr+WPPVan1HlZt4Nk8ThXJ37DNwKWZQtqkD4KPich3e939aw8Xsof5e9b1G 7jBFQx5DSWaQ5JtMHJMoZi6TtRJ1Vf8NQf1Y5 X-Google-Smtp-Source: AGHT+IE0UM/d4M+csfHbg0ruhjIIecTEOfGpEWCQ4NLi3fmPp3zu1MWGy4f0Hx7tOO8mYCGU/KKuFg== X-Received: by 2002:a17:902:bc46:b0:235:f4e3:9cb0 with SMTP id d9443c01a7336-23641aa239dmr20067885ad.9.1749623106244; Tue, 10 Jun 2025 23:25:06 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:25:05 -0700 (PDT) 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: [PATCH v5 15/23] ACPI: scan: Update honor list for RPMI System MSI Date: Wed, 11 Jun 2025 11:52:30 +0530 Message-ID: <20250611062238.636753-16-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 Reviewed-by: Atish Patra --- drivers/acpi/scan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index fb1fe9f3b1a3..54181b03b345 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 Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.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 F322722D4C4 for ; Wed, 11 Jun 2025 06:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623117; cv=none; b=CmV2Sg0EGxDevSV87XNf9erglLMQfNYlWQRlWOW/rM8yENRyKt7oV8oDfO5Vo5N7iTKO9cov3NZ7gobcGLKnaVRpXCtR+noWc5hScdB7t45JsGuIevQxJb9ZtfaokGgubYzxDLLqGhHzI3bcK8oI6dCn0WDlQksbjsandiICapA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623117; c=relaxed/simple; bh=uLkW3DQcKIIgVHib4AKQIVSEPy4uT4MPjoilFNj5tRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A/VK/xbuypLT0u+rBZILZTYQX6ULw8nfwZrDxD5B1XBP/JiQNCFrqxb+Iz5u7vbyAewEaOthcf6IGuJTMa89vgV6gYc04rck+KOu+B8sIr10bWI0klN++/l5pSp06zZT1Ukw6pABNXMLhjZRiFBzOvvqAMsbKhW7GBnIL14j1nc= 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=DApETb2h; arc=none smtp.client-ip=209.85.214.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="DApETb2h" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2353a2bc210so54799505ad.2 for ; Tue, 10 Jun 2025 23:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623115; x=1750227915; 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=yiu9LW4OQPcl48oQrH2DU+mLfm2FHbXqcRasNtW9C8A=; b=DApETb2hsZEWhXaNXn39qAjIm51iYesPlMrA8VTbm7ew33yX80i7uH/TPJNJK6wY8z V8BNYvco/eOvjqD27/k5MUiLjWIl0rdsWm60ZV3EJtPmUIkf1wywt+VJHZIJJBXDEy0H Uvlcux4yCEyma8Q1PvclYw9Bbgrl3DOngukQdjdwpHXbZVv0ph1kgiiYLUo+r+vWxO4F 3z9/Ht2+wQ5n6fx9entZIZ8zlmhTkttylrHWVVTBWws7wEA+sozI/zi0O6/vWz0JQGRV fa4tsnScl+6tPKb9+b5Dx82EYpz0S7THiOxtztHpGUX7xSPmdZqw7WNVCRJNkXcIsDgT IH6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623115; x=1750227915; 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=yiu9LW4OQPcl48oQrH2DU+mLfm2FHbXqcRasNtW9C8A=; b=R/qdb6nXDs1UETjZy/SNeTc1bgcRHgGeRfPdQqj/OoFXfCGJ7yE58G+CS6EIMA4IcJ rvs2kByOhRa/MExjxGErRTT+oSM5BpBo9nqgvctmOtojTGH65TogElbI7/7uv8nDq6cU NsqMecVL19QrwC4V8ghV/YEHHnALVF72FT4HqSEr1RLL55T7EGzus1Q4yDYCT5kTM02N auMr1GdpiwZxMDkmd3V4HlYuEDwR7oRxvBKjzzoUrDKWi8Gf5FRE6VlcVEYtkHkHDltk S/6+Ihoiz+CoKrGiEGbnmmSzKhysDzCyTnhKlW8dYbze87h6xLcLGRj31H2Iz1neMZR2 AoDQ== X-Forwarded-Encrypted: i=1; AJvYcCWmArvnTOswIhEMKxauszNJcWXDCGCLXCOwttX/IvCq9cqqmV2Asg3Sg/DRd9NKyNxP2BPgqZXeWhJ01iI=@vger.kernel.org X-Gm-Message-State: AOJu0YxDWpdwN/8Cur/8LZpr/7sFdQ55c/HHjS74BZFszOh9765Wlct+ csE3T7IFfnMk/H31+9XZo/8Bu+2rR+6O9QYe3qRL+F6ZMFCn4HkFr0JWixWJnHmdF3I= X-Gm-Gg: ASbGncuIvKFM9/IR9txrJ15yBqyvIdmdr9AwfjhRudOFLpXedLPKpJPQq35IpQSvjIJ AqY+PM5CGOC8wR8C80NVyE9pnje7l8y696thVEZUjVQZypYv0DtAa4TIiy4WmJt6TAN5MJcfSTZ NuKRP9Q0YDqjxyPMzDexVFHz7tqcpMfuVfhHS2OPrW/5o8fh1q5Q7gAZbjlNP0Eb3S0wDsgmSVC KFWYmBWt0dlKqy/b46UV7QkWU1YglOgxgxf5/kcXhYR3hPzCKKm52J0C2UXm5mOBo+gbiLk/7Nk BYbGvD0trptoE0B2YbhhQPFRMrueWFbiFqgoDDXHaFnig2sl43zuSYIM6uTUV56M36zI86bn9dx 2OwVkaNT+usS8TdSPHtZxh/pPaw== X-Google-Smtp-Source: AGHT+IFnqBNnTwbehZbdbVmid5c+EUoLDt9iVtCEphlQwJCdvquAFaXOuTjhhB4h2PkL4dhMiL1o0Q== X-Received: by 2002:a17:902:e741:b0:234:c8f6:1b05 with SMTP id d9443c01a7336-236426b7493mr21510465ad.52.1749623115115; Tue, 10 Jun 2025 23:25:15 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:25:14 -0700 (PDT) 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: [PATCH v5 16/23] ACPI: RISC-V: Create interrupt controller list in sorted order Date: Wed, 11 Jun 2025 11:52:31 +0530 Message-ID: <20250611062238.636753-17-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 Currently, the interrupt controller list is created without any order. Create the list sorted with the GSI base of the interrupt controllers. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/acpi/riscv/irq.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index cced960c2aef..33c073e2e71d 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -115,7 +115,7 @@ struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u32 = gsi) static int __init riscv_acpi_register_ext_intc(u32 gsi_base, u32 nr_irqs, = u32 nr_idcs, u32 id, u32 type) { - struct riscv_ext_intc_list *ext_intc_element; + struct riscv_ext_intc_list *ext_intc_element, *node; =20 ext_intc_element =3D kzalloc(sizeof(*ext_intc_element), GFP_KERNEL); if (!ext_intc_element) @@ -125,7 +125,12 @@ static int __init riscv_acpi_register_ext_intc(u32 gsi= _base, u32 nr_irqs, u32 nr ext_intc_element->nr_irqs =3D nr_irqs; ext_intc_element->nr_idcs =3D nr_idcs; ext_intc_element->id =3D id; - list_add_tail(&ext_intc_element->list, &ext_intc_list); + list_for_each_entry(node, &ext_intc_list, list) { + if (node->gsi_base < ext_intc_element->gsi_base) + break; + } + + list_add_tail(&ext_intc_element->list, &node->list); return 0; } =20 --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 C224623182C for ; Wed, 11 Jun 2025 06:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623126; cv=none; b=jCJsdRY9edwNcJdB7/nEopWgqDJXNYRMrA5h8pKDfM47JrcXgGPMelQo6bMV+rqyjefzAJhInO2sCf6xv3Yq21X5SNYZsZIDOAAzT6j0LMaZwqt+fqZCNQuJ6G+EPq5JRWqkGrF8HZb1ogZFNllPN0khHOgFb22NdBFKQdGeuoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623126; c=relaxed/simple; bh=bDMVpDUTCKSQxIzYquuybqhsrFm52uIQJL3fLHSkHZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hyG7sN6BWyjM3rDFrv/yhmb3FEDh5u6FJXP1fFOO9agVnQV1wLDTjdlgejLKTn6/5YnvX9sxlJvbme1czYSDuPqKSd8gRWYflhhhKRbugIdCJ0cTvFXuR7s0g6IjTV9R//zFNhyXdOa/beJJW3xHv2XiVprcoAQHgm0Fris05Kw= 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=aOLNLSBV; arc=none smtp.client-ip=209.85.214.179 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="aOLNLSBV" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2363497cc4dso18828835ad.1 for ; Tue, 10 Jun 2025 23:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623124; x=1750227924; 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=P3TJh+HyLkyeQ1VqRyPxzf43XEd03uT1gCuO+kpCcOM=; b=aOLNLSBVq4WLH7iTTLFU42LhQxBn6hbTSabYvx2Aqf7QXi1OyioL73qzpnc4oegiXJ D/8w9FvUuNBNzgJqqZu3KyuIxWHIt+2+3o2lHnsAefLgYEtWRbjsRGU1+b6letnWlHl/ bo5gE1zDSY3+s+EhMBTK6ODl2XKFNrES/fLh8WhHaM+eVMp1++AfFULtHdrFqQQ87yTU +imgPkYnkH6GdZeCqkotK3D6gRFzNSF+rLxMRSKihsaAc6dWHM8Is100aJWQTNNCOLrO my1KjEuMvTfKcM4NRIpT7sMqqsyG25XkAMBhAK3w2DI9KlAV3xdIIy4WFezRvTMJwNiJ GXBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623124; x=1750227924; 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=P3TJh+HyLkyeQ1VqRyPxzf43XEd03uT1gCuO+kpCcOM=; b=OA/+fdTqGArQlTIj4Kj7qsrtMkYqEEjIc2DJqrRjOi2bJzhrKjqxSRhT4aPfu0Ul0a urkl4vNjF+sAAuEaJ1pQF6Wvr+0LaFRmM1lbvDSBHBRLAW5SY/6Rpk0/KeahOqdzsAgY dgbNeUOYBZnkBQB7nQ+YGvD+Q6CxvCMlIkzXFF95W31pmmOkPP+ygM1c1WIPMj853dC4 qvpFI1BdumtLf83K95iDF81GN8zBHeDy2Xu2Fzcohy5ga3g0d9FoIfxSmOCld/iCCkZn 27IUS9X6otzBIQFO2pTazUys6JloHYljQOdRBElUGXBO5+ZHmMFn/Ofki6SLbHCSayH+ vJJw== X-Forwarded-Encrypted: i=1; AJvYcCUALEMcxLGNZxRFgGL4NVzISpxpyjel+Y49uz4WNkPgSLkvxc12gvZ9xZbIlwR54TzLSgnWYWKoDUTGMqA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2Xwtd5J/IYxRt5wzI9iJMm9Dgcj05U+cmN1GrGkeWzSEhjnC+ Mfdcy3tlM5VbW1ZCgeAqkma4nRe5AOe8FRK9ccHgdy5/LX+kfCX8H8qh92iiGZRYpzI= X-Gm-Gg: ASbGncuVq7u/BEFAdneLAbiVncAp9LTtEF2t1aGGzX4WciFIf6xYVzV8APxYHOZ8TEp 3ND3Yra7GQ9Pirz6pD42VQjfDiUnj7b1mqC+JEM6OiDP6Oj4uS3gzH+oDOIkdZys+9enzFOApi8 KbAVw4lViGCxLO0kGZkr3htf063j13iKiB/n+yBeb2Ar76YLtkxcjwcVAclr9VkPqfpNWeQOb75 t0HeX/ogmoZpiNCbCZBFjWn02gW3VHhMr/xpLkKcXhrlIs/Lg974ABl5PVboVNDSwkTbLtnOj4N gwEU62vbH14bzjz3p2blPWVE33uTpkqQzK2BqIyHwHRWQPHZD1CBD7LFLmQnp9h4rbqZewAiVhC jk+iCt/JTt5RF9Rq0FtRkmKjsaA== X-Google-Smtp-Source: AGHT+IGEWLvHu+QitAoaSc5JCFVSXTiR4zAQBrrLEPUMyZeyXwPVzV+EQ4Eq/uT7lUdx2oEJTNiDkA== X-Received: by 2002:a17:903:2407:b0:224:76f:9e4a with SMTP id d9443c01a7336-23641abc3d7mr31388505ad.14.1749623123949; Tue, 10 Jun 2025 23:25:23 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:25:23 -0700 (PDT) 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: [PATCH v5 17/23] ACPI: RISC-V: Add support to update gsi range Date: Wed, 11 Jun 2025 11:52:32 +0530 Message-ID: <20250611062238.636753-18-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 Some RISC-V interrupt controllers like RPMI based system MSI interrupt controllers do not have MADT entry defined. These interrupt controllers exist only in the namespace. ACPI spec defines _GSB method to get the GSI base of the interrupt controller, However, there is no such standard method to get the GSI range. To support such interrupt controllers, set the GSI range of such interrupt controllers to non-overlapping range and provide API for interrupt controller driver to update it with proper value. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- arch/riscv/include/asm/irq.h | 5 +++++ drivers/acpi/riscv/irq.c | 38 ++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 7b038f3b7cb0..2caf049f09c8 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -40,6 +40,7 @@ unsigned long acpi_rintc_ext_parent_to_hartid(unsigned in= t plic_id, unsigned int unsigned int acpi_rintc_get_plic_nr_contexts(unsigned int plic_id); unsigned int acpi_rintc_get_plic_context(unsigned int plic_id, unsigned in= t ctxt_idx); int __init acpi_rintc_get_imsic_mmio_info(u32 index, struct resource *res); +int riscv_acpi_update_gsi_range(u32 gsi_base, u32 nr_irqs); =20 #else static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u3= 2 *gsi_base, @@ -74,6 +75,10 @@ static inline int __init acpi_rintc_get_imsic_mmio_info(= u32 index, struct resour return 0; } =20 +static inline int riscv_acpi_update_gsi_range(u32 gsi_base, u32 nr_irqs) +{ + return -ENODEV; +} #endif /* CONFIG_ACPI */ =20 #endif /* _ASM_RISCV_IRQ_H */ diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 33c073e2e71d..cc1928422418 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -10,6 +10,8 @@ =20 #include "init.h" =20 +#define RISCV_ACPI_INTC_FLAG_PENDING BIT(0) + struct riscv_ext_intc_list { acpi_handle handle; u32 gsi_base; @@ -17,6 +19,7 @@ struct riscv_ext_intc_list { u32 nr_idcs; u32 id; u32 type; + u32 flag; struct list_head list; }; =20 @@ -69,6 +72,22 @@ static acpi_status riscv_acpi_update_gsi_handle(u32 gsi_= base, acpi_handle handle return AE_NOT_FOUND; } =20 +int riscv_acpi_update_gsi_range(u32 gsi_base, u32 nr_irqs) +{ + struct riscv_ext_intc_list *ext_intc_element; + + list_for_each_entry(ext_intc_element, &ext_intc_list, list) { + if (gsi_base =3D=3D ext_intc_element->gsi_base && + (ext_intc_element->flag & RISCV_ACPI_INTC_FLAG_PENDING)) { + ext_intc_element->nr_irqs =3D nr_irqs; + ext_intc_element->flag &=3D ~RISCV_ACPI_INTC_FLAG_PENDING; + return 0; + } + } + + return -ENODEV; +} + int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, u32 *id, u32 *nr_irqs, u32 *nr_idcs) { @@ -115,14 +134,22 @@ struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u3= 2 gsi) static int __init riscv_acpi_register_ext_intc(u32 gsi_base, u32 nr_irqs, = u32 nr_idcs, u32 id, u32 type) { - struct riscv_ext_intc_list *ext_intc_element, *node; + struct riscv_ext_intc_list *ext_intc_element, *node, *prev; =20 ext_intc_element =3D kzalloc(sizeof(*ext_intc_element), GFP_KERNEL); if (!ext_intc_element) return -ENOMEM; =20 ext_intc_element->gsi_base =3D gsi_base; - ext_intc_element->nr_irqs =3D nr_irqs; + + /* If nr_irqs is zero, indicate it in flag and set to max range possible = */ + if (nr_irqs) { + ext_intc_element->nr_irqs =3D nr_irqs; + } else { + ext_intc_element->flag |=3D RISCV_ACPI_INTC_FLAG_PENDING; + ext_intc_element->nr_irqs =3D U32_MAX - ext_intc_element->gsi_base; + } + ext_intc_element->nr_idcs =3D nr_idcs; ext_intc_element->id =3D id; list_for_each_entry(node, &ext_intc_list, list) { @@ -130,6 +157,13 @@ static int __init riscv_acpi_register_ext_intc(u32 gsi= _base, u32 nr_irqs, u32 nr break; } =20 + /* Adjust the previous node's GSI range if that has pending registration = */ + prev =3D list_prev_entry(node, list); + if (!list_entry_is_head(prev, &ext_intc_list, list)) { + if (prev->flag & RISCV_ACPI_INTC_FLAG_PENDING) + prev->nr_irqs =3D ext_intc_element->gsi_base - prev->gsi_base; + } + list_add_tail(&ext_intc_element->list, &node->list); return 0; } --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.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 B020F22F75D for ; Wed, 11 Jun 2025 06:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623135; cv=none; b=kGTha21rR2CM8FeDsPncP7abFQYrIuZH5QsBKawlhdnF8aQzFgkL9KxT/8VV3VmWnGUFVjEvS5CZ+ryga/zx2THLIENLSzGAjdWLHJjFEHYIe9yyH/sKTO+Fz60159IRIR6ZeoEAMkSy3dVfnrQvB1MTuwFcW/YK7+VmAB1FKOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623135; c=relaxed/simple; bh=HmUGIQxKVHOETiXQmbQMVfvnbNgiP89D8IFlOG4Z2e8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pcs58yZtgT1FgX5ntZl2WqDUTP3Th/I5lx4ZUs4Qcg2Ye0h/smpbsfykFinj/twaYKdDgDL3sTn5LtMRKOzaaPLQR1grjJNm4yopyIXNEA3cIIrCOEJPaGf5Kej8DmPNPj8bVsyxlBeAtm4+VAczEpBUpjAv1M+0GI6toSBMOSU= 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=B2jJZpiG; arc=none smtp.client-ip=209.85.214.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="B2jJZpiG" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-234d366e5f2so71490815ad.1 for ; Tue, 10 Jun 2025 23:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623133; x=1750227933; 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=R+ya0GtiFk/8ci1A3C7Dw+WSyLS2yytdeeB0s74FDG4=; b=B2jJZpiGg04yarCx6myK6NWU1VEtVsnvm4x62tzl4Hj/+gAzyWgYqRFySwYer3bgIb SLil8J4EKO0sYng9FZNUEaeIe2yt7qpq5hgghEINKzave+u+Tb6OIOA5PtBRAyGsEpda sR9U5f8tPCVAOIlBnlhNW50DMV1NO8Lg33y6vCGWh8//wQ/uAnkqwB5lPviKyWePyevp tbSn1fVZzIuYy3t5Cu79iTLSiw9UpQK+pdsdXkh+iQqpCrih/GBGLiLjpPQT6BHi3A6I 1UoLd3WWeX+Zyt+g6suIqv5CkEMIVkieOm3eiyNlKwrx2hk8oB0PJmoFPnEy2JwtecTs HV/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623133; x=1750227933; 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=R+ya0GtiFk/8ci1A3C7Dw+WSyLS2yytdeeB0s74FDG4=; b=PyCcArSEjN+lnPzqoAABoVVumq0WV6zDUPIJep8TCrEEF7Aeo4kLNMStd/S77xkA/a d+Yw13vVanmuTw2mSq8Q4JRLViZoc3sKRA/sTnI3XmbJ2QHL6kGKs0OxD3bYFsP4e3eC xBLuioQBgj7zAKRD/SANjhtT2wI6TRkHqzW55NrF/fdYJ3RSa/D5/QG6XCbqhalN6F5R FfGeGxUKRAshWL1cbsiJWLtRoPoTX8WAe9rR6uvMwvNa9onxNw39DVLLNKoLUMUDHNfr 1Au7NQsHRTjRSlhIhB6OoxHy44Jmt6zyPJSHK25aq3q8rVw0OO7g9ruUiE4Y5TqCVbb1 HedQ== X-Forwarded-Encrypted: i=1; AJvYcCVhwmQENH3qf21SdJgyqUZhGD7X2YA8f18E6Do9j+kdg7FAPmVIhpRvjsAYL3DyYGxXhtt1YgQsn8tiCb0=@vger.kernel.org X-Gm-Message-State: AOJu0YxIcfjq6aMOR1vDtNCDNU1h/Hv3baVgH950GaSq0Liw6VuF3n5p EbRMLdIyOL1UIDRMExPLgWRxVhCbJwUYgJk50Ue13SWJ6c3rBSvVoX6tAVRuBw0RvWA= X-Gm-Gg: ASbGncvt+o8kVuclBRG+jYrLengoqN5WnHfyP19wFd2JYdLvhjbzsyTXM8hPpq3sAB4 BY0fDzIz393WS3nMTX+V/BuemfJO7zpI9fH6fwYdjO+oisekyxNHEg5gCtABMbnYRG4z3RE9pN8 KmUWhKXHcLHCp/wFNjiF1dj9GAFpOb0q2JNkWf26AP69vq93b0SwGm4kNJupVR//GEu6dOoQYMe 97rLFZ2J3iEV2Xozmov76r2MXzHccDD1DQvVEwaMJlHbtPUyk2O26Bu0nW4d6EEqASV07eUtfD8 LvaNn63y0UXSB8PCX0SKG3mIvJmQ/3VhbnngIJfBbfecWCfH7y+EhndCuBbYHkLLyPgvzvWfYVM e2eBB56k4xRE+i7hvhOL1UtE2XtcVMRZwI+Yx X-Google-Smtp-Source: AGHT+IEwIvq+MzJvJvKzSGNR//1g1SyAHTIWb/Bau/CEh4PRJwyomTrDPbcTXddUHnHcaNXUPycI9Q== X-Received: by 2002:a17:902:ccc8:b0:234:b422:7120 with SMTP id d9443c01a7336-23641a8bef9mr26337945ad.9.1749623132858; Tue, 10 Jun 2025 23:25:32 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:25:32 -0700 (PDT) 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: [PATCH v5 18/23] ACPI: RISC-V: Add RPMI System MSI to GSI mapping Date: Wed, 11 Jun 2025 11:52:33 +0530 Message-ID: <20250611062238.636753-19-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 2caf049f09c8..9c9d22f5165e 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 cc1928422418..d9a2154d6c6a 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -168,6 +168,33 @@ 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; + } + + riscv_acpi_register_ext_intc(gbase, 0, 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) { @@ -222,6 +249,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 Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.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 71AD922D9EA for ; Wed, 11 Jun 2025 06:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623145; cv=none; b=u4UzqM9m4+tPHmRVF74a8hG1iPYhURBRRmDvptvWK2yICgPy8cPinTlpJ7+s+7sk8ugjYEyve6mKTF52xWukcPDcAQ2LqMz/96BJjDdppPxiJQxDgD9CTTxWa1e0PI3t4mTHfArI19U/CCxAUQYYgGRaJqbh+nnvvawOYkZhUZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623145; c=relaxed/simple; bh=Pb4fKfMGleHNMPqEtSCsUXXEOw0RGKvlO14pbjto6vU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GBgx26Oc6wrKg0hsPr6XBaDJ12xRZAKo3cXv557Yk/CUpJcqUBksL/YjC0cxEecpqmsuouMbzUXYKwomhvCoS43I87H5jtHeowzO4VYbhhAnSsftB4vF5jxE7JqAIH8CpF+DOzwvO7biTuj4sSnTonsGFifdlTeejxiDFKO+ivk= 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=aGLZ/zBU; arc=none smtp.client-ip=209.85.214.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="aGLZ/zBU" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-235d6de331fso73696965ad.3 for ; Tue, 10 Jun 2025 23:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623142; x=1750227942; 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=d7mx0GUiR5U+ns4+v9sHac9w9AvSdl9HF8/h3RrjQkc=; b=aGLZ/zBU+cZooKEvosxzzaymDEQZq23CAExcmS07T35i5QHUfqc0aEs2KjFq6wnCHv FDgP/+OkyCu1o8hcbHDBUBTGKQ1i1Weke5bYONMRHEblHMHddOdeupxhUJDDXn/PGoAS DQrfSOJMtJC+av2YjRC4eOb8i6DT+haU34ZOnJSHKURNHSdFQXCBCwTcWNbYanILxOQg 9eOUtHEVTLzzop8GSpF6VXzALYUiN1gmgUy1qctCMxVNXOfbABgpiBDZ5/OiWMEDCMd0 VGvkk6K38rMRK1fEhDZQOrwKi7Bw+tL8X6jCgjiqTPC2G0bX2p5ju1j2Aa9ycNm8PMyt GWLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623142; x=1750227942; 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=d7mx0GUiR5U+ns4+v9sHac9w9AvSdl9HF8/h3RrjQkc=; b=PmkFFXGHhBKgGpPuoiF/DQinHiimBcwM8Q+xa1FVumXNAeF7eOasyXzD1+Q3FeLTnY +YuBnyuJCrFE8id4S+Y7lWncf86bDKWRPfvT4fE5fPy7gHidadHUXKvb6rIqXWD1bKqi SRH/up1VLwPSnzZXE9phtSOMOn9sP2rAB7TptC9RvCxQd791XbuBuh/GM0QFiJw9qwGn mhapV3BLYEjDK8Tw8lVfF/lsPqsjZmraQqWj4VZMrSAEhceLpfXXebvZwpd0s1m7i1o6 pMxHeMEHgB/1dEzKbYr05JwPQ0Jh22tArP3Dj/sMpbwRgkwY4xwHgmL2gXX7XphRJWhn dqAg== X-Forwarded-Encrypted: i=1; AJvYcCWxImtnDHWTqR7cAHHISiA8NYYNRehPkol0A3ISvWSybCUTq8KNQ9nt8Qz9CyqLnbw1AIRBDj+nFdr6Yes=@vger.kernel.org X-Gm-Message-State: AOJu0YwBVslLUuSt253Qy8lvcG1XlwZpuSvo116kOLESdo5KEqtwxnGB aib2WIZ7xd6O5d56kQwW4adUMrvA/qSqZaEbvGiNgADDzGWIYa8GWd56ne5lrDEzPZE= X-Gm-Gg: ASbGncvUjFdlXBQ/E4U+NyWIOBlXwPLGd3094nSFIoJN9K0YHLFYRKXtOqDnYhORhvd rsS0mqWKn7tLbfDCe8LOSGKjSikUagbbuhLIhMskq8xftRdiC1FgrDJFtOpFk+3zX7q4ytOtJgg cpPyVtHPDrL4CmLv4pzARkFAOhfj6gAAzdO7p+f21J7Y+bqwAnkh0cxdJazTtno8dEMJLTY1E1s z+HPlWEqlmIyOpaJdaciAcFES0TWJFJ6gDnin0FleI+04lNNk7l2yD58GKVQei28K5zUqYtp/me 3PBeJ2l8YqvssfamIKsqZ8Xqr7nrWtOF34t3tLTiBp/WiHCvqs5PNoZL+hYYoSg/dyT6rd/7uLe h5jTu3do1rJNYx11HeISBnCF4xeP1k8VL1FLe X-Google-Smtp-Source: AGHT+IEfcy/atZIXks3ZUrd+ueaz0kGJBeRvccpphWnGgi4UbEP5A+4LOl8ZEzl2YZ+s8KI4mCAfHA== X-Received: by 2002:a17:903:144f:b0:235:eb8b:9968 with SMTP id d9443c01a7336-236426b4f43mr22663805ad.36.1749623141716; Tue, 10 Jun 2025 23:25:41 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:25:41 -0700 (PDT) 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: [PATCH v5 19/23] irqchip/irq-riscv-imsic-early: Export imsic_acpi_get_fwnode() Date: Wed, 11 Jun 2025 11:52:34 +0530 Message-ID: <20250611062238.636753-20-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 ACPI based loadable drivers which need MSIs will also need imsic_acpi_get_fwnode() to update the device MSI domain so export this function. Signed-off-by: Sunil V L Signed-off-by: Anup Patel Reviewed-by: Thomas Gleixner --- drivers/irqchip/irq-riscv-imsic-early.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-= riscv-imsic-early.c index d9ae87808651..1dbc41d7fe80 100644 --- a/drivers/irqchip/irq-riscv-imsic-early.c +++ b/drivers/irqchip/irq-riscv-imsic-early.c @@ -7,6 +7,7 @@ #define pr_fmt(fmt) "riscv-imsic: " fmt #include #include +#include #include #include #include @@ -215,6 +216,7 @@ struct fwnode_handle *imsic_acpi_get_fwnode(struct devi= ce *dev) { return imsic_acpi_fwnode; } +EXPORT_SYMBOL_GPL(imsic_acpi_get_fwnode); =20 static int __init imsic_early_acpi_init(union acpi_subtable_headers *heade= r, const unsigned long end) --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 0D5D023278D for ; Wed, 11 Jun 2025 06:25:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623153; cv=none; b=KMxb8CHKlLT+EB5jBSfAvKTx+0IvObTDEj69egfrWdCxQuDsb+tWqzUK9ha3wLbwsr/HcU0ZcVnuKsi/dN8VIeRMERxO/EsismEfr+BSRJ7SZx2tAPi2k+NfnOgd63ufNg9LT/zrK+680Cm8rm9Zd/ZrGLrZJWlojn+mdD4JD/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623153; c=relaxed/simple; bh=lpzOjHwOKGYG7no6pJ5n1oiI9rJzwvVEh/x0OT1aKgE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SW6ko+3EyvCmo8dtFMlwnIF8vtVPH1Lirh9ULXJh9QocGc+FG6c3YK7/zgj41/CJ3SKGiN/UgNtJ3WAls2TRhwB4Gac6I6Y0c4zmth+vlbzU2GygGPW3eEvaaJyN8x97duldkkksUOr0Lt+c1BkslgV+kTY/DqCAwD9EVF9JGVM= 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=ivnoH9Yy; arc=none smtp.client-ip=209.85.214.179 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="ivnoH9Yy" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-235e1d710d8so77539795ad.1 for ; Tue, 10 Jun 2025 23:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623151; x=1750227951; 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=SHGP1kRF/SF7T23OiU1gKTpSZCj2TzVO0PDfKD5QgtI=; b=ivnoH9Yyy6qF0hceVzhqQHkyiTFzYZxsz+C64hS31byNoW/KBMHHMW0hShm/LPzjdt EnwEg3zCZY0fb7Tk2XAPlBiXuDkoSu2/nPaGCfZEVHY2SY8qGzUSqemnIdqGjH358x1e zcJxyQ0a5KC9QlZV4dzd2ZJZkdxheTJSRBA+NyULKY646GwU/ZqiT6vP3B6/i38kkb38 Iuhoojrl1h25WpxuZBSVSyb+cv2DMrQrLUtf6WeErI6dCaxKFLY4kPfRVHJjkk4Gktc5 7t9wIw+S/RGvad0rLXCcTNJK8Pqn0tc7hZGpHtiXOAKW23VOMYWI9qEVeKhe3rweTtzl 49QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623151; x=1750227951; 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=SHGP1kRF/SF7T23OiU1gKTpSZCj2TzVO0PDfKD5QgtI=; b=qlmxEH5maHFdqrEjx/6OiQp6h3gp38V18f/FYs999cwryOiTqVjorEDD+DY/CVesE5 z7f6qQz3WNHiIc6C7xzYreNbwx6d08F/9lCQn+7tsT3pZgf3K3JRjl6saChF4Scr6Cdg RmJP8GZiqhKaerWVSbRPe0Kbg60UIGmolhgINWc/TFTK9G6f4nLiLGhFmAP/5zXvTU5u jC9KT3ih4r10ZHKfdkopy4sBW6YHQh+BSRYoHGYsaNMyOyYfqotAWV4LizkC1J9kF+la UHbojEADazBQyOe2iuBpj/pvb398Ae0r1e1elMcb7/Fg9aAAR73meAxR5jUGwAzCz426 GpEA== X-Forwarded-Encrypted: i=1; AJvYcCW+z1m5g707tBaFOO6WYMdZtQ5m19UBM35lSw4MzfVGqZ/5rqYWgKy7FFTqjZsShgrWOquRPKpEZRG0Ul8=@vger.kernel.org X-Gm-Message-State: AOJu0YzUMWhu+QDor6o7nDairnbsnSbuJWMMjuVWKE6z+XQYKfAjbnfP A7Z5k+QKET2fG+4KKMJEJJ7pRxbr8cBAuie4vOwPFgTIJgbB0HGia5tWdMHCwNA/ZF8= X-Gm-Gg: ASbGncv4X1NPcLyvZlE7q+PxySJe+31FTg5hyGYvXZw0K0JoKPjqLP4i6i+jBjmd0k7 fTWLISb46L+Lqtzjz8dVLOdyIuaAWHRW7MqqmGmRnZgtuq83mAQFNps/jEaj269T58pIKgascnO iywLKTQmzNddsAYHGAKDIaMtcn6uqnUF8P8taPWcBO7MTSfSQWMFIkjFhwYmORPnZbJqePX67cT a/6A0i+UiKWB2B5hy2rzmuBjMEGm33X8AiEM6NayKKCqyXNh+AaklbZEQIAl5ykzfslqa8KPeMz 5WRehQz8+8dLwl5AGRAw3BXNpEAseqPgWOZPGg316Frc4hW3nu9PfmOp8VRqOR6NP6gFZeXvHgH Ldvoi4qLnRUOLaaMR4uFQH+yGvg== X-Google-Smtp-Source: AGHT+IH6nfiBAkGOIya5bHfPvFUBz/4//w0r17J0S0KttXRyJ2RxRUT8VeWrU3bXJnI2eud8IG6zCQ== X-Received: by 2002:a17:902:e548:b0:235:779:edfe with SMTP id d9443c01a7336-23641b28c80mr32543345ad.43.1749623151173; Tue, 10 Jun 2025 23:25:51 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:25:50 -0700 (PDT) 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: [PATCH v5 20/23] mailbox/riscv-sbi-mpxy: Add ACPI support Date: Wed, 11 Jun 2025 11:52:35 +0530 Message-ID: <20250611062238.636753-21-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/riscv-sbi-mpxy-mbox.c b/drivers/mailbox/riscv-= sbi-mpxy-mbox.c index ead67345456e..dbc76a254c44 100644 --- a/drivers/mailbox/riscv-sbi-mpxy-mbox.c +++ b/drivers/mailbox/riscv-sbi-mpxy-mbox.c @@ -5,9 +5,11 @@ * Copyright (C) 2025 Ventana Micro Systems Inc. */ =20 +#include #include #include #include +#include #include #include #include @@ -769,6 +771,7 @@ static int mpxy_mbox_probe(struct platform_device *pdev) u32 i, *channel_ids __free(kfree) =3D NULL; struct device *dev =3D &pdev->dev; struct mpxy_mbox_channel *mchan; + struct irq_domain *msi_domain; struct mpxy_mbox *mbox; int msi_idx, rc; =20 @@ -891,6 +894,8 @@ static int mpxy_mbox_probe(struct platform_device *pdev) =20 /* Set the MSI domain if not available */ if (!dev_get_msi_domain(dev)) { + struct fwnode_handle *fwnode =3D dev_fwnode(dev); + /* * The device MSI domain for OF devices is only set at the * time of populating/creating OF device. If the device MSI @@ -898,8 +903,13 @@ static int mpxy_mbox_probe(struct platform_device *pde= v) * then we need to set it explicitly before using any platform * MSI functions. */ - if (dev_of_node(dev)) + if (is_of_node(fwnode)) { of_msi_configure(dev, dev_of_node(dev)); + } else if (is_acpi_device_node(fwnode)) { + msi_domain =3D irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + dev_set_msi_domain(dev, msi_domain); + } } =20 /* Setup MSIs for mailbox (if required) */ @@ -944,6 +954,13 @@ static int mpxy_mbox_probe(struct platform_device *pde= v) return rc; } =20 +#ifdef CONFIG_ACPI + struct acpi_device *adev =3D ACPI_COMPANION(dev); + + if (adev) + acpi_dev_clear_dependencies(adev); +#endif + dev_info(dev, "mailbox registered with %d channels\n", mbox->channel_count); return 0; @@ -963,10 +980,17 @@ static const struct of_device_id mpxy_mbox_of_match[]= =3D { }; MODULE_DEVICE_TABLE(of, mpxy_mbox_of_match); =20 +static const struct acpi_device_id mpxy_mbox_acpi_match[] =3D { + { "RSCV0005" }, + {} +}; +MODULE_DEVICE_TABLE(acpi, mpxy_mbox_acpi_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, + .acpi_match_table =3D mpxy_mbox_acpi_match, }, .probe =3D mpxy_mbox_probe, .remove =3D mpxy_mbox_remove, --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.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 DC73822CBC8 for ; Wed, 11 Jun 2025 06:26:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623162; cv=none; b=gxjCyufvs/yOe6Ai3iZsbtnfQP1CnSwOsNbA8P1LfdT3Z1SF9TDfgf8t0H4fbP6LEL+awrNRRP3ujniES0tKdwn4C4SEdGaYfByoBf4UxaLhSwMFG2onoCtJFbt2eQ7moqO36PhW47qySrVHNgoJMhRQnmJK1XqrmAe1dlxRlck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623162; c=relaxed/simple; bh=cQmAlJ5DFIrp9Ji0v7+dFRa1ZwSMWPgUy9FslwKC2dM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GoIIyVMRAjMODlzQPfJ3dEmhT8Jk+bK327UH22rClgzEUcgkaIzSJsiFwNdj5W0ghygj/SU6fSCBf8NbVkz1sDHgT2/dpFpILqT1582cWWVK5a8pB7tQMjrU66eyFJoPw2XWRK3BP70UQ1z4gXXS4XngY7jqTSvnvUuy50VJyQ4= 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=hqrc5TNT; arc=none smtp.client-ip=209.85.214.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="hqrc5TNT" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-23539a1a421so54448785ad.0 for ; Tue, 10 Jun 2025 23:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623160; x=1750227960; 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=YS9j9gcN2wQKo26dVWHCAmNvKNHMO5vB8LdZytpDdd4=; b=hqrc5TNTS9M8+N8B0SE7yj2jD25tFsNRyQ3GJ0vXrKXZLUMhf25QjuXVJElNTQ55Ab by6LrT+Y8/hLcuKrYJDD5XRTkYXxofMwbDnHajswEH/gc+cavqUj7inKxvciMmP5l2Wn LMY+qmX7UXwWX5ZU8qkb+d3PYRQtPvrOqmMYzDs1gUDwWLWGoQ68+5CIEY4YgHiXwxTt oTaKEPC929o0nBonjBmomiu+t9FPLkZwFvI9UBv17V/JWwOliPFIdmEig+wOxt2w0SuC xH+fAuUQSbJDuQ+r3QxI+Gte7aLkVAX0zew16meSH2bYqVmkY6A/fkBXK8USTEEQO8Oj LA2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623160; x=1750227960; 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=YS9j9gcN2wQKo26dVWHCAmNvKNHMO5vB8LdZytpDdd4=; b=ZxOmXtV1jC6GTIsaT6P69+59G8kiImO0jFoNNTLr/fPNHU15RLjj3KJlfhZ0gyolOr jZ1na4rK9RoGs27z3C/vrW0wqkfNN2TaOiS8jWo+gFFKnHs5KTb3bEj4UI0gXej+6xx3 +OeaCQjoH3aXWzH3/HUoCFGGJQ1dtx+yPx9FFb1XHjwBoZ6VF71153tGOKEWaEuNeFlZ b1ZEvL91D344JDP7YzVkk+iii3tHv/+Xq2vaVbLrFXm4L3ULvyO/fLQobvqvKmq6NjYB 8K+l71jNS/qciNM5+6/DJCSYy6rCgc82NP20tEWtagP5hocHbnBQHY6R8qtIICVBooAv KNQA== X-Forwarded-Encrypted: i=1; AJvYcCUFZBnLE/duDODnhFHsg+7mUFz9YigpLy/ftir4qm7Zkam/jUNphdBWCd/erTdo4Jztf+cvenJ3B0DfTZY=@vger.kernel.org X-Gm-Message-State: AOJu0YwfYCxhevWsCMltUZx5W81VzJz7wyr7c8SgydeQ9b6lLnanK8Fq rDwYQl9xGWn9PObk3qFRF6GaHWqSjE3SYGdFYsx0gcK7U+tuMbE+gBg2ADkX61XqFsY= X-Gm-Gg: ASbGncslFzCBv/3tfNjoaBkogL2snwUfkGfqmozLIKuuC6pAYFgB9iJiLGzIa6wbtIf ZwsxvklOLe96JvziZGB8a/JSfny0fB/ok0j8p56XmpHd3dd5XjySMQJyoRTTmUOrGIEMeIdzY0N 1KP73Bj0Aqexr9AKITmQu176Zw9xhVUsSRNypBG1g0b2xNAYKSsbyurjC10s5reC+hMhrBnIRyj Hb1C6Fo1de1r4SlTnDtGBJYvmrGa5ZQrTDcXi6wMQfmPaDJ7QaDyLXSGD3t5auofb2KGwT6o77A I9v9vFIIRArstDwXaUeH/Cg1tPUXaMAZudqqAZDWdeoX+QEQmajLEBEGfES8e6BzO/SxM/NTnFW NJFJbehymT7fVaBMYma4ALRy+Bg== X-Google-Smtp-Source: AGHT+IGgdyPwstKE3+iWn8KD2dTBYhJpnWD6M3so2zeNZkFWSUS5/H3BXTX0WABWmKEEx/TX7p+X9A== X-Received: by 2002:a17:903:2a8d:b0:235:1962:1bf4 with SMTP id d9443c01a7336-23641a99d80mr28376795ad.14.1749623160046; Tue, 10 Jun 2025 23:26:00 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:25:59 -0700 (PDT) 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: [PATCH v5 21/23] irqchip/riscv-rpmi-sysmsi: Add ACPI support Date: Wed, 11 Jun 2025 11:52:36 +0530 Message-ID: <20250611062238.636753-22-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 Reviewed-by: Thomas Gleixner --- drivers/irqchip/Kconfig | 2 +- drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 46 +++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 96bf6aa55681..dfa8cc0e23dd 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -619,7 +619,7 @@ config RISCV_IMSIC =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 06f64936802a..d424067d22a8 100644 --- a/drivers/irqchip/irq-riscv-rpmi-sysmsi.c +++ b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2025 Ventana Micro Systems Inc. */ =20 +#include #include #include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -211,6 +213,9 @@ static int rpmi_sysmsi_probe(struct platform_device *pd= ev) { struct device *dev =3D &pdev->dev; struct rpmi_sysmsi_priv *priv; + struct irq_domain *msi_domain; + struct fwnode_handle *fwnode; + u32 id; int rc; =20 priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -241,6 +246,22 @@ static int rpmi_sysmsi_probe(struct platform_device *p= dev) } priv->nr_irqs =3D rc; =20 + fwnode =3D dev_fwnode(dev); + if (is_acpi_node(fwnode)) { + u32 nr_irqs; + + rc =3D riscv_acpi_get_gsi_info(fwnode, &priv->gsi_base, &id, + &nr_irqs, NULL); + if (rc) { + dev_err(dev, "failed to find GSI mapping\n"); + return rc; + } + + /* Update with actual GSI range */ + if (nr_irqs !=3D priv->nr_irqs) + riscv_acpi_update_gsi_range(priv->gsi_base, priv->nr_irqs); + } + /* Set the device MSI domain if not available */ if (!dev_get_msi_domain(dev)) { /* @@ -250,8 +271,13 @@ static int rpmi_sysmsi_probe(struct platform_device *p= dev) * then we need to set it explicitly before using any platform * MSI functions. */ - if (dev_of_node(dev)) + if (is_of_node(fwnode)) { of_msi_configure(dev, dev_of_node(dev)); + } else if (is_acpi_device_node(fwnode)) { + msi_domain =3D irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + dev_set_msi_domain(dev, msi_domain); + } =20 if (!dev_get_msi_domain(dev)) { mbox_free_channel(priv->chan); @@ -266,6 +292,13 @@ static int rpmi_sysmsi_probe(struct platform_device *p= dev) return dev_err_probe(dev, -ENOMEM, "failed to create MSI irq domain\n"); } =20 +#ifdef CONFIG_ACPI + struct acpi_device *adev =3D ACPI_COMPANION(dev); + + if (adev) + acpi_dev_clear_dependencies(adev); +#endif + dev_info(dev, "%u system MSIs registered\n", priv->nr_irqs); return 0; } @@ -275,10 +308,17 @@ static const struct of_device_id rpmi_sysmsi_match[] = =3D { {} }; =20 +static const struct acpi_device_id acpi_rpmi_sysmsi_match[] =3D { + { "RSCV0006" }, + {} +}; +MODULE_DEVICE_TABLE(acpi, acpi_rpmi_sysmsi_match); + static struct platform_driver rpmi_sysmsi_driver =3D { .driver =3D { - .name =3D "rpmi-sysmsi", - .of_match_table =3D rpmi_sysmsi_match, + .name =3D "rpmi-sysmsi", + .of_match_table =3D rpmi_sysmsi_match, + .acpi_match_table =3D acpi_rpmi_sysmsi_match, }, .probe =3D rpmi_sysmsi_probe, }; --=20 2.43.0 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.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 A363922DA13 for ; Wed, 11 Jun 2025 06:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623171; cv=none; b=c5/6MjfnodUqrEH9KRvNGJbcXU3mjG7zcEtHodo86O1OjI39VK4f0GctJyykbQzpKrBAY4oOQ74SZGSvDS7FggxWnys1eaMvwvRYnmUpNM1SWcVCDebXL2kHC+OW8EC+v2pKyjXd45lv5czmNsd8UKUncQN+3SsROxD52U+V0+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623171; c=relaxed/simple; bh=do4xgD3FIKiBFCXHybdwqmJMFTQfLzd5+SYEVnCmQ8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CADhJThKApS6TM8+qUjqs0VLzMAXQRo9Elrlet76CP0h/RolpuO4709715KqiLF1WprrxSlRsUG1FCgH7EGR03zKoLVJ7X+ZxP64pBAvlVFqgiomJnT38jMH2PzbXVHgW3P9TpSk9jkkyr4tMFrNmVr3gk6Ac2u0X7NZNSai9xQ= 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=P7e2A5/R; arc=none smtp.client-ip=209.85.214.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="P7e2A5/R" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-234c5b57557so59016095ad.3 for ; Tue, 10 Jun 2025 23:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623169; x=1750227969; 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=nCKZPLGMv6q3Gia2CuwihlvGGifXlgSwREijf4CMFzo=; b=P7e2A5/RMbpKWV4USYgEX54JkYswpao4dAxpHRwOtDaJg2iIbqpr5n5xCDDwJT1YsG RWmezbfWNp15lLMJ0zQuQDlTPyr+GNtPH8Ql14sHNNjNgdUEiveHXin4q3ULUXJBHRry 5mPp7o8+0JQbZI4Pg7biiiX1+PQRKES6GYhJEW7Y52PGD0QnXVkEucY/LegXYvoPOa7V X+YfH4JfgedMbkGbRn4fEmuWac60kIoUEF3YbbL698Im/BZR43juROuTTOuoPJs78v7e beQc7WnzNKTCIY2eDlidnXtLwnp8PRnK8IdDtc12XQaPsE8ZZqneW3uQhJjUEsyWIz7+ 89sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623169; x=1750227969; 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=nCKZPLGMv6q3Gia2CuwihlvGGifXlgSwREijf4CMFzo=; b=pXNo5MpLjAFFhLVmDk4kgG3u3/Ns4mtTb4J6NOW8HdnvH2GsJdDjiTmzIGnl9jt4mN 1ZtMDUELoanNsrHWBAwXJM+VIAkbIsSwyaOlUaltQKjwOFiNjA0Are13K4zTsqRlpBoO av5ergxI55PB9RcSD8W20Cpra7McBRoSluYQ/4sm9sMrTAJ9J3vhedEXdW4qEoI74tjs DLX595Q3yuypo0z6sqKPKgKyKqXugoS8FwLEcyzQWk9p5R/72liYHpi1t/Z8Ku7nzALI A3zRxM5KqT0cIGs+NJMz4EseTaIZtatr3MCCzmo8cWz59CzYw8vqJfadGSrH6pyZTeJa qYDg== X-Forwarded-Encrypted: i=1; AJvYcCUgk/NGhOzhnRoQAp2eweO1Y5GKBo5b3vPUbRvwSay57OKAeieBlPutVb5eMWNEuiNp1ecJ1qQyJWmoQLA=@vger.kernel.org X-Gm-Message-State: AOJu0YxQO4Bm880qhPhO7lOqghwDeVCsXA2rqWj9VcQH74i/tMSefM81 wISIL35QssRU2ml5lSMPG4jtPNZKJzcWZD91d0Sgxk6Ucz4WqW8/RjWD6dogN+I+Ihk= X-Gm-Gg: ASbGncteDeaWp+HAsCAKq8IqZeiqXAjsEapJ6j1YGqnq5TmzlIaUjr8HoAazPn+r+LT 3I8RLpWjLD4z3sRMKH5w9u8iEa/K2hel11fIkd2xg/gHOes/hXub6xeTp83NXVKp8DXVqlVLI3L cG8nQouosJSx/u6dZKBAEx4s6t9Sp/WMfXG0cGl8dNNhVYfWrPxeXdIY+X5PlaGoyeothpVXljc qOCSPfPiX7PsNYaP07EhnBbox5GLMqCLLlQPKyKEcx7lzODON2p0X1wTg50+38HCbbmq9nRE/Tq /GggPCFzmU+1Fai+13s97M9qKDeonUkxwnVlsfX/zMcq6ywEh5PxG6Xu1B9Orf0shCVZ8el3AUA EDUofwSuynz36nJBNtvzZstZt+r1MEmFiy4Aj X-Google-Smtp-Source: AGHT+IHxgzd+8XFQeH6I+CnI3pJzaPr1EGnWCnVsqBSz05ercFVxc937r04XmAc5WZ/WtZq89w951A== X-Received: by 2002:a17:902:ebc4:b0:235:2403:77c7 with SMTP id d9443c01a7336-236426a80b7mr21936585ad.37.1749623168893; Tue, 10 Jun 2025 23:26:08 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:26:08 -0700 (PDT) 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: [PATCH v5 22/23] RISC-V: Enable GPIO keyboard and event device in RV64 defconfig Date: Wed, 11 Jun 2025 11:52:37 +0530 Message-ID: <20250611062238.636753-23-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 fe8bd8afb418..bd5f97e1d1a0 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -138,6 +138,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 From nobody Sat Oct 11 10:27:59 2025 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.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 9F1BF22E01E for ; Wed, 11 Jun 2025 06:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623183; cv=none; b=OoshkVxZgdVyz8Q3TG0gAEIQFSoJOUHLo7JNpIQlDp2Qxr1CKZ5ol8MYBVmMY67YAlqie6+IQitaryMV796WHLUZDbACMglMXI5h+txEuCPyj4VUXEoAPJBGOyd9dB+O4vjlqIEz69LXd8gmrwpX/fBufbxjo+m3bE4PiwDRqjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749623183; c=relaxed/simple; bh=hR1n8x0Puv7CTZWZxD0bA8wGkXIKo6DifapRtybNFHY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pO6TH+KNm4xkGwe8A3/y0HKfzjrKptlF0wYAG0qPNqPLmu61KGfFX40boYqTGNSZcUHKo+j6zaYfe2Eug7Bh+MZAiPs+A8Si0CNSmFtbEodZM9F/2auBkFl3rSBJ1DGNa6fe/pgRp0iFfByoEho23VSiYjB08C12EkUiIncoPj0= 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=Uu+uBohp; arc=none smtp.client-ip=209.85.214.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="Uu+uBohp" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-235d6de331fso73702335ad.3 for ; Tue, 10 Jun 2025 23:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1749623178; x=1750227978; 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=t2ugGpXC4o/CNHHmtI6Ytb/JDD4uHU55rBbbL+FpeXA=; b=Uu+uBohpwjzphPE9rzlGsE8JsFoFTE4976zPzsLwAi8Goknqv0ZijLTY4lAveaov4N PGaSLm/r01w56mLagiXxSufJCsGcjO8Vidg6WbqmoBK+JjGD3JZWtG75E0erWEWYoSqd p66hoznAJCWBoNKmwn4bz03X8uNjrGxte6Z4/RpqaQANVRLXZl4tNh4WVKnDI+5IsO+W UrF5+bMXzhLqO8V54rSsJK2iSEddGC9Qub5i+Es+wVN98B8fw2onubNbqAWVVFWaBtzN 84MSqrRbqoGfRWTRZI75btmnhWJmQqXw7TEJHF6s+pdyqbi+2Sqoda2hLe6xeQ6AUIbq 1nRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749623178; x=1750227978; 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=t2ugGpXC4o/CNHHmtI6Ytb/JDD4uHU55rBbbL+FpeXA=; b=TMi2+vfmGLna0w+3kV3t52kZ5pDUNKZQuJe2jnFn72vZ3RaVh9JQEULkRzwc/gONqZ iFDLHWAdda7w/91ocDaSEcpDkyR3/EO67WutctMktZ1pOqVzTmlweIRSjwOMc9sK2SQj LxLpL7Yo2mIc0+s91jIVyxa3tyAoAf7oLR0eGNvAEO6CvyCU1OtXbxS8fWRhUCk/qAS/ ekGVhheP54T3I9v0VzBbMsCpkxEFUgmNypb8lCB3N50wU03Sz2NiMLGEQRxvpczQg2er BF1w4SqNHCsj3N7SE/2tBjKLojuOVqyjDDHMGaQOUt7ER+JNM2F9L9w1SJQbyR7YJjbh uLiw== X-Forwarded-Encrypted: i=1; AJvYcCVJRbSedYBoa13GLX8m6qoDHGoxDuc/opxnuwc8GxGBldEuPKPCzD1Fx8oncHRIYmoHTIe2xykCYx7EAUU=@vger.kernel.org X-Gm-Message-State: AOJu0YwR8JHVe2Ohs9sXjLQHSsxLCmtfuw/54zBlN9rTqvLpHsETnVlU owePwUHZ6/AWIbIzu39XGAa1iqH00P3SA8+/EmRg0YL9kGgRW+CKkLZKM/8ZhZ1GMSQ= X-Gm-Gg: ASbGnctTMfkDe0Bz/cwfJArSpz2BIUt2G0hR4+L/nI2X6zsWMZ7pmyyEtLlC5WLdgs6 NaacZola+a6zDvLJAaPYlI13uMVRfCexiyOp50CDQijMjUgKdiZ4J96r+SWM9PCY0osdx7kXwS7 TmTLvJz7/4rW3XAuvhD7vasmfaI08j7Yh3yzevxrAmyc7BnYrEXmTgXrvGdAErlN1AFCwffbB6W jgqlNYTQRQSccYG0Xme0C2Ry57bNMCv4jQ8zE2kHPpR21BJHIYmyK2gZmLGVqS26etTm1GZ2du9 qbs6ICZ9tVOKNxKB3ILPmKNn2v+RkG8Ka1AygYlBIlU95br42f95S5QAOWLAWbWyS8ql8l9eIJY W+rwlh1VKrnMx1uji+L3ilyeOaQ== X-Google-Smtp-Source: AGHT+IHWcPo2T5oWAHxVCtrvEXenhjJ10/Omq5VoGqBDmOSNSjGENAvaM/GRXOOcD2Yi8BQMsG2wZQ== X-Received: by 2002:a17:902:d48c:b0:234:b743:c7a4 with SMTP id d9443c01a7336-236426b4fbcmr25446925ad.38.1749623177773; Tue, 10 Jun 2025 23:26:17 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23603092677sm79976295ad.64.2025.06.10.23.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 23:26:17 -0700 (PDT) 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: [PATCH v5 23/23] MAINTAINERS: Add entry for RISC-V RPMI and MPXY drivers Date: Wed, 11 Jun 2025 11:52:38 +0530 Message-ID: <20250611062238.636753-24-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611062238.636753-1-apatel@ventanamicro.com> References: <20250611062238.636753-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 Rahul and myself as maintainers for RISC-V RPMI and MPXY drivers. Signed-off-by: Anup Patel --- MAINTAINERS | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index a92290fffa16..5ac1746f3086 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21361,6 +21361,21 @@ F: drivers/perf/riscv_pmu.c F: drivers/perf/riscv_pmu_legacy.c F: drivers/perf/riscv_pmu_sbi.c =20 +RISC-V RPMI AND MPXY DRIVERS +M: Rahul Pathak +M: Anup Patel +L: linux-riscv@lists.infradead.org +F: Documentation/devicetree/bindings/clock/riscv,rpmi-clock.yaml +F: Documentation/devicetree/bindings/clock/riscv,rpmi-mpxy-clock.yaml +F: Documentation/devicetree/bindings/interrupt-controller/riscv,rpmi-mpxy-= system-msi.yaml +F: Documentation/devicetree/bindings/interrupt-controller/riscv,rpmi-syste= m-msi.yaml +F: Documentation/devicetree/bindings/mailbox/riscv,rpmi-shmem-mbox.yaml +F: Documentation/devicetree/bindings/mailbox/riscv,sbi-mpxy-mbox.yaml +F: drivers/clk/clk-rpmi.c +F: drivers/irqchip/irq-riscv-rpmi-sysmsi.c +F: drivers/mailbox/riscv-sbi-mpxy-mbox.c +F: include/linux/mailbox/riscv-rpmi-message.h + RISC-V SPACEMIT SoC Support M: Yixun Lan L: linux-riscv@lists.infradead.org --=20 2.43.0