cpu.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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-2007, 2012 Freescale Semiconductor, Inc.
  8. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  9. */
  10. #include <common.h>
  11. #include <net.h>
  12. #include <vsprintf.h>
  13. #include <watchdog.h>
  14. #include <command.h>
  15. #include <netdev.h>
  16. #include <asm/immap.h>
  17. #include <asm/io.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  20. {
  21. gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
  22. out_be16(&gptmr->pre, 10);
  23. out_be16(&gptmr->cnt, 1);
  24. /* enable watchdog, set timeout to 0 and wait */
  25. out_8(&gptmr->mode, GPT_TMS_SGPIO);
  26. out_8(&gptmr->ctrl, GPT_CTRL_WDEN | GPT_CTRL_CE);
  27. /* we don't return! */
  28. return 1;
  29. };
  30. #if defined(CONFIG_DISPLAY_CPUINFO)
  31. int print_cpuinfo(void)
  32. {
  33. siu_t *siu = (siu_t *) MMAP_SIU;
  34. u16 id = 0;
  35. puts("CPU: ");
  36. switch ((in_be32(&siu->jtagid) & 0x000FF000) >> 12) {
  37. case 0x0C:
  38. id = 5485;
  39. break;
  40. case 0x0D:
  41. id = 5484;
  42. break;
  43. case 0x0E:
  44. id = 5483;
  45. break;
  46. case 0x0F:
  47. id = 5482;
  48. break;
  49. case 0x10:
  50. id = 5481;
  51. break;
  52. case 0x11:
  53. id = 5480;
  54. break;
  55. case 0x12:
  56. id = 5475;
  57. break;
  58. case 0x13:
  59. id = 5474;
  60. break;
  61. case 0x14:
  62. id = 5473;
  63. break;
  64. case 0x15:
  65. id = 5472;
  66. break;
  67. case 0x16:
  68. id = 5471;
  69. break;
  70. case 0x17:
  71. id = 5470;
  72. break;
  73. }
  74. if (id) {
  75. char buf1[32], buf2[32];
  76. printf("Freescale MCF%d\n", id);
  77. printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
  78. strmhz(buf1, gd->cpu_clk),
  79. strmhz(buf2, gd->bus_clk));
  80. }
  81. return 0;
  82. };
  83. #endif /* CONFIG_DISPLAY_CPUINFO */
  84. #if defined(CONFIG_HW_WATCHDOG)
  85. /* Called by macro WATCHDOG_RESET */
  86. void hw_watchdog_reset(void)
  87. {
  88. gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
  89. out_8(&gptmr->ocpw, 0xa5);
  90. }
  91. int watchdog_disable(void)
  92. {
  93. gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
  94. /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
  95. out_8(&gptmr->mode, 0);
  96. out_8(&gptmr->ctrl, 0);
  97. puts("WATCHDOG:disabled\n");
  98. return (0);
  99. }
  100. int watchdog_init(void)
  101. {
  102. gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
  103. out_be16(&gptmr->pre, CONFIG_WATCHDOG_TIMEOUT);
  104. out_be16(&gptmr->cnt, CONFIG_SYS_TIMER_PRESCALER * 1000);
  105. out_8(&gptmr->mode, GPT_TMS_SGPIO);
  106. out_8(&gptmr->ctrl, GPT_CTRL_CE | GPT_CTRL_WDEN);
  107. puts("WATCHDOG:enabled\n");
  108. return (0);
  109. }
  110. #endif /* CONFIG_HW_WATCHDOG */
  111. #if defined(CONFIG_FSLDMAFEC) || defined(CONFIG_MCFFEC)
  112. /* Default initializations for MCFFEC controllers. To override,
  113. * create a board-specific function called:
  114. * int board_eth_init(bd_t *bis)
  115. */
  116. int cpu_eth_init(bd_t *bis)
  117. {
  118. #if defined(CONFIG_FSLDMAFEC)
  119. mcdmafec_initialize(bis);
  120. #endif
  121. #if defined(CONFIG_MCFFEC)
  122. mcffec_initialize(bis);
  123. #endif
  124. return 0;
  125. }
  126. #endif