cpu.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (C) 2004-2006 Freescale Semiconductor, Inc.
  3. * (C) Copyright 2007 DENX Software Engineering
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /*
  24. * CPU specific code for the MPC512x family.
  25. *
  26. * Derived from the MPC83xx code.
  27. */
  28. #include <common.h>
  29. #include <command.h>
  30. #include <mpc512x.h>
  31. #include <asm/processor.h>
  32. DECLARE_GLOBAL_DATA_PTR;
  33. int checkcpu (void)
  34. {
  35. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  36. ulong clock = gd->cpu_clk;
  37. u32 pvr = get_pvr ();
  38. u32 spridr = immr->sysconf.spridr;
  39. char buf[32];
  40. puts ("CPU: ");
  41. switch (spridr & 0xffff0000) {
  42. case SPR_5121E:
  43. puts ("MPC5121e ");
  44. break;
  45. default:
  46. printf ("Unknown part ID %08x ", spridr & 0xffff0000);
  47. }
  48. printf ("rev. %d.%d, Core ", SVR_MJREV (spridr), SVR_MNREV (spridr));
  49. switch (pvr & 0xffff0000) {
  50. case PVR_E300C4:
  51. puts ("e300c4 ");
  52. break;
  53. default:
  54. puts ("unknown ");
  55. }
  56. printf ("at %s MHz, CSB at %3d MHz\n", strmhz(buf, clock),
  57. gd->csb_clk / 1000000);
  58. return 0;
  59. }
  60. int
  61. do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  62. {
  63. ulong msr;
  64. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  65. /* Interrupts and MMU off */
  66. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  67. msr &= ~( MSR_EE | MSR_IR | MSR_DR);
  68. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  69. /*
  70. * Enable Reset Control Reg - "RSTE" is the magic word that let us go
  71. */
  72. immap->reset.rpr = 0x52535445;
  73. /* Verify Reset Control Reg is enabled */
  74. while (!((immap->reset.rcer) & RCER_CRE))
  75. ;
  76. printf ("Resetting the board.\n");
  77. udelay(200);
  78. /* Perform reset */
  79. immap->reset.rcr = RCR_SWHR;
  80. /* Unreached... */
  81. return 1;
  82. }
  83. /*
  84. * Get timebase clock frequency (like cpu_clk in Hz)
  85. */
  86. unsigned long get_tbclk (void)
  87. {
  88. ulong tbclk;
  89. tbclk = (gd->bus_clk + 3L) / 4L;
  90. return tbclk;
  91. }
  92. #if defined(CONFIG_WATCHDOG)
  93. void watchdog_reset (void)
  94. {
  95. int re_enable = disable_interrupts ();
  96. /* Reset watchdog */
  97. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  98. immr->wdt.swsrr = 0x556c;
  99. immr->wdt.swsrr = 0xaa39;
  100. if (re_enable)
  101. enable_interrupts ();
  102. }
  103. #endif