From patchwork Tue Jan 10 23:10:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 713479 X-Patchwork-Delegate: sbabic@denx.de 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 3tynnw72PPz9sBR for ; Wed, 11 Jan 2017 10:11:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 84EB3B38C5; Wed, 11 Jan 2017 00:11:13 +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 v06aQm5bLVll; Wed, 11 Jan 2017 00:11:13 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D598BB38C7; Wed, 11 Jan 2017 00:11:10 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4B7F5A75EE for ; Wed, 11 Jan 2017 00:11:04 +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 DzmptwJaOKsq for ; Wed, 11 Jan 2017 00:11:04 +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 mail-wj0-f193.google.com (mail-wj0-f193.google.com [209.85.210.193]) by theia.denx.de (Postfix) with ESMTPS id 1674AA75E9 for ; Wed, 11 Jan 2017 00:11:01 +0100 (CET) Received: by mail-wj0-f193.google.com with SMTP id dh1so8659694wjb.3 for ; Tue, 10 Jan 2017 15:11:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jx2Lnoe2d856u7eD6mr7XjF3qAKKgZH1amHSw6Bz0IM=; b=HJyPHcLm1W1dkgwX2BPjQK2CpYIev3EbuSgYDo1sBr4njP+uzLnaY0ynBnnkQ0IED1 W6BO7+HGRTijxwf5eBHe9Jw8uLiElzk+DLPBbDzY3AeQczMt6h8PXKlVEpX3LoTrrrYq K+hP9AcbrDzBdrBZe7QvPanZ9bu8gKZy0lQXOPLQLQo81stm3l0q+mNNAp6YelrpQgCm uooYoKofDTLvp4QsqcT3qlCp1wuM2bNmJCTVqHxHNcPhjYgkm3NDhT8Ptuze6t55Wdcc arIREKGc4fHz8NvSFyOSLQR17wGDtPOof9kIYBimnhx5qL0jSLG0QpZPW9FwjsfEqvhn tSGQ== X-Gm-Message-State: AIkVDXJI2LNvKIDRIA/k+1AfEwpVIh247L5Mx7uGSE8BAPpLzc9lHJxNQPsvNSclRbAQnQ== X-Received: by 10.194.87.103 with SMTP id w7mr3057419wjz.164.1484089860814; Tue, 10 Jan 2017 15:11:00 -0800 (PST) Received: from jagan-XPS-13-9350.lavanda.local ([212.24.144.58]) by smtp.gmail.com with ESMTPSA id ei2sm5447373wjd.47.2017.01.10.15.10.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Jan 2017 15:10:59 -0800 (PST) From: Jagan Teki To: Stefano Babic Date: Wed, 11 Jan 2017 00:10:18 +0100 Message-Id: <1484089820-6987-3-git-send-email-jagan@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484089820-6987-1-git-send-email-jagan@openedev.com> References: <1484089820-6987-1-git-send-email-jagan@openedev.com> Cc: u-boot@lists.denx.de, Jagan Teki , Matteo Lisi Subject: [U-Boot] [PATCH 2/4] imx6: Add imx6_src_get_boot_mode 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" For i.MX6, the bootmode determine code is part of spl_boot_device, but there is might be a possibility for other part the code need to check the desired boot mode for adding new functionalities like modeboot env variable, or changing boot order etc. So introduced imx6_src_get_boot_mode which actually reading the boot mode register for desired modes. More cleanup will be add in future patches. Cc: Stefano Babic Cc: Matteo Lisi Cc: Michael Trimarchi Signed-off-by: Jagan Teki --- arch/arm/imx-common/init.c | 22 ++++++++++++++++++++++ arch/arm/imx-common/spl.c | 6 +++--- arch/arm/include/asm/arch-mx6/sys_proto.h | 5 +++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/arch/arm/imx-common/init.c b/arch/arm/imx-common/init.c index e5dbd93..986c0d0 100644 --- a/arch/arm/imx-common/init.c +++ b/arch/arm/imx-common/init.c @@ -115,3 +115,25 @@ void boot_mode_apply(unsigned cfg_val) writel(reg, &psrc->gpr10); } #endif + +#if defined(CONFIG_MX6) +bool inline is_boot_device_from_gpr9(void) +{ + struct src *psrc = (struct src *)SRC_BASE_ADDR; + bool val; + + val = readl(&psrc->gpr10) & IMX6_SRC_GPR10_BMODE; + + return val; +} + +u32 imx6_src_get_boot_mode(void) +{ + struct src *psrc = (struct src *)SRC_BASE_ADDR; + + if (is_boot_device_from_gpr9()) + return readl(&psrc->gpr9); + else + return readl(&psrc->sbmr1); +} +#endif diff --git a/arch/arm/imx-common/spl.c b/arch/arm/imx-common/spl.c index c86b6f8..950c70d 100644 --- a/arch/arm/imx-common/spl.c +++ b/arch/arm/imx-common/spl.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -19,16 +20,15 @@ u32 spl_boot_device(void) { struct src *psrc = (struct src *)SRC_BASE_ADDR; - unsigned int gpr10_boot = readl(&psrc->gpr10) & (1 << 28); - unsigned reg = gpr10_boot ? readl(&psrc->gpr9) : readl(&psrc->sbmr1); unsigned int bmode = readl(&psrc->sbmr2); + u32 reg = imx6_src_get_boot_mode(); /* * Check for BMODE if serial downloader is enabled * BOOT_MODE - see IMX6DQRM Table 8-1 */ if ((((bmode >> 24) & 0x03) == 0x01) || /* Serial Downloader */ - (gpr10_boot && (reg == 1))) + (is_boot_device_from_gpr9() && (reg == 1))) return BOOT_DEVICE_UART; /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */ switch ((reg & 0x000000FF) >> 4) { diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h index 16c9b76..868f668 100644 --- a/arch/arm/include/asm/arch-mx6/sys_proto.h +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h @@ -6,3 +6,8 @@ */ #include + +#define IMX6_SRC_GPR10_BMODE BIT(28) + +bool is_boot_device_from_gpr9(void); +u32 imx6_src_get_boot_mode(void);