cpu.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. #include <ipu_pixfmt.h>
  33. #ifdef CONFIG_FSL_ESDHC
  34. #include <fsl_esdhc.h>
  35. #endif
  36. char *get_reset_cause(void)
  37. {
  38. u32 cause;
  39. struct src *src_regs = (struct src *)SRC_BASE_ADDR;
  40. cause = readl(&src_regs->srsr);
  41. writel(cause, &src_regs->srsr);
  42. switch (cause) {
  43. case 0x00001:
  44. case 0x00011:
  45. return "POR";
  46. case 0x00004:
  47. return "CSU";
  48. case 0x00008:
  49. return "IPP USER";
  50. case 0x00010:
  51. return "WDOG";
  52. case 0x00020:
  53. return "JTAG HIGH-Z";
  54. case 0x00040:
  55. return "JTAG SW";
  56. case 0x10000:
  57. return "WARM BOOT";
  58. default:
  59. return "unknown reset";
  60. }
  61. }
  62. #if defined(CONFIG_MX53) || defined(CONFIG_MX6)
  63. #if defined(CONFIG_MX53)
  64. #define MEMCTL_BASE ESDCTL_BASE_ADDR;
  65. #else
  66. #define MEMCTL_BASE MMDC_P0_BASE_ADDR;
  67. #endif
  68. static const unsigned char col_lookup[] = {9, 10, 11, 8, 12, 9, 9, 9};
  69. static const unsigned char bank_lookup[] = {3, 2};
  70. struct esd_mmdc_regs {
  71. uint32_t ctl;
  72. uint32_t pdc;
  73. uint32_t otc;
  74. uint32_t cfg0;
  75. uint32_t cfg1;
  76. uint32_t cfg2;
  77. uint32_t misc;
  78. uint32_t scr;
  79. uint32_t ref;
  80. uint32_t rsvd1;
  81. uint32_t rsvd2;
  82. uint32_t rwd;
  83. uint32_t or;
  84. uint32_t mrr;
  85. uint32_t cfg3lp;
  86. uint32_t mr4;
  87. };
  88. #define ESD_MMDC_CTL_GET_ROW(mdctl) ((ctl >> 24) & 7)
  89. #define ESD_MMDC_CTL_GET_COLUMN(mdctl) ((ctl >> 20) & 7)
  90. #define ESD_MMDC_CTL_GET_WIDTH(mdctl) ((ctl >> 16) & 3)
  91. #define ESD_MMDC_CTL_GET_CS1(mdctl) ((ctl >> 30) & 1)
  92. #define ESD_MMDC_MISC_GET_BANK(mdmisc) ((misc >> 5) & 1)
  93. unsigned imx_ddr_size(void)
  94. {
  95. struct esd_mmdc_regs *mem = (struct esd_mmdc_regs *)MEMCTL_BASE;
  96. unsigned ctl = readl(&mem->ctl);
  97. unsigned misc = readl(&mem->misc);
  98. int bits = 11 + 0 + 0 + 1; /* row + col + bank + width */
  99. bits += ESD_MMDC_CTL_GET_ROW(ctl);
  100. bits += col_lookup[ESD_MMDC_CTL_GET_COLUMN(ctl)];
  101. bits += bank_lookup[ESD_MMDC_MISC_GET_BANK(misc)];
  102. bits += ESD_MMDC_CTL_GET_WIDTH(ctl);
  103. bits += ESD_MMDC_CTL_GET_CS1(ctl);
  104. return 1 << bits;
  105. }
  106. #endif
  107. #if defined(CONFIG_DISPLAY_CPUINFO)
  108. const char *get_imx_type(u32 imxtype)
  109. {
  110. switch (imxtype) {
  111. case MXC_CPU_MX6Q:
  112. return "6Q"; /* Quad-core version of the mx6 */
  113. case MXC_CPU_MX6DL:
  114. return "6DL"; /* Dual Lite version of the mx6 */
  115. case MXC_CPU_MX6SOLO:
  116. return "6SOLO"; /* Solo version of the mx6 */
  117. case MXC_CPU_MX6SL:
  118. return "6SL"; /* Solo-Lite version of the mx6 */
  119. case MXC_CPU_MX51:
  120. return "51";
  121. case MXC_CPU_MX53:
  122. return "53";
  123. default:
  124. return "??";
  125. }
  126. }
  127. int print_cpuinfo(void)
  128. {
  129. u32 cpurev;
  130. cpurev = get_cpu_rev();
  131. printf("CPU: Freescale i.MX%s rev%d.%d at %d MHz\n",
  132. get_imx_type((cpurev & 0xFF000) >> 12),
  133. (cpurev & 0x000F0) >> 4,
  134. (cpurev & 0x0000F) >> 0,
  135. mxc_get_clock(MXC_ARM_CLK) / 1000000);
  136. printf("Reset cause: %s\n", get_reset_cause());
  137. return 0;
  138. }
  139. #endif
  140. int cpu_eth_init(bd_t *bis)
  141. {
  142. int rc = -ENODEV;
  143. #if defined(CONFIG_FEC_MXC)
  144. rc = fecmxc_initialize(bis);
  145. #endif
  146. return rc;
  147. }
  148. #ifdef CONFIG_FSL_ESDHC
  149. /*
  150. * Initializes on-chip MMC controllers.
  151. * to override, implement board_mmc_init()
  152. */
  153. int cpu_mmc_init(bd_t *bis)
  154. {
  155. return fsl_esdhc_mmc_init(bis);
  156. }
  157. #endif
  158. u32 get_ahb_clk(void)
  159. {
  160. struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
  161. u32 reg, ahb_podf;
  162. reg = __raw_readl(&imx_ccm->cbcdr);
  163. reg &= MXC_CCM_CBCDR_AHB_PODF_MASK;
  164. ahb_podf = reg >> MXC_CCM_CBCDR_AHB_PODF_OFFSET;
  165. return get_periph_clk() / (ahb_podf + 1);
  166. }
  167. #if defined(CONFIG_VIDEO_IPUV3)
  168. void arch_preboot_os(void)
  169. {
  170. /* disable video before launching O/S */
  171. ipuv3_fb_shutdown();
  172. }
  173. #endif