From patchwork Wed Oct 3 15:03:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 978377 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="KoHl6h7D"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42QK6x31nqz9vd1 for ; Thu, 4 Oct 2018 01:04:25 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id E19DBC220BF; Wed, 3 Oct 2018 15:03:51 +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=T_DKIM_INVALID 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 017D3C22108; Wed, 3 Oct 2018 15:03:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9CE50C22047; Wed, 3 Oct 2018 15:03:28 +0000 (UTC) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lists.denx.de (Postfix) with ESMTPS id 29314C22075 for ; Wed, 3 Oct 2018 15:03:28 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w93F3Oon015054; Wed, 3 Oct 2018 10:03:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1538579004; bh=NQUapHH2JFDTbO+aZPrVpWaHJC33X84im7fEg5wb48o=; h=From:To:CC:Subject:Date; b=KoHl6h7DgS0UNWIMmvKLebxxcyvcHDz5NJmCQ3I9IT5XYZ3MtwaF5cRPRB559Z6lO JcmkezJ/wOwTM1m3GS8L7Wh/wjUIXXLOZ2PLLtzplIMaQneJyRqVKs+u9gsPHft8P9 OLnppE1vkfrNAMHbNZJt/rzdWQqaIuol3sZwmmCU= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w93F3OGk006886; Wed, 3 Oct 2018 10:03:24 -0500 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 3 Oct 2018 10:03:24 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 3 Oct 2018 10:03:24 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w93F3OE1012471; Wed, 3 Oct 2018 10:03:24 -0500 Received: from localhost (uda0226330.dhcp.ti.com [172.22.185.47]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w93F3Nx00167; Wed, 3 Oct 2018 10:03:23 -0500 (CDT) From: "Andrew F. Davis" To: Tom Rini , Lokesh Vutla Date: Wed, 3 Oct 2018 10:03:22 -0500 Message-ID: <20181003150323.19923-1-afd@ti.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" For most devices the boot mode maps directly to the boot device. For MMC this is not the case as we have two MMC boot modes and two MMC boot devices (ports). Check the boot port to determine which MMC device was our boot device. Make this change for both primary and secondary boot modes. Signed-off-by: Andrew F. Davis Reviewed-by: Tom Rini Reviewed-by: Lokesh Vutla --- arch/arm/mach-k3/am6_init.c | 21 +++++++++++++++++++- arch/arm/mach-k3/include/mach/am6_hardware.h | 6 ++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index 8a3a99f23a..b2388b98ec 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -85,7 +85,13 @@ static u32 __get_backup_bootmedia(u32 devstat) case BACKUP_BOOT_DEVICE_ETHERNET: return BOOT_DEVICE_ETHERNET; case BACKUP_BOOT_DEVICE_MMC2: + { + u32 port = (devstat & CTRLMMR_MAIN_DEVSTAT_BKUP_MMC_PORT_MASK) >> + CTRLMMR_MAIN_DEVSTAT_BKUP_MMC_PORT_SHIFT; + if (port == 0x0) + return BOOT_DEVICE_MMC1; return BOOT_DEVICE_MMC2; + } case BACKUP_BOOT_DEVICE_SPI: return BOOT_DEVICE_SPI; case BACKUP_BOOT_DEVICE_HYPERFLASH: @@ -99,11 +105,24 @@ static u32 __get_backup_bootmedia(u32 devstat) static u32 __get_primary_bootmedia(u32 devstat) { - u32 bootmode = devstat & CTRLMMR_MAIN_DEVSTAT_BOOTMODE_MASK; + u32 bootmode = (devstat & CTRLMMR_MAIN_DEVSTAT_BOOTMODE_MASK) >> + CTRLMMR_MAIN_DEVSTAT_BOOTMODE_SHIFT; if (bootmode == BOOT_DEVICE_OSPI || bootmode == BOOT_DEVICE_QSPI) bootmode = BOOT_DEVICE_SPI; + if (bootmode == BOOT_DEVICE_MMC2) { + u32 port = (devstat & CTRLMMR_MAIN_DEVSTAT_MMC_PORT_MASK) >> + CTRLMMR_MAIN_DEVSTAT_MMC_PORT_SHIFT; + if (port == 0x0) + bootmode = BOOT_DEVICE_MMC1; + } else if (bootmode == BOOT_DEVICE_MMC1) { + u32 port = (devstat & CTRLMMR_MAIN_DEVSTAT_EMMC_PORT_MASK) >> + CTRLMMR_MAIN_DEVSTAT_EMMC_PORT_SHIFT; + if (port == 0x1) + bootmode = BOOT_DEVICE_MMC2; + } + return bootmode; } diff --git a/arch/arm/mach-k3/include/mach/am6_hardware.h b/arch/arm/mach-k3/include/mach/am6_hardware.h index e4b78f8617..b5244609af 100644 --- a/arch/arm/mach-k3/include/mach/am6_hardware.h +++ b/arch/arm/mach-k3/include/mach/am6_hardware.h @@ -16,6 +16,12 @@ #define CTRLMMR_MAIN_DEVSTAT_BOOTMODE_SHIFT 0 #define CTRLMMR_MAIN_DEVSTAT_BKUP_BOOTMODE_MASK GENMASK(6, 4) #define CTRLMMR_MAIN_DEVSTAT_BKUP_BOOTMODE_SHIFT 4 +#define CTRLMMR_MAIN_DEVSTAT_MMC_PORT_MASK GENMASK(12, 12) +#define CTRLMMR_MAIN_DEVSTAT_MMC_PORT_SHIFT 12 +#define CTRLMMR_MAIN_DEVSTAT_EMMC_PORT_MASK GENMASK(14, 14) +#define CTRLMMR_MAIN_DEVSTAT_EMMC_PORT_SHIFT 14 +#define CTRLMMR_MAIN_DEVSTAT_BKUP_MMC_PORT_MASK GENMASK(17, 17) +#define CTRLMMR_MAIN_DEVSTAT_BKUP_MMC_PORT_SHIFT 12 #define WKUP_CTRL_MMR0_BASE 0x43000000 #define MCU_CTRL_MMR0_BASE 0x40f00000 From patchwork Wed Oct 3 15:03:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 978376 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="gwvixdA5"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42QK601wKXz9vd1 for ; Thu, 4 Oct 2018 01:03:36 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id DD2E1C220FD; Wed, 3 Oct 2018 15:03:32 +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=T_DKIM_INVALID 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 2A093C22075; Wed, 3 Oct 2018 15:03:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 61860C220BD; Wed, 3 Oct 2018 15:03:28 +0000 (UTC) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lists.denx.de (Postfix) with ESMTPS id C55EEC22047 for ; Wed, 3 Oct 2018 15:03:27 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w93F3P5o015058; Wed, 3 Oct 2018 10:03:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1538579005; bh=fHlY8EkVXxMcTWNDcosMjFI5MCfHeeMqPOawVqOOJLQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gwvixdA5hZwiaL54d+y00kBOnJKJTnH01qs0lPcGqWZ6S2koruuKH6OoVxKkTSgjW Vi8nnVW7jvnA8g+SUzpoXoBixQ6DBfZA2kAtwKxvDCE53U6eQAqQiSuJIonotUcSa9 FTDG5fknfMmaYEXyMidQPSS4a6oQlL8xHZWCmwf8= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w93F3PuW006913; Wed, 3 Oct 2018 10:03:25 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 3 Oct 2018 10:03:24 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 3 Oct 2018 10:03:24 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w93F3OZf000693; Wed, 3 Oct 2018 10:03:24 -0500 Received: from localhost (uda0226330.dhcp.ti.com [172.22.185.47]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w93F3Ox00171; Wed, 3 Oct 2018 10:03:24 -0500 (CDT) From: "Andrew F. Davis" To: Tom Rini , Lokesh Vutla Date: Wed, 3 Oct 2018 10:03:23 -0500 Message-ID: <20181003150323.19923-2-afd@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181003150323.19923-1-afd@ti.com> References: <20181003150323.19923-1-afd@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Read the boot mode register to find the boot mode. Only use eMMC boot0 mode when the mode is eMMC boot (called BOOT_DEVICE_MMC1 currently due to current conflating of boot mode and boot device), and not iff the boot device is MMC port 0. Signed-off-by: Andrew F. Davis Reviewed-by: Tom Rini Reviewed-by: Lokesh Vutla --- arch/arm/mach-k3/am6_init.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index b2388b98ec..68f0b8c011 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -72,6 +72,29 @@ void board_init_f(ulong dummy) preloader_console_init(); } +u32 spl_boot_mode(const u32 boot_device) +{ +#if defined(CONFIG_SUPPORT_EMMC_BOOT) + u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT); + u32 bootindex = readl(K3_BOOT_PARAM_TABLE_INDEX_VAL); + + u32 bootmode = (devstat & CTRLMMR_MAIN_DEVSTAT_BOOTMODE_MASK) >> + CTRLMMR_MAIN_DEVSTAT_BOOTMODE_SHIFT; + + /* eMMC boot0 mode is only supported for primary boot */ + if (bootindex == K3_PRIMARY_BOOTMODE && + bootmode == BOOT_DEVICE_MMC1) + return MMCSD_MODE_EMMCBOOT; +#endif + + /* Everything else use filesystem if available */ +#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT) + return MMCSD_MODE_FS; +#else + return MMCSD_MODE_RAW; +#endif +} + static u32 __get_backup_bootmedia(u32 devstat) { u32 bkup_boot = (devstat & CTRLMMR_MAIN_DEVSTAT_BKUP_BOOTMODE_MASK) >>