soc.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/debug.h>
  7. #include <lib/xlat_tables/xlat_tables_v2.h>
  8. #include <mmio.h>
  9. #include <platform_def.h>
  10. #include <soc.h>
  11. const mmap_region_t plat_rk_mmap[] = {
  12. MAP_REGION_FLAT(RKFPGA_DEV_RNG0_BASE, RKFPGA_DEV_RNG0_SIZE,
  13. MT_DEVICE | MT_RW | MT_SECURE),
  14. MAP_REGION_FLAT(PMUSRAM_BASE, PMUSRAM_SIZE,
  15. MT_MEMORY | MT_RW | MT_SECURE),
  16. { 0 }
  17. };
  18. /* The RockChip power domain tree descriptor */
  19. const unsigned char rockchip_power_domain_tree_desc[] = {
  20. /* No of root nodes */
  21. PLATFORM_SYSTEM_COUNT,
  22. /* No of children for the root node */
  23. PLATFORM_CLUSTER_COUNT,
  24. /* No of children for the first cluster node */
  25. PLATFORM_CLUSTER0_CORE_COUNT,
  26. };
  27. static void secure_timer_init(void)
  28. {
  29. mmio_write_32(STIMER0_CHN_BASE(1) + TIMER_CONTROL_REG, TIMER_DIS);
  30. mmio_write_32(STIMER0_CHN_BASE(1) + TIMER_LOAD_COUNT0, 0xffffffff);
  31. mmio_write_32(STIMER0_CHN_BASE(1) + TIMER_LOAD_COUNT1, 0xffffffff);
  32. /* auto reload & enable the timer */
  33. mmio_write_32(STIMER0_CHN_BASE(1) + TIMER_CONTROL_REG, TIMER_EN);
  34. }
  35. static void sgrf_init(void)
  36. {
  37. mmio_write_32(SGRF_BASE + SGRF_FIREWALL_SLV_CON(0), 0xffff0000);
  38. mmio_write_32(SGRF_BASE + SGRF_FIREWALL_SLV_CON(1), 0xffff0000);
  39. mmio_write_32(SGRF_BASE + SGRF_FIREWALL_SLV_CON(2), 0xffff0000);
  40. mmio_write_32(SGRF_BASE + SGRF_FIREWALL_SLV_CON(3), 0xffff0000);
  41. mmio_write_32(SGRF_BASE + SGRF_FIREWALL_SLV_CON(4), 0xffff0000);
  42. mmio_write_32(SGRF_BASE + SGRF_FIREWALL_SLV_CON(5), 0xffff0000);
  43. mmio_write_32(SGRF_BASE + SGRF_FIREWALL_SLV_CON(6), 0xffff0000);
  44. mmio_write_32(SGRF_BASE + SGRF_FIREWALL_SLV_CON(7), 0xffff0000);
  45. mmio_write_32(SGRF_BASE + SGRF_FIREWALL_SLV_CON(8), 0xffff0000);
  46. mmio_write_32(DDRSGRF_BASE + FIREWALL_DDR_FW_DDR_CON_REG, 0xffff0000);
  47. }
  48. static void set_pll_slow_mode(uint32_t clk_pll)
  49. {
  50. mmio_write_32(CRU_BASE + CRU_MODE_CON00, 0x03 << (16 + clk_pll * 2));
  51. }
  52. static void __dead2 soc_global_soft_reset(void)
  53. {
  54. set_pll_slow_mode(CLK_CPLL);
  55. set_pll_slow_mode(CLK_GPLL);
  56. set_pll_slow_mode(CLK_NPLL);
  57. set_pll_slow_mode(CLK_VPLL);
  58. set_pll_slow_mode(CLK_USBPLL);
  59. set_pll_slow_mode(CLK_APLL);
  60. mmio_write_32(PMUCRU_BASE + PMUCRU_MODE_CON00, 0x000f0000);
  61. dsb();
  62. mmio_write_32(CRU_BASE + CRU_GLB_SRST_FST, GLB_SRST_FST_CFG_VAL);
  63. /*
  64. * Maybe the HW needs some times to reset the system,
  65. * so we do not hope the core to excute valid codes.
  66. */
  67. while (1) {
  68. ;
  69. }
  70. }
  71. static void rockchip_system_reset_init(void)
  72. {
  73. mmio_write_32(GRF_BASE + 0x0508, 0x00100010);
  74. mmio_write_32(CRU_BASE + 0x00dc, 0x01030103);
  75. }
  76. void __dead2 rockchip_soc_soft_reset(void)
  77. {
  78. soc_global_soft_reset();
  79. }
  80. void plat_rockchip_soc_init(void)
  81. {
  82. secure_timer_init();
  83. sgrf_init();
  84. rockchip_system_reset_init();
  85. NOTICE("BL31: Rockchip release version: v%d.%d\n",
  86. MAJOR_VERSION, MINOR_VERSION);
  87. }