omap4-common.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 <asm/hardware/gic.h>
  18. #include <asm/hardware/cache-l2x0.h>
  19. #include <plat/irqs.h>
  20. #include <mach/hardware.h>
  21. #include <mach/omap-wakeupgen.h>
  22. #include "common.h"
  23. #include "omap4-sar-layout.h"
  24. #ifdef CONFIG_CACHE_L2X0
  25. static void __iomem *l2cache_base;
  26. #endif
  27. static void __iomem *sar_ram_base;
  28. void __init gic_init_irq(void)
  29. {
  30. void __iomem *omap_irq_base;
  31. void __iomem *gic_dist_base_addr;
  32. /* Static mapping, never released */
  33. gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K);
  34. BUG_ON(!gic_dist_base_addr);
  35. /* Static mapping, never released */
  36. omap_irq_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512);
  37. BUG_ON(!omap_irq_base);
  38. omap_wakeupgen_init();
  39. gic_init(0, 29, gic_dist_base_addr, omap_irq_base);
  40. }
  41. #ifdef CONFIG_CACHE_L2X0
  42. void __iomem *omap4_get_l2cache_base(void)
  43. {
  44. return l2cache_base;
  45. }
  46. static void omap4_l2x0_disable(void)
  47. {
  48. /* Disable PL310 L2 Cache controller */
  49. omap_smc1(0x102, 0x0);
  50. }
  51. static void omap4_l2x0_set_debug(unsigned long val)
  52. {
  53. /* Program PL310 L2 Cache controller debug register */
  54. omap_smc1(0x100, val);
  55. }
  56. static int __init omap_l2_cache_init(void)
  57. {
  58. u32 aux_ctrl = 0;
  59. /*
  60. * To avoid code running on other OMAPs in
  61. * multi-omap builds
  62. */
  63. if (!cpu_is_omap44xx())
  64. return -ENODEV;
  65. /* Static mapping, never released */
  66. l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
  67. if (WARN_ON(!l2cache_base))
  68. return -ENOMEM;
  69. /*
  70. * 16-way associativity, parity disabled
  71. * Way size - 32KB (es1.0)
  72. * Way size - 64KB (es2.0 +)
  73. */
  74. aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) |
  75. (0x1 << 25) |
  76. (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
  77. (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT));
  78. if (omap_rev() == OMAP4430_REV_ES1_0) {
  79. aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT;
  80. } else {
  81. aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) |
  82. (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) |
  83. (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
  84. (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) |
  85. (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT));
  86. }
  87. if (omap_rev() != OMAP4430_REV_ES1_0)
  88. omap_smc1(0x109, aux_ctrl);
  89. /* Enable PL310 L2 Cache controller */
  90. omap_smc1(0x102, 0x1);
  91. l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK);
  92. /*
  93. * Override default outer_cache.disable with a OMAP4
  94. * specific one
  95. */
  96. outer_cache.disable = omap4_l2x0_disable;
  97. outer_cache.set_debug = omap4_l2x0_set_debug;
  98. return 0;
  99. }
  100. early_initcall(omap_l2_cache_init);
  101. #endif
  102. void __iomem *omap4_get_sar_ram_base(void)
  103. {
  104. return sar_ram_base;
  105. }
  106. /*
  107. * SAR RAM used to save and restore the HW
  108. * context in low power modes
  109. */
  110. static int __init omap4_sar_ram_init(void)
  111. {
  112. /*
  113. * To avoid code running on other OMAPs in
  114. * multi-omap builds
  115. */
  116. if (!cpu_is_omap44xx())
  117. return -ENOMEM;
  118. /* Static mapping, never released */
  119. sar_ram_base = ioremap(OMAP44XX_SAR_RAM_BASE, SZ_16K);
  120. if (WARN_ON(!sar_ram_base))
  121. return -ENOMEM;
  122. return 0;
  123. }
  124. early_initcall(omap4_sar_ram_init);