cpu.c 2.8 KB

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