blob: 6bcfa482315983e2afd18d01cd9d25eec8605e48 [file] [log] [blame]
Lokesh Vutla40700ad2013-02-12 21:29:08 +00001/*
2 * (C) Copyright 2013
3 * Texas Instruments Incorporated, <www.ti.com>
4 *
5 * Lokesh Vutla <lokeshvutla@ti.com>
6 *
7 * Based on previous work by:
8 * Aneesh V <aneesh@ti.com>
9 * Steve Sakoman <steve@sakoman.com>
10 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Lokesh Vutla40700ad2013-02-12 21:29:08 +000012 */
13#include <common.h>
Nishanth Menon627612c2013-03-26 05:20:54 +000014#include <palmas.h>
Dan Murphy57f29ab2014-02-03 06:59:02 -060015#include <sata.h>
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053016#include <linux/string.h>
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +053017#include <asm/gpio.h>
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +053018#include <usb.h>
19#include <linux/usb/gadget.h>
Andreas Dannenberg5cf344b2016-06-27 09:19:22 -050020#include <asm/omap_common.h>
21#include <asm/omap_sec_common.h>
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +053022#include <asm/arch/gpio.h>
Lokesh Vutla1fd80222015-06-04 16:42:38 +053023#include <asm/arch/dra7xx_iodelay.h>
Lokesh Vutla41963ee2016-03-08 09:18:06 +053024#include <asm/emif.h>
Lokesh Vutla40700ad2013-02-12 21:29:08 +000025#include <asm/arch/sys_proto.h>
26#include <asm/arch/mmc_host_def.h>
Roger Quadrosf019ee82013-11-11 16:56:44 +020027#include <asm/arch/sata.h>
Tom Rini560ef452014-04-03 07:52:56 -040028#include <environment.h>
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +053029#include <dwc3-uboot.h>
30#include <dwc3-omap-uboot.h>
31#include <ti-usb-phy-uboot.h>
Dan Murphyb1941f32016-03-30 12:58:37 -050032#include <miiphy.h>
Lokesh Vutla40700ad2013-02-12 21:29:08 +000033
34#include "mux_data.h"
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053035#include "../common/board_detect.h"
36
Lokesh Vutla13376132017-08-21 12:50:53 +053037#define board_is_dra76x_evm() board_ti_is("DRA76/7x")
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053038#define board_is_dra74x_evm() board_ti_is("5777xCPU")
Ravi Babue1031082016-03-15 18:09:14 -050039#define board_is_dra72x_evm() board_ti_is("DRA72x-T")
Lokesh Vutlab9d8f8e2016-11-23 13:25:24 +053040#define board_is_dra71x_evm() board_ti_is("DRA79x,D")
Mugunthan V N3a7f10c2016-09-27 13:01:42 +053041#define board_is_dra74x_revh_or_later() (board_is_dra74x_evm() && \
42 (strncmp("H", board_ti_get_rev(), 1) <= 0))
43#define board_is_dra72x_revc_or_later() (board_is_dra72x_evm() && \
44 (strncmp("C", board_ti_get_rev(), 1) <= 0))
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +053045#define board_ti_get_emif_size() board_ti_get_emif1_size() + \
46 board_ti_get_emif2_size()
Lokesh Vutla40700ad2013-02-12 21:29:08 +000047
Mugunthan V Nab48f782013-07-08 16:04:41 +053048#ifdef CONFIG_DRIVER_TI_CPSW
49#include <cpsw.h>
50#endif
51
Lokesh Vutla40700ad2013-02-12 21:29:08 +000052DECLARE_GLOBAL_DATA_PTR;
53
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +053054/* GPIO 7_11 */
55#define GPIO_DDR_VTT_EN 203
56
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053057#define SYSINFO_BOARD_NAME_MAX_LEN 37
58
Lokesh Vutla40700ad2013-02-12 21:29:08 +000059const struct omap_sysinfo sysinfo = {
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053060 "Board: UNKNOWN(DRA7 EVM) REV UNKNOWN\n"
Lokesh Vutla40700ad2013-02-12 21:29:08 +000061};
62
Lokesh Vutla41963ee2016-03-08 09:18:06 +053063static const struct emif_regs emif1_ddr3_532_mhz_1cs = {
64 .sdram_config_init = 0x61851ab2,
65 .sdram_config = 0x61851ab2,
66 .sdram_config2 = 0x08000000,
67 .ref_ctrl = 0x000040F1,
68 .ref_ctrl_final = 0x00001035,
69 .sdram_tim1 = 0xCCCF36B3,
70 .sdram_tim2 = 0x308F7FDA,
71 .sdram_tim3 = 0x427F88A8,
72 .read_idle_ctrl = 0x00050000,
73 .zq_config = 0x0007190B,
74 .temp_alert_config = 0x00000000,
75 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
76 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
77 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
78 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
79 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
80 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
81 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
82 .emif_rd_wr_lvl_rmp_win = 0x00000000,
83 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
84 .emif_rd_wr_lvl_ctl = 0x00000000,
85 .emif_rd_wr_exec_thresh = 0x00000305
86};
87
88static const struct emif_regs emif2_ddr3_532_mhz_1cs = {
89 .sdram_config_init = 0x61851B32,
90 .sdram_config = 0x61851B32,
91 .sdram_config2 = 0x08000000,
92 .ref_ctrl = 0x000040F1,
93 .ref_ctrl_final = 0x00001035,
94 .sdram_tim1 = 0xCCCF36B3,
95 .sdram_tim2 = 0x308F7FDA,
96 .sdram_tim3 = 0x427F88A8,
97 .read_idle_ctrl = 0x00050000,
98 .zq_config = 0x0007190B,
99 .temp_alert_config = 0x00000000,
100 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
101 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
102 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
103 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
104 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
105 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
106 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
107 .emif_rd_wr_lvl_rmp_win = 0x00000000,
108 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
109 .emif_rd_wr_lvl_ctl = 0x00000000,
110 .emif_rd_wr_exec_thresh = 0x00000305
111};
112
113static const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es1 = {
114 .sdram_config_init = 0x61862B32,
115 .sdram_config = 0x61862B32,
116 .sdram_config2 = 0x08000000,
117 .ref_ctrl = 0x0000514C,
118 .ref_ctrl_final = 0x0000144A,
119 .sdram_tim1 = 0xD113781C,
120 .sdram_tim2 = 0x30717FE3,
121 .sdram_tim3 = 0x409F86A8,
122 .read_idle_ctrl = 0x00050000,
123 .zq_config = 0x5007190B,
124 .temp_alert_config = 0x00000000,
125 .emif_ddr_phy_ctlr_1_init = 0x0024400D,
126 .emif_ddr_phy_ctlr_1 = 0x0E24400D,
127 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
128 .emif_ddr_ext_phy_ctrl_2 = 0x00A400A4,
129 .emif_ddr_ext_phy_ctrl_3 = 0x00A900A9,
130 .emif_ddr_ext_phy_ctrl_4 = 0x00B000B0,
131 .emif_ddr_ext_phy_ctrl_5 = 0x00B000B0,
132 .emif_rd_wr_lvl_rmp_win = 0x00000000,
133 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
134 .emif_rd_wr_lvl_ctl = 0x00000000,
135 .emif_rd_wr_exec_thresh = 0x00000305
136};
137
Ravi Babue1031082016-03-15 18:09:14 -0500138const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es2 = {
139 .sdram_config_init = 0x61862BB2,
140 .sdram_config = 0x61862BB2,
141 .sdram_config2 = 0x00000000,
142 .ref_ctrl = 0x0000514D,
143 .ref_ctrl_final = 0x0000144A,
144 .sdram_tim1 = 0xD1137824,
145 .sdram_tim2 = 0x30B37FE3,
146 .sdram_tim3 = 0x409F8AD8,
147 .read_idle_ctrl = 0x00050000,
148 .zq_config = 0x5007190B,
149 .temp_alert_config = 0x00000000,
150 .emif_ddr_phy_ctlr_1_init = 0x0824400E,
151 .emif_ddr_phy_ctlr_1 = 0x0E24400E,
152 .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
153 .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
154 .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
155 .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
156 .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
157 .emif_rd_wr_lvl_rmp_win = 0x00000000,
158 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
159 .emif_rd_wr_lvl_ctl = 0x00000000,
160 .emif_rd_wr_exec_thresh = 0x00000305
161};
162
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530163const struct emif_regs emif1_ddr3_532_mhz_1cs_2G = {
164 .sdram_config_init = 0x61851ab2,
165 .sdram_config = 0x61851ab2,
166 .sdram_config2 = 0x08000000,
167 .ref_ctrl = 0x000040F1,
168 .ref_ctrl_final = 0x00001035,
169 .sdram_tim1 = 0xCCCF36B3,
170 .sdram_tim2 = 0x30BF7FDA,
171 .sdram_tim3 = 0x427F8BA8,
172 .read_idle_ctrl = 0x00050000,
173 .zq_config = 0x0007190B,
174 .temp_alert_config = 0x00000000,
175 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
176 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
177 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
178 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
179 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
180 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
181 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
182 .emif_rd_wr_lvl_rmp_win = 0x00000000,
183 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
184 .emif_rd_wr_lvl_ctl = 0x00000000,
185 .emif_rd_wr_exec_thresh = 0x00000305
186};
187
188const struct emif_regs emif2_ddr3_532_mhz_1cs_2G = {
189 .sdram_config_init = 0x61851B32,
190 .sdram_config = 0x61851B32,
191 .sdram_config2 = 0x08000000,
192 .ref_ctrl = 0x000040F1,
193 .ref_ctrl_final = 0x00001035,
194 .sdram_tim1 = 0xCCCF36B3,
195 .sdram_tim2 = 0x308F7FDA,
196 .sdram_tim3 = 0x427F88A8,
197 .read_idle_ctrl = 0x00050000,
198 .zq_config = 0x0007190B,
199 .temp_alert_config = 0x00000000,
200 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
201 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
202 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
203 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
204 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
205 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
206 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
207 .emif_rd_wr_lvl_rmp_win = 0x00000000,
208 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
209 .emif_rd_wr_lvl_ctl = 0x00000000,
210 .emif_rd_wr_exec_thresh = 0x00000305
211};
212
Lokesh Vutla6f1038f2017-08-21 12:50:55 +0530213const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra76 = {
214 .sdram_config_init = 0x61862B32,
215 .sdram_config = 0x61862B32,
216 .sdram_config2 = 0x00000000,
217 .ref_ctrl = 0x0000514C,
218 .ref_ctrl_final = 0x0000144A,
219 .sdram_tim1 = 0xD113783C,
220 .sdram_tim2 = 0x30B47FE3,
221 .sdram_tim3 = 0x409F8AD8,
222 .read_idle_ctrl = 0x00050000,
223 .zq_config = 0x5007190B,
224 .temp_alert_config = 0x00000000,
225 .emif_ddr_phy_ctlr_1_init = 0x0824400D,
226 .emif_ddr_phy_ctlr_1 = 0x0E24400D,
227 .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
228 .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
229 .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
230 .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
231 .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
232 .emif_rd_wr_lvl_rmp_win = 0x00000000,
233 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
234 .emif_rd_wr_lvl_ctl = 0x00000000,
235 .emif_rd_wr_exec_thresh = 0x00000305
236};
237
238const struct emif_regs emif_2_regs_ddr3_666_mhz_1cs_dra76 = {
239 .sdram_config_init = 0x61862B32,
240 .sdram_config = 0x61862B32,
241 .sdram_config2 = 0x00000000,
242 .ref_ctrl = 0x0000514C,
243 .ref_ctrl_final = 0x0000144A,
244 .sdram_tim1 = 0xD113781C,
245 .sdram_tim2 = 0x30B47FE3,
246 .sdram_tim3 = 0x409F8AD8,
247 .read_idle_ctrl = 0x00050000,
248 .zq_config = 0x5007190B,
249 .temp_alert_config = 0x00000000,
250 .emif_ddr_phy_ctlr_1_init = 0x0824400D,
251 .emif_ddr_phy_ctlr_1 = 0x0E24400D,
252 .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
253 .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
254 .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
255 .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
256 .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
257 .emif_rd_wr_lvl_rmp_win = 0x00000000,
258 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
259 .emif_rd_wr_lvl_ctl = 0x00000000,
260 .emif_rd_wr_exec_thresh = 0x00000305
261};
262
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530263void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
264{
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530265 u64 ram_size;
266
267 ram_size = board_ti_get_emif_size();
268
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530269 switch (omap_revision()) {
270 case DRA752_ES1_0:
271 case DRA752_ES1_1:
272 case DRA752_ES2_0:
273 switch (emif_nr) {
274 case 1:
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530275 if (ram_size > CONFIG_MAX_MEM_MAPPED)
276 *regs = &emif1_ddr3_532_mhz_1cs_2G;
277 else
278 *regs = &emif1_ddr3_532_mhz_1cs;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530279 break;
280 case 2:
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530281 if (ram_size > CONFIG_MAX_MEM_MAPPED)
282 *regs = &emif2_ddr3_532_mhz_1cs_2G;
283 else
284 *regs = &emif2_ddr3_532_mhz_1cs;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530285 break;
286 }
287 break;
Lokesh Vutla6f1038f2017-08-21 12:50:55 +0530288 case DRA762_ES1_0:
289 if (emif_nr == 1)
290 *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra76;
291 else
292 *regs = &emif_2_regs_ddr3_666_mhz_1cs_dra76;
293 break;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530294 case DRA722_ES1_0:
Ravi Babue1031082016-03-15 18:09:14 -0500295 case DRA722_ES2_0:
Vishal Mahaveer42d25eb2017-08-26 16:51:22 -0500296 case DRA722_ES2_1:
Ravi Babue1031082016-03-15 18:09:14 -0500297 if (ram_size < CONFIG_MAX_MEM_MAPPED)
298 *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es1;
299 else
300 *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es2;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530301 break;
302 default:
303 *regs = &emif1_ddr3_532_mhz_1cs;
304 }
305}
306
307static const struct dmm_lisa_map_regs lisa_map_dra7_1536MB = {
308 .dmm_lisa_map_0 = 0x0,
309 .dmm_lisa_map_1 = 0x80640300,
310 .dmm_lisa_map_2 = 0xC0500220,
311 .dmm_lisa_map_3 = 0xFF020100,
312 .is_ma_present = 0x1
313};
314
315static const struct dmm_lisa_map_regs lisa_map_2G_x_2 = {
316 .dmm_lisa_map_0 = 0x0,
317 .dmm_lisa_map_1 = 0x0,
318 .dmm_lisa_map_2 = 0x80600100,
319 .dmm_lisa_map_3 = 0xFF020100,
320 .is_ma_present = 0x1
321};
322
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530323const struct dmm_lisa_map_regs lisa_map_dra7_2GB = {
324 .dmm_lisa_map_0 = 0x0,
325 .dmm_lisa_map_1 = 0x0,
326 .dmm_lisa_map_2 = 0x80740300,
327 .dmm_lisa_map_3 = 0xFF020100,
328 .is_ma_present = 0x1
329};
330
Ravi Babue1031082016-03-15 18:09:14 -0500331/*
332 * DRA722 EVM EMIF1 2GB CONFIGURATION
333 * EMIF1 4 devices of 512Mb x 8 Micron
334 */
335const struct dmm_lisa_map_regs lisa_map_2G_x_4 = {
336 .dmm_lisa_map_0 = 0x0,
337 .dmm_lisa_map_1 = 0x0,
338 .dmm_lisa_map_2 = 0x80700100,
339 .dmm_lisa_map_3 = 0xFF020100,
340 .is_ma_present = 0x1
341};
342
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530343void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
344{
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530345 u64 ram_size;
346
347 ram_size = board_ti_get_emif_size();
348
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530349 switch (omap_revision()) {
Lokesh Vutla6f1038f2017-08-21 12:50:55 +0530350 case DRA762_ES1_0:
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530351 case DRA752_ES1_0:
352 case DRA752_ES1_1:
353 case DRA752_ES2_0:
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530354 if (ram_size > CONFIG_MAX_MEM_MAPPED)
355 *dmm_lisa_regs = &lisa_map_dra7_2GB;
356 else
357 *dmm_lisa_regs = &lisa_map_dra7_1536MB;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530358 break;
359 case DRA722_ES1_0:
Ravi Babue1031082016-03-15 18:09:14 -0500360 case DRA722_ES2_0:
Vishal Mahaveer42d25eb2017-08-26 16:51:22 -0500361 case DRA722_ES2_1:
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530362 default:
Ravi Babue1031082016-03-15 18:09:14 -0500363 if (ram_size < CONFIG_MAX_MEM_MAPPED)
364 *dmm_lisa_regs = &lisa_map_2G_x_2;
365 else
366 *dmm_lisa_regs = &lisa_map_2G_x_4;
367 break;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530368 }
369}
370
Keerthyc8056232016-06-07 16:05:25 +0530371struct vcores_data dra752_volts = {
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530372 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
373 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
Keerthyc8056232016-06-07 16:05:25 +0530374 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
375 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
376 .mpu.pmic = &tps659038,
377 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
378
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530379 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
380 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
381 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
382 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
383 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
384 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530385 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
386 .eve.addr = TPS659038_REG_ADDR_SMPS45,
387 .eve.pmic = &tps659038,
388 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
389
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530390 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
391 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
392 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
393 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
394 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
395 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530396 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
397 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
398 .gpu.pmic = &tps659038,
399 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
400
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530401 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
402 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
Keerthyc8056232016-06-07 16:05:25 +0530403 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
404 .core.addr = TPS659038_REG_ADDR_SMPS7,
405 .core.pmic = &tps659038,
406
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530407 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
408 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
409 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
410 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
411 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
412 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530413 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
414 .iva.addr = TPS659038_REG_ADDR_SMPS8,
415 .iva.pmic = &tps659038,
416 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
417};
418
Keerthy1b21f552017-08-21 12:50:54 +0530419struct vcores_data dra76x_volts = {
420 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
421 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
422 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
423 .mpu.addr = LP87565_REG_ADDR_BUCK01,
424 .mpu.pmic = &lp87565,
425 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
426
427 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
428 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
429 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
430 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
431 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
432 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
433 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
434 .eve.addr = TPS65917_REG_ADDR_SMPS1,
435 .eve.pmic = &tps659038,
436 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
437
438 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
439 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
440 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
441 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
442 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
443 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
444 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
445 .gpu.addr = LP87565_REG_ADDR_BUCK23,
446 .gpu.pmic = &lp87565,
447 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
448
449 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
450 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
451 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
452 .core.addr = TPS65917_REG_ADDR_SMPS3,
453 .core.pmic = &tps659038,
454
455 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
456 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
457 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
458 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
459 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
460 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
461 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
462 .iva.addr = TPS65917_REG_ADDR_SMPS4,
463 .iva.pmic = &tps659038,
464 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
465};
466
Keerthyc8056232016-06-07 16:05:25 +0530467struct vcores_data dra722_volts = {
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530468 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
469 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
Keerthyc8056232016-06-07 16:05:25 +0530470 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
471 .mpu.addr = TPS65917_REG_ADDR_SMPS1,
472 .mpu.pmic = &tps659038,
473 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
474
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530475 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
476 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
Keerthyc8056232016-06-07 16:05:25 +0530477 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
478 .core.addr = TPS65917_REG_ADDR_SMPS2,
479 .core.pmic = &tps659038,
480
481 /*
482 * The DSPEVE, GPU and IVA rails are usually grouped on DRA72x
483 * designs and powered by TPS65917 SMPS3, as on the J6Eco EVM.
484 */
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530485 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
486 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
487 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
488 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
489 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
490 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530491 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
492 .gpu.addr = TPS65917_REG_ADDR_SMPS3,
493 .gpu.pmic = &tps659038,
494 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
495
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530496 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
497 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
498 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
499 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
500 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
501 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530502 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
503 .eve.addr = TPS65917_REG_ADDR_SMPS3,
504 .eve.pmic = &tps659038,
505 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
506
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530507 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
508 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
509 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
510 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
511 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
512 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530513 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
514 .iva.addr = TPS65917_REG_ADDR_SMPS3,
515 .iva.pmic = &tps659038,
516 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
517};
518
Keerthy4d4e34b2016-11-23 13:25:27 +0530519struct vcores_data dra718_volts = {
520 /*
521 * In the case of dra71x GPU MPU and CORE
522 * are all powered up by BUCK0 of LP873X PMIC
523 */
524 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
525 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
526 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
527 .mpu.addr = LP873X_REG_ADDR_BUCK0,
528 .mpu.pmic = &lp8733,
529 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
530
531 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
532 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
533 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
534 .core.addr = LP873X_REG_ADDR_BUCK0,
535 .core.pmic = &lp8733,
536
537 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
538 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
539 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
540 .gpu.addr = LP873X_REG_ADDR_BUCK0,
541 .gpu.pmic = &lp8733,
542 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
543
544 /*
545 * The DSPEVE and IVA rails are grouped on DRA71x-evm
546 * and are powered by BUCK1 of LP873X PMIC
547 */
548 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
Lokesh Vutlacae84282017-04-20 14:07:52 +0530549 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
Keerthy4d4e34b2016-11-23 13:25:27 +0530550 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
Lokesh Vutlacae84282017-04-20 14:07:52 +0530551 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Keerthy4d4e34b2016-11-23 13:25:27 +0530552 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
553 .eve.addr = LP873X_REG_ADDR_BUCK1,
554 .eve.pmic = &lp8733,
555 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
556
557 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
Lokesh Vutlacae84282017-04-20 14:07:52 +0530558 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
Keerthy4d4e34b2016-11-23 13:25:27 +0530559 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
Lokesh Vutlacae84282017-04-20 14:07:52 +0530560 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthy4d4e34b2016-11-23 13:25:27 +0530561 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
562 .iva.addr = LP873X_REG_ADDR_BUCK1,
563 .iva.pmic = &lp8733,
564 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
565};
566
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530567int get_voltrail_opp(int rail_offset)
568{
569 int opp;
570
571 switch (rail_offset) {
572 case VOLT_MPU:
573 opp = DRA7_MPU_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530574 /* DRA71x supports only OPP_NOM for MPU */
575 if (board_is_dra71x_evm())
576 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530577 break;
578 case VOLT_CORE:
579 opp = DRA7_CORE_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530580 /* DRA71x supports only OPP_NOM for CORE */
581 if (board_is_dra71x_evm())
582 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530583 break;
584 case VOLT_GPU:
585 opp = DRA7_GPU_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530586 /* DRA71x supports only OPP_NOM for GPU */
587 if (board_is_dra71x_evm())
588 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530589 break;
590 case VOLT_EVE:
591 opp = DRA7_DSPEVE_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530592 /*
593 * DRA71x does not support OPP_OD for EVE.
594 * If OPP_OD is selected by menuconfig, fallback
595 * to OPP_NOM.
596 */
597 if (board_is_dra71x_evm() && opp == OPP_OD)
598 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530599 break;
600 case VOLT_IVA:
601 opp = DRA7_IVA_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530602 /*
603 * DRA71x does not support OPP_OD for IVA.
604 * If OPP_OD is selected by menuconfig, fallback
605 * to OPP_NOM.
606 */
607 if (board_is_dra71x_evm() && opp == OPP_OD)
608 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530609 break;
610 default:
611 opp = OPP_NOM;
612 }
613
614 return opp;
615}
616
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000617/**
618 * @brief board_init
619 *
620 * @return 0
621 */
622int board_init(void)
623{
624 gpmc_init();
625 gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
626
627 return 0;
628}
629
Simon Glass2f949c32017-03-31 08:40:32 -0600630int dram_init_banksize(void)
Lokesh Vutla0deb3332016-03-08 09:18:09 +0530631{
632 u64 ram_size;
633
634 ram_size = board_ti_get_emif_size();
635
636 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
637 gd->bd->bi_dram[0].size = get_effective_memsize();
638 if (ram_size > CONFIG_MAX_MEM_MAPPED) {
639 gd->bd->bi_dram[1].start = 0x200000000;
640 gd->bd->bi_dram[1].size = ram_size - CONFIG_MAX_MEM_MAPPED;
641 }
Simon Glass2f949c32017-03-31 08:40:32 -0600642
643 return 0;
Lokesh Vutla0deb3332016-03-08 09:18:09 +0530644}
645
Roger Quadrosf019ee82013-11-11 16:56:44 +0200646int board_late_init(void)
647{
Lokesh Vutla6d576a72014-07-14 19:57:58 +0530648#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530649 char *name = "unknown";
650
Lokesh Vutla9e23ab52016-06-29 14:50:41 +0530651 if (is_dra72x()) {
652 if (board_is_dra72x_revc_or_later())
653 name = "dra72x-revc";
Lokesh Vutlab9d8f8e2016-11-23 13:25:24 +0530654 else if (board_is_dra71x_evm())
655 name = "dra71x";
Lokesh Vutla9e23ab52016-06-29 14:50:41 +0530656 else
657 name = "dra72x";
Lokesh Vutla13376132017-08-21 12:50:53 +0530658 } else if (is_dra76x()) {
659 name = "dra76x";
Lokesh Vutla9e23ab52016-06-29 14:50:41 +0530660 } else {
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530661 name = "dra7xx";
Lokesh Vutla9e23ab52016-06-29 14:50:41 +0530662 }
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530663
664 set_board_info_env(name);
Dileep Katta7354dfc2015-03-25 04:04:51 +0530665
Lokesh Vutla73368b72016-11-29 11:58:01 +0530666 /*
667 * Default FIT boot on HS devices. Non FIT images are not allowed
668 * on HS devices.
669 */
670 if (get_device_type() == HS_DEVICE)
Simon Glass6a38e412017-08-03 12:22:09 -0600671 env_set("boot_fit", "1");
Lokesh Vutla73368b72016-11-29 11:58:01 +0530672
Paul Kocialkowski2edadee2015-08-27 19:37:12 +0200673 omap_die_id_serial();
Semen Protsenko4a845322017-05-22 19:16:42 +0300674 omap_set_fastboot_vars();
Keerthybe0c1f12017-10-12 10:18:45 +0530675
676 /*
677 * Hook the LDO1 regulator to EN pin. This applies only to LP8733
678 * Rest all regulators are hooked to EN Pin at reset.
679 */
680 if (board_is_dra71x_evm())
681 palmas_i2c_write_u8(LP873X_I2C_SLAVE_ADDR, 0x9, 0x7);
Lokesh Vutla6d576a72014-07-14 19:57:58 +0530682#endif
Roger Quadrosf019ee82013-11-11 16:56:44 +0200683 return 0;
684}
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530685
686#ifdef CONFIG_SPL_BUILD
687void do_board_detect(void)
688{
689 int rc;
690
691 rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS,
692 CONFIG_EEPROM_CHIP_ADDRESS);
693 if (rc)
694 printf("ti_i2c_eeprom_init failed %d\n", rc);
695}
696
697#else
698
699void do_board_detect(void)
700{
701 char *bname = NULL;
702 int rc;
703
704 rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS,
705 CONFIG_EEPROM_CHIP_ADDRESS);
706 if (rc)
707 printf("ti_i2c_eeprom_init failed %d\n", rc);
708
709 if (board_is_dra74x_evm()) {
710 bname = "DRA74x EVM";
Ravi Babue1031082016-03-15 18:09:14 -0500711 } else if (board_is_dra72x_evm()) {
712 bname = "DRA72x EVM";
Lokesh Vutlab9d8f8e2016-11-23 13:25:24 +0530713 } else if (board_is_dra71x_evm()) {
714 bname = "DRA71x EVM";
Lokesh Vutla13376132017-08-21 12:50:53 +0530715 } else if (board_is_dra76x_evm()) {
716 bname = "DRA76x EVM";
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530717 } else {
Ravi Babue1031082016-03-15 18:09:14 -0500718 /* If EEPROM is not populated */
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530719 if (is_dra72x())
720 bname = "DRA72x EVM";
721 else
722 bname = "DRA74x EVM";
723 }
724
725 if (bname)
726 snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
727 "Board: %s REV %s\n", bname, board_ti_get_rev());
728}
729#endif /* CONFIG_SPL_BUILD */
Roger Quadrosf019ee82013-11-11 16:56:44 +0200730
Keerthyc8056232016-06-07 16:05:25 +0530731void vcores_init(void)
732{
733 if (board_is_dra74x_evm()) {
734 *omap_vcores = &dra752_volts;
735 } else if (board_is_dra72x_evm()) {
736 *omap_vcores = &dra722_volts;
Keerthy4d4e34b2016-11-23 13:25:27 +0530737 } else if (board_is_dra71x_evm()) {
738 *omap_vcores = &dra718_volts;
Keerthy1b21f552017-08-21 12:50:54 +0530739 } else if (board_is_dra76x_evm()) {
740 *omap_vcores = &dra76x_volts;
Keerthyc8056232016-06-07 16:05:25 +0530741 } else {
742 /* If EEPROM is not populated */
743 if (is_dra72x())
744 *omap_vcores = &dra722_volts;
745 else
746 *omap_vcores = &dra752_volts;
747 }
748}
749
Paul Kocialkowskia00b1e52016-02-27 19:18:56 +0100750void set_muxconf_regs(void)
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000751{
752 do_set_mux32((*ctrl)->control_padconf_core_base,
Lokesh Vutla1fd80222015-06-04 16:42:38 +0530753 early_padconf, ARRAY_SIZE(early_padconf));
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000754}
755
Lokesh Vutla1fd80222015-06-04 16:42:38 +0530756#ifdef CONFIG_IODELAY_RECALIBRATION
757void recalibrate_iodelay(void)
758{
Nishanth Menond3b7d852016-03-15 18:09:17 -0500759 struct pad_conf_entry const *pads, *delta_pads = NULL;
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500760 struct iodelay_cfg_entry const *iodelay;
Nishanth Menond3b7d852016-03-15 18:09:17 -0500761 int npads, niodelays, delta_npads = 0;
762 int ret;
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500763
764 switch (omap_revision()) {
765 case DRA722_ES1_0:
Nishanth Menond3b7d852016-03-15 18:09:17 -0500766 case DRA722_ES2_0:
Vishal Mahaveer42d25eb2017-08-26 16:51:22 -0500767 case DRA722_ES2_1:
Nishanth Menond3b7d852016-03-15 18:09:17 -0500768 pads = dra72x_core_padconf_array_common;
769 npads = ARRAY_SIZE(dra72x_core_padconf_array_common);
Lokesh Vutla52ac1fe2016-11-23 13:25:25 +0530770 if (board_is_dra71x_evm()) {
771 pads = dra71x_core_padconf_array;
772 npads = ARRAY_SIZE(dra71x_core_padconf_array);
773 iodelay = dra71_iodelay_cfg_array;
774 niodelays = ARRAY_SIZE(dra71_iodelay_cfg_array);
775 } else if (board_is_dra72x_revc_or_later()) {
Nishanth Menond3b7d852016-03-15 18:09:17 -0500776 delta_pads = dra72x_rgmii_padconf_array_revc;
777 delta_npads =
778 ARRAY_SIZE(dra72x_rgmii_padconf_array_revc);
779 iodelay = dra72_iodelay_cfg_array_revc;
780 niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revc);
781 } else {
782 delta_pads = dra72x_rgmii_padconf_array_revb;
783 delta_npads =
784 ARRAY_SIZE(dra72x_rgmii_padconf_array_revb);
785 iodelay = dra72_iodelay_cfg_array_revb;
786 niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revb);
787 }
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500788 break;
789 case DRA752_ES1_0:
790 case DRA752_ES1_1:
791 pads = dra74x_core_padconf_array;
792 npads = ARRAY_SIZE(dra74x_core_padconf_array);
793 iodelay = dra742_es1_1_iodelay_cfg_array;
794 niodelays = ARRAY_SIZE(dra742_es1_1_iodelay_cfg_array);
795 break;
Lokesh Vutla7e7d4762017-08-21 12:50:56 +0530796 case DRA762_ES1_0:
797 pads = dra76x_core_padconf_array;
798 npads = ARRAY_SIZE(dra76x_core_padconf_array);
799 iodelay = dra76x_es1_0_iodelay_cfg_array;
800 niodelays = ARRAY_SIZE(dra76x_es1_0_iodelay_cfg_array);
801 break;
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500802 default:
803 case DRA752_ES2_0:
804 pads = dra74x_core_padconf_array;
805 npads = ARRAY_SIZE(dra74x_core_padconf_array);
806 iodelay = dra742_es2_0_iodelay_cfg_array;
807 niodelays = ARRAY_SIZE(dra742_es2_0_iodelay_cfg_array);
Nishanth Menonbe3a5532015-08-13 09:51:00 -0500808 /* Setup port1 and port2 for rgmii with 'no-id' mode */
809 clrset_spare_register(1, 0, RGMII2_ID_MODE_N_MASK |
810 RGMII1_ID_MODE_N_MASK);
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500811 break;
Nishanth Menon97313b52015-06-04 16:42:39 +0530812 }
Nishanth Menond3b7d852016-03-15 18:09:17 -0500813 /* Setup I/O isolation */
814 ret = __recalibrate_iodelay_start();
815 if (ret)
816 goto err;
817
818 /* Do the muxing here */
819 do_set_mux32((*ctrl)->control_padconf_core_base, pads, npads);
820
821 /* Now do the weird minor deltas that should be safe */
822 if (delta_npads)
823 do_set_mux32((*ctrl)->control_padconf_core_base,
824 delta_pads, delta_npads);
825
826 /* Setup IOdelay configuration */
827 ret = do_set_iodelay((*ctrl)->iodelay_config_base, iodelay, niodelays);
828err:
829 /* Closeup.. remove isolation */
830 __recalibrate_iodelay_end(ret);
Lokesh Vutla1fd80222015-06-04 16:42:38 +0530831}
832#endif
833
Masahiro Yamada0a780172017-05-09 20:31:39 +0900834#if defined(CONFIG_MMC)
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000835int board_mmc_init(bd_t *bis)
836{
837 omap_mmc_init(0, 0, 0, -1, -1);
838 omap_mmc_init(1, 0, 0, -1, -1);
839 return 0;
840}
Lokesh Vutla8352d272017-08-21 12:50:49 +0530841
842void board_mmc_poweron_ldo(uint voltage)
843{
844 if (board_is_dra71x_evm()) {
845 if (voltage == LDO_VOLT_3V0)
846 voltage = 0x19;
847 else if (voltage == LDO_VOLT_1V8)
848 voltage = 0xa;
849 lp873x_mmc1_poweron_ldo(voltage);
Lokesh Vutla4712cc42017-08-21 12:50:57 +0530850 } else if (board_is_dra76x_evm()) {
851 palmas_mmc1_poweron_ldo(LDO4_VOLTAGE, LDO4_CTRL, voltage);
Lokesh Vutla8352d272017-08-21 12:50:49 +0530852 } else {
Lokesh Vutla22fa8192017-08-21 12:50:50 +0530853 palmas_mmc1_poweron_ldo(LDO1_VOLTAGE, LDO1_CTRL, voltage);
Lokesh Vutla8352d272017-08-21 12:50:49 +0530854 }
855}
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000856#endif
Mugunthan V Nab48f782013-07-08 16:04:41 +0530857
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530858#ifdef CONFIG_USB_DWC3
859static struct dwc3_device usb_otg_ss1 = {
860 .maximum_speed = USB_SPEED_SUPER,
861 .base = DRA7_USB_OTG_SS1_BASE,
862 .tx_fifo_resize = false,
863 .index = 0,
864};
865
866static struct dwc3_omap_device usb_otg_ss1_glue = {
867 .base = (void *)DRA7_USB_OTG_SS1_GLUE_BASE,
868 .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530869 .index = 0,
870};
871
872static struct ti_usb_phy_device usb_phy1_device = {
873 .pll_ctrl_base = (void *)DRA7_USB3_PHY1_PLL_CTRL,
874 .usb2_phy_power = (void *)DRA7_USB2_PHY1_POWER,
875 .usb3_phy_power = (void *)DRA7_USB3_PHY1_POWER,
876 .index = 0,
877};
878
879static struct dwc3_device usb_otg_ss2 = {
880 .maximum_speed = USB_SPEED_SUPER,
881 .base = DRA7_USB_OTG_SS2_BASE,
882 .tx_fifo_resize = false,
883 .index = 1,
884};
885
886static struct dwc3_omap_device usb_otg_ss2_glue = {
887 .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE,
888 .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530889 .index = 1,
890};
891
892static struct ti_usb_phy_device usb_phy2_device = {
893 .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER,
894 .index = 1,
895};
896
Uri Mashiach63830662017-02-23 15:39:37 +0200897int omap_xhci_board_usb_init(int index, enum usb_init_type init)
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530898{
Kishon Vijay Abraham I831bcba2015-08-19 16:16:27 +0530899 enable_usb_clocks(index);
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530900 switch (index) {
901 case 0:
902 if (init == USB_INIT_DEVICE) {
903 usb_otg_ss1.dr_mode = USB_DR_MODE_PERIPHERAL;
904 usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
905 } else {
906 usb_otg_ss1.dr_mode = USB_DR_MODE_HOST;
907 usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_ID_GROUND;
908 }
909
910 ti_usb_phy_uboot_init(&usb_phy1_device);
911 dwc3_omap_uboot_init(&usb_otg_ss1_glue);
912 dwc3_uboot_init(&usb_otg_ss1);
913 break;
914 case 1:
915 if (init == USB_INIT_DEVICE) {
916 usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL;
917 usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
918 } else {
919 usb_otg_ss2.dr_mode = USB_DR_MODE_HOST;
920 usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_ID_GROUND;
921 }
922
923 ti_usb_phy_uboot_init(&usb_phy2_device);
924 dwc3_omap_uboot_init(&usb_otg_ss2_glue);
925 dwc3_uboot_init(&usb_otg_ss2);
926 break;
927 default:
928 printf("Invalid Controller Index\n");
929 }
930
931 return 0;
932}
933
Uri Mashiach63830662017-02-23 15:39:37 +0200934int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530935{
936 switch (index) {
937 case 0:
938 case 1:
939 ti_usb_phy_uboot_exit(index);
940 dwc3_uboot_exit(index);
941 dwc3_omap_uboot_exit(index);
942 break;
943 default:
944 printf("Invalid Controller Index\n");
945 }
Kishon Vijay Abraham I831bcba2015-08-19 16:16:27 +0530946 disable_usb_clocks(index);
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530947 return 0;
948}
949
Kishon Vijay Abraham I4763e162015-02-23 18:40:23 +0530950int usb_gadget_handle_interrupts(int index)
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530951{
952 u32 status;
953
Kishon Vijay Abraham I4763e162015-02-23 18:40:23 +0530954 status = dwc3_omap_uboot_interrupt_status(index);
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530955 if (status)
Kishon Vijay Abraham I4763e162015-02-23 18:40:23 +0530956 dwc3_uboot_handle_interrupt(index);
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +0530957
958 return 0;
959}
960#endif
961
Tom Rini560ef452014-04-03 07:52:56 -0400962#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
963int spl_start_uboot(void)
964{
965 /* break into full u-boot on 'c' */
966 if (serial_tstc() && serial_getc() == 'c')
967 return 1;
968
969#ifdef CONFIG_SPL_ENV_SUPPORT
970 env_init();
Simon Glass17539572017-08-03 12:22:07 -0600971 env_load();
Simon Glass22c34c22017-08-03 12:22:13 -0600972 if (env_get_yesno("boot_os") != 1)
Tom Rini560ef452014-04-03 07:52:56 -0400973 return 1;
974#endif
975
976 return 0;
977}
978#endif
979
Mugunthan V Nab48f782013-07-08 16:04:41 +0530980#ifdef CONFIG_DRIVER_TI_CPSW
Mugunthan V Nde170b32014-05-22 14:37:12 +0530981extern u32 *const omap_si_rev;
982
Mugunthan V Nab48f782013-07-08 16:04:41 +0530983static void cpsw_control(int enabled)
984{
985 /* VTP can be added here */
986
987 return;
988}
989
990static struct cpsw_slave_data cpsw_slaves[] = {
991 {
992 .slave_reg_ofs = 0x208,
993 .sliver_reg_ofs = 0xd80,
Mugunthan V N4944f372014-02-18 07:31:52 -0500994 .phy_addr = 2,
Mugunthan V Nab48f782013-07-08 16:04:41 +0530995 },
996 {
997 .slave_reg_ofs = 0x308,
998 .sliver_reg_ofs = 0xdc0,
Mugunthan V N4944f372014-02-18 07:31:52 -0500999 .phy_addr = 3,
Mugunthan V Nab48f782013-07-08 16:04:41 +05301000 },
1001};
1002
1003static struct cpsw_platform_data cpsw_data = {
1004 .mdio_base = CPSW_MDIO_BASE,
1005 .cpsw_base = CPSW_BASE,
1006 .mdio_div = 0xff,
1007 .channels = 8,
1008 .cpdma_reg_ofs = 0x800,
Mugunthan V Nde170b32014-05-22 14:37:12 +05301009 .slaves = 2,
Mugunthan V Nab48f782013-07-08 16:04:41 +05301010 .slave_data = cpsw_slaves,
1011 .ale_reg_ofs = 0xd00,
1012 .ale_entries = 1024,
1013 .host_port_reg_ofs = 0x108,
1014 .hw_stats_reg_ofs = 0x900,
1015 .bd_ram_ofs = 0x2000,
1016 .mac_control = (1 << 5),
1017 .control = cpsw_control,
1018 .host_port_num = 0,
1019 .version = CPSW_CTRL_VERSION_2,
1020};
1021
1022int board_eth_init(bd_t *bis)
1023{
1024 int ret;
1025 uint8_t mac_addr[6];
1026 uint32_t mac_hi, mac_lo;
1027 uint32_t ctrl_val;
Mugunthan V Nab48f782013-07-08 16:04:41 +05301028
1029 /* try reading mac address from efuse */
1030 mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
1031 mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
Mugunthan V Nf8b45c22014-01-07 19:57:38 +05301032 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
Mugunthan V Nab48f782013-07-08 16:04:41 +05301033 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
Mugunthan V Nf8b45c22014-01-07 19:57:38 +05301034 mac_addr[2] = mac_hi & 0xFF;
1035 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
Mugunthan V Nab48f782013-07-08 16:04:41 +05301036 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
Mugunthan V Nf8b45c22014-01-07 19:57:38 +05301037 mac_addr[5] = mac_lo & 0xFF;
Mugunthan V Nab48f782013-07-08 16:04:41 +05301038
Simon Glass64b723f2017-08-03 12:22:12 -06001039 if (!env_get("ethaddr")) {
Mugunthan V Nab48f782013-07-08 16:04:41 +05301040 printf("<ethaddr> not set. Validating first E-fuse MAC\n");
1041
Joe Hershberger8ecdbed2015-04-08 01:41:04 -05001042 if (is_valid_ethaddr(mac_addr))
Simon Glass8551d552017-08-03 12:22:11 -06001043 eth_env_set_enetaddr("ethaddr", mac_addr);
Mugunthan V Nab48f782013-07-08 16:04:41 +05301044 }
Mugunthan V N1991b5c2014-02-18 07:31:56 -05001045
1046 mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
1047 mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
1048 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
1049 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
1050 mac_addr[2] = mac_hi & 0xFF;
1051 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
1052 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
1053 mac_addr[5] = mac_lo & 0xFF;
1054
Simon Glass64b723f2017-08-03 12:22:12 -06001055 if (!env_get("eth1addr")) {
Joe Hershberger8ecdbed2015-04-08 01:41:04 -05001056 if (is_valid_ethaddr(mac_addr))
Simon Glass8551d552017-08-03 12:22:11 -06001057 eth_env_set_enetaddr("eth1addr", mac_addr);
Mugunthan V N1991b5c2014-02-18 07:31:56 -05001058 }
1059
Mugunthan V Nab48f782013-07-08 16:04:41 +05301060 ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
1061 ctrl_val |= 0x22;
1062 writel(ctrl_val, (*ctrl)->control_core_control_io1);
1063
Mugunthan V Nde170b32014-05-22 14:37:12 +05301064 if (*omap_si_rev == DRA722_ES1_0)
1065 cpsw_data.active_slave = 1;
1066
Dan Murphyb1941f32016-03-30 12:58:37 -05001067 if (board_is_dra72x_revc_or_later()) {
1068 cpsw_slaves[0].phy_if = PHY_INTERFACE_MODE_RGMII_ID;
1069 cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_RGMII_ID;
1070 }
1071
Mugunthan V Nab48f782013-07-08 16:04:41 +05301072 ret = cpsw_register(&cpsw_data);
1073 if (ret < 0)
1074 printf("Error %d registering CPSW switch\n", ret);
1075
1076 return ret;
1077}
1078#endif
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +05301079
1080#ifdef CONFIG_BOARD_EARLY_INIT_F
1081/* VTT regulator enable */
1082static inline void vtt_regulator_enable(void)
1083{
1084 if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
1085 return;
1086
Lokesh Vutla6f1038f2017-08-21 12:50:55 +05301087 /* Do not enable VTT for DRA722 or DRA76x */
1088 if (is_dra72x() || is_dra76x())
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +05301089 return;
1090
1091 /*
1092 * EVM Rev G and later use gpio7_11 for DDR3 termination.
1093 * This is safe enough to do on older revs.
1094 */
1095 gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
1096 gpio_direction_output(GPIO_DDR_VTT_EN, 1);
1097}
1098
1099int board_early_init_f(void)
1100{
1101 vtt_regulator_enable();
1102 return 0;
1103}
1104#endif
Daniel Allred7ceffb22016-05-19 19:10:54 -05001105
1106#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
1107int ft_board_setup(void *blob, bd_t *bd)
1108{
1109 ft_cpu_setup(blob, bd);
1110
1111 return 0;
1112}
1113#endif
Lokesh Vutlaf4de4722016-05-16 10:51:23 +05301114
1115#ifdef CONFIG_SPL_LOAD_FIT
1116int board_fit_config_name_match(const char *name)
1117{
Mugunthan V Nb8c6b022016-09-27 13:01:41 +05301118 if (is_dra72x()) {
Lokesh Vutlaf0d55172016-11-23 13:25:30 +05301119 if (board_is_dra71x_evm()) {
1120 if (!strcmp(name, "dra71-evm"))
1121 return 0;
1122 }else if(board_is_dra72x_revc_or_later()) {
Mugunthan V Nb8c6b022016-09-27 13:01:41 +05301123 if (!strcmp(name, "dra72-evm-revc"))
1124 return 0;
1125 } else if (!strcmp(name, "dra72-evm")) {
1126 return 0;
1127 }
Lokesh Vutla635848f2017-08-21 12:51:01 +05301128 } else if (is_dra76x() && !strcmp(name, "dra76-evm")) {
1129 return 0;
1130 } else if (!is_dra72x() && !is_dra76x() && !strcmp(name, "dra7-evm")) {
Lokesh Vutlaf4de4722016-05-16 10:51:23 +05301131 return 0;
Mugunthan V Nb8c6b022016-09-27 13:01:41 +05301132 }
1133
1134 return -1;
Lokesh Vutlaf4de4722016-05-16 10:51:23 +05301135}
1136#endif
Andreas Dannenberg5cf344b2016-06-27 09:19:22 -05001137
1138#ifdef CONFIG_TI_SECURE_DEVICE
1139void board_fit_image_post_process(void **p_image, size_t *p_size)
1140{
1141 secure_boot_verify_image(p_image, p_size);
1142}
Andrew F. Davisd216a4c2016-11-29 16:33:25 -06001143
1144void board_tee_image_process(ulong tee_image, size_t tee_size)
1145{
1146 secure_tee_install((u32)tee_image);
1147}
1148
1149U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
Andreas Dannenberg5cf344b2016-06-27 09:19:22 -05001150#endif