cpu.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #include <common.h>
  2. #include <asm/arch/clock.h>
  3. #include <asm/io.h>
  4. #include <asm/pl310.h>
  5. int arch_cpu_init(void)
  6. {
  7. return ark_clock_init();
  8. }
  9. static void enable_ca7_smp(void)
  10. {
  11. u32 val;
  12. /* Read MIDR */
  13. asm volatile ("mrc p15, 0, %0, c0, c0, 0\n\t" : "=r"(val));
  14. val = (val >> 4);
  15. val &= 0xf;
  16. /* Only set the SMP for Cortex A7 */
  17. if (val == 0x7) {
  18. /* Read auxiliary control register */
  19. asm volatile ("mrc p15, 0, %0, c1, c0, 1\n\t" : "=r"(val));
  20. if (val & (1 << 6))
  21. return;
  22. /* Enable SMP */
  23. val |= (1 << 6);
  24. /* Write auxiliary control register */
  25. asm volatile ("mcr p15, 0, %0, c1, c0, 1\n\t" : : "r"(val));
  26. DSB;
  27. ISB;
  28. }
  29. }
  30. void enable_caches(void)
  31. {
  32. /* Avoid random hang when download by usb */
  33. invalidate_dcache_all();
  34. /* Set ACTLR.SMP bit for Cortex-A7 */
  35. enable_ca7_smp();
  36. icache_enable();
  37. dcache_enable();
  38. }
  39. #ifndef CONFIG_SYS_L2CACHE_OFF
  40. #ifdef CONFIG_SYS_L2_PL310
  41. void v7_outer_cache_enable(void)
  42. {
  43. struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE;
  44. unsigned int val;
  45. /*
  46. * Must disable the L2 before changing the latency parameters
  47. * and auxiliary control register.
  48. */
  49. clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
  50. /*
  51. * Set bit 22 in the auxiliary control register. If this bit
  52. * is cleared, PL310 treats Normal Shared Non-cacheable
  53. * accesses as Cacheable no-allocate.
  54. */
  55. setbits_le32(&pl310->pl310_aux_ctrl, L310_SHARED_ATT_OVERRIDE_ENABLE);
  56. writel(0x132, &pl310->pl310_tag_latency_ctrl);
  57. writel(0x132, &pl310->pl310_data_latency_ctrl);
  58. val = readl(&pl310->pl310_prefetch_ctrl);
  59. /* Turn on the L2 I/D prefetch */
  60. val |= 0x30000000;
  61. writel(val, &pl310->pl310_prefetch_ctrl);
  62. val = readl(&pl310->pl310_power_ctrl);
  63. val |= L2X0_DYNAMIC_CLK_GATING_EN;
  64. val |= L2X0_STNDBY_MODE_EN;
  65. writel(val, &pl310->pl310_power_ctrl);
  66. setbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
  67. }
  68. void v7_outer_cache_disable(void)
  69. {
  70. struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE;
  71. clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
  72. }
  73. #endif /* !CONFIG_SYS_L2_PL310 */
  74. #endif /* !CONFIG_SYS_L2CACHE_OFF */