blob: 27dfa9142dcd7be5091ea3ca772e2f00ce84dbe6 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Sricharan508a58f2011-11-15 09:49:55 -05002/*
3 *
4 * Common functions for OMAP4 based boards
5 *
6 * (C) Copyright 2010
7 * Texas Instruments, <www.ti.com>
8 *
9 * Author :
10 * Aneesh V <aneesh@ti.com>
11 * Steve Sakoman <steve@sakoman.com>
Sricharan508a58f2011-11-15 09:49:55 -050012 */
13#include <common.h>
Lokesh Vutlab4b06002016-11-23 13:25:28 +053014#include <palmas.h>
Sricharan508a58f2011-11-15 09:49:55 -050015#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
SRICHARAN Rf92f2272013-04-24 00:41:22 +000023u32 *const omap_si_rev = (u32 *)OMAP_SRAM_SCRATCH_OMAP_REV;
Sricharan508a58f2011-11-15 09:49:55 -050024
25static const struct gpio_bank gpio_bank_44xx[6] = {
Tom Rini0a9e3402015-07-31 19:55:09 -040026 { (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 },
Sricharan508a58f2011-11-15 09:49:55 -050032};
33
34const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx;
35
36#ifdef CONFIG_SPL_BUILD
37/*
38 * Some tuning of IOs for optimal power and performance
39 */
40void do_io_settings(void)
41{
42 u32 lpddr2io;
Sricharan508a58f2011-11-15 09:49:55 -050043
44 u32 omap4_rev = omap_revision();
45
46 if (omap4_rev == OMAP4430_ES1_0)
47 lpddr2io = CONTROL_LPDDR2IO_SLEW_125PS_DRV8_PULL_DOWN;
48 else if (omap4_rev == OMAP4430_ES2_0)
49 lpddr2io = CONTROL_LPDDR2IO_SLEW_325PS_DRV8_GATE_KEEPER;
50 else
51 lpddr2io = CONTROL_LPDDR2IO_SLEW_315PS_DRV12_PULL_DOWN;
52
53 /* EMIF1 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000054 writel(lpddr2io, (*ctrl)->control_lpddr2io1_0);
55 writel(lpddr2io, (*ctrl)->control_lpddr2io1_1);
Sricharan508a58f2011-11-15 09:49:55 -050056 /* No pull for GR10 as per hw team's recommendation */
57 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000058 (*ctrl)->control_lpddr2io1_2);
59 writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io1_3);
Sricharan508a58f2011-11-15 09:49:55 -050060
61 /* EMIF2 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000062 writel(lpddr2io, (*ctrl)->control_lpddr2io2_0);
63 writel(lpddr2io, (*ctrl)->control_lpddr2io2_1);
Sricharan508a58f2011-11-15 09:49:55 -050064 /* No pull for GR10 as per hw team's recommendation */
65 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000066 (*ctrl)->control_lpddr2io2_2);
67 writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io2_3);
Sricharan508a58f2011-11-15 09:49:55 -050068
69 /*
70 * Some of these settings (TRIM values) come from eFuse and are
71 * in turn programmed in the eFuse at manufacturing time after
72 * calibration of the device. Do the software over-ride only if
73 * the device is not correctly trimmed
74 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000075 if (!(readl((*ctrl)->control_std_fuse_opp_bgap) & 0xFFFF)) {
Sricharan508a58f2011-11-15 09:49:55 -050076
77 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000078 (*ctrl)->control_ldosram_iva_voltage_ctrl);
Sricharan508a58f2011-11-15 09:49:55 -050079
80 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000081 (*ctrl)->control_ldosram_mpu_voltage_ctrl);
Sricharan508a58f2011-11-15 09:49:55 -050082
83 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutlac43c8332013-02-04 04:22:04 +000084 (*ctrl)->control_ldosram_core_voltage_ctrl);
Sricharan508a58f2011-11-15 09:49:55 -050085 }
86
Aneesh V23e9f072011-11-21 23:39:05 +000087 /*
88 * Over-ride the register
89 * i. unconditionally for all 4430
90 * ii. only if un-trimmed for 4460
91 */
Lokesh Vutlac43c8332013-02-04 04:22:04 +000092 if (!readl((*ctrl)->control_efuse_1))
93 writel(CONTROL_EFUSE_1_OVERRIDE, (*ctrl)->control_efuse_1);
Sricharan508a58f2011-11-15 09:49:55 -050094
Lokesh Vutlac43c8332013-02-04 04:22:04 +000095 if ((omap4_rev < OMAP4460_ES1_0) || !readl((*ctrl)->control_efuse_2))
96 writel(CONTROL_EFUSE_2_OVERRIDE, (*ctrl)->control_efuse_2);
Sricharan508a58f2011-11-15 09:49:55 -050097}
Robert P. J. Dayf281f292012-11-13 08:12:08 +000098#endif /* CONFIG_SPL_BUILD */
Sricharan508a58f2011-11-15 09:49:55 -050099
Lokesh Vutla784ab7c2012-05-22 00:03:25 +0000100/* dummy fuction for omap4 */
101void config_data_eye_leveling_samples(u32 emif_base)
102{
103}
104
Sricharan508a58f2011-11-15 09:49:55 -0500105void init_omap_revision(void)
106{
107 /*
108 * For some of the ES2/ES1 boards ID_CODE is not reliable:
109 * Also, ES1 and ES2 have different ARM revisions
110 * So use ARM revision for identification
111 */
112 unsigned int arm_rev = cortex_rev();
113
114 switch (arm_rev) {
115 case MIDR_CORTEX_A9_R0P1:
SRICHARAN R087189f2012-03-12 02:25:40 +0000116 *omap_si_rev = OMAP4430_ES1_0;
Sricharan508a58f2011-11-15 09:49:55 -0500117 break;
118 case MIDR_CORTEX_A9_R1P2:
119 switch (readl(CONTROL_ID_CODE)) {
120 case OMAP4_CONTROL_ID_CODE_ES2_0:
SRICHARAN R087189f2012-03-12 02:25:40 +0000121 *omap_si_rev = OMAP4430_ES2_0;
Sricharan508a58f2011-11-15 09:49:55 -0500122 break;
123 case OMAP4_CONTROL_ID_CODE_ES2_1:
SRICHARAN R087189f2012-03-12 02:25:40 +0000124 *omap_si_rev = OMAP4430_ES2_1;
Sricharan508a58f2011-11-15 09:49:55 -0500125 break;
126 case OMAP4_CONTROL_ID_CODE_ES2_2:
SRICHARAN R087189f2012-03-12 02:25:40 +0000127 *omap_si_rev = OMAP4430_ES2_2;
Sricharan508a58f2011-11-15 09:49:55 -0500128 break;
129 default:
SRICHARAN R087189f2012-03-12 02:25:40 +0000130 *omap_si_rev = OMAP4430_ES2_0;
Sricharan508a58f2011-11-15 09:49:55 -0500131 break;
132 }
133 break;
134 case MIDR_CORTEX_A9_R1P3:
SRICHARAN R087189f2012-03-12 02:25:40 +0000135 *omap_si_rev = OMAP4430_ES2_3;
Sricharan508a58f2011-11-15 09:49:55 -0500136 break;
137 case MIDR_CORTEX_A9_R2P10:
Aneesh V94047582011-11-21 23:39:03 +0000138 switch (readl(CONTROL_ID_CODE)) {
Taras Kondratiuk696f81f2013-08-06 15:18:48 +0300139 case OMAP4470_CONTROL_ID_CODE_ES1_0:
140 *omap_si_rev = OMAP4470_ES1_0;
141 break;
Aneesh V94047582011-11-21 23:39:03 +0000142 case OMAP4460_CONTROL_ID_CODE_ES1_1:
SRICHARAN R087189f2012-03-12 02:25:40 +0000143 *omap_si_rev = OMAP4460_ES1_1;
Aneesh V94047582011-11-21 23:39:03 +0000144 break;
145 case OMAP4460_CONTROL_ID_CODE_ES1_0:
146 default:
SRICHARAN R087189f2012-03-12 02:25:40 +0000147 *omap_si_rev = OMAP4460_ES1_0;
Aneesh V94047582011-11-21 23:39:03 +0000148 break;
149 }
Sricharan508a58f2011-11-15 09:49:55 -0500150 break;
151 default:
SRICHARAN R087189f2012-03-12 02:25:40 +0000152 *omap_si_rev = OMAP4430_SILICON_ID_INVALID;
Sricharan508a58f2011-11-15 09:49:55 -0500153 break;
154 }
155}
156
Paul Kocialkowski987a40d2015-08-27 19:37:10 +0200157void omap_die_id(unsigned int *die_id)
158{
159 die_id[0] = readl((*ctrl)->control_std_fuse_die_id_0);
160 die_id[1] = readl((*ctrl)->control_std_fuse_die_id_1);
161 die_id[2] = readl((*ctrl)->control_std_fuse_die_id_2);
162 die_id[3] = readl((*ctrl)->control_std_fuse_die_id_3);
163}
164
Sricharan508a58f2011-11-15 09:49:55 -0500165#ifndef CONFIG_SYS_L2CACHE_OFF
166void v7_outer_cache_enable(void)
167{
Nishanth Menon6d8abe62015-03-09 17:12:03 -0500168 omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 1);
Sricharan508a58f2011-11-15 09:49:55 -0500169}
170
171void v7_outer_cache_disable(void)
172{
Nishanth Menon6d8abe62015-03-09 17:12:03 -0500173 omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 0);
Sricharan508a58f2011-11-15 09:49:55 -0500174}
Robert P. J. Dayf281f292012-11-13 08:12:08 +0000175#endif /* !CONFIG_SYS_L2CACHE_OFF */
Lokesh Vutlab4b06002016-11-23 13:25:28 +0530176
177void vmmc_pbias_config(uint voltage)
178{
179 u32 value = 0;
180
181 value = readl((*ctrl)->control_pbiaslite);
182 value &= ~(MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ);
183 writel(value, (*ctrl)->control_pbiaslite);
184 value = readl((*ctrl)->control_pbiaslite);
185 value |= MMC1_PBIASLITE_VMODE | MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ;
186 writel(value, (*ctrl)->control_pbiaslite);
187}