cpu.c 2.3 KB

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