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 088A3C433F5 for ; Thu, 27 Jan 2022 06:12:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E4B008312A; Thu, 27 Jan 2022 07:11:55 +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="E5/VpTSX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 83CB983107; Thu, 27 Jan 2022 07:11:52 +0100 (CET) Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 8942F81432 for ; Thu, 27 Jan 2022 07:11:49 +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-pj1-x102b.google.com with SMTP id d12-20020a17090a628c00b001b4f47e2f51so6534257pjj.3 for ; Wed, 26 Jan 2022 22:11:49 -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=D0JwdZixEciTCeNb4BcQ8vLfh9+Sd0YLuA+s6c43Flk=; b=E5/VpTSXA4TQxPZg+dzMSThxO/0j5KKk1+c8eyTTR2uh/lN1WQfDKCOO9NB+ZT0Vyj /KGC8TDMjTabzE01Km9mP7uCLSmfMQYp+s6K9dR4EVEopK/cjVH/fhKtFZve9f4ObZt/ 4OwylMknQssyCWn/6zUOFulKQ2QBf36f5J0QH0f83D+3eyLY5NRJ16nDgVamh/TGOVhS /ltj7fkpg+ShGWNL/jAN0k+o0kdly3ydU2vyTML5ec1bKeIrgBO/6MUE3aseCVySkdmc DhnRnfQuUiaSWOlTRTe2RZnThBvf8VJT/msXiOZRfZTt7X8oDxdw3pNoFDsA9uzVkZTq 4xgg== 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=D0JwdZixEciTCeNb4BcQ8vLfh9+Sd0YLuA+s6c43Flk=; b=BdJOip6WZhidqpDMjH8XIFScnvZLverYH8gUbxePELgM7CHV+Ca9LEp2bHrKXlkF0S ePVmc6l9DknaMRlWDOD/A4k5UWyEPlpA7nu022i1rVvQTDljaZXgePDkUMxrNpKbsn2e tUs9q/VAc5+DaszTHvFPe8cZbDjuUKvRnnrJuZ4rd/ol1ijc4ITUzbf4dwLZIY5W6Bgi 9ZQjY0lepDbnh3XH49sHCuYHfZ4SQc8sBMo2Ev76SZReks+3s6oSNBsCZwYt4rZ7IAiA /H08pUB7nVN9tT3kDzzhSBTCQVrRKyB/pK7SZL5QRTNDYf7s0nsC0odKJju4E9txWq3r Lc2A== X-Gm-Message-State: AOAM530FhkqtUe2Q+Dn26Q6YZggE4pkKjTWKMGmYmJdtFiIO5+IZ7+gz fMi0v/ac8Li5QuNV9udTKbY2jA== X-Google-Smtp-Source: ABdhPJzh0d3kkH7F66Bgd4MkxvBsO0KZZQDNPizF5h1nsvePc0c67TLFBdUPySTLrbRqPR+we1bSrQ== X-Received: by 2002:a17:90b:4a47:: with SMTP id lb7mr12242793pjb.55.1643263908063; Wed, 26 Jan 2022 22:11:48 -0800 (PST) Received: from localhost.localdomain ([171.61.74.240]) by smtp.gmail.com with ESMTPSA id j4sm4732441pjv.46.2022.01.26.22.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 22:11:47 -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 v2 3/4] riscv: qemu: Implement is_flash_available() for MTD NOR Date: Thu, 27 Jan 2022 11:41:09 +0530 Message-Id: <20220127061110.721103-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127061110.721103-1-apatel@ventanamicro.com> References: <20220127061110.721103-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.5 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) { /* -- 2.25.1