boot-common.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * boot-common.c
  3. *
  4. * Common bootmode functions for omap based boards
  5. *
  6. * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <common.h>
  11. #include <spl.h>
  12. #include <asm/omap_common.h>
  13. #include <asm/arch/omap.h>
  14. #include <asm/arch/mmc_host_def.h>
  15. #include <asm/arch/sys_proto.h>
  16. DECLARE_GLOBAL_DATA_PTR;
  17. void save_omap_boot_params(void)
  18. {
  19. u32 rom_params = *((u32 *)OMAP_SRAM_SCRATCH_BOOT_PARAMS);
  20. u8 boot_device;
  21. u32 dev_desc, dev_data;
  22. if ((rom_params < NON_SECURE_SRAM_START) ||
  23. (rom_params > NON_SECURE_SRAM_END))
  24. return;
  25. /*
  26. * rom_params can be type casted to omap_boot_parameters and
  27. * used. But it not correct to assume that romcode structure
  28. * encoding would be same as u-boot. So use the defined offsets.
  29. */
  30. gd->arch.omap_boot_params.omap_bootdevice = boot_device =
  31. *((u8 *)(rom_params + BOOT_DEVICE_OFFSET));
  32. gd->arch.omap_boot_params.ch_flags =
  33. *((u8 *)(rom_params + CH_FLAGS_OFFSET));
  34. if ((boot_device >= MMC_BOOT_DEVICES_START) &&
  35. (boot_device <= MMC_BOOT_DEVICES_END)) {
  36. #if !defined(CONFIG_AM33XX) && !defined(CONFIG_TI81XX) && \
  37. !defined(CONFIG_AM43XX)
  38. if ((omap_hw_init_context() ==
  39. OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)) {
  40. gd->arch.omap_boot_params.omap_bootmode =
  41. *((u8 *)(rom_params + BOOT_MODE_OFFSET));
  42. } else
  43. #endif
  44. {
  45. dev_desc = *((u32 *)(rom_params + DEV_DESC_PTR_OFFSET));
  46. dev_data = *((u32 *)(dev_desc + DEV_DATA_PTR_OFFSET));
  47. gd->arch.omap_boot_params.omap_bootmode =
  48. *((u32 *)(dev_data + BOOT_MODE_OFFSET));
  49. }
  50. }
  51. }
  52. #ifdef CONFIG_SPL_BUILD
  53. u32 spl_boot_device(void)
  54. {
  55. return (u32) (gd->arch.omap_boot_params.omap_bootdevice);
  56. }
  57. u32 spl_boot_mode(void)
  58. {
  59. return gd->arch.omap_boot_params.omap_bootmode;
  60. }
  61. void spl_board_init(void)
  62. {
  63. #ifdef CONFIG_SPL_NAND_SUPPORT
  64. gpmc_init();
  65. #endif
  66. #if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT)
  67. arch_misc_init();
  68. #endif
  69. }
  70. int board_mmc_init(bd_t *bis)
  71. {
  72. switch (spl_boot_device()) {
  73. case BOOT_DEVICE_MMC1:
  74. omap_mmc_init(0, 0, 0, -1, -1);
  75. break;
  76. case BOOT_DEVICE_MMC2:
  77. case BOOT_DEVICE_MMC2_2:
  78. omap_mmc_init(1, 0, 0, -1, -1);
  79. break;
  80. }
  81. return 0;
  82. }
  83. void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
  84. {
  85. typedef void __noreturn (*image_entry_noargs_t)(u32 *);
  86. image_entry_noargs_t image_entry =
  87. (image_entry_noargs_t) spl_image->entry_point;
  88. debug("image entry point: 0x%X\n", spl_image->entry_point);
  89. /* Pass the saved boot_params from rom code */
  90. image_entry((u32 *)&gd->arch.omap_boot_params);
  91. }
  92. #endif