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>
18 #include <asm/omap_common.h>
19 #include <asm/omap_sec_common.h>
22 #include <asm/arch/gpio.h>
23 #include <asm/arch/clock.h>
24 #include <asm/arch/dra7xx_iodelay.h>
25 #include <asm/arch/sys_proto.h>
26 #include <asm/arch/mmc_host_def.h>
27 #include <asm/arch/sata.h>
28 #include <asm/arch/gpio.h>
29 #include <asm/arch/omap.h>
31 #include <linux/usb/gadget.h>
32 #include <dwc3-uboot.h>
33 #include <dwc3-omap-uboot.h>
34 #include <ti-usb-phy-uboot.h>
36 #include <dm/uclass.h>
38 #include "../common/board_detect.h"
41 #define board_is_x15() board_ti_is("BBRDX15_")
42 #define board_is_x15_revb1() (board_ti_is("BBRDX15_") && \
43 !strncmp("B.10", board_ti_get_rev(), 3))
44 #define board_is_x15_revc() (board_ti_is("BBRDX15_") && \
45 !strncmp("C.00", board_ti_get_rev(), 3))
46 #define board_is_am572x_evm() board_ti_is("AM572PM_")
47 #define board_is_am572x_evm_reva3() \
48 (board_ti_is("AM572PM_") && \
49 !strncmp("A.30", board_ti_get_rev(), 3))
50 #define board_is_am574x_idk() board_ti_is("AM574IDK")
51 #define board_is_am572x_idk() board_ti_is("AM572IDK")
52 #define board_is_am571x_idk() board_ti_is("AM571IDK")
54 #ifdef CONFIG_DRIVER_TI_CPSW
58 DECLARE_GLOBAL_DATA_PTR;
60 #define GPIO_ETH_LCD GPIO_TO_PIN(2, 22)
62 #define GPIO_DDR_VTT_EN 203
64 /* Touch screen controller to identify the LCD */
65 #define OSD_TS_FT_BUS_ADDRESS 0
66 #define OSD_TS_FT_CHIP_ADDRESS 0x38
67 #define OSD_TS_FT_REG_ID 0xA3
69 * Touchscreen IDs for various OSD panels
70 * Ref: http://www.osddisplays.com/TI/OSD101T2587-53TS_A.1.pdf
72 /* Used on newer osd101t2587 Panels */
73 #define OSD_TS_FT_ID_5x46 0x54
74 /* Used on older osd101t2045 Panels */
75 #define OSD_TS_FT_ID_5606 0x08
77 #define SYSINFO_BOARD_NAME_MAX_LEN 45
79 #define TPS65903X_PRIMARY_SECONDARY_PAD2 0xFB
80 #define TPS65903X_PAD2_POWERHOLD_MASK 0x20
82 const struct omap_sysinfo sysinfo = {
83 "Board: UNKNOWN(BeagleBoard X15?) REV UNKNOWN\n"
86 static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = {
87 .dmm_lisa_map_3 = 0x80740300,
91 static const struct dmm_lisa_map_regs am571x_idk_lisa_regs = {
92 .dmm_lisa_map_3 = 0x80640100,
96 static const struct dmm_lisa_map_regs am574x_idk_lisa_regs = {
97 .dmm_lisa_map_2 = 0xc0600200,
98 .dmm_lisa_map_3 = 0x80600100,
102 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
104 if (board_is_am571x_idk())
105 *dmm_lisa_regs = &am571x_idk_lisa_regs;
106 else if (board_is_am574x_idk())
107 *dmm_lisa_regs = &am574x_idk_lisa_regs;
109 *dmm_lisa_regs = &beagle_x15_lisa_regs;
112 static const struct emif_regs beagle_x15_emif1_ddr3_532mhz_emif_regs = {
113 .sdram_config_init = 0x61851b32,
114 .sdram_config = 0x61851b32,
115 .sdram_config2 = 0x08000000,
116 .ref_ctrl = 0x000040F1,
117 .ref_ctrl_final = 0x00001035,
118 .sdram_tim1 = 0xcccf36ab,
119 .sdram_tim2 = 0x308f7fda,
120 .sdram_tim3 = 0x409f88a8,
121 .read_idle_ctrl = 0x00050000,
122 .zq_config = 0x5007190b,
123 .temp_alert_config = 0x00000000,
124 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
125 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
126 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
127 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
128 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
129 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
130 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
131 .emif_rd_wr_lvl_rmp_win = 0x00000000,
132 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
133 .emif_rd_wr_lvl_ctl = 0x00000000,
134 .emif_rd_wr_exec_thresh = 0x00000305
137 /* Ext phy ctrl regs 1-35 */
138 static const u32 beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs[] = {
176 static const struct emif_regs beagle_x15_emif2_ddr3_532mhz_emif_regs = {
177 .sdram_config_init = 0x61851b32,
178 .sdram_config = 0x61851b32,
179 .sdram_config2 = 0x08000000,
180 .ref_ctrl = 0x000040F1,
181 .ref_ctrl_final = 0x00001035,
182 .sdram_tim1 = 0xcccf36b3,
183 .sdram_tim2 = 0x308f7fda,
184 .sdram_tim3 = 0x407f88a8,
185 .read_idle_ctrl = 0x00050000,
186 .zq_config = 0x5007190b,
187 .temp_alert_config = 0x00000000,
188 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
189 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
190 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
191 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
192 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
193 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
194 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
195 .emif_rd_wr_lvl_rmp_win = 0x00000000,
196 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
197 .emif_rd_wr_lvl_ctl = 0x00000000,
198 .emif_rd_wr_exec_thresh = 0x00000305
201 static const u32 beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs[] = {
239 static const struct emif_regs am571x_emif1_ddr3_666mhz_emif_regs = {
240 .sdram_config_init = 0x61863332,
241 .sdram_config = 0x61863332,
242 .sdram_config2 = 0x08000000,
243 .ref_ctrl = 0x0000514d,
244 .ref_ctrl_final = 0x0000144a,
245 .sdram_tim1 = 0xd333887c,
246 .sdram_tim2 = 0x30b37fe3,
247 .sdram_tim3 = 0x409f8ad8,
248 .read_idle_ctrl = 0x00050000,
249 .zq_config = 0x5007190b,
250 .temp_alert_config = 0x00000000,
251 .emif_ddr_phy_ctlr_1_init = 0x0024400f,
252 .emif_ddr_phy_ctlr_1 = 0x0e24400f,
253 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
254 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
255 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
256 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
257 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
258 .emif_rd_wr_lvl_rmp_win = 0x00000000,
259 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
260 .emif_rd_wr_lvl_ctl = 0x00000000,
261 .emif_rd_wr_exec_thresh = 0x00000305
264 static const struct emif_regs am574x_emif1_ddr3_666mhz_emif_ecc_regs = {
265 .sdram_config_init = 0x61863332,
266 .sdram_config = 0x61863332,
267 .sdram_config2 = 0x08000000,
268 .ref_ctrl = 0x0000514d,
269 .ref_ctrl_final = 0x0000144a,
270 .sdram_tim1 = 0xd333887c,
271 .sdram_tim2 = 0x30b37fe3,
272 .sdram_tim3 = 0x409f8ad8,
273 .read_idle_ctrl = 0x00050000,
274 .zq_config = 0x5007190b,
275 .temp_alert_config = 0x00000000,
276 .emif_ddr_phy_ctlr_1_init = 0x0024400f,
277 .emif_ddr_phy_ctlr_1 = 0x0e24400f,
278 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
279 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
280 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
281 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
282 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
283 .emif_rd_wr_lvl_rmp_win = 0x00000000,
284 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
285 .emif_rd_wr_lvl_ctl = 0x00000000,
286 .emif_rd_wr_exec_thresh = 0x00000305,
287 .emif_ecc_ctrl_reg = 0xD0000001,
288 .emif_ecc_address_range_1 = 0x3FFF0000,
289 .emif_ecc_address_range_2 = 0x00000000
292 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
296 if (board_is_am571x_idk())
297 *regs = &am571x_emif1_ddr3_666mhz_emif_regs;
298 else if (board_is_am574x_idk())
299 *regs = &am574x_emif1_ddr3_666mhz_emif_ecc_regs;
301 *regs = &beagle_x15_emif1_ddr3_532mhz_emif_regs;
304 if (board_is_am574x_idk())
305 *regs = &am571x_emif1_ddr3_666mhz_emif_regs;
307 *regs = &beagle_x15_emif2_ddr3_532mhz_emif_regs;
312 void emif_get_ext_phy_ctrl_const_regs(u32 emif_nr, const u32 **regs, u32 *size)
316 *regs = beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs;
317 *size = ARRAY_SIZE(beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs);
320 *regs = beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs;
321 *size = ARRAY_SIZE(beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs);
326 struct vcores_data beagle_x15_volts = {
327 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
328 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
329 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
330 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
331 .mpu.pmic = &tps659038,
332 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
334 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
335 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
336 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
337 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
338 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
339 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
340 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
341 .eve.addr = TPS659038_REG_ADDR_SMPS45,
342 .eve.pmic = &tps659038,
343 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
345 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
346 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
347 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
348 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
349 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
350 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
351 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
352 .gpu.addr = TPS659038_REG_ADDR_SMPS45,
353 .gpu.pmic = &tps659038,
354 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
356 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
357 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
358 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
359 .core.addr = TPS659038_REG_ADDR_SMPS6,
360 .core.pmic = &tps659038,
362 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
363 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
364 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
365 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
366 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
367 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
368 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
369 .iva.addr = TPS659038_REG_ADDR_SMPS45,
370 .iva.pmic = &tps659038,
371 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
374 struct vcores_data am572x_idk_volts = {
375 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
376 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
377 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
378 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
379 .mpu.pmic = &tps659038,
380 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
382 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
383 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
384 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
385 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
386 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
387 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
388 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
389 .eve.addr = TPS659038_REG_ADDR_SMPS45,
390 .eve.pmic = &tps659038,
391 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
393 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
394 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
395 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
396 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
397 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
398 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
399 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
400 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
401 .gpu.pmic = &tps659038,
402 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
404 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
405 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
406 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
407 .core.addr = TPS659038_REG_ADDR_SMPS7,
408 .core.pmic = &tps659038,
410 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
411 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
412 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
413 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
414 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
415 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
416 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
417 .iva.addr = TPS659038_REG_ADDR_SMPS8,
418 .iva.pmic = &tps659038,
419 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
422 struct vcores_data am571x_idk_volts = {
423 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
424 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
425 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
426 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
427 .mpu.pmic = &tps659038,
428 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
430 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
431 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
432 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
433 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
434 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
435 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
436 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
437 .eve.addr = TPS659038_REG_ADDR_SMPS45,
438 .eve.pmic = &tps659038,
439 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
441 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
442 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
443 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
444 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
445 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
446 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
447 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
448 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
449 .gpu.pmic = &tps659038,
450 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
452 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
453 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
454 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
455 .core.addr = TPS659038_REG_ADDR_SMPS7,
456 .core.pmic = &tps659038,
458 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
459 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
460 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
461 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
462 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
463 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
464 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
465 .iva.addr = TPS659038_REG_ADDR_SMPS45,
466 .iva.pmic = &tps659038,
467 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
470 int get_voltrail_opp(int rail_offset)
474 switch (rail_offset) {
485 opp = DRA7_DSPEVE_OPP;
498 #ifdef CONFIG_SPL_BUILD
499 /* No env to setup for SPL */
500 static inline void setup_board_eeprom_env(void) { }
502 /* Override function to read eeprom information */
503 void do_board_detect(void)
507 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
508 CONFIG_EEPROM_CHIP_ADDRESS);
510 printf("ti_i2c_eeprom_init failed %d\n", rc);
513 #else /* CONFIG_SPL_BUILD */
515 /* Override function to read eeprom information: actual i2c read done by SPL*/
516 void do_board_detect(void)
521 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
522 CONFIG_EEPROM_CHIP_ADDRESS);
524 printf("ti_i2c_eeprom_init failed %d\n", rc);
527 bname = "BeagleBoard X15";
528 else if (board_is_am572x_evm())
529 bname = "AM572x EVM";
530 else if (board_is_am574x_idk())
531 bname = "AM574x IDK";
532 else if (board_is_am572x_idk())
533 bname = "AM572x IDK";
534 else if (board_is_am571x_idk())
535 bname = "AM571x IDK";
538 snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
539 "Board: %s REV %s\n", bname, board_ti_get_rev());
542 static void setup_board_eeprom_env(void)
544 char *name = "beagle_x15";
547 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
548 CONFIG_EEPROM_CHIP_ADDRESS);
552 if (board_is_x15()) {
553 if (board_is_x15_revb1())
554 name = "beagle_x15_revb1";
555 else if (board_is_x15_revc())
556 name = "beagle_x15_revc";
559 } else if (board_is_am572x_evm()) {
560 if (board_is_am572x_evm_reva3())
561 name = "am57xx_evm_reva3";
564 } else if (board_is_am574x_idk()) {
566 } else if (board_is_am572x_idk()) {
568 } else if (board_is_am571x_idk()) {
571 printf("Unidentified board claims %s in eeprom header\n",
572 board_ti_get_name());
576 set_board_info_env(name);
579 #endif /* CONFIG_SPL_BUILD */
581 void vcores_init(void)
583 if (board_is_am572x_idk() || board_is_am574x_idk())
584 *omap_vcores = &am572x_idk_volts;
585 else if (board_is_am571x_idk())
586 *omap_vcores = &am571x_idk_volts;
588 *omap_vcores = &beagle_x15_volts;
591 void hw_data_init(void)
593 *prcm = &dra7xx_prcm;
595 *dplls_data = &dra72x_dplls;
596 else if (is_dra76x())
597 *dplls_data = &dra76x_dplls;
599 *dplls_data = &dra7xx_dplls;
600 *ctrl = &dra7xx_ctrl;
603 bool am571x_idk_needs_lcd(void)
607 gpio_request(GPIO_ETH_LCD, "nLCD_Detect");
608 if (gpio_get_value(GPIO_ETH_LCD))
613 gpio_free(GPIO_ETH_LCD);
621 gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100);
626 void am57x_idk_lcd_detect(void)
629 char *idk_lcd = "no";
632 /* Only valid for IDKs */
633 if (board_is_x15() || board_is_am572x_evm())
636 /* Only AM571x IDK has gpio control detect.. so check that */
637 if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
640 r = i2c_get_chip_for_busnum(OSD_TS_FT_BUS_ADDRESS,
641 OSD_TS_FT_CHIP_ADDRESS, 1, &dev);
643 printf("%s: Failed to get I2C device %d/%d (ret %d)\n",
644 __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
646 /* AM572x IDK has no explicit settings for optional LCD kit */
647 if (board_is_am571x_idk())
648 printf("%s: Touch screen detect failed: %d!\n",
654 r = dm_i2c_reg_read(dev, OSD_TS_FT_REG_ID);
656 printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n",
657 __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
658 OSD_TS_FT_REG_ID, r);
663 case OSD_TS_FT_ID_5606:
664 idk_lcd = "osd101t2045";
666 case OSD_TS_FT_ID_5x46:
667 idk_lcd = "osd101t2587";
670 printf("%s: Unidentifed Touch screen ID 0x%02x\n",
672 /* we will let default be "no lcd" */
675 env_set("idk_lcd", idk_lcd);
679 #if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
680 static int device_okay(const char *path)
684 node = fdt_path_offset(gd->fdt_blob, path);
688 return fdtdec_get_is_enabled(gd->fdt_blob, node);
692 int board_late_init(void)
694 setup_board_eeprom_env();
699 * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
700 * This is the POWERHOLD-in-Low behavior.
702 palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);
705 * Default FIT boot on HS devices. Non FIT images are not allowed
708 if (get_device_type() == HS_DEVICE)
709 env_set("boot_fit", "1");
712 * Set the GPIO7 Pad to POWERHOLD. This has higher priority
713 * over DEV_CTRL.DEV_ON bit. This can be reset in case of
714 * PMIC Power off. So to be on the safer side set it back
715 * to POWERHOLD mode irrespective of the current state.
717 palmas_i2c_read_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
719 val = val | TPS65903X_PAD2_POWERHOLD_MASK;
720 palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
723 omap_die_id_serial();
724 omap_set_fastboot_vars();
726 am57x_idk_lcd_detect();
728 /* Just probe the potentially supported cdce913 device */
729 uclass_get_device(UCLASS_CLK, 0, &dev);
731 #if !defined(CONFIG_SPL_BUILD)
732 board_ti_set_ethaddr(2);
735 #if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
736 if (device_okay("/ocp/omap_dwc3_1@48880000"))
737 enable_usb_clocks(0);
738 if (device_okay("/ocp/omap_dwc3_2@488c0000"))
739 enable_usb_clocks(1);
744 void set_muxconf_regs(void)
746 do_set_mux32((*ctrl)->control_padconf_core_base,
747 early_padconf, ARRAY_SIZE(early_padconf));
750 #ifdef CONFIG_IODELAY_RECALIBRATION
751 void recalibrate_iodelay(void)
753 const struct pad_conf_entry *pconf;
754 const struct iodelay_cfg_entry *iod, *delta_iod;
755 int pconf_sz, iod_sz, delta_iod_sz = 0;
758 if (board_is_am572x_idk()) {
759 pconf = core_padconf_array_essential_am572x_idk;
760 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am572x_idk);
761 iod = iodelay_cfg_array_am572x_idk;
762 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am572x_idk);
763 } else if (board_is_am574x_idk()) {
764 pconf = core_padconf_array_essential_am574x_idk;
765 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am574x_idk);
766 iod = iodelay_cfg_array_am574x_idk;
767 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am574x_idk);
768 } else if (board_is_am571x_idk()) {
769 pconf = core_padconf_array_essential_am571x_idk;
770 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am571x_idk);
771 iod = iodelay_cfg_array_am571x_idk;
772 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk);
774 /* Common for X15/GPEVM */
775 pconf = core_padconf_array_essential_x15;
776 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_x15);
777 /* There never was an SR1.0 X15.. So.. */
778 if (omap_revision() == DRA752_ES1_1) {
779 iod = iodelay_cfg_array_x15_sr1_1;
780 iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr1_1);
782 /* Since full production should switch to SR2.0 */
783 iod = iodelay_cfg_array_x15_sr2_0;
784 iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr2_0);
788 /* Setup I/O isolation */
789 ret = __recalibrate_iodelay_start();
793 /* Do the muxing here */
794 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
796 /* Now do the weird minor deltas that should be safe */
797 if (board_is_x15() || board_is_am572x_evm()) {
798 if (board_is_x15_revb1() || board_is_am572x_evm_reva3() ||
799 board_is_x15_revc()) {
800 pconf = core_padconf_array_delta_x15_sr2_0;
801 pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr2_0);
803 pconf = core_padconf_array_delta_x15_sr1_1;
804 pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr1_1);
806 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
809 if (board_is_am571x_idk()) {
810 if (am571x_idk_needs_lcd()) {
811 pconf = core_padconf_array_vout_am571x_idk;
812 pconf_sz = ARRAY_SIZE(core_padconf_array_vout_am571x_idk);
813 delta_iod = iodelay_cfg_array_am571x_idk_4port;
814 delta_iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk_4port);
817 pconf = core_padconf_array_icss1eth_am571x_idk;
818 pconf_sz = ARRAY_SIZE(core_padconf_array_icss1eth_am571x_idk);
820 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
823 /* Setup IOdelay configuration */
824 ret = do_set_iodelay((*ctrl)->iodelay_config_base, iod, iod_sz);
826 ret = do_set_iodelay((*ctrl)->iodelay_config_base, delta_iod,
830 /* Closeup.. remove isolation */
831 __recalibrate_iodelay_end(ret);
835 #if defined(CONFIG_MMC)
836 int board_mmc_init(bd_t *bis)
838 omap_mmc_init(0, 0, 0, -1, -1);
839 omap_mmc_init(1, 0, 0, -1, -1);
843 static const struct mmc_platform_fixups am57x_es1_1_mmc1_fixups = {
845 .unsupported_caps = MMC_CAP(MMC_HS_200) |
847 .max_freq = 96000000,
850 static const struct mmc_platform_fixups am57x_es1_1_mmc23_fixups = {
852 .unsupported_caps = MMC_CAP(MMC_HS_200) |
853 MMC_CAP(UHS_SDR104) |
855 .max_freq = 48000000,
858 const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr)
860 switch (omap_revision()) {
863 if (addr == OMAP_HSMMC1_BASE)
864 return &am57x_es1_1_mmc1_fixups;
866 return &am57x_es1_1_mmc23_fixups;
873 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
874 int spl_start_uboot(void)
876 /* break into full u-boot on 'c' */
877 if (serial_tstc() && serial_getc() == 'c')
880 #ifdef CONFIG_SPL_ENV_SUPPORT
883 if (env_get_yesno("boot_os") != 1)
891 #ifdef CONFIG_DRIVER_TI_CPSW
893 /* Delay value to add to calibrated value */
894 #define RGMII0_TXCTL_DLY_VAL ((0x3 << 5) + 0x8)
895 #define RGMII0_TXD0_DLY_VAL ((0x3 << 5) + 0x8)
896 #define RGMII0_TXD1_DLY_VAL ((0x3 << 5) + 0x2)
897 #define RGMII0_TXD2_DLY_VAL ((0x4 << 5) + 0x0)
898 #define RGMII0_TXD3_DLY_VAL ((0x4 << 5) + 0x0)
899 #define VIN2A_D13_DLY_VAL ((0x3 << 5) + 0x8)
900 #define VIN2A_D17_DLY_VAL ((0x3 << 5) + 0x8)
901 #define VIN2A_D16_DLY_VAL ((0x3 << 5) + 0x2)
902 #define VIN2A_D15_DLY_VAL ((0x4 << 5) + 0x0)
903 #define VIN2A_D14_DLY_VAL ((0x4 << 5) + 0x0)
905 static void cpsw_control(int enabled)
907 /* VTP can be added here */
910 static struct cpsw_slave_data cpsw_slaves[] = {
912 .slave_reg_ofs = 0x208,
913 .sliver_reg_ofs = 0xd80,
917 .slave_reg_ofs = 0x308,
918 .sliver_reg_ofs = 0xdc0,
923 static struct cpsw_platform_data cpsw_data = {
924 .mdio_base = CPSW_MDIO_BASE,
925 .cpsw_base = CPSW_BASE,
928 .cpdma_reg_ofs = 0x800,
930 .slave_data = cpsw_slaves,
931 .ale_reg_ofs = 0xd00,
933 .host_port_reg_ofs = 0x108,
934 .hw_stats_reg_ofs = 0x900,
935 .bd_ram_ofs = 0x2000,
936 .mac_control = (1 << 5),
937 .control = cpsw_control,
939 .version = CPSW_CTRL_VERSION_2,
942 static u64 mac_to_u64(u8 mac[6])
947 for (i = 0; i < 6; i++) {
955 static void u64_to_mac(u64 addr, u8 mac[6])
965 int board_eth_init(bd_t *bis)
969 uint32_t mac_hi, mac_lo;
973 u8 mac_addr1[6], mac_addr2[6];
976 /* try reading mac address from efuse */
977 mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
978 mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
979 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
980 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
981 mac_addr[2] = mac_hi & 0xFF;
982 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
983 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
984 mac_addr[5] = mac_lo & 0xFF;
986 if (!env_get("ethaddr")) {
987 printf("<ethaddr> not set. Validating first E-fuse MAC\n");
989 if (is_valid_ethaddr(mac_addr))
990 eth_env_set_enetaddr("ethaddr", mac_addr);
993 mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
994 mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
995 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
996 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
997 mac_addr[2] = mac_hi & 0xFF;
998 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
999 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
1000 mac_addr[5] = mac_lo & 0xFF;
1002 if (!env_get("eth1addr")) {
1003 if (is_valid_ethaddr(mac_addr))
1004 eth_env_set_enetaddr("eth1addr", mac_addr);
1007 ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
1009 writel(ctrl_val, (*ctrl)->control_core_control_io1);
1011 /* The phy address for the AM57xx IDK are different than x15 */
1012 if (board_is_am572x_idk() || board_is_am571x_idk() ||
1013 board_is_am574x_idk()) {
1014 cpsw_data.slave_data[0].phy_addr = 0;
1015 cpsw_data.slave_data[1].phy_addr = 1;
1018 ret = cpsw_register(&cpsw_data);
1020 printf("Error %d registering CPSW switch\n", ret);
1023 * Export any Ethernet MAC addresses from EEPROM.
1024 * On AM57xx the 2 MAC addresses define the address range
1026 board_ti_get_eth_mac_addr(0, mac_addr1);
1027 board_ti_get_eth_mac_addr(1, mac_addr2);
1029 if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) {
1030 mac1 = mac_to_u64(mac_addr1);
1031 mac2 = mac_to_u64(mac_addr2);
1033 /* must contain an address range */
1034 num_macs = mac2 - mac1 + 1;
1035 /* <= 50 to protect against user programming error */
1036 if (num_macs > 0 && num_macs <= 50) {
1037 for (i = 0; i < num_macs; i++) {
1038 u64_to_mac(mac1 + i, mac_addr);
1039 if (is_valid_ethaddr(mac_addr)) {
1040 eth_env_set_enetaddr_by_index("eth",
1052 #ifdef CONFIG_BOARD_EARLY_INIT_F
1053 /* VTT regulator enable */
1054 static inline void vtt_regulator_enable(void)
1056 if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
1059 gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
1060 gpio_direction_output(GPIO_DDR_VTT_EN, 1);
1063 int board_early_init_f(void)
1065 vtt_regulator_enable();
1070 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
1071 int ft_board_setup(void *blob, bd_t *bd)
1073 ft_cpu_setup(blob, bd);
1079 #ifdef CONFIG_SPL_LOAD_FIT
1080 int board_fit_config_name_match(const char *name)
1082 if (board_is_x15()) {
1083 if (board_is_x15_revb1()) {
1084 if (!strcmp(name, "am57xx-beagle-x15-revb1"))
1086 } else if (board_is_x15_revc()) {
1087 if (!strcmp(name, "am57xx-beagle-x15-revc"))
1089 } else if (!strcmp(name, "am57xx-beagle-x15")) {
1092 } else if (board_is_am572x_evm() &&
1093 !strcmp(name, "am57xx-beagle-x15")) {
1095 } else if (board_is_am572x_idk() && !strcmp(name, "am572x-idk")) {
1097 } else if (board_is_am574x_idk() && !strcmp(name, "am574x-idk")) {
1099 } else if (board_is_am571x_idk() && !strcmp(name, "am571x-idk")) {
1107 #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
1108 int fastboot_set_reboot_flag(void)
1110 printf("Setting reboot to fastboot flag ...\n");
1111 env_set("dofastboot", "1");
1117 #ifdef CONFIG_TI_SECURE_DEVICE
1118 void board_fit_image_post_process(void **p_image, size_t *p_size)
1120 secure_boot_verify_image(p_image, p_size);
1123 void board_tee_image_process(ulong tee_image, size_t tee_size)
1125 secure_tee_install((u32)tee_image);
1128 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);