cache.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * (C) Copyright 2008 Texas Insturments
  3. *
  4. * (C) Copyright 2002
  5. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  6. * Marius Groeger <mgroeger@sysgo.de>
  7. *
  8. * (C) Copyright 2002
  9. * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. /*
  30. * omap3 L2 cache code
  31. */
  32. #include <common.h>
  33. #include <asm/arch/sys_proto.h>
  34. #include <asm/cache.h>
  35. void l2_cache_enable(void)
  36. {
  37. unsigned long i;
  38. volatile unsigned int j;
  39. /* ES2 onwards we can disable/enable L2 ourselves */
  40. if (get_cpu_rev() >= CPU_3XX_ES20) {
  41. __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
  42. __asm__ __volatile__("orr %0, %0, #0x2":"=r"(i));
  43. __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
  44. } else {
  45. /* Save r0, r12 and restore them after usage */
  46. __asm__ __volatile__("mov %0, r12":"=r"(j));
  47. __asm__ __volatile__("mov %0, r0":"=r"(i));
  48. /*
  49. * GP Device ROM code API usage here
  50. * r12 = AUXCR Write function and r0 value
  51. */
  52. __asm__ __volatile__("mov r12, #0x3");
  53. __asm__ __volatile__("mrc p15, 0, r0, c1, c0, 1");
  54. __asm__ __volatile__("orr r0, r0, #0x2");
  55. /* SMI instruction to call ROM Code API */
  56. __asm__ __volatile__(".word 0xE1600070");
  57. __asm__ __volatile__("mov r0, %0":"=r"(i));
  58. __asm__ __volatile__("mov r12, %0":"=r"(j));
  59. }
  60. }
  61. void l2_cache_disable(void)
  62. {
  63. unsigned long i;
  64. volatile unsigned int j;
  65. /* ES2 onwards we can disable/enable L2 ourselves */
  66. if (get_cpu_rev() >= CPU_3XX_ES20) {
  67. __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
  68. __asm__ __volatile__("bic %0, %0, #0x2":"=r"(i));
  69. __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
  70. } else {
  71. /* Save r0, r12 and restore them after usage */
  72. __asm__ __volatile__("mov %0, r12":"=r"(j));
  73. __asm__ __volatile__("mov %0, r0":"=r"(i));
  74. /*
  75. * GP Device ROM code API usage here
  76. * r12 = AUXCR Write function and r0 value
  77. */
  78. __asm__ __volatile__("mov r12, #0x3");
  79. __asm__ __volatile__("mrc p15, 0, r0, c1, c0, 1");
  80. __asm__ __volatile__("bic r0, r0, #0x2");
  81. /* SMI instruction to call ROM Code API */
  82. __asm__ __volatile__(".word 0xE1600070");
  83. __asm__ __volatile__("mov r0, %0":"=r"(i));
  84. __asm__ __volatile__("mov r12, %0":"=r"(j));
  85. }
  86. }