spl.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. clrsetbits_le32(TAMP_BOOT_CONTEXT,
  15. TAMP_BOOT_MODE_MASK,
  16. boot_mode << TAMP_BOOT_MODE_SHIFT);
  17. switch (boot_mode) {
  18. case BOOT_FLASH_SD_1:
  19. case BOOT_FLASH_EMMC_1:
  20. return BOOT_DEVICE_MMC1;
  21. case BOOT_FLASH_SD_2:
  22. case BOOT_FLASH_EMMC_2:
  23. return BOOT_DEVICE_MMC2;
  24. }
  25. return BOOT_DEVICE_MMC1;
  26. }
  27. u32 spl_boot_mode(const u32 boot_device)
  28. {
  29. return MMCSD_MODE_RAW;
  30. }
  31. int spl_boot_partition(const u32 boot_device)
  32. {
  33. switch (boot_device) {
  34. case BOOT_DEVICE_MMC1:
  35. return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
  36. case BOOT_DEVICE_MMC2:
  37. return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2;
  38. default:
  39. return -EINVAL;
  40. }
  41. }
  42. void board_init_f(ulong dummy)
  43. {
  44. struct udevice *dev;
  45. int ret;
  46. arch_cpu_init();
  47. ret = spl_early_init();
  48. if (ret) {
  49. debug("spl_early_init() failed: %d\n", ret);
  50. hang();
  51. }
  52. ret = uclass_get_device(UCLASS_CLK, 0, &dev);
  53. if (ret) {
  54. debug("Clock init failed: %d\n", ret);
  55. return;
  56. }
  57. ret = uclass_get_device(UCLASS_RESET, 0, &dev);
  58. if (ret) {
  59. debug("Reset init failed: %d\n", ret);
  60. return;
  61. }
  62. ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
  63. if (ret) {
  64. debug("%s: Cannot find pinctrl device\n", __func__);
  65. return;
  66. }
  67. /* enable console uart printing */
  68. preloader_console_init();
  69. ret = uclass_get_device(UCLASS_RAM, 0, &dev);
  70. if (ret) {
  71. debug("DRAM init failed: %d\n", ret);
  72. return;
  73. }
  74. }