1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
5 * Author: Felipe Balbi <balbi@ti.com>
7 * Based on board/ti/dra7xx/evm.c
12 #include <fdt_support.h>
21 #include <asm/omap_common.h>
22 #include <asm/omap_sec_common.h>
25 #include <asm/arch/gpio.h>
26 #include <asm/arch/clock.h>
27 #include <asm/arch/dra7xx_iodelay.h>
28 #include <asm/arch/sys_proto.h>
29 #include <asm/arch/mmc_host_def.h>
30 #include <asm/arch/sata.h>
31 #include <asm/arch/gpio.h>
32 #include <asm/arch/omap.h>
34 #include <linux/usb/gadget.h>
35 #include <dwc3-uboot.h>
36 #include <dwc3-omap-uboot.h>
37 #include <ti-usb-phy-uboot.h>
39 #include <dm/uclass.h>
42 #include "../common/board_detect.h"
45 #ifdef CONFIG_SUPPORT_EMMC_BOOT
46 static int board_bootmode_has_emmc(void);
49 #define board_is_x15() board_ti_is("BBRDX15_")
50 #define board_is_x15_revb1() (board_ti_is("BBRDX15_") && \
51 !strncmp("B.10", board_ti_get_rev(), 3))
52 #define board_is_x15_revc() (board_ti_is("BBRDX15_") && \
53 !strncmp("C.00", board_ti_get_rev(), 3))
54 #define board_is_am572x_evm() board_ti_is("AM572PM_")
55 #define board_is_am572x_evm_reva3() \
56 (board_ti_is("AM572PM_") && \
57 !strncmp("A.30", board_ti_get_rev(), 3))
58 #define board_is_am574x_idk() board_ti_is("AM574IDK")
59 #define board_is_am572x_idk() board_ti_is("AM572IDK")
60 #define board_is_am571x_idk() board_ti_is("AM571IDK")
61 #define board_is_bbai() board_ti_is("BBONE-AI")
63 #ifdef CONFIG_DRIVER_TI_CPSW
67 DECLARE_GLOBAL_DATA_PTR;
69 #define GPIO_ETH_LCD GPIO_TO_PIN(2, 22)
71 #define GPIO_DDR_VTT_EN 203
73 /* Touch screen controller to identify the LCD */
74 #define OSD_TS_FT_BUS_ADDRESS 0
75 #define OSD_TS_FT_CHIP_ADDRESS 0x38
76 #define OSD_TS_FT_REG_ID 0xA3
78 * Touchscreen IDs for various OSD panels
79 * Ref: http://www.osddisplays.com/TI/OSD101T2587-53TS_A.1.pdf
81 /* Used on newer osd101t2587 Panels */
82 #define OSD_TS_FT_ID_5x46 0x54
83 /* Used on older osd101t2045 Panels */
84 #define OSD_TS_FT_ID_5606 0x08
86 #define SYSINFO_BOARD_NAME_MAX_LEN 45
88 #define TPS65903X_PRIMARY_SECONDARY_PAD2 0xFB
89 #define TPS65903X_PAD2_POWERHOLD_MASK 0x20
91 const struct omap_sysinfo sysinfo = {
92 "Board: UNKNOWN(BeagleBoard X15?) REV UNKNOWN\n"
95 static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = {
96 .dmm_lisa_map_3 = 0x80740300,
100 static const struct dmm_lisa_map_regs am571x_idk_lisa_regs = {
101 .dmm_lisa_map_3 = 0x80640100,
105 static const struct dmm_lisa_map_regs am574x_idk_lisa_regs = {
106 .dmm_lisa_map_2 = 0xc0600200,
107 .dmm_lisa_map_3 = 0x80600100,
111 static const struct dmm_lisa_map_regs bbai_lisa_regs = {
112 .dmm_lisa_map_3 = 0x80640100,
116 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
118 if (board_is_am571x_idk())
119 *dmm_lisa_regs = &am571x_idk_lisa_regs;
120 else if (board_is_am574x_idk())
121 *dmm_lisa_regs = &am574x_idk_lisa_regs;
122 else if (board_is_bbai())
123 *dmm_lisa_regs = &bbai_lisa_regs;
125 *dmm_lisa_regs = &beagle_x15_lisa_regs;
128 static const struct emif_regs beagle_x15_emif1_ddr3_532mhz_emif_regs = {
129 .sdram_config_init = 0x61851b32,
130 .sdram_config = 0x61851b32,
131 .sdram_config2 = 0x08000000,
132 .ref_ctrl = 0x000040F1,
133 .ref_ctrl_final = 0x00001035,
134 .sdram_tim1 = 0xcccf36ab,
135 .sdram_tim2 = 0x308f7fda,
136 .sdram_tim3 = 0x409f88a8,
137 .read_idle_ctrl = 0x00050000,
138 .zq_config = 0x5007190b,
139 .temp_alert_config = 0x00000000,
140 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
141 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
142 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
143 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
144 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
145 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
146 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
147 .emif_rd_wr_lvl_rmp_win = 0x00000000,
148 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
149 .emif_rd_wr_lvl_ctl = 0x00000000,
150 .emif_rd_wr_exec_thresh = 0x00000305
153 /* Ext phy ctrl regs 1-35 */
154 static const u32 beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs[] = {
192 static const struct emif_regs beagle_x15_emif2_ddr3_532mhz_emif_regs = {
193 .sdram_config_init = 0x61851b32,
194 .sdram_config = 0x61851b32,
195 .sdram_config2 = 0x08000000,
196 .ref_ctrl = 0x000040F1,
197 .ref_ctrl_final = 0x00001035,
198 .sdram_tim1 = 0xcccf36b3,
199 .sdram_tim2 = 0x308f7fda,
200 .sdram_tim3 = 0x407f88a8,
201 .read_idle_ctrl = 0x00050000,
202 .zq_config = 0x5007190b,
203 .temp_alert_config = 0x00000000,
204 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
205 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
206 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
207 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
208 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
209 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
210 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
211 .emif_rd_wr_lvl_rmp_win = 0x00000000,
212 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
213 .emif_rd_wr_lvl_ctl = 0x00000000,
214 .emif_rd_wr_exec_thresh = 0x00000305
217 static const u32 beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs[] = {
255 static const struct emif_regs am571x_emif1_ddr3_666mhz_emif_regs = {
256 .sdram_config_init = 0x61863332,
257 .sdram_config = 0x61863332,
258 .sdram_config2 = 0x08000000,
259 .ref_ctrl = 0x0000514d,
260 .ref_ctrl_final = 0x0000144a,
261 .sdram_tim1 = 0xd333887c,
262 .sdram_tim2 = 0x30b37fe3,
263 .sdram_tim3 = 0x409f8ad8,
264 .read_idle_ctrl = 0x00050000,
265 .zq_config = 0x5007190b,
266 .temp_alert_config = 0x00000000,
267 .emif_ddr_phy_ctlr_1_init = 0x0024400f,
268 .emif_ddr_phy_ctlr_1 = 0x0e24400f,
269 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
270 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
271 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
272 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
273 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
274 .emif_rd_wr_lvl_rmp_win = 0x00000000,
275 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
276 .emif_rd_wr_lvl_ctl = 0x00000000,
277 .emif_rd_wr_exec_thresh = 0x00000305
280 static const struct emif_regs am574x_emif1_ddr3_666mhz_emif_ecc_regs = {
281 .sdram_config_init = 0x61863332,
282 .sdram_config = 0x61863332,
283 .sdram_config2 = 0x08000000,
284 .ref_ctrl = 0x0000514d,
285 .ref_ctrl_final = 0x0000144a,
286 .sdram_tim1 = 0xd333887c,
287 .sdram_tim2 = 0x30b37fe3,
288 .sdram_tim3 = 0x409f8ad8,
289 .read_idle_ctrl = 0x00050000,
290 .zq_config = 0x5007190b,
291 .temp_alert_config = 0x00000000,
292 .emif_ddr_phy_ctlr_1_init = 0x0024400f,
293 .emif_ddr_phy_ctlr_1 = 0x0e24400f,
294 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
295 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
296 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
297 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
298 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
299 .emif_rd_wr_lvl_rmp_win = 0x00000000,
300 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
301 .emif_rd_wr_lvl_ctl = 0x00000000,
302 .emif_rd_wr_exec_thresh = 0x00000305,
303 .emif_ecc_ctrl_reg = 0xD0000001,
304 .emif_ecc_address_range_1 = 0x3FFF0000,
305 .emif_ecc_address_range_2 = 0x00000000
308 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
312 if (board_is_am571x_idk())
313 *regs = &am571x_emif1_ddr3_666mhz_emif_regs;
314 else if (board_is_am574x_idk())
315 *regs = &am574x_emif1_ddr3_666mhz_emif_ecc_regs;
317 *regs = &beagle_x15_emif1_ddr3_532mhz_emif_regs;
320 if (board_is_am574x_idk())
321 *regs = &am571x_emif1_ddr3_666mhz_emif_regs;
323 *regs = &beagle_x15_emif2_ddr3_532mhz_emif_regs;
328 void emif_get_ext_phy_ctrl_const_regs(u32 emif_nr, const u32 **regs, u32 *size)
332 *regs = beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs;
333 *size = ARRAY_SIZE(beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs);
336 *regs = beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs;
337 *size = ARRAY_SIZE(beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs);
342 struct vcores_data beagle_x15_volts = {
343 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
344 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
345 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
346 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
347 .mpu.pmic = &tps659038,
348 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
350 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
351 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
352 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
353 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
354 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
355 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
356 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
357 .eve.addr = TPS659038_REG_ADDR_SMPS45,
358 .eve.pmic = &tps659038,
359 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
361 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
362 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
363 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
364 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
365 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
366 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
367 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
368 .gpu.addr = TPS659038_REG_ADDR_SMPS45,
369 .gpu.pmic = &tps659038,
370 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
372 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
373 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
374 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
375 .core.addr = TPS659038_REG_ADDR_SMPS6,
376 .core.pmic = &tps659038,
378 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
379 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
380 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
381 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
382 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
383 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
384 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
385 .iva.addr = TPS659038_REG_ADDR_SMPS45,
386 .iva.pmic = &tps659038,
387 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
390 struct vcores_data am572x_idk_volts = {
391 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
392 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
393 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
394 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
395 .mpu.pmic = &tps659038,
396 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
398 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
399 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
400 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
401 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
402 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
403 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
404 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
405 .eve.addr = TPS659038_REG_ADDR_SMPS45,
406 .eve.pmic = &tps659038,
407 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
409 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
410 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
411 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
412 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
413 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
414 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
415 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
416 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
417 .gpu.pmic = &tps659038,
418 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
420 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
421 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
422 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
423 .core.addr = TPS659038_REG_ADDR_SMPS7,
424 .core.pmic = &tps659038,
426 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
427 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
428 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
429 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
430 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
431 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
432 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
433 .iva.addr = TPS659038_REG_ADDR_SMPS8,
434 .iva.pmic = &tps659038,
435 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
438 struct vcores_data am571x_idk_volts = {
439 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
440 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
441 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
442 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
443 .mpu.pmic = &tps659038,
444 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
446 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
447 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
448 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
449 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
450 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
451 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
452 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
453 .eve.addr = TPS659038_REG_ADDR_SMPS45,
454 .eve.pmic = &tps659038,
455 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
457 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
458 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
459 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
460 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
461 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
462 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
463 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
464 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
465 .gpu.pmic = &tps659038,
466 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
468 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
469 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
470 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
471 .core.addr = TPS659038_REG_ADDR_SMPS7,
472 .core.pmic = &tps659038,
474 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
475 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
476 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
477 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
478 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
479 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
480 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
481 .iva.addr = TPS659038_REG_ADDR_SMPS45,
482 .iva.pmic = &tps659038,
483 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
486 int get_voltrail_opp(int rail_offset)
490 switch (rail_offset) {
501 opp = DRA7_DSPEVE_OPP;
514 #ifdef CONFIG_SPL_BUILD
515 /* No env to setup for SPL */
516 static inline void setup_board_eeprom_env(void) { }
518 /* Override function to read eeprom information */
519 void do_board_detect(void)
523 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
524 CONFIG_EEPROM_CHIP_ADDRESS);
526 printf("ti_i2c_eeprom_init failed %d\n", rc);
528 #ifdef CONFIG_SUPPORT_EMMC_BOOT
529 rc = board_bootmode_has_emmc();
531 rc = ti_emmc_boardid_get();
533 printf("ti_emmc_boardid_get failed %d\n", rc);
537 #else /* CONFIG_SPL_BUILD */
539 /* Override function to read eeprom information: actual i2c read done by SPL*/
540 void do_board_detect(void)
545 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
546 CONFIG_EEPROM_CHIP_ADDRESS);
548 printf("ti_i2c_eeprom_init failed %d\n", rc);
550 #ifdef CONFIG_SUPPORT_EMMC_BOOT
551 rc = board_bootmode_has_emmc();
553 rc = ti_emmc_boardid_get();
555 printf("ti_emmc_boardid_get failed %d\n", rc);
559 bname = "BeagleBoard X15";
560 else if (board_is_am572x_evm())
561 bname = "AM572x EVM";
562 else if (board_is_am574x_idk())
563 bname = "AM574x IDK";
564 else if (board_is_am572x_idk())
565 bname = "AM572x IDK";
566 else if (board_is_am571x_idk())
567 bname = "AM571x IDK";
568 else if (board_is_bbai())
569 bname = "BeagleBone AI";
572 snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
573 "Board: %s REV %s\n", bname, board_ti_get_rev());
576 static void setup_board_eeprom_env(void)
578 char *name = "beagle_x15";
581 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
582 CONFIG_EEPROM_CHIP_ADDRESS);
586 if (board_is_x15()) {
587 if (board_is_x15_revb1())
588 name = "beagle_x15_revb1";
589 else if (board_is_x15_revc())
590 name = "beagle_x15_revc";
593 } else if (board_is_am572x_evm()) {
594 if (board_is_am572x_evm_reva3())
595 name = "am57xx_evm_reva3";
598 } else if (board_is_am574x_idk()) {
600 } else if (board_is_am572x_idk()) {
602 } else if (board_is_am571x_idk()) {
604 } else if (board_is_bbai()) {
605 name = "am5729_beagleboneai";
607 printf("Unidentified board claims %s in eeprom header\n",
608 board_ti_get_name());
612 set_board_info_env(name);
615 #endif /* CONFIG_SPL_BUILD */
617 void vcores_init(void)
619 if (board_is_am572x_idk() || board_is_am574x_idk())
620 *omap_vcores = &am572x_idk_volts;
621 else if (board_is_am571x_idk())
622 *omap_vcores = &am571x_idk_volts;
624 *omap_vcores = &beagle_x15_volts;
627 void hw_data_init(void)
629 *prcm = &dra7xx_prcm;
631 *dplls_data = &dra72x_dplls;
632 else if (is_dra76x())
633 *dplls_data = &dra76x_dplls;
635 *dplls_data = &dra7xx_dplls;
636 *ctrl = &dra7xx_ctrl;
639 bool am571x_idk_needs_lcd(void)
643 gpio_request(GPIO_ETH_LCD, "nLCD_Detect");
644 if (gpio_get_value(GPIO_ETH_LCD))
649 gpio_free(GPIO_ETH_LCD);
657 gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100);
662 void am57x_idk_lcd_detect(void)
665 char *idk_lcd = "no";
668 /* Only valid for IDKs */
669 if (board_is_x15() || board_is_am572x_evm() || board_is_bbai())
672 /* Only AM571x IDK has gpio control detect.. so check that */
673 if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
676 r = i2c_get_chip_for_busnum(OSD_TS_FT_BUS_ADDRESS,
677 OSD_TS_FT_CHIP_ADDRESS, 1, &dev);
679 printf("%s: Failed to get I2C device %d/%d (ret %d)\n",
680 __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
682 /* AM572x IDK has no explicit settings for optional LCD kit */
683 if (board_is_am571x_idk())
684 printf("%s: Touch screen detect failed: %d!\n",
690 r = dm_i2c_reg_read(dev, OSD_TS_FT_REG_ID);
692 printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n",
693 __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
694 OSD_TS_FT_REG_ID, r);
699 case OSD_TS_FT_ID_5606:
700 idk_lcd = "osd101t2045";
702 case OSD_TS_FT_ID_5x46:
703 idk_lcd = "osd101t2587";
706 printf("%s: Unidentifed Touch screen ID 0x%02x\n",
708 /* we will let default be "no lcd" */
711 env_set("idk_lcd", idk_lcd);
714 * On AM571x_IDK, no Display with J51 set to LCD is considered as an
715 * invalid configuration and we prevent boot to get user attention.
717 if (board_is_am571x_idk() && am571x_idk_needs_lcd() &&
718 !strncmp(idk_lcd, "no", 2)) {
719 printf("%s: Invalid HW configuration: display not detected/supported but J51 is set. Remove J51 to boot without display.\n",
727 #if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
728 static int device_okay(const char *path)
732 node = fdt_path_offset(gd->fdt_blob, path);
736 return fdtdec_get_is_enabled(gd->fdt_blob, node);
740 int board_late_init(void)
742 setup_board_eeprom_env();
747 * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
748 * This is the POWERHOLD-in-Low behavior.
750 palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);
753 * Default FIT boot on HS devices. Non FIT images are not allowed
756 if (get_device_type() == HS_DEVICE)
757 env_set("boot_fit", "1");
760 * Set the GPIO7 Pad to POWERHOLD. This has higher priority
761 * over DEV_CTRL.DEV_ON bit. This can be reset in case of
762 * PMIC Power off. So to be on the safer side set it back
763 * to POWERHOLD mode irrespective of the current state.
765 palmas_i2c_read_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
767 val = val | TPS65903X_PAD2_POWERHOLD_MASK;
768 palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
771 omap_die_id_serial();
772 omap_set_fastboot_vars();
774 am57x_idk_lcd_detect();
776 /* Just probe the potentially supported cdce913 device */
777 uclass_get_device(UCLASS_CLK, 0, &dev);
780 env_set("console", "ttyS0,115200n8");
782 #if !defined(CONFIG_SPL_BUILD)
783 board_ti_set_ethaddr(2);
786 #if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
787 if (device_okay("/ocp/omap_dwc3_1@48880000"))
788 enable_usb_clocks(0);
789 if (device_okay("/ocp/omap_dwc3_2@488c0000"))
790 enable_usb_clocks(1);
795 void set_muxconf_regs(void)
797 do_set_mux32((*ctrl)->control_padconf_core_base,
798 early_padconf, ARRAY_SIZE(early_padconf));
800 #ifdef CONFIG_SUPPORT_EMMC_BOOT
801 do_set_mux32((*ctrl)->control_padconf_core_base,
802 emmc_padconf, ARRAY_SIZE(emmc_padconf));
806 #ifdef CONFIG_IODELAY_RECALIBRATION
807 void recalibrate_iodelay(void)
809 const struct pad_conf_entry *pconf;
810 const struct iodelay_cfg_entry *iod, *delta_iod;
811 int pconf_sz, iod_sz, delta_iod_sz = 0;
814 if (board_is_am572x_idk()) {
815 pconf = core_padconf_array_essential_am572x_idk;
816 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am572x_idk);
817 iod = iodelay_cfg_array_am572x_idk;
818 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am572x_idk);
819 } else if (board_is_am574x_idk()) {
820 pconf = core_padconf_array_essential_am574x_idk;
821 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am574x_idk);
822 iod = iodelay_cfg_array_am574x_idk;
823 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am574x_idk);
824 } else if (board_is_am571x_idk()) {
825 pconf = core_padconf_array_essential_am571x_idk;
826 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am571x_idk);
827 iod = iodelay_cfg_array_am571x_idk;
828 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk);
829 } else if (board_is_bbai()) {
830 pconf = core_padconf_array_essential_bbai;
831 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_bbai);
832 iod = iodelay_cfg_array_bbai;
833 iod_sz = ARRAY_SIZE(iodelay_cfg_array_bbai);
835 /* Common for X15/GPEVM */
836 pconf = core_padconf_array_essential_x15;
837 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_x15);
838 /* There never was an SR1.0 X15.. So.. */
839 if (omap_revision() == DRA752_ES1_1) {
840 iod = iodelay_cfg_array_x15_sr1_1;
841 iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr1_1);
843 /* Since full production should switch to SR2.0 */
844 iod = iodelay_cfg_array_x15_sr2_0;
845 iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr2_0);
849 /* Setup I/O isolation */
850 ret = __recalibrate_iodelay_start();
854 /* Do the muxing here */
855 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
857 /* Now do the weird minor deltas that should be safe */
858 if (board_is_x15() || board_is_am572x_evm()) {
859 if (board_is_x15_revb1() || board_is_am572x_evm_reva3() ||
860 board_is_x15_revc()) {
861 pconf = core_padconf_array_delta_x15_sr2_0;
862 pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr2_0);
864 pconf = core_padconf_array_delta_x15_sr1_1;
865 pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr1_1);
867 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
870 if (board_is_am571x_idk()) {
871 if (am571x_idk_needs_lcd()) {
872 pconf = core_padconf_array_vout_am571x_idk;
873 pconf_sz = ARRAY_SIZE(core_padconf_array_vout_am571x_idk);
874 delta_iod = iodelay_cfg_array_am571x_idk_4port;
875 delta_iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk_4port);
878 pconf = core_padconf_array_icss1eth_am571x_idk;
879 pconf_sz = ARRAY_SIZE(core_padconf_array_icss1eth_am571x_idk);
881 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
884 /* Setup IOdelay configuration */
885 ret = do_set_iodelay((*ctrl)->iodelay_config_base, iod, iod_sz);
887 ret = do_set_iodelay((*ctrl)->iodelay_config_base, delta_iod,
891 /* Closeup.. remove isolation */
892 __recalibrate_iodelay_end(ret);
896 #if defined(CONFIG_MMC)
897 int board_mmc_init(bd_t *bis)
899 omap_mmc_init(0, 0, 0, -1, -1);
900 omap_mmc_init(1, 0, 0, -1, -1);
904 static const struct mmc_platform_fixups am57x_es1_1_mmc1_fixups = {
906 .unsupported_caps = MMC_CAP(MMC_HS_200) |
908 .max_freq = 96000000,
911 static const struct mmc_platform_fixups am57x_es1_1_mmc23_fixups = {
913 .unsupported_caps = MMC_CAP(MMC_HS_200) |
914 MMC_CAP(UHS_SDR104) |
916 .max_freq = 48000000,
919 const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr)
921 switch (omap_revision()) {
924 if (addr == OMAP_HSMMC1_BASE)
925 return &am57x_es1_1_mmc1_fixups;
927 return &am57x_es1_1_mmc23_fixups;
934 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
935 int spl_start_uboot(void)
937 /* break into full u-boot on 'c' */
938 if (serial_tstc() && serial_getc() == 'c')
941 #ifdef CONFIG_SPL_ENV_SUPPORT
944 if (env_get_yesno("boot_os") != 1)
952 #ifdef CONFIG_DRIVER_TI_CPSW
954 /* Delay value to add to calibrated value */
955 #define RGMII0_TXCTL_DLY_VAL ((0x3 << 5) + 0x8)
956 #define RGMII0_TXD0_DLY_VAL ((0x3 << 5) + 0x8)
957 #define RGMII0_TXD1_DLY_VAL ((0x3 << 5) + 0x2)
958 #define RGMII0_TXD2_DLY_VAL ((0x4 << 5) + 0x0)
959 #define RGMII0_TXD3_DLY_VAL ((0x4 << 5) + 0x0)
960 #define VIN2A_D13_DLY_VAL ((0x3 << 5) + 0x8)
961 #define VIN2A_D17_DLY_VAL ((0x3 << 5) + 0x8)
962 #define VIN2A_D16_DLY_VAL ((0x3 << 5) + 0x2)
963 #define VIN2A_D15_DLY_VAL ((0x4 << 5) + 0x0)
964 #define VIN2A_D14_DLY_VAL ((0x4 << 5) + 0x0)
966 static void cpsw_control(int enabled)
968 /* VTP can be added here */
971 static struct cpsw_slave_data cpsw_slaves[] = {
973 .slave_reg_ofs = 0x208,
974 .sliver_reg_ofs = 0xd80,
978 .slave_reg_ofs = 0x308,
979 .sliver_reg_ofs = 0xdc0,
984 static struct cpsw_platform_data cpsw_data = {
985 .mdio_base = CPSW_MDIO_BASE,
986 .cpsw_base = CPSW_BASE,
989 .cpdma_reg_ofs = 0x800,
991 .slave_data = cpsw_slaves,
992 .ale_reg_ofs = 0xd00,
994 .host_port_reg_ofs = 0x108,
995 .hw_stats_reg_ofs = 0x900,
996 .bd_ram_ofs = 0x2000,
997 .mac_control = (1 << 5),
998 .control = cpsw_control,
1000 .version = CPSW_CTRL_VERSION_2,
1003 static u64 mac_to_u64(u8 mac[6])
1008 for (i = 0; i < 6; i++) {
1016 static void u64_to_mac(u64 addr, u8 mac[6])
1020 mac[3] = addr >> 16;
1021 mac[2] = addr >> 24;
1022 mac[1] = addr >> 32;
1023 mac[0] = addr >> 40;
1026 int board_eth_init(bd_t *bis)
1029 uint8_t mac_addr[6];
1030 uint32_t mac_hi, mac_lo;
1034 u8 mac_addr1[6], mac_addr2[6];
1037 /* try reading mac address from efuse */
1038 mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
1039 mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
1040 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
1041 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
1042 mac_addr[2] = mac_hi & 0xFF;
1043 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
1044 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
1045 mac_addr[5] = mac_lo & 0xFF;
1047 if (!env_get("ethaddr")) {
1048 printf("<ethaddr> not set. Validating first E-fuse MAC\n");
1050 if (is_valid_ethaddr(mac_addr))
1051 eth_env_set_enetaddr("ethaddr", mac_addr);
1054 mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
1055 mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
1056 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
1057 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
1058 mac_addr[2] = mac_hi & 0xFF;
1059 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
1060 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
1061 mac_addr[5] = mac_lo & 0xFF;
1063 if (!env_get("eth1addr")) {
1064 if (is_valid_ethaddr(mac_addr))
1065 eth_env_set_enetaddr("eth1addr", mac_addr);
1068 ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
1070 writel(ctrl_val, (*ctrl)->control_core_control_io1);
1072 /* The phy address for the AM57xx IDK are different than x15 */
1073 if (board_is_am572x_idk() || board_is_am571x_idk() ||
1074 board_is_am574x_idk()) {
1075 cpsw_data.slave_data[0].phy_addr = 0;
1076 cpsw_data.slave_data[1].phy_addr = 1;
1079 ret = cpsw_register(&cpsw_data);
1081 printf("Error %d registering CPSW switch\n", ret);
1084 * Export any Ethernet MAC addresses from EEPROM.
1085 * On AM57xx the 2 MAC addresses define the address range
1087 board_ti_get_eth_mac_addr(0, mac_addr1);
1088 board_ti_get_eth_mac_addr(1, mac_addr2);
1090 if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) {
1091 mac1 = mac_to_u64(mac_addr1);
1092 mac2 = mac_to_u64(mac_addr2);
1094 /* must contain an address range */
1095 num_macs = mac2 - mac1 + 1;
1096 /* <= 50 to protect against user programming error */
1097 if (num_macs > 0 && num_macs <= 50) {
1098 for (i = 0; i < num_macs; i++) {
1099 u64_to_mac(mac1 + i, mac_addr);
1100 if (is_valid_ethaddr(mac_addr)) {
1101 eth_env_set_enetaddr_by_index("eth",
1113 #ifdef CONFIG_BOARD_EARLY_INIT_F
1114 /* VTT regulator enable */
1115 static inline void vtt_regulator_enable(void)
1117 if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
1120 gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
1121 gpio_direction_output(GPIO_DDR_VTT_EN, 1);
1124 int board_early_init_f(void)
1126 vtt_regulator_enable();
1131 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
1132 int ft_board_setup(void *blob, bd_t *bd)
1134 ft_cpu_setup(blob, bd);
1140 #ifdef CONFIG_SPL_LOAD_FIT
1141 int board_fit_config_name_match(const char *name)
1143 if (board_is_x15()) {
1144 if (board_is_x15_revb1()) {
1145 if (!strcmp(name, "am57xx-beagle-x15-revb1"))
1147 } else if (board_is_x15_revc()) {
1148 if (!strcmp(name, "am57xx-beagle-x15-revc"))
1150 } else if (!strcmp(name, "am57xx-beagle-x15")) {
1153 } else if (board_is_am572x_evm() &&
1154 !strcmp(name, "am57xx-beagle-x15")) {
1156 } else if (board_is_am572x_idk() && !strcmp(name, "am572x-idk")) {
1158 } else if (board_is_am574x_idk() && !strcmp(name, "am574x-idk")) {
1160 } else if (board_is_am571x_idk() && !strcmp(name, "am571x-idk")) {
1162 } else if (board_is_bbai() && !strcmp(name, "am5729-beagleboneai")) {
1170 #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
1171 int fastboot_set_reboot_flag(void)
1173 printf("Setting reboot to fastboot flag ...\n");
1174 env_set("dofastboot", "1");
1180 #ifdef CONFIG_SUPPORT_EMMC_BOOT
1181 static int board_bootmode_has_emmc(void)
1183 /* Check that boot mode is same as BBAI */
1184 if (gd->arch.omap_boot_mode != 2)
1191 #ifdef CONFIG_TI_SECURE_DEVICE
1192 void board_fit_image_post_process(void **p_image, size_t *p_size)
1194 secure_boot_verify_image(p_image, p_size);
1197 void board_tee_image_process(ulong tee_image, size_t tee_size)
1199 secure_tee_install((u32)tee_image);
1202 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);