2 * (C) Heiko Schocher, DENX Software Engineering, hs@denx.de.
4 * U-Boot:board/davinci/da8xxevm/da850evm.c
6 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
8 * Based on da830evm.c. Original Copyrights follow:
10 * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
11 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
13 * SPDX-License-Identifier: GPL-2.0+
21 #include <spi_flash.h>
22 #include <asm/arch/hardware.h>
23 #include <asm/ti-common/davinci_nand.h>
24 #include <asm/arch/emac_defs.h>
25 #include <asm/arch/pinmux_defs.h>
27 #include <asm/arch/davinci_misc.h>
28 #include <linux/errno.h>
31 #include <bootstage.h>
32 #include <asm/mach-types.h>
34 DECLARE_GLOBAL_DATA_PTR;
36 #ifdef CONFIG_DRIVER_TI_EMAC
37 #ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
42 #endif /* CONFIG_DRIVER_TI_EMAC */
44 void dsp_lpsc_on(unsigned domain, unsigned int id)
46 dv_reg_p mdstat, mdctl, ptstat, ptcmd;
47 struct davinci_psc_regs *psc_regs;
49 psc_regs = davinci_psc0_regs;
50 mdstat = &psc_regs->psc0.mdstat[id];
51 mdctl = &psc_regs->psc0.mdctl[id];
52 ptstat = &psc_regs->ptstat;
53 ptcmd = &psc_regs->ptcmd;
55 while (*ptstat & (0x1 << domain))
58 if ((*mdstat & 0x1f) == 0x03)
59 return; /* Already on and enabled */
63 *ptcmd = 0x1 << domain;
65 while (*ptstat & (0x1 << domain))
67 while ((*mdstat & 0x1f) != 0x03)
68 ; /* Probably an overkill... */
71 static void dspwake(void)
73 unsigned *resetvect = (unsigned *)DAVINCI_L3CBARAM_BASE;
76 /* if the device is ARM only, return */
77 if ((readl(CHIP_REV_ID_REG) & 0x3f) == 0x10)
80 if (hwconfig_subarg_cmp_f("dsp", "wake", "no", NULL))
83 *resetvect++ = 0x1E000; /* DSP Idle */
84 /* clear out the next 10 words as NOP */
85 memset(resetvect, 0, sizeof(unsigned) * 10);
87 /* setup the DSP reset vector */
88 writel(DAVINCI_L3CBARAM_BASE, HOST1CFG);
90 dsp_lpsc_on(1, DAVINCI_LPSC_GEM);
91 val = readl(PSC0_MDCTL + (15 * 4));
93 writel(val, (PSC0_MDCTL + (15 * 4)));
102 static const struct pinmux_config gpio_pins[] = {
103 /* GP7[14] selects bootmode*/
104 { pinmux(16), 8, 3 }, /* GP7[14] */
107 const struct pinmux_resource pinmuxes[] = {
108 #ifdef CONFIG_DRIVER_TI_EMAC
109 PINMUX_ITEM(emac_pins_mdio),
110 #ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
111 PINMUX_ITEM(emac_pins_rmii),
113 PINMUX_ITEM(emac_pins_mii),
116 PINMUX_ITEM(uart2_pins_txrx),
117 PINMUX_ITEM(uart2_pins_rtscts),
118 PINMUX_ITEM(uart0_pins_txrx),
119 PINMUX_ITEM(uart0_pins_rtscts),
120 #ifdef CONFIG_NAND_DAVINCI
121 PINMUX_ITEM(emifa_pins_cs3),
122 PINMUX_ITEM(emifa_pins_nand),
124 PINMUX_ITEM(gpio_pins),
127 const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
129 const struct lpsc_resource lpsc[] = {
130 { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
131 { DAVINCI_LPSC_EMAC }, /* image download */
132 { DAVINCI_LPSC_UART2 }, /* console */
133 { DAVINCI_LPSC_UART0 }, /* console */
134 { DAVINCI_LPSC_GPIO },
137 const int lpsc_size = ARRAY_SIZE(lpsc);
139 #ifndef CONFIG_DA850_EVM_MAX_CPU_CLK
140 #define CONFIG_DA850_EVM_MAX_CPU_CLK 300000000
143 #define REV_AM18X_EVM 0x100
146 * get_board_rev() - setup to pass kernel board revision information
148 * bit[0-3] Maximum cpu clock rate supported by onboard SoC
154 u32 get_board_rev(void)
157 u32 maxcpuclk = CONFIG_DA850_EVM_MAX_CPU_CLK;
160 s = getenv("maxcpuclk");
162 maxcpuclk = simple_strtoul(s, NULL, 10);
164 if (maxcpuclk >= 456000000)
166 else if (maxcpuclk >= 408000000)
168 else if (maxcpuclk >= 372000000)
170 #ifdef CONFIG_DA850_AM18X_EVM
171 rev |= REV_AM18X_EVM;
176 int board_early_init_f(void)
179 * Power on required peripherals
180 * ARM does not have access by default to PSC0 and PSC1
181 * assuming here that the DSP bootloader has set the IOPU
182 * such that PSC access is available to ARM
184 if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
194 /* arch number of the board */
195 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA850_EVM;
197 /* address of boot parameters */
198 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
200 /* setup the SUSPSRC for ARM to control emulation suspend */
201 writel(readl(&davinci_syscfg_regs->suspsrc) &
202 ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
203 DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
204 DAVINCI_SYSCFG_SUSPSRC_UART0),
205 &davinci_syscfg_regs->suspsrc);
207 /* configure pinmux settings */
208 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
211 #ifdef CONFIG_DRIVER_TI_EMAC
212 davinci_emac_mii_mode_sel(HAS_RMII);
213 #endif /* CONFIG_DRIVER_TI_EMAC */
215 /* enable the console UART */
216 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
217 DAVINCI_UART_PWREMU_MGMT_UTRST),
218 #if (CONFIG_SYS_NS16550_COM1 == DAVINCI_UART0_BASE)
219 &davinci_uart0_ctrl_regs->pwremu_mgmt);
221 &davinci_uart2_ctrl_regs->pwremu_mgmt);
226 #ifdef CONFIG_DRIVER_TI_EMAC
228 * Initializes on-board ethernet controllers.
230 int board_eth_init(bd_t *bis)
232 if (!davinci_emac_initialize()) {
233 printf("Error: Ethernet init failed!\n");
239 #endif /* CONFIG_DRIVER_TI_EMAC */
241 static int init_led(int gpio, char *name, int val)
245 ret = gpio_request(gpio, name);
248 ret = gpio_direction_output(gpio, val);
258 #if !defined(CONFIG_SPL_BUILD)
259 #ifdef CONFIG_SHOW_BOOT_PROGRESS
260 void show_boot_progress(int status)
266 red = init_led(CONFIG_IPAM390_GPIO_LED_RED, "red", LED_ON);
267 if (red != CONFIG_IPAM390_GPIO_LED_RED)
270 green = init_led(CONFIG_IPAM390_GPIO_LED_GREEN, "green",
272 if (green != CONFIG_IPAM390_GPIO_LED_GREEN)
276 case BOOTSTAGE_ID_RUN_OS:
282 gpio_set_value(red, LED_ON);
283 gpio_set_value(green, LED_OFF);
285 case BOOTSTAGE_ID_MAIN_LOOP:
291 gpio_set_value(red, LED_ON);
292 gpio_set_value(green, LED_ON);
299 #ifdef CONFIG_SPL_OS_BOOT
300 int spl_start_uboot(void)
306 * GP7[14] selects bootmode:
309 * if error accessing gpio boot U-Boot
315 ret = gpio_request(CONFIG_IPAM390_GPIO_BOOTMODE , "bootmode");
319 ret = gpio_direction_input(CONFIG_IPAM390_GPIO_BOOTMODE);
324 ret = gpio_get_value(CONFIG_IPAM390_GPIO_BOOTMODE);
332 init_led(CONFIG_IPAM390_GPIO_LED_RED, "red", LED_ON);
333 init_led(CONFIG_IPAM390_GPIO_LED_GREEN, "green", LED_OFF);