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>
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+
280320static 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