2 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
4 * Author: Felipe Balbi <balbi@ti.com>
6 * Based on board/ti/dra7xx/evm.c
8 * SPDX-License-Identifier: GPL-2.0+
15 #include <asm/omap_common.h>
17 #include <asm/arch/clock.h>
18 #include <asm/arch/dra7xx_iodelay.h>
19 #include <asm/arch/sys_proto.h>
20 #include <asm/arch/mmc_host_def.h>
21 #include <asm/arch/sata.h>
22 #include <asm/arch/gpio.h>
23 #include <environment.h>
27 #ifdef CONFIG_DRIVER_TI_CPSW
31 DECLARE_GLOBAL_DATA_PTR;
33 const struct omap_sysinfo sysinfo = {
34 "Board: BeagleBoard x15\n"
37 static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = {
38 .dmm_lisa_map_3 = 0x80740300,
42 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
44 *dmm_lisa_regs = &beagle_x15_lisa_regs;
47 static const struct emif_regs beagle_x15_emif1_ddr3_532mhz_emif_regs = {
48 .sdram_config_init = 0x61851b32,
49 .sdram_config = 0x61851b32,
50 .sdram_config2 = 0x00000000,
51 .ref_ctrl = 0x000040F1,
52 .ref_ctrl_final = 0x00001035,
53 .sdram_tim1 = 0xceef266b,
54 .sdram_tim2 = 0x328f7fda,
55 .sdram_tim3 = 0x027f88a8,
56 .read_idle_ctrl = 0x00050000,
57 .zq_config = 0x0007190b,
58 .temp_alert_config = 0x00000000,
59 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
60 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
61 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
62 .emif_ddr_ext_phy_ctrl_2 = 0x00740074,
63 .emif_ddr_ext_phy_ctrl_3 = 0x00780078,
64 .emif_ddr_ext_phy_ctrl_4 = 0x007c007c,
65 .emif_ddr_ext_phy_ctrl_5 = 0x007b007b,
66 .emif_rd_wr_lvl_rmp_win = 0x00000000,
67 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
68 .emif_rd_wr_lvl_ctl = 0x00000000,
69 .emif_rd_wr_exec_thresh = 0x00000305
72 /* Ext phy ctrl regs 1-35 */
73 static const u32 beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs[] = {
115 static const struct emif_regs beagle_x15_emif2_ddr3_532mhz_emif_regs = {
116 .sdram_config_init = 0x61851b32,
117 .sdram_config = 0x61851b32,
118 .sdram_config2 = 0x00000000,
119 .ref_ctrl = 0x000040F1,
120 .ref_ctrl_final = 0x00001035,
121 .sdram_tim1 = 0xceef266b,
122 .sdram_tim2 = 0x328f7fda,
123 .sdram_tim3 = 0x027f88a8,
124 .read_idle_ctrl = 0x00050000,
125 .zq_config = 0x0007190b,
126 .temp_alert_config = 0x00000000,
127 .emif_ddr_phy_ctlr_1_init = 0x0024400b,
128 .emif_ddr_phy_ctlr_1 = 0x0e24400b,
129 .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
130 .emif_ddr_ext_phy_ctrl_2 = 0x00820082,
131 .emif_ddr_ext_phy_ctrl_3 = 0x008b008b,
132 .emif_ddr_ext_phy_ctrl_4 = 0x00800080,
133 .emif_ddr_ext_phy_ctrl_5 = 0x007e007e,
134 .emif_rd_wr_lvl_rmp_win = 0x00000000,
135 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
136 .emif_rd_wr_lvl_ctl = 0x00000000,
137 .emif_rd_wr_exec_thresh = 0x00000305
140 static const u32 beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs[] = {
180 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
184 *regs = &beagle_x15_emif1_ddr3_532mhz_emif_regs;
187 *regs = &beagle_x15_emif2_ddr3_532mhz_emif_regs;
192 void emif_get_ext_phy_ctrl_const_regs(u32 emif_nr, const u32 **regs, u32 *size)
196 *regs = beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs;
197 *size = ARRAY_SIZE(beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs);
200 *regs = beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs;
201 *size = ARRAY_SIZE(beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs);
206 struct vcores_data beagle_x15_volts = {
207 .mpu.value = VDD_MPU_DRA752,
208 .mpu.efuse.reg = STD_FUSE_OPP_VMIN_MPU_NOM,
209 .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
210 .mpu.addr = TPS659038_REG_ADDR_SMPS12,
211 .mpu.pmic = &tps659038,
213 .eve.value = VDD_EVE_DRA752,
214 .eve.efuse.reg = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
215 .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
216 .eve.addr = TPS659038_REG_ADDR_SMPS45,
217 .eve.pmic = &tps659038,
219 .gpu.value = VDD_GPU_DRA752,
220 .gpu.efuse.reg = STD_FUSE_OPP_VMIN_GPU_NOM,
221 .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
222 .gpu.addr = TPS659038_REG_ADDR_SMPS45,
223 .gpu.pmic = &tps659038,
225 .core.value = VDD_CORE_DRA752,
226 .core.efuse.reg = STD_FUSE_OPP_VMIN_CORE_NOM,
227 .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
228 .core.addr = TPS659038_REG_ADDR_SMPS6,
229 .core.pmic = &tps659038,
231 .iva.value = VDD_IVA_DRA752,
232 .iva.efuse.reg = STD_FUSE_OPP_VMIN_IVA_NOM,
233 .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
234 .iva.addr = TPS659038_REG_ADDR_SMPS45,
235 .iva.pmic = &tps659038,
238 void hw_data_init(void)
240 *prcm = &dra7xx_prcm;
241 *dplls_data = &dra7xx_dplls;
242 *omap_vcores = &beagle_x15_volts;
243 *ctrl = &dra7xx_ctrl;
249 gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100);
254 int board_late_init(void)
258 * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
259 * This is the POWERHOLD-in-Low behavior.
261 palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);
265 void set_muxconf_regs_essential(void)
267 do_set_mux32((*ctrl)->control_padconf_core_base,
268 early_padconf, ARRAY_SIZE(early_padconf));
271 #ifdef CONFIG_IODELAY_RECALIBRATION
272 void recalibrate_iodelay(void)
274 __recalibrate_iodelay(core_padconf_array_essential,
275 ARRAY_SIZE(core_padconf_array_essential),
276 iodelay_cfg_array, ARRAY_SIZE(iodelay_cfg_array));
280 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC)
281 int board_mmc_init(bd_t *bis)
283 omap_mmc_init(0, 0, 0, -1, -1);
284 omap_mmc_init(1, 0, 0, -1, -1);
289 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
290 int spl_start_uboot(void)
292 /* break into full u-boot on 'c' */
293 if (serial_tstc() && serial_getc() == 'c')
296 #ifdef CONFIG_SPL_ENV_SUPPORT
299 if (getenv_yesno("boot_os") != 1)
307 #ifdef CONFIG_DRIVER_TI_CPSW
309 /* Delay value to add to calibrated value */
310 #define RGMII0_TXCTL_DLY_VAL ((0x3 << 5) + 0x8)
311 #define RGMII0_TXD0_DLY_VAL ((0x3 << 5) + 0x8)
312 #define RGMII0_TXD1_DLY_VAL ((0x3 << 5) + 0x2)
313 #define RGMII0_TXD2_DLY_VAL ((0x4 << 5) + 0x0)
314 #define RGMII0_TXD3_DLY_VAL ((0x4 << 5) + 0x0)
315 #define VIN2A_D13_DLY_VAL ((0x3 << 5) + 0x8)
316 #define VIN2A_D17_DLY_VAL ((0x3 << 5) + 0x8)
317 #define VIN2A_D16_DLY_VAL ((0x3 << 5) + 0x2)
318 #define VIN2A_D15_DLY_VAL ((0x4 << 5) + 0x0)
319 #define VIN2A_D14_DLY_VAL ((0x4 << 5) + 0x0)
321 static void cpsw_control(int enabled)
323 /* VTP can be added here */
326 static struct cpsw_slave_data cpsw_slaves[] = {
328 .slave_reg_ofs = 0x208,
329 .sliver_reg_ofs = 0xd80,
333 .slave_reg_ofs = 0x308,
334 .sliver_reg_ofs = 0xdc0,
339 static struct cpsw_platform_data cpsw_data = {
340 .mdio_base = CPSW_MDIO_BASE,
341 .cpsw_base = CPSW_BASE,
344 .cpdma_reg_ofs = 0x800,
346 .slave_data = cpsw_slaves,
347 .ale_reg_ofs = 0xd00,
349 .host_port_reg_ofs = 0x108,
350 .hw_stats_reg_ofs = 0x900,
351 .bd_ram_ofs = 0x2000,
352 .mac_control = (1 << 5),
353 .control = cpsw_control,
355 .version = CPSW_CTRL_VERSION_2,
358 int board_eth_init(bd_t *bis)
362 uint32_t mac_hi, mac_lo;
365 /* try reading mac address from efuse */
366 mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
367 mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
368 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
369 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
370 mac_addr[2] = mac_hi & 0xFF;
371 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
372 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
373 mac_addr[5] = mac_lo & 0xFF;
375 if (!getenv("ethaddr")) {
376 printf("<ethaddr> not set. Validating first E-fuse MAC\n");
378 if (is_valid_ethaddr(mac_addr))
379 eth_setenv_enetaddr("ethaddr", mac_addr);
382 mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
383 mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
384 mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
385 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
386 mac_addr[2] = mac_hi & 0xFF;
387 mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
388 mac_addr[4] = (mac_lo & 0xFF00) >> 8;
389 mac_addr[5] = mac_lo & 0xFF;
391 if (!getenv("eth1addr")) {
392 if (is_valid_ethaddr(mac_addr))
393 eth_setenv_enetaddr("eth1addr", mac_addr);
396 ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
398 writel(ctrl_val, (*ctrl)->control_core_control_io1);
400 ret = cpsw_register(&cpsw_data);
402 printf("Error %d registering CPSW switch\n", ret);