blob: c8c5e1b30edb5f08fdbb0b5f2c8b3b82ad1e6c04 [file] [log] [blame]
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +05301/*
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>
Ben Gardiner3d248d32010-10-14 17:26:29 -040026#include <net.h>
27#include <netdev.h>
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +053028#include <asm/arch/hardware.h>
Ben Gardinera3f88292010-10-14 17:26:22 -040029#include <asm/arch/emif_defs.h>
Ben Gardiner3d248d32010-10-14 17:26:29 -040030#include <asm/arch/emac_defs.h>
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +053031#include <asm/io.h>
32#include "../common/misc.h"
33#include "common.h"
34
35DECLARE_GLOBAL_DATA_PTR;
36
Prakash PM37adbf92010-07-15 16:08:38 -040037#define pinmux(x) (&davinci_syscfg_regs->pinmux[x])
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +053038
39/* SPI0 pin muxer settings */
40static const struct pinmux_config spi1_pins[] = {
Prakash PM37adbf92010-07-15 16:08:38 -040041 { pinmux(5), 1, 1 },
42 { pinmux(5), 1, 2 },
43 { pinmux(5), 1, 4 },
44 { pinmux(5), 1, 5 }
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +053045};
46
47/* UART pin muxer settings */
48static const struct pinmux_config uart_pins[] = {
Prakash PM37adbf92010-07-15 16:08:38 -040049 { pinmux(0), 4, 6 },
50 { pinmux(0), 4, 7 },
51 { pinmux(4), 2, 4 },
52 { pinmux(4), 2, 5 }
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +053053};
54
Ben Gardiner3d248d32010-10-14 17:26:29 -040055#ifdef CONFIG_DRIVER_TI_EMAC
56static const struct pinmux_config emac_pins[] = {
57 { pinmux(2), 8, 1 },
58 { pinmux(2), 8, 2 },
59 { pinmux(2), 8, 3 },
60 { pinmux(2), 8, 4 },
61 { pinmux(2), 8, 5 },
62 { pinmux(2), 8, 6 },
63 { pinmux(2), 8, 7 },
64 { pinmux(3), 8, 0 },
65 { pinmux(3), 8, 1 },
66 { pinmux(3), 8, 2 },
67 { pinmux(3), 8, 3 },
68 { pinmux(3), 8, 4 },
69 { pinmux(3), 8, 5 },
70 { pinmux(3), 8, 6 },
71 { pinmux(3), 8, 7 },
72 { pinmux(4), 8, 0 },
73 { pinmux(4), 8, 1 }
74};
75#endif /* CONFIG_DRIVER_TI_EMAC */
76
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +053077/* I2C pin muxer settings */
78static const struct pinmux_config i2c_pins[] = {
Prakash PM37adbf92010-07-15 16:08:38 -040079 { pinmux(4), 2, 2 },
80 { pinmux(4), 2, 3 }
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +053081};
82
Ben Gardiner756d1fe2010-10-14 17:26:19 -040083#ifdef CONFIG_NAND_DAVINCI
84const struct pinmux_config nand_pins[] = {
85 { pinmux(7), 1, 1 },
86 { pinmux(7), 1, 2 },
87 { pinmux(7), 1, 4 },
88 { pinmux(7), 1, 5 },
89 { pinmux(9), 1, 0 },
90 { pinmux(9), 1, 1 },
91 { pinmux(9), 1, 2 },
92 { pinmux(9), 1, 3 },
93 { pinmux(9), 1, 4 },
94 { pinmux(9), 1, 5 },
95 { pinmux(9), 1, 6 },
96 { pinmux(9), 1, 7 },
97 { pinmux(12), 1, 5 },
98 { pinmux(12), 1, 6 }
99};
100#endif
101
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +0530102static const struct pinmux_resource pinmuxes[] = {
103#ifdef CONFIG_SPI_FLASH
104 PINMUX_ITEM(spi1_pins),
105#endif
106 PINMUX_ITEM(uart_pins),
107 PINMUX_ITEM(i2c_pins),
Ben Gardiner756d1fe2010-10-14 17:26:19 -0400108#ifdef CONFIG_NAND_DAVINCI
109 PINMUX_ITEM(nand_pins),
110#endif
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +0530111};
112
113static const struct lpsc_resource lpsc[] = {
114 { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
115 { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
116 { DAVINCI_LPSC_EMAC }, /* image download */
117 { DAVINCI_LPSC_UART2 }, /* console */
118 { DAVINCI_LPSC_GPIO },
119};
120
121int board_init(void)
122{
123#ifndef CONFIG_USE_IRQ
124 irq_init();
125#endif
126
Ben Gardinera3f88292010-10-14 17:26:22 -0400127
128#ifdef CONFIG_NAND_DAVINCI
129 /*
130 * NAND CS setup - cycle counts based on da850evm NAND timings in the
131 * Linux kernel @ 25MHz EMIFA
132 */
133 writel((DAVINCI_ABCR_WSETUP(0) |
134 DAVINCI_ABCR_WSTROBE(0) |
135 DAVINCI_ABCR_WHOLD(0) |
136 DAVINCI_ABCR_RSETUP(0) |
137 DAVINCI_ABCR_RSTROBE(1) |
138 DAVINCI_ABCR_RHOLD(0) |
139 DAVINCI_ABCR_TA(0) |
140 DAVINCI_ABCR_ASIZE_8BIT),
141 &davinci_emif_regs->ab2cr); /* CS3 */
142#endif
143
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +0530144 /* arch number of the board */
145 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA850_EVM;
146
147 /* address of boot parameters */
148 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
149
150 /*
151 * Power on required peripherals
152 * ARM does not have access by default to PSC0 and PSC1
153 * assuming here that the DSP bootloader has set the IOPU
154 * such that PSC access is available to ARM
155 */
156 if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
157 return 1;
158
159 /* setup the SUSPSRC for ARM to control emulation suspend */
160 writel(readl(&davinci_syscfg_regs->suspsrc) &
161 ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
162 DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
163 DAVINCI_SYSCFG_SUSPSRC_UART2),
164 &davinci_syscfg_regs->suspsrc);
165
166 /* configure pinmux settings */
167 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
168 return 1;
169
Ben Gardiner3d248d32010-10-14 17:26:29 -0400170#ifdef CONFIG_DRIVER_TI_EMAC
171 if (davinci_configure_pin_mux(emac_pins, ARRAY_SIZE(emac_pins)) != 0)
172 return 1;
173 /* set cfgchip3 to select MII */
174 writel(readl(&davinci_syscfg_regs->cfgchip3) & ~(1 << 8),
175 &davinci_syscfg_regs->cfgchip3);
176#endif /* CONFIG_DRIVER_TI_EMAC */
177
Sudhakar Rajashekhara89b765c2010-06-10 15:18:15 +0530178 /* enable the console UART */
179 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
180 DAVINCI_UART_PWREMU_MGMT_UTRST),
181 &davinci_uart2_ctrl_regs->pwremu_mgmt);
182
183 return 0;
184}
Ben Gardiner3d248d32010-10-14 17:26:29 -0400185
186#ifdef CONFIG_DRIVER_TI_EMAC
187
188/*
189 * Initializes on-board ethernet controllers.
190 */
191int board_eth_init(bd_t *bis)
192{
193 if (!davinci_emac_initialize()) {
194 printf("Error: Ethernet init failed!\n");
195 return -1;
196 }
197
198 return 0;
199}
200#endif /* CONFIG_DRIVER_TI_EMAC */