cpu.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2016 Nexell
  4. * Hyunseok, Jung <hsjung@nexell.co.kr>
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <asm/system.h>
  9. #include <asm/cache.h>
  10. #include <asm/sections.h>
  11. #include <asm/io.h>
  12. #include <asm/arch/nexell.h>
  13. #include <asm/arch/clk.h>
  14. #include <asm/arch/reset.h>
  15. #include <asm/arch/tieoff.h>
  16. #include <cpu_func.h>
  17. #include <linux/delay.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. #ifndef CONFIG_ARCH_CPU_INIT
  20. #error must be define the macro "CONFIG_ARCH_CPU_INIT"
  21. #endif
  22. void s_init(void)
  23. {
  24. }
  25. static void cpu_soc_init(void)
  26. {
  27. /*
  28. * NOTE> ALIVE Power Gate must enable for Alive register access.
  29. * must be clear wfi jump address
  30. */
  31. writel(1, ALIVEPWRGATEREG);
  32. writel(0xFFFFFFFF, SCR_ARM_SECOND_BOOT);
  33. /* write 0xf0 on alive scratchpad reg for boot success check */
  34. writel(readl(SCR_SIGNAGURE_READ) | 0xF0, (SCR_SIGNAGURE_SET));
  35. /* set l2 cache tieoff */
  36. nx_tieoff_set(NX_TIEOFF_CORTEXA9MP_TOP_QUADL2C_L2RET1N_0, 1);
  37. nx_tieoff_set(NX_TIEOFF_CORTEXA9MP_TOP_QUADL2C_L2RET1N_1, 1);
  38. }
  39. #ifdef CONFIG_PL011_SERIAL
  40. static void serial_device_init(void)
  41. {
  42. char dev[10];
  43. int id;
  44. sprintf(dev, "nx-uart.%d", CONFIG_CONS_INDEX);
  45. id = RESET_ID_UART0 + CONFIG_CONS_INDEX;
  46. struct clk *clk = clk_get((const char *)dev);
  47. /* reset control: Low active ___|--- */
  48. nx_rstcon_setrst(id, RSTCON_ASSERT);
  49. udelay(10);
  50. nx_rstcon_setrst(id, RSTCON_NEGATE);
  51. udelay(10);
  52. /* set clock */
  53. clk_disable(clk);
  54. clk_set_rate(clk, CONFIG_PL011_CLOCK);
  55. clk_enable(clk);
  56. }
  57. #endif
  58. int arch_cpu_init(void)
  59. {
  60. flush_dcache_all();
  61. cpu_soc_init();
  62. clk_init();
  63. if (IS_ENABLED(CONFIG_PL011_SERIAL))
  64. serial_device_init();
  65. return 0;
  66. }
  67. #if defined(CONFIG_DISPLAY_CPUINFO)
  68. int print_cpuinfo(void)
  69. {
  70. return 0;
  71. }
  72. #endif
  73. void reset_cpu(ulong ignored)
  74. {
  75. void *clkpwr_reg = (void *)PHY_BASEADDR_CLKPWR;
  76. const u32 sw_rst_enb_bitpos = 3;
  77. const u32 sw_rst_enb_mask = 1 << sw_rst_enb_bitpos;
  78. const u32 sw_rst_bitpos = 12;
  79. const u32 sw_rst_mask = 1 << sw_rst_bitpos;
  80. int pwrcont = 0x224;
  81. int pwrmode = 0x228;
  82. u32 read_value;
  83. read_value = readl((void *)(clkpwr_reg + pwrcont));
  84. read_value &= ~sw_rst_enb_mask;
  85. read_value |= 1 << sw_rst_enb_bitpos;
  86. writel(read_value, (void *)(clkpwr_reg + pwrcont));
  87. writel(sw_rst_mask, (void *)(clkpwr_reg + pwrmode));
  88. }
  89. void enable_caches(void)
  90. {
  91. /* Enable D-cache. I-cache is already enabled in start.S */
  92. dcache_enable();
  93. }
  94. #if defined(CONFIG_ARCH_MISC_INIT)
  95. int arch_misc_init(void)
  96. {
  97. return 0;
  98. }
  99. #endif /* CONFIG_ARCH_MISC_INIT */