Commit c0fa385c9b0d924c66e55467e867f37adc2c6630

Authored by Fabien Parent
Committed by Tom Rini
1 parent 208db781ca

davinci: spl: use bootcfg to select boot device

Right now the SPL is trying to load u-boot based on defines, i.e. one
has to define CONFIG_SPL_NAND_SIMPLE to boot from NAND,
or CONFIG_SPL_SPI_LOAD to boot from SPI FLASH, etc...
This prevent us from having a single SPL image that is able to boot from
all media, and one need to build an image for each medium. This
commit is replacing the #ifdef that select the boot medium by reading
the value of the boot pins (via the BOOTCFG register).

Now a single SPL image will be able to read from the boot pin to know
which device should be used to load u-boot.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

Showing 2 changed files with 36 additions and 11 deletions Side-by-side Diff

arch/arm/mach-davinci/include/mach/hardware.h
... ... @@ -475,12 +475,15 @@
475 475 /* Boot config */
476 476 struct davinci_syscfg_regs {
477 477 dv_reg revid;
478   - dv_reg rsvd[13];
  478 + dv_reg rsvd[7];
  479 + dv_reg bootcfg;
  480 + dv_reg chiprevidr;
  481 + dv_reg rsvd2[4];
479 482 dv_reg kick0;
480 483 dv_reg kick1;
481 484 dv_reg rsvd1[52];
482 485 dv_reg mstpri[3];
483   - dv_reg rsvd2;
  486 + dv_reg rsvd3;
484 487 dv_reg pinmux[20];
485 488 dv_reg suspsrc;
486 489 dv_reg chipsig;
... ... @@ -494,6 +497,15 @@
494 497  
495 498 #define davinci_syscfg_regs \
496 499 ((struct davinci_syscfg_regs *)DAVINCI_BOOTCFG_BASE)
  500 +
  501 +enum {
  502 + DAVINCI_NAND8_BOOT = 0b001110,
  503 + DAVINCI_NAND16_BOOT = 0b010000,
  504 + DAVINCI_SD_OR_MMC_BOOT = 0b011100,
  505 + DAVINCI_MMC_ONLY_BOOT = 0b111100,
  506 + DAVINCI_SPI0_FLASH_BOOT = 0b001010,
  507 + DAVINCI_SPI1_FLASH_BOOT = 0b001100,
  508 +};
497 509  
498 510 #define pinmux(x) (&davinci_syscfg_regs->pinmux[x])
499 511  
arch/arm/mach-davinci/spl.c
... ... @@ -52,15 +52,28 @@
52 52  
53 53 u32 spl_boot_device(void)
54 54 {
55   -#ifdef CONFIG_SPL_NAND_SIMPLE
56   - return BOOT_DEVICE_NAND;
57   -#elif defined(CONFIG_SPL_SPI_LOAD)
58   - return BOOT_DEVICE_SPI;
59   -#elif defined(CONFIG_SPL_MMC_LOAD)
60   - return BOOT_DEVICE_MMC1;
61   -#else
62   - puts("Unknown boot device\n");
63   - hang();
  55 + switch (davinci_syscfg_regs->bootcfg) {
  56 +#ifdef CONFIG_SPL_NAND_SUPPORT
  57 + case DAVINCI_NAND8_BOOT:
  58 + case DAVINCI_NAND16_BOOT:
  59 + return BOOT_DEVICE_NAND;
64 60 #endif
  61 +
  62 +#ifdef CONFIG_SPL_MMC_SUPPORT
  63 + case DAVINCI_SD_OR_MMC_BOOT:
  64 + case DAVINCI_MMC_ONLY_BOOT:
  65 + return BOOT_DEVICE_MMC1;
  66 +#endif
  67 +
  68 +#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT
  69 + case DAVINCI_SPI0_FLASH_BOOT:
  70 + case DAVINCI_SPI1_FLASH_BOOT:
  71 + return BOOT_DEVICE_SPI;
  72 +#endif
  73 +
  74 + default:
  75 + puts("Unknown boot device\n");
  76 + hang();
  77 + }
65 78 }