Patchwork [U-Boot,u-boot,RFC,v1] ARMV7: OMAP4+: Fix boot issues when using Alternative Boot operation mode

login
register
mail settings
Submitter Oleksandr Tyshchenko
Date Aug. 6, 2013, 10:47 a.m.
Message ID <1375786067-7927-1-git-send-email-oleksandr.tyshchenko@ti.com>
Download mbox | patch
Permalink /patch/265001/
State Changes Requested
Delegated to: Tom Rini
Headers show

Comments

Oleksandr Tyshchenko - Aug. 6, 2013, 10:47 a.m.
The Alternative Boot operation mode (boot from eMMC boot partition)
is selected through sys_boot pads configuration:
- sys_boot[5:0]=0b101100 for OMAP4 (MMC2_BOOT)
- sys_boot[3:0]=0xb1110 for OMAP5 (eMMC, boot partition only)

So, add new bootdevice BOOT_DEVICE_MMC2_BOOT for OMAP4 and change bootmode
from MMCSD_MODE_UNDEFINED to MMCSD_MODE_RAW for it to support this mode.
As for OMAP5, then only change bootmode to MMCSD_MODE_RAW.

Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@ti.com>
---
 arch/arm/cpu/armv7/omap-common/boot-common.c |   21 ++++++++++++++++-----
 arch/arm/include/asm/arch-omap4/spl.h        |    3 ++-
 common/spl/spl.c                             |    1 +
 3 files changed, 19 insertions(+), 6 deletions(-)
Tom Rini - Aug. 28, 2013, 3:10 p.m.
On Tue, Aug 06, 2013 at 01:47:47PM +0300, Oleksandr Tyshchenko wrote:

> The Alternative Boot operation mode (boot from eMMC boot partition)
> is selected through sys_boot pads configuration:
> - sys_boot[5:0]=0b101100 for OMAP4 (MMC2_BOOT)
> - sys_boot[3:0]=0xb1110 for OMAP5 (eMMC, boot partition only)
> 
> So, add new bootdevice BOOT_DEVICE_MMC2_BOOT for OMAP4 and change bootmode
> from MMCSD_MODE_UNDEFINED to MMCSD_MODE_RAW for it to support this mode.
> As for OMAP5, then only change bootmode to MMCSD_MODE_RAW.

To be clear, on OMAP4 (and probably later) when using the boot partition
the ROM is not setting the boot mode flag correctly, and we need to fix
it up?  If so, we should handle that fixup more directly, and spell this
out.  In the comment here:

> +		/*
> +		 * Make spl_mmc_load_image() happy with Alternative
> +		 * Boot operation mode
> +		 */
> +#if defined(CONFIG_OMAP44XX)
> +		if (boot_device == BOOT_DEVICE_MMC2_BOOT)
> +			boot_mode = MMCSD_MODE_RAW;
> +#elif defined(CONFIG_OMAP54XX)
> +		if (boot_device == BOOT_DEVICE_MMC2)
> +			boot_mode = MMCSD_MODE_RAW;
> +#endif
> +		gd->arch.omap_boot_params.omap_bootmode = boot_mode;

Also note that on OMAP54XX we'll have a separate MMC2_BOOT rather than
just MMC2, when booting from boot partitions rather than the rest of
eMMC, so this fixup isn't right.

[snip]
> @@ -92,6 +102,7 @@ int board_mmc_init(bd_t *bis)
>  		omap_mmc_init(0, 0, 0, -1, -1);
>  		break;
>  	case BOOT_DEVICE_MMC2:
> +	case BOOT_DEVICE_MMC2_BOOT:
>  	case BOOT_DEVICE_MMC2_2:

This is common code, so you need to fixup all of the omap-family spl.h
files.

> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 628c399..ba91b65 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -177,6 +177,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>  #ifdef CONFIG_SPL_MMC_SUPPORT
>  	case BOOT_DEVICE_MMC1:
>  	case BOOT_DEVICE_MMC2:
> +	case BOOT_DEVICE_MMC2_BOOT:
>  	case BOOT_DEVICE_MMC2_2:

