cpu.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. #include <asm/arch/crm_regs.h>
  32. #ifdef CONFIG_FSL_ESDHC
  33. #include <fsl_esdhc.h>
  34. #endif
  35. char *get_reset_cause(void)
  36. {
  37. u32 cause;
  38. struct src *src_regs = (struct src *)SRC_BASE_ADDR;
  39. cause = readl(&src_regs->srsr);
  40. writel(cause, &src_regs->srsr);
  41. switch (cause) {
  42. case 0x00001:
  43. case 0x00011:
  44. return "POR";
  45. case 0x00004:
  46. return "CSU";
  47. case 0x00008:
  48. return "IPP USER";
  49. case 0x00010:
  50. return "WDOG";
  51. case 0x00020:
  52. return "JTAG HIGH-Z";
  53. case 0x00040:
  54. return "JTAG SW";
  55. case 0x10000:
  56. return "WARM BOOT";
  57. default:
  58. return "unknown reset";
  59. }
  60. }
  61. #if defined(CONFIG_DISPLAY_CPUINFO)
  62. static const char *get_imx_type(u32 imxtype)
  63. {
  64. switch (imxtype) {
  65. case 0x63:
  66. return "6Q"; /* Quad-core version of the mx6 */
  67. case 0x61:
  68. return "6DS"; /* Dual/Solo version of the mx6 */
  69. case 0x60:
  70. return "6SL"; /* Solo-Lite version of the mx6 */
  71. case 0x51:
  72. return "51";
  73. case 0x53:
  74. return "53";
  75. default:
  76. return "??";
  77. }
  78. }
  79. int print_cpuinfo(void)
  80. {
  81. u32 cpurev;
  82. cpurev = get_cpu_rev();
  83. printf("CPU: Freescale i.MX%s rev%d.%d at %d MHz\n",
  84. get_imx_type((cpurev & 0xFF000) >> 12),
  85. (cpurev & 0x000F0) >> 4,
  86. (cpurev & 0x0000F) >> 0,
  87. mxc_get_clock(MXC_ARM_CLK) / 1000000);
  88. printf("Reset cause: %s\n", get_reset_cause());
  89. return 0;
  90. }
  91. #endif
  92. int cpu_eth_init(bd_t *bis)
  93. {
  94. int rc = -ENODEV;
  95. #if defined(CONFIG_FEC_MXC)
  96. rc = fecmxc_initialize(bis);
  97. #endif
  98. return rc;
  99. }
  100. #ifdef CONFIG_FSL_ESDHC
  101. /*
  102. * Initializes on-chip MMC controllers.
  103. * to override, implement board_mmc_init()
  104. */
  105. int cpu_mmc_init(bd_t *bis)
  106. {
  107. return fsl_esdhc_mmc_init(bis);
  108. }
  109. #endif
  110. void reset_cpu(ulong addr)
  111. {
  112. __raw_writew(4, WDOG1_BASE_ADDR);
  113. }
  114. u32 get_ahb_clk(void)
  115. {
  116. struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
  117. u32 reg, ahb_podf;
  118. reg = __raw_readl(&imx_ccm->cbcdr);
  119. reg &= MXC_CCM_CBCDR_AHB_PODF_MASK;
  120. ahb_podf = reg >> MXC_CCM_CBCDR_AHB_PODF_OFFSET;
  121. return get_periph_clk() / (ahb_podf + 1);
  122. }