cpu.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * (C) Copyright 2003
  3. * Josef Baumgartner <josef.baumgartner@telex.de>
  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. #include <common.h>
  24. #include <watchdog.h>
  25. #include <command.h>
  26. #ifdef CONFIG_M5271
  27. #include <asm/immap_5271.h>
  28. #include <asm/m5271.h>
  29. #endif
  30. #ifdef CONFIG_M5272
  31. #include <asm/immap_5272.h>
  32. #include <asm/m5272.h>
  33. #endif
  34. #ifdef CONFIG_M5282
  35. #endif
  36. #ifdef CONFIG_M5249
  37. #include <asm/m5249.h>
  38. #endif
  39. #ifdef CONFIG_M5271
  40. int checkcpu (void)
  41. {
  42. puts ("CPU: MOTOROLA Coldfire MCF5271\n");
  43. return 0;
  44. }
  45. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
  46. mbar_writeByte(MCF_RCM_RCR,
  47. MCF_RCM_RCR_SOFTRST | MCF_RCM_RCR_FRCRSTOUT);
  48. return 0;
  49. };
  50. #if defined(CONFIG_WATCHDOG)
  51. void watchdog_reset (void)
  52. {
  53. mbar_writeShort(MCF_WTM_WSR, 0x5555);
  54. mbar_writeShort(MCF_WTM_WSR, 0xAAAA);
  55. }
  56. int watchdog_disable (void)
  57. {
  58. mbar_writeShort(MCF_WTM_WCR, 0);
  59. return (0);
  60. }
  61. int watchdog_init (void)
  62. {
  63. mbar_writeShort(MCF_WTM_WCNTR, CONFIG_WATCHDOG_TIMEOUT);
  64. mbar_writeShort(MCF_WTM_WCR, MCF_WTM_WCR_EN);
  65. return (0);
  66. }
  67. #endif /* #ifdef CONFIG_WATCHDOG */
  68. #endif
  69. #ifdef CONFIG_M5272
  70. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
  71. volatile wdog_t * wdp = (wdog_t *)(CFG_MBAR + MCFSIM_WRRR);
  72. wdp->wdog_wrrr = 0;
  73. udelay (1000);
  74. /* enable watchdog, set timeout to 0 and wait */
  75. wdp->wdog_wrrr = 1;
  76. while (1);
  77. /* we don't return! */
  78. return 0;
  79. };
  80. int checkcpu(void) {
  81. ulong *dirp = (ulong *)(CFG_MBAR + MCFSIM_DIR);
  82. uchar msk;
  83. char *suf;
  84. puts ("CPU: ");
  85. msk = (*dirp > 28) & 0xf;
  86. switch (msk) {
  87. case 0x2: suf = "1K75N"; break;
  88. case 0x4: suf = "3K75N"; break;
  89. default:
  90. suf = NULL;
  91. printf ("MOTOROLA MCF5272 (Mask:%01x)\n", msk);
  92. break;
  93. }
  94. if (suf)
  95. printf ("MOTOROLA MCF5272 %s\n", suf);
  96. return 0;
  97. };
  98. #if defined(CONFIG_WATCHDOG)
  99. /* Called by macro WATCHDOG_RESET */
  100. void watchdog_reset (void)
  101. {
  102. volatile immap_t * regp = (volatile immap_t *)CFG_MBAR;
  103. regp->wdog_reg.wdog_wcr = 0;
  104. }
  105. int watchdog_disable (void)
  106. {
  107. volatile immap_t *regp = (volatile immap_t *)CFG_MBAR;
  108. regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */
  109. regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */
  110. regp->wdog_reg.wdog_wrrr = 0; /* disable watchdog timer */
  111. puts ("WATCHDOG:disabled\n");
  112. return (0);
  113. }
  114. int watchdog_init (void)
  115. {
  116. volatile immap_t *regp = (volatile immap_t *)CFG_MBAR;
  117. regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */
  118. /* set timeout and enable watchdog */
  119. regp->wdog_reg.wdog_wrrr = ((CONFIG_WATCHDOG_TIMEOUT * CFG_HZ) / (32768 * 1000)) - 1;
  120. regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */
  121. puts ("WATCHDOG:enabled\n");
  122. return (0);
  123. }
  124. #endif /* #ifdef CONFIG_WATCHDOG */
  125. #endif /* #ifdef CONFIG_M5272 */
  126. #ifdef CONFIG_M5282
  127. int checkcpu (void)
  128. {
  129. puts ("CPU: MOTOROLA Coldfire MCF5282\n");
  130. return 0;
  131. }
  132. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
  133. return 0;
  134. };
  135. #endif
  136. #ifdef CONFIG_M5249 /* test-only: todo... */
  137. int checkcpu (void)
  138. {
  139. char buf[32];
  140. printf ("CPU: MOTOROLA Coldfire MCF5249 at %s MHz\n", strmhz(buf, CFG_CLK));
  141. return 0;
  142. }
  143. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
  144. /* enable watchdog, set timeout to 0 and wait */
  145. mbar_writeByte(MCFSIM_SYPCR, 0xc0);
  146. while (1);
  147. /* we don't return! */
  148. return 0;
  149. };
  150. #endif