cpu.c 3.4 KB

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