1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2013 Lothar Felten <lothar.felten@gmail.com>
12 #include <asm/arch/cpu.h>
13 #include <asm/arch/hardware.h>
14 #include <asm/arch/ddr_defs.h>
15 #include <asm/arch/clock.h>
16 #include <asm/arch/sys_proto.h>
22 DECLARE_GLOBAL_DATA_PTR;
24 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
26 #if defined(CONFIG_SPL_BUILD)
28 /* DDR3 RAM timings */
29 static const struct ddr_data ddr3_data = {
30 .datardsratio0 = MT41K128MJT187E_RD_DQS,
31 .datawdsratio0 = MT41K128MJT187E_WR_DQS,
32 .datafwsratio0 = MT41K128MJT187E_PHY_FIFO_WE,
33 .datawrsratio0 = MT41K128MJT187E_PHY_WR_DATA,
36 static const struct cmd_control ddr3_cmd_ctrl_data = {
37 .cmd0csratio = MT41K128MJT187E_RATIO,
38 .cmd0iclkout = MT41K128MJT187E_INVERT_CLKOUT,
39 .cmd1csratio = MT41K128MJT187E_RATIO,
40 .cmd1iclkout = MT41K128MJT187E_INVERT_CLKOUT,
41 .cmd2csratio = MT41K128MJT187E_RATIO,
42 .cmd2iclkout = MT41K128MJT187E_INVERT_CLKOUT,
45 static struct emif_regs ddr3_emif_reg_data = {
46 .sdram_config = MT41K128MJT187E_EMIF_SDCFG,
47 .ref_ctrl = MT41K128MJT187E_EMIF_SDREF,
48 .sdram_tim1 = MT41K128MJT187E_EMIF_TIM1,
49 .sdram_tim2 = MT41K128MJT187E_EMIF_TIM2,
50 .sdram_tim3 = MT41K128MJT187E_EMIF_TIM3,
51 .zq_config = MT41K128MJT187E_ZQ_CFG,
52 .emif_ddr_phy_ctlr_1 = MT41K128MJT187E_EMIF_READ_LATENCY |
56 const struct ctrl_ioregs ddr3_ioregs = {
57 .cm0ioctl = MT41K128MJT187E_IOCTRL_VALUE,
58 .cm1ioctl = MT41K128MJT187E_IOCTRL_VALUE,
59 .cm2ioctl = MT41K128MJT187E_IOCTRL_VALUE,
60 .dt0ioctl = MT41K128MJT187E_IOCTRL_VALUE,
61 .dt1ioctl = MT41K128MJT187E_IOCTRL_VALUE,
64 #ifdef CONFIG_SPL_OS_BOOT
65 int spl_start_uboot(void)
67 /* break into full u-boot on 'c' */
68 return serial_tstc() && serial_getc() == 'c';
72 #define OSC (V_OSCK/1000000)
73 const struct dpll_params dpll_ddr_266 = {
74 266, OSC-1, 1, -1, -1, -1, -1};
75 const struct dpll_params dpll_ddr_303 = {
76 303, OSC-1, 1, -1, -1, -1, -1};
77 const struct dpll_params dpll_ddr_400 = {
78 400, OSC-1, 1, -1, -1, -1, -1};
80 void am33xx_spl_board_init(void)
83 * The pengwyn board uses the TPS650250 PMIC without I2C
84 * interface and will output the following fixed voltages:
85 * DCDC1=3V3 (IO) DCDC2=1V5 (DDR) DCDC3=1V26 (Vmpu)
86 * VLDO1=1V8 (IO) VLDO2=1V8(IO)
87 * Vcore=1V1 is fixed, generated by TPS62231
90 /* Get the frequency */
91 dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev);
93 /* Set CORE Frequencies to OPP100 */
94 do_setup_dpll(&dpll_core_regs, &dpll_core_opp100);
96 /* 720MHz cpu, this might change on newer board revisions */
97 dpll_mpu_opp100.m = MPUPLL_M_720;
98 do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100);
101 const struct dpll_params *get_dpll_ddr_params(void)
103 /* future configs can return other clock settings */
104 return &dpll_ddr_303;
107 void set_uart_mux_conf(void)
109 enable_uart0_pin_mux();
112 void set_mux_conf_regs(void)
114 enable_board_pin_mux();
117 void sdram_init(void)
119 config_ddr(303, &ddr3_ioregs, &ddr3_data,
120 &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);
122 #endif /* if CONFIG_SPL_BUILD */
125 * Basic board specific setup. Pinmux has been handled already.
129 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
130 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
135 #ifdef CONFIG_DRIVER_TI_CPSW
136 static void cpsw_control(int enabled)
138 /* VTP can be added here */
142 static struct cpsw_slave_data cpsw_slaves[] = {
144 .slave_reg_ofs = 0x208,
145 .sliver_reg_ofs = 0xd80,
147 .phy_if = PHY_INTERFACE_MODE_MII,
151 static struct cpsw_platform_data cpsw_data = {
152 .mdio_base = CPSW_MDIO_BASE,
153 .cpsw_base = CPSW_BASE,
156 .cpdma_reg_ofs = 0x800,
158 .slave_data = cpsw_slaves,
159 .ale_reg_ofs = 0xd00,
161 .host_port_reg_ofs = 0x108,
162 .hw_stats_reg_ofs = 0x900,
163 .bd_ram_ofs = 0x2000,
164 .mac_control = (1 << 5),
165 .control = cpsw_control,
167 .version = CPSW_CTRL_VERSION_2,
170 int board_eth_init(bd_t *bis)
174 uint32_t mac_hi, mac_lo;
176 if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
177 printf("<ethaddr> not set. Reading from E-fuse\n");
178 /* try reading mac address from efuse */
179 mac_lo = readl(&cdev->macid0l);
180 mac_hi = readl(&cdev->macid0h);
181 mac_addr[0] = mac_hi & 0xFF;
182 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
183 mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
184 mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
185 mac_addr[4] = mac_lo & 0xFF;
186 mac_addr[5] = (mac_lo & 0xFF00) >> 8;
188 if (is_valid_ethaddr(mac_addr))
189 eth_env_set_enetaddr("ethaddr", mac_addr);
194 writel(MII_MODE_ENABLE, &cdev->miisel);
196 rv = cpsw_register(&cpsw_data);
198 printf("Error %d registering CPSW switch\n", rv);
203 #endif /* if CONFIG_DRIVER_TI_CPSW */