Re: [U-Boot] [PATCH 1/4] sunxi: Use BROM stored boot_media value to determine our boot-source

2016-07-11 Thread Hans de Goede

Hi,

On 10-07-16 10:17, Ian Campbell wrote:

On Sat, 2016-07-09 at 22:22 +0200, Hans de Goede wrote:

Now that we know that the BROM stores a value indicating the boot-
source
at the beginning of SRAM, use that instead of trying to recreate the
BROM's boot probing.

Signed-off-by: Hans de Goede 


All 4 patches:
Acked-by: Ian Campbell 

You might want to s/3th/3rd/ in the third patch's description.


Done.

Thanks for all the reviews.

Regards,

Hans

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/4] sunxi: Use BROM stored boot_media value to determine our boot-source

2016-07-10 Thread Ian Campbell
On Sat, 2016-07-09 at 22:22 +0200, Hans de Goede wrote:
> Now that we know that the BROM stores a value indicating the boot-
> source
> at the beginning of SRAM, use that instead of trying to recreate the
> BROM's boot probing.
> 
> Signed-off-by: Hans de Goede 

All 4 patches:
Acked-by: Ian Campbell 

You might want to s/3th/3rd/ in the third patch's description.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/4] sunxi: Use BROM stored boot_media value to determine our boot-source

2016-07-09 Thread Hans de Goede
Now that we know that the BROM stores a value indicating the boot-source
at the beginning of SRAM, use that instead of trying to recreate the
BROM's boot probing.

Signed-off-by: Hans de Goede 
---
 arch/arm/include/asm/arch-sunxi/mmc.h |  1 -
 arch/arm/mach-sunxi/board.c   | 34 +++---
 board/sunxi/board.c   |  3 +--
 drivers/mmc/sunxi_mmc.c   | 17 -
 4 files changed, 12 insertions(+), 43 deletions(-)

diff --git a/arch/arm/include/asm/arch-sunxi/mmc.h 
b/arch/arm/include/asm/arch-sunxi/mmc.h
index 3da360b..cb52e64 100644
--- a/arch/arm/include/asm/arch-sunxi/mmc.h
+++ b/arch/arm/include/asm/arch-sunxi/mmc.h
@@ -127,5 +127,4 @@ struct sunxi_mmc {
 #define SUNXI_MMC_COMMON_RESET (1 << 18)
 
 struct mmc *sunxi_mmc_init(int sdc_no);
-int sunxi_mmc_has_egon_boot_signature(struct mmc *mmc);
 #endif /* _SUNXI_MMC_H */
diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index 3f5116b..06a1986 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -203,7 +203,8 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 u32 spl_boot_device(void)
 {
-   __maybe_unused struct mmc *mmc0, *mmc1;
+   int boot_source;
+
/*
 * When booting from the SD card or NAND memory, the "eGON.BT0"
 * signature is expected to be found in memory at the address 0x0004
@@ -223,32 +224,19 @@ u32 spl_boot_device(void)
if (!is_boot0_magic(SPL_ADDR + 4)) /* eGON.BT0 */
return BOOT_DEVICE_BOARD;
 
-#ifdef CONFIG_SPL_SPI_SUNXI
-   if (readb(SPL_ADDR + 0x28) == SUNXI_BOOTED_FROM_SPI)
-   return BOOT_DEVICE_SPI;
-#endif
-
-   /* The BROM will try to boot from mmc0 first, so try that first. */
-#ifdef CONFIG_MMC
-   mmc_initialize(gd->bd);
-   mmc0 = find_mmc_device(0);
-   if (sunxi_mmc_has_egon_boot_signature(mmc0))
+   boot_source = readb(SPL_ADDR + 0x28);
+   switch (boot_source) {
+   case SUNXI_BOOTED_FROM_MMC0:
return BOOT_DEVICE_MMC1;
-#endif
-
-   /* Fallback to booting NAND if enabled. */
-   if (IS_ENABLED(CONFIG_SPL_NAND_SUPPORT))
+   case SUNXI_BOOTED_FROM_NAND:
return BOOT_DEVICE_NAND;
-
-#ifdef CONFIG_MMC
-   if (CONFIG_MMC_SUNXI_SLOT_EXTRA == 2) {
-   mmc1 = find_mmc_device(1);
-   if (sunxi_mmc_has_egon_boot_signature(mmc1))
-   return BOOT_DEVICE_MMC2;
+   case SUNXI_BOOTED_FROM_MMC2:
+   return BOOT_DEVICE_MMC2;
+   case SUNXI_BOOTED_FROM_SPI:
+   return BOOT_DEVICE_SPI;
}
-#endif
 
-   panic("Could not determine boot source\n");
+   panic("Unknown boot source %d\n", boot_source);
return -1;  /* Never reached */
 }
 
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 9767310..840f01d 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -369,8 +369,7 @@ int board_mmc_init(bd_t *bis)
 * are searched there first. Note we only do this for u-boot proper,
 * not for the SPL, see spl_boot_device().
 */
-   if (!sunxi_mmc_has_egon_boot_signature(mmc0) &&
-   sunxi_mmc_has_egon_boot_signature(mmc1)) {
+   if (readb(SPL_ADDR + 0x28) == SUNXI_BOOTED_FROM_MMC2) {
/* Booting from emmc / mmc2, swap */
mmc0->block_dev.devnum = 1;
mmc1->block_dev.devnum = 0;
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index 3be9a90..5d8abdc 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -445,23 +445,6 @@ static int sunxi_mmc_getcd(struct mmc *mmc)
return !gpio_get_value(cd_pin);
 }
 
-int sunxi_mmc_has_egon_boot_signature(struct mmc *mmc)
-{
-   char *buf = malloc(512);
-   int valid_signature = 0;
-
-   if (buf == NULL)
-   panic("Failed to allocate memory\n");
-
-   if (mmc_getcd(mmc) && mmc_init(mmc) == 0 &&
-   mmc->block_dev.block_read(>block_dev, 16, 1, buf) == 1 &&
-   strncmp([4], "eGON.BT0", 8) == 0)
-   valid_signature = 1;
-
-   free(buf);
-   return valid_signature;
-}
-
 static const struct mmc_ops sunxi_mmc_ops = {
.send_cmd   = sunxi_mmc_send_cmd,
.set_ios= sunxi_mmc_set_ios,
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot