blob: 8c02addd081eac15242f7ea98372f4f80b3e8c80 [file] [log] [blame]
Lokesh Vutla687054a2013-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 Denk1a459662013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Lokesh Vutla687054a2013-02-12 21:29:08 +000012 */
13#include <common.h>
Nishanth Menoncb199102013-03-26 05:20:54 +000014#include <palmas.h>
Dan Murphye9024ef2014-02-03 06:59:02 -060015#include <sata.h>
Lokesh Vutla25afe552016-03-08 09:18:05 +053016#include <linux/string.h>
Lokesh Vutla7b922522014-08-04 19:42:24 +053017#include <asm/gpio.h>
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +053018#include <usb.h>
19#include <linux/usb/gadget.h>
Andreas Dannenberg17c29872016-06-27 09:19:22 -050020#include <asm/omap_common.h>
21#include <asm/omap_sec_common.h>
Lokesh Vutla7b922522014-08-04 19:42:24 +053022#include <asm/arch/gpio.h>
Lokesh Vutla706dd342015-06-04 16:42:38 +053023#include <asm/arch/dra7xx_iodelay.h>
Lokesh Vutlaa7638832016-03-08 09:18:06 +053024#include <asm/emif.h>
Lokesh Vutla687054a2013-02-12 21:29:08 +000025#include <asm/arch/sys_proto.h>
26#include <asm/arch/mmc_host_def.h>
Roger Quadros21914ee2013-11-11 16:56:44 +020027#include <asm/arch/sata.h>
Tom Rini79b079f2014-04-03 07:52:56 -040028#include <environment.h>
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +053029#include <dwc3-uboot.h>
30#include <dwc3-omap-uboot.h>
31#include <ti-usb-phy-uboot.h>
Dan Murphy39fbac92016-03-30 12:58:37 -050032#include <miiphy.h>
Lokesh Vutla687054a2013-02-12 21:29:08 +000033
34#include "mux_data.h"
Lokesh Vutla25afe552016-03-08 09:18:05 +053035#include "../common/board_detect.h"
36
37#define board_is_dra74x_evm() board_ti_is("5777xCPU")
Ravi Babu6b1c14b2016-03-15 18:09:14 -050038#define board_is_dra72x_evm() board_ti_is("DRA72x-T")
Lokesh Vutla463dd222016-11-23 13:25:24 +053039#define board_is_dra71x_evm() board_ti_is("DRA79x,D")
Mugunthan V N1053a762016-09-27 13:01:42 +053040#define board_is_dra74x_revh_or_later() (board_is_dra74x_evm() && \
41 (strncmp("H", board_ti_get_rev(), 1) <= 0))
42#define board_is_dra72x_revc_or_later() (board_is_dra72x_evm() && \
43 (strncmp("C", board_ti_get_rev(), 1) <= 0))
Lokesh Vutlac4a27362016-03-08 09:18:08 +053044#define board_ti_get_emif_size() board_ti_get_emif1_size() + \
45 board_ti_get_emif2_size()
Lokesh Vutla687054a2013-02-12 21:29:08 +000046
Mugunthan V Nb1e26e32013-07-08 16:04:41 +053047#ifdef CONFIG_DRIVER_TI_CPSW
48#include <cpsw.h>
49#endif
50
Lokesh Vutla687054a2013-02-12 21:29:08 +000051DECLARE_GLOBAL_DATA_PTR;
52
Lokesh Vutla7b922522014-08-04 19:42:24 +053053/* GPIO 7_11 */
54#define GPIO_DDR_VTT_EN 203
55
Lokesh Vutla25afe552016-03-08 09:18:05 +053056#define SYSINFO_BOARD_NAME_MAX_LEN 37
57
Lokesh Vutla687054a2013-02-12 21:29:08 +000058const struct omap_sysinfo sysinfo = {
Lokesh Vutla25afe552016-03-08 09:18:05 +053059 "Board: UNKNOWN(DRA7 EVM) REV UNKNOWN\n"
Lokesh Vutla687054a2013-02-12 21:29:08 +000060};
61
Lokesh Vutlaa7638832016-03-08 09:18:06 +053062static const struct emif_regs emif1_ddr3_532_mhz_1cs = {
63 .sdram_config_init = 0x61851ab2,
64 .sdram_config = 0x61851ab2,
65 .sdram_config2 = 0x08000000,
66 .ref_ctrl = 0x000040F1,
67 .ref_ctrl_final = 0x00001035,
68 .sdram_tim1 = 0xCCCF36B3,
69 .sdram_tim2 = 0x308F7FDA,
70 .sdram_tim3 = 0x427F88A8,
71 .read_idle_ctrl = 0x00050000,
72 .zq_config = 0x0007190B,
73 .temp_alert_config = 0x00000000,
74 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
75 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
76 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
77 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
78 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
79 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
80 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
81 .emif_rd_wr_lvl_rmp_win = 0x00000000,
82 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
83 .emif_rd_wr_lvl_ctl = 0x00000000,
84 .emif_rd_wr_exec_thresh = 0x00000305
85};
86
87static const struct emif_regs emif2_ddr3_532_mhz_1cs = {
88 .sdram_config_init = 0x61851B32,
89 .sdram_config = 0x61851B32,
90 .sdram_config2 = 0x08000000,
91 .ref_ctrl = 0x000040F1,
92 .ref_ctrl_final = 0x00001035,
93 .sdram_tim1 = 0xCCCF36B3,
94 .sdram_tim2 = 0x308F7FDA,
95 .sdram_tim3 = 0x427F88A8,
96 .read_idle_ctrl = 0x00050000,
97 .zq_config = 0x0007190B,
98 .temp_alert_config = 0x00000000,
99 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
100 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
101 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
102 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
103 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
104 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
105 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
106 .emif_rd_wr_lvl_rmp_win = 0x00000000,
107 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
108 .emif_rd_wr_lvl_ctl = 0x00000000,
109 .emif_rd_wr_exec_thresh = 0x00000305
110};
111
112static const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es1 = {
113 .sdram_config_init = 0x61862B32,
114 .sdram_config = 0x61862B32,
115 .sdram_config2 = 0x08000000,
116 .ref_ctrl = 0x0000514C,
117 .ref_ctrl_final = 0x0000144A,
118 .sdram_tim1 = 0xD113781C,
119 .sdram_tim2 = 0x30717FE3,
120 .sdram_tim3 = 0x409F86A8,
121 .read_idle_ctrl = 0x00050000,
122 .zq_config = 0x5007190B,
123 .temp_alert_config = 0x00000000,
124 .emif_ddr_phy_ctlr_1_init = 0x0024400D,
125 .emif_ddr_phy_ctlr_1 = 0x0E24400D,
126 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
127 .emif_ddr_ext_phy_ctrl_2 = 0x00A400A4,
128 .emif_ddr_ext_phy_ctrl_3 = 0x00A900A9,
129 .emif_ddr_ext_phy_ctrl_4 = 0x00B000B0,
130 .emif_ddr_ext_phy_ctrl_5 = 0x00B000B0,
131 .emif_rd_wr_lvl_rmp_win = 0x00000000,
132 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
133 .emif_rd_wr_lvl_ctl = 0x00000000,
134 .emif_rd_wr_exec_thresh = 0x00000305
135};
136
Ravi Babu6b1c14b2016-03-15 18:09:14 -0500137const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es2 = {
138 .sdram_config_init = 0x61862BB2,
139 .sdram_config = 0x61862BB2,
140 .sdram_config2 = 0x00000000,
141 .ref_ctrl = 0x0000514D,
142 .ref_ctrl_final = 0x0000144A,
143 .sdram_tim1 = 0xD1137824,
144 .sdram_tim2 = 0x30B37FE3,
145 .sdram_tim3 = 0x409F8AD8,
146 .read_idle_ctrl = 0x00050000,
147 .zq_config = 0x5007190B,
148 .temp_alert_config = 0x00000000,
149 .emif_ddr_phy_ctlr_1_init = 0x0824400E,
150 .emif_ddr_phy_ctlr_1 = 0x0E24400E,
151 .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
152 .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
153 .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
154 .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
155 .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
156 .emif_rd_wr_lvl_rmp_win = 0x00000000,
157 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
158 .emif_rd_wr_lvl_ctl = 0x00000000,
159 .emif_rd_wr_exec_thresh = 0x00000305
160};
161
Lokesh Vutlac4a27362016-03-08 09:18:08 +0530162const struct emif_regs emif1_ddr3_532_mhz_1cs_2G = {
163 .sdram_config_init = 0x61851ab2,
164 .sdram_config = 0x61851ab2,
165 .sdram_config2 = 0x08000000,
166 .ref_ctrl = 0x000040F1,
167 .ref_ctrl_final = 0x00001035,
168 .sdram_tim1 = 0xCCCF36B3,
169 .sdram_tim2 = 0x30BF7FDA,
170 .sdram_tim3 = 0x427F8BA8,
171 .read_idle_ctrl = 0x00050000,
172 .zq_config = 0x0007190B,
173 .temp_alert_config = 0x00000000,
174 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
175 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
176 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
177 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
178 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
179 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
180 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
181 .emif_rd_wr_lvl_rmp_win = 0x00000000,
182 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
183 .emif_rd_wr_lvl_ctl = 0x00000000,
184 .emif_rd_wr_exec_thresh = 0x00000305
185};
186
187const struct emif_regs emif2_ddr3_532_mhz_1cs_2G = {
188 .sdram_config_init = 0x61851B32,
189 .sdram_config = 0x61851B32,
190 .sdram_config2 = 0x08000000,
191 .ref_ctrl = 0x000040F1,
192 .ref_ctrl_final = 0x00001035,
193 .sdram_tim1 = 0xCCCF36B3,
194 .sdram_tim2 = 0x308F7FDA,
195 .sdram_tim3 = 0x427F88A8,
196 .read_idle_ctrl = 0x00050000,
197 .zq_config = 0x0007190B,
198 .temp_alert_config = 0x00000000,
199 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
200 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
201 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
202 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
203 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
204 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
205 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
206 .emif_rd_wr_lvl_rmp_win = 0x00000000,
207 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
208 .emif_rd_wr_lvl_ctl = 0x00000000,
209 .emif_rd_wr_exec_thresh = 0x00000305
210};
211
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530212void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
213{
Lokesh Vutlac4a27362016-03-08 09:18:08 +0530214 u64 ram_size;
215
216 ram_size = board_ti_get_emif_size();
217
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530218 switch (omap_revision()) {
219 case DRA752_ES1_0:
220 case DRA752_ES1_1:
221 case DRA752_ES2_0:
222 switch (emif_nr) {
223 case 1:
Lokesh Vutlac4a27362016-03-08 09:18:08 +0530224 if (ram_size > CONFIG_MAX_MEM_MAPPED)
225 *regs = &emif1_ddr3_532_mhz_1cs_2G;
226 else
227 *regs = &emif1_ddr3_532_mhz_1cs;
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530228 break;
229 case 2:
Lokesh Vutlac4a27362016-03-08 09:18:08 +0530230 if (ram_size > CONFIG_MAX_MEM_MAPPED)
231 *regs = &emif2_ddr3_532_mhz_1cs_2G;
232 else
233 *regs = &emif2_ddr3_532_mhz_1cs;
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530234 break;
235 }
236 break;
237 case DRA722_ES1_0:
Ravi Babu6b1c14b2016-03-15 18:09:14 -0500238 case DRA722_ES2_0:
239 if (ram_size < CONFIG_MAX_MEM_MAPPED)
240 *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es1;
241 else
242 *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es2;
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530243 break;
244 default:
245 *regs = &emif1_ddr3_532_mhz_1cs;
246 }
247}
248
249static const struct dmm_lisa_map_regs lisa_map_dra7_1536MB = {
250 .dmm_lisa_map_0 = 0x0,
251 .dmm_lisa_map_1 = 0x80640300,
252 .dmm_lisa_map_2 = 0xC0500220,
253 .dmm_lisa_map_3 = 0xFF020100,
254 .is_ma_present = 0x1
255};
256
257static const struct dmm_lisa_map_regs lisa_map_2G_x_2 = {
258 .dmm_lisa_map_0 = 0x0,
259 .dmm_lisa_map_1 = 0x0,
260 .dmm_lisa_map_2 = 0x80600100,
261 .dmm_lisa_map_3 = 0xFF020100,
262 .is_ma_present = 0x1
263};
264
Lokesh Vutlac4a27362016-03-08 09:18:08 +0530265const struct dmm_lisa_map_regs lisa_map_dra7_2GB = {
266 .dmm_lisa_map_0 = 0x0,
267 .dmm_lisa_map_1 = 0x0,
268 .dmm_lisa_map_2 = 0x80740300,
269 .dmm_lisa_map_3 = 0xFF020100,
270 .is_ma_present = 0x1
271};
272
Ravi Babu6b1c14b2016-03-15 18:09:14 -0500273/*
274 * DRA722 EVM EMIF1 2GB CONFIGURATION
275 * EMIF1 4 devices of 512Mb x 8 Micron
276 */
277const struct dmm_lisa_map_regs lisa_map_2G_x_4 = {
278 .dmm_lisa_map_0 = 0x0,
279 .dmm_lisa_map_1 = 0x0,
280 .dmm_lisa_map_2 = 0x80700100,
281 .dmm_lisa_map_3 = 0xFF020100,
282 .is_ma_present = 0x1
283};
284
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530285void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
286{
Lokesh Vutlac4a27362016-03-08 09:18:08 +0530287 u64 ram_size;
288
289 ram_size = board_ti_get_emif_size();
290
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530291 switch (omap_revision()) {
292 case DRA752_ES1_0:
293 case DRA752_ES1_1:
294 case DRA752_ES2_0:
Lokesh Vutlac4a27362016-03-08 09:18:08 +0530295 if (ram_size > CONFIG_MAX_MEM_MAPPED)
296 *dmm_lisa_regs = &lisa_map_dra7_2GB;
297 else
298 *dmm_lisa_regs = &lisa_map_dra7_1536MB;
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530299 break;
300 case DRA722_ES1_0:
Ravi Babu6b1c14b2016-03-15 18:09:14 -0500301 case DRA722_ES2_0:
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530302 default:
Ravi Babu6b1c14b2016-03-15 18:09:14 -0500303 if (ram_size < CONFIG_MAX_MEM_MAPPED)
304 *dmm_lisa_regs = &lisa_map_2G_x_2;
305 else
306 *dmm_lisa_regs = &lisa_map_2G_x_4;
307 break;
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530308 }
309}
310
Keerthy1428d832016-06-07 16:05:25 +0530311struct vcores_data dra752_volts = {
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530312 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
313 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
Keerthy1428d832016-06-07 16:05:25 +0530314 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
315 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
316 .mpu.pmic = &tps659038,
317 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
318
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530319 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
320 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
321 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
322 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
323 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
324 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Keerthy1428d832016-06-07 16:05:25 +0530325 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
326 .eve.addr = TPS659038_REG_ADDR_SMPS45,
327 .eve.pmic = &tps659038,
328 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
329
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530330 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
331 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
332 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
333 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
334 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
335 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
Keerthy1428d832016-06-07 16:05:25 +0530336 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
337 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
338 .gpu.pmic = &tps659038,
339 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
340
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530341 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
342 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
Keerthy1428d832016-06-07 16:05:25 +0530343 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
344 .core.addr = TPS659038_REG_ADDR_SMPS7,
345 .core.pmic = &tps659038,
346
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530347 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
348 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
349 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
350 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
351 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
352 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthy1428d832016-06-07 16:05:25 +0530353 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
354 .iva.addr = TPS659038_REG_ADDR_SMPS8,
355 .iva.pmic = &tps659038,
356 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
357};
358
359struct vcores_data dra722_volts = {
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530360 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
361 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
Keerthy1428d832016-06-07 16:05:25 +0530362 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
363 .mpu.addr = TPS65917_REG_ADDR_SMPS1,
364 .mpu.pmic = &tps659038,
365 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
366
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530367 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
368 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
Keerthy1428d832016-06-07 16:05:25 +0530369 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
370 .core.addr = TPS65917_REG_ADDR_SMPS2,
371 .core.pmic = &tps659038,
372
373 /*
374 * The DSPEVE, GPU and IVA rails are usually grouped on DRA72x
375 * designs and powered by TPS65917 SMPS3, as on the J6Eco EVM.
376 */
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530377 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
378 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
379 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
380 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
381 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
382 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
Keerthy1428d832016-06-07 16:05:25 +0530383 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
384 .gpu.addr = TPS65917_REG_ADDR_SMPS3,
385 .gpu.pmic = &tps659038,
386 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
387
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530388 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
389 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
390 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
391 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
392 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
393 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Keerthy1428d832016-06-07 16:05:25 +0530394 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
395 .eve.addr = TPS65917_REG_ADDR_SMPS3,
396 .eve.pmic = &tps659038,
397 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
398
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530399 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
400 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
401 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
402 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
403 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
404 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthy1428d832016-06-07 16:05:25 +0530405 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
406 .iva.addr = TPS65917_REG_ADDR_SMPS3,
407 .iva.pmic = &tps659038,
408 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
409};
410
Keerthyf56e6352016-11-23 13:25:27 +0530411struct vcores_data dra718_volts = {
412 /*
413 * In the case of dra71x GPU MPU and CORE
414 * are all powered up by BUCK0 of LP873X PMIC
415 */
416 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
417 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
418 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
419 .mpu.addr = LP873X_REG_ADDR_BUCK0,
420 .mpu.pmic = &lp8733,
421 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
422
423 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
424 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
425 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
426 .core.addr = LP873X_REG_ADDR_BUCK0,
427 .core.pmic = &lp8733,
428
429 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
430 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
431 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
432 .gpu.addr = LP873X_REG_ADDR_BUCK0,
433 .gpu.pmic = &lp8733,
434 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
435
436 /*
437 * The DSPEVE and IVA rails are grouped on DRA71x-evm
438 * and are powered by BUCK1 of LP873X PMIC
439 */
440 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
Lokesh Vutla6cc96bc2017-04-20 14:07:52 +0530441 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
Keerthyf56e6352016-11-23 13:25:27 +0530442 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
Lokesh Vutla6cc96bc2017-04-20 14:07:52 +0530443 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Keerthyf56e6352016-11-23 13:25:27 +0530444 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
445 .eve.addr = LP873X_REG_ADDR_BUCK1,
446 .eve.pmic = &lp8733,
447 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
448
449 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
Lokesh Vutla6cc96bc2017-04-20 14:07:52 +0530450 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
Keerthyf56e6352016-11-23 13:25:27 +0530451 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
Lokesh Vutla6cc96bc2017-04-20 14:07:52 +0530452 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthyf56e6352016-11-23 13:25:27 +0530453 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
454 .iva.addr = LP873X_REG_ADDR_BUCK1,
455 .iva.pmic = &lp8733,
456 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
457};
458
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530459int get_voltrail_opp(int rail_offset)
460{
461 int opp;
462
463 switch (rail_offset) {
464 case VOLT_MPU:
465 opp = DRA7_MPU_OPP;
Lokesh Vutla6cc96bc2017-04-20 14:07:52 +0530466 /* DRA71x supports only OPP_NOM for MPU */
467 if (board_is_dra71x_evm())
468 opp = OPP_NOM;
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530469 break;
470 case VOLT_CORE:
471 opp = DRA7_CORE_OPP;
Lokesh Vutla6cc96bc2017-04-20 14:07:52 +0530472 /* DRA71x supports only OPP_NOM for CORE */
473 if (board_is_dra71x_evm())
474 opp = OPP_NOM;
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530475 break;
476 case VOLT_GPU:
477 opp = DRA7_GPU_OPP;
Lokesh Vutla6cc96bc2017-04-20 14:07:52 +0530478 /* DRA71x supports only OPP_NOM for GPU */
479 if (board_is_dra71x_evm())
480 opp = OPP_NOM;
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530481 break;
482 case VOLT_EVE:
483 opp = DRA7_DSPEVE_OPP;
Lokesh Vutla6cc96bc2017-04-20 14:07:52 +0530484 /*
485 * DRA71x does not support OPP_OD for EVE.
486 * If OPP_OD is selected by menuconfig, fallback
487 * to OPP_NOM.
488 */
489 if (board_is_dra71x_evm() && opp == OPP_OD)
490 opp = OPP_NOM;
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530491 break;
492 case VOLT_IVA:
493 opp = DRA7_IVA_OPP;
Lokesh Vutla6cc96bc2017-04-20 14:07:52 +0530494 /*
495 * DRA71x does not support OPP_OD for IVA.
496 * If OPP_OD is selected by menuconfig, fallback
497 * to OPP_NOM.
498 */
499 if (board_is_dra71x_evm() && opp == OPP_OD)
500 opp = OPP_NOM;
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530501 break;
502 default:
503 opp = OPP_NOM;
504 }
505
506 return opp;
507}
508
Lokesh Vutla687054a2013-02-12 21:29:08 +0000509/**
510 * @brief board_init
511 *
512 * @return 0
513 */
514int board_init(void)
515{
516 gpmc_init();
517 gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
518
519 return 0;
520}
521
Simon Glass76b00ac2017-03-31 08:40:32 -0600522int dram_init_banksize(void)
Lokesh Vutlad468b172016-03-08 09:18:09 +0530523{
524 u64 ram_size;
525
526 ram_size = board_ti_get_emif_size();
527
528 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
529 gd->bd->bi_dram[0].size = get_effective_memsize();
530 if (ram_size > CONFIG_MAX_MEM_MAPPED) {
531 gd->bd->bi_dram[1].start = 0x200000000;
532 gd->bd->bi_dram[1].size = ram_size - CONFIG_MAX_MEM_MAPPED;
533 }
Simon Glass76b00ac2017-03-31 08:40:32 -0600534
535 return 0;
Lokesh Vutlad468b172016-03-08 09:18:09 +0530536}
537
Roger Quadros21914ee2013-11-11 16:56:44 +0200538int board_late_init(void)
539{
Lokesh Vutla4ec3f6e2014-07-14 19:57:58 +0530540#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
Lokesh Vutla25afe552016-03-08 09:18:05 +0530541 char *name = "unknown";
542
Lokesh Vutladf6b5062016-06-29 14:50:41 +0530543 if (is_dra72x()) {
544 if (board_is_dra72x_revc_or_later())
545 name = "dra72x-revc";
Lokesh Vutla463dd222016-11-23 13:25:24 +0530546 else if (board_is_dra71x_evm())
547 name = "dra71x";
Lokesh Vutladf6b5062016-06-29 14:50:41 +0530548 else
549 name = "dra72x";
550 } else {
Lokesh Vutla25afe552016-03-08 09:18:05 +0530551 name = "dra7xx";
Lokesh Vutladf6b5062016-06-29 14:50:41 +0530552 }
Lokesh Vutla25afe552016-03-08 09:18:05 +0530553
554 set_board_info_env(name);
Dileep Kattaf12467d2015-03-25 04:04:51 +0530555
Lokesh Vutla71c1b582016-11-29 11:58:01 +0530556 /*
557 * Default FIT boot on HS devices. Non FIT images are not allowed
558 * on HS devices.
559 */
560 if (get_device_type() == HS_DEVICE)
561 setenv("boot_fit", "1");
562
Paul Kocialkowski07815eb2015-08-27 19:37:12 +0200563 omap_die_id_serial();
Lokesh Vutla4ec3f6e2014-07-14 19:57:58 +0530564#endif
Roger Quadros21914ee2013-11-11 16:56:44 +0200565 return 0;
566}
567
Lokesh Vutla25afe552016-03-08 09:18:05 +0530568#ifdef CONFIG_SPL_BUILD
569void do_board_detect(void)
570{
571 int rc;
572
573 rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS,
574 CONFIG_EEPROM_CHIP_ADDRESS);
575 if (rc)
576 printf("ti_i2c_eeprom_init failed %d\n", rc);
577}
578
579#else
580
581void do_board_detect(void)
582{
583 char *bname = NULL;
584 int rc;
585
586 rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS,
587 CONFIG_EEPROM_CHIP_ADDRESS);
588 if (rc)
589 printf("ti_i2c_eeprom_init failed %d\n", rc);
590
591 if (board_is_dra74x_evm()) {
592 bname = "DRA74x EVM";
Ravi Babu6b1c14b2016-03-15 18:09:14 -0500593 } else if (board_is_dra72x_evm()) {
594 bname = "DRA72x EVM";
Lokesh Vutla463dd222016-11-23 13:25:24 +0530595 } else if (board_is_dra71x_evm()) {
596 bname = "DRA71x EVM";
Lokesh Vutla25afe552016-03-08 09:18:05 +0530597 } else {
Ravi Babu6b1c14b2016-03-15 18:09:14 -0500598 /* If EEPROM is not populated */
Lokesh Vutla25afe552016-03-08 09:18:05 +0530599 if (is_dra72x())
600 bname = "DRA72x EVM";
601 else
602 bname = "DRA74x EVM";
603 }
604
605 if (bname)
606 snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
607 "Board: %s REV %s\n", bname, board_ti_get_rev());
608}
609#endif /* CONFIG_SPL_BUILD */
610
Keerthy1428d832016-06-07 16:05:25 +0530611void vcores_init(void)
612{
613 if (board_is_dra74x_evm()) {
614 *omap_vcores = &dra752_volts;
615 } else if (board_is_dra72x_evm()) {
616 *omap_vcores = &dra722_volts;
Keerthyf56e6352016-11-23 13:25:27 +0530617 } else if (board_is_dra71x_evm()) {
618 *omap_vcores = &dra718_volts;
Keerthy1428d832016-06-07 16:05:25 +0530619 } else {
620 /* If EEPROM is not populated */
621 if (is_dra72x())
622 *omap_vcores = &dra722_volts;
623 else
624 *omap_vcores = &dra752_volts;
625 }
626}
627
Paul Kocialkowski3ef56e62016-02-27 19:18:56 +0100628void set_muxconf_regs(void)
Lokesh Vutla687054a2013-02-12 21:29:08 +0000629{
630 do_set_mux32((*ctrl)->control_padconf_core_base,
Lokesh Vutla706dd342015-06-04 16:42:38 +0530631 early_padconf, ARRAY_SIZE(early_padconf));
Lokesh Vutla687054a2013-02-12 21:29:08 +0000632}
633
Lokesh Vutla706dd342015-06-04 16:42:38 +0530634#ifdef CONFIG_IODELAY_RECALIBRATION
635void recalibrate_iodelay(void)
636{
Nishanth Menon8cac1472016-03-15 18:09:17 -0500637 struct pad_conf_entry const *pads, *delta_pads = NULL;
Nishanth Menon03589232015-08-13 09:50:59 -0500638 struct iodelay_cfg_entry const *iodelay;
Nishanth Menon8cac1472016-03-15 18:09:17 -0500639 int npads, niodelays, delta_npads = 0;
640 int ret;
Nishanth Menon03589232015-08-13 09:50:59 -0500641
642 switch (omap_revision()) {
643 case DRA722_ES1_0:
Nishanth Menon8cac1472016-03-15 18:09:17 -0500644 case DRA722_ES2_0:
645 pads = dra72x_core_padconf_array_common;
646 npads = ARRAY_SIZE(dra72x_core_padconf_array_common);
Lokesh Vutla4d748042016-11-23 13:25:25 +0530647 if (board_is_dra71x_evm()) {
648 pads = dra71x_core_padconf_array;
649 npads = ARRAY_SIZE(dra71x_core_padconf_array);
650 iodelay = dra71_iodelay_cfg_array;
651 niodelays = ARRAY_SIZE(dra71_iodelay_cfg_array);
652 } else if (board_is_dra72x_revc_or_later()) {
Nishanth Menon8cac1472016-03-15 18:09:17 -0500653 delta_pads = dra72x_rgmii_padconf_array_revc;
654 delta_npads =
655 ARRAY_SIZE(dra72x_rgmii_padconf_array_revc);
656 iodelay = dra72_iodelay_cfg_array_revc;
657 niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revc);
658 } else {
659 delta_pads = dra72x_rgmii_padconf_array_revb;
660 delta_npads =
661 ARRAY_SIZE(dra72x_rgmii_padconf_array_revb);
662 iodelay = dra72_iodelay_cfg_array_revb;
663 niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revb);
664 }
Nishanth Menon03589232015-08-13 09:50:59 -0500665 break;
666 case DRA752_ES1_0:
667 case DRA752_ES1_1:
668 pads = dra74x_core_padconf_array;
669 npads = ARRAY_SIZE(dra74x_core_padconf_array);
670 iodelay = dra742_es1_1_iodelay_cfg_array;
671 niodelays = ARRAY_SIZE(dra742_es1_1_iodelay_cfg_array);
672 break;
673 default:
674 case DRA752_ES2_0:
675 pads = dra74x_core_padconf_array;
676 npads = ARRAY_SIZE(dra74x_core_padconf_array);
677 iodelay = dra742_es2_0_iodelay_cfg_array;
678 niodelays = ARRAY_SIZE(dra742_es2_0_iodelay_cfg_array);
Nishanth Menon76cff2b2015-08-13 09:51:00 -0500679 /* Setup port1 and port2 for rgmii with 'no-id' mode */
680 clrset_spare_register(1, 0, RGMII2_ID_MODE_N_MASK |
681 RGMII1_ID_MODE_N_MASK);
Nishanth Menon03589232015-08-13 09:50:59 -0500682 break;
Nishanth Menon27d170a2015-06-04 16:42:39 +0530683 }
Nishanth Menon8cac1472016-03-15 18:09:17 -0500684 /* Setup I/O isolation */
685 ret = __recalibrate_iodelay_start();
686 if (ret)
687 goto err;
688
689 /* Do the muxing here */
690 do_set_mux32((*ctrl)->control_padconf_core_base, pads, npads);
691
692 /* Now do the weird minor deltas that should be safe */
693 if (delta_npads)
694 do_set_mux32((*ctrl)->control_padconf_core_base,
695 delta_pads, delta_npads);
696
697 /* Setup IOdelay configuration */
698 ret = do_set_iodelay((*ctrl)->iodelay_config_base, iodelay, niodelays);
699err:
700 /* Closeup.. remove isolation */
701 __recalibrate_iodelay_end(ret);
Lokesh Vutla706dd342015-06-04 16:42:38 +0530702}
703#endif
704
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900705#if defined(CONFIG_MMC)
Lokesh Vutla687054a2013-02-12 21:29:08 +0000706int board_mmc_init(bd_t *bis)
707{
708 omap_mmc_init(0, 0, 0, -1, -1);
709 omap_mmc_init(1, 0, 0, -1, -1);
710 return 0;
711}
712#endif
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530713
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530714#ifdef CONFIG_USB_DWC3
715static struct dwc3_device usb_otg_ss1 = {
716 .maximum_speed = USB_SPEED_SUPER,
717 .base = DRA7_USB_OTG_SS1_BASE,
718 .tx_fifo_resize = false,
719 .index = 0,
720};
721
722static struct dwc3_omap_device usb_otg_ss1_glue = {
723 .base = (void *)DRA7_USB_OTG_SS1_GLUE_BASE,
724 .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530725 .index = 0,
726};
727
728static struct ti_usb_phy_device usb_phy1_device = {
729 .pll_ctrl_base = (void *)DRA7_USB3_PHY1_PLL_CTRL,
730 .usb2_phy_power = (void *)DRA7_USB2_PHY1_POWER,
731 .usb3_phy_power = (void *)DRA7_USB3_PHY1_POWER,
732 .index = 0,
733};
734
735static struct dwc3_device usb_otg_ss2 = {
736 .maximum_speed = USB_SPEED_SUPER,
737 .base = DRA7_USB_OTG_SS2_BASE,
738 .tx_fifo_resize = false,
739 .index = 1,
740};
741
742static struct dwc3_omap_device usb_otg_ss2_glue = {
743 .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE,
744 .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530745 .index = 1,
746};
747
748static struct ti_usb_phy_device usb_phy2_device = {
749 .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER,
750 .index = 1,
751};
752
Uri Mashiach1a9a5f72017-02-23 15:39:37 +0200753int omap_xhci_board_usb_init(int index, enum usb_init_type init)
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530754{
Kishon Vijay Abraham I6f1af1e2015-08-19 16:16:27 +0530755 enable_usb_clocks(index);
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530756 switch (index) {
757 case 0:
758 if (init == USB_INIT_DEVICE) {
759 usb_otg_ss1.dr_mode = USB_DR_MODE_PERIPHERAL;
760 usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
761 } else {
762 usb_otg_ss1.dr_mode = USB_DR_MODE_HOST;
763 usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_ID_GROUND;
764 }
765
766 ti_usb_phy_uboot_init(&usb_phy1_device);
767 dwc3_omap_uboot_init(&usb_otg_ss1_glue);
768 dwc3_uboot_init(&usb_otg_ss1);
769 break;
770 case 1:
771 if (init == USB_INIT_DEVICE) {
772 usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL;
773 usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
774 } else {
775 usb_otg_ss2.dr_mode = USB_DR_MODE_HOST;
776 usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_ID_GROUND;
777 }
778
779 ti_usb_phy_uboot_init(&usb_phy2_device);
780 dwc3_omap_uboot_init(&usb_otg_ss2_glue);
781 dwc3_uboot_init(&usb_otg_ss2);
782 break;
783 default:
784 printf("Invalid Controller Index\n");
785 }
786
787 return 0;
788}
789
Uri Mashiach1a9a5f72017-02-23 15:39:37 +0200790int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530791{
792 switch (index) {
793 case 0:
794 case 1:
795 ti_usb_phy_uboot_exit(index);
796 dwc3_uboot_exit(index);
797 dwc3_omap_uboot_exit(index);
798 break;
799 default:
800 printf("Invalid Controller Index\n");
801 }
Kishon Vijay Abraham I6f1af1e2015-08-19 16:16:27 +0530802 disable_usb_clocks(index);
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530803 return 0;
804}
805
Kishon Vijay Abraham I2d48aa62015-02-23 18:40:23 +0530806int usb_gadget_handle_interrupts(int index)
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530807{
808 u32 status;
809
Kishon Vijay Abraham I2d48aa62015-02-23 18:40:23 +0530810 status = dwc3_omap_uboot_interrupt_status(index);
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530811 if (status)
Kishon Vijay Abraham I2d48aa62015-02-23 18:40:23 +0530812 dwc3_uboot_handle_interrupt(index);
Kishon Vijay Abraham Ia17188c2015-02-23 18:40:19 +0530813
814 return 0;
815}
816#endif
817
Tom Rini79b079f2014-04-03 07:52:56 -0400818#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
819int spl_start_uboot(void)
820{
821 /* break into full u-boot on 'c' */
822 if (serial_tstc() && serial_getc() == 'c')
823 return 1;
824
825#ifdef CONFIG_SPL_ENV_SUPPORT
826 env_init();
827 env_relocate_spec();
828 if (getenv_yesno("boot_os") != 1)
829 return 1;
830#endif
831
832 return 0;
833}
834#endif
835
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530836#ifdef CONFIG_DRIVER_TI_CPSW
Mugunthan V N4c8014b2014-05-22 14:37:12 +0530837extern u32 *const omap_si_rev;
838
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530839static void cpsw_control(int enabled)
840{
841 /* VTP can be added here */
842
843 return;
844}
845
846static struct cpsw_slave_data cpsw_slaves[] = {
847 {
848 .slave_reg_ofs = 0x208,
849 .sliver_reg_ofs = 0xd80,
Mugunthan V N9c653aa2014-02-18 07:31:52 -0500850 .phy_addr = 2,
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530851 },
852 {
853 .slave_reg_ofs = 0x308,
854 .sliver_reg_ofs = 0xdc0,
Mugunthan V N9c653aa2014-02-18 07:31:52 -0500855 .phy_addr = 3,
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530856 },
857};
858
859static struct cpsw_platform_data cpsw_data = {
860 .mdio_base = CPSW_MDIO_BASE,
861 .cpsw_base = CPSW_BASE,
862 .mdio_div = 0xff,
863 .channels = 8,
864 .cpdma_reg_ofs = 0x800,
Mugunthan V N4c8014b2014-05-22 14:37:12 +0530865 .slaves = 2,
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530866 .slave_data = cpsw_slaves,
867 .ale_reg_ofs = 0xd00,
868 .ale_entries = 1024,
869 .host_port_reg_ofs = 0x108,
870 .hw_stats_reg_ofs = 0x900,
871 .bd_ram_ofs = 0x2000,
872 .mac_control = (1 << 5),
873 .control = cpsw_control,
874 .host_port_num = 0,
875 .version = CPSW_CTRL_VERSION_2,
876};
877
878int board_eth_init(bd_t *bis)
879{
880 int ret;
881 uint8_t mac_addr[6];
882 uint32_t mac_hi, mac_lo;
883 uint32_t ctrl_val;
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530884
885 /* try reading mac address from efuse */
886 mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
887 mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
Mugunthan V Ne0a1d592014-01-07 19:57:38 +0530888 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530889 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
Mugunthan V Ne0a1d592014-01-07 19:57:38 +0530890 mac_addr[2] = mac_hi & 0xFF;
891 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530892 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
Mugunthan V Ne0a1d592014-01-07 19:57:38 +0530893 mac_addr[5] = mac_lo & 0xFF;
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530894
895 if (!getenv("ethaddr")) {
896 printf("<ethaddr> not set. Validating first E-fuse MAC\n");
897
Joe Hershberger0adb5b72015-04-08 01:41:04 -0500898 if (is_valid_ethaddr(mac_addr))
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530899 eth_setenv_enetaddr("ethaddr", mac_addr);
900 }
Mugunthan V N8feb37b2014-02-18 07:31:56 -0500901
902 mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
903 mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
904 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
905 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
906 mac_addr[2] = mac_hi & 0xFF;
907 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
908 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
909 mac_addr[5] = mac_lo & 0xFF;
910
911 if (!getenv("eth1addr")) {
Joe Hershberger0adb5b72015-04-08 01:41:04 -0500912 if (is_valid_ethaddr(mac_addr))
Mugunthan V N8feb37b2014-02-18 07:31:56 -0500913 eth_setenv_enetaddr("eth1addr", mac_addr);
914 }
915
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530916 ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
917 ctrl_val |= 0x22;
918 writel(ctrl_val, (*ctrl)->control_core_control_io1);
919
Mugunthan V N4c8014b2014-05-22 14:37:12 +0530920 if (*omap_si_rev == DRA722_ES1_0)
921 cpsw_data.active_slave = 1;
922
Dan Murphy39fbac92016-03-30 12:58:37 -0500923 if (board_is_dra72x_revc_or_later()) {
924 cpsw_slaves[0].phy_if = PHY_INTERFACE_MODE_RGMII_ID;
925 cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_RGMII_ID;
926 }
927
Mugunthan V Nb1e26e32013-07-08 16:04:41 +0530928 ret = cpsw_register(&cpsw_data);
929 if (ret < 0)
930 printf("Error %d registering CPSW switch\n", ret);
931
932 return ret;
933}
934#endif
Lokesh Vutla7b922522014-08-04 19:42:24 +0530935
936#ifdef CONFIG_BOARD_EARLY_INIT_F
937/* VTT regulator enable */
938static inline void vtt_regulator_enable(void)
939{
940 if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
941 return;
942
943 /* Do not enable VTT for DRA722 */
Ravi Babu6b1c14b2016-03-15 18:09:14 -0500944 if (is_dra72x())
Lokesh Vutla7b922522014-08-04 19:42:24 +0530945 return;
946
947 /*
948 * EVM Rev G and later use gpio7_11 for DDR3 termination.
949 * This is safe enough to do on older revs.
950 */
951 gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
952 gpio_direction_output(GPIO_DDR_VTT_EN, 1);
953}
954
955int board_early_init_f(void)
956{
957 vtt_regulator_enable();
958 return 0;
959}
960#endif
Daniel Allred62a09f02016-05-19 19:10:54 -0500961
962#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
963int ft_board_setup(void *blob, bd_t *bd)
964{
965 ft_cpu_setup(blob, bd);
966
967 return 0;
968}
969#endif
Lokesh Vutla09da87d2016-05-16 10:51:23 +0530970
971#ifdef CONFIG_SPL_LOAD_FIT
972int board_fit_config_name_match(const char *name)
973{
Mugunthan V Ne8131382016-09-27 13:01:41 +0530974 if (is_dra72x()) {
Lokesh Vutla40de70f2016-11-23 13:25:30 +0530975 if (board_is_dra71x_evm()) {
976 if (!strcmp(name, "dra71-evm"))
977 return 0;
978 }else if(board_is_dra72x_revc_or_later()) {
Mugunthan V Ne8131382016-09-27 13:01:41 +0530979 if (!strcmp(name, "dra72-evm-revc"))
980 return 0;
981 } else if (!strcmp(name, "dra72-evm")) {
982 return 0;
983 }
984 } else if (!is_dra72x() && !strcmp(name, "dra7-evm")) {
Lokesh Vutla09da87d2016-05-16 10:51:23 +0530985 return 0;
Mugunthan V Ne8131382016-09-27 13:01:41 +0530986 }
987
988 return -1;
Lokesh Vutla09da87d2016-05-16 10:51:23 +0530989}
990#endif
Andreas Dannenberg17c29872016-06-27 09:19:22 -0500991
992#ifdef CONFIG_TI_SECURE_DEVICE
993void board_fit_image_post_process(void **p_image, size_t *p_size)
994{
995 secure_boot_verify_image(p_image, p_size);
996}
Andrew F. Davis0fcc52072016-11-29 16:33:25 -0600997
998void board_tee_image_process(ulong tee_image, size_t tee_size)
999{
1000 secure_tee_install((u32)tee_image);
1001}
1002
1003U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
Andreas Dannenberg17c29872016-06-27 09:19:22 -05001004#endif