blob: e3e6cc8e57858cdeffa5ccc8da1c5ca742464464 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Sricharan9310ff72011-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>
Sricharan9310ff72011-11-15 09:49:55 -050012 */
Lokesh Vutlad999d052016-11-23 13:25:28 +053013#include <palmas.h>
Sricharan9310ff72011-11-15 09:49:55 -050014#include <asm/armv7.h>
15#include <asm/arch/cpu.h>
16#include <asm/arch/sys_proto.h>
Alexey Brodkin267d8e22014-02-26 17:47:58 +040017#include <linux/sizes.h>
Sricharan62a86502011-11-15 09:50:00 -050018#include <asm/emif.h>
Sricharan9310ff72011-11-15 09:49:55 -050019#include <asm/arch/gpio.h>
SRICHARAN R4b1b61c2013-04-24 00:41:22 +000020#include <asm/omap_common.h>
Sricharan9310ff72011-11-15 09:49:55 -050021
SRICHARAN R4b1b61c2013-04-24 00:41:22 +000022u32 *const omap_si_rev = (u32 *)OMAP_SRAM_SCRATCH_OMAP_REV;
Sricharan9310ff72011-11-15 09:49:55 -050023
24static const struct gpio_bank gpio_bank_44xx[6] = {
Tom Rini7bc2bca2015-07-31 19:55:09 -040025 { (void *)OMAP44XX_GPIO1_BASE },
26 { (void *)OMAP44XX_GPIO2_BASE },
27 { (void *)OMAP44XX_GPIO3_BASE },
28 { (void *)OMAP44XX_GPIO4_BASE },
29 { (void *)OMAP44XX_GPIO5_BASE },
30 { (void *)OMAP44XX_GPIO6_BASE },
Sricharan9310ff72011-11-15 09:49:55 -050031};
32
33const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx;
34
35#ifdef CONFIG_SPL_BUILD
36/*
37 * Some tuning of IOs for optimal power and performance
38 */
39void do_io_settings(void)
40{
41 u32 lpddr2io;
Sricharan9310ff72011-11-15 09:49:55 -050042
43 u32 omap4_rev = omap_revision();
44
45 if (omap4_rev == OMAP4430_ES1_0)
46 lpddr2io = CONTROL_LPDDR2IO_SLEW_125PS_DRV8_PULL_DOWN;
47 else if (omap4_rev == OMAP4430_ES2_0)
48 lpddr2io = CONTROL_LPDDR2IO_SLEW_325PS_DRV8_GATE_KEEPER;
49 else
50 lpddr2io = CONTROL_LPDDR2IO_SLEW_315PS_DRV12_PULL_DOWN;
51
52 /* EMIF1 */
Lokesh Vutla834b6b02013-02-04 04:22:04 +000053 writel(lpddr2io, (*ctrl)->control_lpddr2io1_0);
54 writel(lpddr2io, (*ctrl)->control_lpddr2io1_1);
Sricharan9310ff72011-11-15 09:49:55 -050055 /* No pull for GR10 as per hw team's recommendation */
56 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
Lokesh Vutla834b6b02013-02-04 04:22:04 +000057 (*ctrl)->control_lpddr2io1_2);
58 writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io1_3);
Sricharan9310ff72011-11-15 09:49:55 -050059
60 /* EMIF2 */
Lokesh Vutla834b6b02013-02-04 04:22:04 +000061 writel(lpddr2io, (*ctrl)->control_lpddr2io2_0);
62 writel(lpddr2io, (*ctrl)->control_lpddr2io2_1);
Sricharan9310ff72011-11-15 09:49:55 -050063 /* No pull for GR10 as per hw team's recommendation */
64 writel(lpddr2io & ~LPDDR2IO_GR10_WD_MASK,
Lokesh Vutla834b6b02013-02-04 04:22:04 +000065 (*ctrl)->control_lpddr2io2_2);
66 writel(CONTROL_LPDDR2IO_3_VAL, (*ctrl)->control_lpddr2io2_3);
Sricharan9310ff72011-11-15 09:49:55 -050067
68 /*
69 * Some of these settings (TRIM values) come from eFuse and are
70 * in turn programmed in the eFuse at manufacturing time after
71 * calibration of the device. Do the software over-ride only if
72 * the device is not correctly trimmed
73 */
Lokesh Vutla834b6b02013-02-04 04:22:04 +000074 if (!(readl((*ctrl)->control_std_fuse_opp_bgap) & 0xFFFF)) {
Sricharan9310ff72011-11-15 09:49:55 -050075
76 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutla834b6b02013-02-04 04:22:04 +000077 (*ctrl)->control_ldosram_iva_voltage_ctrl);
Sricharan9310ff72011-11-15 09:49:55 -050078
79 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutla834b6b02013-02-04 04:22:04 +000080 (*ctrl)->control_ldosram_mpu_voltage_ctrl);
Sricharan9310ff72011-11-15 09:49:55 -050081
82 writel(LDOSRAM_VOLT_CTRL_OVERRIDE,
Lokesh Vutla834b6b02013-02-04 04:22:04 +000083 (*ctrl)->control_ldosram_core_voltage_ctrl);
Sricharan9310ff72011-11-15 09:49:55 -050084 }
85
Aneesh V8ed98d82011-11-21 23:39:05 +000086 /*
87 * Over-ride the register
88 * i. unconditionally for all 4430
89 * ii. only if un-trimmed for 4460
90 */
Lokesh Vutla834b6b02013-02-04 04:22:04 +000091 if (!readl((*ctrl)->control_efuse_1))
92 writel(CONTROL_EFUSE_1_OVERRIDE, (*ctrl)->control_efuse_1);
Sricharan9310ff72011-11-15 09:49:55 -050093
Lokesh Vutla834b6b02013-02-04 04:22:04 +000094 if ((omap4_rev < OMAP4460_ES1_0) || !readl((*ctrl)->control_efuse_2))
95 writel(CONTROL_EFUSE_2_OVERRIDE, (*ctrl)->control_efuse_2);
Sricharan9310ff72011-11-15 09:49:55 -050096}
Robert P. J. Day3037e522012-11-13 08:12:08 +000097#endif /* CONFIG_SPL_BUILD */
Sricharan9310ff72011-11-15 09:49:55 -050098
Lokesh Vutla0f42de62012-05-22 00:03:25 +000099/* dummy fuction for omap4 */
100void config_data_eye_leveling_samples(u32 emif_base)
101{
102}
103
Sricharan9310ff72011-11-15 09:49:55 -0500104void init_omap_revision(void)
105{
106 /*
107 * For some of the ES2/ES1 boards ID_CODE is not reliable:
108 * Also, ES1 and ES2 have different ARM revisions
109 * So use ARM revision for identification
110 */
111 unsigned int arm_rev = cortex_rev();
112
113 switch (arm_rev) {
114 case MIDR_CORTEX_A9_R0P1:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000115 *omap_si_rev = OMAP4430_ES1_0;
Sricharan9310ff72011-11-15 09:49:55 -0500116 break;
117 case MIDR_CORTEX_A9_R1P2:
118 switch (readl(CONTROL_ID_CODE)) {
119 case OMAP4_CONTROL_ID_CODE_ES2_0:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000120 *omap_si_rev = OMAP4430_ES2_0;
Sricharan9310ff72011-11-15 09:49:55 -0500121 break;
122 case OMAP4_CONTROL_ID_CODE_ES2_1:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000123 *omap_si_rev = OMAP4430_ES2_1;
Sricharan9310ff72011-11-15 09:49:55 -0500124 break;
125 case OMAP4_CONTROL_ID_CODE_ES2_2:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000126 *omap_si_rev = OMAP4430_ES2_2;
Sricharan9310ff72011-11-15 09:49:55 -0500127 break;
128 default:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000129 *omap_si_rev = OMAP4430_ES2_0;
Sricharan9310ff72011-11-15 09:49:55 -0500130 break;
131 }
132 break;
133 case MIDR_CORTEX_A9_R1P3:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000134 *omap_si_rev = OMAP4430_ES2_3;
Sricharan9310ff72011-11-15 09:49:55 -0500135 break;
136 case MIDR_CORTEX_A9_R2P10:
Aneesh Va04c3042011-11-21 23:39:03 +0000137 switch (readl(CONTROL_ID_CODE)) {
Taras Kondratiuk1fc94372013-08-06 15:18:48 +0300138 case OMAP4470_CONTROL_ID_CODE_ES1_0:
139 *omap_si_rev = OMAP4470_ES1_0;
140 break;
Aneesh Va04c3042011-11-21 23:39:03 +0000141 case OMAP4460_CONTROL_ID_CODE_ES1_1:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000142 *omap_si_rev = OMAP4460_ES1_1;
Aneesh Va04c3042011-11-21 23:39:03 +0000143 break;
144 case OMAP4460_CONTROL_ID_CODE_ES1_0:
145 default:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000146 *omap_si_rev = OMAP4460_ES1_0;
Aneesh Va04c3042011-11-21 23:39:03 +0000147 break;
148 }
Sricharan9310ff72011-11-15 09:49:55 -0500149 break;
150 default:
SRICHARAN Rd3901b12012-03-12 02:25:40 +0000151 *omap_si_rev = OMAP4430_SILICON_ID_INVALID;
Sricharan9310ff72011-11-15 09:49:55 -0500152 break;
153 }
154}
155
Paul Kocialkowskid76b8b92015-08-27 19:37:10 +0200156void omap_die_id(unsigned int *die_id)
157{
158 die_id[0] = readl((*ctrl)->control_std_fuse_die_id_0);
159 die_id[1] = readl((*ctrl)->control_std_fuse_die_id_1);
160 die_id[2] = readl((*ctrl)->control_std_fuse_die_id_2);
161 die_id[3] = readl((*ctrl)->control_std_fuse_die_id_3);
162}
163
Sricharan9310ff72011-11-15 09:49:55 -0500164#ifndef CONFIG_SYS_L2CACHE_OFF
165void v7_outer_cache_enable(void)
166{
Nishanth Menon19e1fdf2015-03-09 17:12:03 -0500167 omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 1);
Sricharan9310ff72011-11-15 09:49:55 -0500168}
169
170void v7_outer_cache_disable(void)
171{
Nishanth Menon19e1fdf2015-03-09 17:12:03 -0500172 omap_smc1(OMAP4_SERVICE_PL310_CONTROL_REG_SET, 0);
Sricharan9310ff72011-11-15 09:49:55 -0500173}
Robert P. J. Day3037e522012-11-13 08:12:08 +0000174#endif /* !CONFIG_SYS_L2CACHE_OFF */
Lokesh Vutlad999d052016-11-23 13:25:28 +0530175
176void vmmc_pbias_config(uint voltage)
177{
178 u32 value = 0;
179
180 value = readl((*ctrl)->control_pbiaslite);
181 value &= ~(MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ);
182 writel(value, (*ctrl)->control_pbiaslite);
183 value = readl((*ctrl)->control_pbiaslite);
184 value |= MMC1_PBIASLITE_VMODE | MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ;
185 writel(value, (*ctrl)->control_pbiaslite);
186}