cpu.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  8. * Alex Zuepke <azu@sysgo.de>
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. /*
  29. * CPU specific code
  30. */
  31. #include <common.h>
  32. #include <command.h>
  33. #include <netdev.h>
  34. #include <asm/arch/ixp425.h>
  35. #include <asm/system.h>
  36. ulong loops_per_jiffy;
  37. #ifdef CONFIG_USE_IRQ
  38. DECLARE_GLOBAL_DATA_PTR;
  39. #endif
  40. #if defined(CONFIG_DISPLAY_CPUINFO)
  41. int print_cpuinfo (void)
  42. {
  43. unsigned long id;
  44. int speed = 0;
  45. asm ("mrc p15, 0, %0, c0, c0, 0":"=r" (id));
  46. puts("CPU: Intel IXP425 at ");
  47. switch ((id & 0x000003f0) >> 4) {
  48. case 0x1c:
  49. loops_per_jiffy = 887467;
  50. speed = 533;
  51. break;
  52. case 0x1d:
  53. loops_per_jiffy = 666016;
  54. speed = 400;
  55. break;
  56. case 0x1f:
  57. loops_per_jiffy = 442901;
  58. speed = 266;
  59. break;
  60. }
  61. if (speed)
  62. printf("%d MHz\n", speed);
  63. else
  64. puts("unknown revision\n");
  65. return 0;
  66. }
  67. #endif /* CONFIG_DISPLAY_CPUINFO */
  68. int cpu_init (void)
  69. {
  70. /*
  71. * setup up stacks if necessary
  72. */
  73. #ifdef CONFIG_USE_IRQ
  74. IRQ_STACK_START = _armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4;
  75. FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
  76. #endif
  77. return 0;
  78. }
  79. int cleanup_before_linux (void)
  80. {
  81. /*
  82. * this function is called just before we call linux
  83. * it prepares the processor for linux
  84. *
  85. * just disable everything that can disturb booting linux
  86. */
  87. unsigned long i;
  88. disable_interrupts ();
  89. /* turn off I-cache */
  90. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  91. i &= ~0x1000;
  92. asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
  93. /* flush I-cache */
  94. asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
  95. return (0);
  96. }
  97. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  98. {
  99. printf ("resetting ...\n");
  100. udelay (50000); /* wait 50 ms */
  101. disable_interrupts ();
  102. reset_cpu (0);
  103. /*NOTREACHED*/
  104. return (0);
  105. }
  106. /* cache_bit must be either CR_I or CR_C */
  107. static void cache_enable(uint32_t cache_bit)
  108. {
  109. uint32_t reg;
  110. reg = get_cr(); /* get control reg. */
  111. cp_delay();
  112. set_cr(reg | cache_bit);
  113. }
  114. /* cache_bit must be either CR_I or CR_C */
  115. static void cache_disable(uint32_t cache_bit)
  116. {
  117. uint32_t reg;
  118. reg = get_cr();
  119. cp_delay();
  120. set_cr(reg & ~cache_bit);
  121. }
  122. void icache_enable(void)
  123. {
  124. cache_enable(CR_I);
  125. }
  126. void icache_disable(void)
  127. {
  128. cache_disable(CR_I);
  129. }
  130. int icache_status(void)
  131. {
  132. return (get_cr() & CR_I) != 0;
  133. }
  134. /* we will never enable dcache, because we have to setup MMU first */
  135. void dcache_enable (void)
  136. {
  137. return;
  138. }
  139. void dcache_disable (void)
  140. {
  141. return;
  142. }
  143. int dcache_status (void)
  144. {
  145. return 0; /* always off */
  146. }
  147. /* FIXME */
  148. /*
  149. void pci_init(void)
  150. {
  151. return;
  152. }
  153. */
  154. #ifdef CONFIG_BOOTCOUNT_LIMIT
  155. void bootcount_store (ulong a)
  156. {
  157. volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
  158. save_addr[0] = a;
  159. save_addr[1] = BOOTCOUNT_MAGIC;
  160. }
  161. ulong bootcount_load (void)
  162. {
  163. volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
  164. if (save_addr[1] != BOOTCOUNT_MAGIC)
  165. return 0;
  166. else
  167. return save_addr[0];
  168. }
  169. #endif /* CONFIG_BOOTCOUNT_LIMIT */
  170. int cpu_eth_init(bd_t *bis)
  171. {
  172. #ifdef CONFIG_IXP4XX_NPE
  173. npe_initialize(bis);
  174. #endif
  175. return 0;
  176. }