cpu.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * (C) Copyright 2003
  3. * Josef Baumgartner <josef.baumgartner@telex.de>
  4. *
  5. * MCF5282 additionals
  6. * (C) Copyright 2005
  7. * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. #include <watchdog.h>
  29. #include <command.h>
  30. #ifdef CONFIG_M5272
  31. #include <asm/immap_5272.h>
  32. #include <asm/m5272.h>
  33. #endif
  34. #ifdef CONFIG_M5282
  35. #include <asm/m5282.h>
  36. #include <asm/immap_5282.h>
  37. #endif
  38. #ifdef CONFIG_M5249
  39. #include <asm/m5249.h>
  40. #endif
  41. #ifdef CONFIG_M5272
  42. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
  43. volatile wdog_t * wdp = (wdog_t *)(CFG_MBAR + MCFSIM_WRRR);
  44. wdp->wdog_wrrr = 0;
  45. udelay (1000);
  46. /* enable watchdog, set timeout to 0 and wait */
  47. wdp->wdog_wrrr = 1;
  48. while (1);
  49. /* we don't return! */
  50. return 0;
  51. };
  52. int checkcpu(void) {
  53. ulong *dirp = (ulong *)(CFG_MBAR + MCFSIM_DIR);
  54. uchar msk;
  55. char *suf;
  56. puts ("CPU: ");
  57. msk = (*dirp > 28) & 0xf;
  58. switch (msk) {
  59. case 0x2: suf = "1K75N"; break;
  60. case 0x4: suf = "3K75N"; break;
  61. default:
  62. suf = NULL;
  63. printf ("MOTOROLA MCF5272 (Mask:%01x)\n", msk);
  64. break;
  65. }
  66. if (suf)
  67. printf ("MOTOROLA MCF5272 %s\n", suf);
  68. return 0;
  69. };
  70. #if defined(CONFIG_WATCHDOG)
  71. /* Called by macro WATCHDOG_RESET */
  72. void watchdog_reset (void)
  73. {
  74. volatile immap_t * regp = (volatile immap_t *)CFG_MBAR;
  75. regp->wdog_reg.wdog_wcr = 0;
  76. }
  77. int watchdog_disable (void)
  78. {
  79. volatile immap_t *regp = (volatile immap_t *)CFG_MBAR;
  80. regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */
  81. regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */
  82. regp->wdog_reg.wdog_wrrr = 0; /* disable watchdog timer */
  83. puts ("WATCHDOG:disabled\n");
  84. return (0);
  85. }
  86. int watchdog_init (void)
  87. {
  88. volatile immap_t *regp = (volatile immap_t *)CFG_MBAR;
  89. regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */
  90. /* set timeout and enable watchdog */
  91. regp->wdog_reg.wdog_wrrr = ((CONFIG_WATCHDOG_TIMEOUT * CFG_HZ) / (32768 * 1000)) - 1;
  92. regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */
  93. puts ("WATCHDOG:enabled\n");
  94. return (0);
  95. }
  96. #endif /* #ifdef CONFIG_WATCHDOG */
  97. #endif /* #ifdef CONFIG_M5272 */
  98. #ifdef CONFIG_M5282
  99. int checkcpu (void)
  100. {
  101. unsigned char resetsource;
  102. printf ("CPU: MOTOROLA Coldfire MCF5282 (PIN: %2.2x REV: %2.2x)\n",
  103. MCFCCM_CIR>>8,MCFCCM_CIR & MCFCCM_CIR_PRN_MASK);
  104. puts ("Reset: ");
  105. resetsource = MCFRESET_RSR;
  106. if (resetsource & MCFRESET_RSR_LOL) puts("Lose-of-lock ");
  107. if (resetsource & MCFRESET_RSR_LOC) puts("Lose-of-clock ");
  108. if (resetsource & MCFRESET_RSR_EXT) puts("external ");
  109. if (resetsource & MCFRESET_RSR_POR) puts("Power-on ");
  110. if (resetsource & MCFRESET_RSR_WDR) puts("Watchdog ");
  111. if (resetsource & MCFRESET_RSR_SOFT) puts("Software ");
  112. if (resetsource & MCFRESET_RSR_LVD) puts("Low-voltage ");
  113. puts("\n");
  114. return 0;
  115. }
  116. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
  117. {
  118. MCFRESET_RCR = MCFRESET_RCR_SOFTRST;
  119. return 0;
  120. };
  121. #endif
  122. #ifdef CONFIG_M5249 /* test-only: todo... */
  123. int checkcpu (void)
  124. {
  125. char buf[32];
  126. printf ("CPU: MOTOROLA Coldfire MCF5249 at %s MHz\n", strmhz(buf, CFG_CLK));
  127. return 0;
  128. }
  129. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
  130. /* enable watchdog, set timeout to 0 and wait */
  131. mbar_writeByte(MCFSIM_SYPCR, 0xc0);
  132. while (1);
  133. /* we don't return! */
  134. return 0;
  135. };
  136. #endif