And this is generic code, so everyone that sets MMC1/2/2_2 needs to add
2_BOOT.

Patch

diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c
index 76ae1b6..f693b0d 100644
--- a/arch/arm/cpu/armv7/omap-common/boot-common.c
+++ b/arch/arm/cpu/armv7/omap-common/boot-common.c
@@ -29,7 +29,7 @@  void save_omap_boot_params(void)
 {
 	u32 rom_params = *((u32 *)OMAP_SRAM_SCRATCH_BOOT_PARAMS);
 	u8 boot_device;
-	u32 dev_desc, dev_data;
+	u32 dev_desc, dev_data, boot_mode;
 
 	if ((rom_params <  NON_SECURE_SRAM_START) ||
 	    (rom_params > NON_SECURE_SRAM_END))
@@ -51,16 +51,26 @@  void save_omap_boot_params(void)
 #if !defined(CONFIG_AM33XX) && !defined(CONFIG_TI81XX)
 		if ((omap_hw_init_context() ==
 				      OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)) {
-			gd->arch.omap_boot_params.omap_bootmode =
-			*((u8 *)(rom_params + BOOT_MODE_OFFSET));
+			boot_mode = *((u8 *)(rom_params + BOOT_MODE_OFFSET));
 		} else
 #endif
 		{
 			dev_desc = *((u32 *)(rom_params + DEV_DESC_PTR_OFFSET));
 			dev_data = *((u32 *)(dev_desc + DEV_DATA_PTR_OFFSET));
-			gd->arch.omap_boot_params.omap_bootmode =
-					*((u32 *)(dev_data + BOOT_MODE_OFFSET));
+			boot_mode = *((u32 *)(dev_data + BOOT_MODE_OFFSET));
 		}
+		/*
+		 * Make spl_mmc_load_image() happy with Alternative
+		 * Boot operation mode
+		 */
+#if defined(CONFIG_OMAP44XX)
+		if (boot_device == BOOT_DEVICE_MMC2_BOOT)
+			boot_mode = MMCSD_MODE_RAW;
+#elif defined(CONFIG_OMAP54XX)
+		if (boot_device == BOOT_DEVICE_MMC2)
+			boot_mode = MMCSD_MODE_RAW;
+#endif
+		gd->arch.omap_boot_params.omap_bootmode = boot_mode;
 	}
 }
 
@@ -92,6 +102,7 @@  int board_mmc_init(bd_t *bis)
 		omap_mmc_init(0, 0, 0, -1, -1);
 		break;
 	case BOOT_DEVICE_MMC2:
+	case BOOT_DEVICE_MMC2_BOOT:
 	case BOOT_DEVICE_MMC2_2:
 		omap_mmc_init(1, 0, 0, -1, -1);
 		break;
diff --git a/arch/arm/include/asm/arch-omap4/spl.h b/arch/arm/include/asm/arch-omap4/spl.h
index f61627f..245b81f 100644
--- a/arch/arm/include/asm/arch-omap4/spl.h
+++ b/arch/arm/include/asm/arch-omap4/spl.h
@@ -30,8 +30,9 @@ 
 #define BOOT_DEVICE_ONENAND	4
 #define BOOT_DEVICE_MMC1	5
 #define BOOT_DEVICE_MMC2	6
+#define BOOT_DEVICE_MMC2_BOOT	8
 #define BOOT_DEVICE_MMC2_2	0xFF
 
 #define MMC_BOOT_DEVICES_START	BOOT_DEVICE_MMC1
-#define MMC_BOOT_DEVICES_END	BOOT_DEVICE_MMC2
+#define MMC_BOOT_DEVICES_END	BOOT_DEVICE_MMC2_BOOT
 #endif
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 628c399..ba91b65 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -177,6 +177,7 @@  void board_init_r(gd_t *dummy1, ulong dummy2)
 #ifdef CONFIG_SPL_MMC_SUPPORT
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
+	case BOOT_DEVICE_MMC2_BOOT:
 	case BOOT_DEVICE_MMC2_2:
 		spl_mmc_load_image();
 		break;