From patchwork Thu Feb 2 14:55:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 723083 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 3vDjkY0qc3z9s7G for ; Fri, 3 Feb 2017 01:56:37 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D51494B645; Thu, 2 Feb 2017 15:56:34 +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 C0r2jiLrHrij; Thu, 2 Feb 2017 15:56:34 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5ADCF4B646; Thu, 2 Feb 2017 15:56:28 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 577974B5A1 for ; Thu, 2 Feb 2017 15:56:24 +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 yGJVMV6urxPQ for ; Thu, 2 Feb 2017 15:56:24 +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-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by theia.denx.de (Postfix) with ESMTPS id 1A47E4B58A for ; Thu, 2 Feb 2017 15:56:21 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id u63so4716485wmu.2 for ; Thu, 02 Feb 2017 06:56:21 -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=shnn/706QFulpNNaBYH/zIqTmTn+Ew9lxNdY60SmRFA=; b=ZPeCerCiIFXBuiZmN7ethtcfXcW3TUlwMJAcurtBtk+MLvfehLTLVrNsMCUJ6GOh/F pQbR4orRfkEf5nzisKWaf8EiZlRnH2E/m+kXs1Bc6pVrZfsiTazK4PlHaAPknEwuD9J2 2LZPqhhj3qcnv20o6WBSBcWMLsElaI8TrAq9yOz63KrWQ7a7jDApWRLdvKux7Pi4JESx Lo50EXORsSWXr7DRnd0i7KNgWW2AUbMYVxxrZD4yVZKdD+4gEAtiCWiUR73Cg3ZoVUzN +wkoUZVgKgR/ID7Ff75Zo+ERGBDXFjztHWlxuK1irnjUv/hDj0XR060Fg9XBL5nJpvkB J4mQ== X-Gm-Message-State: AIkVDXIsKIa47Pt7/Xuvhq0sqd5bbP0gqUOA731PWF1fQvEXwtDW1YN5zDrmgd/4/KPmgw== X-Received: by 10.28.107.141 with SMTP id a13mr8269608wmi.61.1486047380813; Thu, 02 Feb 2017 06:56:20 -0800 (PST) Received: from jagan-XPS-13-9350.homenet.telecomitalia.it (host211-95-static.0-79-b.business.telecomitalia.it. [79.0.95.211]) by smtp.gmail.com with ESMTPSA id s26sm39984869wra.26.2017.02.02.06.56.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Feb 2017 06:56:19 -0800 (PST) From: Jagan Teki To: Stefano Babic Date: Thu, 2 Feb 2017 15:55:59 +0100 Message-Id: <1486047373-31676-2-git-send-email-jagan@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486047373-31676-1-git-send-email-jagan@openedev.com> References: <1486047373-31676-1-git-send-email-jagan@openedev.com> Cc: u-boot@lists.denx.de, Jagan Teki , Matteo Lisi Subject: [U-Boot] [PATCH v3 01/15] 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: Tim Harvey Cc: Matteo Lisi Cc: Michael Trimarchi Signed-off-by: Jagan Teki --- arch/arm/imx-common/init.c | 12 ++++++++++++ arch/arm/imx-common/spl.c | 6 +++--- arch/arm/include/asm/imx-common/sys_proto.h | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/arch/arm/imx-common/init.c b/arch/arm/imx-common/init.c index e5dbd93..036ebb2 100644 --- a/arch/arm/imx-common/init.c +++ b/arch/arm/imx-common/init.c @@ -115,3 +115,15 @@ void boot_mode_apply(unsigned cfg_val) writel(reg, &psrc->gpr10); } #endif + +#if defined(CONFIG_MX6) +u32 imx6_src_get_boot_mode(void) +{ + struct src *psrc = (struct src *)SRC_BASE_ADDR; + + if (imx6_is_bmode_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 60c4adf..a7f9705 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))) + (imx6_is_bmode_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/imx-common/sys_proto.h b/arch/arm/include/asm/imx-common/sys_proto.h index 539d34b..99e3869 100644 --- a/arch/arm/include/asm/imx-common/sys_proto.h +++ b/arch/arm/include/asm/imx-common/sys_proto.h @@ -8,6 +8,7 @@ #ifndef _SYS_PROTO_H_ #define _SYS_PROTO_H_ +#include #include #include #include "../arch-imx/cpu.h" @@ -38,6 +39,19 @@ #define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL)) #define is_mx6sll() (is_cpu_type(MXC_CPU_MX6SLL)) +#ifdef CONFIG_MX6 +#define IMX6_SRC_GPR10_BMODE BIT(28) + +static inline u8 imx6_is_bmode_from_gpr9(void) +{ + struct src *psrc = (struct src *)SRC_BASE_ADDR; + + return readl(&psrc->gpr10) & IMX6_SRC_GPR10_BMODE; +} + +u32 imx6_src_get_boot_mode(void); +#endif /* CONFIG_MX6 */ + u32 get_nr_cpus(void); u32 get_cpu_rev(void); u32 get_cpu_speed_grade_hz(void);