2 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
4 * Based on da830evm.c. Original Copyrights follow:
6 * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
7 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <asm/arch/hardware.h>
29 #include <asm/arch/emif_defs.h>
30 #include <asm/arch/emac_defs.h>
31 #include <asm/arch/pinmux_defs.h>
33 #include <asm/arch/davinci_misc.h>
36 DECLARE_GLOBAL_DATA_PTR;
38 #ifdef CONFIG_DRIVER_TI_EMAC
39 #ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
44 #endif /* CONFIG_DRIVER_TI_EMAC */
46 void dsp_lpsc_on(unsigned domain, unsigned int id)
48 dv_reg_p mdstat, mdctl, ptstat, ptcmd;
49 struct davinci_psc_regs *psc_regs;
51 psc_regs = davinci_psc0_regs;
52 mdstat = &psc_regs->psc0.mdstat[id];
53 mdctl = &psc_regs->psc0.mdctl[id];
54 ptstat = &psc_regs->ptstat;
55 ptcmd = &psc_regs->ptcmd;
57 while (*ptstat & (0x1 << domain))
60 if ((*mdstat & 0x1f) == 0x03)
61 return; /* Already on and enabled */
65 *ptcmd = 0x1 << domain;
67 while (*ptstat & (0x1 << domain))
69 while ((*mdstat & 0x1f) != 0x03)
70 ; /* Probably an overkill... */
73 static void dspwake(void)
75 unsigned *resetvect = (unsigned *)DAVINCI_L3CBARAM_BASE;
78 /* if the device is ARM only, return */
79 if ((readl(CHIP_REV_ID_REG) & 0x3f) == 0x10)
82 if (hwconfig_subarg_cmp_f("dsp", "wake", "no", NULL))
85 *resetvect++ = 0x1E000; /* DSP Idle */
86 /* clear out the next 10 words as NOP */
87 memset(resetvect, 0, sizeof(unsigned) *10);
89 /* setup the DSP reset vector */
90 writel(DAVINCI_L3CBARAM_BASE, HOST1CFG);
92 dsp_lpsc_on(1, DAVINCI_LPSC_GEM);
93 val = readl(PSC0_MDCTL + (15 * 4));
95 writel(val, (PSC0_MDCTL + (15 * 4)));
104 static const struct pinmux_config gpio_pins[] = {
105 #ifdef CONFIG_USE_NOR
106 /* GP0[11] is required for NOR to work on Rev 3 EVMs */
107 { pinmux(0), 8, 4 }, /* GP0[11] */
111 static const struct pinmux_resource pinmuxes[] = {
112 #ifdef CONFIG_DRIVER_TI_EMAC
113 PINMUX_ITEM(emac_pins_mdio),
114 #ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
115 PINMUX_ITEM(emac_pins_rmii),
117 PINMUX_ITEM(emac_pins_mii),
120 #ifdef CONFIG_SPI_FLASH
121 PINMUX_ITEM(spi1_pins_base),
122 PINMUX_ITEM(spi1_pins_scs0),
124 PINMUX_ITEM(uart2_pins_txrx),
125 PINMUX_ITEM(uart2_pins_rtscts),
126 PINMUX_ITEM(i2c0_pins),
127 #ifdef CONFIG_NAND_DAVINCI
128 PINMUX_ITEM(emifa_pins_cs3),
129 PINMUX_ITEM(emifa_pins_cs4),
130 PINMUX_ITEM(emifa_pins_nand),
131 #elif defined(CONFIG_USE_NOR)
132 PINMUX_ITEM(emifa_pins_cs2),
133 PINMUX_ITEM(emifa_pins_nor),
135 PINMUX_ITEM(gpio_pins),
138 static const struct lpsc_resource lpsc[] = {
139 { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
140 { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
141 { DAVINCI_LPSC_EMAC }, /* image download */
142 { DAVINCI_LPSC_UART2 }, /* console */
143 { DAVINCI_LPSC_GPIO },
146 #ifndef CONFIG_DA850_EVM_MAX_CPU_CLK
147 #define CONFIG_DA850_EVM_MAX_CPU_CLK 300000000
150 #define REV_AM18X_EVM 0x100
153 * get_board_rev() - setup to pass kernel board revision information
155 * bit[0-3] Maximum cpu clock rate supported by onboard SoC
161 u32 get_board_rev(void)
164 u32 maxcpuclk = CONFIG_DA850_EVM_MAX_CPU_CLK;
167 s = getenv("maxcpuclk");
169 maxcpuclk = simple_strtoul(s, NULL, 10);
171 if (maxcpuclk >= 456000000)
173 else if (maxcpuclk >= 408000000)
175 else if (maxcpuclk >= 372000000)
177 #ifdef CONFIG_DA850_AM18X_EVM
178 rev |= REV_AM18X_EVM;
183 int board_early_init_f(void)
186 * Power on required peripherals
187 * ARM does not have access by default to PSC0 and PSC1
188 * assuming here that the DSP bootloader has set the IOPU
189 * such that PSC access is available to ARM
191 if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
199 #ifdef CONFIG_USE_NOR
203 #ifndef CONFIG_USE_IRQ
207 #ifdef CONFIG_NAND_DAVINCI
209 * NAND CS setup - cycle counts based on da850evm NAND timings in the
210 * Linux kernel @ 25MHz EMIFA
212 writel((DAVINCI_ABCR_WSETUP(0) |
213 DAVINCI_ABCR_WSTROBE(1) |
214 DAVINCI_ABCR_WHOLD(0) |
215 DAVINCI_ABCR_RSETUP(0) |
216 DAVINCI_ABCR_RSTROBE(1) |
217 DAVINCI_ABCR_RHOLD(0) |
219 DAVINCI_ABCR_ASIZE_8BIT),
220 &davinci_emif_regs->ab2cr); /* CS3 */
223 /* arch number of the board */
224 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA850_EVM;
226 /* address of boot parameters */
227 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
229 /* setup the SUSPSRC for ARM to control emulation suspend */
230 writel(readl(&davinci_syscfg_regs->suspsrc) &
231 ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
232 DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
233 DAVINCI_SYSCFG_SUSPSRC_UART2),
234 &davinci_syscfg_regs->suspsrc);
236 /* configure pinmux settings */
237 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
240 #ifdef CONFIG_USE_NOR
241 /* Set the GPIO direction as output */
242 clrbits_be32((u32 *)GPIO_BANK0_REG_DIR_ADDR, (0x01 << 11));
244 /* Set the output as low */
245 val = readl(GPIO_BANK0_REG_SET_ADDR);
247 writel(val, GPIO_BANK0_REG_CLR_ADDR);
250 #ifdef CONFIG_DRIVER_TI_EMAC
251 davinci_emac_mii_mode_sel(HAS_RMII);
252 #endif /* CONFIG_DRIVER_TI_EMAC */
254 /* enable the console UART */
255 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
256 DAVINCI_UART_PWREMU_MGMT_UTRST),
257 &davinci_uart2_ctrl_regs->pwremu_mgmt);
262 #ifdef CONFIG_DRIVER_TI_EMAC
264 #ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
268 * DA850/OMAP-L138 EVM can interface to a daughter card for
269 * additional features. This card has an I2C GPIO Expander TCA6416
270 * to select the required functions like camera, RMII Ethernet,
271 * character LCD, video.
273 * Initialization of the expander involves configuring the
274 * polarity and direction of the ports. P07-P05 are used here.
275 * These ports are connected to a Mux chip which enables only one
276 * functionality at a time.
278 * For RMII phy to respond, the MII MDIO clock has to be disabled
279 * since both the PHY devices have address as zero. The MII MDIO
280 * clock is controlled via GPIO2[6].
282 * This code is valid for Beta version of the hardware
284 int rmii_hw_init(void)
286 const struct pinmux_config gpio_pins[] = {
293 /* PinMux for GPIO */
294 if (davinci_configure_pin_mux(gpio_pins, ARRAY_SIZE(gpio_pins)) != 0)
297 /* I2C Exapnder configuration */
298 /* Set polarity to non-inverted */
301 ret = i2c_write(CONFIG_SYS_I2C_EXPANDER_ADDR, 4, 1, buf, 2);
303 printf("\nExpander @ 0x%02x write FAILED!!!\n",
304 CONFIG_SYS_I2C_EXPANDER_ADDR);
308 /* Configure P07-P05 as outputs */
311 ret = i2c_write(CONFIG_SYS_I2C_EXPANDER_ADDR, 6, 1, buf, 2);
313 printf("\nExpander @ 0x%02x write FAILED!!!\n",
314 CONFIG_SYS_I2C_EXPANDER_ADDR);
317 /* For Ethernet RMII selection
322 if (i2c_read(CONFIG_SYS_I2C_EXPANDER_ADDR, 2, 1, buf, 1)) {
323 printf("\nExpander @ 0x%02x read FAILED!!!\n",
324 CONFIG_SYS_I2C_EXPANDER_ADDR);
328 buf[0] |= (0 << 7) | (1 << 6) | (1 << 5);
329 if (i2c_write(CONFIG_SYS_I2C_EXPANDER_ADDR, 2, 1, buf, 1)) {
330 printf("\nExpander @ 0x%02x write FAILED!!!\n",
331 CONFIG_SYS_I2C_EXPANDER_ADDR);
334 /* Set the output as high */
335 temp = REG(GPIO_BANK2_REG_SET_ADDR);
337 REG(GPIO_BANK2_REG_SET_ADDR) = temp;
339 /* Set the GPIO direction as output */
340 temp = REG(GPIO_BANK2_REG_DIR_ADDR);
341 temp &= ~(0x01 << 6);
342 REG(GPIO_BANK2_REG_DIR_ADDR) = temp;
346 #endif /* CONFIG_DRIVER_TI_EMAC_USE_RMII */
349 * Initializes on-board ethernet controllers.
351 int board_eth_init(bd_t *bis)
353 #ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
354 /* Select RMII fucntion through the expander */
356 printf("RMII hardware init failed!!!\n");
358 if (!davinci_emac_initialize()) {
359 printf("Error: Ethernet init failed!\n");
365 #endif /* CONFIG_DRIVER_TI_EMAC */