omap4-common.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. #include <linux/export.h>
  30. #ifdef CONFIG_CACHE_L2X0
  31. static void __iomem *l2cache_base;
  32. #endif
  33. static void __iomem *sar_ram_base;
  34. #ifdef CONFIG_OMAP4_ERRATA_I688
  35. /* Used to implement memory barrier on DRAM path */
  36. #define OMAP4_DRAM_BARRIER_VA 0xfe600000
  37. void __iomem *dram_sync, *sram_sync;
  38. static phys_addr_t paddr;
  39. static u32 size;
  40. void omap_bus_sync(void)
  41. {
  42. if (dram_sync && sram_sync) {
  43. writel_relaxed(readl_relaxed(dram_sync), dram_sync);
  44. writel_relaxed(readl_relaxed(sram_sync), sram_sync);
  45. isb();
  46. }
  47. }
  48. EXPORT_SYMBOL(omap_bus_sync);
  49. /* Steal one page physical memory for barrier implementation */
  50. int __init omap_barrier_reserve_memblock(void)
  51. {
  52. size = ALIGN(PAGE_SIZE, SZ_1M);
  53. paddr = arm_memblock_steal(size, SZ_1M);
  54. return 0;
  55. }
  56. void __init omap_barriers_init(void)
  57. {
  58. struct map_desc dram_io_desc[1];
  59. dram_io_desc[0].virtual = OMAP4_DRAM_BARRIER_VA;
  60. dram_io_desc[0].pfn = __phys_to_pfn(paddr);
  61. dram_io_desc[0].length = size;
  62. dram_io_desc[0].type = MT_MEMORY_SO;
  63. iotable_init(dram_io_desc, ARRAY_SIZE(dram_io_desc));
  64. dram_sync = (void __iomem *) dram_io_desc[0].virtual;
  65. sram_sync = (void __iomem *) OMAP4_SRAM_VA;
  66. pr_info("OMAP4: Map 0x%08llx to 0x%08lx for dram barrier\n",
  67. (long long) paddr, dram_io_desc[0].virtual);
  68. }
  69. #else
  70. void __init omap_barriers_init(void)
  71. {}
  72. #endif
  73. void __init gic_init_irq(void)
  74. {
  75. void __iomem *omap_irq_base;
  76. void __iomem *gic_dist_base_addr;
  77. /* Static mapping, never released */
  78. gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K);
  79. BUG_ON(!gic_dist_base_addr);
  80. /* Static mapping, never released */
  81. omap_irq_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512);
  82. BUG_ON(!omap_irq_base);
  83. omap_wakeupgen_init();
  84. gic_init(0, 29, gic_dist_base_addr, omap_irq_base);
  85. }
  86. #ifdef CONFIG_CACHE_L2X0
  87. void __iomem *omap4_get_l2cache_base(void)
  88. {
  89. return l2cache_base;
  90. }
  91. static void omap4_l2x0_disable(void)
  92. {
  93. /* Disable PL310 L2 Cache controller */
  94. omap_smc1(0x102, 0x0);
  95. }
  96. static void omap4_l2x0_set_debug(unsigned long val)
  97. {
  98. /* Program PL310 L2 Cache controller debug register */
  99. omap_smc1(0x100, val);
  100. }
  101. static int __init omap_l2_cache_init(void)
  102. {
  103. u32 aux_ctrl = 0;
  104. /*
  105. * To avoid code running on other OMAPs in
  106. * multi-omap builds
  107. */
  108. if (!cpu_is_omap44xx())
  109. return -ENODEV;
  110. /* Static mapping, never released */
  111. l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
  112. if (WARN_ON(!l2cache_base))
  113. return -ENOMEM;
  114. /*
  115. * 16-way associativity, parity disabled
  116. * Way size - 32KB (es1.0)
  117. * Way size - 64KB (es2.0 +)
  118. */
  119. aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) |
  120. (0x1 << 25) |
  121. (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
  122. (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT));
  123. if (omap_rev() == OMAP4430_REV_ES1_0) {
  124. aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT;
  125. } else {
  126. aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) |
  127. (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) |
  128. (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
  129. (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) |
  130. (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT));
  131. }
  132. if (omap_rev() != OMAP4430_REV_ES1_0)
  133. omap_smc1(0x109, aux_ctrl);
  134. /* Enable PL310 L2 Cache controller */
  135. omap_smc1(0x102, 0x1);
  136. l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK);
  137. /*
  138. * Override default outer_cache.disable with a OMAP4
  139. * specific one
  140. */
  141. outer_cache.disable = omap4_l2x0_disable;
  142. outer_cache.set_debug = omap4_l2x0_set_debug;
  143. return 0;
  144. }
  145. early_initcall(omap_l2_cache_init);
  146. #endif
  147. void __iomem *omap4_get_sar_ram_base(void)
  148. {
  149. return sar_ram_base;
  150. }
  151. /*
  152. * SAR RAM used to save and restore the HW
  153. * context in low power modes
  154. */
  155. static int __init omap4_sar_ram_init(void)
  156. {
  157. /*
  158. * To avoid code running on other OMAPs in
  159. * multi-omap builds
  160. */
  161. if (!cpu_is_omap44xx())
  162. return -ENOMEM;
  163. /* Static mapping, never released */
  164. sar_ram_base = ioremap(OMAP44XX_SAR_RAM_BASE, SZ_16K);
  165. if (WARN_ON(!sar_ram_base))
  166. return -ENOMEM;
  167. return 0;
  168. }
  169. early_initcall(omap4_sar_ram_init);