cpu.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * (C) Copyright 2007
  3. * Sascha Hauer, Pengutronix
  4. *
  5. * (C) Copyright 2009 Freescale Semiconductor, Inc.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <asm/errno.h>
  27. #include <asm/io.h>
  28. #include <asm/arch/imx-regs.h>
  29. #include <asm/arch/clock.h>
  30. #include <asm/arch/sys_proto.h>
  31. #ifdef CONFIG_FSL_ESDHC
  32. #include <fsl_esdhc.h>
  33. #endif
  34. static char *get_reset_cause(void)
  35. {
  36. u32 cause;
  37. struct src *src_regs = (struct src *)SRC_BASE_ADDR;
  38. cause = readl(&src_regs->srsr);
  39. writel(cause, &src_regs->srsr);
  40. switch (cause) {
  41. case 0x00001:
  42. case 0x00011:
  43. return "POR";
  44. case 0x00004:
  45. return "CSU";
  46. case 0x00008:
  47. return "IPP USER";
  48. case 0x00010:
  49. return "WDOG";
  50. case 0x00020:
  51. return "JTAG HIGH-Z";
  52. case 0x00040:
  53. return "JTAG SW";
  54. case 0x10000:
  55. return "WARM BOOT";
  56. default:
  57. return "unknown reset";
  58. }
  59. }
  60. #if defined(CONFIG_DISPLAY_CPUINFO)
  61. int print_cpuinfo(void)
  62. {
  63. u32 cpurev;
  64. cpurev = get_cpu_rev();
  65. printf("CPU: Freescale i.MX%x family rev%d.%d at %d MHz\n",
  66. (cpurev & 0xFF000) >> 12,
  67. (cpurev & 0x000F0) >> 4,
  68. (cpurev & 0x0000F) >> 0,
  69. mxc_get_clock(MXC_ARM_CLK) / 1000000);
  70. printf("Reset cause: %s\n", get_reset_cause());
  71. return 0;
  72. }
  73. #endif
  74. int cpu_eth_init(bd_t *bis)
  75. {
  76. int rc = -ENODEV;
  77. #if defined(CONFIG_FEC_MXC)
  78. rc = fecmxc_initialize(bis);
  79. #endif
  80. return rc;
  81. }
  82. /*
  83. * Initializes on-chip MMC controllers.
  84. * to override, implement board_mmc_init()
  85. */
  86. int cpu_mmc_init(bd_t *bis)
  87. {
  88. #ifdef CONFIG_FSL_ESDHC
  89. return fsl_esdhc_mmc_init(bis);
  90. #else
  91. return 0;
  92. #endif
  93. }
  94. void reset_cpu(ulong addr)
  95. {
  96. __raw_writew(4, WDOG1_BASE_ADDR);
  97. }