cpu.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright 2004 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. *
  22. * Change log:
  23. *
  24. * 20050101: Eran Liberty (liberty@freescale.com)
  25. * Initial file creating (porting from 85XX & 8260)
  26. */
  27. /*
  28. * CPU specific code for the MPC83xx family.
  29. *
  30. * Derived from the MPC8260 and MPC85xx.
  31. */
  32. #include <common.h>
  33. #include <watchdog.h>
  34. #include <command.h>
  35. #include <mpc83xx.h>
  36. #include <asm/processor.h>
  37. int checkcpu(void)
  38. {
  39. DECLARE_GLOBAL_DATA_PTR;
  40. ulong clock = gd->cpu_clk;
  41. u32 pvr = get_pvr();
  42. char buf[32];
  43. if ((pvr & 0xFFFF0000) != PVR_83xx) {
  44. puts("Not MPC83xx Family!!!\n");
  45. return -1;
  46. }
  47. puts("CPU: MPC83xx, ");
  48. switch(pvr) {
  49. case PVR_8349_REV10:
  50. break;
  51. case PVR_8349_REV11:
  52. break;
  53. default:
  54. puts("Rev: Unknown\n");
  55. return -1; /* Not sure what this is */
  56. }
  57. printf("Rev: %d.%d at %s MHz\n", (pvr & 0xf0) >> 4,
  58. (pvr & 0x0f), strmhz(buf, clock));
  59. return 0;
  60. }
  61. void upmconfig (uint upm, uint *table, uint size)
  62. {
  63. hang(); /* FIXME: upconfig() needed? */
  64. }
  65. int
  66. do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  67. {
  68. ulong msr;
  69. #ifndef MPC83xx_RESET
  70. ulong addr;
  71. #endif
  72. volatile immap_t *immap = (immap_t *) CFG_IMMRBAR;
  73. #ifdef MPC83xx_RESET
  74. /* Interrupts and MMU off */
  75. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  76. msr &= ~( MSR_EE | MSR_IR | MSR_DR);
  77. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  78. /* enable Reset Control Reg */
  79. immap->reset.rpr = 0x52535445;
  80. /* confirm Reset Control Reg is enabled */
  81. while(!((immap->reset.rcer) & RCER_CRE));
  82. printf("Resetting the board.");
  83. printf("\n");
  84. udelay(200);
  85. /* perform reset, only one bit */
  86. immap->reset.rcr = RCR_SWHR;
  87. #else /* ! MPC83xx_RESET */
  88. immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
  89. /* Interrupts and MMU off */
  90. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  91. msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
  92. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  93. /*
  94. * Trying to execute the next instruction at a non-existing address
  95. * should cause a machine check, resulting in reset
  96. */
  97. addr = CFG_RESET_ADDRESS;
  98. printf("resetting the board.");
  99. printf("\n");
  100. ((void (*)(void)) addr) ();
  101. #endif /* MPC83xx_RESET */
  102. return 1;
  103. }
  104. /*
  105. * Get timebase clock frequency (like cpu_clk in Hz)
  106. */
  107. unsigned long get_tbclk(void)
  108. {
  109. DECLARE_GLOBAL_DATA_PTR;
  110. ulong tbclk;
  111. tbclk = (gd->bus_clk + 3L) / 4L;
  112. return tbclk;
  113. }
  114. #if defined(CONFIG_WATCHDOG)
  115. void watchdog_reset (void)
  116. {
  117. hang(); /* FIXME: implement watchdog_reset()? */
  118. }
  119. #endif /* CONFIG_WATCHDOG */