hwinit.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. *
  3. * Functions for omap5 based boards.
  4. *
  5. * (C) Copyright 2011
  6. * Texas Instruments, <www.ti.com>
  7. *
  8. * Author :
  9. * Aneesh V <aneesh@ti.com>
  10. * Steve Sakoman <steve@sakoman.com>
  11. * Sricharan <r.sricharan@ti.com>
  12. *
  13. * See file CREDITS for list of people who contributed to this
  14. * project.
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License as
  18. * published by the Free Software Foundation; either version 2 of
  19. * the License, or (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  29. * MA 02111-1307 USA
  30. */
  31. #include <common.h>
  32. #include <asm/armv7.h>
  33. #include <asm/arch/cpu.h>
  34. #include <asm/arch/sys_proto.h>
  35. #include <asm/sizes.h>
  36. #include <asm/utils.h>
  37. #include <asm/arch/gpio.h>
  38. DECLARE_GLOBAL_DATA_PTR;
  39. u32 *const omap_si_rev = (u32 *)OMAP5_SRAM_SCRATCH_OMAP5_REV;
  40. static struct gpio_bank gpio_bank_54xx[6] = {
  41. { (void *)OMAP54XX_GPIO1_BASE, METHOD_GPIO_24XX },
  42. { (void *)OMAP54XX_GPIO2_BASE, METHOD_GPIO_24XX },
  43. { (void *)OMAP54XX_GPIO3_BASE, METHOD_GPIO_24XX },
  44. { (void *)OMAP54XX_GPIO4_BASE, METHOD_GPIO_24XX },
  45. { (void *)OMAP54XX_GPIO5_BASE, METHOD_GPIO_24XX },
  46. { (void *)OMAP54XX_GPIO6_BASE, METHOD_GPIO_24XX },
  47. };
  48. const struct gpio_bank *const omap_gpio_bank = gpio_bank_54xx;
  49. #ifdef CONFIG_SPL_BUILD
  50. /*
  51. * Some tuning of IOs for optimal power and performance
  52. */
  53. void do_io_settings(void)
  54. {
  55. u32 io_settings = 0, mask = 0;
  56. struct omap_sys_ctrl_regs *ioregs_base =
  57. (struct omap_sys_ctrl_regs *) SYSCTRL_GENERAL_CORE_BASE;
  58. /* Impedance settings EMMC, C2C 1,2, hsi2 */
  59. mask = (ds_mask << 2) | (ds_mask << 8) |
  60. (ds_mask << 16) | (ds_mask << 18);
  61. io_settings = readl(&(ioregs_base->control_smart1io_padconf_0)) &
  62. (~mask);
  63. io_settings |= (ds_60_ohm << 8) | (ds_45_ohm << 16) |
  64. (ds_45_ohm << 18) | (ds_60_ohm << 2);
  65. writel(io_settings, &(ioregs_base->control_smart1io_padconf_0));
  66. /* Impedance settings Mcspi2 */
  67. mask = (ds_mask << 30);
  68. io_settings = readl(&(ioregs_base->control_smart1io_padconf_1)) &
  69. (~mask);
  70. io_settings |= (ds_60_ohm << 30);
  71. writel(io_settings, &(ioregs_base->control_smart1io_padconf_1));
  72. /* Impedance settings C2C 3,4 */
  73. mask = (ds_mask << 14) | (ds_mask << 16);
  74. io_settings = readl(&(ioregs_base->control_smart1io_padconf_2)) &
  75. (~mask);
  76. io_settings |= (ds_45_ohm << 14) | (ds_45_ohm << 16);
  77. writel(io_settings, &(ioregs_base->control_smart1io_padconf_2));
  78. /* Slew rate settings EMMC, C2C 1,2 */
  79. mask = (sc_mask << 8) | (sc_mask << 16) | (sc_mask << 18);
  80. io_settings = readl(&(ioregs_base->control_smart2io_padconf_0)) &
  81. (~mask);
  82. io_settings |= (sc_fast << 8) | (sc_na << 16) | (sc_na << 18);
  83. writel(io_settings, &(ioregs_base->control_smart2io_padconf_0));
  84. /* Slew rate settings hsi2, Mcspi2 */
  85. mask = (sc_mask << 24) | (sc_mask << 28);
  86. io_settings = readl(&(ioregs_base->control_smart2io_padconf_1)) &
  87. (~mask);
  88. io_settings |= (sc_fast << 28) | (sc_fast << 24);
  89. writel(io_settings, &(ioregs_base->control_smart2io_padconf_1));
  90. /* Slew rate settings C2C 3,4 */
  91. mask = (sc_mask << 16) | (sc_mask << 18);
  92. io_settings = readl(&(ioregs_base->control_smart2io_padconf_2)) &
  93. (~mask);
  94. io_settings |= (sc_na << 16) | (sc_na << 18);
  95. writel(io_settings, &(ioregs_base->control_smart2io_padconf_2));
  96. /* impedance and slew rate settings for usb */
  97. mask = (usb_i_mask << 29) | (usb_i_mask << 26) | (usb_i_mask << 23) |
  98. (usb_i_mask << 20) | (usb_i_mask << 17) | (usb_i_mask << 14);
  99. io_settings = readl(&(ioregs_base->control_smart3io_padconf_1)) &
  100. (~mask);
  101. io_settings |= (ds_60_ohm << 29) | (ds_60_ohm << 26) |
  102. (ds_60_ohm << 23) | (sc_fast << 20) |
  103. (sc_fast << 17) | (sc_fast << 14);
  104. writel(io_settings, &(ioregs_base->control_smart3io_padconf_1));
  105. /* LPDDR2 io settings */
  106. writel(DDR_IO_I_34OHM_SR_FASTEST_WD_DQ_NO_PULL_DQS_PULL_DOWN,
  107. &(ioregs_base->control_ddrch1_0));
  108. writel(DDR_IO_I_34OHM_SR_FASTEST_WD_DQ_NO_PULL_DQS_PULL_DOWN,
  109. &(ioregs_base->control_ddrch1_1));
  110. writel(DDR_IO_I_34OHM_SR_FASTEST_WD_DQ_NO_PULL_DQS_PULL_DOWN,
  111. &(ioregs_base->control_ddrch2_0));
  112. writel(DDR_IO_I_34OHM_SR_FASTEST_WD_DQ_NO_PULL_DQS_PULL_DOWN,
  113. &(ioregs_base->control_ddrch2_1));
  114. writel(DDR_IO_I_34OHM_SR_FASTEST_WD_CK_CKE_NCS_CA_PULL_DOWN,
  115. &(ioregs_base->control_lpddr2ch1_0));
  116. writel(DDR_IO_I_34OHM_SR_FASTEST_WD_CK_CKE_NCS_CA_PULL_DOWN,
  117. &(ioregs_base->control_lpddr2ch1_1));
  118. writel(DDR_IO_0_DDR2_DQ_INT_EN_ALL_DDR3_CA_DIS_ALL,
  119. &(ioregs_base->control_ddrio_0));
  120. writel(DDR_IO_1_DQ_OUT_EN_ALL_DQ_INT_EN_ALL,
  121. &(ioregs_base->control_ddrio_1));
  122. writel(DDR_IO_2_CA_OUT_EN_ALL_CA_INT_EN_ALL,
  123. &(ioregs_base->control_ddrio_2));
  124. /* Efuse settings */
  125. writel(EFUSE_1, &(ioregs_base->control_efuse_1));
  126. writel(EFUSE_2, &(ioregs_base->control_efuse_2));
  127. writel(EFUSE_3, &(ioregs_base->control_efuse_3));
  128. writel(EFUSE_4, &(ioregs_base->control_efuse_4));
  129. }
  130. #endif
  131. void init_omap_revision(void)
  132. {
  133. /*
  134. * For some of the ES2/ES1 boards ID_CODE is not reliable:
  135. * Also, ES1 and ES2 have different ARM revisions
  136. * So use ARM revision for identification
  137. */
  138. unsigned int rev = cortex_rev();
  139. switch (rev) {
  140. case MIDR_CORTEX_A15_R0P0:
  141. switch (readl(CONTROL_ID_CODE)) {
  142. case OMAP5430_CONTROL_ID_CODE_ES1_0:
  143. *omap_si_rev = OMAP5430_ES1_0;
  144. break;
  145. case OMAP5432_CONTROL_ID_CODE_ES1_0:
  146. default:
  147. *omap_si_rev = OMAP5432_ES1_0;
  148. break;
  149. }
  150. break;
  151. default:
  152. *omap_si_rev = OMAP5430_SILICON_ID_INVALID;
  153. }
  154. }
  155. void reset_cpu(ulong ignored)
  156. {
  157. u32 omap_rev = omap_revision();
  158. /*
  159. * WARM reset is not functional in case of OMAP5430 ES1.0 soc.
  160. * So use cold reset in case instead.
  161. */
  162. if (omap_rev == OMAP5430_ES1_0)
  163. writel(PRM_RSTCTRL_RESET << 0x1, PRM_RSTCTRL);
  164. else
  165. writel(PRM_RSTCTRL_RESET, PRM_RSTCTRL);
  166. }