From patchwork Fri Jan 14 16:20:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1580204 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=Mno99e9B; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jb6hM2JJSz9sXM for ; Sat, 15 Jan 2022 03:49:07 +1100 (AEDT) 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) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 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 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 Reviewed-by: Rick Chen --- 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) { /*