[PATCH v3 21/23] irqchip/riscv-rpmi-sysmsi: Add ACPI support

Anup Patel
2025-05-11T13:43:04Z

From: Sunil V L <sunilvl@ventanamicro.com>

Add ACPI support for the RISC-V RPMI system MSI based irqchip driver.

Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
drivers/irqchip/Kconfig | 2 +-
drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 41 +++++++++++++++++++++++--
2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 83700fc2ddc9..132e56a596fc 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -614,7 +614,7 @@ config RISCV_IMSIC

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 9f14a92290c4..cfe8d45dba97 100644
--- a/drivers/irqchip/irq-riscv-rpmi-sysmsi.c
+++ b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c
@@ -3,11 +3,13 @@
* Copyright (C) 2025 Ventana Micro Systems Inc.
*/

+#include <linux/acpi.h>
#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/cpu.h>
#include <linux/interrupt.h>
#include <linux/irqchip.h>
+#include <linux/irqchip/riscv-imsic.h>
#include <linux/mailbox_client.h>
#include <linux/mailbox/riscv-rpmi-message.h>
#include <linux/module.h>
@@ -212,6 +214,8 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct rpmi_sysmsi_priv *priv;
+ struct irq_domain *msi_domain;
+ u32 id;
int rc;

priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -240,6 +244,21 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
}
priv->nr_irqs = rc;

+ if (is_acpi_node(dev_fwnode(dev))) {
+ u32 nr_irqs;
+
+ rc = riscv_acpi_get_gsi_info(dev_fwnode(dev), &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 != 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)) {
/*
@@ -249,8 +268,13 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
* then we need to set it explicitly before using any platform
* MSI functions.
*/
- if (is_of_node(dev_fwnode(dev)))
+ if (is_of_node(dev_fwnode(dev))) {
of_msi_configure(dev, to_of_node(dev_fwnode(dev)));
+ } else {
+ msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev),
+ DOMAIN_BUS_PLATFORM_MSI);
+ dev_set_msi_domain(dev, msi_domain);
+ }

if (!dev_get_msi_domain(dev))
return -EPROBE_DEFER;
@@ -261,6 +285,10 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
priv->nr_irqs, priv, priv))
return dev_err_probe(dev, -ENOMEM, "failed to create MSI irq domain\n");

+#ifdef CONFIG_ACPI
+ if (!acpi_disabled)
+ acpi_dev_clear_dependencies(ACPI_COMPANION(dev));
+#endif
dev_info(dev, "%d system MSIs registered\n", priv->nr_irqs);
return 0;
}
@@ -270,10 +298,17 @@ static const struct of_device_id rpmi_sysmsi_match[] = {
{}
};

+static const struct acpi_device_id acpi_rpmi_sysmsi_match[] = {
+ { "RSCV0006" },
+ {}
+};
+MODULE_DEVICE_TABLE(acpi, acpi_rpmi_sysmsi_match);
+
static struct platform_driver rpmi_sysmsi_driver = {
.driver = {
- .name = "rpmi-sysmsi",
- .of_match_table = rpmi_sysmsi_match,
+ .name = "rpmi-sysmsi",
+ .of_match_table = rpmi_sysmsi_match,
+ .acpi_match_table = acpi_rpmi_sysmsi_match,
},
.probe = rpmi_sysmsi_probe,
};
--
2.43.0