[RFC,v1,15/21] ACPI: RISC-V: Create IMSIC platform device
Commit Message
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@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
@@ -6,7 +6,9 @@
*/
#include <linux/acpi.h>
+#include "init.h"
void __init acpi_riscv_init(void)
{
+ riscv_acpi_imsic_platform_init();
}
new file mode 100644
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <linux/init.h>
+
+void __init riscv_acpi_imsic_platform_init(void);
@@ -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);
+}