[RFC PATCH v1 15/21] ACPI: RISC-V: Create IMSIC platform device
Sunil V L
sunilvl at ventanamicro.com
Thu Aug 3 10:59:10 PDT 2023
The MSI controller functionality of the RISC-V IMSIC is
probed as a platform device by the driver. So, create the
IMSIC platform device if the IMSIC was discovered in MADT
during early IMSIC driver probe.
Signed-off-by: Sunil V L <sunilvl at ventanamicro.com>
---
drivers/acpi/riscv/init.c | 2 ++
drivers/acpi/riscv/init.h | 4 ++++
drivers/acpi/riscv/irqchip.c | 23 +++++++++++++++++++++++
3 files changed, 29 insertions(+)
create mode 100644 drivers/acpi/riscv/init.h
diff --git a/drivers/acpi/riscv/init.c b/drivers/acpi/riscv/init.c
index b5807bbdb171..be61c08ea385 100644
--- a/drivers/acpi/riscv/init.c
+++ b/drivers/acpi/riscv/init.c
@@ -6,7 +6,9 @@
*/
#include <linux/acpi.h>
+#include "init.h"
void __init acpi_riscv_init(void)
{
+ riscv_acpi_imsic_platform_init();
}
diff --git a/drivers/acpi/riscv/init.h b/drivers/acpi/riscv/init.h
new file mode 100644
index 000000000000..a2f72bb294d3
--- /dev/null
+++ b/drivers/acpi/riscv/init.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <linux/init.h>
+
+void __init riscv_acpi_imsic_platform_init(void);
diff --git a/drivers/acpi/riscv/irqchip.c b/drivers/acpi/riscv/irqchip.c
index 6e15d45cb229..ca96bf109cf7 100644
--- a/drivers/acpi/riscv/irqchip.c
+++ b/drivers/acpi/riscv/irqchip.c
@@ -9,7 +9,10 @@
#include <linux/fwnode.h>
#include <linux/irqdomain.h>
#include <linux/list.h>
+#include <linux/msi.h>
+#include <linux/platform_device.h>
#include <linux/property.h>
+#include "../../../drivers/pci/pci.h"
struct riscv_irqchip_list {
struct fwnode_handle *fwnode;
@@ -101,3 +104,23 @@ struct fwnode_handle *acpi_riscv_get_msi_fwnode(struct device *dev)
{
return imsic_acpi_fwnode;
}
+
+void __init riscv_acpi_imsic_platform_init(void)
+{
+ struct platform_device *pdev;
+ int ret;
+
+ if (!acpi_riscv_get_msi_fwnode(NULL)) {
+ pci_no_msi();
+ return;
+ }
+
+ pdev = platform_device_alloc("riscv-imsic", 0);
+ if (!pdev)
+ return;
+
+ pdev->dev.fwnode = acpi_riscv_get_msi_fwnode(NULL);
+ ret = platform_device_add(pdev);
+ if (ret)
+ platform_device_put(pdev);
+}
--
2.39.2
More information about the linux-riscv
mailing list