cpu.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_M5272
  27. #include <asm/immap_5272.h>
  28. #include <asm/m5272.h>
  29. #endif
  30. #ifdef CONFIG_M5282
  31. #endif
  32. #ifdef CONFIG_M5272
  33. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
  34. volatile wdog_t * wdp = (wdog_t *)(CFG_MBAR + MCFSIM_WRRR);
  35. wdp->wdog_wrrr = 0;
  36. udelay (1000);
  37. /* enable watchdog, set timeout to 0 and wait */
  38. wdp->wdog_wrrr = 1;
  39. while (1);
  40. /* we don't return! */
  41. return 0;
  42. };
  43. int checkcpu(void) {
  44. ulong *dirp = (ulong *)(CFG_MBAR + MCFSIM_DIR);
  45. uchar msk;
  46. char *suf;
  47. puts ("CPU: ");
  48. msk = (*dirp > 28) & 0xf;
  49. switch (msk) {
  50. case 0x2: suf = "1K75N"; break;
  51. case 0x4: suf = "3K75N"; break;
  52. default:
  53. suf = NULL;
  54. printf ("MOTOROLA MCF5272 (Mask:%01x)\n", msk);
  55. break;
  56. }
  57. if (suf)
  58. printf ("MOTOROLA MCF5272 %s\n", suf);
  59. return 0;
  60. };
  61. #if defined(CONFIG_WATCHDOG)
  62. /* Called by macro WATCHDOG_RESET */
  63. void watchdog_reset (void)
  64. {
  65. volatile immap_t * regp = (volatile immap_t *)CFG_MBAR;
  66. regp->wdog_reg.wdog_wcr = 0;
  67. }
  68. int watchdog_disable (void)
  69. {
  70. volatile immap_t *regp = (volatile immap_t *)CFG_MBAR;
  71. regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */
  72. regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */
  73. regp->wdog_reg.wdog_wrrr = 0; /* disable watchdog timer */
  74. puts ("WATCHDOG:disabled\n");
  75. return (0);
  76. }
  77. int watchdog_init (void)
  78. {
  79. volatile immap_t *regp = (volatile immap_t *)CFG_MBAR;
  80. regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */
  81. /* set timeout and enable watchdog */
  82. regp->wdog_reg.wdog_wrrr = ((CONFIG_WATCHDOG_TIMEOUT * CFG_HZ) / (32768 * 1000)) - 1;
  83. regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */
  84. puts ("WATCHDOG:enabled\n");
  85. return (0);
  86. }
  87. #endif /* #ifdef CONFIG_WATCHDOG */
  88. #endif /* #ifdef CONFIG_M5272 */
  89. #ifdef CONFIG_M5282
  90. int checkcpu (void)
  91. {
  92. puts ("CPU: MOTOROLA Coldfire MCF5282\n");
  93. return 0;
  94. }
  95. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
  96. return 0;
  97. };
  98. #endif