cpu.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
  5. * License terms: GNU General Public License (GPL) version 2
  6. */
  7. #include <linux/platform_device.h>
  8. #include <linux/io.h>
  9. #include <linux/clk.h>
  10. #include <asm/cacheflush.h>
  11. #include <asm/hardware/cache-l2x0.h>
  12. #include <asm/hardware/gic.h>
  13. #include <asm/mach/map.h>
  14. #include <asm/localtimer.h>
  15. #include <plat/mtu.h>
  16. #include <mach/hardware.h>
  17. #include <mach/setup.h>
  18. #include <mach/devices.h>
  19. #include <mach/prcmu.h>
  20. #include "clock.h"
  21. #ifdef CONFIG_CACHE_L2X0
  22. static void __iomem *l2x0_base;
  23. #endif
  24. void __init ux500_init_irq(void)
  25. {
  26. void __iomem *dist_base;
  27. void __iomem *cpu_base;
  28. if (cpu_is_u5500()) {
  29. dist_base = __io_address(U5500_GIC_DIST_BASE);
  30. cpu_base = __io_address(U5500_GIC_CPU_BASE);
  31. } else if (cpu_is_u8500()) {
  32. dist_base = __io_address(U8500_GIC_DIST_BASE);
  33. cpu_base = __io_address(U8500_GIC_CPU_BASE);
  34. } else
  35. ux500_unknown_soc();
  36. gic_init(0, 29, dist_base, cpu_base);
  37. /*
  38. * Init clocks here so that they are available for system timer
  39. * initialization.
  40. */
  41. if (cpu_is_u8500())
  42. prcmu_early_init();
  43. clk_init();
  44. }
  45. #ifdef CONFIG_CACHE_L2X0
  46. static inline void ux500_cache_wait(void __iomem *reg, unsigned long mask)
  47. {
  48. /* wait for the operation to complete */
  49. while (readl_relaxed(reg) & mask)
  50. ;
  51. }
  52. static inline void ux500_cache_sync(void)
  53. {
  54. void __iomem *base = l2x0_base;
  55. writel_relaxed(0, base + L2X0_CACHE_SYNC);
  56. ux500_cache_wait(base + L2X0_CACHE_SYNC, 1);
  57. }
  58. /*
  59. * The L2 cache cannot be turned off in the non-secure world.
  60. * Dummy until a secure service is in place.
  61. */
  62. static void ux500_l2x0_disable(void)
  63. {
  64. }
  65. /*
  66. * This is only called when doing a kexec, just after turning off the L2
  67. * and L1 cache, and it is surrounded by a spinlock in the generic version.
  68. * However, we're not really turning off the L2 cache right now and the
  69. * PL310 does not support exclusive accesses (used to implement the spinlock).
  70. * So, the invalidation needs to be done without the spinlock.
  71. */
  72. static void ux500_l2x0_inv_all(void)
  73. {
  74. void __iomem *base = l2x0_base;
  75. uint32_t l2x0_way_mask = (1<<16) - 1; /* Bitmask of active ways */
  76. /* invalidate all ways */
  77. writel_relaxed(l2x0_way_mask, base + L2X0_INV_WAY);
  78. ux500_cache_wait(base + L2X0_INV_WAY, l2x0_way_mask);
  79. ux500_cache_sync();
  80. }
  81. static int ux500_l2x0_init(void)
  82. {
  83. if (cpu_is_u5500())
  84. l2x0_base = __io_address(U5500_L2CC_BASE);
  85. else if (cpu_is_u8500())
  86. l2x0_base = __io_address(U8500_L2CC_BASE);
  87. else
  88. ux500_unknown_soc();
  89. /* 64KB way size, 8 way associativity, force WA */
  90. l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
  91. /* Override invalidate function */
  92. outer_cache.disable = ux500_l2x0_disable;
  93. outer_cache.inv_all = ux500_l2x0_inv_all;
  94. return 0;
  95. }
  96. early_initcall(ux500_l2x0_init);
  97. #endif
  98. static void __init ux500_timer_init(void)
  99. {
  100. #ifdef CONFIG_LOCAL_TIMERS
  101. /* Setup the local timer base */
  102. if (cpu_is_u5500())
  103. twd_base = __io_address(U5500_TWD_BASE);
  104. else if (cpu_is_u8500())
  105. twd_base = __io_address(U8500_TWD_BASE);
  106. else
  107. ux500_unknown_soc();
  108. #endif
  109. if (cpu_is_u5500())
  110. mtu_base = __io_address(U5500_MTU0_BASE);
  111. else if (cpu_is_u8500ed())
  112. mtu_base = __io_address(U8500_MTU0_BASE_ED);
  113. else if (cpu_is_u8500())
  114. mtu_base = __io_address(U8500_MTU0_BASE);
  115. else
  116. ux500_unknown_soc();
  117. nmdk_timer_init();
  118. }
  119. struct sys_timer ux500_timer = {
  120. .init = ux500_timer_init,
  121. };