platform_common.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (c) 2015-2020, Broadcom
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch_helpers.h>
  7. #include <common/debug.h>
  8. #include <drivers/brcm/sotp.h>
  9. #include <cmn_plat_util.h>
  10. #include <platform_def.h>
  11. uint32_t boot_source_get(void)
  12. {
  13. uint32_t data;
  14. #ifdef FORCE_BOOTSOURCE
  15. data = FORCE_BOOTSOURCE;
  16. #else
  17. /* Read primary boot strap from CRMU persistent registers */
  18. data = mmio_read_32(CRMU_IHOST_SW_PERSISTENT_REG1);
  19. if (data & BOOT_SOURCE_SOFT_ENABLE_MASK) {
  20. data >>= BOOT_SOURCE_SOFT_DATA_OFFSET;
  21. } else {
  22. uint64_t sotp_atf_row;
  23. sotp_atf_row =
  24. sotp_mem_read(SOTP_ATF_CFG_ROW_ID, SOTP_ROW_NO_ECC);
  25. if (sotp_atf_row & SOTP_BOOT_SOURCE_ENABLE_MASK) {
  26. /* Construct the boot source based on SOTP bits */
  27. data = 0;
  28. if (sotp_atf_row & SOTP_BOOT_SOURCE_BITS0)
  29. data |= 0x1;
  30. if (sotp_atf_row & SOTP_BOOT_SOURCE_BITS1)
  31. data |= 0x2;
  32. if (sotp_atf_row & SOTP_BOOT_SOURCE_BITS2)
  33. data |= 0x4;
  34. } else {
  35. /*
  36. * This path is for L0 reset with
  37. * Primary Boot source disabled in SOTP.
  38. * BOOT_SOURCE_FROM_PR_ON_L1 compile flag will allow
  39. * to never come back here so that the
  40. * external straps will not be read on L1 reset.
  41. */
  42. /* Use the external straps */
  43. data = mmio_read_32(ROM_S0_IDM_IO_STATUS);
  44. #ifdef BOOT_SOURCE_FROM_PR_ON_L1
  45. /* Enable boot source read from PR#1 */
  46. mmio_setbits_32(CRMU_IHOST_SW_PERSISTENT_REG1,
  47. BOOT_SOURCE_SOFT_ENABLE_MASK);
  48. /* set boot source */
  49. data &= BOOT_SOURCE_MASK;
  50. mmio_clrsetbits_32(CRMU_IHOST_SW_PERSISTENT_REG1,
  51. BOOT_SOURCE_MASK << BOOT_SOURCE_SOFT_DATA_OFFSET,
  52. data << BOOT_SOURCE_SOFT_DATA_OFFSET);
  53. #endif
  54. }
  55. }
  56. #endif
  57. return (data & BOOT_SOURCE_MASK);
  58. }
  59. void __dead2 plat_soft_reset(uint32_t reset)
  60. {
  61. if (reset == SOFT_RESET_L3) {
  62. mmio_setbits_32(CRMU_IHOST_SW_PERSISTENT_REG1, reset);
  63. mmio_write_32(CRMU_MAIL_BOX0, 0x0);
  64. mmio_write_32(CRMU_MAIL_BOX1, 0xFFFFFFFF);
  65. }
  66. if (reset != SOFT_SYS_RESET_L1)
  67. reset = SOFT_PWR_UP_RESET_L0;
  68. if (reset == SOFT_PWR_UP_RESET_L0)
  69. INFO("L0 RESET...\n");
  70. if (reset == SOFT_SYS_RESET_L1)
  71. INFO("L1 RESET...\n");
  72. console_flush();
  73. mmio_clrbits_32(CRMU_SOFT_RESET_CTRL, 1 << reset);
  74. while (1) {
  75. ;
  76. }
  77. }