boot.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * OMAP3 boot
  3. *
  4. * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <asm/io.h>
  10. #include <asm/arch/sys_proto.h>
  11. #include <spl.h>
  12. static u32 boot_devices[] = {
  13. BOOT_DEVICE_ONENAND,
  14. BOOT_DEVICE_NAND,
  15. BOOT_DEVICE_ONENAND,
  16. BOOT_DEVICE_MMC2,
  17. BOOT_DEVICE_ONENAND,
  18. BOOT_DEVICE_MMC2,
  19. BOOT_DEVICE_MMC1,
  20. BOOT_DEVICE_XIP,
  21. BOOT_DEVICE_XIPWAIT,
  22. BOOT_DEVICE_MMC2,
  23. BOOT_DEVICE_XIP,
  24. BOOT_DEVICE_XIPWAIT,
  25. BOOT_DEVICE_NAND,
  26. BOOT_DEVICE_XIP,
  27. BOOT_DEVICE_XIPWAIT,
  28. BOOT_DEVICE_NAND,
  29. BOOT_DEVICE_ONENAND,
  30. BOOT_DEVICE_MMC2,
  31. BOOT_DEVICE_MMC1,
  32. BOOT_DEVICE_XIP,
  33. BOOT_DEVICE_XIPWAIT,
  34. BOOT_DEVICE_NAND,
  35. BOOT_DEVICE_ONENAND,
  36. BOOT_DEVICE_MMC2,
  37. BOOT_DEVICE_MMC1,
  38. BOOT_DEVICE_XIP,
  39. BOOT_DEVICE_XIPWAIT,
  40. BOOT_DEVICE_NAND,
  41. BOOT_DEVICE_MMC2_2,
  42. };
  43. u32 omap_sys_boot_device(void)
  44. {
  45. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  46. u32 sys_boot;
  47. /* Grab the first 5 bits of the status register for SYS_BOOT. */
  48. sys_boot = readl(&ctrl_base->status) & ((1 << 5) - 1);
  49. if (sys_boot >= (sizeof(boot_devices) / sizeof(u32)))
  50. return BOOT_DEVICE_NONE;
  51. return boot_devices[sys_boot];
  52. }
  53. char omap_reboot_mode(void)
  54. {
  55. u32 reboot_mode;
  56. char c;
  57. reboot_mode = readl((u32 *)(OMAP34XX_SCRATCHPAD + 4));
  58. c = (reboot_mode >> 24) & 0xff;
  59. if (c != 'B')
  60. return -1;
  61. c = (reboot_mode >> 16) & 0xff;
  62. if (c != 'M')
  63. return -1;
  64. c = reboot_mode & 0xff;
  65. return c;
  66. }
  67. int omap_reboot_mode_clear(void)
  68. {
  69. writel(0, (u32 *)(OMAP34XX_SCRATCHPAD + 4));
  70. return 0;
  71. }
  72. int omap_reboot_mode_store(char c)
  73. {
  74. u32 reboot_mode;
  75. reboot_mode = 'B' << 24 | 'M' << 16 | c;
  76. writel(reboot_mode, (u32 *)(OMAP34XX_SCRATCHPAD + 4));
  77. return 0;
  78. }