hwinit.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. *
  3. * Common functions for OMAP4 based boards
  4. *
  5. * (C) Copyright 2010
  6. * Texas Instruments, <www.ti.com>
  7. *
  8. * Author :
  9. * Aneesh V <aneesh@ti.com>
  10. * Steve Sakoman <steve@sakoman.com>
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28. * MA 02111-1307 USA
  29. */
  30. #include <common.h>
  31. #include <asm/armv7.h>
  32. #include <asm/arch/cpu.h>
  33. #include <asm/arch/sys_proto.h>
  34. #include <asm/sizes.h>
  35. #include <asm/emif.h>
  36. #include <asm/arch/gpio.h>
  37. DECLARE_GLOBAL_DATA_PTR;
  38. u32 *const omap_si_rev = (u32 *)OMAP4_SRAM_SCRATCH_OMAP4_REV;
  39. static const struct gpio_bank gpio_bank_44xx[6] = {
  40. { (void *)OMAP44XX_GPIO1_BASE, METHOD_GPIO_24XX },
  41. { (void *)OMAP44XX_GPIO2_BASE, METHOD_GPIO_24XX },
  42. { (void *)OMAP44XX_GPIO3_BASE, METHOD_GPIO_24XX },
  43. { (void *)OMAP44XX_GPIO4_BASE, METHOD_GPIO_24XX },
  44. { (void *)OMAP44XX_GPIO5_BASE, METHOD_GPIO_24XX },
  45. { (void *)OMAP44XX_GPIO6_BASE, METHOD_GPIO_24XX },
  46. };
  47. const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx;
  48. #ifdef CONFIG_SPL_BUILD
  49. /*
  50. * Some tuning of IOs for optimal power and performance
  51. */
  52. void do_io_settings(void)
  53. {
  54. u32 lpddr2io;
  55. struct control_lpddr2io_regs *lpddr2io_regs =
  56. (struct control_lpddr2io_regs *)LPDDR2_IO_REGS_BASE;
  57. struct omap_sys_ctrl_regs *const ctrl =
  58. (struct omap_sys_ctrl_regs *)SYSCTRL_GENERAL_CORE_BASE;
  59. u32 omap4_rev = omap_revision();
  60. if (omap4_rev == OMAP4430_ES1_0)
  61. lpddr2io = CONTROL_LPDDR2IO_SLEW_125PS_DRV8_PULL_DOWN;
  62. else if (omap4_rev == OMAP4430_ES2_0)
  63. lpddr2io = CONTROL_LPDDR2IO_SLEW_325PS_DRV8_GATE_KEEPER;
  64. else
  65. lpddr2io = CONTROL_LPDDR2IO_SLEW_315PS_DRV12_PULL_DOWN;
  66. /* EMIF1 */
  67. writel(lpddr2io, &lpddr2io_regs->control_lpddr2io1_0);
  68. writel(lpddr2io, &lpddr2io_regs->control_lpddr2io1_1);
  69. /* No pull for GR10 as per hw team's recommendation */
  70. writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
  71. &lpddr2io_regs->control_lpddr2io1_2);
  72. writel(CONTROL_LPDDR2IO_3_VAL, &lpddr2io_regs->control_lpddr2io1_3);
  73. /* EMIF2 */
  74. writel(lpddr2io, &lpddr2io_regs->control_lpddr2io2_0);
  75. writel(lpddr2io, &lpddr2io_regs->control_lpddr2io2_1);
  76. /* No pull for GR10 as per hw team's recommendation */
  77. writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
  78. &lpddr2io_regs->control_lpddr2io2_2);
  79. writel(CONTROL_LPDDR2IO_3_VAL, &lpddr2io_regs->control_lpddr2io2_3);
  80. /*
  81. * Some of these settings (TRIM values) come from eFuse and are
  82. * in turn programmed in the eFuse at manufacturing time after
  83. * calibration of the device. Do the software over-ride only if
  84. * the device is not correctly trimmed
  85. */
  86. if (!(readl(&ctrl->control_std_fuse_opp_bgap) & 0xFFFF)) {
  87. writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
  88. &ctrl->control_ldosram_iva_voltage_ctrl);
  89. writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
  90. &ctrl->control_ldosram_mpu_voltage_ctrl);
  91. writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
  92. &ctrl->control_ldosram_core_voltage_ctrl);
  93. }
  94. /*
  95. * Over-ride the register
  96. * i. unconditionally for all 4430
  97. * ii. only if un-trimmed for 4460
  98. */
  99. if (!readl(&ctrl->control_efuse_1))
  100. writel(CONTROL_EFUSE_1_OVERRIDE, &ctrl->control_efuse_1);
  101. if ((omap4_rev < OMAP4460_ES1_0) || !readl(&ctrl->control_efuse_2))
  102. writel(CONTROL_EFUSE_2_OVERRIDE, &ctrl->control_efuse_2);
  103. }
  104. #endif /* CONFIG_SPL_BUILD */
  105. /* dummy fuction for omap4 */
  106. void config_data_eye_leveling_samples(u32 emif_base)
  107. {
  108. }
  109. void init_omap_revision(void)
  110. {
  111. /*
  112. * For some of the ES2/ES1 boards ID_CODE is not reliable:
  113. * Also, ES1 and ES2 have different ARM revisions
  114. * So use ARM revision for identification
  115. */
  116. unsigned int arm_rev = cortex_rev();
  117. switch (arm_rev) {
  118. case MIDR_CORTEX_A9_R0P1:
  119. *omap_si_rev = OMAP4430_ES1_0;
  120. break;
  121. case MIDR_CORTEX_A9_R1P2:
  122. switch (readl(CONTROL_ID_CODE)) {
  123. case OMAP4_CONTROL_ID_CODE_ES2_0:
  124. *omap_si_rev = OMAP4430_ES2_0;
  125. break;
  126. case OMAP4_CONTROL_ID_CODE_ES2_1:
  127. *omap_si_rev = OMAP4430_ES2_1;
  128. break;
  129. case OMAP4_CONTROL_ID_CODE_ES2_2:
  130. *omap_si_rev = OMAP4430_ES2_2;
  131. break;
  132. default:
  133. *omap_si_rev = OMAP4430_ES2_0;
  134. break;
  135. }
  136. break;
  137. case MIDR_CORTEX_A9_R1P3:
  138. *omap_si_rev = OMAP4430_ES2_3;
  139. break;
  140. case MIDR_CORTEX_A9_R2P10:
  141. switch (readl(CONTROL_ID_CODE)) {
  142. case OMAP4460_CONTROL_ID_CODE_ES1_1:
  143. *omap_si_rev = OMAP4460_ES1_1;
  144. break;
  145. case OMAP4460_CONTROL_ID_CODE_ES1_0:
  146. default:
  147. *omap_si_rev = OMAP4460_ES1_0;
  148. break;
  149. }
  150. break;
  151. default:
  152. *omap_si_rev = OMAP4430_SILICON_ID_INVALID;
  153. break;
  154. }
  155. }
  156. #ifndef CONFIG_SYS_L2CACHE_OFF
  157. void v7_outer_cache_enable(void)
  158. {
  159. set_pl310_ctrl_reg(1);
  160. }
  161. void v7_outer_cache_disable(void)
  162. {
  163. set_pl310_ctrl_reg(0);
  164. }
  165. #endif /* !CONFIG_SYS_L2CACHE_OFF */