blob: 6d9ee206c7e396e947663bea484ea8bea90c4d96 [file] [log] [blame]
Felipe Balbi1e4ad742014-11-10 14:02:44 -06001/*
2 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
3 *
4 * Author: Felipe Balbi <balbi@ti.com>
5 *
6 * Based on board/ti/dra7xx/evm.c
7 *
8 * SPDX-License-Identifier: GPL-2.0+
9 */
10
11#include <common.h>
12#include <palmas.h>
13#include <sata.h>
14#include <usb.h>
15#include <asm/omap_common.h>
Andreas Dannenberg17c29872016-06-27 09:19:22 -050016#include <asm/omap_sec_common.h>
Felipe Balbi1e4ad742014-11-10 14:02:44 -060017#include <asm/emif.h>
Lokesh Vutla334bbb32015-06-16 20:36:05 +053018#include <asm/gpio.h>
19#include <asm/arch/gpio.h>
Felipe Balbi1e4ad742014-11-10 14:02:44 -060020#include <asm/arch/clock.h>
Lokesh Vutlaf91e0c42015-06-04 16:42:41 +053021#include <asm/arch/dra7xx_iodelay.h>
Felipe Balbi1e4ad742014-11-10 14:02:44 -060022#include <asm/arch/sys_proto.h>
23#include <asm/arch/mmc_host_def.h>
24#include <asm/arch/sata.h>
25#include <asm/arch/gpio.h>
Kishon Vijay Abraham I7c379aa2015-08-19 14:13:19 +053026#include <asm/arch/omap.h>
Felipe Balbi1e4ad742014-11-10 14:02:44 -060027#include <environment.h>
Kishon Vijay Abraham I7c379aa2015-08-19 14:13:19 +053028#include <usb.h>
29#include <linux/usb/gadget.h>
30#include <dwc3-uboot.h>
31#include <dwc3-omap-uboot.h>
32#include <ti-usb-phy-uboot.h>
Felipe Balbi1e4ad742014-11-10 14:02:44 -060033
Kipisz, Steven212f96f2016-02-24 12:30:58 -060034#include "../common/board_detect.h"
Felipe Balbi1e4ad742014-11-10 14:02:44 -060035#include "mux_data.h"
36
Kipisz, Steven212f96f2016-02-24 12:30:58 -060037#define board_is_x15() board_ti_is("BBRDX15_")
Lokesh Vutlaf7f9f6b2016-11-25 11:14:20 +053038#define board_is_x15_revb1() (board_ti_is("BBRDX15_") && \
39 (strncmp("B.10", board_ti_get_rev(), 3) <= 0))
Kipisz, Steven212f96f2016-02-24 12:30:58 -060040#define board_is_am572x_evm() board_ti_is("AM572PM_")
Nishanth Menonbf43ce62016-11-25 11:14:19 +053041#define board_is_am572x_evm_reva3() \
42 (board_ti_is("AM572PM_") && \
43 (strncmp("A.30", board_ti_get_rev(), 3) <= 0))
Steve Kipiszc020d352016-04-08 17:01:29 -050044#define board_is_am572x_idk() board_ti_is("AM572IDK")
Steve Kipisz4d8397c2016-11-25 11:14:24 +053045#define board_is_am571x_idk() board_ti_is("AM571IDK")
Kipisz, Steven212f96f2016-02-24 12:30:58 -060046
Felipe Balbi1e4ad742014-11-10 14:02:44 -060047#ifdef CONFIG_DRIVER_TI_CPSW
48#include <cpsw.h>
49#endif
50
51DECLARE_GLOBAL_DATA_PTR;
52
Roger Quadros37611052017-03-13 15:04:28 +020053#define GPIO_ETH_LCD GPIO_TO_PIN(2, 22)
Lokesh Vutla334bbb32015-06-16 20:36:05 +053054/* GPIO 7_11 */
55#define GPIO_DDR_VTT_EN 203
56
Nishanth Menonfcb18522017-03-13 15:04:30 +020057/* Touch screen controller to identify the LCD */
58#define OSD_TS_FT_BUS_ADDRESS 0
59#define OSD_TS_FT_CHIP_ADDRESS 0x38
60#define OSD_TS_FT_REG_ID 0xA3
61/*
62 * Touchscreen IDs for various OSD panels
63 * Ref: http://www.osddisplays.com/TI/OSD101T2587-53TS_A.1.pdf
64 */
65/* Used on newer osd101t2587 Panels */
66#define OSD_TS_FT_ID_5x46 0x54
67/* Used on older osd101t2045 Panels */
68#define OSD_TS_FT_ID_5606 0x08
69
Kipisz, Steven212f96f2016-02-24 12:30:58 -060070#define SYSINFO_BOARD_NAME_MAX_LEN 45
71
Keerthy385d3632016-11-30 15:02:53 +053072#define TPS65903X_PRIMARY_SECONDARY_PAD2 0xFB
73#define TPS65903X_PAD2_POWERHOLD_MASK 0x20
74
Felipe Balbi1e4ad742014-11-10 14:02:44 -060075const struct omap_sysinfo sysinfo = {
Kipisz, Steven212f96f2016-02-24 12:30:58 -060076 "Board: UNKNOWN(BeagleBoard X15?) REV UNKNOWN\n"
Felipe Balbi1e4ad742014-11-10 14:02:44 -060077};
78
79static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = {
80 .dmm_lisa_map_3 = 0x80740300,
81 .is_ma_present = 0x1
82};
83
Steve Kipisz4d8397c2016-11-25 11:14:24 +053084static const struct dmm_lisa_map_regs am571x_idk_lisa_regs = {
85 .dmm_lisa_map_3 = 0x80640100,
86 .is_ma_present = 0x1
87};
88
Felipe Balbi1e4ad742014-11-10 14:02:44 -060089void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
90{
Steve Kipisz4d8397c2016-11-25 11:14:24 +053091 if (board_is_am571x_idk())
92 *dmm_lisa_regs = &am571x_idk_lisa_regs;
93 else
94 *dmm_lisa_regs = &beagle_x15_lisa_regs;
Felipe Balbi1e4ad742014-11-10 14:02:44 -060095}
96
97static const struct emif_regs beagle_x15_emif1_ddr3_532mhz_emif_regs = {
Keerthyeafd4642016-05-24 11:45:07 +053098 .sdram_config_init = 0x61851b32,
99 .sdram_config = 0x61851b32,
100 .sdram_config2 = 0x08000000,
101 .ref_ctrl = 0x000040F1,
102 .ref_ctrl_final = 0x00001035,
103 .sdram_tim1 = 0xcccf36ab,
104 .sdram_tim2 = 0x308f7fda,
105 .sdram_tim3 = 0x409f88a8,
106 .read_idle_ctrl = 0x00050000,
107 .zq_config = 0x5007190b,
108 .temp_alert_config = 0x00000000,
109 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
110 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
111 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
112 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
113 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
114 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
115 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
116 .emif_rd_wr_lvl_rmp_win = 0x00000000,
117 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
118 .emif_rd_wr_lvl_ctl = 0x00000000,
119 .emif_rd_wr_exec_thresh = 0x00000305
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600120};
121
Lokesh Vutla6213db72015-06-03 14:43:21 +0530122/* Ext phy ctrl regs 1-35 */
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600123static const u32 beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs[] = {
Lokesh Vutla6213db72015-06-03 14:43:21 +0530124 0x10040100,
Lokesh Vutla11e2b042016-03-08 09:11:35 +0530125 0x00910091,
126 0x00950095,
127 0x009B009B,
128 0x009E009E,
129 0x00980098,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600130 0x00340034,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600131 0x00350035,
Lokesh Vutla11e2b042016-03-08 09:11:35 +0530132 0x00340034,
133 0x00310031,
134 0x00340034,
135 0x007F007F,
136 0x007F007F,
137 0x007F007F,
138 0x007F007F,
139 0x007F007F,
140 0x00480048,
141 0x004A004A,
142 0x00520052,
143 0x00550055,
144 0x00500050,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600145 0x00000000,
146 0x00600020,
Lokesh Vutla6213db72015-06-03 14:43:21 +0530147 0x40011080,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600148 0x08102040,
Lokesh Vutla11e2b042016-03-08 09:11:35 +0530149 0x0,
150 0x0,
151 0x0,
152 0x0,
153 0x0,
Lokesh Vutla496edff2015-06-03 14:43:22 +0530154 0x0,
155 0x0,
156 0x0,
157 0x0,
158 0x0
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600159};
160
161static const struct emif_regs beagle_x15_emif2_ddr3_532mhz_emif_regs = {
Keerthyeafd4642016-05-24 11:45:07 +0530162 .sdram_config_init = 0x61851b32,
163 .sdram_config = 0x61851b32,
164 .sdram_config2 = 0x08000000,
165 .ref_ctrl = 0x000040F1,
166 .ref_ctrl_final = 0x00001035,
167 .sdram_tim1 = 0xcccf36b3,
168 .sdram_tim2 = 0x308f7fda,
169 .sdram_tim3 = 0x407f88a8,
170 .read_idle_ctrl = 0x00050000,
171 .zq_config = 0x5007190b,
172 .temp_alert_config = 0x00000000,
173 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
174 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
175 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
176 .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
177 .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
178 .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
179 .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
180 .emif_rd_wr_lvl_rmp_win = 0x00000000,
181 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
182 .emif_rd_wr_lvl_ctl = 0x00000000,
183 .emif_rd_wr_exec_thresh = 0x00000305
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600184};
185
186static const u32 beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs[] = {
Lokesh Vutla6213db72015-06-03 14:43:21 +0530187 0x10040100,
Lokesh Vutla11e2b042016-03-08 09:11:35 +0530188 0x00910091,
189 0x00950095,
190 0x009B009B,
191 0x009E009E,
192 0x00980098,
193 0x00340034,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600194 0x00350035,
Lokesh Vutla11e2b042016-03-08 09:11:35 +0530195 0x00340034,
196 0x00310031,
197 0x00340034,
198 0x007F007F,
199 0x007F007F,
200 0x007F007F,
201 0x007F007F,
202 0x007F007F,
203 0x00480048,
204 0x004A004A,
205 0x00520052,
206 0x00550055,
207 0x00500050,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600208 0x00000000,
209 0x00600020,
Lokesh Vutla6213db72015-06-03 14:43:21 +0530210 0x40011080,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600211 0x08102040,
Lokesh Vutla11e2b042016-03-08 09:11:35 +0530212 0x0,
213 0x0,
214 0x0,
215 0x0,
216 0x0,
Lokesh Vutla496edff2015-06-03 14:43:22 +0530217 0x0,
218 0x0,
219 0x0,
220 0x0,
221 0x0
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600222};
223
224void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
225{
226 switch (emif_nr) {
227 case 1:
228 *regs = &beagle_x15_emif1_ddr3_532mhz_emif_regs;
229 break;
230 case 2:
231 *regs = &beagle_x15_emif2_ddr3_532mhz_emif_regs;
232 break;
233 }
234}
235
236void emif_get_ext_phy_ctrl_const_regs(u32 emif_nr, const u32 **regs, u32 *size)
237{
238 switch (emif_nr) {
239 case 1:
240 *regs = beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs;
241 *size = ARRAY_SIZE(beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs);
242 break;
243 case 2:
244 *regs = beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs;
245 *size = ARRAY_SIZE(beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs);
246 break;
247 }
248}
249
250struct vcores_data beagle_x15_volts = {
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530251 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
252 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600253 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
254 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
255 .mpu.pmic = &tps659038,
Keerthyeafd4642016-05-24 11:45:07 +0530256 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600257
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530258 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
259 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
260 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
261 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
262 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
263 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600264 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
265 .eve.addr = TPS659038_REG_ADDR_SMPS45,
266 .eve.pmic = &tps659038,
Nishanth Menone52e3342016-04-21 14:34:25 -0500267 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600268
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530269 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
270 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
271 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
272 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
273 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
274 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600275 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
276 .gpu.addr = TPS659038_REG_ADDR_SMPS45,
277 .gpu.pmic = &tps659038,
Nishanth Menone52e3342016-04-21 14:34:25 -0500278 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600279
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530280 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
281 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600282 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
283 .core.addr = TPS659038_REG_ADDR_SMPS6,
284 .core.pmic = &tps659038,
285
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530286 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
287 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
288 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
289 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
290 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
291 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600292 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
293 .iva.addr = TPS659038_REG_ADDR_SMPS45,
294 .iva.pmic = &tps659038,
Nishanth Menone52e3342016-04-21 14:34:25 -0500295 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600296};
297
Keerthyd60198d2016-05-24 11:45:06 +0530298struct vcores_data am572x_idk_volts = {
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530299 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
300 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
Keerthyd60198d2016-05-24 11:45:06 +0530301 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
302 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
303 .mpu.pmic = &tps659038,
304 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
305
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530306 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
307 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
308 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
309 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
310 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
311 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
Keerthyd60198d2016-05-24 11:45:06 +0530312 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
313 .eve.addr = TPS659038_REG_ADDR_SMPS45,
314 .eve.pmic = &tps659038,
315 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
316
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530317 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
318 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
319 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
320 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
321 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
322 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
Keerthyd60198d2016-05-24 11:45:06 +0530323 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
324 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
325 .gpu.pmic = &tps659038,
326 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
327
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530328 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
329 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
Keerthyd60198d2016-05-24 11:45:06 +0530330 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
331 .core.addr = TPS659038_REG_ADDR_SMPS7,
332 .core.pmic = &tps659038,
333
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530334 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
335 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
336 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
337 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
338 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
339 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
Keerthyd60198d2016-05-24 11:45:06 +0530340 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
341 .iva.addr = TPS659038_REG_ADDR_SMPS8,
342 .iva.pmic = &tps659038,
343 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
344};
345
Keerthyb12550e2017-05-25 15:37:34 +0530346struct vcores_data am571x_idk_volts = {
347 .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
348 .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
349 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
350 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
351 .mpu.pmic = &tps659038,
352 .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
353
354 .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
355 .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
356 .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
357 .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
358 .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
359 .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
360 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
361 .eve.addr = TPS659038_REG_ADDR_SMPS45,
362 .eve.pmic = &tps659038,
363 .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
364
365 .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
366 .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
367 .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
368 .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
369 .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
370 .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
371 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
372 .gpu.addr = TPS659038_REG_ADDR_SMPS6,
373 .gpu.pmic = &tps659038,
374 .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
375
376 .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
377 .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
378 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
379 .core.addr = TPS659038_REG_ADDR_SMPS7,
380 .core.pmic = &tps659038,
381
382 .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
383 .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
384 .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
385 .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
386 .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
387 .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
388 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
389 .iva.addr = TPS659038_REG_ADDR_SMPS45,
390 .iva.pmic = &tps659038,
391 .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
392};
393
Lokesh Vutlabeb71272016-11-23 12:54:39 +0530394int get_voltrail_opp(int rail_offset)
395{
396 int opp;
397
398 switch (rail_offset) {
399 case VOLT_MPU:
400 opp = DRA7_MPU_OPP;
401 break;
402 case VOLT_CORE:
403 opp = DRA7_CORE_OPP;
404 break;
405 case VOLT_GPU:
406 opp = DRA7_GPU_OPP;
407 break;
408 case VOLT_EVE:
409 opp = DRA7_DSPEVE_OPP;
410 break;
411 case VOLT_IVA:
412 opp = DRA7_IVA_OPP;
413 break;
414 default:
415 opp = OPP_NOM;
416 }
417
418 return opp;
419}
420
421
Kipisz, Steven212f96f2016-02-24 12:30:58 -0600422#ifdef CONFIG_SPL_BUILD
423/* No env to setup for SPL */
424static inline void setup_board_eeprom_env(void) { }
425
426/* Override function to read eeprom information */
427void do_board_detect(void)
428{
429 int rc;
430
431 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
432 CONFIG_EEPROM_CHIP_ADDRESS);
433 if (rc)
434 printf("ti_i2c_eeprom_init failed %d\n", rc);
435}
436
437#else /* CONFIG_SPL_BUILD */
438
439/* Override function to read eeprom information: actual i2c read done by SPL*/
440void do_board_detect(void)
441{
442 char *bname = NULL;
443 int rc;
444
445 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
446 CONFIG_EEPROM_CHIP_ADDRESS);
447 if (rc)
448 printf("ti_i2c_eeprom_init failed %d\n", rc);
449
450 if (board_is_x15())
451 bname = "BeagleBoard X15";
452 else if (board_is_am572x_evm())
453 bname = "AM572x EVM";
Steve Kipiszc020d352016-04-08 17:01:29 -0500454 else if (board_is_am572x_idk())
455 bname = "AM572x IDK";
Steve Kipisz4d8397c2016-11-25 11:14:24 +0530456 else if (board_is_am571x_idk())
457 bname = "AM571x IDK";
Kipisz, Steven212f96f2016-02-24 12:30:58 -0600458
459 if (bname)
460 snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
461 "Board: %s REV %s\n", bname, board_ti_get_rev());
462}
463
464static void setup_board_eeprom_env(void)
465{
466 char *name = "beagle_x15";
467 int rc;
468
469 rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
470 CONFIG_EEPROM_CHIP_ADDRESS);
471 if (rc)
472 goto invalid_eeprom;
473
Nishanth Menonbf43ce62016-11-25 11:14:19 +0530474 if (board_is_x15()) {
Lokesh Vutlaf7f9f6b2016-11-25 11:14:20 +0530475 if (board_is_x15_revb1())
476 name = "beagle_x15_revb1";
477 else
478 name = "beagle_x15";
Nishanth Menonbf43ce62016-11-25 11:14:19 +0530479 } else if (board_is_am572x_evm()) {
480 if (board_is_am572x_evm_reva3())
481 name = "am57xx_evm_reva3";
482 else
483 name = "am57xx_evm";
484 } else if (board_is_am572x_idk()) {
Steve Kipiszc020d352016-04-08 17:01:29 -0500485 name = "am572x_idk";
Steve Kipisz4d8397c2016-11-25 11:14:24 +0530486 } else if (board_is_am571x_idk()) {
487 name = "am571x_idk";
Nishanth Menonbf43ce62016-11-25 11:14:19 +0530488 } else {
Kipisz, Steven212f96f2016-02-24 12:30:58 -0600489 printf("Unidentified board claims %s in eeprom header\n",
490 board_ti_get_name());
Nishanth Menonbf43ce62016-11-25 11:14:19 +0530491 }
Kipisz, Steven212f96f2016-02-24 12:30:58 -0600492
493invalid_eeprom:
494 set_board_info_env(name);
495}
496
497#endif /* CONFIG_SPL_BUILD */
498
Keerthyd60198d2016-05-24 11:45:06 +0530499void vcores_init(void)
500{
501 if (board_is_am572x_idk())
502 *omap_vcores = &am572x_idk_volts;
Keerthyb12550e2017-05-25 15:37:34 +0530503 else if (board_is_am571x_idk())
504 *omap_vcores = &am571x_idk_volts;
Keerthyd60198d2016-05-24 11:45:06 +0530505 else
506 *omap_vcores = &beagle_x15_volts;
507}
508
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600509void hw_data_init(void)
510{
511 *prcm = &dra7xx_prcm;
512 *dplls_data = &dra7xx_dplls;
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600513 *ctrl = &dra7xx_ctrl;
514}
515
Roger Quadros37611052017-03-13 15:04:28 +0200516bool am571x_idk_needs_lcd(void)
517{
518 bool needs_lcd;
519
520 gpio_request(GPIO_ETH_LCD, "nLCD_Detect");
521 if (gpio_get_value(GPIO_ETH_LCD))
522 needs_lcd = false;
523 else
524 needs_lcd = true;
525
526 gpio_free(GPIO_ETH_LCD);
527
528 return needs_lcd;
529}
530
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600531int board_init(void)
532{
533 gpmc_init();
534 gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100);
535
536 return 0;
537}
538
Nishanth Menonfcb18522017-03-13 15:04:30 +0200539void am57x_idk_lcd_detect(void)
540{
541 int r = -ENODEV;
542 char *idk_lcd = "no";
543 uint8_t buf = 0;
544
545 /* Only valid for IDKs */
546 if (board_is_x15() || board_is_am572x_evm())
547 return;
548
549 /* Only AM571x IDK has gpio control detect.. so check that */
550 if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
551 goto out;
552
553 r = i2c_set_bus_num(OSD_TS_FT_BUS_ADDRESS);
554 if (r) {
555 printf("%s: Failed to set bus address to %d: %d\n",
556 __func__, OSD_TS_FT_BUS_ADDRESS, r);
557 goto out;
558 }
559 r = i2c_probe(OSD_TS_FT_CHIP_ADDRESS);
560 if (r) {
561 /* AM572x IDK has no explicit settings for optional LCD kit */
562 if (board_is_am571x_idk()) {
563 printf("%s: Touch screen detect failed: %d!\n",
564 __func__, r);
565 }
566 goto out;
567 }
568
569 /* Read FT ID */
570 r = i2c_read(OSD_TS_FT_CHIP_ADDRESS, OSD_TS_FT_REG_ID, 1, &buf, 1);
571 if (r) {
572 printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n",
573 __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
574 OSD_TS_FT_REG_ID, r);
575 goto out;
576 }
577
578 switch (buf) {
579 case OSD_TS_FT_ID_5606:
580 idk_lcd = "osd101t2045";
581 break;
582 case OSD_TS_FT_ID_5x46:
583 idk_lcd = "osd101t2587";
584 break;
585 default:
586 printf("%s: Unidentifed Touch screen ID 0x%02x\n",
587 __func__, buf);
588 /* we will let default be "no lcd" */
589 }
590out:
591 setenv("idk_lcd", idk_lcd);
592 return;
593}
594
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600595int board_late_init(void)
596{
Kipisz, Steven212f96f2016-02-24 12:30:58 -0600597 setup_board_eeprom_env();
Keerthy385d3632016-11-30 15:02:53 +0530598 u8 val;
Kipisz, Steven212f96f2016-02-24 12:30:58 -0600599
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600600 /*
601 * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
602 * This is the POWERHOLD-in-Low behavior.
603 */
604 palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);
Lokesh Vutla82cca5a2016-11-29 11:58:02 +0530605
606 /*
607 * Default FIT boot on HS devices. Non FIT images are not allowed
608 * on HS devices.
609 */
610 if (get_device_type() == HS_DEVICE)
611 setenv("boot_fit", "1");
612
Keerthy385d3632016-11-30 15:02:53 +0530613 /*
614 * Set the GPIO7 Pad to POWERHOLD. This has higher priority
615 * over DEV_CTRL.DEV_ON bit. This can be reset in case of
616 * PMIC Power off. So to be on the safer side set it back
617 * to POWERHOLD mode irrespective of the current state.
618 */
619 palmas_i2c_read_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
620 &val);
621 val = val | TPS65903X_PAD2_POWERHOLD_MASK;
622 palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
623 val);
624
Semen Protsenko7a2af752017-02-13 19:09:37 +0200625 omap_die_id_serial();
626
Nishanth Menonfcb18522017-03-13 15:04:30 +0200627 am57x_idk_lcd_detect();
Roger Quadros37611052017-03-13 15:04:28 +0200628
629#if !defined(CONFIG_SPL_BUILD)
630 board_ti_set_ethaddr(2);
631#endif
632
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600633 return 0;
634}
635
Paul Kocialkowski3ef56e62016-02-27 19:18:56 +0100636void set_muxconf_regs(void)
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600637{
638 do_set_mux32((*ctrl)->control_padconf_core_base,
Lokesh Vutlaf91e0c42015-06-04 16:42:41 +0530639 early_padconf, ARRAY_SIZE(early_padconf));
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600640}
641
Lokesh Vutlaf91e0c42015-06-04 16:42:41 +0530642#ifdef CONFIG_IODELAY_RECALIBRATION
643void recalibrate_iodelay(void)
644{
Steve Kipiszc020d352016-04-08 17:01:29 -0500645 const struct pad_conf_entry *pconf;
646 const struct iodelay_cfg_entry *iod;
647 int pconf_sz, iod_sz;
Nishanth Menon89a38952016-11-25 11:14:22 +0530648 int ret;
Steve Kipiszc020d352016-04-08 17:01:29 -0500649
650 if (board_is_am572x_idk()) {
651 pconf = core_padconf_array_essential_am572x_idk;
652 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am572x_idk);
653 iod = iodelay_cfg_array_am572x_idk;
654 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am572x_idk);
Steve Kipisz4d8397c2016-11-25 11:14:24 +0530655 } else if (board_is_am571x_idk()) {
656 pconf = core_padconf_array_essential_am571x_idk;
657 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am571x_idk);
658 iod = iodelay_cfg_array_am571x_idk;
659 iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk);
Steve Kipiszc020d352016-04-08 17:01:29 -0500660 } else {
661 /* Common for X15/GPEVM */
662 pconf = core_padconf_array_essential_x15;
663 pconf_sz = ARRAY_SIZE(core_padconf_array_essential_x15);
Nishanth Menon89a38952016-11-25 11:14:22 +0530664 /* There never was an SR1.0 X15.. So.. */
665 if (omap_revision() == DRA752_ES1_1) {
666 iod = iodelay_cfg_array_x15_sr1_1;
667 iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr1_1);
668 } else {
669 /* Since full production should switch to SR2.0 */
670 iod = iodelay_cfg_array_x15_sr2_0;
671 iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr2_0);
672 }
Steve Kipiszc020d352016-04-08 17:01:29 -0500673 }
674
Nishanth Menon89a38952016-11-25 11:14:22 +0530675 /* Setup I/O isolation */
676 ret = __recalibrate_iodelay_start();
677 if (ret)
678 goto err;
679
680 /* Do the muxing here */
681 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
682
683 /* Now do the weird minor deltas that should be safe */
684 if (board_is_x15() || board_is_am572x_evm()) {
685 if (board_is_x15_revb1() || board_is_am572x_evm_reva3()) {
686 pconf = core_padconf_array_delta_x15_sr2_0;
687 pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr2_0);
688 } else {
689 pconf = core_padconf_array_delta_x15_sr1_1;
690 pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr1_1);
691 }
692 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
693 }
694
Roger Quadros37611052017-03-13 15:04:28 +0200695 if (board_is_am571x_idk()) {
696 if (am571x_idk_needs_lcd()) {
697 pconf = core_padconf_array_vout_am571x_idk;
698 pconf_sz = ARRAY_SIZE(core_padconf_array_vout_am571x_idk);
699 } else {
700 pconf = core_padconf_array_icss1eth_am571x_idk;
701 pconf_sz = ARRAY_SIZE(core_padconf_array_icss1eth_am571x_idk);
702 }
703 do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
704 }
705
Nishanth Menon89a38952016-11-25 11:14:22 +0530706 /* Setup IOdelay configuration */
707 ret = do_set_iodelay((*ctrl)->iodelay_config_base, iod, iod_sz);
708err:
709 /* Closeup.. remove isolation */
710 __recalibrate_iodelay_end(ret);
Lokesh Vutlaf91e0c42015-06-04 16:42:41 +0530711}
712#endif
713
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900714#if defined(CONFIG_MMC)
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600715int board_mmc_init(bd_t *bis)
716{
717 omap_mmc_init(0, 0, 0, -1, -1);
718 omap_mmc_init(1, 0, 0, -1, -1);
719 return 0;
720}
721#endif
722
723#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
724int spl_start_uboot(void)
725{
726 /* break into full u-boot on 'c' */
727 if (serial_tstc() && serial_getc() == 'c')
728 return 1;
729
730#ifdef CONFIG_SPL_ENV_SUPPORT
731 env_init();
732 env_relocate_spec();
733 if (getenv_yesno("boot_os") != 1)
734 return 1;
735#endif
736
737 return 0;
738}
739#endif
740
Kishon Vijay Abraham I7c379aa2015-08-19 14:13:19 +0530741#ifdef CONFIG_USB_DWC3
Kishon Vijay Abraham I7c379aa2015-08-19 14:13:19 +0530742static struct dwc3_device usb_otg_ss2 = {
743 .maximum_speed = USB_SPEED_HIGH,
744 .base = DRA7_USB_OTG_SS2_BASE,
745 .tx_fifo_resize = false,
746 .index = 1,
747};
748
749static struct dwc3_omap_device usb_otg_ss2_glue = {
750 .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE,
751 .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
752 .index = 1,
753};
754
755static struct ti_usb_phy_device usb_phy2_device = {
756 .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER,
757 .index = 1,
758};
759
Kishon Vijay Abraham I7c379aa2015-08-19 14:13:19 +0530760int usb_gadget_handle_interrupts(int index)
761{
762 u32 status;
763
764 status = dwc3_omap_uboot_interrupt_status(index);
765 if (status)
766 dwc3_uboot_handle_interrupt(index);
767
768 return 0;
769}
Roger Quadros55efadd2016-05-23 17:37:48 +0300770#endif /* CONFIG_USB_DWC3 */
771
772#if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP)
Uri Mashiach1a9a5f72017-02-23 15:39:37 +0200773int omap_xhci_board_usb_init(int index, enum usb_init_type init)
Roger Quadros55efadd2016-05-23 17:37:48 +0300774{
775 enable_usb_clocks(index);
776 switch (index) {
777 case 0:
778 if (init == USB_INIT_DEVICE) {
779 printf("port %d can't be used as device\n", index);
780 disable_usb_clocks(index);
781 return -EINVAL;
782 }
783 break;
784 case 1:
785 if (init == USB_INIT_DEVICE) {
786#ifdef CONFIG_USB_DWC3
787 usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL;
788 usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
789 ti_usb_phy_uboot_init(&usb_phy2_device);
790 dwc3_omap_uboot_init(&usb_otg_ss2_glue);
791 dwc3_uboot_init(&usb_otg_ss2);
Kishon Vijay Abraham I7c379aa2015-08-19 14:13:19 +0530792#endif
Roger Quadros55efadd2016-05-23 17:37:48 +0300793 } else {
794 printf("port %d can't be used as host\n", index);
795 disable_usb_clocks(index);
796 return -EINVAL;
797 }
798
799 break;
800 default:
801 printf("Invalid Controller Index\n");
802 }
803
804 return 0;
805}
806
Uri Mashiach1a9a5f72017-02-23 15:39:37 +0200807int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)
Roger Quadros55efadd2016-05-23 17:37:48 +0300808{
809#ifdef CONFIG_USB_DWC3
810 switch (index) {
811 case 0:
812 case 1:
813 if (init == USB_INIT_DEVICE) {
814 ti_usb_phy_uboot_exit(index);
815 dwc3_uboot_exit(index);
816 dwc3_omap_uboot_exit(index);
817 }
818 break;
819 default:
820 printf("Invalid Controller Index\n");
821 }
822#endif
823 disable_usb_clocks(index);
824 return 0;
825}
826#endif /* defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP) */
Kishon Vijay Abraham I7c379aa2015-08-19 14:13:19 +0530827
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600828#ifdef CONFIG_DRIVER_TI_CPSW
829
830/* Delay value to add to calibrated value */
831#define RGMII0_TXCTL_DLY_VAL ((0x3 << 5) + 0x8)
832#define RGMII0_TXD0_DLY_VAL ((0x3 << 5) + 0x8)
833#define RGMII0_TXD1_DLY_VAL ((0x3 << 5) + 0x2)
834#define RGMII0_TXD2_DLY_VAL ((0x4 << 5) + 0x0)
835#define RGMII0_TXD3_DLY_VAL ((0x4 << 5) + 0x0)
836#define VIN2A_D13_DLY_VAL ((0x3 << 5) + 0x8)
837#define VIN2A_D17_DLY_VAL ((0x3 << 5) + 0x8)
838#define VIN2A_D16_DLY_VAL ((0x3 << 5) + 0x2)
839#define VIN2A_D15_DLY_VAL ((0x4 << 5) + 0x0)
840#define VIN2A_D14_DLY_VAL ((0x4 << 5) + 0x0)
841
842static void cpsw_control(int enabled)
843{
844 /* VTP can be added here */
845}
846
847static struct cpsw_slave_data cpsw_slaves[] = {
848 {
849 .slave_reg_ofs = 0x208,
850 .sliver_reg_ofs = 0xd80,
851 .phy_addr = 1,
852 },
853 {
854 .slave_reg_ofs = 0x308,
855 .sliver_reg_ofs = 0xdc0,
856 .phy_addr = 2,
857 },
858};
859
860static struct cpsw_platform_data cpsw_data = {
861 .mdio_base = CPSW_MDIO_BASE,
862 .cpsw_base = CPSW_BASE,
863 .mdio_div = 0xff,
864 .channels = 8,
865 .cpdma_reg_ofs = 0x800,
866 .slaves = 1,
867 .slave_data = cpsw_slaves,
868 .ale_reg_ofs = 0xd00,
869 .ale_entries = 1024,
870 .host_port_reg_ofs = 0x108,
871 .hw_stats_reg_ofs = 0x900,
872 .bd_ram_ofs = 0x2000,
873 .mac_control = (1 << 5),
874 .control = cpsw_control,
875 .host_port_num = 0,
876 .version = CPSW_CTRL_VERSION_2,
877};
878
Roger Quadros92667e82016-03-18 13:18:12 +0200879static u64 mac_to_u64(u8 mac[6])
880{
881 int i;
882 u64 addr = 0;
883
884 for (i = 0; i < 6; i++) {
885 addr <<= 8;
886 addr |= mac[i];
887 }
888
889 return addr;
890}
891
892static void u64_to_mac(u64 addr, u8 mac[6])
893{
894 mac[5] = addr;
895 mac[4] = addr >> 8;
896 mac[3] = addr >> 16;
897 mac[2] = addr >> 24;
898 mac[1] = addr >> 32;
899 mac[0] = addr >> 40;
900}
901
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600902int board_eth_init(bd_t *bis)
903{
904 int ret;
905 uint8_t mac_addr[6];
906 uint32_t mac_hi, mac_lo;
907 uint32_t ctrl_val;
Roger Quadros92667e82016-03-18 13:18:12 +0200908 int i;
909 u64 mac1, mac2;
910 u8 mac_addr1[6], mac_addr2[6];
911 int num_macs;
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600912
913 /* try reading mac address from efuse */
914 mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
915 mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
916 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
917 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
918 mac_addr[2] = mac_hi & 0xFF;
919 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
920 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
921 mac_addr[5] = mac_lo & 0xFF;
922
923 if (!getenv("ethaddr")) {
924 printf("<ethaddr> not set. Validating first E-fuse MAC\n");
925
Joe Hershberger0adb5b72015-04-08 01:41:04 -0500926 if (is_valid_ethaddr(mac_addr))
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600927 eth_setenv_enetaddr("ethaddr", mac_addr);
928 }
929
930 mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
931 mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
932 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
933 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
934 mac_addr[2] = mac_hi & 0xFF;
935 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
936 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
937 mac_addr[5] = mac_lo & 0xFF;
938
939 if (!getenv("eth1addr")) {
Joe Hershberger0adb5b72015-04-08 01:41:04 -0500940 if (is_valid_ethaddr(mac_addr))
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600941 eth_setenv_enetaddr("eth1addr", mac_addr);
942 }
943
944 ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
945 ctrl_val |= 0x22;
946 writel(ctrl_val, (*ctrl)->control_core_control_io1);
947
Steve Kipisz4d8397c2016-11-25 11:14:24 +0530948 /* The phy address for the AM57xx IDK are different than x15 */
949 if (board_is_am572x_idk() || board_is_am571x_idk()) {
Steve Kipiszc020d352016-04-08 17:01:29 -0500950 cpsw_data.slave_data[0].phy_addr = 0;
951 cpsw_data.slave_data[1].phy_addr = 1;
952 }
953
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600954 ret = cpsw_register(&cpsw_data);
955 if (ret < 0)
956 printf("Error %d registering CPSW switch\n", ret);
957
Roger Quadros92667e82016-03-18 13:18:12 +0200958 /*
959 * Export any Ethernet MAC addresses from EEPROM.
960 * On AM57xx the 2 MAC addresses define the address range
961 */
962 board_ti_get_eth_mac_addr(0, mac_addr1);
963 board_ti_get_eth_mac_addr(1, mac_addr2);
964
965 if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) {
966 mac1 = mac_to_u64(mac_addr1);
967 mac2 = mac_to_u64(mac_addr2);
968
969 /* must contain an address range */
970 num_macs = mac2 - mac1 + 1;
971 /* <= 50 to protect against user programming error */
972 if (num_macs > 0 && num_macs <= 50) {
973 for (i = 0; i < num_macs; i++) {
974 u64_to_mac(mac1 + i, mac_addr);
975 if (is_valid_ethaddr(mac_addr)) {
976 eth_setenv_enetaddr_by_index("eth",
977 i + 2,
978 mac_addr);
979 }
980 }
981 }
982 }
983
Felipe Balbi1e4ad742014-11-10 14:02:44 -0600984 return ret;
985}
986#endif
Lokesh Vutla334bbb32015-06-16 20:36:05 +0530987
988#ifdef CONFIG_BOARD_EARLY_INIT_F
989/* VTT regulator enable */
990static inline void vtt_regulator_enable(void)
991{
992 if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
993 return;
994
995 gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
996 gpio_direction_output(GPIO_DDR_VTT_EN, 1);
997}
998
999int board_early_init_f(void)
1000{
1001 vtt_regulator_enable();
1002 return 0;
1003}
1004#endif
Daniel Allred62a09f02016-05-19 19:10:54 -05001005
1006#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
1007int ft_board_setup(void *blob, bd_t *bd)
1008{
1009 ft_cpu_setup(blob, bd);
1010
1011 return 0;
1012}
1013#endif
Lokesh Vutla7a0ea582016-06-10 09:35:43 +05301014
1015#ifdef CONFIG_SPL_LOAD_FIT
1016int board_fit_config_name_match(const char *name)
1017{
Lokesh Vutlaf7f9f6b2016-11-25 11:14:20 +05301018 if (board_is_x15()) {
1019 if (board_is_x15_revb1()) {
1020 if (!strcmp(name, "am57xx-beagle-x15-revb1"))
1021 return 0;
1022 } else if (!strcmp(name, "am57xx-beagle-x15")) {
1023 return 0;
1024 }
1025 } else if (board_is_am572x_evm() &&
1026 !strcmp(name, "am57xx-beagle-x15")) {
Lokesh Vutla7a0ea582016-06-10 09:35:43 +05301027 return 0;
Lokesh Vutlaf7f9f6b2016-11-25 11:14:20 +05301028 } else if (board_is_am572x_idk() && !strcmp(name, "am572x-idk")) {
Lokesh Vutla7a0ea582016-06-10 09:35:43 +05301029 return 0;
Schuyler Patton45e7f7e2016-11-25 11:14:25 +05301030 } else if (board_is_am571x_idk() && !strcmp(name, "am571x-idk")) {
1031 return 0;
Lokesh Vutlaf7f9f6b2016-11-25 11:14:20 +05301032 }
1033
1034 return -1;
Lokesh Vutla7a0ea582016-06-10 09:35:43 +05301035}
1036#endif
Andreas Dannenberg17c29872016-06-27 09:19:22 -05001037
1038#ifdef CONFIG_TI_SECURE_DEVICE
1039void board_fit_image_post_process(void **p_image, size_t *p_size)
1040{
1041 secure_boot_verify_image(p_image, p_size);
1042}
Andrew F. Davis1b597ad2016-11-29 16:33:26 -06001043
1044void board_tee_image_process(ulong tee_image, size_t tee_size)
1045{
1046 secure_tee_install((u32)tee_image);
1047}
1048
1049U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
Andreas Dannenberg17c29872016-06-27 09:19:22 -05001050#endif