blob: aac5c5cbe1a51ec0b7495f2604702f3a97cd5597 [file] [log] [blame]
Sekhar Noria9ada862009-11-12 11:08:39 -05001/*
2 * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
3 *
4 * Base on code from TI. Original Notices follow:
5 *
6 * (C) Copyright 2008, Texas Instruments, Inc. http://www.ti.com/
7 *
8 * Modified for DA8xx EVM.
9 *
10 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
11 *
12 * Parts are shamelessly stolen from various TI sources, original copyright
13 * follows:
14 * -----------------------------------------------------------------
15 *
16 * Copyright (C) 2004 Texas Instruments.
17 *
18 * ----------------------------------------------------------------------------
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 * ----------------------------------------------------------------------------
33 */
34
35#include <common.h>
36#include <i2c.h>
37#include <asm/arch/hardware.h>
Nick Thompson60b19942010-02-08 11:36:16 -050038#include <asm/arch/emif_defs.h>
Sekhar Noria9ada862009-11-12 11:08:39 -050039#include <asm/io.h>
40#include "../common/misc.h"
41
42DECLARE_GLOBAL_DATA_PTR;
43
44#define pinmux &davinci_syscfg_regs->pinmux
45
Sekhar Noria9ada862009-11-12 11:08:39 -050046/* SPI0 pin muxer settings */
Nick Thompson1d300d82010-01-27 11:11:28 -050047static const struct pinmux_config spi0_pins[] = {
Sekhar Noria9ada862009-11-12 11:08:39 -050048 { pinmux[7], 1, 3 },
49 { pinmux[7], 1, 4 },
50 { pinmux[7], 1, 5 },
51 { pinmux[7], 1, 6 },
52 { pinmux[7], 1, 7 }
53};
Sekhar Noria9ada862009-11-12 11:08:39 -050054
Nick Thompson60b19942010-02-08 11:36:16 -050055/* EMIF-A bus pins for 8-bit NAND support on CS3 */
56static const struct pinmux_config emifa_nand_pins[] = {
57 { pinmux[13], 1, 6 },
58 { pinmux[13], 1, 7 },
59 { pinmux[14], 1, 0 },
60 { pinmux[14], 1, 1 },
61 { pinmux[14], 1, 2 },
62 { pinmux[14], 1, 3 },
63 { pinmux[14], 1, 4 },
64 { pinmux[14], 1, 5 },
65 { pinmux[15], 1, 7 },
66 { pinmux[16], 1, 0 },
67 { pinmux[18], 1, 1 },
68 { pinmux[18], 1, 4 },
69 { pinmux[18], 1, 5 },
70};
71
Sekhar Noria9ada862009-11-12 11:08:39 -050072/* UART pin muxer settings */
Nick Thompson1d300d82010-01-27 11:11:28 -050073static const struct pinmux_config uart_pins[] = {
Sekhar Noria9ada862009-11-12 11:08:39 -050074 { pinmux[8], 2, 7 },
75 { pinmux[9], 2, 0 }
76};
77
78/* I2C pin muxer settings */
Nick Thompson1d300d82010-01-27 11:11:28 -050079static const struct pinmux_config i2c_pins[] = {
Sekhar Noria9ada862009-11-12 11:08:39 -050080 { pinmux[9], 2, 3 },
81 { pinmux[9], 2, 4 }
82};
83
Ajay Kumar Guptae94491d2009-12-22 10:56:11 +053084/* USB0_DRVVBUS pin muxer settings */
Nick Thompson1d300d82010-01-27 11:11:28 -050085static const struct pinmux_config usb_pins[] = {
Ajay Kumar Guptae94491d2009-12-22 10:56:11 +053086 { pinmux[9], 1, 1 }
87};
88
Nick Thompson1d300d82010-01-27 11:11:28 -050089static const struct pinmux_resource pinmuxes[] = {
90#ifdef CONFIG_SPI_FLASH
91 PINMUX_ITEM(spi0_pins),
92#endif
93 PINMUX_ITEM(uart_pins),
94 PINMUX_ITEM(i2c_pins),
95#ifdef CONFIG_USB_DA8XX
96 PINMUX_ITEM(usb_pins),
97#endif
Nick Thompson60b19942010-02-08 11:36:16 -050098#ifdef CONFIG_USE_NAND
99 PINMUX_ITEM(emifa_nand_pins),
100#endif
Nick Thompson1d300d82010-01-27 11:11:28 -0500101};
102
Sekhar Noria9ada862009-11-12 11:08:39 -0500103int board_init(void)
104{
105#ifndef CONFIG_USE_IRQ
106 /*
107 * Mask all IRQs by clearing the global enable and setting
108 * the enable clear for all the 90 interrupts.
109 */
110
111 writel(0, &davinci_aintc_regs->ger);
112
113 writel(0, &davinci_aintc_regs->hier);
114
115 writel(0xffffffff, &davinci_aintc_regs->ecr1);
116 writel(0xffffffff, &davinci_aintc_regs->ecr2);
117 writel(0xffffffff, &davinci_aintc_regs->ecr3);
118#endif
119
Nick Thompson60b19942010-02-08 11:36:16 -0500120#ifdef CONFIG_NAND_DAVINCI
121 /* EMIFA 100MHz clock select */
122 writel(readl(&davinci_syscfg_regs->cfgchip3) & ~2,
123 &davinci_syscfg_regs->cfgchip3);
124 /* NAND CS setup */
125 writel((DAVINCI_ABCR_WSETUP(0) |
126 DAVINCI_ABCR_WSTROBE(2) |
127 DAVINCI_ABCR_WHOLD(0) |
128 DAVINCI_ABCR_RSETUP(0) |
129 DAVINCI_ABCR_RSTROBE(2) |
130 DAVINCI_ABCR_RHOLD(0) |
131 DAVINCI_ABCR_TA(2) |
132 DAVINCI_ABCR_ASIZE_8BIT),
133 &davinci_emif_regs->AB2CR);
134#endif
135
Sekhar Noria9ada862009-11-12 11:08:39 -0500136 /* arch number of the board */
137 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA830_EVM;
138
139 /* address of boot parameters */
140 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
141
142 /*
143 * Power on required peripherals
144 * ARM does not have access by default to PSC0 and PSC1
145 * assuming here that the DSP bootloader has set the IOPU
146 * such that PSC access is available to ARM
147 */
148 lpsc_on(DAVINCI_LPSC_AEMIF); /* NAND, NOR */
149 lpsc_on(DAVINCI_LPSC_SPI0); /* Serial Flash */
150 lpsc_on(DAVINCI_LPSC_EMAC); /* image download */
151 lpsc_on(DAVINCI_LPSC_UART2); /* console */
152 lpsc_on(DAVINCI_LPSC_GPIO);
153
154 /* setup the SUSPSRC for ARM to control emulation suspend */
155 writel(readl(&davinci_syscfg_regs->suspsrc) &
156 ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
157 DAVINCI_SYSCFG_SUSPSRC_SPI0 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
158 DAVINCI_SYSCFG_SUSPSRC_UART2),
159 &davinci_syscfg_regs->suspsrc);
160
Nick Thompson1d300d82010-01-27 11:11:28 -0500161 /* configure pinmux settings */
162 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
Ajay Kumar Guptae94491d2009-12-22 10:56:11 +0530163 return 1;
164
Sekhar Noria9ada862009-11-12 11:08:39 -0500165 /* enable the console UART */
166 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
167 DAVINCI_UART_PWREMU_MGMT_UTRST),
168 &davinci_uart2_ctrl_regs->pwremu_mgmt);
169
170 return(0);
171}