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 A841CC19F2C for ; Mon, 1 Aug 2022 10:31:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 01F5B8456E; Mon, 1 Aug 2022 12:31:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=fris.de 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=fris.de header.i=@fris.de header.b="trECR8zE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D2B5684566; Mon, 1 Aug 2022 12:30:55 +0200 (CEST) Received: from mail.fris.de (mail.fris.de [116.203.77.234]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5738C8450E for ; Mon, 1 Aug 2022 12:30:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=fris.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=frieder@fris.de Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 969F4BFB1D; Mon, 1 Aug 2022 12:30:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1659349846; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=WNFjvr9ljk+oLOShbXhf46kpFV/A63CFiqzW7MjjgdE=; b=trECR8zEx/tAencyXbPo58zo30JQjrl7E87FbBv+/P5W5ApgRvE9RCNkAd04hNmJ2GU55w hBdoCEYZ0z4p94rGg+mgiFW3fhqJ/HMeQUKw0c04pdF42GKHVJvrRqZPoM1pFCk/VfZWy1 T7H9IwO7AzqrX833funiZeQbSqDkxSBIUWReitqgMxeE0U5yxY5/cGautmTKa5uBRx6bwo dwATxOmWfH6oqoXepA7GL8+4NbLrAFDmn9zTbkVejTHzru9LTUrDIv2544kwuHlaWbVw7Z rm/X5u1zEZV1zIgVhR2KABW4JuKbcQA8JrZN5peTozD6ViUBVxuPhbgAXHyo6w== From: Frieder Schrempf To: Frieder Schrempf , u-boot@lists.denx.de Cc: Fabio Estevam , Simon Glass , Stefano Babic , Sughosh Ganu Subject: [PATCH v2 07/19] imx: kontron-sl-mx8mm: Enable environment in MMC Date: Mon, 1 Aug 2022 12:30:09 +0200 Message-Id: <20220801103027.96820-8-frieder@fris.de> In-Reply-To: <20220801103027.96820-1-frieder@fris.de> References: <20220801103027.96820-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 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.6 at phobos.denx.de X-Virus-Status: Clean From: Frieder Schrempf In case we boot from SD card or eMMC, we also want to load the environment from the according boot device. Signed-off-by: Frieder Schrempf --- Changes in v2: * none --- board/kontron/sl-mx8mm/sl-mx8mm.c | 31 ++++++++++++++++++++++++++++++ configs/kontron-sl-mx8mm_defconfig | 1 + 2 files changed, 32 insertions(+) diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index fea93278374..416c4cbb407 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -4,10 +4,13 @@ */ #include +#include #include #include +#include #include #include +#include #include #include #include @@ -117,3 +120,31 @@ int board_init(void) { return 0; } + +enum env_location env_get_location(enum env_operation op, int prio) +{ + enum boot_device boot_dev = get_boot_device(); + + if (prio) + return ENVL_UNKNOWN; + + /* + * Make sure that the environment is loaded from + * the MMC if we are running from SD card or eMMC. + */ + if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC) && + (boot_dev == SD1_BOOT || boot_dev == SD2_BOOT)) + return ENVL_MMC; + + if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH)) + return ENVL_SPI_FLASH; + + return ENVL_NOWHERE; +} + +#if defined(CONFIG_ENV_IS_IN_MMC) +int board_mmc_get_env_dev(int devno) +{ + return devno; +} +#endif diff --git a/configs/kontron-sl-mx8mm_defconfig b/configs/kontron-sl-mx8mm_defconfig index 5c1dc754967..842a1a01e1a 100644 --- a/configs/kontron-sl-mx8mm_defconfig +++ b/configs/kontron-sl-mx8mm_defconfig @@ -72,6 +72,7 @@ CONFIG_CMD_REGULATOR=y CONFIG_CMD_EXT4_WRITE=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y +CONFIG_ENV_IS_IN_MMC=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_REDUNDAND_ENVIRONMENT=y CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y -- 2.37.1