blob: f4123aaffca6a8b0bc5564b904d60b8d998f901d [file] [log] [blame]
Sricharan9310ff72011-11-15 09:49:55 -05001/*
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>
Sricharan62a86502011-11-15 09:50:00 -050035#include <asm/emif.h>
Sricharan9310ff72011-11-15 09:49:55 -050036#include <asm/arch/gpio.h>
37
38DECLARE_GLOBAL_DATA_PTR;
39
SRICHARAN Rd3901b12012-03-12 02:25:40 +000040u32 *const omap_si_rev = (u32 *)OMAP4_SRAM_SCRATCH_OMAP4_REV;
Sricharan9310ff72011-11-15 09:49:55 -050041
42static const struct gpio_bank gpio_bank_44xx[6] = {
43 { (void *)OMAP44XX_GPIO1_BASE, METHOD_GPIO_24XX },
44 { (void *)OMAP44XX_GPIO2_BASE, METHOD_GPIO_24XX },
45 { (void *)OMAP44XX_GPIO3_BASE, METHOD_GPIO_24XX },
46 { (void *)OMAP44XX_GPIO4_BASE, METHOD_GPIO_24XX },
47 { (void *)OMAP44XX_GPIO5_BASE, METHOD_GPIO_24XX },
48 { (void *)OMAP44XX_GPIO6_BASE, METHOD_GPIO_24XX },
49};
50
51const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx;
52
53#ifdef CONFIG_SPL_BUILD
54/*
55 * Some tuning of IOs for optimal power and performance
56 */
57void do_io_settings(void)
58{
59 u32 lpddr2io;
60 struct control_lpddr2io_regs *lpddr2io_regs =
61 (struct control_lpddr2io_regs *)LPDDR2_IO_REGS_BASE;
SRICHARAN R20c372f2012-03-12 02:25:42 +000062 struct omap_sys_ctrl_regs *const ctrl =
63 (struct omap_sys_ctrl_regs *)SYSCTRL_GENERAL_CORE_BASE;
Sricharan9310ff72011-11-15 09:49:55 -050064
65 u32 omap4_rev = omap_revision();
66
67 if (omap4_rev == OMAP4430_ES1_0)
68 lpddr2io = CONTROL_LPDDR2IO_SLEW_125PS_DRV8_PULL_DOWN;
69 else if (omap4_rev == OMAP4430_ES2_0)
70 lpddr2io = CONTROL_LPDDR2IO_SLEW_325PS_DRV8_GATE_KEEPER;
71 else
72 lpddr2io = CONTROL_LPDDR2IO_SLEW_315PS_DRV12_PULL_DOWN;
73
74 /* EMIF1 */
75 writel(lpddr2io, &lpddr2io_regs->control_lpddr2io1_0);
76 writel(lpddr2io, &lpddr2io_regs->control_lpddr2io1_1);
77 /* No pull for GR10 as per hw team's recommendation */
78 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
79 &lpddr2io_regs->control_lpddr2io1_2);
80 writel(CONTROL_LPDDR2IO_3_VAL, &lpddr2io_regs->control_lpddr2io1_3);
81
82 /* EMIF2 */
83 writel(lpddr2io, &lpddr2io_regs->control_lpddr2io2_0);
84 writel(lpddr2io, &lpddr2io_regs->control_lpddr2io2_1);
85 /* No pull for GR10 as per hw team's recommendation */
86 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
87 &lpddr2io_regs->control_lpddr2io2_2);
88 writel(CONTROL_LPDDR2IO_3_VAL, &lpddr2io_regs->control_lpddr2io2_3);
89
90 /*
91 * Some of these settings (TRIM values) come from eFuse and are
92 * in turn programmed in the eFuse at manufacturing time after
93 * calibration of the device. Do the software over-ride only if
94 * the device is not correctly trimmed
95 */
96 if (!(readl(&ctrl->control_std_fuse_opp_bgap) & 0xFFFF)) {
97
98 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
99 &ctrl->control_ldosram_iva_voltage_ctrl);
100
101 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
102 &ctrl->control_ldosram_mpu_voltage_ctrl);
103
104 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
105 &ctrl->control_ldosram_core_voltage_ctrl);
106 }
107
Aneesh V8ed98d82011-11-21 23:39:05 +0000108 /*
109 * Over-ride the register
110 * i. unconditionally for all 4430
111 * ii. only if un-trimmed for 4460
112 */
Aneesh V89376b32011-12-29 08:47:17 +0000113 if (!readl(&ctrl->control_efuse_1))
Sricharan9310ff72011-11-15 09:49:55 -0500114 writel(CONTROL_EFUSE_1_OVERRIDE, &ctrl->control_efuse_1);
115
Aneesh V89376b32011-12-29 08:47:17 +0000116 if ((omap4_rev < OMAP4460_ES1_0) || !readl(&ctrl->control_efuse_2))
Sricharan9310ff72011-11-15 09:49:55 -0500117 writel(CONTROL_EFUSE_2_OVERRIDE, &ctrl->control_efuse_2);
118}
Robert P. J. Day3037e522012-11-13 08:12:08 +0000119#endif /* CONFIG_SPL_BUILD */
Sricharan9310ff72011-11-15 09:49:55 -0500120
Lokesh Vutla0f42de62012-05-22 00:03:25 +0000121/* dummy fuction for omap4 */
122void config_data_eye_leveling_samples(u32 emif_base)
123{
124}
125
Sricharan9310ff72011-11-15 09:49:55 -0500126void init_omap_revision(void)
127{
128 /*
129 * For some of the ES2/ES1 boards ID_CODE is not reliable:
130 * Also, ES1 and ES2 have different ARM revisions
131 * So use ARM revision for identification
132 */
133 unsigned int arm_rev = cortex_rev();
134
135 switch (arm_rev) {
136 case MIDR_CORTEX_A9_R0P1:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000137 *omap_si_rev = OMAP4430_ES1_0;
Sricharan9310ff72011-11-15 09:49:55 -0500138 break;
139 case MIDR_CORTEX_A9_R1P2:
140 switch (readl(CONTROL_ID_CODE)) {
141 case OMAP4_CONTROL_ID_CODE_ES2_0:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000142 *omap_si_rev = OMAP4430_ES2_0;
Sricharan9310ff72011-11-15 09:49:55 -0500143 break;
144 case OMAP4_CONTROL_ID_CODE_ES2_1:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000145 *omap_si_rev = OMAP4430_ES2_1;
Sricharan9310ff72011-11-15 09:49:55 -0500146 break;
147 case OMAP4_CONTROL_ID_CODE_ES2_2:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000148 *omap_si_rev = OMAP4430_ES2_2;
Sricharan9310ff72011-11-15 09:49:55 -0500149 break;
150 default:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000151 *omap_si_rev = OMAP4430_ES2_0;
Sricharan9310ff72011-11-15 09:49:55 -0500152 break;
153 }
154 break;
155 case MIDR_CORTEX_A9_R1P3:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000156 *omap_si_rev = OMAP4430_ES2_3;
Sricharan9310ff72011-11-15 09:49:55 -0500157 break;
158 case MIDR_CORTEX_A9_R2P10:
Aneesh Va04c3042011-11-21 23:39:03 +0000159 switch (readl(CONTROL_ID_CODE)) {
160 case OMAP4460_CONTROL_ID_CODE_ES1_1:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000161 *omap_si_rev = OMAP4460_ES1_1;
Aneesh Va04c3042011-11-21 23:39:03 +0000162 break;
163 case OMAP4460_CONTROL_ID_CODE_ES1_0:
164 default:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000165 *omap_si_rev = OMAP4460_ES1_0;
Aneesh Va04c3042011-11-21 23:39:03 +0000166 break;
167 }
Sricharan9310ff72011-11-15 09:49:55 -0500168 break;
169 default:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000170 *omap_si_rev = OMAP4430_SILICON_ID_INVALID;
Sricharan9310ff72011-11-15 09:49:55 -0500171 break;
172 }
173}
174
175#ifndef CONFIG_SYS_L2CACHE_OFF
176void v7_outer_cache_enable(void)
177{
178 set_pl310_ctrl_reg(1);
179}
180
181void v7_outer_cache_disable(void)
182{
183 set_pl310_ctrl_reg(0);
184}
Robert P. J. Day3037e522012-11-13 08:12:08 +0000185#endif /* !CONFIG_SYS_L2CACHE_OFF */