cpu.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. *
  3. * (C) Copyright 2000-2003
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
  7. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <watchdog.h>
  13. #include <command.h>
  14. #include <netdev.h>
  15. #include <asm/immap.h>
  16. #include <asm/io.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  19. {
  20. ccm_t *ccm = (ccm_t *) MMAP_CCM;
  21. out_8(&ccm->rcr, CCM_RCR_SOFTRST);
  22. /* we don't return! */
  23. return 0;
  24. }
  25. #if defined(CONFIG_DISPLAY_CPUINFO)
  26. int print_cpuinfo(void)
  27. {
  28. ccm_t *ccm = (ccm_t *) MMAP_CCM;
  29. u16 msk;
  30. u16 id = 0;
  31. u8 ver;
  32. puts("CPU: ");
  33. msk = (in_be16(&ccm->cir) >> 6);
  34. ver = (in_be16(&ccm->cir) & 0x003f);
  35. switch (msk) {
  36. case 0x31:
  37. id = 5235;
  38. break;
  39. }
  40. if (id) {
  41. char buf1[32], buf2[32];
  42. printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
  43. ver);
  44. printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
  45. strmhz(buf1, gd->cpu_clk),
  46. strmhz(buf2, gd->bus_clk));
  47. }
  48. return 0;
  49. };
  50. #endif /* CONFIG_DISPLAY_CPUINFO */
  51. #if defined(CONFIG_WATCHDOG)
  52. /* Called by macro WATCHDOG_RESET */
  53. void watchdog_reset(void)
  54. {
  55. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  56. /* Count register */
  57. out_be16(&wdp->sr, 0x5555);
  58. asm("nop");
  59. out_be16(&wdp->sr, 0xaaaa);
  60. }
  61. int watchdog_disable(void)
  62. {
  63. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  64. /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
  65. /* halted watchdog timer */
  66. setbits_be16(&wdp->cr, WTM_WCR_HALTED);
  67. puts("WATCHDOG:disabled\n");
  68. return (0);
  69. }
  70. int watchdog_init(void)
  71. {
  72. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  73. u32 wdog_module = 0;
  74. /* set timeout and enable watchdog */
  75. wdog_module = ((CONFIG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT);
  76. wdog_module |= (wdog_module / 8192);
  77. out_be16(&wdp->mr, wdog_module);
  78. out_be16(&wdp->cr, WTM_WCR_EN);
  79. puts("WATCHDOG:enabled\n");
  80. return (0);
  81. }
  82. #endif /* CONFIG_WATCHDOG */
  83. #if defined(CONFIG_MCFFEC)
  84. /* Default initializations for MCFFEC controllers. To override,
  85. * create a board-specific function called:
  86. * int board_eth_init(bd_t *bis)
  87. */
  88. int cpu_eth_init(bd_t *bis)
  89. {
  90. return mcffec_initialize(bis);
  91. }
  92. #endif