cpu.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
  77. pci_init();
  78. #endif
  79. return 0;
  80. }
  81. int cleanup_before_linux (void)
  82. {
  83. /*
  84. * this function is called just before we call linux
  85. * it prepares the processor for linux
  86. *
  87. * just disable everything that can disturb booting linux
  88. */
  89. unsigned long i;
  90. disable_interrupts ();
  91. /* turn off I-cache */
  92. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  93. i &= ~0x1000;
  94. asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
  95. /* flush I-cache */
  96. asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
  97. return (0);
  98. }
  99. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  100. {
  101. printf ("resetting ...\n");
  102. udelay (50000); /* wait 50 ms */
  103. disable_interrupts ();
  104. reset_cpu (0);
  105. /*NOTREACHED*/
  106. return (0);
  107. }
  108. /* taken from blob */
  109. void icache_enable (void)
  110. {
  111. register u32 i;
  112. /* read control register */
  113. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  114. /* set i-cache */
  115. i |= 0x1000;
  116. /* write back to control register */
  117. asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
  118. }
  119. void icache_disable (void)
  120. {
  121. register u32 i;
  122. /* read control register */
  123. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  124. /* clear i-cache */
  125. i &= ~0x1000;
  126. /* write back to control register */
  127. asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i));
  128. /* flush i-cache */
  129. asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
  130. }
  131. int icache_status (void)
  132. {
  133. register u32 i;
  134. /* read control register */
  135. asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i));
  136. /* return bit */
  137. return (i & 0x1000);
  138. }
  139. /* we will never enable dcache, because we have to setup MMU first */
  140. void dcache_enable (void)
  141. {
  142. return;
  143. }
  144. void dcache_disable (void)
  145. {
  146. return;
  147. }
  148. int dcache_status (void)
  149. {
  150. return 0; /* always off */
  151. }
  152. /* FIXME */
  153. /*
  154. void pci_init(void)
  155. {
  156. return;
  157. }
  158. */
  159. #ifdef CONFIG_BOOTCOUNT_LIMIT
  160. void bootcount_store (ulong a)
  161. {
  162. volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
  163. save_addr[0] = a;
  164. save_addr[1] = BOOTCOUNT_MAGIC;
  165. }
  166. ulong bootcount_load (void)
  167. {
  168. volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
  169. if (save_addr[1] != BOOTCOUNT_MAGIC)
  170. return 0;
  171. else
  172. return save_addr[0];
  173. }
  174. #endif /* CONFIG_BOOTCOUNT_LIMIT */
  175. int cpu_eth_init(bd_t *bis)
  176. {
  177. #ifdef CONFIG_IXP4XX_NPE
  178. npe_initialize(bis);
  179. #endif
  180. return 0;
  181. }