blob: a8a216d034a45de85ce5b96d731ad34b290ab2e5 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Lokesh Vutla40700ad2013-02-12 21:29:08 +00002/*
3 * (C) Copyright 2013
4 * Texas Instruments Incorporated, <www.ti.com>
5 *
6 * Lokesh Vutla <lokeshvutla@ti.com>
7 *
8 * Based on previous work by:
9 * Aneesh V <aneesh@ti.com>
10 * Steve Sakoman <steve@sakoman.com>
Lokesh Vutla40700ad2013-02-12 21:29:08 +000011 */
12#include <common.h>
Simon Glass79fd2142019-08-01 09:46:43 -060013#include <env.h>
Simon Glass3bbe70c2019-12-28 10:44:54 -070014#include <fdt_support.h>
Roman Kovalivskyi1bb13422020-07-28 23:35:32 +030015#include <fastboot.h>
Simon Glassa7b51302019-11-14 12:57:46 -070016#include <init.h>
Grygorii Strashko52168f82019-11-22 19:26:17 +020017#include <spl.h>
Simon Glass274e0b02020-05-10 11:39:56 -060018#include <net.h>
Nishanth Menon627612c2013-03-26 05:20:54 +000019#include <palmas.h>
Dan Murphy57f29ab2014-02-03 06:59:02 -060020#include <sata.h>
Simon Glass36736182019-11-14 12:57:24 -070021#include <serial.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060022#include <asm/global_data.h>
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053023#include <linux/string.h>
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +053024#include <asm/gpio.h>
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +053025#include <usb.h>
26#include <linux/usb/gadget.h>
Andreas Dannenberg5cf344b2016-06-27 09:19:22 -050027#include <asm/omap_common.h>
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +053028#include <asm/arch/gpio.h>
Lokesh Vutla1fd80222015-06-04 16:42:38 +053029#include <asm/arch/dra7xx_iodelay.h>
Lokesh Vutla41963ee2016-03-08 09:18:06 +053030#include <asm/emif.h>
Lokesh Vutla40700ad2013-02-12 21:29:08 +000031#include <asm/arch/sys_proto.h>
32#include <asm/arch/mmc_host_def.h>
Roger Quadrosf019ee82013-11-11 16:56:44 +020033#include <asm/arch/sata.h>
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +053034#include <dwc3-uboot.h>
35#include <dwc3-omap-uboot.h>
Franklin S Cooper Jr236fca82019-02-27 13:29:36 +053036#include <i2c.h>
Kishon Vijay Abraham Ice61fd72015-02-23 18:40:19 +053037#include <ti-usb-phy-uboot.h>
Lokesh Vutla40700ad2013-02-12 21:29:08 +000038
39#include "mux_data.h"
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053040#include "../common/board_detect.h"
41
Lokesh Vutla13376132017-08-21 12:50:53 +053042#define board_is_dra76x_evm() board_ti_is("DRA76/7x")
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053043#define board_is_dra74x_evm() board_ti_is("5777xCPU")
Ravi Babue1031082016-03-15 18:09:14 -050044#define board_is_dra72x_evm() board_ti_is("DRA72x-T")
Lokesh Vutlab9d8f8e2016-11-23 13:25:24 +053045#define board_is_dra71x_evm() board_ti_is("DRA79x,D")
Mugunthan V N3a7f10c2016-09-27 13:01:42 +053046#define board_is_dra74x_revh_or_later() (board_is_dra74x_evm() && \
47 (strncmp("H", board_ti_get_rev(), 1) <= 0))
48#define board_is_dra72x_revc_or_later() (board_is_dra72x_evm() && \
49 (strncmp("C", board_ti_get_rev(), 1) <= 0))
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +053050#define board_ti_get_emif_size() board_ti_get_emif1_size() + \
51 board_ti_get_emif2_size()
Lokesh Vutla40700ad2013-02-12 21:29:08 +000052
Lokesh Vutla40700ad2013-02-12 21:29:08 +000053DECLARE_GLOBAL_DATA_PTR;
54
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +053055/* GPIO 7_11 */
56#define GPIO_DDR_VTT_EN 203
57
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053058#define SYSINFO_BOARD_NAME_MAX_LEN 37
59
Franklin S Cooper Jr236fca82019-02-27 13:29:36 +053060/* I2C I/O Expander */
61#define NAND_PCF8575_ADDR 0x21
62#define NAND_PCF8575_I2C_BUS_NUM 0
63
Lokesh Vutla40700ad2013-02-12 21:29:08 +000064const struct omap_sysinfo sysinfo = {
Lokesh Vutla3c7dc012016-03-08 09:18:05 +053065 "Board: UNKNOWN(DRA7 EVM) REV UNKNOWN\n"
Lokesh Vutla40700ad2013-02-12 21:29:08 +000066};
67
Lokesh Vutla41963ee2016-03-08 09:18:06 +053068static const struct emif_regs emif1_ddr3_532_mhz_1cs = {
69 .sdram_config_init = 0x61851ab2,
70 .sdram_config = 0x61851ab2,
71 .sdram_config2 = 0x08000000,
72 .ref_ctrl = 0x000040F1,
73 .ref_ctrl_final = 0x00001035,
74 .sdram_tim1 = 0xCCCF36B3,
75 .sdram_tim2 = 0x308F7FDA,
76 .sdram_tim3 = 0x427F88A8,
77 .read_idle_ctrl = 0x00050000,
78 .zq_config = 0x0007190B,
79 .temp_alert_config = 0x00000000,
80 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
81 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
82 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
83 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
84 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
85 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
86 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
87 .emif_rd_wr_lvl_rmp_win = 0x00000000,
88 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
89 .emif_rd_wr_lvl_ctl = 0x00000000,
90 .emif_rd_wr_exec_thresh = 0x00000305
91};
92
93static const struct emif_regs emif2_ddr3_532_mhz_1cs = {
94 .sdram_config_init = 0x61851B32,
95 .sdram_config = 0x61851B32,
96 .sdram_config2 = 0x08000000,
97 .ref_ctrl = 0x000040F1,
98 .ref_ctrl_final = 0x00001035,
99 .sdram_tim1 = 0xCCCF36B3,
100 .sdram_tim2 = 0x308F7FDA,
101 .sdram_tim3 = 0x427F88A8,
102 .read_idle_ctrl = 0x00050000,
103 .zq_config = 0x0007190B,
104 .temp_alert_config = 0x00000000,
105 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
106 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
107 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
108 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
109 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
110 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
111 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
112 .emif_rd_wr_lvl_rmp_win = 0x00000000,
113 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
114 .emif_rd_wr_lvl_ctl = 0x00000000,
115 .emif_rd_wr_exec_thresh = 0x00000305
116};
117
118static const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es1 = {
119 .sdram_config_init = 0x61862B32,
120 .sdram_config = 0x61862B32,
121 .sdram_config2 = 0x08000000,
122 .ref_ctrl = 0x0000514C,
123 .ref_ctrl_final = 0x0000144A,
124 .sdram_tim1 = 0xD113781C,
125 .sdram_tim2 = 0x30717FE3,
126 .sdram_tim3 = 0x409F86A8,
127 .read_idle_ctrl = 0x00050000,
128 .zq_config = 0x5007190B,
129 .temp_alert_config = 0x00000000,
130 .emif_ddr_phy_ctlr_1_init = 0x0024400D,
131 .emif_ddr_phy_ctlr_1 = 0x0E24400D,
132 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
133 .emif_ddr_ext_phy_ctrl_2 = 0x00A400A4,
134 .emif_ddr_ext_phy_ctrl_3 = 0x00A900A9,
135 .emif_ddr_ext_phy_ctrl_4 = 0x00B000B0,
136 .emif_ddr_ext_phy_ctrl_5 = 0x00B000B0,
137 .emif_rd_wr_lvl_rmp_win = 0x00000000,
138 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
139 .emif_rd_wr_lvl_ctl = 0x00000000,
140 .emif_rd_wr_exec_thresh = 0x00000305
141};
142
Ravi Babue1031082016-03-15 18:09:14 -0500143const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es2 = {
144 .sdram_config_init = 0x61862BB2,
145 .sdram_config = 0x61862BB2,
146 .sdram_config2 = 0x00000000,
147 .ref_ctrl = 0x0000514D,
148 .ref_ctrl_final = 0x0000144A,
149 .sdram_tim1 = 0xD1137824,
150 .sdram_tim2 = 0x30B37FE3,
151 .sdram_tim3 = 0x409F8AD8,
152 .read_idle_ctrl = 0x00050000,
153 .zq_config = 0x5007190B,
154 .temp_alert_config = 0x00000000,
155 .emif_ddr_phy_ctlr_1_init = 0x0824400E,
156 .emif_ddr_phy_ctlr_1 = 0x0E24400E,
157 .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
158 .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
159 .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
160 .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
161 .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
162 .emif_rd_wr_lvl_rmp_win = 0x00000000,
163 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
164 .emif_rd_wr_lvl_ctl = 0x00000000,
165 .emif_rd_wr_exec_thresh = 0x00000305
166};
167
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530168const struct emif_regs emif1_ddr3_532_mhz_1cs_2G = {
169 .sdram_config_init = 0x61851ab2,
170 .sdram_config = 0x61851ab2,
171 .sdram_config2 = 0x08000000,
172 .ref_ctrl = 0x000040F1,
173 .ref_ctrl_final = 0x00001035,
174 .sdram_tim1 = 0xCCCF36B3,
175 .sdram_tim2 = 0x30BF7FDA,
176 .sdram_tim3 = 0x427F8BA8,
177 .read_idle_ctrl = 0x00050000,
178 .zq_config = 0x0007190B,
179 .temp_alert_config = 0x00000000,
180 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
181 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
182 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
183 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
184 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
185 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
186 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
187 .emif_rd_wr_lvl_rmp_win = 0x00000000,
188 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
189 .emif_rd_wr_lvl_ctl = 0x00000000,
190 .emif_rd_wr_exec_thresh = 0x00000305
191};
192
193const struct emif_regs emif2_ddr3_532_mhz_1cs_2G = {
194 .sdram_config_init = 0x61851B32,
195 .sdram_config = 0x61851B32,
196 .sdram_config2 = 0x08000000,
197 .ref_ctrl = 0x000040F1,
198 .ref_ctrl_final = 0x00001035,
199 .sdram_tim1 = 0xCCCF36B3,
200 .sdram_tim2 = 0x308F7FDA,
201 .sdram_tim3 = 0x427F88A8,
202 .read_idle_ctrl = 0x00050000,
203 .zq_config = 0x0007190B,
204 .temp_alert_config = 0x00000000,
205 .emif_ddr_phy_ctlr_1_init = 0x0024400B,
206 .emif_ddr_phy_ctlr_1 = 0x0E24400B,
207 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
208 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
209 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
210 .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
211 .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
212 .emif_rd_wr_lvl_rmp_win = 0x00000000,
213 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
214 .emif_rd_wr_lvl_ctl = 0x00000000,
215 .emif_rd_wr_exec_thresh = 0x00000305
216};
217
Lokesh Vutla6f1038f2017-08-21 12:50:55 +0530218const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra76 = {
219 .sdram_config_init = 0x61862B32,
220 .sdram_config = 0x61862B32,
221 .sdram_config2 = 0x00000000,
222 .ref_ctrl = 0x0000514C,
223 .ref_ctrl_final = 0x0000144A,
224 .sdram_tim1 = 0xD113783C,
225 .sdram_tim2 = 0x30B47FE3,
226 .sdram_tim3 = 0x409F8AD8,
227 .read_idle_ctrl = 0x00050000,
228 .zq_config = 0x5007190B,
229 .temp_alert_config = 0x00000000,
230 .emif_ddr_phy_ctlr_1_init = 0x0824400D,
231 .emif_ddr_phy_ctlr_1 = 0x0E24400D,
232 .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
233 .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
234 .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
235 .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
236 .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
237 .emif_rd_wr_lvl_rmp_win = 0x00000000,
238 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
239 .emif_rd_wr_lvl_ctl = 0x00000000,
240 .emif_rd_wr_exec_thresh = 0x00000305
241};
242
243const struct emif_regs emif_2_regs_ddr3_666_mhz_1cs_dra76 = {
244 .sdram_config_init = 0x61862B32,
245 .sdram_config = 0x61862B32,
246 .sdram_config2 = 0x00000000,
247 .ref_ctrl = 0x0000514C,
248 .ref_ctrl_final = 0x0000144A,
249 .sdram_tim1 = 0xD113781C,
250 .sdram_tim2 = 0x30B47FE3,
251 .sdram_tim3 = 0x409F8AD8,
252 .read_idle_ctrl = 0x00050000,
253 .zq_config = 0x5007190B,
254 .temp_alert_config = 0x00000000,
255 .emif_ddr_phy_ctlr_1_init = 0x0824400D,
256 .emif_ddr_phy_ctlr_1 = 0x0E24400D,
257 .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
258 .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
259 .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
260 .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
261 .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
262 .emif_rd_wr_lvl_rmp_win = 0x00000000,
263 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
264 .emif_rd_wr_lvl_ctl = 0x00000000,
265 .emif_rd_wr_exec_thresh = 0x00000305
266};
267
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530268void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
269{
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530270 u64 ram_size;
271
272 ram_size = board_ti_get_emif_size();
273
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530274 switch (omap_revision()) {
275 case DRA752_ES1_0:
276 case DRA752_ES1_1:
277 case DRA752_ES2_0:
278 switch (emif_nr) {
279 case 1:
Tom Rinibc9d46b2022-12-04 10:04:50 -0500280 if (ram_size > CFG_MAX_MEM_MAPPED)
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530281 *regs = &emif1_ddr3_532_mhz_1cs_2G;
282 else
283 *regs = &emif1_ddr3_532_mhz_1cs;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530284 break;
285 case 2:
Tom Rinibc9d46b2022-12-04 10:04:50 -0500286 if (ram_size > CFG_MAX_MEM_MAPPED)
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530287 *regs = &emif2_ddr3_532_mhz_1cs_2G;
288 else
289 *regs = &emif2_ddr3_532_mhz_1cs;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530290 break;
291 }
292 break;
Lokesh Vutla69483e62017-12-29 11:47:51 +0530293 case DRA762_ABZ_ES1_0:
294 case DRA762_ACD_ES1_0:
Lokesh Vutla6f1038f2017-08-21 12:50:55 +0530295 case DRA762_ES1_0:
296 if (emif_nr == 1)
297 *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra76;
298 else
299 *regs = &emif_2_regs_ddr3_666_mhz_1cs_dra76;
300 break;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530301 case DRA722_ES1_0:
Ravi Babue1031082016-03-15 18:09:14 -0500302 case DRA722_ES2_0:
Vishal Mahaveer42d25eb2017-08-26 16:51:22 -0500303 case DRA722_ES2_1:
Tom Rinibc9d46b2022-12-04 10:04:50 -0500304 if (ram_size < CFG_MAX_MEM_MAPPED)
Ravi Babue1031082016-03-15 18:09:14 -0500305 *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es1;
306 else
307 *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es2;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530308 break;
309 default:
310 *regs = &emif1_ddr3_532_mhz_1cs;
311 }
312}
313
314static const struct dmm_lisa_map_regs lisa_map_dra7_1536MB = {
315 .dmm_lisa_map_0 = 0x0,
316 .dmm_lisa_map_1 = 0x80640300,
317 .dmm_lisa_map_2 = 0xC0500220,
318 .dmm_lisa_map_3 = 0xFF020100,
319 .is_ma_present = 0x1
320};
321
322static const struct dmm_lisa_map_regs lisa_map_2G_x_2 = {
323 .dmm_lisa_map_0 = 0x0,
324 .dmm_lisa_map_1 = 0x0,
325 .dmm_lisa_map_2 = 0x80600100,
326 .dmm_lisa_map_3 = 0xFF020100,
327 .is_ma_present = 0x1
328};
329
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530330const struct dmm_lisa_map_regs lisa_map_dra7_2GB = {
331 .dmm_lisa_map_0 = 0x0,
332 .dmm_lisa_map_1 = 0x0,
333 .dmm_lisa_map_2 = 0x80740300,
334 .dmm_lisa_map_3 = 0xFF020100,
335 .is_ma_present = 0x1
336};
337
Ravi Babue1031082016-03-15 18:09:14 -0500338/*
339 * DRA722 EVM EMIF1 2GB CONFIGURATION
340 * EMIF1 4 devices of 512Mb x 8 Micron
341 */
342const struct dmm_lisa_map_regs lisa_map_2G_x_4 = {
343 .dmm_lisa_map_0 = 0x0,
344 .dmm_lisa_map_1 = 0x0,
345 .dmm_lisa_map_2 = 0x80700100,
346 .dmm_lisa_map_3 = 0xFF020100,
347 .is_ma_present = 0x1
348};
349
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530350void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
351{
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530352 u64 ram_size;
353
354 ram_size = board_ti_get_emif_size();
355
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530356 switch (omap_revision()) {
Lokesh Vutla69483e62017-12-29 11:47:51 +0530357 case DRA762_ABZ_ES1_0:
358 case DRA762_ACD_ES1_0:
Lokesh Vutla6f1038f2017-08-21 12:50:55 +0530359 case DRA762_ES1_0:
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530360 case DRA752_ES1_0:
361 case DRA752_ES1_1:
362 case DRA752_ES2_0:
Tom Rinibc9d46b2022-12-04 10:04:50 -0500363 if (ram_size > CFG_MAX_MEM_MAPPED)
Lokesh Vutlab85fbcd2016-03-08 09:18:08 +0530364 *dmm_lisa_regs = &lisa_map_dra7_2GB;
365 else
366 *dmm_lisa_regs = &lisa_map_dra7_1536MB;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530367 break;
368 case DRA722_ES1_0:
Ravi Babue1031082016-03-15 18:09:14 -0500369 case DRA722_ES2_0:
Vishal Mahaveer42d25eb2017-08-26 16:51:22 -0500370 case DRA722_ES2_1:
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530371 default:
Tom Rinibc9d46b2022-12-04 10:04:50 -0500372 if (ram_size < CFG_MAX_MEM_MAPPED)
Ravi Babue1031082016-03-15 18:09:14 -0500373 *dmm_lisa_regs = &lisa_map_2G_x_2;
374 else
375 *dmm_lisa_regs = &lisa_map_2G_x_4;
376 break;
Lokesh Vutla41963ee2016-03-08 09:18:06 +0530377 }
378}
379
Keerthyc8056232016-06-07 16:05:25 +0530380struct vcores_data dra752_volts = {
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530381 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
382 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
Keerthyc8056232016-06-07 16:05:25 +0530383 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
384 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
385 .mpu.pmic = &tps659038,
386 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
387
Lokesh Vutla6ede0fd2016-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,
Keerthyc8056232016-06-07 16:05:25 +0530394 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
395 .eve.addr = TPS659038_REG_ADDR_SMPS45,
396 .eve.pmic = &tps659038,
397 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
398
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530399 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
400 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
401 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
402 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
403 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
404 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530405 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
406 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
407 .gpu.pmic = &tps659038,
408 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
409
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530410 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
411 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
Keerthyc8056232016-06-07 16:05:25 +0530412 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
413 .core.addr = TPS659038_REG_ADDR_SMPS7,
414 .core.pmic = &tps659038,
415
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530416 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
417 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
418 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
419 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
420 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
421 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530422 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
423 .iva.addr = TPS659038_REG_ADDR_SMPS8,
424 .iva.pmic = &tps659038,
425 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
426};
427
Keerthy1b21f552017-08-21 12:50:54 +0530428struct vcores_data dra76x_volts = {
429 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
430 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
431 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
432 .mpu.addr = LP87565_REG_ADDR_BUCK01,
433 .mpu.pmic = &lp87565,
434 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
435
436 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
437 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
438 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
439 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
440 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
441 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
442 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
443 .eve.addr = TPS65917_REG_ADDR_SMPS1,
444 .eve.pmic = &tps659038,
445 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
446
447 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
448 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
449 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
450 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
451 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
452 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
453 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
454 .gpu.addr = LP87565_REG_ADDR_BUCK23,
455 .gpu.pmic = &lp87565,
456 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
457
458 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
459 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
460 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
461 .core.addr = TPS65917_REG_ADDR_SMPS3,
462 .core.pmic = &tps659038,
463
464 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
465 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
466 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
467 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
468 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
469 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
470 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
471 .iva.addr = TPS65917_REG_ADDR_SMPS4,
472 .iva.pmic = &tps659038,
473 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
474};
475
Keerthyc8056232016-06-07 16:05:25 +0530476struct vcores_data dra722_volts = {
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530477 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
478 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
Keerthyc8056232016-06-07 16:05:25 +0530479 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
480 .mpu.addr = TPS65917_REG_ADDR_SMPS1,
481 .mpu.pmic = &tps659038,
482 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
483
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530484 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
485 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
Keerthyc8056232016-06-07 16:05:25 +0530486 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
487 .core.addr = TPS65917_REG_ADDR_SMPS2,
488 .core.pmic = &tps659038,
489
490 /*
491 * The DSPEVE, GPU and IVA rails are usually grouped on DRA72x
492 * designs and powered by TPS65917 SMPS3, as on the J6Eco EVM.
493 */
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530494 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
495 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
496 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
497 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
498 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
499 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530500 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
501 .gpu.addr = TPS65917_REG_ADDR_SMPS3,
502 .gpu.pmic = &tps659038,
503 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
504
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530505 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
506 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
507 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
508 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
509 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
510 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530511 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
512 .eve.addr = TPS65917_REG_ADDR_SMPS3,
513 .eve.pmic = &tps659038,
514 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
515
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530516 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
517 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
518 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
519 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
520 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
521 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthyc8056232016-06-07 16:05:25 +0530522 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
523 .iva.addr = TPS65917_REG_ADDR_SMPS3,
524 .iva.pmic = &tps659038,
525 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
526};
527
Keerthy4d4e34b2016-11-23 13:25:27 +0530528struct vcores_data dra718_volts = {
529 /*
530 * In the case of dra71x GPU MPU and CORE
531 * are all powered up by BUCK0 of LP873X PMIC
532 */
533 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
534 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
535 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
536 .mpu.addr = LP873X_REG_ADDR_BUCK0,
537 .mpu.pmic = &lp8733,
538 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
539
540 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
541 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
542 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
543 .core.addr = LP873X_REG_ADDR_BUCK0,
544 .core.pmic = &lp8733,
545
546 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
547 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
548 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
549 .gpu.addr = LP873X_REG_ADDR_BUCK0,
550 .gpu.pmic = &lp8733,
551 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
552
553 /*
554 * The DSPEVE and IVA rails are grouped on DRA71x-evm
555 * and are powered by BUCK1 of LP873X PMIC
556 */
557 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
Lokesh Vutlacae84282017-04-20 14:07:52 +0530558 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
Keerthy4d4e34b2016-11-23 13:25:27 +0530559 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
Lokesh Vutlacae84282017-04-20 14:07:52 +0530560 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Keerthy4d4e34b2016-11-23 13:25:27 +0530561 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
562 .eve.addr = LP873X_REG_ADDR_BUCK1,
563 .eve.pmic = &lp8733,
564 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
565
566 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
Lokesh Vutlacae84282017-04-20 14:07:52 +0530567 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
Keerthy4d4e34b2016-11-23 13:25:27 +0530568 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
Lokesh Vutlacae84282017-04-20 14:07:52 +0530569 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthy4d4e34b2016-11-23 13:25:27 +0530570 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
571 .iva.addr = LP873X_REG_ADDR_BUCK1,
572 .iva.pmic = &lp8733,
573 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
574};
575
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530576int get_voltrail_opp(int rail_offset)
577{
578 int opp;
579
580 switch (rail_offset) {
581 case VOLT_MPU:
582 opp = DRA7_MPU_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530583 /* DRA71x supports only OPP_NOM for MPU */
584 if (board_is_dra71x_evm())
585 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530586 break;
587 case VOLT_CORE:
588 opp = DRA7_CORE_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530589 /* DRA71x supports only OPP_NOM for CORE */
590 if (board_is_dra71x_evm())
591 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530592 break;
593 case VOLT_GPU:
594 opp = DRA7_GPU_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530595 /* DRA71x supports only OPP_NOM for GPU */
596 if (board_is_dra71x_evm())
597 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530598 break;
599 case VOLT_EVE:
600 opp = DRA7_DSPEVE_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530601 /*
602 * DRA71x does not support OPP_OD for EVE.
603 * If OPP_OD is selected by menuconfig, fallback
604 * to OPP_NOM.
605 */
606 if (board_is_dra71x_evm() && opp == OPP_OD)
607 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530608 break;
609 case VOLT_IVA:
610 opp = DRA7_IVA_OPP;
Lokesh Vutlacae84282017-04-20 14:07:52 +0530611 /*
612 * DRA71x does not support OPP_OD for IVA.
613 * If OPP_OD is selected by menuconfig, fallback
614 * to OPP_NOM.
615 */
616 if (board_is_dra71x_evm() && opp == OPP_OD)
617 opp = OPP_NOM;
Lokesh Vutla6ede0fd2016-11-23 12:54:39 +0530618 break;
619 default:
620 opp = OPP_NOM;
621 }
622
623 return opp;
624}
625
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000626/**
627 * @brief board_init
628 *
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100629 * Return: 0
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000630 */
631int board_init(void)
632{
633 gpmc_init();
634 gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
635
636 return 0;
637}
638
Simon Glass2f949c32017-03-31 08:40:32 -0600639int dram_init_banksize(void)
Lokesh Vutla0deb3332016-03-08 09:18:09 +0530640{
641 u64 ram_size;
642
643 ram_size = board_ti_get_emif_size();
644
Tom Rinibb4dd962022-11-16 13:10:37 -0500645 gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE;
Lokesh Vutla0deb3332016-03-08 09:18:09 +0530646 gd->bd->bi_dram[0].size = get_effective_memsize();
Tom Rinibc9d46b2022-12-04 10:04:50 -0500647 if (ram_size > CFG_MAX_MEM_MAPPED) {
Lokesh Vutla0deb3332016-03-08 09:18:09 +0530648 gd->bd->bi_dram[1].start = 0x200000000;
Tom Rinibc9d46b2022-12-04 10:04:50 -0500649 gd->bd->bi_dram[1].size = ram_size - CFG_MAX_MEM_MAPPED;
Lokesh Vutla0deb3332016-03-08 09:18:09 +0530650 }
Simon Glass2f949c32017-03-31 08:40:32 -0600651
652 return 0;
Lokesh Vutla0deb3332016-03-08 09:18:09 +0530653}
654
Jean-Jacques Hiblota58fe0a2018-11-29 10:57:41 +0100655#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
656static int device_okay(const char *path)
657{
658 int node;
659
660 node = fdt_path_offset(gd->fdt_blob, path);
661 if (node < 0)
662 return 0;
663
664 return fdtdec_get_is_enabled(gd->fdt_blob, node);
665}
666#endif
667
Roger Quadrosf019ee82013-11-11 16:56:44 +0200668int board_late_init(void)
669{
Lokesh Vutla6d576a72014-07-14 19:57:58 +0530670#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530671 char *name = "unknown";
672
Lokesh Vutla9e23ab52016-06-29 14:50:41 +0530673 if (is_dra72x()) {
674 if (board_is_dra72x_revc_or_later())
675 name = "dra72x-revc";
Lokesh Vutlab9d8f8e2016-11-23 13:25:24 +0530676 else if (board_is_dra71x_evm())
677 name = "dra71x";
Lokesh Vutla9e23ab52016-06-29 14:50:41 +0530678 else
679 name = "dra72x";
Lokesh Vutla69483e62017-12-29 11:47:51 +0530680 } else if (is_dra76x_abz()) {
681 name = "dra76x_abz";
682 } else if (is_dra76x_acd()) {
683 name = "dra76x_acd";
Lokesh Vutla9e23ab52016-06-29 14:50:41 +0530684 } else {
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530685 name = "dra7xx";
Lokesh Vutla9e23ab52016-06-29 14:50:41 +0530686 }
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530687
688 set_board_info_env(name);
Dileep Katta7354dfc2015-03-25 04:04:51 +0530689
Lokesh Vutla73368b72016-11-29 11:58:01 +0530690 /*
691 * Default FIT boot on HS devices. Non FIT images are not allowed
692 * on HS devices.
693 */
694 if (get_device_type() == HS_DEVICE)
Simon Glass6a38e412017-08-03 12:22:09 -0600695 env_set("boot_fit", "1");
Lokesh Vutla73368b72016-11-29 11:58:01 +0530696
Paul Kocialkowski2edadee2015-08-27 19:37:12 +0200697 omap_die_id_serial();
Semen Protsenko4a845322017-05-22 19:16:42 +0300698 omap_set_fastboot_vars();
Keerthybe0c1f12017-10-12 10:18:45 +0530699
700 /*
701 * Hook the LDO1 regulator to EN pin. This applies only to LP8733
702 * Rest all regulators are hooked to EN Pin at reset.
703 */
704 if (board_is_dra71x_evm())
705 palmas_i2c_write_u8(LP873X_I2C_SLAVE_ADDR, 0x9, 0x7);
Lokesh Vutla6d576a72014-07-14 19:57:58 +0530706#endif
Jean-Jacques Hiblota58fe0a2018-11-29 10:57:41 +0100707#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
708 if (device_okay("/ocp/omap_dwc3_1@48880000"))
709 enable_usb_clocks(0);
710 if (device_okay("/ocp/omap_dwc3_2@488c0000"))
711 enable_usb_clocks(1);
712#endif
Roger Quadrosf019ee82013-11-11 16:56:44 +0200713 return 0;
714}
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530715
716#ifdef CONFIG_SPL_BUILD
717void do_board_detect(void)
718{
719 int rc;
720
721 rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS,
722 CONFIG_EEPROM_CHIP_ADDRESS);
723 if (rc)
724 printf("ti_i2c_eeprom_init failed %d\n", rc);
725}
726
727#else
728
729void do_board_detect(void)
730{
731 char *bname = NULL;
732 int rc;
733
734 rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS,
735 CONFIG_EEPROM_CHIP_ADDRESS);
736 if (rc)
737 printf("ti_i2c_eeprom_init failed %d\n", rc);
738
739 if (board_is_dra74x_evm()) {
740 bname = "DRA74x EVM";
Ravi Babue1031082016-03-15 18:09:14 -0500741 } else if (board_is_dra72x_evm()) {
742 bname = "DRA72x EVM";
Lokesh Vutlab9d8f8e2016-11-23 13:25:24 +0530743 } else if (board_is_dra71x_evm()) {
744 bname = "DRA71x EVM";
Lokesh Vutla13376132017-08-21 12:50:53 +0530745 } else if (board_is_dra76x_evm()) {
746 bname = "DRA76x EVM";
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530747 } else {
Ravi Babue1031082016-03-15 18:09:14 -0500748 /* If EEPROM is not populated */
Lokesh Vutla3c7dc012016-03-08 09:18:05 +0530749 if (is_dra72x())
750 bname = "DRA72x EVM";
751 else
752 bname = "DRA74x EVM";
753 }
754
755 if (bname)
756 snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
757 "Board: %s REV %s\n", bname, board_ti_get_rev());
758}
759#endif /* CONFIG_SPL_BUILD */
Roger Quadrosf019ee82013-11-11 16:56:44 +0200760
Keerthyc8056232016-06-07 16:05:25 +0530761void vcores_init(void)
762{
763 if (board_is_dra74x_evm()) {
764 *omap_vcores = &dra752_volts;
765 } else if (board_is_dra72x_evm()) {
766 *omap_vcores = &dra722_volts;
Keerthy4d4e34b2016-11-23 13:25:27 +0530767 } else if (board_is_dra71x_evm()) {
768 *omap_vcores = &dra718_volts;
Keerthy1b21f552017-08-21 12:50:54 +0530769 } else if (board_is_dra76x_evm()) {
770 *omap_vcores = &dra76x_volts;
Keerthyc8056232016-06-07 16:05:25 +0530771 } else {
772 /* If EEPROM is not populated */
773 if (is_dra72x())
774 *omap_vcores = &dra722_volts;
775 else
776 *omap_vcores = &dra752_volts;
777 }
778}
779
Paul Kocialkowskia00b1e52016-02-27 19:18:56 +0100780void set_muxconf_regs(void)
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000781{
782 do_set_mux32((*ctrl)->control_padconf_core_base,
Lokesh Vutla1fd80222015-06-04 16:42:38 +0530783 early_padconf, ARRAY_SIZE(early_padconf));
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000784}
Franklin S Cooper Jr236fca82019-02-27 13:29:36 +0530785
Miquel Raynald0935362019-10-03 19:50:03 +0200786#if defined(CONFIG_MTD_RAW_NAND)
Franklin S Cooper Jr236fca82019-02-27 13:29:36 +0530787static int nand_sw_detect(void)
788{
789 int rc;
790 uchar data[2];
791 struct udevice *dev;
792
793 rc = i2c_get_chip_for_busnum(NAND_PCF8575_I2C_BUS_NUM,
794 NAND_PCF8575_ADDR, 0, &dev);
795 if (rc)
796 return -1;
797
798 rc = dm_i2c_read(dev, 0, (uint8_t *)&data, sizeof(data));
799 if (rc)
800 return -1;
801
802 /* We are only interested in P10 and P11 on PCF8575 which is equal to
803 * bits 8 and 9.
804 */
805 data[1] = data[1] & 0x3;
806
807 /* Ensure only P11 is set and P10 is cleared. This ensures only
808 * NAND (P10) is configured and not NOR (P11) which are both low
809 * true signals. NAND and NOR settings should not be enabled at
810 * the same time.
811 */
812 if (data[1] == 0x2)
813 return 0;
814
815 return -1;
816}
817#else
818int nand_sw_detect(void)
819{
820 return -1;
821}
822#endif
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000823
Lokesh Vutla1fd80222015-06-04 16:42:38 +0530824#ifdef CONFIG_IODELAY_RECALIBRATION
825void recalibrate_iodelay(void)
826{
Nishanth Menond3b7d852016-03-15 18:09:17 -0500827 struct pad_conf_entry const *pads, *delta_pads = NULL;
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500828 struct iodelay_cfg_entry const *iodelay;
Nishanth Menond3b7d852016-03-15 18:09:17 -0500829 int npads, niodelays, delta_npads = 0;
830 int ret;
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500831
832 switch (omap_revision()) {
833 case DRA722_ES1_0:
Nishanth Menond3b7d852016-03-15 18:09:17 -0500834 case DRA722_ES2_0:
Vishal Mahaveer42d25eb2017-08-26 16:51:22 -0500835 case DRA722_ES2_1:
Nishanth Menond3b7d852016-03-15 18:09:17 -0500836 pads = dra72x_core_padconf_array_common;
837 npads = ARRAY_SIZE(dra72x_core_padconf_array_common);
Lokesh Vutla52ac1fe2016-11-23 13:25:25 +0530838 if (board_is_dra71x_evm()) {
839 pads = dra71x_core_padconf_array;
840 npads = ARRAY_SIZE(dra71x_core_padconf_array);
841 iodelay = dra71_iodelay_cfg_array;
842 niodelays = ARRAY_SIZE(dra71_iodelay_cfg_array);
Franklin S Cooper Jr236fca82019-02-27 13:29:36 +0530843 /* If SW8 on the EVM is set to enable NAND then
844 * overwrite the pins used by VOUT3 with NAND.
845 */
846 if (!nand_sw_detect()) {
847 delta_pads = dra71x_nand_padconf_array;
848 delta_npads =
849 ARRAY_SIZE(dra71x_nand_padconf_array);
850 } else {
851 delta_pads = dra71x_vout3_padconf_array;
852 delta_npads =
853 ARRAY_SIZE(dra71x_vout3_padconf_array);
854 }
855
Lokesh Vutla52ac1fe2016-11-23 13:25:25 +0530856 } else if (board_is_dra72x_revc_or_later()) {
Nishanth Menond3b7d852016-03-15 18:09:17 -0500857 delta_pads = dra72x_rgmii_padconf_array_revc;
858 delta_npads =
859 ARRAY_SIZE(dra72x_rgmii_padconf_array_revc);
860 iodelay = dra72_iodelay_cfg_array_revc;
861 niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revc);
862 } else {
863 delta_pads = dra72x_rgmii_padconf_array_revb;
864 delta_npads =
865 ARRAY_SIZE(dra72x_rgmii_padconf_array_revb);
866 iodelay = dra72_iodelay_cfg_array_revb;
867 niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revb);
868 }
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500869 break;
870 case DRA752_ES1_0:
871 case DRA752_ES1_1:
872 pads = dra74x_core_padconf_array;
873 npads = ARRAY_SIZE(dra74x_core_padconf_array);
874 iodelay = dra742_es1_1_iodelay_cfg_array;
875 niodelays = ARRAY_SIZE(dra742_es1_1_iodelay_cfg_array);
876 break;
Lokesh Vutla69483e62017-12-29 11:47:51 +0530877 case DRA762_ACD_ES1_0:
Lokesh Vutla7e7d4762017-08-21 12:50:56 +0530878 case DRA762_ES1_0:
879 pads = dra76x_core_padconf_array;
880 npads = ARRAY_SIZE(dra76x_core_padconf_array);
881 iodelay = dra76x_es1_0_iodelay_cfg_array;
882 niodelays = ARRAY_SIZE(dra76x_es1_0_iodelay_cfg_array);
883 break;
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500884 default:
885 case DRA752_ES2_0:
Lokesh Vutla69483e62017-12-29 11:47:51 +0530886 case DRA762_ABZ_ES1_0:
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500887 pads = dra74x_core_padconf_array;
888 npads = ARRAY_SIZE(dra74x_core_padconf_array);
889 iodelay = dra742_es2_0_iodelay_cfg_array;
890 niodelays = ARRAY_SIZE(dra742_es2_0_iodelay_cfg_array);
Nishanth Menonbe3a5532015-08-13 09:51:00 -0500891 /* Setup port1 and port2 for rgmii with 'no-id' mode */
892 clrset_spare_register(1, 0, RGMII2_ID_MODE_N_MASK |
893 RGMII1_ID_MODE_N_MASK);
Nishanth Menon6759e7f2015-08-13 09:50:59 -0500894 break;
Nishanth Menon97313b52015-06-04 16:42:39 +0530895 }
Nishanth Menond3b7d852016-03-15 18:09:17 -0500896 /* Setup I/O isolation */
897 ret = __recalibrate_iodelay_start();
898 if (ret)
899 goto err;
900
901 /* Do the muxing here */
902 do_set_mux32((*ctrl)->control_padconf_core_base, pads, npads);
903
904 /* Now do the weird minor deltas that should be safe */
905 if (delta_npads)
906 do_set_mux32((*ctrl)->control_padconf_core_base,
907 delta_pads, delta_npads);
908
Vignesh R0e0835e2017-12-12 17:14:27 +0530909 if (is_dra76x())
910 /* Set mux for MCAN instead of DCAN1 */
911 clrsetbits_le32((*ctrl)->control_core_control_spare_rw,
912 MCAN_SEL_ALT_MASK, MCAN_SEL);
913
Nishanth Menond3b7d852016-03-15 18:09:17 -0500914 /* Setup IOdelay configuration */
915 ret = do_set_iodelay((*ctrl)->iodelay_config_base, iodelay, niodelays);
916err:
917 /* Closeup.. remove isolation */
918 __recalibrate_iodelay_end(ret);
Lokesh Vutla1fd80222015-06-04 16:42:38 +0530919}
920#endif
921
Masahiro Yamada0a780172017-05-09 20:31:39 +0900922#if defined(CONFIG_MMC)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900923int board_mmc_init(struct bd_info *bis)
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000924{
925 omap_mmc_init(0, 0, 0, -1, -1);
926 omap_mmc_init(1, 0, 0, -1, -1);
927 return 0;
928}
Lokesh Vutla8352d272017-08-21 12:50:49 +0530929
930void board_mmc_poweron_ldo(uint voltage)
931{
932 if (board_is_dra71x_evm()) {
933 if (voltage == LDO_VOLT_3V0)
934 voltage = 0x19;
935 else if (voltage == LDO_VOLT_1V8)
936 voltage = 0xa;
937 lp873x_mmc1_poweron_ldo(voltage);
Lokesh Vutla4712cc42017-08-21 12:50:57 +0530938 } else if (board_is_dra76x_evm()) {
939 palmas_mmc1_poweron_ldo(LDO4_VOLTAGE, LDO4_CTRL, voltage);
Lokesh Vutla8352d272017-08-21 12:50:49 +0530940 } else {
Lokesh Vutla22fa8192017-08-21 12:50:50 +0530941 palmas_mmc1_poweron_ldo(LDO1_VOLTAGE, LDO1_CTRL, voltage);
Lokesh Vutla8352d272017-08-21 12:50:49 +0530942 }
943}
Kishon Vijay Abraham I110ed012018-01-30 16:01:52 +0100944
945static const struct mmc_platform_fixups dra7x_es1_1_mmc1_fixups = {
946 .hw_rev = "rev11",
947 .unsupported_caps = MMC_CAP(MMC_HS_200) |
948 MMC_CAP(UHS_SDR104),
949 .max_freq = 96000000,
950};
951
952static const struct mmc_platform_fixups dra7x_es1_1_mmc23_fixups = {
953 .hw_rev = "rev11",
954 .unsupported_caps = MMC_CAP(MMC_HS_200) |
955 MMC_CAP(UHS_SDR104) |
956 MMC_CAP(UHS_SDR50),
957 .max_freq = 48000000,
958};
959
960const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr)
961{
962 switch (omap_revision()) {
963 case DRA752_ES1_0:
964 case DRA752_ES1_1:
965 if (addr == OMAP_HSMMC1_BASE)
966 return &dra7x_es1_1_mmc1_fixups;
967 else
968 return &dra7x_es1_1_mmc23_fixups;
969 default:
970 return NULL;
971 }
972}
Lokesh Vutla40700ad2013-02-12 21:29:08 +0000973#endif
Mugunthan V Nab48f782013-07-08 16:04:41 +0530974
Tom Rini560ef452014-04-03 07:52:56 -0400975#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
976int spl_start_uboot(void)
977{
978 /* break into full u-boot on 'c' */
979 if (serial_tstc() && serial_getc() == 'c')
980 return 1;
981
982#ifdef CONFIG_SPL_ENV_SUPPORT
983 env_init();
Simon Glass17539572017-08-03 12:22:07 -0600984 env_load();
Simon Glass22c34c22017-08-03 12:22:13 -0600985 if (env_get_yesno("boot_os") != 1)
Tom Rini560ef452014-04-03 07:52:56 -0400986 return 1;
987#endif
988
989 return 0;
990}
991#endif
992
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +0530993#ifdef CONFIG_BOARD_EARLY_INIT_F
994/* VTT regulator enable */
995static inline void vtt_regulator_enable(void)
996{
997 if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
998 return;
999
Lokesh Vutla6f1038f2017-08-21 12:50:55 +05301000 /* Do not enable VTT for DRA722 or DRA76x */
1001 if (is_dra72x() || is_dra76x())
Lokesh Vutlabe86f0e2014-08-04 19:42:24 +05301002 return;
1003
1004 /*
1005 * EVM Rev G and later use gpio7_11 for DDR3 termination.
1006 * This is safe enough to do on older revs.
1007 */
1008 gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
1009 gpio_direction_output(GPIO_DDR_VTT_EN, 1);
1010}
1011
1012int board_early_init_f(void)
1013{
1014 vtt_regulator_enable();
1015 return 0;
1016}
1017#endif
Daniel Allred7ceffb22016-05-19 19:10:54 -05001018
1019#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +09001020int ft_board_setup(void *blob, struct bd_info *bd)
Daniel Allred7ceffb22016-05-19 19:10:54 -05001021{
1022 ft_cpu_setup(blob, bd);
1023
1024 return 0;
1025}
1026#endif
Lokesh Vutlaf4de4722016-05-16 10:51:23 +05301027
1028#ifdef CONFIG_SPL_LOAD_FIT
1029int board_fit_config_name_match(const char *name)
1030{
Mugunthan V Nb8c6b022016-09-27 13:01:41 +05301031 if (is_dra72x()) {
Lokesh Vutlaf0d55172016-11-23 13:25:30 +05301032 if (board_is_dra71x_evm()) {
1033 if (!strcmp(name, "dra71-evm"))
1034 return 0;
1035 }else if(board_is_dra72x_revc_or_later()) {
Mugunthan V Nb8c6b022016-09-27 13:01:41 +05301036 if (!strcmp(name, "dra72-evm-revc"))
1037 return 0;
1038 } else if (!strcmp(name, "dra72-evm")) {
1039 return 0;
1040 }
Lokesh Vutla69483e62017-12-29 11:47:51 +05301041 } else if (is_dra76x_acd() && !strcmp(name, "dra76-evm")) {
Lokesh Vutla635848f2017-08-21 12:51:01 +05301042 return 0;
Lokesh Vutla69483e62017-12-29 11:47:51 +05301043 } else if (!is_dra72x() && !is_dra76x_acd() &&
1044 !strcmp(name, "dra7-evm")) {
Lokesh Vutlaf4de4722016-05-16 10:51:23 +05301045 return 0;
Mugunthan V Nb8c6b022016-09-27 13:01:41 +05301046 }
1047
1048 return -1;
Lokesh Vutlaf4de4722016-05-16 10:51:23 +05301049}
1050#endif
Andreas Dannenberg5cf344b2016-06-27 09:19:22 -05001051
Simon Glass96c0d2b2023-02-05 17:54:10 -07001052#if IS_ENABLED(CONFIG_FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
Roman Kovalivskyi1bb13422020-07-28 23:35:32 +03001053int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
Andrew F. Davisd3555832019-02-11 08:00:08 -06001054{
Roman Kovalivskyi1bb13422020-07-28 23:35:32 +03001055 if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
1056 return -ENOTSUPP;
1057
Andrew F. Davisd3555832019-02-11 08:00:08 -06001058 printf("Setting reboot to fastboot flag ...\n");
1059 env_set("dofastboot", "1");
1060 env_save();
1061 return 0;
1062}
1063#endif