hwinit.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. * SPDX-License-Identifier: GPL-2.0+
  13. */
  14. #include <common.h>
  15. #include <palmas.h>
  16. #include <asm/armv7.h>
  17. #include <asm/arch/cpu.h>
  18. #include <asm/arch/sys_proto.h>
  19. #include <linux/sizes.h>
  20. #include <asm/emif.h>
  21. #include <asm/arch/gpio.h>
  22. #include <asm/omap_common.h>
  23. DECLARE_GLOBAL_DATA_PTR;
  24. u32 *const omap_si_rev = (u32 *)OMAP_SRAM_SCRATCH_OMAP_REV;
  25. static const struct gpio_bank gpio_bank_44xx[6] = {
  26. { (void *)OMAP44XX_GPIO1_BASE },
  27. { (void *)OMAP44XX_GPIO2_BASE },
  28. { (void *)OMAP44XX_GPIO3_BASE },
  29. { (void *)OMAP44XX_GPIO4_BASE },
  30. { (void *)OMAP44XX_GPIO5_BASE },
  31. { (void *)OMAP44XX_GPIO6_BASE },
  32. };
  33. const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx;
  34. #ifdef CONFIG_SPL_BUILD
  35. /*
  36. * Some tuning of IOs for optimal power and performance
  37. */
  38. void do_io_settings(void)
  39. {
  40. u32 lpddr2io;
  41. u32 omap4_rev = omap_revision();
  42. if (omap4_rev == OMAP4430_ES1_0)
  43. lpddr2io = CONTROL_LPDDR2IO_SLEW_125PS_DRV8_PULL_DOWN;
  44. else if (omap4_rev == OMAP4430_ES2_0)
  45. lpddr2io = CONTROL_LPDDR2IO_SLEW_325PS_DRV8_GATE_KEEPER;
  46. else
  47. lpddr2io = CONTROL_LPDDR2IO_SLEW_315PS_DRV12_PULL_DOWN;
  48. /* EMIF1 */
  49. writel(lpddr2io, (*ctrl)->control_lpddr2io1_0);
  50. writel(lpddr2io, (*ctrl)->control_lpddr2io1_1);
  51. /* No pull for GR10 as per hw team's recommendation */
  52. writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
  53. (*ctrl)->control_lpddr2io1_2);
  54. writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io1_3);
  55. /* EMIF2 */
  56. writel(lpddr2io, (*ctrl)->control_lpddr2io2_0);
  57. writel(lpddr2io, (*ctrl)->control_lpddr2io2_1);
  58. /* No pull for GR10 as per hw team's recommendation */
  59. writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
  60. (*ctrl)->control_lpddr2io2_2);
  61. writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io2_3);
  62. /*
  63. * Some of these settings (TRIM values) come from eFuse and are
  64. * in turn programmed in the eFuse at manufacturing time after
  65. * calibration of the device. Do the software over-ride only if
  66. * the device is not correctly trimmed
  67. */
  68. if (!(readl((*ctrl)->control_std_fuse_opp_bgap) & 0xFFFF)) {
  69. writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
  70. (*ctrl)->control_ldosram_iva_voltage_ctrl);
  71. writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
  72. (*ctrl)->control_ldosram_mpu_voltage_ctrl);
  73. writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
  74. (*ctrl)->control_ldosram_core_voltage_ctrl);
  75. }
  76. /*
  77. * Over-ride the register
  78. * i. unconditionally for all 4430
  79. * ii. only if un-trimmed for 4460
  80. */
  81. if (!readl((*ctrl)->control_efuse_1))
  82. writel(CONTROL_EFUSE_1_OVERRIDE, (*ctrl)->control_efuse_1);
  83. if ((omap4_rev < OMAP4460_ES1_0) || !readl((*ctrl)->control_efuse_2))
  84. writel(CONTROL_EFUSE_2_OVERRIDE, (*ctrl)->control_efuse_2);
  85. }
  86. #endif /* CONFIG_SPL_BUILD */
  87. /* dummy fuction for omap4 */
  88. void config_data_eye_leveling_samples(u32 emif_base)
  89. {
  90. }
  91. void init_omap_revision(void)
  92. {
  93. /*
  94. * For some of the ES2/ES1 boards ID_CODE is not reliable:
  95. * Also, ES1 and ES2 have different ARM revisions
  96. * So use ARM revision for identification
  97. */
  98. unsigned int arm_rev = cortex_rev();
  99. switch (arm_rev) {
  100. case MIDR_CORTEX_A9_R0P1:
  101. *omap_si_rev = OMAP4430_ES1_0;
  102. break;
  103. case MIDR_CORTEX_A9_R1P2:
  104. switch (readl(CONTROL_ID_CODE)) {
  105. case OMAP4_CONTROL_ID_CODE_ES2_0:
  106. *omap_si_rev = OMAP4430_ES2_0;
  107. break;
  108. case OMAP4_CONTROL_ID_CODE_ES2_1:
  109. *omap_si_rev = OMAP4430_ES2_1;
  110. break;
  111. case OMAP4_CONTROL_ID_CODE_ES2_2:
  112. *omap_si_rev = OMAP4430_ES2_2;
  113. break;
  114. default:
  115. *omap_si_rev = OMAP4430_ES2_0;
  116. break;
  117. }
  118. break;
  119. case MIDR_CORTEX_A9_R1P3:
  120. *omap_si_rev = OMAP4430_ES2_3;
  121. break;
  122. case MIDR_CORTEX_A9_R2P10:
  123. switch (readl(CONTROL_ID_CODE)) {
  124. case OMAP4470_CONTROL_ID_CODE_ES1_0:
  125. *omap_si_rev = OMAP4470_ES1_0;
  126. break;
  127. case OMAP4460_CONTROL_ID_CODE_ES1_1:
  128. *omap_si_rev = OMAP4460_ES1_1;
  129. break;
  130. case OMAP4460_CONTROL_ID_CODE_ES1_0:
  131. default:
  132. *omap_si_rev = OMAP4460_ES1_0;
  133. break;
  134. }
  135. break;
  136. default:
  137. *omap_si_rev = OMAP4430_SILICON_ID_INVALID;
  138. break;
  139. }
  140. }
  141. void omap_die_id(unsigned int *die_id)
  142. {
  143. die_id[0] = readl((*ctrl)->control_std_fuse_die_id_0);
  144. die_id[1] = readl((*ctrl)->control_std_fuse_die_id_1);
  145. die_id[2] = readl((*ctrl)->control_std_fuse_die_id_2);
  146. die_id[3] = readl((*ctrl)->control_std_fuse_die_id_3);
  147. }
  148. #ifndef CONFIG_SYS_L2CACHE_OFF
  149. void v7_outer_cache_enable(void)
  150. {
  151. omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 1);
  152. }
  153. void v7_outer_cache_disable(void)
  154. {
  155. omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 0);
  156. }
  157. #endif /* !CONFIG_SYS_L2CACHE_OFF */
  158. void vmmc_pbias_config(uint voltage)
  159. {
  160. u32 value = 0;
  161. value = readl((*ctrl)->control_pbiaslite);
  162. value &= ~(MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ);
  163. writel(value, (*ctrl)->control_pbiaslite);
  164. value = readl((*ctrl)->control_pbiaslite);
  165. value |= MMC1_PBIASLITE_VMODE | MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ;
  166. writel(value, (*ctrl)->control_pbiaslite);
  167. }