cpu.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. *
  3. * (C) Copyright 2000-2003
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * Copyright (C) 2004-2008, 2012 Freescale Semiconductor, Inc.
  7. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <watchdog.h>
  13. #include <command.h>
  14. #include <netdev.h>
  15. #include <asm/immap.h>
  16. #include <asm/io.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  19. {
  20. rcm_t *rcm = (rcm_t *) (MMAP_RCM);
  21. udelay(1000);
  22. setbits_8(&rcm->rcr, RCM_RCR_SOFTRST);
  23. /* we don't return! */
  24. return 0;
  25. };
  26. int checkcpu(void)
  27. {
  28. ccm_t *ccm = (ccm_t *) MMAP_CCM;
  29. u16 msk;
  30. u16 id = 0;
  31. u8 ver;
  32. puts("CPU: ");
  33. msk = (in_be16(&ccm->cir) >> 6);
  34. ver = (in_be16(&ccm->cir) & 0x003f);
  35. switch (msk) {
  36. #ifdef CONFIG_MCF5301x
  37. case 0x78:
  38. id = 53010;
  39. break;
  40. case 0x77:
  41. id = 53012;
  42. break;
  43. case 0x76:
  44. id = 53015;
  45. break;
  46. case 0x74:
  47. id = 53011;
  48. break;
  49. case 0x73:
  50. id = 53013;
  51. break;
  52. #endif
  53. #ifdef CONFIG_MCF532x
  54. case 0x54:
  55. id = 5329;
  56. break;
  57. case 0x59:
  58. id = 5328;
  59. break;
  60. case 0x61:
  61. id = 5327;
  62. break;
  63. case 0x65:
  64. id = 5373;
  65. break;
  66. case 0x68:
  67. id = 53721;
  68. break;
  69. case 0x69:
  70. id = 5372;
  71. break;
  72. case 0x6B:
  73. id = 5372;
  74. break;
  75. #endif
  76. }
  77. if (id) {
  78. char buf1[32], buf2[32];
  79. printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
  80. ver);
  81. printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
  82. strmhz(buf1, gd->cpu_clk),
  83. strmhz(buf2, gd->bus_clk));
  84. }
  85. return 0;
  86. };
  87. #if defined(CONFIG_WATCHDOG)
  88. /* Called by macro WATCHDOG_RESET */
  89. void watchdog_reset(void)
  90. {
  91. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  92. /* Count register */
  93. out_be16(&wdp->sr, 0x5555);
  94. out_be16(&wdp->sr, 0xaaaa);
  95. }
  96. int watchdog_disable(void)
  97. {
  98. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  99. /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
  100. /* halted watchdog timer */
  101. setbits_be16(&wdp->cr, WTM_WCR_HALTED);
  102. puts("WATCHDOG:disabled\n");
  103. return (0);
  104. }
  105. int watchdog_init(void)
  106. {
  107. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  108. u32 wdog_module = 0;
  109. /* set timeout and enable watchdog */
  110. wdog_module = ((CONFIG_SYS_CLK / 1000) * CONFIG_WATCHDOG_TIMEOUT);
  111. #ifdef CONFIG_M5329
  112. out_be16(&wdp->mr, wdog_module / 8192);
  113. #else
  114. out_be16(&wdp->mr, wdog_module / 4096);
  115. #endif
  116. out_be16(&wdp->cr, WTM_WCR_EN);
  117. puts("WATCHDOG:enabled\n");
  118. return (0);
  119. }
  120. #endif /* CONFIG_WATCHDOG */
  121. #if defined(CONFIG_MCFFEC)
  122. /* Default initializations for MCFFEC controllers. To override,
  123. * create a board-specific function called:
  124. * int board_eth_init(bd_t *bis)
  125. */
  126. int cpu_eth_init(bd_t *bis)
  127. {
  128. return mcffec_initialize(bis);
  129. }
  130. #endif