soc.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. #include <asm/imx-common/boot_mode.h>
  32. #if !(defined(CONFIG_MX51) || defined(CONFIG_MX53))
  33. #error "CPU_TYPE not defined"
  34. #endif
  35. u32 get_cpu_rev(void)
  36. {
  37. #ifdef CONFIG_MX51
  38. int system_rev = 0x51000;
  39. #else
  40. int system_rev = 0x53000;
  41. #endif
  42. int reg = __raw_readl(ROM_SI_REV);
  43. #if defined(CONFIG_MX51)
  44. switch (reg) {
  45. case 0x02:
  46. system_rev |= CHIP_REV_1_1;
  47. break;
  48. case 0x10:
  49. if ((__raw_readl(GPIO1_BASE_ADDR + 0x0) & (0x1 << 22)) == 0)
  50. system_rev |= CHIP_REV_2_5;
  51. else
  52. system_rev |= CHIP_REV_2_0;
  53. break;
  54. case 0x20:
  55. system_rev |= CHIP_REV_3_0;
  56. break;
  57. default:
  58. system_rev |= CHIP_REV_1_0;
  59. break;
  60. }
  61. #else
  62. if (reg < 0x20)
  63. system_rev |= CHIP_REV_1_0;
  64. else
  65. system_rev |= reg;
  66. #endif
  67. return system_rev;
  68. }
  69. #ifdef CONFIG_REVISION_TAG
  70. u32 __weak get_board_rev(void)
  71. {
  72. return get_cpu_rev();
  73. }
  74. #endif
  75. #ifndef CONFIG_SYS_DCACHE_OFF
  76. void enable_caches(void)
  77. {
  78. /* Enable D-cache. I-cache is already enabled in start.S */
  79. dcache_enable();
  80. }
  81. #endif
  82. #if defined(CONFIG_FEC_MXC)
  83. void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
  84. {
  85. int i;
  86. struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
  87. struct fuse_bank *bank = &iim->bank[1];
  88. struct fuse_bank1_regs *fuse =
  89. (struct fuse_bank1_regs *)bank->fuse_regs;
  90. for (i = 0; i < 6; i++)
  91. mac[i] = readl(&fuse->mac_addr[i]) & 0xff;
  92. }
  93. #endif
  94. void set_chipselect_size(int const cs_size)
  95. {
  96. unsigned int reg;
  97. struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
  98. reg = readl(&iomuxc_regs->gpr1);
  99. switch (cs_size) {
  100. case CS0_128:
  101. reg &= ~0x7; /* CS0=128MB, CS1=0, CS2=0, CS3=0 */
  102. reg |= 0x5;
  103. break;
  104. case CS0_64M_CS1_64M:
  105. reg &= ~0x3F; /* CS0=64MB, CS1=64MB, CS2=0, CS3=0 */
  106. reg |= 0x1B;
  107. break;
  108. case CS0_64M_CS1_32M_CS2_32M:
  109. reg &= ~0x1FF; /* CS0=64MB, CS1=32MB, CS2=32MB, CS3=0 */
  110. reg |= 0x4B;
  111. break;
  112. case CS0_32M_CS1_32M_CS2_32M_CS3_32M:
  113. reg &= ~0xFFF; /* CS0=32MB, CS1=32MB, CS2=32MB, CS3=32MB */
  114. reg |= 0x249;
  115. break;
  116. default:
  117. printf("Unknown chip select size: %d\n", cs_size);
  118. break;
  119. }
  120. writel(reg, &iomuxc_regs->gpr1);
  121. }
  122. #ifdef CONFIG_MX53
  123. void boot_mode_apply(unsigned cfg_val)
  124. {
  125. writel(cfg_val, &((struct srtc_regs *)SRTC_BASE_ADDR)->lpgr);
  126. }
  127. /*
  128. * cfg_val will be used for
  129. * Boot_cfg3[7:0]:Boot_cfg2[7:0]:Boot_cfg1[7:0]
  130. *
  131. * If bit 28 of LPGR is set upon watchdog reset,
  132. * bits[25:0] of LPGR will move to SBMR.
  133. */
  134. const struct boot_mode soc_boot_modes[] = {
  135. {"normal", MAKE_CFGVAL(0x00, 0x00, 0x00, 0x00)},
  136. /* usb or serial download */
  137. {"usb", MAKE_CFGVAL(0x00, 0x00, 0x00, 0x13)},
  138. {"sata", MAKE_CFGVAL(0x28, 0x00, 0x00, 0x12)},
  139. {"escpi1:0", MAKE_CFGVAL(0x38, 0x20, 0x00, 0x12)},
  140. {"escpi1:1", MAKE_CFGVAL(0x38, 0x20, 0x04, 0x12)},
  141. {"escpi1:2", MAKE_CFGVAL(0x38, 0x20, 0x08, 0x12)},
  142. {"escpi1:3", MAKE_CFGVAL(0x38, 0x20, 0x0c, 0x12)},
  143. /* 4 bit bus width */
  144. {"esdhc1", MAKE_CFGVAL(0x40, 0x20, 0x00, 0x12)},
  145. {"esdhc2", MAKE_CFGVAL(0x40, 0x20, 0x08, 0x12)},
  146. {"esdhc3", MAKE_CFGVAL(0x40, 0x20, 0x10, 0x12)},
  147. {"esdhc4", MAKE_CFGVAL(0x40, 0x20, 0x18, 0x12)},
  148. {NULL, 0},
  149. };
  150. #endif