spl.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
  2. /*
  3. * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <spl.h>
  8. #include <asm/io.h>
  9. u32 spl_boot_device(void)
  10. {
  11. u32 boot_mode;
  12. boot_mode = (readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_MODE_MASK) >>
  13. TAMP_BOOT_MODE_SHIFT;
  14. switch (boot_mode) {
  15. case BOOT_FLASH_SD_1:
  16. case BOOT_FLASH_EMMC_1:
  17. return BOOT_DEVICE_MMC1;
  18. case BOOT_FLASH_SD_2:
  19. case BOOT_FLASH_EMMC_2:
  20. return BOOT_DEVICE_MMC2;
  21. }
  22. return BOOT_DEVICE_MMC1;
  23. }
  24. u32 spl_boot_mode(const u32 boot_device)
  25. {
  26. return MMCSD_MODE_RAW;
  27. }
  28. int spl_boot_partition(const u32 boot_device)
  29. {
  30. switch (boot_device) {
  31. case BOOT_DEVICE_MMC1:
  32. return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
  33. case BOOT_DEVICE_MMC2:
  34. return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2;
  35. default:
  36. return -EINVAL;
  37. }
  38. }
  39. void board_init_f(ulong dummy)
  40. {
  41. struct udevice *dev;
  42. int ret;
  43. arch_cpu_init();
  44. ret = spl_early_init();
  45. if (ret) {
  46. debug("spl_early_init() failed: %d\n", ret);
  47. hang();
  48. }
  49. ret = uclass_get_device(UCLASS_CLK, 0, &dev);
  50. if (ret) {
  51. debug("Clock init failed: %d\n", ret);
  52. return;
  53. }
  54. ret = uclass_get_device(UCLASS_RESET, 0, &dev);
  55. if (ret) {
  56. debug("Reset init failed: %d\n", ret);
  57. return;
  58. }
  59. ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
  60. if (ret) {
  61. debug("%s: Cannot find pinctrl device\n", __func__);
  62. return;
  63. }
  64. /* enable console uart printing */
  65. preloader_console_init();
  66. ret = uclass_get_device(UCLASS_RAM, 0, &dev);
  67. if (ret) {
  68. debug("DRAM init failed: %d\n", ret);
  69. return;
  70. }
  71. }