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>
19 #include <asm/omap_common.h>
20 #include <asm/omap_sec_common.h>
23 #include <asm/arch/gpio.h>
24 #include <asm/arch/clock.h>
25 #include <asm/arch/dra7xx_iodelay.h>
26 #include <asm/arch/sys_proto.h>
27 #include <asm/arch/mmc_host_def.h>
28 #include <asm/arch/sata.h>
29 #include <asm/arch/gpio.h>
30 #include <asm/arch/omap.h>
32 #include <linux/usb/gadget.h>
33 #include <dwc3-uboot.h>
34 #include <dwc3-omap-uboot.h>
35 #include <ti-usb-phy-uboot.h>
37 #include <dm/uclass.h>
39 #include "../common/board_detect.h"
42 #ifdef CONFIG_SUPPORT_EMMC_BOOT
43 static int board_bootmode_has_emmc(void);
46 #define board_is_x15() board_ti_is("BBRDX15_")
47 #define board_is_x15_revb1() (board_ti_is("BBRDX15_") && \
48 !strncmp("B.10", board_ti_get_rev(), 3))
49 #define board_is_x15_revc() (board_ti_is("BBRDX15_") && \
50 !strncmp("C.00", board_ti_get_rev(), 3))
51 #define board_is_am572x_evm() board_ti_is("AM572PM_")
52 #define board_is_am572x_evm_reva3() \
53 (board_ti_is("AM572PM_") && \
54 !strncmp("A.30", board_ti_get_rev(), 3))
55 #define board_is_am574x_idk() board_ti_is("AM574IDK")
56 #define board_is_am572x_idk() board_ti_is("AM572IDK")
57 #define board_is_am571x_idk() board_ti_is("AM571IDK")
58 #define board_is_bbai() board_ti_is("BBONE-AI")
60 #ifdef CONFIG_DRIVER_TI_CPSW
64 DECLARE_GLOBAL_DATA_PTR;
66 #define GPIO_ETH_LCD GPIO_TO_PIN(2, 22)
68 #define GPIO_DDR_VTT_EN 203
70 /* Touch screen controller to identify the LCD */
71 #define OSD_TS_FT_BUS_ADDRESS 0
72 #define OSD_TS_FT_CHIP_ADDRESS 0x38
73 #define OSD_TS_FT_REG_ID 0xA3
75 * Touchscreen IDs for various OSD panels
76 * Ref: http://www.osddisplays.com/TI/OSD101T2587-53TS_A.1.pdf
78 /* Used on newer osd101t2587 Panels */
79 #define OSD_TS_FT_ID_5x46 0x54
80 /* Used on older osd101t2045 Panels */
81 #define OSD_TS_FT_ID_5606 0x08
83 #define SYSINFO_BOARD_NAME_MAX_LEN 45
85 #define TPS65903X_PRIMARY_SECONDARY_PAD2 0xFB
86 #define TPS65903X_PAD2_POWERHOLD_MASK 0x20
88 const struct omap_sysinfo sysinfo = {
89 "Board: UNKNOWN(BeagleBoard X15?) REV UNKNOWN\n"
92 static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = {
93 .dmm_lisa_map_3 = 0x80740300,
97 static const struct dmm_lisa_map_regs am571x_idk_lisa_regs = {
98 .dmm_lisa_map_3 = 0x80640100,
102 static const struct dmm_lisa_map_regs am574x_idk_lisa_regs = {
103 .dmm_lisa_map_2 = 0xc0600200,
104 .dmm_lisa_map_3 = 0x80600100,
108 static const struct dmm_lisa_map_regs bbai_lisa_regs = {
109 .dmm_lisa_map_3 = 0x80640100,
113 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
115 if (board_is_am571x_idk())
116 *dmm_lisa_regs = &am571x_idk_lisa_regs;
117 else if (board_is_am574x_idk())
118 *dmm_lisa_regs = &am574x_idk_lisa_regs;
119 else if (board_is_bbai())
120 *dmm_lisa_regs = &bbai_lisa_regs;
122 *dmm_lisa_regs = &beagle_x15_lisa_regs;
125 static const struct emif_regs beagle_x15_emif1_ddr3_532mhz_emif_regs = {
126 .sdram_config_init = 0x61851b32,
127 .sdram_config = 0x61851b32,
128 .sdram_config2 = 0x08000000,
129 .ref_ctrl = 0x000040F1,
130 .ref_ctrl_final = 0x00001035,
131 .sdram_tim1 = 0xcccf36ab,
132 .sdram_tim2 = 0x308f7fda,
133 .sdram_tim3 = 0x409f88a8,
134 .read_idle_ctrl = 0x00050000,
135 .zq_config = 0x5007190b,
136 .temp_alert_config = 0x00000000,
137 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
138 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
139 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
140 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
141 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
142 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
143 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
144 .emif_rd_wr_lvl_rmp_win = 0x00000000,
145 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
146 .emif_rd_wr_lvl_ctl = 0x00000000,
147 .emif_rd_wr_exec_thresh = 0x00000305
150 /* Ext phy ctrl regs 1-35 */
151 static const u32 beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs[] = {
189 static const struct emif_regs beagle_x15_emif2_ddr3_532mhz_emif_regs = {
190 .sdram_config_init = 0x61851b32,
191 .sdram_config = 0x61851b32,
192 .sdram_config2 = 0x08000000,
193 .ref_ctrl = 0x000040F1,
194 .ref_ctrl_final = 0x00001035,
195 .sdram_tim1 = 0xcccf36b3,
196 .sdram_tim2 = 0x308f7fda,
197 .sdram_tim3 = 0x407f88a8,
198 .read_idle_ctrl = 0x00050000,
199 .zq_config = 0x5007190b,
200 .temp_alert_config = 0x00000000,
201 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
202 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
203 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
204 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
205 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
206 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
207 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
208 .emif_rd_wr_lvl_rmp_win = 0x00000000,
209 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
210 .emif_rd_wr_lvl_ctl = 0x00000000,
211 .emif_rd_wr_exec_thresh = 0x00000305
214 static const u32 beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs[] = {
252 static const struct emif_regs am571x_emif1_ddr3_666mhz_emif_regs = {
253 .sdram_config_init = 0x61863332,
254 .sdram_config = 0x61863332,
255 .sdram_config2 = 0x08000000,
256 .ref_ctrl = 0x0000514d,
257 .ref_ctrl_final = 0x0000144a,
258 .sdram_tim1 = 0xd333887c,
259 .sdram_tim2 = 0x30b37fe3,
260 .sdram_tim3 = 0x409f8ad8,
261 .read_idle_ctrl = 0x00050000,
262 .zq_config = 0x5007190b,
263 .temp_alert_config = 0x00000000,
264 .emif_ddr_phy_ctlr_1_init = 0x0024400f,
265 .emif_ddr_phy_ctlr_1 = 0x0e24400f,
266 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
267 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
268 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
269 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
270 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
271 .emif_rd_wr_lvl_rmp_win = 0x00000000,
272 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
273 .emif_rd_wr_lvl_ctl = 0x00000000,
274 .emif_rd_wr_exec_thresh = 0x00000305
277 static const struct emif_regs am574x_emif1_ddr3_666mhz_emif_ecc_regs = {
278 .sdram_config_init = 0x61863332,
279 .sdram_config = 0x61863332,
280 .sdram_config2 = 0x08000000,
281 .ref_ctrl = 0x0000514d,
282 .ref_ctrl_final = 0x0000144a,
283 .sdram_tim1 = 0xd333887c,
284 .sdram_tim2 = 0x30b37fe3,
285 .sdram_tim3 = 0x409f8ad8,
286 .read_idle_ctrl = 0x00050000,
287 .zq_config = 0x5007190b,
288 .temp_alert_config = 0x00000000,
289 .emif_ddr_phy_ctlr_1_init = 0x0024400f,
290 .emif_ddr_phy_ctlr_1 = 0x0e24400f,
291 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
292 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
293 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
294 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
295 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
296 .emif_rd_wr_lvl_rmp_win = 0x00000000,
297 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
298 .emif_rd_wr_lvl_ctl = 0x00000000,
299 .emif_rd_wr_exec_thresh = 0x00000305,
300 .emif_ecc_ctrl_reg = 0xD0000001,
301 .emif_ecc_address_range_1 = 0x3FFF0000,
302 .emif_ecc_address_range_2 = 0x00000000
305 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
309 if (board_is_am571x_idk())
310 *regs = &am571x_emif1_ddr3_666mhz_emif_regs;
311 else if (board_is_am574x_idk())
312 *regs = &am574x_emif1_ddr3_666mhz_emif_ecc_regs;
314 *regs = &beagle_x15_emif1_ddr3_532mhz_emif_regs;
317 if (board_is_am574x_idk())
318 *regs = &am571x_emif1_ddr3_666mhz_emif_regs;
320 *regs = &beagle_x15_emif2_ddr3_532mhz_emif_regs;
325 void emif_get_ext_phy_ctrl_const_regs(u32 emif_nr, const u32 **regs, u32 *size)
329 *regs = beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs;
330 *size = ARRAY_SIZE(beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs);
333 *regs = beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs;
334 *size = ARRAY_SIZE(beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs);
339 struct vcores_data beagle_x15_volts = {
340 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
341 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
342 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
343 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
344 .mpu.pmic = &tps659038,
345 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
347 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
348 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
349 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
350 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
351 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
352 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
353 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
354 .eve.addr = TPS659038_REG_ADDR_SMPS45,
355 .eve.pmic = &tps659038,
356 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
358 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
359 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
360 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
361 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
362 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
363 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
364 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
365 .gpu.addr = TPS659038_REG_ADDR_SMPS45,
366 .gpu.pmic = &tps659038,
367 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
369 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
370 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
371 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
372 .core.addr = TPS659038_REG_ADDR_SMPS6,
373 .core.pmic = &tps659038,
375 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
376 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
377 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
378 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
379 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
380 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
381 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
382 .iva.addr = TPS659038_REG_ADDR_SMPS45,
383 .iva.pmic = &tps659038,
384 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
387 struct vcores_data am572x_idk_volts = {
388 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
389 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
390 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
391 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
392 .mpu.pmic = &tps659038,
393 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
395 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
396 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
397 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
398 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
399 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
400 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
401 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
402 .eve.addr = TPS659038_REG_ADDR_SMPS45,
403 .eve.pmic = &tps659038,
404 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
406 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
407 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
408 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
409 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
410 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
411 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
412 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
413 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
414 .gpu.pmic = &tps659038,
415 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
417 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
418 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
419 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
420 .core.addr = TPS659038_REG_ADDR_SMPS7,
421 .core.pmic = &tps659038,
423 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
424 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
425 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
426 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
427 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
428 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
429 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
430 .iva.addr = TPS659038_REG_ADDR_SMPS8,
431 .iva.pmic = &tps659038,
432 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
435 struct vcores_data am571x_idk_volts = {
436 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
437 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
438 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
439 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
440 .mpu.pmic = &tps659038,
441 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
443 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
444 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
445 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
446 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
447 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
448 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
449 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
450 .eve.addr = TPS659038_REG_ADDR_SMPS45,
451 .eve.pmic = &tps659038,
452 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
454 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
455 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
456 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
457 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
458 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
459 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
460 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
461 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
462 .gpu.pmic = &tps659038,
463 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
465 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
466 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
467 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
468 .core.addr = TPS659038_REG_ADDR_SMPS7,
469 .core.pmic = &tps659038,
471 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
472 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
473 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
474 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
475 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
476 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
477 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
478 .iva.addr = TPS659038_REG_ADDR_SMPS45,
479 .iva.pmic = &tps659038,
480 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
483 int get_voltrail_opp(int rail_offset)
487 switch (rail_offset) {
498 opp = DRA7_DSPEVE_OPP;
511 #ifdef CONFIG_SPL_BUILD
512 /* No env to setup for SPL */
513 static inline void setup_board_eeprom_env(void) { }
515 /* Override function to read eeprom information */
516 void do_board_detect(void)
520 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
521 CONFIG_EEPROM_CHIP_ADDRESS);
523 printf("ti_i2c_eeprom_init failed %d\n", rc);
525 #ifdef CONFIG_SUPPORT_EMMC_BOOT
526 rc = board_bootmode_has_emmc();
528 rc = ti_emmc_boardid_get();
530 printf("ti_emmc_boardid_get failed %d\n", rc);
534 #else /* CONFIG_SPL_BUILD */
536 /* Override function to read eeprom information: actual i2c read done by SPL*/
537 void do_board_detect(void)
542 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
543 CONFIG_EEPROM_CHIP_ADDRESS);
545 printf("ti_i2c_eeprom_init failed %d\n", rc);
547 #ifdef CONFIG_SUPPORT_EMMC_BOOT
548 rc = board_bootmode_has_emmc();
550 rc = ti_emmc_boardid_get();
552 printf("ti_emmc_boardid_get failed %d\n", rc);
556 bname = "BeagleBoard X15";
557 else if (board_is_am572x_evm())
558 bname = "AM572x EVM";
559 else if (board_is_am574x_idk())
560 bname = "AM574x IDK";
561 else if (board_is_am572x_idk())
562 bname = "AM572x IDK";
563 else if (board_is_am571x_idk())
564 bname = "AM571x IDK";
565 else if (board_is_bbai())
566 bname = "BeagleBone AI";
569 snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
570 "Board: %s REV %s\n", bname, board_ti_get_rev());
573 static void setup_board_eeprom_env(void)
575 char *name = "beagle_x15";
578 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
579 CONFIG_EEPROM_CHIP_ADDRESS);
583 if (board_is_x15()) {
584 if (board_is_x15_revb1())
585 name = "beagle_x15_revb1";
586 else if (board_is_x15_revc())
587 name = "beagle_x15_revc";
590 } else if (board_is_am572x_evm()) {
591 if (board_is_am572x_evm_reva3())
592 name = "am57xx_evm_reva3";
595 } else if (board_is_am574x_idk()) {
597 } else if (board_is_am572x_idk()) {
599 } else if (board_is_am571x_idk()) {
601 } else if (board_is_bbai()) {
602 name = "am5729_beagleboneai";
604 printf("Unidentified board claims %s in eeprom header\n",
605 board_ti_get_name());
609 set_board_info_env(name);
612 #endif /* CONFIG_SPL_BUILD */
614 void vcores_init(void)
616 if (board_is_am572x_idk() || board_is_am574x_idk())
617 *omap_vcores = &am572x_idk_volts;
618 else if (board_is_am571x_idk())
619 *omap_vcores = &am571x_idk_volts;
621 *omap_vcores = &beagle_x15_volts;
624 void hw_data_init(void)
626 *prcm = &dra7xx_prcm;
628 *dplls_data = &dra72x_dplls;
629 else if (is_dra76x())
630 *dplls_data = &dra76x_dplls;
632 *dplls_data = &dra7xx_dplls;
633 *ctrl = &dra7xx_ctrl;
636 bool am571x_idk_needs_lcd(void)
640 gpio_request(GPIO_ETH_LCD, "nLCD_Detect");
641 if (gpio_get_value(GPIO_ETH_LCD))
646 gpio_free(GPIO_ETH_LCD);
654 gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100);
659 void am57x_idk_lcd_detect(void)
662 char *idk_lcd = "no";
665 /* Only valid for IDKs */
666 if (board_is_x15() || board_is_am572x_evm() || board_is_bbai())
669 /* Only AM571x IDK has gpio control detect.. so check that */
670 if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
673 r = i2c_get_chip_for_busnum(OSD_TS_FT_BUS_ADDRESS,
674 OSD_TS_FT_CHIP_ADDRESS, 1, &dev);
676 printf("%s: Failed to get I2C device %d/%d (ret %d)\n",
677 __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
679 /* AM572x IDK has no explicit settings for optional LCD kit */
680 if (board_is_am571x_idk())
681 printf("%s: Touch screen detect failed: %d!\n",
687 r = dm_i2c_reg_read(dev, OSD_TS_FT_REG_ID);
689 printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n",
690 __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
691 OSD_TS_FT_REG_ID, r);
696 case OSD_TS_FT_ID_5606:
697 idk_lcd = "osd101t2045";
699 case OSD_TS_FT_ID_5x46:
700 idk_lcd = "osd101t2587";
703 printf("%s: Unidentifed Touch screen ID 0x%02x\n",
705 /* we will let default be "no lcd" */
708 env_set("idk_lcd", idk_lcd);
712 #if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
713 static int device_okay(const char *path)
717 node = fdt_path_offset(gd->fdt_blob, path);
721 return fdtdec_get_is_enabled(gd->fdt_blob, node);
725 int board_late_init(void)
727 setup_board_eeprom_env();
732 * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
733 * This is the POWERHOLD-in-Low behavior.
735 palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);
738 * Default FIT boot on HS devices. Non FIT images are not allowed
741 if (get_device_type() == HS_DEVICE)
742 env_set("boot_fit", "1");
745 * Set the GPIO7 Pad to POWERHOLD. This has higher priority
746 * over DEV_CTRL.DEV_ON bit. This can be reset in case of
747 * PMIC Power off. So to be on the safer side set it back
748 * to POWERHOLD mode irrespective of the current state.
750 palmas_i2c_read_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
752 val = val | TPS65903X_PAD2_POWERHOLD_MASK;
753 palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
756 omap_die_id_serial();
757 omap_set_fastboot_vars();
759 am57x_idk_lcd_detect();
761 /* Just probe the potentially supported cdce913 device */
762 uclass_get_device(UCLASS_CLK, 0, &dev);
765 env_set("console", "ttyS0,115200n8");
767 #if !defined(CONFIG_SPL_BUILD)
768 board_ti_set_ethaddr(2);
771 #if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
772 if (device_okay("/ocp/omap_dwc3_1@48880000"))
773 enable_usb_clocks(0);
774 if (device_okay("/ocp/omap_dwc3_2@488c0000"))
775 enable_usb_clocks(1);
780 void set_muxconf_regs(void)
782 do_set_mux32((*ctrl)->control_padconf_core_base,
783 early_padconf, ARRAY_SIZE(early_padconf));
785 #ifdef CONFIG_SUPPORT_EMMC_BOOT
786 do_set_mux32((*ctrl)->control_padconf_core_base,
787 emmc_padconf, ARRAY_SIZE(emmc_padconf));
791 #ifdef CONFIG_IODELAY_RECALIBRATION
792 void recalibrate_iodelay(void)
794 const struct pad_conf_entry *pconf;
795 const struct iodelay_cfg_entry *iod, *delta_iod;
796 int pconf_sz, iod_sz, delta_iod_sz = 0;
799 if (board_is_am572x_idk()) {
800 pconf = core_padconf_array_essential_am572x_idk;
801 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am572x_idk);
802 iod = iodelay_cfg_array_am572x_idk;
803 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am572x_idk);
804 } else if (board_is_am574x_idk()) {
805 pconf = core_padconf_array_essential_am574x_idk;
806 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am574x_idk);
807 iod = iodelay_cfg_array_am574x_idk;
808 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am574x_idk);
809 } else if (board_is_am571x_idk()) {
810 pconf = core_padconf_array_essential_am571x_idk;
811 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am571x_idk);
812 iod = iodelay_cfg_array_am571x_idk;
813 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk);
814 } else if (board_is_bbai()) {
815 pconf = core_padconf_array_essential_bbai;
816 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_bbai);
817 iod = iodelay_cfg_array_bbai;
818 iod_sz = ARRAY_SIZE(iodelay_cfg_array_bbai);
820 /* Common for X15/GPEVM */
821 pconf = core_padconf_array_essential_x15;
822 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_x15);
823 /* There never was an SR1.0 X15.. So.. */
824 if (omap_revision() == DRA752_ES1_1) {
825 iod = iodelay_cfg_array_x15_sr1_1;
826 iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr1_1);
828 /* Since full production should switch to SR2.0 */
829 iod = iodelay_cfg_array_x15_sr2_0;
830 iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr2_0);
834 /* Setup I/O isolation */
835 ret = __recalibrate_iodelay_start();
839 /* Do the muxing here */
840 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
842 /* Now do the weird minor deltas that should be safe */
843 if (board_is_x15() || board_is_am572x_evm()) {
844 if (board_is_x15_revb1() || board_is_am572x_evm_reva3() ||
845 board_is_x15_revc()) {
846 pconf = core_padconf_array_delta_x15_sr2_0;
847 pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr2_0);
849 pconf = core_padconf_array_delta_x15_sr1_1;
850 pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr1_1);
852 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
855 if (board_is_am571x_idk()) {
856 if (am571x_idk_needs_lcd()) {
857 pconf = core_padconf_array_vout_am571x_idk;
858 pconf_sz = ARRAY_SIZE(core_padconf_array_vout_am571x_idk);
859 delta_iod = iodelay_cfg_array_am571x_idk_4port;
860 delta_iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk_4port);
863 pconf = core_padconf_array_icss1eth_am571x_idk;
864 pconf_sz = ARRAY_SIZE(core_padconf_array_icss1eth_am571x_idk);
866 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
869 /* Setup IOdelay configuration */
870 ret = do_set_iodelay((*ctrl)->iodelay_config_base, iod, iod_sz);
872 ret = do_set_iodelay((*ctrl)->iodelay_config_base, delta_iod,
876 /* Closeup.. remove isolation */
877 __recalibrate_iodelay_end(ret);
881 #if defined(CONFIG_MMC)
882 int board_mmc_init(bd_t *bis)
884 omap_mmc_init(0, 0, 0, -1, -1);
885 omap_mmc_init(1, 0, 0, -1, -1);
889 static const struct mmc_platform_fixups am57x_es1_1_mmc1_fixups = {
891 .unsupported_caps = MMC_CAP(MMC_HS_200) |
893 .max_freq = 96000000,
896 static const struct mmc_platform_fixups am57x_es1_1_mmc23_fixups = {
898 .unsupported_caps = MMC_CAP(MMC_HS_200) |
899 MMC_CAP(UHS_SDR104) |
901 .max_freq = 48000000,
904 const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr)
906 switch (omap_revision()) {
909 if (addr == OMAP_HSMMC1_BASE)
910 return &am57x_es1_1_mmc1_fixups;
912 return &am57x_es1_1_mmc23_fixups;
919 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
920 int spl_start_uboot(void)
922 /* break into full u-boot on 'c' */
923 if (serial_tstc() && serial_getc() == 'c')
926 #ifdef CONFIG_SPL_ENV_SUPPORT
929 if (env_get_yesno("boot_os") != 1)
937 #ifdef CONFIG_DRIVER_TI_CPSW
939 /* Delay value to add to calibrated value */
940 #define RGMII0_TXCTL_DLY_VAL ((0x3 << 5) + 0x8)
941 #define RGMII0_TXD0_DLY_VAL ((0x3 << 5) + 0x8)
942 #define RGMII0_TXD1_DLY_VAL ((0x3 << 5) + 0x2)
943 #define RGMII0_TXD2_DLY_VAL ((0x4 << 5) + 0x0)
944 #define RGMII0_TXD3_DLY_VAL ((0x4 << 5) + 0x0)
945 #define VIN2A_D13_DLY_VAL ((0x3 << 5) + 0x8)
946 #define VIN2A_D17_DLY_VAL ((0x3 << 5) + 0x8)
947 #define VIN2A_D16_DLY_VAL ((0x3 << 5) + 0x2)
948 #define VIN2A_D15_DLY_VAL ((0x4 << 5) + 0x0)
949 #define VIN2A_D14_DLY_VAL ((0x4 << 5) + 0x0)
951 static void cpsw_control(int enabled)
953 /* VTP can be added here */
956 static struct cpsw_slave_data cpsw_slaves[] = {
958 .slave_reg_ofs = 0x208,
959 .sliver_reg_ofs = 0xd80,
963 .slave_reg_ofs = 0x308,
964 .sliver_reg_ofs = 0xdc0,
969 static struct cpsw_platform_data cpsw_data = {
970 .mdio_base = CPSW_MDIO_BASE,
971 .cpsw_base = CPSW_BASE,
974 .cpdma_reg_ofs = 0x800,
976 .slave_data = cpsw_slaves,
977 .ale_reg_ofs = 0xd00,
979 .host_port_reg_ofs = 0x108,
980 .hw_stats_reg_ofs = 0x900,
981 .bd_ram_ofs = 0x2000,
982 .mac_control = (1 << 5),
983 .control = cpsw_control,
985 .version = CPSW_CTRL_VERSION_2,
988 static u64 mac_to_u64(u8 mac[6])
993 for (i = 0; i < 6; i++) {
1001 static void u64_to_mac(u64 addr, u8 mac[6])
1005 mac[3] = addr >> 16;
1006 mac[2] = addr >> 24;
1007 mac[1] = addr >> 32;
1008 mac[0] = addr >> 40;
1011 int board_eth_init(bd_t *bis)
1014 uint8_t mac_addr[6];
1015 uint32_t mac_hi, mac_lo;
1019 u8 mac_addr1[6], mac_addr2[6];
1022 /* try reading mac address from efuse */
1023 mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
1024 mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
1025 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
1026 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
1027 mac_addr[2] = mac_hi & 0xFF;
1028 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
1029 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
1030 mac_addr[5] = mac_lo & 0xFF;
1032 if (!env_get("ethaddr")) {
1033 printf("<ethaddr> not set. Validating first E-fuse MAC\n");
1035 if (is_valid_ethaddr(mac_addr))
1036 eth_env_set_enetaddr("ethaddr", mac_addr);
1039 mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
1040 mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
1041 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
1042 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
1043 mac_addr[2] = mac_hi & 0xFF;
1044 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
1045 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
1046 mac_addr[5] = mac_lo & 0xFF;
1048 if (!env_get("eth1addr")) {
1049 if (is_valid_ethaddr(mac_addr))
1050 eth_env_set_enetaddr("eth1addr", mac_addr);
1053 ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
1055 writel(ctrl_val, (*ctrl)->control_core_control_io1);
1057 /* The phy address for the AM57xx IDK are different than x15 */
1058 if (board_is_am572x_idk() || board_is_am571x_idk() ||
1059 board_is_am574x_idk()) {
1060 cpsw_data.slave_data[0].phy_addr = 0;
1061 cpsw_data.slave_data[1].phy_addr = 1;
1064 ret = cpsw_register(&cpsw_data);
1066 printf("Error %d registering CPSW switch\n", ret);
1069 * Export any Ethernet MAC addresses from EEPROM.
1070 * On AM57xx the 2 MAC addresses define the address range
1072 board_ti_get_eth_mac_addr(0, mac_addr1);
1073 board_ti_get_eth_mac_addr(1, mac_addr2);
1075 if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) {
1076 mac1 = mac_to_u64(mac_addr1);
1077 mac2 = mac_to_u64(mac_addr2);
1079 /* must contain an address range */
1080 num_macs = mac2 - mac1 + 1;
1081 /* <= 50 to protect against user programming error */
1082 if (num_macs > 0 && num_macs <= 50) {
1083 for (i = 0; i < num_macs; i++) {
1084 u64_to_mac(mac1 + i, mac_addr);
1085 if (is_valid_ethaddr(mac_addr)) {
1086 eth_env_set_enetaddr_by_index("eth",
1098 #ifdef CONFIG_BOARD_EARLY_INIT_F
1099 /* VTT regulator enable */
1100 static inline void vtt_regulator_enable(void)
1102 if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
1105 gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
1106 gpio_direction_output(GPIO_DDR_VTT_EN, 1);
1109 int board_early_init_f(void)
1111 vtt_regulator_enable();
1116 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
1117 int ft_board_setup(void *blob, bd_t *bd)
1119 ft_cpu_setup(blob, bd);
1125 #ifdef CONFIG_SPL_LOAD_FIT
1126 int board_fit_config_name_match(const char *name)
1128 if (board_is_x15()) {
1129 if (board_is_x15_revb1()) {
1130 if (!strcmp(name, "am57xx-beagle-x15-revb1"))
1132 } else if (board_is_x15_revc()) {
1133 if (!strcmp(name, "am57xx-beagle-x15-revc"))
1135 } else if (!strcmp(name, "am57xx-beagle-x15")) {
1138 } else if (board_is_am572x_evm() &&
1139 !strcmp(name, "am57xx-beagle-x15")) {
1141 } else if (board_is_am572x_idk() && !strcmp(name, "am572x-idk")) {
1143 } else if (board_is_am574x_idk() && !strcmp(name, "am574x-idk")) {
1145 } else if (board_is_am571x_idk() && !strcmp(name, "am571x-idk")) {
1147 } else if (board_is_bbai() && !strcmp(name, "am5729-beagleboneai")) {
1155 #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
1156 int fastboot_set_reboot_flag(void)
1158 printf("Setting reboot to fastboot flag ...\n");
1159 env_set("dofastboot", "1");
1165 #ifdef CONFIG_SUPPORT_EMMC_BOOT
1166 static int board_bootmode_has_emmc(void)
1168 /* Check that boot mode is same as BBAI */
1169 if (gd->arch.omap_boot_mode != 2)
1176 #ifdef CONFIG_TI_SECURE_DEVICE
1177 void board_fit_image_post_process(void **p_image, size_t *p_size)
1179 secure_boot_verify_image(p_image, p_size);
1182 void board_tee_image_process(ulong tee_image, size_t tee_size)
1184 secure_tee_install((u32)tee_image);
1187 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);