cpu.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * (C) Copyright 2002
  3. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  4. * Marius Groeger <mgroeger@sysgo.de>
  5. *
  6. * (C) Copyright 2002
  7. * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. /*
  28. * CPU specific code
  29. */
  30. #include <common.h>
  31. #include <command.h>
  32. #include <arm925t.h>
  33. #include <asm/system.h>
  34. #ifdef CONFIG_USE_IRQ
  35. DECLARE_GLOBAL_DATA_PTR;
  36. #endif
  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. }
  43. int cpu_init (void)
  44. {
  45. /*
  46. * setup up stacks if necessary
  47. */
  48. #ifdef CONFIG_USE_IRQ
  49. IRQ_STACK_START = _armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4;
  50. FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
  51. #endif
  52. return 0;
  53. }
  54. int cleanup_before_linux (void)
  55. {
  56. /*
  57. * this function is called just before we call linux
  58. * it prepares the processor for linux
  59. *
  60. * we turn off caches etc ...
  61. */
  62. unsigned long i;
  63. disable_interrupts ();
  64. /* turn off I/D-cache */
  65. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  66. i &= ~(CR_C | CR_I);
  67. asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
  68. /* flush I/D-cache */
  69. i = 0;
  70. asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
  71. return (0);
  72. }
  73. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  74. {
  75. disable_interrupts ();
  76. reset_cpu (0);
  77. /*NOTREACHED*/
  78. return (0);
  79. }
  80. void icache_enable (void)
  81. {
  82. ulong reg;
  83. reg = get_cr (); /* get control reg. */
  84. cp_delay ();
  85. set_cr (reg | CR_I);
  86. }
  87. void icache_disable (void)
  88. {
  89. ulong reg;
  90. reg = get_cr ();
  91. cp_delay ();
  92. set_cr (reg & ~CR_I);
  93. }
  94. int icache_status (void)
  95. {
  96. return (get_cr () & CR_I) != 0;
  97. }