From: Anup Patel Date: Thu, 27 Jan 2022 06:11:09 +0000 (+0530) Subject: riscv: qemu: Implement is_flash_available() for MTD NOR X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=ef19131b800806a129df5468aef1d2c5de9b0a89;p=u-boot.git riscv: qemu: Implement is_flash_available() for MTD NOR Currently, if MTD NOR is enabled then U-Boot tries to issue flash commands even when CFI flash DT node is not present. This causes access fault on RISC-V emulators or ISS which do not emulate CFI flash. To handle this issue, we implement is_flash_available() for qemu-riscv board which will return 1 only if CFI flash DT node is present. Fixes: d248627f9d42 ("riscv: qemu: Enable MTD NOR flash support") Signed-off-by: Anup Patel Reviewed-by: Rick Chen Reviewed-by: Bin Meng Tested-by: Bin Meng --- diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index b0d9dd59b1..ae3b7a3295 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -16,6 +17,17 @@ DECLARE_GLOBAL_DATA_PTR; +#if IS_ENABLED(CONFIG_MTD_NOR_FLASH) +int is_flash_available(void) +{ + if (!ofnode_equal(ofnode_by_compatible(ofnode_null(), "cfi-flash"), + ofnode_null())) + return 1; + + return 0; +} +#endif + int board_init(void) { /*