spl.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2014 Gateworks Corporation
  3. * Copyright (C) 2011-2012 Freescale Semiconductor, Inc.
  4. *
  5. * Author: Tim Harvey <tharvey@gateworks.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <asm/io.h>
  11. #include <asm/arch/imx-regs.h>
  12. #include <asm/spl.h>
  13. #include <spl.h>
  14. #if defined(CONFIG_MX6)
  15. /* determine boot device from SRC_SBMR1 register (BOOT_CFG[4:1]) */
  16. u32 spl_boot_device(void)
  17. {
  18. struct src *psrc = (struct src *)SRC_BASE_ADDR;
  19. unsigned reg = readl(&psrc->sbmr1);
  20. /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
  21. switch ((reg & 0x000000FF) >> 4) {
  22. /* EIM: See 8.5.1, Table 8-9 */
  23. case 0x0:
  24. /* BOOT_CFG1[3]: NOR/OneNAND Selection */
  25. if ((reg & 0x00000008) >> 3)
  26. return BOOT_DEVICE_ONENAND;
  27. else
  28. return BOOT_DEVICE_NOR;
  29. break;
  30. /* SATA: See 8.5.4, Table 8-20 */
  31. case 0x2:
  32. return BOOT_DEVICE_SATA;
  33. /* Serial ROM: See 8.5.5.1, Table 8-22 */
  34. case 0x3:
  35. /* BOOT_CFG4[2:0] */
  36. switch ((reg & 0x07000000) >> 24) {
  37. case 0x0 ... 0x4:
  38. return BOOT_DEVICE_SPI;
  39. case 0x5 ... 0x7:
  40. return BOOT_DEVICE_I2C;
  41. }
  42. break;
  43. /* SD/eSD: 8.5.3, Table 8-15 */
  44. case 0x4:
  45. case 0x5:
  46. return BOOT_DEVICE_MMC1;
  47. /* MMC/eMMC: 8.5.3 */
  48. case 0x6:
  49. case 0x7:
  50. return BOOT_DEVICE_MMC1;
  51. /* NAND Flash: 8.5.2 */
  52. case 0x8 ... 0xf:
  53. return BOOT_DEVICE_NAND;
  54. }
  55. return BOOT_DEVICE_NONE;
  56. }
  57. #endif
  58. #if defined(CONFIG_SPL_MMC_SUPPORT)
  59. /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
  60. u32 spl_boot_mode(void)
  61. {
  62. switch (spl_boot_device()) {
  63. /* for MMC return either RAW or FAT mode */
  64. case BOOT_DEVICE_MMC1:
  65. case BOOT_DEVICE_MMC2:
  66. #ifdef CONFIG_SPL_FAT_SUPPORT
  67. return MMCSD_MODE_FAT;
  68. #else
  69. return MMCSD_MODE_RAW;
  70. #endif
  71. break;
  72. default:
  73. puts("spl: ERROR: unsupported device\n");
  74. hang();
  75. }
  76. }
  77. #endif