1649a33e4SStefano Babic /* 2649a33e4SStefano Babic * (C) Copyright 2010 3649a33e4SStefano Babic * Stefano Babic, DENX Software Engineering, sbabic@denx.de 4649a33e4SStefano Babic * 5649a33e4SStefano Babic * Based on da850evm.c, original Copyrights follow: 6649a33e4SStefano Babic * 7649a33e4SStefano Babic * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ 8649a33e4SStefano Babic * 9649a33e4SStefano Babic * Based on da830evm.c. Original Copyrights follow: 10649a33e4SStefano Babic * 11649a33e4SStefano Babic * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com> 12649a33e4SStefano Babic * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net> 13649a33e4SStefano Babic * 14649a33e4SStefano Babic * This program is free software; you can redistribute it and/or modify 15649a33e4SStefano Babic * it under the terms of the GNU General Public License as published by 16649a33e4SStefano Babic * the Free Software Foundation; either version 2 of the License, or 17649a33e4SStefano Babic * (at your option) any later version. 18649a33e4SStefano Babic * 19649a33e4SStefano Babic * This program is distributed in the hope that it will be useful, 20649a33e4SStefano Babic * but WITHOUT ANY WARRANTY; without even the implied warranty of 21649a33e4SStefano Babic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22649a33e4SStefano Babic * GNU General Public License for more details. 23649a33e4SStefano Babic * 24649a33e4SStefano Babic * You should have received a copy of the GNU General Public License 25649a33e4SStefano Babic * along with this program; if not, write to the Free Software 26649a33e4SStefano Babic * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27649a33e4SStefano Babic */ 28649a33e4SStefano Babic 29649a33e4SStefano Babic #include <common.h> 30649a33e4SStefano Babic #include <i2c.h> 31649a33e4SStefano Babic #include <net.h> 32649a33e4SStefano Babic #include <netdev.h> 33649a33e4SStefano Babic #include <asm/arch/hardware.h> 34649a33e4SStefano Babic #include <asm/arch/emif_defs.h> 35649a33e4SStefano Babic #include <asm/arch/emac_defs.h> 36649a33e4SStefano Babic #include <asm/io.h> 37649a33e4SStefano Babic #include <asm/arch/davinci_misc.h> 38649a33e4SStefano Babic 39649a33e4SStefano Babic DECLARE_GLOBAL_DATA_PTR; 40649a33e4SStefano Babic 41649a33e4SStefano Babic #define pinmux(x) (&davinci_syscfg_regs->pinmux[x]) 42649a33e4SStefano Babic 43649a33e4SStefano Babic /* SPI0 pin muxer settings */ 44649a33e4SStefano Babic static const struct pinmux_config spi1_pins[] = { 45649a33e4SStefano Babic { pinmux(5), 1, 1 }, 46649a33e4SStefano Babic { pinmux(5), 1, 2 }, 47649a33e4SStefano Babic { pinmux(5), 1, 4 }, 48649a33e4SStefano Babic { pinmux(5), 1, 5 } 49649a33e4SStefano Babic }; 50649a33e4SStefano Babic 51*f9fc237fSBastian Ruppert /* UART0 pin muxer settings */ 52649a33e4SStefano Babic static const struct pinmux_config uart_pins[] = { 53*f9fc237fSBastian Ruppert { pinmux(3), 2, 7 }, 54*f9fc237fSBastian Ruppert { pinmux(3), 2, 6 }, 55*f9fc237fSBastian Ruppert { pinmux(3), 2, 4 }, 56*f9fc237fSBastian Ruppert { pinmux(3), 2, 5 } 57649a33e4SStefano Babic }; 58649a33e4SStefano Babic 59649a33e4SStefano Babic #ifdef CONFIG_DRIVER_TI_EMAC 60649a33e4SStefano Babic #define HAS_RMII 1 61649a33e4SStefano Babic static const struct pinmux_config emac_pins[] = { 62649a33e4SStefano Babic { pinmux(14), 8, 2 }, 63649a33e4SStefano Babic { pinmux(14), 8, 3 }, 64649a33e4SStefano Babic { pinmux(14), 8, 4 }, 65649a33e4SStefano Babic { pinmux(14), 8, 5 }, 66649a33e4SStefano Babic { pinmux(14), 8, 6 }, 67649a33e4SStefano Babic { pinmux(14), 8, 7 }, 68649a33e4SStefano Babic { pinmux(15), 8, 1 }, 69649a33e4SStefano Babic { pinmux(4), 8, 0 }, 70649a33e4SStefano Babic { pinmux(4), 8, 1 } 71649a33e4SStefano Babic }; 72649a33e4SStefano Babic #endif 73649a33e4SStefano Babic 74649a33e4SStefano Babic #ifdef CONFIG_NAND_DAVINCI 75649a33e4SStefano Babic const struct pinmux_config nand_pins[] = { 76649a33e4SStefano Babic { pinmux(7), 1, 1 }, 77649a33e4SStefano Babic { pinmux(7), 1, 2 }, 78649a33e4SStefano Babic { pinmux(7), 1, 4 }, 79649a33e4SStefano Babic { pinmux(7), 1, 5 }, 80649a33e4SStefano Babic { pinmux(9), 1, 0 }, 81649a33e4SStefano Babic { pinmux(9), 1, 1 }, 82649a33e4SStefano Babic { pinmux(9), 1, 2 }, 83649a33e4SStefano Babic { pinmux(9), 1, 3 }, 84649a33e4SStefano Babic { pinmux(9), 1, 4 }, 85649a33e4SStefano Babic { pinmux(9), 1, 5 }, 86649a33e4SStefano Babic { pinmux(9), 1, 6 }, 87649a33e4SStefano Babic { pinmux(9), 1, 7 }, 88649a33e4SStefano Babic { pinmux(12), 1, 5 }, 89649a33e4SStefano Babic { pinmux(12), 1, 6 } 90649a33e4SStefano Babic }; 91649a33e4SStefano Babic #endif 92649a33e4SStefano Babic 93649a33e4SStefano Babic static const struct pinmux_resource pinmuxes[] = { 94649a33e4SStefano Babic #ifdef CONFIG_SPI_FLASH 95649a33e4SStefano Babic PINMUX_ITEM(spi1_pins), 96649a33e4SStefano Babic #endif 97649a33e4SStefano Babic PINMUX_ITEM(uart_pins), 98649a33e4SStefano Babic #ifdef CONFIG_NAND_DAVINCI 99649a33e4SStefano Babic PINMUX_ITEM(nand_pins), 100649a33e4SStefano Babic #endif 101649a33e4SStefano Babic }; 102649a33e4SStefano Babic 103649a33e4SStefano Babic static const struct lpsc_resource lpsc[] = { 104649a33e4SStefano Babic { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */ 105649a33e4SStefano Babic { DAVINCI_LPSC_SPI1 }, /* Serial Flash */ 106649a33e4SStefano Babic { DAVINCI_LPSC_EMAC }, /* image download */ 107*f9fc237fSBastian Ruppert { DAVINCI_LPSC_UART0 }, /* console */ 108649a33e4SStefano Babic { DAVINCI_LPSC_GPIO }, 109649a33e4SStefano Babic }; 110649a33e4SStefano Babic 111649a33e4SStefano Babic int board_init(void) 112649a33e4SStefano Babic { 113649a33e4SStefano Babic #ifndef CONFIG_USE_IRQ 114649a33e4SStefano Babic irq_init(); 115649a33e4SStefano Babic #endif 116649a33e4SStefano Babic 117649a33e4SStefano Babic 118649a33e4SStefano Babic #ifdef CONFIG_NAND_DAVINCI 119649a33e4SStefano Babic /* 120649a33e4SStefano Babic * NAND CS setup - cycle counts based on da850evm NAND timings in the 121649a33e4SStefano Babic * Linux kernel @ 25MHz EMIFA 122649a33e4SStefano Babic */ 123649a33e4SStefano Babic writel((DAVINCI_ABCR_WSETUP(0) | 124649a33e4SStefano Babic DAVINCI_ABCR_WSTROBE(0) | 125649a33e4SStefano Babic DAVINCI_ABCR_WHOLD(0) | 126649a33e4SStefano Babic DAVINCI_ABCR_RSETUP(0) | 127649a33e4SStefano Babic DAVINCI_ABCR_RSTROBE(1) | 128649a33e4SStefano Babic DAVINCI_ABCR_RHOLD(0) | 129649a33e4SStefano Babic DAVINCI_ABCR_TA(0) | 130649a33e4SStefano Babic DAVINCI_ABCR_ASIZE_8BIT), 131649a33e4SStefano Babic &davinci_emif_regs->ab2cr); /* CS3 */ 132649a33e4SStefano Babic #endif 133649a33e4SStefano Babic 134649a33e4SStefano Babic /* arch number of the board */ 135649a33e4SStefano Babic gd->bd->bi_arch_number = MACH_TYPE_EA20; 136649a33e4SStefano Babic 137649a33e4SStefano Babic /* address of boot parameters */ 138649a33e4SStefano Babic gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; 139649a33e4SStefano Babic 140649a33e4SStefano Babic /* 141649a33e4SStefano Babic * Power on required peripherals 142649a33e4SStefano Babic * ARM does not have access by default to PSC0 and PSC1 143649a33e4SStefano Babic * assuming here that the DSP bootloader has set the IOPU 144649a33e4SStefano Babic * such that PSC access is available to ARM 145649a33e4SStefano Babic */ 146649a33e4SStefano Babic if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc))) 147649a33e4SStefano Babic return 1; 148649a33e4SStefano Babic 149649a33e4SStefano Babic /* setup the SUSPSRC for ARM to control emulation suspend */ 150649a33e4SStefano Babic writel(readl(&davinci_syscfg_regs->suspsrc) & 151649a33e4SStefano Babic ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C | 152649a33e4SStefano Babic DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 | 153*f9fc237fSBastian Ruppert DAVINCI_SYSCFG_SUSPSRC_UART0), 154649a33e4SStefano Babic &davinci_syscfg_regs->suspsrc); 155649a33e4SStefano Babic 156649a33e4SStefano Babic /* configure pinmux settings */ 157649a33e4SStefano Babic if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes))) 158649a33e4SStefano Babic return 1; 159649a33e4SStefano Babic 160649a33e4SStefano Babic #ifdef CONFIG_DRIVER_TI_EMAC 161649a33e4SStefano Babic if (davinci_configure_pin_mux(emac_pins, ARRAY_SIZE(emac_pins)) != 0) 162649a33e4SStefano Babic return 1; 163649a33e4SStefano Babic 164649a33e4SStefano Babic davinci_emac_mii_mode_sel(HAS_RMII); 165649a33e4SStefano Babic #endif /* CONFIG_DRIVER_TI_EMAC */ 166649a33e4SStefano Babic 167649a33e4SStefano Babic /* enable the console UART */ 168649a33e4SStefano Babic writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | 169649a33e4SStefano Babic DAVINCI_UART_PWREMU_MGMT_UTRST), 170*f9fc237fSBastian Ruppert &davinci_uart0_ctrl_regs->pwremu_mgmt); 171649a33e4SStefano Babic 172649a33e4SStefano Babic return 0; 173649a33e4SStefano Babic } 174649a33e4SStefano Babic 175649a33e4SStefano Babic #ifdef CONFIG_DRIVER_TI_EMAC 176649a33e4SStefano Babic 177649a33e4SStefano Babic /* 178649a33e4SStefano Babic * Initializes on-board ethernet controllers. 179649a33e4SStefano Babic */ 180649a33e4SStefano Babic int board_eth_init(bd_t *bis) 181649a33e4SStefano Babic { 182649a33e4SStefano Babic if (!davinci_emac_initialize()) { 183649a33e4SStefano Babic printf("Error: Ethernet init failed!\n"); 184649a33e4SStefano Babic return -1; 185649a33e4SStefano Babic } 186649a33e4SStefano Babic 187649a33e4SStefano Babic /* 188649a33e4SStefano Babic * This board has a RMII PHY. However, the MDC line on the SOM 189649a33e4SStefano Babic * must not be disabled (there is no MII PHY on the 190649a33e4SStefano Babic * baseboard) via the GPIO2[6], because this pin 191649a33e4SStefano Babic * disables at the same time the SPI flash. 192649a33e4SStefano Babic */ 193649a33e4SStefano Babic 194649a33e4SStefano Babic return 0; 195649a33e4SStefano Babic } 196649a33e4SStefano Babic #endif /* CONFIG_DRIVER_TI_EMAC */ 197