spl.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2014-2015 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <spl.h>
  8. #include <asm/io.h>
  9. #include <fsl_ifc.h>
  10. #include <fsl_csu.h>
  11. #include <i2c.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. u32 spl_boot_device(void)
  14. {
  15. #ifdef CONFIG_SPL_MMC_SUPPORT
  16. return BOOT_DEVICE_MMC1;
  17. #endif
  18. #ifdef CONFIG_SPL_NAND_SUPPORT
  19. return BOOT_DEVICE_NAND;
  20. #endif
  21. return 0;
  22. }
  23. u32 spl_boot_mode(void)
  24. {
  25. switch (spl_boot_device()) {
  26. case BOOT_DEVICE_MMC1:
  27. #ifdef CONFIG_SPL_FAT_SUPPORT
  28. return MMCSD_MODE_FAT;
  29. #else
  30. return MMCSD_MODE_RAW;
  31. #endif
  32. case BOOT_DEVICE_NAND:
  33. return 0;
  34. default:
  35. puts("spl: error: unsupported device\n");
  36. hang();
  37. }
  38. }
  39. #ifdef CONFIG_SPL_BUILD
  40. void board_init_f(ulong dummy)
  41. {
  42. /* Set global data pointer */
  43. gd = &gdata;
  44. /* Clear global data */
  45. memset((void *)gd, 0, sizeof(gd_t));
  46. #ifdef CONFIG_LS2080A
  47. arch_cpu_init();
  48. #endif
  49. #ifdef CONFIG_FSL_IFC
  50. init_early_memctl_regs();
  51. #endif
  52. board_early_init_f();
  53. timer_init();
  54. #ifdef CONFIG_LS2080A
  55. env_init();
  56. #endif
  57. get_clocks();
  58. preloader_console_init();
  59. #ifdef CONFIG_SPL_I2C_SUPPORT
  60. i2c_init_all();
  61. #endif
  62. dram_init();
  63. /* Clear the BSS */
  64. memset(__bss_start, 0, __bss_end - __bss_start);
  65. #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
  66. enable_layerscape_ns_access();
  67. #endif
  68. board_init_r(NULL, 0);
  69. }
  70. #endif