blob: 9792761d40a0263a0c7b19f57b7edd3fd087cdd1 [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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +020012 * SPDX-License-Identifier: GPL-2.0+
Sricharan508a58f2011-11-15 09:49:55 -050013 */
14#include <common.h>
15#include <asm/armv7.h>
16#include <asm/arch/cpu.h>
17#include <asm/arch/sys_proto.h>
Alexey Brodkin1ace4022014-02-26 17:47:58 +040018#include <linux/sizes.h>
Sricharanbb772a52011-11-15 09:50:00 -050019#include <asm/emif.h>
Sricharan508a58f2011-11-15 09:49:55 -050020#include <asm/arch/gpio.h>
SRICHARAN Rf92f2272013-04-24 00:41:22 +000021#include <asm/omap_common.h>
Sricharan508a58f2011-11-15 09:49:55 -050022
23DECLARE_GLOBAL_DATA_PTR;
24
SRICHARAN Rf92f2272013-04-24 00:41:22 +000025u32 *const omap_si_rev = (u32 *)OMAP_SRAM_SCRATCH_OMAP_REV;
Sricharan508a58f2011-11-15 09:49:55 -050026
27static const struct gpio_bank gpio_bank_44xx[6] = {
28 { (void *)OMAP44XX_GPIO1_BASE, METHOD_GPIO_24XX },
29 { (void *)OMAP44XX_GPIO2_BASE, METHOD_GPIO_24XX },
30 { (void *)OMAP44XX_GPIO3_BASE, METHOD_GPIO_24XX },
31 { (void *)OMAP44XX_GPIO4_BASE, METHOD_GPIO_24XX },
32 { (void *)OMAP44XX_GPIO5_BASE, METHOD_GPIO_24XX },
33 { (void *)OMAP44XX_GPIO6_BASE, METHOD_GPIO_24XX },
34};
35
36const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx;
37
38#ifdef CONFIG_SPL_BUILD
39/*
40 * Some tuning of IOs for optimal power and performance
41 */
42void do_io_settings(void)
43{
44 u32 lpddr2io;
Sricharan508a58f2011-11-15 09:49:55 -050045
46 u32 omap4_rev = omap_revision();
47
48 if (omap4_rev == OMAP4430_ES1_0)
49 lpddr2io = CONTROL_LPDDR2IO_SLEW_125PS_DRV8_PULL_DOWN;
50 else if (omap4_rev == OMAP4430_ES2_0)
51 lpddr2io = CONTROL_LPDDR2IO_SLEW_325PS_DRV8_GATE_KEEPER;
52 else
53 lpddr2io = CONTROL_LPDDR2IO_SLEW_315PS_DRV12_PULL_DOWN;
54
55 /* EMIF1 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000056 writel(lpddr2io, (*ctrl)->control_lpddr2io1_0);
57 writel(lpddr2io, (*ctrl)->control_lpddr2io1_1);
Sricharan508a58f2011-11-15 09:49:55 -050058 /* No pull for GR10 as per hw team's recommendation */
59 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000060 (*ctrl)->control_lpddr2io1_2);
61 writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io1_3);
Sricharan508a58f2011-11-15 09:49:55 -050062
63 /* EMIF2 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000064 writel(lpddr2io, (*ctrl)->control_lpddr2io2_0);
65 writel(lpddr2io, (*ctrl)->control_lpddr2io2_1);
Sricharan508a58f2011-11-15 09:49:55 -050066 /* No pull for GR10 as per hw team's recommendation */
67 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000068 (*ctrl)->control_lpddr2io2_2);
69 writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io2_3);
Sricharan508a58f2011-11-15 09:49:55 -050070
71 /*
72 * Some of these settings (TRIM values) come from eFuse and are
73 * in turn programmed in the eFuse at manufacturing time after
74 * calibration of the device. Do the software over-ride only if
75 * the device is not correctly trimmed
76 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000077 if (!(readl((*ctrl)->control_std_fuse_opp_bgap) & 0xFFFF)) {
Sricharan508a58f2011-11-15 09:49:55 -050078
79 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000080 (*ctrl)->control_ldosram_iva_voltage_ctrl);
Sricharan508a58f2011-11-15 09:49:55 -050081
82 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000083 (*ctrl)->control_ldosram_mpu_voltage_ctrl);
Sricharan508a58f2011-11-15 09:49:55 -050084
85 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000086 (*ctrl)->control_ldosram_core_voltage_ctrl);
Sricharan508a58f2011-11-15 09:49:55 -050087 }
88
Aneesh V23e9f072011-11-21 23:39:05 +000089 /*
90 * Over-ride the register
91 * i. unconditionally for all 4430
92 * ii. only if un-trimmed for 4460
93 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000094 if (!readl((*ctrl)->control_efuse_1))
95 writel(CONTROL_EFUSE_1_OVERRIDE, (*ctrl)->control_efuse_1);
Sricharan508a58f2011-11-15 09:49:55 -050096
Lokesh Vutlac43c8332013-02-04 04:22:04 +000097 if ((omap4_rev < OMAP4460_ES1_0) || !readl((*ctrl)->control_efuse_2))
98 writel(CONTROL_EFUSE_2_OVERRIDE, (*ctrl)->control_efuse_2);
Sricharan508a58f2011-11-15 09:49:55 -050099}
Robert P. J. Dayf281f292012-11-13 08:12:08 +0000100#endif /* CONFIG_SPL_BUILD */
Sricharan508a58f2011-11-15 09:49:55 -0500101
Lokesh Vutla784ab7c2012-05-22 00:03:25 +0000102/* dummy fuction for omap4 */
103void config_data_eye_leveling_samples(u32 emif_base)
104{
105}
106
Sricharan508a58f2011-11-15 09:49:55 -0500107void init_omap_revision(void)
108{
109 /*
110 * For some of the ES2/ES1 boards ID_CODE is not reliable:
111 * Also, ES1 and ES2 have different ARM revisions
112 * So use ARM revision for identification
113 */
114 unsigned int arm_rev = cortex_rev();
115
116 switch (arm_rev) {
117 case MIDR_CORTEX_A9_R0P1:
SRICHARAN R087189f2012-03-12 02:25:40 +0000118 *omap_si_rev = OMAP4430_ES1_0;
Sricharan508a58f2011-11-15 09:49:55 -0500119 break;
120 case MIDR_CORTEX_A9_R1P2:
121 switch (readl(CONTROL_ID_CODE)) {
122 case OMAP4_CONTROL_ID_CODE_ES2_0:
SRICHARAN R087189f2012-03-12 02:25:40 +0000123 *omap_si_rev = OMAP4430_ES2_0;
Sricharan508a58f2011-11-15 09:49:55 -0500124 break;
125 case OMAP4_CONTROL_ID_CODE_ES2_1:
SRICHARAN R087189f2012-03-12 02:25:40 +0000126 *omap_si_rev = OMAP4430_ES2_1;
Sricharan508a58f2011-11-15 09:49:55 -0500127 break;
128 case OMAP4_CONTROL_ID_CODE_ES2_2:
SRICHARAN R087189f2012-03-12 02:25:40 +0000129 *omap_si_rev = OMAP4430_ES2_2;
Sricharan508a58f2011-11-15 09:49:55 -0500130 break;
131 default:
SRICHARAN R087189f2012-03-12 02:25:40 +0000132 *omap_si_rev = OMAP4430_ES2_0;
Sricharan508a58f2011-11-15 09:49:55 -0500133 break;
134 }
135 break;
136 case MIDR_CORTEX_A9_R1P3:
SRICHARAN R087189f2012-03-12 02:25:40 +0000137 *omap_si_rev = OMAP4430_ES2_3;
Sricharan508a58f2011-11-15 09:49:55 -0500138 break;
139 case MIDR_CORTEX_A9_R2P10:
Aneesh V94047582011-11-21 23:39:03 +0000140 switch (readl(CONTROL_ID_CODE)) {
Taras Kondratiuk696f81f2013-08-06 15:18:48 +0300141 case OMAP4470_CONTROL_ID_CODE_ES1_0:
142 *omap_si_rev = OMAP4470_ES1_0;
143 break;
Aneesh V94047582011-11-21 23:39:03 +0000144 case OMAP4460_CONTROL_ID_CODE_ES1_1:
SRICHARAN R087189f2012-03-12 02:25:40 +0000145 *omap_si_rev = OMAP4460_ES1_1;
Aneesh V94047582011-11-21 23:39:03 +0000146 break;
147 case OMAP4460_CONTROL_ID_CODE_ES1_0:
148 default:
SRICHARAN R087189f2012-03-12 02:25:40 +0000149 *omap_si_rev = OMAP4460_ES1_0;
Aneesh V94047582011-11-21 23:39:03 +0000150 break;
151 }
Sricharan508a58f2011-11-15 09:49:55 -0500152 break;
153 default:
SRICHARAN R087189f2012-03-12 02:25:40 +0000154 *omap_si_rev = OMAP4430_SILICON_ID_INVALID;
Sricharan508a58f2011-11-15 09:49:55 -0500155 break;
156 }
157}
158
159#ifndef CONFIG_SYS_L2CACHE_OFF
160void v7_outer_cache_enable(void)
161{
Nishanth Menon6d8abe62015-03-09 17:12:03 -0500162 omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 1);
Sricharan508a58f2011-11-15 09:49:55 -0500163}
164
165void v7_outer_cache_disable(void)
166{
Nishanth Menon6d8abe62015-03-09 17:12:03 -0500167 omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 0);
Sricharan508a58f2011-11-15 09:49:55 -0500168}
Robert P. J. Dayf281f292012-11-13 08:12:08 +0000169#endif /* !CONFIG_SYS_L2CACHE_OFF */