boot-common.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <common.h>
  19. #include <spl.h>
  20. #include <asm/omap_common.h>
  21. #include <asm/arch/omap.h>
  22. #include <asm/arch/mmc_host_def.h>
  23. #include <asm/arch/sys_proto.h>
  24. DECLARE_GLOBAL_DATA_PTR;
  25. void save_omap_boot_params(void)
  26. {
  27. u32 rom_params = *((u32 *)OMAP_SRAM_SCRATCH_BOOT_PARAMS);
  28. u8 boot_device;
  29. u32 dev_desc, dev_data;
  30. if ((rom_params < NON_SECURE_SRAM_START) ||
  31. (rom_params > NON_SECURE_SRAM_END))
  32. return;
  33. /*
  34. * rom_params can be type casted to omap_boot_parameters and
  35. * used. But it not correct to assume that romcode structure
  36. * encoding would be same as u-boot. So use the defined offsets.
  37. */
  38. gd->arch.omap_boot_params.omap_bootdevice = boot_device =
  39. *((u8 *)(rom_params + BOOT_DEVICE_OFFSET));
  40. gd->arch.omap_boot_params.ch_flags =
  41. *((u8 *)(rom_params + CH_FLAGS_OFFSET));
  42. if ((boot_device >= MMC_BOOT_DEVICES_START) &&
  43. (boot_device <= MMC_BOOT_DEVICES_END)) {
  44. #if !defined(CONFIG_AM33XX) && !defined(CONFIG_TI81XX)
  45. if ((omap_hw_init_context() ==
  46. OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)) {
  47. gd->arch.omap_boot_params.omap_bootmode =
  48. *((u8 *)(rom_params + BOOT_MODE_OFFSET));
  49. } else
  50. #endif
  51. {
  52. dev_desc = *((u32 *)(rom_params + DEV_DESC_PTR_OFFSET));
  53. dev_data = *((u32 *)(dev_desc + DEV_DATA_PTR_OFFSET));
  54. gd->arch.omap_boot_params.omap_bootmode =
  55. *((u32 *)(dev_data + BOOT_MODE_OFFSET));
  56. }
  57. }
  58. }
  59. #ifdef CONFIG_SPL_BUILD
  60. u32 spl_boot_device(void)
  61. {
  62. return (u32) (gd->arch.omap_boot_params.omap_bootdevice);
  63. }
  64. u32 spl_boot_mode(void)
  65. {
  66. return gd->arch.omap_boot_params.omap_bootmode;
  67. }
  68. void spl_board_init(void)
  69. {
  70. #ifdef CONFIG_SPL_NAND_SUPPORT
  71. gpmc_init();
  72. #endif
  73. #if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT)
  74. arch_misc_init();
  75. #endif
  76. }
  77. int board_mmc_init(bd_t *bis)
  78. {
  79. switch (spl_boot_device()) {
  80. case BOOT_DEVICE_MMC1:
  81. omap_mmc_init(0, 0, 0, -1, -1);
  82. break;
  83. case BOOT_DEVICE_MMC2:
  84. case BOOT_DEVICE_MMC2_2:
  85. omap_mmc_init(1, 0, 0, -1, -1);
  86. break;
  87. }
  88. return 0;
  89. }
  90. void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
  91. {
  92. typedef void __noreturn (*image_entry_noargs_t)(u32 *);
  93. image_entry_noargs_t image_entry =
  94. (image_entry_noargs_t) spl_image->entry_point;
  95. debug("image entry point: 0x%X\n", spl_image->entry_point);
  96. /* Pass the saved boot_params from rom code */
  97. image_entry((u32 *)&gd->arch.omap_boot_params);
  98. }
  99. #endif