Sudhakar Rajashekhara | 6892181 | 2010-06-10 15:18:15 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ |
| 3 | * |
| 4 | * Based on da830evm.c. Original Copyrights follow: |
| 5 | * |
| 6 | * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com> |
| 7 | * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net> |
| 8 | * |
| 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. |
| 13 | * |
| 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. |
| 18 | * |
| 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. |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <i2c.h> |
| 26 | #include <asm/arch/hardware.h> |
Ben Gardiner | cf86d2c | 2010-10-14 17:26:22 -0400 | [diff] [blame^] | 27 | #include <asm/arch/emif_defs.h> |
Sudhakar Rajashekhara | 6892181 | 2010-06-10 15:18:15 +0530 | [diff] [blame] | 28 | #include <asm/io.h> |
| 29 | #include "../common/misc.h" |
| 30 | #include "common.h" |
| 31 | |
| 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
Prakash PM | 0dab150 | 2010-07-15 16:08:38 -0400 | [diff] [blame] | 34 | #define pinmux(x) (&davinci_syscfg_regs->pinmux[x]) |
Sudhakar Rajashekhara | 6892181 | 2010-06-10 15:18:15 +0530 | [diff] [blame] | 35 | |
| 36 | /* SPI0 pin muxer settings */ |
| 37 | static const struct pinmux_config spi1_pins[] = { |
Prakash PM | 0dab150 | 2010-07-15 16:08:38 -0400 | [diff] [blame] | 38 | { pinmux(5), 1, 1 }, |
| 39 | { pinmux(5), 1, 2 }, |
| 40 | { pinmux(5), 1, 4 }, |
| 41 | { pinmux(5), 1, 5 } |
Sudhakar Rajashekhara | 6892181 | 2010-06-10 15:18:15 +0530 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | /* UART pin muxer settings */ |
| 45 | static const struct pinmux_config uart_pins[] = { |
Prakash PM | 0dab150 | 2010-07-15 16:08:38 -0400 | [diff] [blame] | 46 | { pinmux(0), 4, 6 }, |
| 47 | { pinmux(0), 4, 7 }, |
| 48 | { pinmux(4), 2, 4 }, |
| 49 | { pinmux(4), 2, 5 } |
Sudhakar Rajashekhara | 6892181 | 2010-06-10 15:18:15 +0530 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | /* I2C pin muxer settings */ |
| 53 | static const struct pinmux_config i2c_pins[] = { |
Prakash PM | 0dab150 | 2010-07-15 16:08:38 -0400 | [diff] [blame] | 54 | { pinmux(4), 2, 2 }, |
| 55 | { pinmux(4), 2, 3 } |
Sudhakar Rajashekhara | 6892181 | 2010-06-10 15:18:15 +0530 | [diff] [blame] | 56 | }; |
| 57 | |
Ben Gardiner | f522c1b | 2010-10-14 17:26:19 -0400 | [diff] [blame] | 58 | #ifdef CONFIG_NAND_DAVINCI |
| 59 | const struct pinmux_config nand_pins[] = { |
| 60 | { pinmux(7), 1, 1 }, |
| 61 | { pinmux(7), 1, 2 }, |
| 62 | { pinmux(7), 1, 4 }, |
| 63 | { pinmux(7), 1, 5 }, |
| 64 | { pinmux(9), 1, 0 }, |
| 65 | { pinmux(9), 1, 1 }, |
| 66 | { pinmux(9), 1, 2 }, |
| 67 | { pinmux(9), 1, 3 }, |
| 68 | { pinmux(9), 1, 4 }, |
| 69 | { pinmux(9), 1, 5 }, |
| 70 | { pinmux(9), 1, 6 }, |
| 71 | { pinmux(9), 1, 7 }, |
| 72 | { pinmux(12), 1, 5 }, |
| 73 | { pinmux(12), 1, 6 } |
| 74 | }; |
| 75 | #endif |
| 76 | |
Sudhakar Rajashekhara | 6892181 | 2010-06-10 15:18:15 +0530 | [diff] [blame] | 77 | static const struct pinmux_resource pinmuxes[] = { |
| 78 | #ifdef CONFIG_SPI_FLASH |
| 79 | PINMUX_ITEM(spi1_pins), |
| 80 | #endif |
| 81 | PINMUX_ITEM(uart_pins), |
| 82 | PINMUX_ITEM(i2c_pins), |
Ben Gardiner | f522c1b | 2010-10-14 17:26:19 -0400 | [diff] [blame] | 83 | #ifdef CONFIG_NAND_DAVINCI |
| 84 | PINMUX_ITEM(nand_pins), |
| 85 | #endif |
Sudhakar Rajashekhara | 6892181 | 2010-06-10 15:18:15 +0530 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | static const struct lpsc_resource lpsc[] = { |
| 89 | { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */ |
| 90 | { DAVINCI_LPSC_SPI1 }, /* Serial Flash */ |
| 91 | { DAVINCI_LPSC_EMAC }, /* image download */ |
| 92 | { DAVINCI_LPSC_UART2 }, /* console */ |
| 93 | { DAVINCI_LPSC_GPIO }, |
| 94 | }; |
| 95 | |
| 96 | int board_init(void) |
| 97 | { |
| 98 | #ifndef CONFIG_USE_IRQ |
| 99 | irq_init(); |
| 100 | #endif |
| 101 | |
Ben Gardiner | cf86d2c | 2010-10-14 17:26:22 -0400 | [diff] [blame^] | 102 | |
| 103 | #ifdef CONFIG_NAND_DAVINCI |
| 104 | /* |
| 105 | * NAND CS setup - cycle counts based on da850evm NAND timings in the |
| 106 | * Linux kernel @ 25MHz EMIFA |
| 107 | */ |
| 108 | writel((DAVINCI_ABCR_WSETUP(0) | |
| 109 | DAVINCI_ABCR_WSTROBE(0) | |
| 110 | DAVINCI_ABCR_WHOLD(0) | |
| 111 | DAVINCI_ABCR_RSETUP(0) | |
| 112 | DAVINCI_ABCR_RSTROBE(1) | |
| 113 | DAVINCI_ABCR_RHOLD(0) | |
| 114 | DAVINCI_ABCR_TA(0) | |
| 115 | DAVINCI_ABCR_ASIZE_8BIT), |
| 116 | &davinci_emif_regs->ab2cr); /* CS3 */ |
| 117 | #endif |
| 118 | |
Sudhakar Rajashekhara | 6892181 | 2010-06-10 15:18:15 +0530 | [diff] [blame] | 119 | /* arch number of the board */ |
| 120 | gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA850_EVM; |
| 121 | |
| 122 | /* address of boot parameters */ |
| 123 | gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; |
| 124 | |
| 125 | /* |
| 126 | * Power on required peripherals |
| 127 | * ARM does not have access by default to PSC0 and PSC1 |
| 128 | * assuming here that the DSP bootloader has set the IOPU |
| 129 | * such that PSC access is available to ARM |
| 130 | */ |
| 131 | if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc))) |
| 132 | return 1; |
| 133 | |
| 134 | /* setup the SUSPSRC for ARM to control emulation suspend */ |
| 135 | writel(readl(&davinci_syscfg_regs->suspsrc) & |
| 136 | ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C | |
| 137 | DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 | |
| 138 | DAVINCI_SYSCFG_SUSPSRC_UART2), |
| 139 | &davinci_syscfg_regs->suspsrc); |
| 140 | |
| 141 | /* configure pinmux settings */ |
| 142 | if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes))) |
| 143 | return 1; |
| 144 | |
| 145 | /* enable the console UART */ |
| 146 | writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | |
| 147 | DAVINCI_UART_PWREMU_MGMT_UTRST), |
| 148 | &davinci_uart2_ctrl_regs->pwremu_mgmt); |
| 149 | |
| 150 | return 0; |
| 151 | } |