cpu.c 2.8 KB

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