cpu.c 2.2 KB

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