2 * Board functions for IGEP COM AQUILA/CYGNUS based boards
4 * Copyright (C) 2013, ISEE 2007 SL - http://www.isee.biz/
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
14 * GNU General Public License for more details.
20 #include <asm/arch/cpu.h>
21 #include <asm/arch/hardware.h>
22 #include <asm/arch/omap.h>
23 #include <asm/arch/ddr_defs.h>
24 #include <asm/arch/clock.h>
25 #include <asm/arch/gpio.h>
26 #include <asm/arch/mmc_host_def.h>
27 #include <asm/arch/sys_proto.h>
36 DECLARE_GLOBAL_DATA_PTR;
38 static struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
39 #ifdef CONFIG_SPL_BUILD
40 static struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
43 /* MII mode defines */
44 #define RMII_MODE_ENABLE 0x4D
46 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
49 #ifdef CONFIG_SPL_BUILD
50 #define UART_RESET (0x1 << 1)
51 #define UART_CLK_RUNNING_MASK 0x1
52 #define UART_SMART_IDLE_EN (0x1 << 0x3)
54 static const struct ddr_data ddr3_data = {
55 .datardsratio0 = K4B2G1646EBIH9_RD_DQS,
56 .datawdsratio0 = K4B2G1646EBIH9_WR_DQS,
57 .datafwsratio0 = K4B2G1646EBIH9_PHY_FIFO_WE,
58 .datawrsratio0 = K4B2G1646EBIH9_PHY_WR_DATA,
59 .datadldiff0 = PHY_DLL_LOCK_DIFF,
62 static const struct cmd_control ddr3_cmd_ctrl_data = {
63 .cmd0csratio = K4B2G1646EBIH9_RATIO,
64 .cmd0dldiff = K4B2G1646EBIH9_DLL_LOCK_DIFF,
65 .cmd0iclkout = K4B2G1646EBIH9_INVERT_CLKOUT,
67 .cmd1csratio = K4B2G1646EBIH9_RATIO,
68 .cmd1dldiff = K4B2G1646EBIH9_DLL_LOCK_DIFF,
69 .cmd1iclkout = K4B2G1646EBIH9_INVERT_CLKOUT,
71 .cmd2csratio = K4B2G1646EBIH9_RATIO,
72 .cmd2dldiff = K4B2G1646EBIH9_DLL_LOCK_DIFF,
73 .cmd2iclkout = K4B2G1646EBIH9_INVERT_CLKOUT,
76 static struct emif_regs ddr3_emif_reg_data = {
77 .sdram_config = K4B2G1646EBIH9_EMIF_SDCFG,
78 .ref_ctrl = K4B2G1646EBIH9_EMIF_SDREF,
79 .sdram_tim1 = K4B2G1646EBIH9_EMIF_TIM1,
80 .sdram_tim2 = K4B2G1646EBIH9_EMIF_TIM2,
81 .sdram_tim3 = K4B2G1646EBIH9_EMIF_TIM3,
82 .zq_config = K4B2G1646EBIH9_ZQ_CFG,
83 .emif_ddr_phy_ctlr_1 = K4B2G1646EBIH9_EMIF_READ_LATENCY,
88 * Early system init of muxing and clocks.
93 * Save the boot parameters passed from romcode.
94 * We cannot delay the saving further than this,
95 * to prevent overwrites.
97 #ifdef CONFIG_SPL_BUILD
98 save_omap_boot_params();
101 /* WDT1 is already running when the bootloader gets control
102 * Disable it to avoid "random" resets
104 writel(0xAAAA, &wdtimer->wdtwspr);
105 while (readl(&wdtimer->wdtwwps) != 0x0)
107 writel(0x5555, &wdtimer->wdtwspr);
108 while (readl(&wdtimer->wdtwwps) != 0x0)
111 #ifdef CONFIG_SPL_BUILD
112 /* Setup the PLLs and the clocks for the peripherals */
115 /* Enable RTC32K clock */
121 enable_uart0_pin_mux();
123 regval = readl(&uart_base->uartsyscfg);
124 regval |= UART_RESET;
125 writel(regval, &uart_base->uartsyscfg);
126 while ((readl(&uart_base->uartsyssts) &
127 UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
130 /* Disable smart idle */
131 regval = readl(&uart_base->uartsyscfg);
132 regval |= UART_SMART_IDLE_EN;
133 writel(regval, &uart_base->uartsyscfg);
137 preloader_console_init();
139 /* Configure board pin mux */
140 enable_board_pin_mux();
142 config_ddr(303, K4B2G1646EBIH9_IOCTRL_VALUE, &ddr3_data,
143 &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);
148 * Basic board specific setup. Pinmux has been handled already.
152 gd->bd->bi_boot_params = PHYS_DRAM_1 + 0x100;
159 #if defined(CONFIG_DRIVER_TI_CPSW)
160 static void cpsw_control(int enabled)
162 /* VTP can be added here */
167 static struct cpsw_slave_data cpsw_slaves[] = {
169 .slave_reg_ofs = 0x208,
170 .sliver_reg_ofs = 0xd80,
172 .phy_if = PHY_INTERFACE_MODE_RMII,
176 static struct cpsw_platform_data cpsw_data = {
177 .mdio_base = CPSW_MDIO_BASE,
178 .cpsw_base = CPSW_BASE,
181 .cpdma_reg_ofs = 0x800,
183 .slave_data = cpsw_slaves,
184 .ale_reg_ofs = 0xd00,
186 .host_port_reg_ofs = 0x108,
187 .hw_stats_reg_ofs = 0x900,
188 .mac_control = (1 << 5),
189 .control = cpsw_control,
191 .version = CPSW_CTRL_VERSION_2,
194 int board_eth_init(bd_t *bis)
198 uint32_t mac_hi, mac_lo;
200 if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
201 /* try reading mac address from efuse */
202 mac_lo = readl(&cdev->macid0l);
203 mac_hi = readl(&cdev->macid0h);
204 mac_addr[0] = mac_hi & 0xFF;
205 mac_addr[1] = (mac_hi & 0xFF00) >> 8;
206 mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
207 mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
208 mac_addr[4] = mac_lo & 0xFF;
209 mac_addr[5] = (mac_lo & 0xFF00) >> 8;
210 if (is_valid_ether_addr(mac_addr))
211 eth_setenv_enetaddr("ethaddr", mac_addr);
214 writel(RMII_MODE_ENABLE, &cdev->miisel);
216 rv = cpsw_register(&cpsw_data);
218 printf("Error %d registering CPSW switch\n", rv);