cpu.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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: %02x at %s MHz\n",pvr & 0x0000FFFF, strmhz(buf, clock));
  58. return 0;
  59. }
  60. void upmconfig (uint upm, uint *table, uint size)
  61. {
  62. hang(); /* FIXME: upconfig() needed? */
  63. }
  64. int
  65. do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  66. {
  67. ulong msr, addr;
  68. volatile immap_t *immap = (immap_t *) CFG_IMMRBAR;
  69. #ifdef MPC83xx_RESET
  70. /* Interrupts and MMU off */
  71. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  72. msr &= ~( MSR_EE | MSR_IR | MSR_DR);
  73. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  74. /* enable Reset Control Reg */
  75. immap->reset.rpr = 0x52535445;
  76. /* confirm Reset Control Reg is enabled */
  77. while(!((immap->reset.rcer) & RCER_CRE));
  78. printf("Resetting the board.");
  79. printf("\n");
  80. udelay(200);
  81. /* perform reset, only one bit */
  82. immap->reset.rcr = RCR_SWHR;
  83. #else
  84. immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
  85. /* Interrupts and MMU off */
  86. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  87. msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
  88. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  89. /*
  90. * Trying to execute the next instruction at a non-existing address
  91. * should cause a machine check, resulting in reset
  92. */
  93. addr = CFG_RESET_ADDRESS;
  94. printf("resetting the board.");
  95. printf("\n");
  96. ((void (*)(void)) addr) ();
  97. #endif
  98. return 1;
  99. }
  100. /*
  101. * Get timebase clock frequency (like cpu_clk in Hz)
  102. */
  103. unsigned long get_tbclk(void)
  104. {
  105. DECLARE_GLOBAL_DATA_PTR;
  106. ulong tbclk;
  107. tbclk = (gd->bus_clk + 3L) / 4L;
  108. return tbclk;
  109. }
  110. #if defined(CONFIG_WATCHDOG)
  111. void watchdog_reset (void)
  112. {
  113. hang(); /* FIXME: implement watchdog_reset()? */
  114. }
  115. #endif /* CONFIG_WATCHDOG */