cpu.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * arch/arm/mach-meson6/cpu.c
  3. *
  4. * Copyright (C) 2011-2012 Amlogic, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #include <linux/module.h>
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <plat/io.h>
  24. #include <plat/regops.h>
  25. #include <linux/printk.h>
  26. #include <linux/string.h>
  27. #include <asm/hardware/cache-l2x0.h>
  28. extern void meson6_l2x0_init(void __iomem *);
  29. #ifdef CONFIG_MESON_L2CC_OPTIMIZE
  30. static inline u32 __init read_actlr(void)
  31. {
  32. u32 actlr;
  33. __asm__("mrc p15, 0, %0, c1, c0, 1\n" : "=r" (actlr));
  34. printk(KERN_INFO "===actlr=0x%x\n", actlr);
  35. return actlr;
  36. }
  37. static inline void __init write_actlr(u32 actlr)
  38. {
  39. __asm__("mcr p15, 0, %0, c1, c0, 1\n" : : "r" (actlr));
  40. }
  41. #endif
  42. static void __init meson_cache_init(void)
  43. {
  44. #ifdef CONFIG_CACHE_L2X0
  45. __u32 prefetch, aux;
  46. void __iomem *l2x0_base;
  47. /*
  48. * Early BRESP, I/D prefetch enabled
  49. * Shared attribute override enabled
  50. * Full line of zero enabled
  51. */
  52. // l2x0_init((void __iomem *)IO_PL310_BASE, ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) |
  53. // (0x1 << 25) |
  54. // (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
  55. // (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT))|(0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT), L2X0_AUX_CTRL_MASK);
  56. // (3<<28)|(3<<26) | (1<<11) |(1<<10)|(1<<13)|(1<<22), ~0);
  57. l2x0_base=(void __iomem *)IO_PL310_BASE;
  58. #ifdef CONFIG_MESON_L2CC_OPTIMIZE
  59. l2x0_init(l2x0_base, ((1<<L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) | (1<<L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
  60. (1<<L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT) | (1<<L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
  61. (1<<L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | (1<<L2X0_AUX_CTRL_SHARE_INVALID_SHIFT) |
  62. (1<<L2X0_AUX_CTRL_STORE_BUFFER_LIMIT_SHIFT) |
  63. (1<<L2X0_AUX_CTRL_HIGH_PRIORITY_SO_DEVICE_SHIFT) | (1<<0)), ~0);
  64. #else
  65. l2x0_init(l2x0_base, ((1<<L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) | (1<<L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
  66. (1<<L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT) | (1<<L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
  67. (1<<L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | (1<<L2X0_AUX_CTRL_SHARE_INVALID_SHIFT) |
  68. (1<<L2X0_AUX_CTRL_STORE_BUFFER_LIMIT_SHIFT) |
  69. (1<<L2X0_AUX_CTRL_HIGH_PRIORITY_SO_DEVICE_SHIFT)), ~0);
  70. #endif
  71. prefetch = readl_relaxed(l2x0_base+ L2X0_PREFETCH_CTRL);
  72. /* prefetch 1+6 lines over */
  73. prefetch |= 0x6;
  74. #ifdef CONFIG_SMP
  75. prefetch |= (1<<28) | (1<<29);
  76. #ifdef CONFIG_MESON_L2CC_OPTIMIZE
  77. prefetch |= (1<<24);
  78. #endif
  79. writel_relaxed(prefetch, l2x0_base + L2X0_PREFETCH_CTRL);
  80. #else
  81. prefetch |= (1<<30) | (1<<24) | (1<<28) | (1<<29);
  82. writel_relaxed(prefetch, l2x0_base + L2X0_PREFETCH_CTRL);
  83. #endif
  84. #ifdef CONFIG_MESON_L2CC_OPTIMIZE
  85. write_actlr((read_actlr()|(1<<3)));
  86. read_actlr();
  87. aux=readl_relaxed(l2x0_base+ L2X0_AUX_CTRL);
  88. prefetch=readl_relaxed(l2x0_base+ L2X0_PREFETCH_CTRL);
  89. printk("pl310: aux=0x%x, prefetch=0x%x\n", aux, prefetch);
  90. #endif
  91. #endif
  92. }
  93. early_initcall(meson_cache_init);
  94. int mali_revb_flag = -1;
  95. //int mali_version(void)
  96. EXPORT_SYMBOL_GPL(mali_revb_flag);
  97. static int __init maliversion(char *str)
  98. {
  99. mali_revb_flag=-1;
  100. if(strncasecmp(str,"a",1)==0)
  101. mali_revb_flag = 0;
  102. else if(strncasecmp(str,"b",1)==0)
  103. mali_revb_flag = 1;
  104. return 1;
  105. }
  106. __setup("mali_version=",maliversion);