1 // SPDX-License-Identifier: GPL-2.0+
3 * Board specific initialization for AM642 EVM
5 * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/
13 #include <asm/arch/hardware.h>
14 #include <asm/arch/sys_proto.h>
17 #include "../common/board_detect.h"
19 #define board_is_am64x_gpevm() board_ti_k3_is("AM64-GPEVM")
20 #define board_is_am64x_skevm() board_ti_k3_is("AM64-SKEVM")
22 DECLARE_GLOBAL_DATA_PTR;
31 gd->ram_size = 0x80000000;
36 int dram_init_banksize(void)
38 /* Bank 0 declares the memory available in the DDR low region */
39 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
40 gd->bd->bi_dram[0].size = 0x80000000;
41 gd->ram_size = 0x80000000;
46 #if defined(CONFIG_SPL_LOAD_FIT)
47 int board_fit_config_name_match(const char *name)
49 bool eeprom_read = board_ti_was_eeprom_read();
51 if (!eeprom_read || board_is_am64x_gpevm()) {
52 if (!strcmp(name, "k3-am642-r5-evm") || !strcmp(name, "k3-am642-evm"))
54 } else if (board_is_am64x_skevm()) {
55 if (!strcmp(name, "k3-am642-r5-sk") || !strcmp(name, "k3-am642-sk"))
63 #ifdef CONFIG_TI_I2C_BOARD_DETECT
64 int do_board_detect(void)
68 ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
69 CONFIG_EEPROM_CHIP_ADDRESS);
71 printf("EEPROM not available at 0x%02x, trying to read at 0x%02x\n",
72 CONFIG_EEPROM_CHIP_ADDRESS, CONFIG_EEPROM_CHIP_ADDRESS + 1);
73 ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
74 CONFIG_EEPROM_CHIP_ADDRESS + 1);
76 pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
77 CONFIG_EEPROM_CHIP_ADDRESS + 1, ret);
85 struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
87 if (!do_board_detect())
88 printf("Board: %s rev %s\n", ep->name, ep->version);
93 #ifdef CONFIG_BOARD_LATE_INIT
94 static void setup_board_eeprom_env(void)
96 char *name = "am64x_gpevm";
98 if (do_board_detect())
101 if (board_is_am64x_gpevm())
102 name = "am64x_gpevm";
103 else if (board_is_am64x_skevm())
104 name = "am64x_skevm";
106 printf("Unidentified board claims %s in eeprom header\n",
107 board_ti_get_name());
110 set_board_info_env_am6(name);
113 static void setup_serial(void)
115 struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
116 unsigned long board_serial;
118 char serial_string[17] = { 0 };
120 if (env_get("serial#"))
123 board_serial = hextoul(ep->serial, &endp);
125 pr_err("Error: Can't set serial# to %s\n", ep->serial);
129 snprintf(serial_string, sizeof(serial_string), "%016lx", board_serial);
130 env_set("serial#", serial_string);
135 #ifdef CONFIG_BOARD_LATE_INIT
136 int board_late_init(void)
138 if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
139 struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
141 setup_board_eeprom_env();
144 * The first MAC address for ethernet a.k.a. ethernet0 comes from
145 * efuse populated via the am654 gigabit eth switch subsystem driver.
146 * All the other ones are populated via EEPROM, hence continue with
149 board_ti_am6_set_ethaddr(1, ep->mac_addr_cnt);
156 #define CTRLMMR_USB0_PHY_CTRL 0x43004008
157 #define CORE_VOLTAGE 0x80000000
159 #ifdef CONFIG_SPL_BOARD_INIT
160 void spl_board_init(void)
163 /* Set USB PHY core voltage to 0.85V */
164 val = readl(CTRLMMR_USB0_PHY_CTRL);
165 val &= ~(CORE_VOLTAGE);
166 writel(val, CTRLMMR_USB0_PHY_CTRL);