cpu.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * (C) Copyright 2004 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. * CPU specific code
  31. */
  32. #include <common.h>
  33. #include <command.h>
  34. #include <s3c6400.h>
  35. #include <asm/system.h>
  36. static void cache_flush (void);
  37. static void cp_delay (void)
  38. {
  39. volatile int i;
  40. /* Many OMAP regs need at least 2 nops */
  41. for (i = 0; i < 100; i++)
  42. __asm__ __volatile__("nop\n");
  43. }
  44. int cpu_init (void)
  45. {
  46. return 0;
  47. }
  48. int cleanup_before_linux (void)
  49. {
  50. /*
  51. * this function is called just before we call linux
  52. * it prepares the processor for linux
  53. *
  54. * we turn off caches etc ...
  55. */
  56. disable_interrupts ();
  57. /* turn off I/D-cache */
  58. icache_disable();
  59. dcache_disable();
  60. cache_flush();
  61. return 0;
  62. }
  63. /* * reset the cpu by setting up the watchdog timer and let him time out */
  64. void reset_cpu (ulong ignored)
  65. {
  66. printf("reset... \n\n\n");
  67. SW_RST_REG = 0x6400;
  68. /* loop forever and wait for reset to happen */
  69. while (1) {
  70. if (serial_tstc()) {
  71. serial_getc();
  72. break;
  73. }
  74. }
  75. /*NOTREACHED*/
  76. }
  77. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  78. {
  79. disable_interrupts ();
  80. reset_cpu (0);
  81. /*NOTREACHED*/
  82. return 0;
  83. }
  84. void icache_enable (void)
  85. {
  86. ulong reg;
  87. reg = get_cr (); /* get control reg. */
  88. cp_delay ();
  89. set_cr (reg | CR_I);
  90. }
  91. void icache_disable (void)
  92. {
  93. ulong reg;
  94. reg = get_cr ();
  95. cp_delay ();
  96. set_cr (reg & ~CR_I);
  97. }
  98. int icache_status (void)
  99. {
  100. return (get_cr () & CR_I) != 0;
  101. }
  102. /* It makes no sense to use the dcache if the MMU is not enabled */
  103. void dcache_enable (void)
  104. {
  105. ulong reg;
  106. reg = get_cr ();
  107. cp_delay ();
  108. set_cr (reg | CR_C);
  109. }
  110. void dcache_disable (void)
  111. {
  112. ulong reg;
  113. reg = get_cr ();
  114. cp_delay ();
  115. set_cr (reg & ~CR_C);
  116. }
  117. int dcache_status (void)
  118. {
  119. return (get_cr () & CR_C) != 0;
  120. }
  121. /* flush I/D-cache */
  122. static void cache_flush (void)
  123. {
  124. /* invalidate both caches and flush btb */
  125. asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (0));
  126. /* mem barrier to sync things */
  127. asm ("mcr p15, 0, %0, c7, c10, 4": :"r" (0));
  128. }