From patchwork Wed Oct 28 09:23:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryanov X-Patchwork-Id: 537280 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 24A40140DAE for ; Wed, 28 Oct 2015 20:25:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=compulab.co.il header.i=@compulab.co.il header.b=rQRSOb9F; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 34BCE4B705; Wed, 28 Oct 2015 10:25:28 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NBBbGMrsTO27; Wed, 28 Oct 2015 10:25:28 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1D20C4B719; Wed, 28 Oct 2015 10:24:18 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C7804B656 for ; Wed, 28 Oct 2015 10:23:43 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UAuKPSAOC0Ok for ; Wed, 28 Oct 2015 10:23:43 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from compulab.co.il (softlayer.compulab.co.il [50.23.254.55]) by theia.denx.de (Postfix) with ESMTPS id 5DA664B632 for ; Wed, 28 Oct 2015 10:23:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=compulab.co.il; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From; bh=c68LiVCtweBmh3OZOScDMd9cxxyDrEdw5fQorDn5J8U=; b=rQRSOb9Fchdmk 0nwIAfiVbzyXMl0dllNfmNPexOPNn6tkwnntmWMRuTrlM/4Cid0CllRzh8s69MhIHh799zgTJN4hm ohVWLhv8KB0E6PvfuHyMzA71g4bBsre389LdxGZfVX7yYULoaTA87rKLgZ/Qwv67Thv1DWUHr6gXx j+Os=; Received: from [62.90.235.247] (port=34873 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.86) (envelope-from ) id 1ZrMxE-0006Sx-Sc; Wed, 28 Oct 2015 11:23:37 +0200 Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 82834487004; Wed, 28 Oct 2015 11:23:36 +0200 (IST) Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Q98EsD2OAsf5; Wed, 28 Oct 2015 11:23:36 +0200 (IST) Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id B3F7048700E; Wed, 28 Oct 2015 11:23:34 +0200 (IST) X-Virus-Scanned: amavisd-new at zimbra-mta.compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id uCxgb-YGVGZR; Wed, 28 Oct 2015 11:23:34 +0200 (IST) Received: from skynet.compulab.local (nikita-pc.compulab.local [192.168.11.211]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 80FA0487002; Wed, 28 Oct 2015 11:23:34 +0200 (IST) From: Nikita Kiryanov To: u-boot@lists.denx.de Date: Wed, 28 Oct 2015 11:23:30 +0200 Message-Id: <1446024210-16517-14-git-send-email-nikita@compulab.co.il> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446024210-16517-1-git-send-email-nikita@compulab.co.il> References: <1446024210-16517-1-git-send-email-nikita@compulab.co.il> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il X-Get-Message-Sender-Via: softlayer.compulab.co.il: acl_c_recent_authed_mail_ips_text_entry: nikita@compulab.co.il|compulab.co.il X-Authenticated-Sender: softlayer.compulab.co.il: nikita@compulab.co.il Cc: Ian Campbell , Tom Rini Subject: [U-Boot] [PATCH V2 13/13] spl: mmc: add support for BOOT_DEVICE_MMC2 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" Currently the mmc device that SPL looks at is always mmc0, regardless of the BOOT_DEVICE_MMCx value. This forces some boards to implement hacks in order to boot from other mmc devices. Make SPL take into account the correct mmc device. Signed-off-by: Nikita Kiryanov Cc: Hans De Goede Cc: Tom Rini Cc: Ian Campbell Reviewed-by: Tom Rini --- Changes in V2: - New patch. arch/arm/cpu/armv7/sunxi/board.c | 10 +--------- common/spl/spl.c | 2 +- common/spl/spl_mmc.c | 41 ++++++++++++++++++++++++++++++++-------- include/spl.h | 2 +- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c index 9b5c46b..794b829 100644 --- a/arch/arm/cpu/armv7/sunxi/board.c +++ b/arch/arm/cpu/armv7/sunxi/board.c @@ -173,16 +173,8 @@ u32 spl_boot_device(void) #ifdef CONFIG_MMC if (CONFIG_MMC_SUNXI_SLOT_EXTRA == 2) { mmc1 = find_mmc_device(1); - if (sunxi_mmc_has_egon_boot_signature(mmc1)) { - /* - * spl_mmc.c: spl_mmc_load_image() is hard-coded to - * use find_mmc_device(0), no matter what we - * return. Swap mmc0 and mmc2 to make this work. - */ - mmc0->block_dev.dev = 1; - mmc1->block_dev.dev = 0; + if (sunxi_mmc_has_egon_boot_signature(mmc1)) return BOOT_DEVICE_MMC2; - } } #endif diff --git a/common/spl/spl.c b/common/spl/spl.c index ee30290..189c8f7 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -291,7 +291,7 @@ static int spl_load_image(u32 boot_device) case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2: case BOOT_DEVICE_MMC2_2: - return spl_mmc_load_image(); + return spl_mmc_load_image(boot_device); #endif #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND: diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index ab9ec88..2f7e7aa 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -61,11 +61,32 @@ end: return 0; } +int spl_mmc_get_device_index(u32 boot_device) +{ + switch (boot_device) { + case BOOT_DEVICE_MMC1: + return 0; + case BOOT_DEVICE_MMC2: + case BOOT_DEVICE_MMC2_2: + return 1; + } + +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT + printf("spl: unsupported mmc boot device.\n"); +#endif + + return -ENODEV; +} + #ifdef CONFIG_DM_MMC -static int spl_mmc_find_device(struct mmc **mmc) +static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device) { struct udevice *dev; - int err; + int err, mmc_dev; + + mmc_dev = spl_mmc_get_device_index(boot_device); + if (mmc_dev < 0) + return mmc_dev; err = mmc_initialize(NULL); if (err) { @@ -75,7 +96,7 @@ static int spl_mmc_find_device(struct mmc **mmc) return err; } - err = uclass_get_device(UCLASS_MMC, 0, &dev); + err = uclass_get_device(UCLASS_MMC, mmc_dev, &dev); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT puts("spl: could not find mmc device. error: %d\n", err); @@ -88,9 +109,13 @@ static int spl_mmc_find_device(struct mmc **mmc) return *mmc != NULL ? 0 : -ENODEV; } #else -static int spl_mmc_find_device(struct mmc **mmc) +static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device) { - int err; + int err, mmc_dev; + + mmc_dev = spl_mmc_get_device_index(boot_device); + if (mmc_dev < 0) + return mmc_dev; err = mmc_initialize(gd->bd); if (err) { @@ -101,7 +126,7 @@ static int spl_mmc_find_device(struct mmc **mmc) } /* We register only one device. So, the dev id is always 0 */ - *mmc = find_mmc_device(0); + *mmc = find_mmc_device(mmc_dev); if (!*mmc) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT puts("spl: mmc device not found\n"); @@ -221,14 +246,14 @@ int spl_mmc_do_fs_boot(struct mmc *mmc) } #endif -int spl_mmc_load_image(void) +int spl_mmc_load_image(u32 boot_device) { struct mmc *mmc; u32 boot_mode; int err = 0; __maybe_unused int part; - err = spl_mmc_find_device(&mmc); + err = spl_mmc_find_device(&mmc, boot_device); if (err) return err; diff --git a/include/spl.h b/include/spl.h index 46fc454..92cdc04 100644 --- a/include/spl.h +++ b/include/spl.h @@ -54,7 +54,7 @@ int spl_onenand_load_image(void); int spl_nor_load_image(void); /* MMC SPL functions */ -int spl_mmc_load_image(void); +int spl_mmc_load_image(u32 boot_device); /* YMODEM SPL functions */ int spl_ymodem_load_image(void);