cpu.c 3.5 KB

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