1 // SPDX-License-Identifier: GPL-2.0+
5 * Board functions for TCL SL50 board
7 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
16 #include <asm/arch/cpu.h>
17 #include <asm/arch/hardware.h>
18 #include <asm/arch/omap.h>
19 #include <asm/arch/ddr_defs.h>
20 #include <asm/arch/clock.h>
21 #include <asm/arch/gpio.h>
22 #include <asm/arch/mmc_host_def.h>
23 #include <asm/arch/sys_proto.h>
24 #include <asm/arch/mem.h>
31 #include <power/tps65217.h>
32 #include <power/tps65910.h>
33 #include <env_internal.h>
37 DECLARE_GLOBAL_DATA_PTR
;
39 static struct ctrl_dev
*cdev
= (struct ctrl_dev
*)CTRL_DEVICE_BASE
;
41 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
43 static const struct ddr_data ddr3_sl50_data
= {
44 .datardsratio0
= MT41K256M16HA125E_RD_DQS
,
45 .datawdsratio0
= MT41K256M16HA125E_WR_DQS
,
46 .datafwsratio0
= MT41K256M16HA125E_PHY_FIFO_WE
,
47 .datawrsratio0
= MT41K256M16HA125E_PHY_WR_DATA
,
50 static const struct cmd_control ddr3_sl50_cmd_ctrl_data
= {
51 .cmd0csratio
= MT41K256M16HA125E_RATIO
,
52 .cmd0iclkout
= MT41K256M16HA125E_INVERT_CLKOUT
,
54 .cmd1csratio
= MT41K256M16HA125E_RATIO
,
55 .cmd1iclkout
= MT41K256M16HA125E_INVERT_CLKOUT
,
57 .cmd2csratio
= MT41K256M16HA125E_RATIO
,
58 .cmd2iclkout
= MT41K256M16HA125E_INVERT_CLKOUT
,
61 static struct emif_regs ddr3_sl50_emif_reg_data
= {
62 .sdram_config
= MT41K256M16HA125E_EMIF_SDCFG
,
63 .ref_ctrl
= MT41K256M16HA125E_EMIF_SDREF
,
64 .sdram_tim1
= MT41K256M16HA125E_EMIF_TIM1
,
65 .sdram_tim2
= MT41K256M16HA125E_EMIF_TIM2
,
66 .sdram_tim3
= MT41K256M16HA125E_EMIF_TIM3
,
67 .zq_config
= MT41K256M16HA125E_ZQ_CFG
,
68 .emif_ddr_phy_ctlr_1
= MT41K256M16HA125E_EMIF_READ_LATENCY
,
71 #ifdef CONFIG_SPL_OS_BOOT
72 int spl_start_uboot(void)
74 /* break into full u-boot on 'c' */
75 if (serial_tstc() && serial_getc() == 'c')
78 #ifdef CONFIG_SPL_ENV_SUPPORT
81 if (env_get_yesno("boot_os") != 1)
89 #define OSC (V_OSCK/1000000)
90 const struct dpll_params dpll_ddr_sl50
= {
91 400, OSC
-1, 1, -1, -1, -1, -1};
93 void am33xx_spl_board_init(void)
97 /* Get the frequency */
98 dpll_mpu_opp100
.m
= am335x_get_efuse_mpu_max_freq(cdev
);
100 /* BeagleBone PMIC Code */
103 if (i2c_probe(TPS65217_CHIP_PM
))
107 * Increase USB current limit to 1300mA or 1800mA and set
108 * the MPU voltage controller as needed.
110 if (dpll_mpu_opp100
.m
== MPUPLL_M_1000
) {
111 usb_cur_lim
= TPS65217_USB_INPUT_CUR_LIMIT_1800MA
;
112 mpu_vdd
= TPS65217_DCDC_VOLT_SEL_1325MV
;
114 usb_cur_lim
= TPS65217_USB_INPUT_CUR_LIMIT_1300MA
;
115 mpu_vdd
= TPS65217_DCDC_VOLT_SEL_1275MV
;
118 if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE
,
121 TPS65217_USB_INPUT_CUR_LIMIT_MASK
))
122 puts("tps65217_reg_write failure\n");
124 /* Set DCDC3 (CORE) voltage to 1.125V */
125 if (tps65217_voltage_update(TPS65217_DEFDCDC3
,
126 TPS65217_DCDC_VOLT_SEL_1125MV
)) {
127 puts("tps65217_voltage_update failure\n");
131 /* Set CORE Frequencies to OPP100 */
132 do_setup_dpll(&dpll_core_regs
, &dpll_core_opp100
);
134 /* Set DCDC2 (MPU) voltage */
135 if (tps65217_voltage_update(TPS65217_DEFDCDC2
, mpu_vdd
)) {
136 puts("tps65217_voltage_update failure\n");
141 * Set LDO3 to 1.8V and LDO4 to 3.3V
143 if (tps65217_reg_write(TPS65217_PROT_LEVEL_2
,
145 TPS65217_LDO_VOLTAGE_OUT_1_8
,
147 puts("tps65217_reg_write failure\n");
149 if (tps65217_reg_write(TPS65217_PROT_LEVEL_2
,
151 TPS65217_LDO_VOLTAGE_OUT_3_3
,
153 puts("tps65217_reg_write failure\n");
155 /* Set MPU Frequency to what we detected now that voltages are set */
156 do_setup_dpll(&dpll_mpu_regs
, &dpll_mpu_opp100
);
159 const struct dpll_params
*get_dpll_ddr_params(void)
161 enable_i2c0_pin_mux();
162 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED
, CONFIG_SYS_OMAP24_I2C_SLAVE
);
164 return &dpll_ddr_sl50
;
167 void set_uart_mux_conf(void)
169 #if CONFIG_CONS_INDEX == 1
170 enable_uart0_pin_mux();
171 #elif CONFIG_CONS_INDEX == 2
172 enable_uart1_pin_mux();
173 #elif CONFIG_CONS_INDEX == 3
174 enable_uart2_pin_mux();
175 #elif CONFIG_CONS_INDEX == 4
176 enable_uart3_pin_mux();
177 #elif CONFIG_CONS_INDEX == 5
178 enable_uart4_pin_mux();
179 #elif CONFIG_CONS_INDEX == 6
180 enable_uart5_pin_mux();
184 void set_mux_conf_regs(void)
186 enable_board_pin_mux();
189 const struct ctrl_ioregs ioregs_evmsk
= {
190 .cm0ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
191 .cm1ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
192 .cm2ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
193 .dt0ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
194 .dt1ioctl
= MT41J128MJT125_IOCTRL_VALUE
,
197 const struct ctrl_ioregs ioregs_bonelt
= {
198 .cm0ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
199 .cm1ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
200 .cm2ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
201 .dt0ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
202 .dt1ioctl
= MT41K256M16HA125E_IOCTRL_VALUE
,
205 const struct ctrl_ioregs ioregs_evm15
= {
206 .cm0ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
207 .cm1ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
208 .cm2ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
209 .dt0ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
210 .dt1ioctl
= MT41J512M8RH125_IOCTRL_VALUE
,
213 const struct ctrl_ioregs ioregs
= {
214 .cm0ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
215 .cm1ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
216 .cm2ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
217 .dt0ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
218 .dt1ioctl
= MT47H128M16RT25E_IOCTRL_VALUE
,
221 void sdram_init(void)
223 config_ddr(400, &ioregs_bonelt
,
225 &ddr3_sl50_cmd_ctrl_data
,
226 &ddr3_sl50_emif_reg_data
, 0);
231 * Basic board specific setup. Pinmux has been handled already.
235 #if defined(CONFIG_HW_WATCHDOG)
239 gd
->bd
->bi_boot_params
= CONFIG_SYS_SDRAM_BASE
+ 0x100;
243 #ifdef CONFIG_BOARD_LATE_INIT
244 int board_late_init(void)
250 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
251 (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
252 static void cpsw_control(int enabled
)
254 /* VTP can be added here */
259 static struct cpsw_slave_data cpsw_slaves
[] = {
261 .slave_reg_ofs
= 0x208,
262 .sliver_reg_ofs
= 0xd80,
266 .slave_reg_ofs
= 0x308,
267 .sliver_reg_ofs
= 0xdc0,
272 static struct cpsw_platform_data cpsw_data
= {
273 .mdio_base
= CPSW_MDIO_BASE
,
274 .cpsw_base
= CPSW_BASE
,
277 .cpdma_reg_ofs
= 0x800,
279 .slave_data
= cpsw_slaves
,
280 .ale_reg_ofs
= 0xd00,
282 .host_port_reg_ofs
= 0x108,
283 .hw_stats_reg_ofs
= 0x900,
284 .bd_ram_ofs
= 0x2000,
285 .mac_control
= (1 << 5),
286 .control
= cpsw_control
,
288 .version
= CPSW_CTRL_VERSION_2
,
293 * This function will:
294 * Read the eFuse for MAC addresses, and set ethaddr/eth1addr/usbnet_devaddr
296 * Perform fixups to the PHY present on certain boards. We only need this
298 * - SPL with either CPSW or USB ethernet support
299 * - Full U-Boot, with either CPSW or USB ethernet
300 * Build in only these cases to avoid warnings about unused variables
301 * when we build an SPL that has neither option but full U-Boot will.
303 #if ((defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USB_ETHER)) \
304 && defined(CONFIG_SPL_BUILD)) || \
305 ((defined(CONFIG_DRIVER_TI_CPSW) || \
306 defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)) && \
307 !defined(CONFIG_SPL_BUILD))
308 int board_eth_init(bd_t
*bis
)
312 uint32_t mac_hi
, mac_lo
;
314 /* try reading mac address from efuse */
315 mac_lo
= readl(&cdev
->macid0l
);
316 mac_hi
= readl(&cdev
->macid0h
);
317 mac_addr
[0] = mac_hi
& 0xFF;
318 mac_addr
[1] = (mac_hi
& 0xFF00) >> 8;
319 mac_addr
[2] = (mac_hi
& 0xFF0000) >> 16;
320 mac_addr
[3] = (mac_hi
& 0xFF000000) >> 24;
321 mac_addr
[4] = mac_lo
& 0xFF;
322 mac_addr
[5] = (mac_lo
& 0xFF00) >> 8;
324 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
325 (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
326 if (!env_get("ethaddr")) {
327 printf("<ethaddr> not set. Validating first E-fuse MAC\n");
329 if (is_valid_ethaddr(mac_addr
))
330 eth_env_set_enetaddr("ethaddr", mac_addr
);
333 #ifdef CONFIG_DRIVER_TI_CPSW
335 mac_lo
= readl(&cdev
->macid1l
);
336 mac_hi
= readl(&cdev
->macid1h
);
337 mac_addr
[0] = mac_hi
& 0xFF;
338 mac_addr
[1] = (mac_hi
& 0xFF00) >> 8;
339 mac_addr
[2] = (mac_hi
& 0xFF0000) >> 16;
340 mac_addr
[3] = (mac_hi
& 0xFF000000) >> 24;
341 mac_addr
[4] = mac_lo
& 0xFF;
342 mac_addr
[5] = (mac_lo
& 0xFF00) >> 8;
344 if (!env_get("eth1addr")) {
345 if (is_valid_ethaddr(mac_addr
))
346 eth_env_set_enetaddr("eth1addr", mac_addr
);
350 writel(MII_MODE_ENABLE
, &cdev
->miisel
);
351 cpsw_slaves
[0].phy_if
= cpsw_slaves
[1].phy_if
=
352 PHY_INTERFACE_MODE_MII
;
354 rv
= cpsw_register(&cpsw_data
);
356 printf("Error %d registering CPSW switch\n", rv
);
363 * CPSW RGMII Internal Delay Mode is not supported in all PVT
364 * operating points. So we must set the TX clock delay feature
365 * in the AR8051 PHY. Since we only support a single ethernet
366 * device in U-Boot, we only do this for the first instance.
368 #define AR8051_PHY_DEBUG_ADDR_REG 0x1d
369 #define AR8051_PHY_DEBUG_DATA_REG 0x1e
370 #define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5
371 #define AR8051_RGMII_TX_CLK_DLY 0x100
374 #if defined(CONFIG_USB_ETHER) && \
375 (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USB_ETHER))
376 if (is_valid_ether_addr(mac_addr
))
377 eth_env_set_enetaddr("usbnet_devaddr", mac_addr
);
379 rv
= usb_eth_initialize(bis
);
381 printf("Error %d registering USB_ETHER\n", rv
);