cpu.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. ulong loops_per_jiffy;
  36. #ifdef CONFIG_USE_IRQ
  37. DECLARE_GLOBAL_DATA_PTR;
  38. #endif
  39. #if defined(CONFIG_DISPLAY_CPUINFO)
  40. int print_cpuinfo (void)
  41. {
  42. unsigned long id;
  43. int speed = 0;
  44. asm ("mrc p15, 0, %0, c0, c0, 0":"=r" (id));
  45. puts("CPU: Intel IXP425 at ");
  46. switch ((id & 0x000003f0) >> 4) {
  47. case 0x1c:
  48. loops_per_jiffy = 887467;
  49. speed = 533;
  50. break;
  51. case 0x1d:
  52. loops_per_jiffy = 666016;
  53. speed = 400;
  54. break;
  55. case 0x1f:
  56. loops_per_jiffy = 442901;
  57. speed = 266;
  58. break;
  59. }
  60. if (speed)
  61. printf("%d MHz\n", speed);
  62. else
  63. puts("unknown revision\n");
  64. return 0;
  65. }
  66. #endif /* CONFIG_DISPLAY_CPUINFO */
  67. int cpu_init (void)
  68. {
  69. /*
  70. * setup up stacks if necessary
  71. */
  72. #ifdef CONFIG_USE_IRQ
  73. IRQ_STACK_START = _armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4;
  74. FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
  75. #endif
  76. return 0;
  77. }
  78. int cleanup_before_linux (void)
  79. {
  80. /*
  81. * this function is called just before we call linux
  82. * it prepares the processor for linux
  83. *
  84. * just disable everything that can disturb booting linux
  85. */
  86. unsigned long i;
  87. disable_interrupts ();
  88. /* turn off I-cache */
  89. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  90. i &= ~0x1000;
  91. asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
  92. /* flush I-cache */
  93. asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
  94. return (0);
  95. }
  96. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  97. {
  98. printf ("resetting ...\n");
  99. udelay (50000); /* wait 50 ms */
  100. disable_interrupts ();
  101. reset_cpu (0);
  102. /*NOTREACHED*/
  103. return (0);
  104. }
  105. /* taken from blob */
  106. void icache_enable (void)
  107. {
  108. register u32 i;
  109. /* read control register */
  110. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  111. /* set i-cache */
  112. i |= 0x1000;
  113. /* write back to control register */
  114. asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
  115. }
  116. void icache_disable (void)
  117. {
  118. register u32 i;
  119. /* read control register */
  120. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  121. /* clear i-cache */
  122. i &= ~0x1000;
  123. /* write back to control register */
  124. asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
  125. /* flush i-cache */
  126. asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
  127. }
  128. int icache_status (void)
  129. {
  130. register u32 i;
  131. /* read control register */
  132. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  133. /* return bit */
  134. return (i & 0x1000);
  135. }
  136. /* we will never enable dcache, because we have to setup MMU first */
  137. void dcache_enable (void)
  138. {
  139. return;
  140. }
  141. void dcache_disable (void)
  142. {
  143. return;
  144. }
  145. int dcache_status (void)
  146. {
  147. return 0; /* always off */
  148. }
  149. /* FIXME */
  150. /*
  151. void pci_init(void)
  152. {
  153. return;
  154. }
  155. */
  156. #ifdef CONFIG_BOOTCOUNT_LIMIT
  157. void bootcount_store (ulong a)
  158. {
  159. volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
  160. save_addr[0] = a;
  161. save_addr[1] = BOOTCOUNT_MAGIC;
  162. }
  163. ulong bootcount_load (void)
  164. {
  165. volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
  166. if (save_addr[1] != BOOTCOUNT_MAGIC)
  167. return 0;
  168. else
  169. return save_addr[0];
  170. }
  171. #endif /* CONFIG_BOOTCOUNT_LIMIT */
  172. int cpu_eth_init(bd_t *bis)
  173. {
  174. #ifdef CONFIG_IXP4XX_NPE
  175. npe_initialize(bis);
  176. #endif
  177. return 0;
  178. }