cpu.c 2.3 KB

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