omap4-common.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 "common.h"
  22. #ifdef CONFIG_CACHE_L2X0
  23. static void __iomem *l2cache_base;
  24. #endif
  25. void __init gic_init_irq(void)
  26. {
  27. void __iomem *omap_irq_base;
  28. void __iomem *gic_dist_base_addr;
  29. /* Static mapping, never released */
  30. gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K);
  31. BUG_ON(!gic_dist_base_addr);
  32. /* Static mapping, never released */
  33. omap_irq_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512);
  34. BUG_ON(!omap_irq_base);
  35. gic_init(0, 29, gic_dist_base_addr, omap_irq_base);
  36. }
  37. #ifdef CONFIG_CACHE_L2X0
  38. void __iomem *omap4_get_l2cache_base(void)
  39. {
  40. return l2cache_base;
  41. }
  42. static void omap4_l2x0_disable(void)
  43. {
  44. /* Disable PL310 L2 Cache controller */
  45. omap_smc1(0x102, 0x0);
  46. }
  47. static void omap4_l2x0_set_debug(unsigned long val)
  48. {
  49. /* Program PL310 L2 Cache controller debug register */
  50. omap_smc1(0x100, val);
  51. }
  52. static int __init omap_l2_cache_init(void)
  53. {
  54. u32 aux_ctrl = 0;
  55. /*
  56. * To avoid code running on other OMAPs in
  57. * multi-omap builds
  58. */
  59. if (!cpu_is_omap44xx())
  60. return -ENODEV;
  61. /* Static mapping, never released */
  62. l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
  63. if (WARN_ON(!l2cache_base))
  64. return -ENOMEM;
  65. /*
  66. * 16-way associativity, parity disabled
  67. * Way size - 32KB (es1.0)
  68. * Way size - 64KB (es2.0 +)
  69. */
  70. aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) |
  71. (0x1 << 25) |
  72. (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
  73. (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT));
  74. if (omap_rev() == OMAP4430_REV_ES1_0) {
  75. aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT;
  76. } else {
  77. aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) |
  78. (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) |
  79. (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
  80. (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) |
  81. (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT));
  82. }
  83. if (omap_rev() != OMAP4430_REV_ES1_0)
  84. omap_smc1(0x109, aux_ctrl);
  85. /* Enable PL310 L2 Cache controller */
  86. omap_smc1(0x102, 0x1);
  87. l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK);
  88. /*
  89. * Override default outer_cache.disable with a OMAP4
  90. * specific one
  91. */
  92. outer_cache.disable = omap4_l2x0_disable;
  93. outer_cache.set_debug = omap4_l2x0_set_debug;
  94. return 0;
  95. }
  96. early_initcall(omap_l2_cache_init);
  97. #endif