All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port
@ 2018-10-03 15:03 Andrew F. Davis
  2018-10-03 15:03 ` [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode Andrew F. Davis
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Andrew F. Davis @ 2018-10-03 15:03 UTC (permalink / raw)
  To: 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 <afd@ti.com>
---
 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
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode
  2018-10-03 15:03 [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port Andrew F. Davis
@ 2018-10-03 15:03 ` Andrew F. Davis
  2018-10-03 15:06   ` Tom Rini
                     ` (2 more replies)
  2018-10-03 15:06 ` [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port Tom Rini
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 8+ messages in thread
From: Andrew F. Davis @ 2018-10-03 15:03 UTC (permalink / raw)
  To: 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 <afd@ti.com>
---
 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) >>
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port
  2018-10-03 15:03 [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port Andrew F. Davis
  2018-10-03 15:03 ` [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode Andrew F. Davis
@ 2018-10-03 15:06 ` Tom Rini
  2018-10-03 15:13 ` Lokesh Vutla
  2018-10-11 14:12 ` [U-Boot] [U-Boot, " Tom Rini
  3 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2018-10-03 15:06 UTC (permalink / raw)
  To: u-boot

On Wed, Oct 03, 2018 at 10:03:22AM -0500, Andrew F. Davis wrote:

> 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 <afd@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181003/aaaea209/attachment.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode
  2018-10-03 15:03 ` [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode Andrew F. Davis
@ 2018-10-03 15:06   ` Tom Rini
  2018-10-03 15:13   ` Lokesh Vutla
  2018-10-11 14:12   ` [U-Boot] [U-Boot, " Tom Rini
  2 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2018-10-03 15:06 UTC (permalink / raw)
  To: u-boot

On Wed, Oct 03, 2018 at 10:03:23AM -0500, Andrew F. Davis wrote:

> 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 <afd@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181003/563d62f4/attachment.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port
  2018-10-03 15:03 [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port Andrew F. Davis
  2018-10-03 15:03 ` [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode Andrew F. Davis
  2018-10-03 15:06 ` [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port Tom Rini
@ 2018-10-03 15:13 ` Lokesh Vutla
  2018-10-11 14:12 ` [U-Boot] [U-Boot, " Tom Rini
  3 siblings, 0 replies; 8+ messages in thread
From: Lokesh Vutla @ 2018-10-03 15:13 UTC (permalink / raw)
  To: u-boot



On Wednesday 03 October 2018 08:33 PM, Andrew F. Davis wrote:
> 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 <afd@ti.com>

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode
  2018-10-03 15:03 ` [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode Andrew F. Davis
  2018-10-03 15:06   ` Tom Rini
@ 2018-10-03 15:13   ` Lokesh Vutla
  2018-10-11 14:12   ` [U-Boot] [U-Boot, " Tom Rini
  2 siblings, 0 replies; 8+ messages in thread
From: Lokesh Vutla @ 2018-10-03 15:13 UTC (permalink / raw)
  To: u-boot



On Wednesday 03 October 2018 08:33 PM, Andrew F. Davis wrote:
> 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 <afd@ti.com>


Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [U-Boot, 1/2] arm: K3: am654: Choose MMC boot device based on boot port
  2018-10-03 15:03 [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port Andrew F. Davis
                   ` (2 preceding siblings ...)
  2018-10-03 15:13 ` Lokesh Vutla
@ 2018-10-11 14:12 ` Tom Rini
  3 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2018-10-11 14:12 UTC (permalink / raw)
  To: u-boot

On Wed, Oct 03, 2018 at 10:03:22AM -0500, Andrew F. Davis wrote:

> 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 <afd@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181011/45634b3a/attachment.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [U-Boot, 2/2] arm: K3: am654: Add support for getting boot mode
  2018-10-03 15:03 ` [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode Andrew F. Davis
  2018-10-03 15:06   ` Tom Rini
  2018-10-03 15:13   ` Lokesh Vutla
@ 2018-10-11 14:12   ` Tom Rini
  2 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2018-10-11 14:12 UTC (permalink / raw)
  To: u-boot

On Wed, Oct 03, 2018 at 10:03:23AM -0500, Andrew F. Davis wrote:

> 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 <afd@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181011/884debf5/attachment.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-11 14:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 15:03 [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port Andrew F. Davis
2018-10-03 15:03 ` [U-Boot] [PATCH 2/2] arm: K3: am654: Add support for getting boot mode Andrew F. Davis
2018-10-03 15:06   ` Tom Rini
2018-10-03 15:13   ` Lokesh Vutla
2018-10-11 14:12   ` [U-Boot] [U-Boot, " Tom Rini
2018-10-03 15:06 ` [U-Boot] [PATCH 1/2] arm: K3: am654: Choose MMC boot device based on boot port Tom Rini
2018-10-03 15:13 ` Lokesh Vutla
2018-10-11 14:12 ` [U-Boot] [U-Boot, " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.