cpu.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. static void cache_flush(void);
  41. #if defined(CONFIG_DISPLAY_CPUINFO)
  42. int print_cpuinfo (void)
  43. {
  44. unsigned long id;
  45. int speed = 0;
  46. asm ("mrc p15, 0, %0, c0, c0, 0":"=r" (id));
  47. puts("CPU: Intel IXP425 at ");
  48. switch ((id & 0x000003f0) >> 4) {
  49. case 0x1c:
  50. loops_per_jiffy = 887467;
  51. speed = 533;
  52. break;
  53. case 0x1d:
  54. loops_per_jiffy = 666016;
  55. speed = 400;
  56. break;
  57. case 0x1f:
  58. loops_per_jiffy = 442901;
  59. speed = 266;
  60. break;
  61. }
  62. if (speed)
  63. printf("%d MHz\n", speed);
  64. else
  65. puts("unknown revision\n");
  66. return 0;
  67. }
  68. #endif /* CONFIG_DISPLAY_CPUINFO */
  69. int cpu_init (void)
  70. {
  71. /*
  72. * setup up stacks if necessary
  73. */
  74. #ifdef CONFIG_USE_IRQ
  75. IRQ_STACK_START = _armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4;
  76. FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
  77. #endif
  78. return 0;
  79. }
  80. int cleanup_before_linux (void)
  81. {
  82. /*
  83. * this function is called just before we call linux
  84. * it prepares the processor for linux
  85. *
  86. * just disable everything that can disturb booting linux
  87. */
  88. disable_interrupts ();
  89. /* turn off I-cache */
  90. icache_disable();
  91. dcache_disable();
  92. /* flush I-cache */
  93. cache_flush();
  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. /* flush I/D-cache */
  106. static void cache_flush (void)
  107. {
  108. unsigned long i = 0;
  109. asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
  110. }
  111. /* FIXME */
  112. /*
  113. void pci_init(void)
  114. {
  115. return;
  116. }
  117. */
  118. #ifdef CONFIG_BOOTCOUNT_LIMIT
  119. void bootcount_store (ulong a)
  120. {
  121. volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
  122. save_addr[0] = a;
  123. save_addr[1] = BOOTCOUNT_MAGIC;
  124. }
  125. ulong bootcount_load (void)
  126. {
  127. volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
  128. if (save_addr[1] != BOOTCOUNT_MAGIC)
  129. return 0;
  130. else
  131. return save_addr[0];
  132. }
  133. #endif /* CONFIG_BOOTCOUNT_LIMIT */
  134. int cpu_eth_init(bd_t *bis)
  135. {
  136. #ifdef CONFIG_IXP4XX_NPE
  137. npe_initialize(bis);
  138. #endif
  139. return 0;
  140. }