cpu.c 2.8 KB

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