Skip to content

Commit 4752b0c

Browse files
vlsunilPaul Walmsley
authored andcommitted
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>
1 parent 7e64042 commit 4752b0c

2 files changed

Lines changed: 45 additions & 4 deletions

File tree

drivers/irqchip/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ config RISCV_IMSIC
636636

637637
config RISCV_RPMI_SYSMSI
638638
bool
639-
depends on MAILBOX
639+
depends on RISCV && MAILBOX
640640
select IRQ_DOMAIN_HIERARCHY
641641
select GENERIC_MSI_IRQ
642642
default RISCV

drivers/irqchip/irq-riscv-rpmi-sysmsi.c

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/* Copyright (C) 2025 Ventana Micro Systems Inc. */
33

4+
#include <linux/acpi.h>
45
#include <linux/bits.h>
56
#include <linux/bug.h>
67
#include <linux/device.h>
@@ -9,6 +10,7 @@
910
#include <linux/errno.h>
1011
#include <linux/irq.h>
1112
#include <linux/irqdomain.h>
13+
#include <linux/irqchip/riscv-imsic.h>
1214
#include <linux/mailbox_client.h>
1315
#include <linux/mailbox/riscv-rpmi-message.h>
1416
#include <linux/module.h>
@@ -209,6 +211,8 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
209211
{
210212
struct device *dev = &pdev->dev;
211213
struct rpmi_sysmsi_priv *priv;
214+
struct fwnode_handle *fwnode;
215+
u32 id;
212216
int rc;
213217

214218
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -239,6 +243,22 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
239243
}
240244
priv->nr_irqs = rc;
241245

246+
fwnode = dev_fwnode(dev);
247+
if (is_acpi_node(fwnode)) {
248+
u32 nr_irqs;
249+
250+
rc = riscv_acpi_get_gsi_info(fwnode, &priv->gsi_base, &id,
251+
&nr_irqs, NULL);
252+
if (rc) {
253+
dev_err(dev, "failed to find GSI mapping\n");
254+
return rc;
255+
}
256+
257+
/* Update with actual GSI range */
258+
if (nr_irqs != priv->nr_irqs)
259+
riscv_acpi_update_gsi_range(priv->gsi_base, priv->nr_irqs);
260+
}
261+
242262
/*
243263
* The device MSI domain for platform devices on RISC-V architecture
244264
* is only available after the MSI controller driver is probed so,
@@ -252,8 +272,15 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
252272
* then we need to set it explicitly before using any platform
253273
* MSI functions.
254274
*/
255-
if (dev_of_node(dev))
275+
if (is_of_node(fwnode)) {
256276
of_msi_configure(dev, dev_of_node(dev));
277+
} else if (is_acpi_device_node(fwnode)) {
278+
struct irq_domain *msi_domain;
279+
280+
msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev),
281+
DOMAIN_BUS_PLATFORM_MSI);
282+
dev_set_msi_domain(dev, msi_domain);
283+
}
257284

258285
if (!dev_get_msi_domain(dev)) {
259286
mbox_free_channel(priv->chan);
@@ -268,6 +295,13 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
268295
return dev_err_probe(dev, -ENOMEM, "failed to create MSI irq domain\n");
269296
}
270297

298+
#ifdef CONFIG_ACPI
299+
struct acpi_device *adev = ACPI_COMPANION(dev);
300+
301+
if (adev)
302+
acpi_dev_clear_dependencies(adev);
303+
#endif
304+
271305
dev_info(dev, "%u system MSIs registered\n", priv->nr_irqs);
272306
return 0;
273307
}
@@ -277,10 +311,17 @@ static const struct of_device_id rpmi_sysmsi_match[] = {
277311
{}
278312
};
279313

314+
static const struct acpi_device_id acpi_rpmi_sysmsi_match[] = {
315+
{ "RSCV0006" },
316+
{}
317+
};
318+
MODULE_DEVICE_TABLE(acpi, acpi_rpmi_sysmsi_match);
319+
280320
static struct platform_driver rpmi_sysmsi_driver = {
281321
.driver = {
282-
.name = "rpmi-sysmsi",
283-
.of_match_table = rpmi_sysmsi_match,
322+
.name = "rpmi-sysmsi",
323+
.of_match_table = rpmi_sysmsi_match,
324+
.acpi_match_table = acpi_rpmi_sysmsi_match,
284325
},
285326
.probe = rpmi_sysmsi_probe,
286327
};

0 commit comments

Comments
 (0)