blob: 81f5a48e509ab2202cddc02c30c7519447e61043 [file] [log] [blame]
Sricharan508a58f2011-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>
Sricharanbb772a52011-11-15 09:50:00 -050035#include <asm/emif.h>
Sricharan508a58f2011-11-15 09:49:55 -050036#include <asm/arch/gpio.h>
SRICHARAN Rf92f2272013-04-24 00:41:22 +000037#include <asm/omap_common.h>
Sricharan508a58f2011-11-15 09:49:55 -050038
39DECLARE_GLOBAL_DATA_PTR;
40
SRICHARAN Rf92f2272013-04-24 00:41:22 +000041u32 *const omap_si_rev = (u32 *)OMAP_SRAM_SCRATCH_OMAP_REV;
Sricharan508a58f2011-11-15 09:49:55 -050042
43static const struct gpio_bank gpio_bank_44xx[6] = {
44 { (void *)OMAP44XX_GPIO1_BASE, METHOD_GPIO_24XX },
45 { (void *)OMAP44XX_GPIO2_BASE, METHOD_GPIO_24XX },
46 { (void *)OMAP44XX_GPIO3_BASE, METHOD_GPIO_24XX },
47 { (void *)OMAP44XX_GPIO4_BASE, METHOD_GPIO_24XX },
48 { (void *)OMAP44XX_GPIO5_BASE, METHOD_GPIO_24XX },
49 { (void *)OMAP44XX_GPIO6_BASE, METHOD_GPIO_24XX },
50};
51
52const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx;
53
54#ifdef CONFIG_SPL_BUILD
55/*
56 * Some tuning of IOs for optimal power and performance
57 */
58void do_io_settings(void)
59{
60 u32 lpddr2io;
Sricharan508a58f2011-11-15 09:49:55 -050061
62 u32 omap4_rev = omap_revision();
63
64 if (omap4_rev == OMAP4430_ES1_0)
65 lpddr2io = CONTROL_LPDDR2IO_SLEW_125PS_DRV8_PULL_DOWN;
66 else if (omap4_rev == OMAP4430_ES2_0)
67 lpddr2io = CONTROL_LPDDR2IO_SLEW_325PS_DRV8_GATE_KEEPER;
68 else
69 lpddr2io = CONTROL_LPDDR2IO_SLEW_315PS_DRV12_PULL_DOWN;
70
71 /* EMIF1 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000072 writel(lpddr2io, (*ctrl)->control_lpddr2io1_0);
73 writel(lpddr2io, (*ctrl)->control_lpddr2io1_1);
Sricharan508a58f2011-11-15 09:49:55 -050074 /* No pull for GR10 as per hw team's recommendation */
75 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000076 (*ctrl)->control_lpddr2io1_2);
77 writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io1_3);
Sricharan508a58f2011-11-15 09:49:55 -050078
79 /* EMIF2 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000080 writel(lpddr2io, (*ctrl)->control_lpddr2io2_0);
81 writel(lpddr2io, (*ctrl)->control_lpddr2io2_1);
Sricharan508a58f2011-11-15 09:49:55 -050082 /* No pull for GR10 as per hw team's recommendation */
83 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000084 (*ctrl)->control_lpddr2io2_2);
85 writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io2_3);
Sricharan508a58f2011-11-15 09:49:55 -050086
87 /*
88 * Some of these settings (TRIM values) come from eFuse and are
89 * in turn programmed in the eFuse at manufacturing time after
90 * calibration of the device. Do the software over-ride only if
91 * the device is not correctly trimmed
92 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000093 if (!(readl((*ctrl)->control_std_fuse_opp_bgap) & 0xFFFF)) {
Sricharan508a58f2011-11-15 09:49:55 -050094
95 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000096 (*ctrl)->control_ldosram_iva_voltage_ctrl);
Sricharan508a58f2011-11-15 09:49:55 -050097
98 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000099 (*ctrl)->control_ldosram_mpu_voltage_ctrl);
Sricharan508a58f2011-11-15 09:49:55 -0500100
101 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutlac43c8332013-02-04 04:22:04 +0000102 (*ctrl)->control_ldosram_core_voltage_ctrl);
Sricharan508a58f2011-11-15 09:49:55 -0500103 }
104
Aneesh V23e9f072011-11-21 23:39:05 +0000105 /*
106 * Over-ride the register
107 * i. unconditionally for all 4430
108 * ii. only if un-trimmed for 4460
109 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +0000110 if (!readl((*ctrl)->control_efuse_1))
111 writel(CONTROL_EFUSE_1_OVERRIDE, (*ctrl)->control_efuse_1);
Sricharan508a58f2011-11-15 09:49:55 -0500112
Lokesh Vutlac43c8332013-02-04 04:22:04 +0000113 if ((omap4_rev < OMAP4460_ES1_0) || !readl((*ctrl)->control_efuse_2))
114 writel(CONTROL_EFUSE_2_OVERRIDE, (*ctrl)->control_efuse_2);
Sricharan508a58f2011-11-15 09:49:55 -0500115}
Robert P. J. Dayf281f292012-11-13 08:12:08 +0000116#endif /* CONFIG_SPL_BUILD */
Sricharan508a58f2011-11-15 09:49:55 -0500117
Lokesh Vutla784ab7c2012-05-22 00:03:25 +0000118/* dummy fuction for omap4 */
119void config_data_eye_leveling_samples(u32 emif_base)
120{
121}
122
Sricharan508a58f2011-11-15 09:49:55 -0500123void init_omap_revision(void)
124{
125 /*
126 * For some of the ES2/ES1 boards ID_CODE is not reliable:
127 * Also, ES1 and ES2 have different ARM revisions
128 * So use ARM revision for identification
129 */
130 unsigned int arm_rev = cortex_rev();
131
132 switch (arm_rev) {
133 case MIDR_CORTEX_A9_R0P1:
SRICHARAN R087189f2012-03-12 02:25:40 +0000134 *omap_si_rev = OMAP4430_ES1_0;
Sricharan508a58f2011-11-15 09:49:55 -0500135 break;
136 case MIDR_CORTEX_A9_R1P2:
137 switch (readl(CONTROL_ID_CODE)) {
138 case OMAP4_CONTROL_ID_CODE_ES2_0:
SRICHARAN R087189f2012-03-12 02:25:40 +0000139 *omap_si_rev = OMAP4430_ES2_0;
Sricharan508a58f2011-11-15 09:49:55 -0500140 break;
141 case OMAP4_CONTROL_ID_CODE_ES2_1:
SRICHARAN R087189f2012-03-12 02:25:40 +0000142 *omap_si_rev = OMAP4430_ES2_1;
Sricharan508a58f2011-11-15 09:49:55 -0500143 break;
144 case OMAP4_CONTROL_ID_CODE_ES2_2:
SRICHARAN R087189f2012-03-12 02:25:40 +0000145 *omap_si_rev = OMAP4430_ES2_2;
Sricharan508a58f2011-11-15 09:49:55 -0500146 break;
147 default:
SRICHARAN R087189f2012-03-12 02:25:40 +0000148 *omap_si_rev = OMAP4430_ES2_0;
Sricharan508a58f2011-11-15 09:49:55 -0500149 break;
150 }
151 break;
152 case MIDR_CORTEX_A9_R1P3:
SRICHARAN R087189f2012-03-12 02:25:40 +0000153 *omap_si_rev = OMAP4430_ES2_3;
Sricharan508a58f2011-11-15 09:49:55 -0500154 break;
155 case MIDR_CORTEX_A9_R2P10:
Aneesh V94047582011-11-21 23:39:03 +0000156 switch (readl(CONTROL_ID_CODE)) {
157 case OMAP4460_CONTROL_ID_CODE_ES1_1:
SRICHARAN R087189f2012-03-12 02:25:40 +0000158 *omap_si_rev = OMAP4460_ES1_1;
Aneesh V94047582011-11-21 23:39:03 +0000159 break;
160 case OMAP4460_CONTROL_ID_CODE_ES1_0:
161 default:
SRICHARAN R087189f2012-03-12 02:25:40 +0000162 *omap_si_rev = OMAP4460_ES1_0;
Aneesh V94047582011-11-21 23:39:03 +0000163 break;
164 }
Sricharan508a58f2011-11-15 09:49:55 -0500165 break;
166 default:
SRICHARAN R087189f2012-03-12 02:25:40 +0000167 *omap_si_rev = OMAP4430_SILICON_ID_INVALID;
Sricharan508a58f2011-11-15 09:49:55 -0500168 break;
169 }
170}
171
172#ifndef CONFIG_SYS_L2CACHE_OFF
173void v7_outer_cache_enable(void)
174{
175 set_pl310_ctrl_reg(1);
176}
177
178void v7_outer_cache_disable(void)
179{
180 set_pl310_ctrl_reg(0);
181}
Robert P. J. Dayf281f292012-11-13 08:12:08 +0000182#endif /* !CONFIG_SYS_L2CACHE_OFF */