[PATCH] [PATCH] drivers/firmware/qemu_fw_cfg: add RISCV support

From: xiaoming
Date: Wed Sep 01 2021 - 06:41:59 EST


In the latest release of qemu (qemu 6.0.0 or higher) riscv virt already supports fw_cfg, but
drivers/firmware/qemu_fw_cfg not support.

Signed-off-by: xiaoming <2014500726@xxxxxxxxxxxxxxxx>
---
drivers/firmware/Kconfig | 2 +-
drivers/firmware/qemu_fw_cfg.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 1db738d5b..4eb8d8a3a 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -186,7 +186,7 @@ config RASPBERRYPI_FIRMWARE

config FW_CFG_SYSFS
tristate "QEMU fw_cfg device support in sysfs"
- depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || SPARC || X86)
+ depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || SPARC || X86 || RISCV)
depends on HAS_IOPORT_MAP
default n
help
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index 172c751a4..36b5b2612 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -225,6 +225,10 @@ static void fw_cfg_io_cleanup(void)
# define FW_CFG_CTRL_OFF 0x00
# define FW_CFG_DATA_OFF 0x01
# define FW_CFG_DMA_OFF 0x04
+# elif defined(CONFIG_RISCV)
+# define FW_CFG_CTRL_OFF 0x08
+# define FW_CFG_DATA_OFF 0x00
+# define FW_CFG_DMA_OFF 0x10
# else
# error "QEMU FW_CFG not available on this architecture!"
# endif
--
2.17.1