cpu.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. int checkcpu(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. #if defined(CONFIG_WATCHDOG)
  50. /* Called by macro WATCHDOG_RESET */
  51. void watchdog_reset(void)
  52. {
  53. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  54. /* Count register */
  55. out_be16(&wdp->sr, 0x5555);
  56. asm("nop");
  57. out_be16(&wdp->sr, 0xaaaa);
  58. }
  59. int watchdog_disable(void)
  60. {
  61. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  62. /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
  63. /* halted watchdog timer */
  64. setbits_be16(&wdp->cr, WTM_WCR_HALTED);
  65. puts("WATCHDOG:disabled\n");
  66. return (0);
  67. }
  68. int watchdog_init(void)
  69. {
  70. wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
  71. u32 wdog_module = 0;
  72. /* set timeout and enable watchdog */
  73. wdog_module = ((CONFIG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT);
  74. wdog_module |= (wdog_module / 8192);
  75. out_be16(&wdp->mr, wdog_module);
  76. out_be16(&wdp->cr, WTM_WCR_EN);
  77. puts("WATCHDOG:enabled\n");
  78. return (0);
  79. }
  80. #endif /* CONFIG_WATCHDOG */
  81. #if defined(CONFIG_MCFFEC)
  82. /* Default initializations for MCFFEC controllers. To override,
  83. * create a board-specific function called:
  84. * int board_eth_init(bd_t *bis)
  85. */
  86. int cpu_eth_init(bd_t *bis)
  87. {
  88. return mcffec_initialize(bis);
  89. }
  90. #endif