soc.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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/arch/imx-regs.h>
  27. #include <asm/arch/clock.h>
  28. #include <asm/errno.h>
  29. #include <asm/io.h>
  30. #ifdef CONFIG_FSL_ESDHC
  31. #include <fsl_esdhc.h>
  32. #endif
  33. #if !(defined(CONFIG_MX51) || defined(CONFIG_MX53))
  34. #error "CPU_TYPE not defined"
  35. #endif
  36. u32 get_cpu_rev(void)
  37. {
  38. #ifdef CONFIG_MX51
  39. int system_rev = 0x51000;
  40. #else
  41. int system_rev = 0x53000;
  42. #endif
  43. int reg = __raw_readl(ROM_SI_REV);
  44. #if defined(CONFIG_MX51)
  45. switch (reg) {
  46. case 0x02:
  47. system_rev |= CHIP_REV_1_1;
  48. break;
  49. case 0x10:
  50. if ((__raw_readl(GPIO1_BASE_ADDR + 0x0) & (0x1 << 22)) == 0)
  51. system_rev |= CHIP_REV_2_5;
  52. else
  53. system_rev |= CHIP_REV_2_0;
  54. break;
  55. case 0x20:
  56. system_rev |= CHIP_REV_3_0;
  57. break;
  58. default:
  59. system_rev |= CHIP_REV_1_0;
  60. break;
  61. }
  62. #else
  63. if (reg < 0x20)
  64. system_rev |= CHIP_REV_1_0;
  65. else
  66. system_rev |= reg;
  67. #endif
  68. return system_rev;
  69. }
  70. static char *get_reset_cause(void)
  71. {
  72. u32 cause;
  73. struct src *src_regs = (struct src *)SRC_BASE_ADDR;
  74. cause = readl(&src_regs->srsr);
  75. writel(cause, &src_regs->srsr);
  76. switch (cause) {
  77. case 0x00001:
  78. return "POR";
  79. case 0x00004:
  80. return "CSU";
  81. case 0x00008:
  82. return "IPP USER";
  83. case 0x00010:
  84. return "WDOG";
  85. case 0x00020:
  86. return "JTAG HIGH-Z";
  87. case 0x00040:
  88. return "JTAG SW";
  89. case 0x10000:
  90. return "WARM BOOT";
  91. default:
  92. return "unknown reset";
  93. }
  94. }
  95. #if defined(CONFIG_DISPLAY_CPUINFO)
  96. int print_cpuinfo(void)
  97. {
  98. u32 cpurev;
  99. cpurev = get_cpu_rev();
  100. printf("CPU: Freescale i.MX%x family rev%d.%d at %d MHz\n",
  101. (cpurev & 0xFF000) >> 12,
  102. (cpurev & 0x000F0) >> 4,
  103. (cpurev & 0x0000F) >> 0,
  104. mxc_get_clock(MXC_ARM_CLK) / 1000000);
  105. printf("Reset cause: %s\n", get_reset_cause());
  106. return 0;
  107. }
  108. #endif
  109. /*
  110. * Initializes on-chip ethernet controllers.
  111. * to override, implement board_eth_init()
  112. */
  113. #if defined(CONFIG_FEC_MXC)
  114. extern int fecmxc_initialize(bd_t *bis);
  115. #endif
  116. int cpu_eth_init(bd_t *bis)
  117. {
  118. int rc = -ENODEV;
  119. #if defined(CONFIG_FEC_MXC)
  120. rc = fecmxc_initialize(bis);
  121. #endif
  122. return rc;
  123. }
  124. #if defined(CONFIG_FEC_MXC)
  125. void imx_get_mac_from_fuse(unsigned char *mac)
  126. {
  127. int i;
  128. struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
  129. struct fuse_bank *bank = &iim->bank[1];
  130. struct fuse_bank1_regs *fuse =
  131. (struct fuse_bank1_regs *)bank->fuse_regs;
  132. for (i = 0; i < 6; i++)
  133. mac[i] = readl(&fuse->mac_addr[i]) & 0xff;
  134. }
  135. #endif
  136. /*
  137. * Initializes on-chip MMC controllers.
  138. * to override, implement board_mmc_init()
  139. */
  140. int cpu_mmc_init(bd_t *bis)
  141. {
  142. #ifdef CONFIG_FSL_ESDHC
  143. return fsl_esdhc_mmc_init(bis);
  144. #else
  145. return 0;
  146. #endif
  147. }
  148. void reset_cpu(ulong addr)
  149. {
  150. __raw_writew(4, WDOG1_BASE_ADDR);
  151. }