omap4-common.c 4.5 KB

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