irqchip/riscv-rpmi-sysmsi: Add ACPI support

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

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Link: https://lore.kernel.org/r/20250818040920.272664-23-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
pull/1354/merge
Sunil V L 2025-08-18 09:39:18 +05:30 committed by Paul Walmsley
parent 7e64042fdb
commit 4752b0cfbc
2 changed files with 45 additions and 4 deletions

View File

@ -636,7 +636,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

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) 2025 Ventana Micro Systems Inc. */
#include <linux/acpi.h>
#include <linux/bits.h>
#include <linux/bug.h>
#include <linux/device.h>
@ -9,6 +10,7 @@
#include <linux/errno.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/irqchip/riscv-imsic.h>
#include <linux/mailbox_client.h>
#include <linux/mailbox/riscv-rpmi-message.h>
#include <linux/module.h>
@ -209,6 +211,8 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct rpmi_sysmsi_priv *priv;
struct fwnode_handle *fwnode;
u32 id;
int rc;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@ -239,6 +243,22 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
}
priv->nr_irqs = rc;
fwnode = dev_fwnode(dev);
if (is_acpi_node(fwnode)) {
u32 nr_irqs;
rc = 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 != priv->nr_irqs)
riscv_acpi_update_gsi_range(priv->gsi_base, priv->nr_irqs);
}
/*
* The device MSI domain for platform devices on RISC-V architecture
* is only available after the MSI controller driver is probed so,
@ -252,8 +272,15 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
* 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)) {
struct irq_domain *msi_domain;
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)) {
mbox_free_channel(priv->chan);
@ -268,6 +295,13 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
return dev_err_probe(dev, -ENOMEM, "failed to create MSI irq domain\n");
}
#ifdef CONFIG_ACPI
struct acpi_device *adev = ACPI_COMPANION(dev);
if (adev)
acpi_dev_clear_dependencies(adev);
#endif
dev_info(dev, "%u system MSIs registered\n", priv->nr_irqs);
return 0;
}
@ -277,10 +311,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,
};