From patchwork Tue Sep 12 20:02:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 112385 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp35992qgf; Tue, 12 Sep 2017 13:03:48 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4cKFGeYHcSsOFrWrseGgc5iZ9+DWo06BqySIIj4Q9P6qiHrCzCj4LJ0lKEPU/6sFZ7uNgV X-Received: by 10.80.190.13 with SMTP id a13mr13271705edi.2.1505246628788; Tue, 12 Sep 2017 13:03:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505246628; cv=none; d=google.com; s=arc-20160816; b=cBdmFFu6izl/VQrvoMDN5vjQFWPt+MZ9SxRT4n9ejubp905mJhO5hspxwLA8LBeKOp gTpJ/0L1oIk6PaS1Ck8gCJAUoC87W5gXUuPezOW4V1WjF23uEoiOqgpOBe4FTjbLPAGC EEFL5c74VKI/+oBAOp+Sm4xEHM/BBnJlgSjl11VepkKofuxjJD+wmEE/OHqQhfFZxkcz bJ4ZRBmn/j4NbiYzpg3K1xsHJWTvpGmB2cWy9cVqnOJjQkbRRuKeCwtW30ZUIOPIqBoL whk/MOKvIfHESDEuIOJnKhkhCi2IiI4b92zTrYS0PzEtxGKF+KUSUfs0Vl76dlhn6CRt xDFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=1EIj89vKZrGTiXZ6nYE8RubClNW5m/a8IWEQAGICJHc=; b=E+QJ3fASsP5iEDIFYqIOQWZCiAwyd9hEI9grb0Fi1c621K8MC6ds3pARNZbPDVHep4 r6mn242eeTPNqL+5kPUQ/xL1US89vygoE1SojAwWprg99ZXQSHu4dluuTiwKm0hP3vvE nBhfgkWw16DVEV72B74MEhwQjdv3+mPFV2nPrNJxOg7uGTXysNgW0zW/R8cEdCFjFNaw LNTt+29hfwV01hcT2zwsLqKEumn6qwtASrX+HfAKoca1qdS7s4MFL92U2fNw4wzy0z7d J8aN1Olk7nJPIA6/ekdUwWboiCUeUk9mw/YEwq6YnUIgia0dnD168x/+wn8gBTqco+hu f5BA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id p8si6465054edh.42.2017.09.12.13.03.48; Tue, 12 Sep 2017 13:03:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 213B5C221E8; Tue, 12 Sep 2017 20:02:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8B1AFC2210B; Tue, 12 Sep 2017 20:02:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DED3FC22080; Tue, 12 Sep 2017 20:02:28 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 6455CC21F97 for ; Tue, 12 Sep 2017 20:02:28 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 3613820846; Tue, 12 Sep 2017 22:02:28 +0200 (CEST) Received: from localhost (LFbn-TOU-1-209-191.w86-201.abo.wanadoo.fr [86.201.56.191]) by mail.free-electrons.com (Postfix) with ESMTPSA id 0BE2320834; Tue, 12 Sep 2017 22:02:28 +0200 (CEST) From: Maxime Ripard To: Tom Rini Date: Tue, 12 Sep 2017 22:02:22 +0200 Message-Id: <7c8317f3ea8169b31efb21440441eac5875a9f37.1505246502.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: References: In-Reply-To: References: Cc: u-boot@lists.denx.de, Jagan Teki , Maxime Ripard Subject: [U-Boot] [PATCH v2 1/3] arm: sunxi: Move spl_boot_device in a separate function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" U-Boot itself might need to identify the boot device, for example to be able to tell where to load the kernel from when several options are possible. Move the logic of spl_boot_device to a function that is compiled both for the SPL and the main binary. Tested-by: Chen-Yu Tsai Signed-off-by: Maxime Ripard --- arch/arm/include/asm/arch-sunxi/spl.h | 2 ++ arch/arm/mach-sunxi/board.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/arch-sunxi/spl.h b/arch/arm/include/asm/arch-sunxi/spl.h index 9358397da27a..a70b1797e5d7 100644 --- a/arch/arm/include/asm/arch-sunxi/spl.h +++ b/arch/arm/include/asm/arch-sunxi/spl.h @@ -78,4 +78,6 @@ typedef char boot_file_head_not_multiple_of_32[1 - 2*(sizeof(struct boot_file_he #define is_boot0_magic(addr) (memcmp((void *)addr, BOOT0_MAGIC, 8) == 0) +uint32_t sunxi_get_boot_device(void); + #endif diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c index 65b1ebd83787..0c60ee04da54 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -14,9 +14,7 @@ #include #include #include -#ifdef CONFIG_SPL_BUILD #include -#endif #include #include #include @@ -212,11 +210,12 @@ void s_init(void) #ifdef CONFIG_SPL_BUILD DECLARE_GLOBAL_DATA_PTR; +#endif /* The sunxi internal brom will try to loader external bootloader * from mmc0, nand flash, mmc2. */ -u32 spl_boot_device(void) +uint32_t sunxi_get_boot_device(void) { int boot_source; @@ -255,6 +254,12 @@ u32 spl_boot_device(void) return -1; /* Never reached */ } +#ifdef CONFIG_SPL_BUILD +u32 spl_boot_device(void) +{ + return sunxi_get_boot_device(); +} + /* No confirmation data available in SPL yet. Hardcode bootmode */ u32 spl_boot_mode(const u32 boot_device) { From patchwork Tue Sep 12 20:02:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 112387 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp37353qgf; Tue, 12 Sep 2017 13:05:01 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5ZGNkRt2V05LOP9cVQxrEWZhR+IItrb393wrFw5Wqhl5TPT2KtAEIllKq/EMlDORxhOl5h X-Received: by 10.80.146.35 with SMTP id i32mr9727009eda.10.1505246701288; Tue, 12 Sep 2017 13:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505246701; cv=none; d=google.com; s=arc-20160816; b=h910JaSOj1UE6ZWvfIYB8DI0WlYlIqDOxm8HrJOUG9MNGMW730cUMVnHNOMfIwnofw OgP0LI8WCSgk/EcS0xiS5GS4qPkATGhRYBZvribpC1XTy4bB6HsAyVROvS4UjtDtrLd3 5iOFJkwlC1VPR06DzNFQrRJf53hs3OR/whEdEGlYnS15yUGgLQtzzMUrCE3tc1zTAN+W mcdzvp1M81xYRWHTV0+tb1ANx9ca7M7Mxs+RsDoyXKSAyMx1ZFbcGjPyLjgVql4ThHRU h1q6QIn30OkS3MPsDmOWJ9kLe555G0w0e71aQzfGsrr/qUqfaWA5GgbZZF0JjZIBaDLt kNzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=Z3Uz5omP6zSB2vYp6SGohRO4kKA5XVsJYTzbLPUWTyw=; b=sdfEwAz/5fMnGG+KQTcKTeZhWBhE6+YTuimJ0jy61hj/yhbIMuoBeQ2+4ZiS7nJ9tE fsNf8hVvp2lkucDSqsfLGkz055fMuTnymPdqxHJz2wIQ41eqxT9vdURhzvEylNrkThJg aFM+l0cNwHOmigQde9XCw/1OghB8uEeRHjud3jVs6gPTdCjq7owcjwiWRXaDGSC94Ajp 84E68pFVYbH0dnGPoKAvuobv5RAhU6DNK4u4G9l8HBlGxIzjPz5E59QbQeFPy136Z1Ms xq0QSRDxG0MVksNPKFENW9fOWVXwQlnrG7rLY150d3xqhaTEAQXDDsHs/54R5F5xXMJA XreQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id f13si12373927edl.233.2017.09.12.13.05.00; Tue, 12 Sep 2017 13:05:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 4353EC2222D; Tue, 12 Sep 2017 20:03:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 91F6FC22194; Tue, 12 Sep 2017 20:02:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 00779C22159; Tue, 12 Sep 2017 20:02:30 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id BBEEBC21FDC for ; Tue, 12 Sep 2017 20:02:28 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 8AD9A20848; Tue, 12 Sep 2017 22:02:28 +0200 (CEST) Received: from localhost (LFbn-TOU-1-209-191.w86-201.abo.wanadoo.fr [86.201.56.191]) by mail.free-electrons.com (Postfix) with ESMTPSA id 628BA20834; Tue, 12 Sep 2017 22:02:28 +0200 (CEST) From: Maxime Ripard To: Tom Rini Date: Tue, 12 Sep 2017 22:02:23 +0200 Message-Id: X-Mailer: git-send-email 2.13.5 In-Reply-To: References: In-Reply-To: References: Cc: u-boot@lists.denx.de, Jagan Teki , Maxime Ripard Subject: [U-Boot] [PATCH v2 2/3] sunxi: Use sunxi_get_boot_device X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Our current board code duplicates a bit the sunxi_get_boot_device logic. Now that we can use that function in the full-flavoured U-Boot, remove that duplication and call the function instead. Signed-off-by: Maxime Ripard --- board/sunxi/board.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 70e01437c4f4..9c7fc4168894 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -720,11 +721,14 @@ static void setup_environment(const void *fdt) int misc_init_r(void) { __maybe_unused int ret; + uint boot; env_set("fel_booted", NULL); env_set("fel_scriptaddr", NULL); + + boot = sunxi_get_boot_device(); /* determine if we are running in FEL mode */ - if (!is_boot0_magic(SPL_ADDR + 4)) { /* eGON.BT0 */ + if (boot == BOOT_DEVICE_BOARD) { env_set("fel_booted", "1"); parse_spl_header(SPL_ADDR); } From patchwork Tue Sep 12 20:02:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 112386 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp37083qgf; Tue, 12 Sep 2017 13:04:46 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4HOj1L8DMWbz9TJ28ywt1PFO3ILrbOd+IoNsTXrFGSudbyLI9ElbvnwFKuIXybWyhqx1kT X-Received: by 10.80.201.202 with SMTP id c10mr13502891edi.60.1505246685968; Tue, 12 Sep 2017 13:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505246685; cv=none; d=google.com; s=arc-20160816; b=xqKhQFqwklah6X6sTE3uIbtyHEm1+qo5Ouv1aR/P1qGk9873lK+Xm1cgA2C/sxzc+w M0DkaNf82mlpnadzGLIxKTkpXKXR5QaCVGg3kdOKmOVg78vdrmW3kGmlpAz3De+2Up0s ACn1aSpmxafpXlUqpjp7Niz2WNwkgVLvZFWX29FnRy6SgqUB+hITWbT86c2S4e9B4KO0 pNsrp7z1VMwOjPuw5EEg9Fa6eQLo/ApADiDrhSQL2B0A4O8WFJzRPyj4G5rs91d6LYUQ PkReOfnZSHYfe5gNk66/SSDrKPYhzESp0lBIs91ajMGpugTM+Y9PAezxwX3cS7HNFxw3 Drxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=GW1D8uSkZGRebiZj5E/p3i2Y2wWmVmGnjkFGs/RnsSk=; b=l+mM3796zIE9+7UYmMIQkS+hMfUFmrWOAGLP39FmPilalxE/UJty+XMse3VL7ALLMV kySx5SS0N8sATn4TrE9bNLVMY/FmDMraU+/Ho8dMKBBY8Fbv8YgBsg/EfyHr83lds1g3 Mcix8Qt8erLUodExIk3iEm3SEX32PYiH4wQq+Bm9n5700g/jkw7zLbHA4gtSXJ3QiQaW brxKfsXA/ZoZeyQpVGIwzVjW2q7iffDdsDbPflOZ1KO5s0K+i0hgK19saq3UIpRxcQmp sUUPuwJyzLL1ZaE1M3EjnfFZQnpiWLMraHteh5TOzmf/4sgyGg9qBa5XjuCps/4wDWex ex8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id z94si11407949ede.320.2017.09.12.13.04.45; Tue, 12 Sep 2017 13:04:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 897E4C221EF; Tue, 12 Sep 2017 20:03:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A6740C2216F; Tue, 12 Sep 2017 20:02:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 873EEC221D3; Tue, 12 Sep 2017 20:02:32 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 2BFCBC220AA for ; Tue, 12 Sep 2017 20:02:29 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id EE8372088C; Tue, 12 Sep 2017 22:02:28 +0200 (CEST) Received: from localhost (LFbn-TOU-1-209-191.w86-201.abo.wanadoo.fr [86.201.56.191]) by mail.free-electrons.com (Postfix) with ESMTPSA id BF14A20834; Tue, 12 Sep 2017 22:02:28 +0200 (CEST) From: Maxime Ripard To: Tom Rini Date: Tue, 12 Sep 2017 22:02:24 +0200 Message-Id: <461cff59c468322dbd930d6dc871d4da4f42cd58.1505246502.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: References: In-Reply-To: References: Cc: u-boot@lists.denx.de, Jagan Teki , Maxime Ripard Subject: [U-Boot] [PATCH v2 3/3] sunxi: Remove the MMC index hack X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The current code, if there's both an eMMC and an MMC slot available on the board, will swap the MMC indices based on whether we booted from the eMMC or the MMC. This way, the MMC we're supposed to boot on will always have the index 0. However, this causes various issues, for example when using other components that base their behaviour on the MMC index, such as fastboot. Let's remove that hack, and take the opposite approach. The MMC will always have the same index, but the bootcmd will pick the same device than the one we booted from. This is done through the introduction of the mmc_bootdev environment variable that will be filled by the board code based on the boot device informations we can get from the SoC. In order to not introduce regressions, we also need to adjust the fastboot MMC device and the environment device in order to set it to the eMMC, over the MMC, like it used to be the case. Tested-by: Chen-Yu Tsai Signed-off-by: Maxime Ripard --- board/sunxi/board.c | 20 ++++----------- cmd/fastboot/Kconfig | 2 ++- configs/A20-OLinuXino-Lime2-eMMC_defconfig | 1 +- configs/Sinlinx_SinA33_defconfig | 1 +- configs/parrot_r16_defconfig | 1 +- include/configs/sunxi-common.h | 30 ++++++++++++++++++----- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 9c7fc4168894..feb8d7490d8b 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -492,20 +492,6 @@ int board_mmc_init(bd_t *bis) return -1; #endif -#if !defined(CONFIG_SPL_BUILD) && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2 - /* - * On systems with an emmc (mmc2), figure out if we are booting from - * the emmc and if we are make it "mmc dev 0" so that boot.scr, etc. - * are searched there first. Note we only do this for u-boot proper, - * not for the SPL, see spl_boot_device(). - */ - if (readb(SPL_ADDR + 0x28) == SUNXI_BOOTED_FROM_MMC2) { - /* Booting from emmc / mmc2, swap */ - mmc0->block_dev.devnum = 1; - mmc1->block_dev.devnum = 0; - } -#endif - return 0; } #endif @@ -725,12 +711,18 @@ int misc_init_r(void) env_set("fel_booted", NULL); env_set("fel_scriptaddr", NULL); + env_set("mmc_bootdev", NULL); boot = sunxi_get_boot_device(); /* determine if we are running in FEL mode */ if (boot == BOOT_DEVICE_BOARD) { env_set("fel_booted", "1"); parse_spl_header(SPL_ADDR); + /* or if we booted from MMC, and which one */ + } else if (boot == BOOT_DEVICE_MMC1) { + env_set("mmc_bootdev", "0"); + } else if (boot == BOOT_DEVICE_MMC2) { + env_set("mmc_bootdev", "1"); } setup_environment(gd->fdt_blob); diff --git a/cmd/fastboot/Kconfig b/cmd/fastboot/Kconfig index fb0c5da94cdb..6baea8974690 100644 --- a/cmd/fastboot/Kconfig +++ b/cmd/fastboot/Kconfig @@ -69,6 +69,8 @@ config FASTBOOT_FLASH config FASTBOOT_FLASH_MMC_DEV int "Define FASTBOOT MMC FLASH default device" depends on FASTBOOT_FLASH && MMC + default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 + default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 help The fastboot "flash" command requires additional information regarding the non-volatile storage device. Define this to diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig index 58aa988b2363..caaa0b9a0d88 100644 --- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig +++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig @@ -14,7 +14,6 @@ CONFIG_AHCI=y CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 # CONFIG_CMD_IMLS is not set CONFIG_CMD_DFU=y # CONFIG_CMD_FLASH is not set diff --git a/configs/Sinlinx_SinA33_defconfig b/configs/Sinlinx_SinA33_defconfig index af00e5434763..471c843e5dcf 100644 --- a/configs/Sinlinx_SinA33_defconfig +++ b/configs/Sinlinx_SinA33_defconfig @@ -15,7 +15,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-a33-sinlinx-sina33" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set CONFIG_SPL=y CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 # CONFIG_CMD_IMLS is not set CONFIG_CMD_DFU=y # CONFIG_CMD_FLASH is not set diff --git a/configs/parrot_r16_defconfig b/configs/parrot_r16_defconfig index 53825eba33c3..c63e7f259f35 100644 --- a/configs/parrot_r16_defconfig +++ b/configs/parrot_r16_defconfig @@ -13,7 +13,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-r16-parrot" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set CONFIG_SPL=y CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set # CONFIG_CMD_FPGA is not set diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 02d7be08495d..91751171ec2b 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -148,7 +148,13 @@ #endif #if defined(CONFIG_ENV_IS_IN_MMC) -#define CONFIG_SYS_MMC_ENV_DEV 0 /* first detected MMC controller */ +#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1 +/* If we have two devices (most likely eMMC + MMC), favour the eMMC */ +#define CONFIG_SYS_MMC_ENV_DEV 1 +#else +/* Otherwise, use the only device we have */ +#define CONFIG_SYS_MMC_ENV_DEV 0 +#endif #define CONFIG_SYS_MMC_MAX_DEVICE 4 #elif defined(CONFIG_ENV_IS_NOWHERE) #define CONFIG_ENV_SIZE (128 << 10) @@ -382,15 +388,28 @@ extern int soft_i2c_gpio_scl; "ramdisk ram " RAMDISK_ADDR_R " 0x4000000\0" #ifdef CONFIG_MMC -#define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) #if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1 -#define BOOT_TARGET_DEVICES_MMC_EXTRA(func) func(MMC, mmc, 1) +#define BOOTENV_DEV_MMC_AUTO(devtypeu, devtypel, instance) \ + BOOTENV_DEV_MMC(MMC, mmc, 0) \ + BOOTENV_DEV_MMC(MMC, mmc, 1) \ + "bootcmd_mmc_auto=" \ + "if test ${mmc_bootdev} -eq 1; then " \ + "run bootcmd_mmc1; " \ + "run bootcmd_mmc0; " \ + "elif test ${mmc_bootdev} -eq 0; then " \ + "run bootcmd_mmc0; " \ + "run bootcmd_mmc1; " \ + "fi\0" + +#define BOOTENV_DEV_NAME_MMC_AUTO(devtypeu, devtypel, instance) \ + "mmc_auto " + +#define BOOT_TARGET_DEVICES_MMC(func) func(MMC_AUTO, mmc_auto, na) #else -#define BOOT_TARGET_DEVICES_MMC_EXTRA(func) +#define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) #endif #else #define BOOT_TARGET_DEVICES_MMC(func) -#define BOOT_TARGET_DEVICES_MMC_EXTRA(func) #endif #ifdef CONFIG_AHCI @@ -418,7 +437,6 @@ extern int soft_i2c_gpio_scl; #define BOOT_TARGET_DEVICES(func) \ func(FEL, fel, na) \ BOOT_TARGET_DEVICES_MMC(func) \ - BOOT_TARGET_DEVICES_MMC_EXTRA(func) \ BOOT_TARGET_DEVICES_SCSI(func) \ BOOT_TARGET_DEVICES_USB(func) \ func(PXE, pxe, na) \