cpu.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. ccm_t *ccm = (ccm_t *) MMAP_CCM;
  22. out_8(&ccm->rcr, CCM_RCR_SOFTRST);
  23. /* we don't return! */
  24. return 0;
  25. }
  26. #if defined(CONFIG_DISPLAY_CPUINFO)
  27. int print_cpuinfo(void)
  28. {
  29. ccm_t *ccm = (ccm_t *) MMAP_CCM;
  30. u16 msk;
  31. u16 id = 0;
  32. u8 ver;
  33. puts("CPU: ");
  34. msk = (in_be16(&ccm->cir) >> 6);
  35. ver = (in_be16(&ccm->cir) & 0x003f);
  36. switch (msk) {
  37. case 0x31:
  38. id = 5235;
  39. break;
  40. }
  41. if (id) {
  42. char buf1[32], buf2[32];
  43. printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
  44. ver);
  45. printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
  46. strmhz(buf1, gd->cpu_clk),
  47. strmhz(buf2, gd->bus_clk));
  48. }
  49. return 0;
  50. };
  51. #endif /* CONFIG_DISPLAY_CPUINFO */
  52. #if defined(CONFIG_WATCHDOG)
  53. /* Called by macro WATCHDOG_RESET */
  54. void watchdog_reset(void)
  55. {
  56. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  57. /* Count register */
  58. out_be16(&wdp->sr, 0x5555);
  59. asm("nop");
  60. out_be16(&wdp->sr, 0xaaaa);
  61. }
  62. int watchdog_disable(void)
  63. {
  64. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  65. /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
  66. /* halted watchdog timer */
  67. setbits_be16(&wdp->cr, WTM_WCR_HALTED);
  68. puts("WATCHDOG:disabled\n");
  69. return (0);
  70. }
  71. int watchdog_init(void)
  72. {
  73. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  74. u32 wdog_module = 0;
  75. /* set timeout and enable watchdog */
  76. wdog_module = ((CONFIG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT);
  77. wdog_module |= (wdog_module / 8192);
  78. out_be16(&wdp->mr, wdog_module);
  79. out_be16(&wdp->cr, WTM_WCR_EN);
  80. puts("WATCHDOG:enabled\n");
  81. return (0);
  82. }
  83. #endif /* CONFIG_WATCHDOG */
  84. #if defined(CONFIG_MCFFEC)
  85. /* Default initializations for MCFFEC controllers. To override,
  86. * create a board-specific function called:
  87. * int board_eth_init(bd_t *bis)
  88. */
  89. int cpu_eth_init(bd_t *bis)
  90. {
  91. return mcffec_initialize(bis);
  92. }
  93. #endif