4 * Board functions for TCL SL50 board
6 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
8 * SPDX-License-Identifier: GPL-2.0+
14 #include <asm/arch/cpu.h>
15 #include <asm/arch/hardware.h>
16 #include <asm/arch/omap.h>
17 #include <asm/arch/ddr_defs.h>
18 #include <asm/arch/clock.h>
19 #include <asm/arch/gpio.h>
20 #include <asm/arch/mmc_host_def.h>
21 #include <asm/arch/sys_proto.h>
22 #include <asm/arch/mem.h>
29 #include <power/tps65217.h>
30 #include <power/tps65910.h>
31 #include <environment.h>
33 #include <environment.h>
36 DECLARE_GLOBAL_DATA_PTR
;
38 static struct ctrl_dev
*cdev
= (struct ctrl_dev
*)CTRL_DEVICE_BASE
;
40 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
42 static const struct ddr_data ddr3_sl50_data
= {
43 .datardsratio0
= MT41K256M16HA125E_RD_DQS
,
44 .datawdsratio0
= MT41K256M16HA125E_WR_DQS
,
45 .datafwsratio0
= MT41K256M16HA125E_PHY_FIFO_WE
,
46 .datawrsratio0
= MT41K256M16HA125E_PHY_WR_DATA
,
49 static const struct cmd_control ddr3_sl50_cmd_ctrl_data
= {
50 .cmd0csratio
= MT41K256M16HA125E_RATIO
,
51 .cmd0iclkout
= MT41K256M16HA125E_INVERT_CLKOUT
,
53 .cmd1csratio
= MT41K256M16HA125E_RATIO
,
54 .cmd1iclkout
= MT41K256M16HA125E_INVERT_CLKOUT
,
56 .cmd2csratio
= MT41K256M16HA125E_RATIO
,
57 .cmd2iclkout
= MT41K256M16HA125E_INVERT_CLKOUT
,
60 static struct emif_regs ddr3_sl50_emif_reg_data
= {
61 .sdram_config
= MT41K256M16HA125E_EMIF_SDCFG
,
62 .ref_ctrl
= MT41K256M16HA125E_EMIF_SDREF
,
63 .sdram_tim1
= MT41K256M16HA125E_EMIF_TIM1
,
64 .sdram_tim2
= MT41K256M16HA125E_EMIF_TIM2
,
65 .sdram_tim3
= MT41K256M16HA125E_EMIF_TIM3
,
66 .zq_config
= MT41K256M16HA125E_ZQ_CFG
,
67 .emif_ddr_phy_ctlr_1
= MT41K256M16HA125E_EMIF_READ_LATENCY
,
70 #ifdef CONFIG_SPL_OS_BOOT
71 int spl_start_uboot(void)
73 /* break into full u-boot on 'c' */
74 if (serial_tstc() && serial_getc() == 'c')
77 #ifdef CONFIG_SPL_ENV_SUPPORT
80 if (env_get_yesno("boot_os") != 1)
88 #define OSC (V_OSCK/1000000)
89 const struct dpll_params dpll_ddr_sl50
= {
90 400, OSC
-1, 1, -1, -1, -1, -1};
92 void am33xx_spl_board_init(void)
96 /* Get the frequency */
97 dpll_mpu_opp100
.m
= am335x_get_efuse_mpu_max_freq(cdev
);
99 /* BeagleBone PMIC Code */
102 if (i2c_probe(TPS65217_CHIP_PM
))
106 * Increase USB current limit to 1300mA or 1800mA and set
107 * the MPU voltage controller as needed.
109 if (dpll_mpu_opp100
.m
== MPUPLL_M_1000
) {
110 usb_cur_lim
= TPS65217_USB_INPUT_CUR_LIMIT_1800MA
;
111 mpu_vdd
= TPS65217_DCDC_VOLT_SEL_1325MV
;
113 usb_cur_lim
= TPS65217_USB_INPUT_CUR_LIMIT_1300MA
;
114 mpu_vdd
= TPS65217_DCDC_VOLT_SEL_1275MV
;
117 if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE
,
120 TPS65217_USB_INPUT_CUR_LIMIT_MASK
))
121 puts("tps65217_reg_write failure\n");
123 /* Set DCDC3 (CORE) voltage to 1.125V */
124 if (tps65217_voltage_update(TPS65217_DEFDCDC3
,
125 TPS65217_DCDC_VOLT_SEL_1125MV
)) {
126 puts("tps65217_voltage_update failure\n");
130 /* Set CORE Frequencies to OPP100 */
131 do_setup_dpll(&dpll_core_regs
, &dpll_core_opp100
);
133 /* Set DCDC2 (MPU) voltage */
134 if (tps65217_voltage_update(TPS65217_DEFDCDC2
, mpu_vdd
)) {
135 puts("tps65217_voltage_update failure\n");
140 * Set LDO3 to 1.8V and LDO4 to 3.3V
142 if (tps65217_reg_write(TPS65217_PROT_LEVEL_2
,
144 TPS65217_LDO_VOLTAGE_OUT_1_8
,
146 puts("tps65217_reg_write failure\n");
148 if (tps65217_reg_write(TPS65217_PROT_LEVEL_2
,
150 TPS65217_LDO_VOLTAGE_OUT_3_3
,
152 puts("tps65217_reg_write failure\n");
154 /* Set MPU Frequency to what we detected now that voltages are set */
155 do_setup_dpll(&dpll_mpu_regs
, &dpll_mpu_opp100
);
158 const struct dpll_params
*get_dpll_ddr_params(void)
160 enable_i2c0_pin_mux();
161 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED
, CONFIG_SYS_OMAP24_I2C_SLAVE
);
163 return &dpll_ddr_sl50
;
166 void set_uart_mux_conf(void)
168 #if CONFIG_CONS_INDEX == 1
169 enable_uart0_pin_mux();
170 #elif CONFIG_CONS_INDEX == 2
171 enable_uart1_pin_mux();
172 #elif CONFIG_CONS_INDEX == 3
173 enable_uart2_pin_mux();
174 #elif CONFIG_CONS_INDEX == 4
175 enable_uart3_pin_mux();
176 #elif CONFIG_CONS_INDEX == 5
177 enable_uart4_pin_mux();
178 #elif CONFIG_CONS_INDEX == 6
179 enable_uart5_pin_mux();
183 void set_mux_conf_regs(void)
185 enable_board_pin_mux();
188 const struct ctrl_ioregs ioregs_evmsk
= {
189 .cm0ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
190 .cm1ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
191 .cm2ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
192 .dt0ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
193 .dt1ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
196 const struct ctrl_ioregs ioregs_bonelt
= {
197 .cm0ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
198 .cm1ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
199 .cm2ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
200 .dt0ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
201 .dt1ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
204 const struct ctrl_ioregs ioregs_evm15
= {
205 .cm0ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
206 .cm1ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
207 .cm2ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
208 .dt0ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
209 .dt1ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
212 const struct ctrl_ioregs ioregs
= {
213 .cm0ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
214 .cm1ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
215 .cm2ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
216 .dt0ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
217 .dt1ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
220 void sdram_init(void)
222 config_ddr(400, &ioregs_bonelt
,
224 &ddr3_sl50_cmd_ctrl_data
,
225 &ddr3_sl50_emif_reg_data
, 0);
230 * Basic board specific setup. Pinmux has been handled already.
234 #if defined(CONFIG_HW_WATCHDOG)
238 gd
->bd
->bi_boot_params
= CONFIG_SYS_SDRAM_BASE
+ 0x100;
242 #ifdef CONFIG_BOARD_LATE_INIT
243 int board_late_init(void)
249 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
250 (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
251 static void cpsw_control(int enabled
)
253 /* VTP can be added here */
258 static struct cpsw_slave_data cpsw_slaves
[] = {
260 .slave_reg_ofs
= 0x208,
261 .sliver_reg_ofs
= 0xd80,
265 .slave_reg_ofs
= 0x308,
266 .sliver_reg_ofs
= 0xdc0,
271 static struct cpsw_platform_data cpsw_data
= {
272 .mdio_base
= CPSW_MDIO_BASE
,
273 .cpsw_base
= CPSW_BASE
,
276 .cpdma_reg_ofs
= 0x800,
278 .slave_data
= cpsw_slaves
,
279 .ale_reg_ofs
= 0xd00,
281 .host_port_reg_ofs
= 0x108,
282 .hw_stats_reg_ofs
= 0x900,
283 .bd_ram_ofs
= 0x2000,
284 .mac_control
= (1 << 5),
285 .control
= cpsw_control
,
287 .version
= CPSW_CTRL_VERSION_2
,
292 * This function will:
293 * Read the eFuse for MAC addresses, and set ethaddr/eth1addr/usbnet_devaddr
295 * Perform fixups to the PHY present on certain boards. We only need this
297 * - SPL with either CPSW or USB ethernet support
298 * - Full U-Boot, with either CPSW or USB ethernet
299 * Build in only these cases to avoid warnings about unused variables
300 * when we build an SPL that has neither option but full U-Boot will.
302 #if ((defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)) \
303 && defined(CONFIG_SPL_BUILD)) || \
304 ((defined(CONFIG_DRIVER_TI_CPSW) || \
305 defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)) && \
306 !defined(CONFIG_SPL_BUILD))
307 int board_eth_init(bd_t
*bis
)
311 uint32_t mac_hi
, mac_lo
;
313 /* try reading mac address from efuse */
314 mac_lo
= readl(&cdev
->macid0l
);
315 mac_hi
= readl(&cdev
->macid0h
);
316 mac_addr
[0] = mac_hi
& 0xFF;
317 mac_addr
[1] = (mac_hi
& 0xFF00) >> 8;
318 mac_addr
[2] = (mac_hi
& 0xFF0000) >> 16;
319 mac_addr
[3] = (mac_hi
& 0xFF000000) >> 24;
320 mac_addr
[4] = mac_lo
& 0xFF;
321 mac_addr
[5] = (mac_lo
& 0xFF00) >> 8;
323 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
324 (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
325 if (!env_get("ethaddr")) {
326 printf("<ethaddr> not set. Validating first E-fuse MAC\n");
328 if (is_valid_ethaddr(mac_addr
))
329 eth_env_set_enetaddr("ethaddr", mac_addr
);
332 #ifdef CONFIG_DRIVER_TI_CPSW
334 mac_lo
= readl(&cdev
->macid1l
);
335 mac_hi
= readl(&cdev
->macid1h
);
336 mac_addr
[0] = mac_hi
& 0xFF;
337 mac_addr
[1] = (mac_hi
& 0xFF00) >> 8;
338 mac_addr
[2] = (mac_hi
& 0xFF0000) >> 16;
339 mac_addr
[3] = (mac_hi
& 0xFF000000) >> 24;
340 mac_addr
[4] = mac_lo
& 0xFF;
341 mac_addr
[5] = (mac_lo
& 0xFF00) >> 8;
343 if (!env_get("eth1addr")) {
344 if (is_valid_ethaddr(mac_addr
))
345 eth_env_set_enetaddr("eth1addr", mac_addr
);
349 writel(MII_MODE_ENABLE
, &cdev
->miisel
);
350 cpsw_slaves
[0].phy_if
= cpsw_slaves
[1].phy_if
=
351 PHY_INTERFACE_MODE_MII
;
353 rv
= cpsw_register(&cpsw_data
);
355 printf("Error %d registering CPSW switch\n", rv
);
362 * CPSW RGMII Internal Delay Mode is not supported in all PVT
363 * operating points. So we must set the TX clock delay feature
364 * in the AR8051 PHY. Since we only support a single ethernet
365 * device in U-Boot, we only do this for the first instance.
367 #define AR8051_PHY_DEBUG_ADDR_REG 0x1d
368 #define AR8051_PHY_DEBUG_DATA_REG 0x1e
369 #define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5
370 #define AR8051_RGMII_TX_CLK_DLY 0x100
373 #if defined(CONFIG_USB_ETHER) && \
374 (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
375 if (is_valid_ether_addr(mac_addr
))
376 eth_env_set_enetaddr("usbnet_devaddr", mac_addr
);
378 rv
= usb_eth_initialize(bis
);
380 printf("Error %d registering USB_ETHER\n", rv
);