From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9AB0C433EF for ; Fri, 14 Jan 2022 16:49:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A04A834CB; Fri, 14 Jan 2022 17:48:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="Mno99e9B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A81D083420; Fri, 14 Jan 2022 17:20:34 +0100 (CET) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9FD12833C2 for ; Fri, 14 Jan 2022 17:20:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=apatel@ventanamicro.com Received: by mail-wm1-x329.google.com with SMTP id l4so7117430wmq.3 for ; Fri, 14 Jan 2022 08:20:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6VAhhBgi2PF00ENVFs0/fa62lJu8c4oO4piR7a0YjQ8=; b=Mno99e9BlFnz0Zv5PzF9YMp/d2teJykDLLhQ+PtKSQkaPPoUd1a+vwro9z4K9ieiCx EyzzWSLaKtOkNDgpw9sdnrEbleYx8FFN1ObTQ+M6Adct4QrqyRv7D9xlLdA/nkOcySgp XLUlt1nhJuPkQ/mNgENRIvmmKPIDZCCS10h8GV3I+P0/rWdMp+k6DvQ1ykb61SAApYBJ f+kvWldCmw17K+k816fBldRsEq3xs0Nbm4M8HG+GkDmxecYpF0saoUOUwc0q6NqzcYoc j2s8JUDQ6jZE7sxSXxFR/Bd3Cp+CAFlYBsNOsiNcsFjoRvzn6W60Vfw+gTbykGvkrAKB D82A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6VAhhBgi2PF00ENVFs0/fa62lJu8c4oO4piR7a0YjQ8=; b=pE8rGToMmARvwFrKzcOhHGb/n9ED0QECym1NXtY9wGjWWSk9kV7GAvHvBS31COaDxo BLgCNveS3Os+HC1eFnnGTqbJQfFL/o0Y8i198pRPmQ9fo5gKinGXsT5vzhfmSm6XntZE TONC2U5avSjpUBiVpQS714EjI1uCBPUXO2C+nKCUgviqvh2IVqSSzs8h3I9uQ3NvmIqN Z5bUN81zEevDVqeIzeUNt9fLDjP8oFqB2uLR8aHMOgplpkRc6Y3aHK5QkCMfQJzTgXVZ uNcwC0I5YDD5/Kxejp9X4qjxbj+lyjfswnVF+1j8+NY7x1VznurbV6R9zI4tuEOkmONi imtw== X-Gm-Message-State: AOAM532peeWVwvpW6PVzTWIoKGMam+otleKoVCkwxPgidvBoVacOZrWm ps+tytsuzbBr1IevWRRjR/UBy8wqv6rJWg== X-Google-Smtp-Source: ABdhPJyCoAHxgbQ1WCk3SgC4Q02IbteqsWPsd+c9W+7j9qpX6Da2GO36hNLktlcA7BFPGlhC016dBQ== X-Received: by 2002:a1c:1fc4:: with SMTP id f187mr16336290wmf.41.1642177231215; Fri, 14 Jan 2022 08:20:31 -0800 (PST) Received: from localhost.localdomain ([122.179.78.147]) by smtp.gmail.com with ESMTPSA id bi24sm10797930wmb.9.2022.01.14.08.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 08:20:30 -0800 (PST) From: Anup Patel To: Rick Chen , Bin Meng Cc: Atish Patra , Alistair Francis , Anup Patel , U-Boot Mailing List , Anup Patel Subject: [PATCH 3/3] riscv: qemu: Implement is_flash_available() for MTD NOR Date: Fri, 14 Jan 2022 21:50:08 +0530 Message-Id: <20220114162008.70468-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220114162008.70468-1-apatel@ventanamicro.com> References: <20220114162008.70468-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 14 Jan 2022 17:48:29 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 --- board/emulation/qemu-riscv/qemu-riscv.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index b0d9dd59b1..cd02dae1ab 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,22 @@ DECLARE_GLOBAL_DATA_PTR; +#if IS_ENABLED(CONFIG_MTD_NOR_FLASH) +int is_flash_available(void) +{ + if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) { + const void *fdt = + (const void *)(uintptr_t)gd->arch.firmware_fdt_addr; + int rc = fdt_node_offset_by_compatible(fdt, -1, "cfi-flash"); + + if (rc >= 0) + return 1; + } + + return 0; +} +#endif + int board_init(void) { /* -- 2.25.1