soc.c 4.0 KB

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