omap4-common.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * OMAP4 specific common source file.
  3. *
  4. * Copyright (C) 2010 Texas Instruments, Inc.
  5. * Author:
  6. * Santosh Shilimkar <santosh.shilimkar@ti.com>
  7. *
  8. *
  9. * This program is free software,you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/io.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/memblock.h>
  18. #include <asm/hardware/gic.h>
  19. #include <asm/hardware/cache-l2x0.h>
  20. #include <asm/mach/map.h>
  21. #include <asm/memblock.h>
  22. #include <plat/irqs.h>
  23. #include <plat/sram.h>
  24. #include <plat/omap-secure.h>
  25. #include <mach/hardware.h>
  26. #include <mach/omap-wakeupgen.h>
  27. #include "common.h"
  28. #include "omap4-sar-layout.h"
  29. #ifdef CONFIG_CACHE_L2X0
  30. static void __iomem *l2cache_base;
  31. #endif
  32. static void __iomem *sar_ram_base;
  33. #ifdef CONFIG_OMAP4_ERRATA_I688
  34. /* Used to implement memory barrier on DRAM path */
  35. #define OMAP4_DRAM_BARRIER_VA 0xfe600000
  36. void __iomem *dram_sync, *sram_sync;
  37. static phys_addr_t paddr;
  38. static u32 size;
  39. void omap_bus_sync(void)
  40. {
  41. if (dram_sync && sram_sync) {
  42. writel_relaxed(readl_relaxed(dram_sync), dram_sync);
  43. writel_relaxed(readl_relaxed(sram_sync), sram_sync);
  44. isb();
  45. }
  46. }
  47. /* Steal one page physical memory for barrier implementation */
  48. int __init omap_barrier_reserve_memblock(void)
  49. {
  50. size = ALIGN(PAGE_SIZE, SZ_1M);
  51. paddr = arm_memblock_steal(size, SZ_1M);
  52. return 0;
  53. }
  54. void __init omap_barriers_init(void)
  55. {
  56. struct map_desc dram_io_desc[1];
  57. dram_io_desc[0].virtual = OMAP4_DRAM_BARRIER_VA;
  58. dram_io_desc[0].pfn = __phys_to_pfn(paddr);
  59. dram_io_desc[0].length = size;
  60. dram_io_desc[0].type = MT_MEMORY_SO;
  61. iotable_init(dram_io_desc, ARRAY_SIZE(dram_io_desc));
  62. dram_sync = (void __iomem *) dram_io_desc[0].virtual;
  63. sram_sync = (void __iomem *) OMAP4_SRAM_VA;
  64. pr_info("OMAP4: Map 0x%08llx to 0x%08lx for dram barrier\n",
  65. (long long) paddr, dram_io_desc[0].virtual);
  66. }
  67. #else
  68. void __init omap_barriers_init(void)
  69. {}
  70. #endif
  71. void __init gic_init_irq(void)
  72. {
  73. void __iomem *omap_irq_base;
  74. void __iomem *gic_dist_base_addr;
  75. /* Static mapping, never released */
  76. gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K);
  77. BUG_ON(!gic_dist_base_addr);
  78. /* Static mapping, never released */
  79. omap_irq_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512);
  80. BUG_ON(!omap_irq_base);
  81. omap_wakeupgen_init();
  82. gic_init(0, 29, gic_dist_base_addr, omap_irq_base);
  83. }
  84. #ifdef CONFIG_CACHE_L2X0
  85. void __iomem *omap4_get_l2cache_base(void)
  86. {
  87. return l2cache_base;
  88. }
  89. static void omap4_l2x0_disable(void)
  90. {
  91. /* Disable PL310 L2 Cache controller */
  92. omap_smc1(0x102, 0x0);
  93. }
  94. static void omap4_l2x0_set_debug(unsigned long val)
  95. {
  96. /* Program PL310 L2 Cache controller debug register */
  97. omap_smc1(0x100, val);
  98. }
  99. static int __init omap_l2_cache_init(void)
  100. {
  101. u32 aux_ctrl = 0;
  102. /*
  103. * To avoid code running on other OMAPs in
  104. * multi-omap builds
  105. */
  106. if (!cpu_is_omap44xx())
  107. return -ENODEV;
  108. /* Static mapping, never released */
  109. l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
  110. if (WARN_ON(!l2cache_base))
  111. return -ENOMEM;
  112. /*
  113. * 16-way associativity, parity disabled
  114. * Way size - 32KB (es1.0)
  115. * Way size - 64KB (es2.0 +)
  116. */
  117. aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) |
  118. (0x1 << 25) |
  119. (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
  120. (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT));
  121. if (omap_rev() == OMAP4430_REV_ES1_0) {
  122. aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT;
  123. } else {
  124. aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) |
  125. (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) |
  126. (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
  127. (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) |
  128. (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT));
  129. }
  130. if (omap_rev() != OMAP4430_REV_ES1_0)
  131. omap_smc1(0x109, aux_ctrl);
  132. /* Enable PL310 L2 Cache controller */
  133. omap_smc1(0x102, 0x1);
  134. l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK);
  135. /*
  136. * Override default outer_cache.disable with a OMAP4
  137. * specific one
  138. */
  139. outer_cache.disable = omap4_l2x0_disable;
  140. outer_cache.set_debug = omap4_l2x0_set_debug;
  141. return 0;
  142. }
  143. early_initcall(omap_l2_cache_init);
  144. #endif
  145. void __iomem *omap4_get_sar_ram_base(void)
  146. {
  147. return sar_ram_base;
  148. }
  149. /*
  150. * SAR RAM used to save and restore the HW
  151. * context in low power modes
  152. */
  153. static int __init omap4_sar_ram_init(void)
  154. {
  155. /*
  156. * To avoid code running on other OMAPs in
  157. * multi-omap builds
  158. */
  159. if (!cpu_is_omap44xx())
  160. return -ENOMEM;
  161. /* Static mapping, never released */
  162. sar_ram_base = ioremap(OMAP44XX_SAR_RAM_BASE, SZ_16K);
  163. if (WARN_ON(!sar_ram_base))
  164. return -ENOMEM;
  165. return 0;
  166. }
  167. early_initcall(omap4_sar_ram_init);