]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/davinci/da8xxevm/hawkboard_nand_spl.c
0fdccac435fb0b3615a816c5218e723075e11e40
[karo-tx-uboot.git] / board / davinci / da8xxevm / hawkboard_nand_spl.c
1 /*
2  * Modified for Hawkboard - Syed Mohammed Khasim <khasim@beagleboard.org>
3  *
4  * Copyright (C) 2008 Sekhar Nori, Texas Instruments, Inc.  <nsekhar@ti.com>
5  * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
6  * Copyright (C) 2004 Texas Instruments.
7  *
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
25 #include <common.h>
26 #include <asm/errno.h>
27 #include <asm/arch/hardware.h>
28 #include <asm/io.h>
29 #include <asm/arch/davinci_misc.h>
30 #include <ns16550.h>
31 #include <nand.h>
32
33 DECLARE_GLOBAL_DATA_PTR;
34
35 static const struct pinmux_config mii_pins[] = {
36         { pinmux(2), 8, 1 },
37         { pinmux(2), 8, 2 },
38         { pinmux(2), 8, 3 },
39         { pinmux(2), 8, 4 },
40         { pinmux(2), 8, 5 },
41         { pinmux(2), 8, 6 },
42         { pinmux(2), 8, 7 }
43 };
44
45 static const struct pinmux_config mdio_pins[] = {
46         { pinmux(4), 8, 0 },
47         { pinmux(4), 8, 1 }
48 };
49
50 static const struct pinmux_config nand_pins[] = {
51         { pinmux(7), 1, 1 },
52         { pinmux(7), 1, 2 },
53         { pinmux(7), 1, 4 },
54         { pinmux(7), 1, 5 },
55         { pinmux(9), 1, 0 },
56         { pinmux(9), 1, 1 },
57         { pinmux(9), 1, 2 },
58         { pinmux(9), 1, 3 },
59         { pinmux(9), 1, 4 },
60         { pinmux(9), 1, 5 },
61         { pinmux(9), 1, 6 },
62         { pinmux(9), 1, 7 },
63         { pinmux(12), 1, 5 },
64         { pinmux(12), 1, 6 }
65 };
66
67 static const struct pinmux_config uart2_pins[] = {
68         { pinmux(0), 4, 6 },
69         { pinmux(0), 4, 7 },
70         { pinmux(4), 2, 4 },
71         { pinmux(4), 2, 5 }
72 };
73
74 static const struct pinmux_config i2c_pins[] = {
75         { pinmux(4), 2, 4 },
76         { pinmux(4), 2, 5 }
77 };
78
79 static const struct pinmux_resource pinmuxes[] = {
80         PINMUX_ITEM(mii_pins),
81         PINMUX_ITEM(mdio_pins),
82         PINMUX_ITEM(i2c_pins),
83         PINMUX_ITEM(nand_pins),
84         PINMUX_ITEM(uart2_pins),
85 };
86
87 static const struct lpsc_resource lpsc[] = {
88         { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
89         { DAVINCI_LPSC_SPI1 },  /* Serial Flash */
90         { DAVINCI_LPSC_EMAC },  /* image download */
91         { DAVINCI_LPSC_UART2 }, /* console */
92         { DAVINCI_LPSC_GPIO },
93 };
94
95 void board_init_f(ulong bootflag)
96 {
97         /*
98          * Kick Registers need to be set to allow access to Pin Mux registers
99          */
100         writel(DV_SYSCFG_KICK0_UNLOCK, &davinci_syscfg_regs->kick0);
101         writel(DV_SYSCFG_KICK1_UNLOCK, &davinci_syscfg_regs->kick1);
102
103         /* setup the SUSPSRC for ARM to control emulation suspend */
104         writel(readl(&davinci_syscfg_regs->suspsrc) &
105                ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
106                  DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
107                  DAVINCI_SYSCFG_SUSPSRC_UART2), &davinci_syscfg_regs->suspsrc);
108
109         /* Power on required peripherals
110          * ARM does not have acess by default to PSC0 and PSC1
111          * assuming here that the DSP bootloader has set the IOPU
112          * such that PSC access is available to ARM
113          */
114         da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc));
115
116         /* configure pinmux settings */
117         davinci_configure_pin_mux_items(pinmuxes,
118                                         ARRAY_SIZE(pinmuxes));
119
120         writel(readl(&davinci_uart2_ctrl_regs->pwremu_mgmt) |
121                (DAVINCI_UART_PWREMU_MGMT_FREE) |
122                (DAVINCI_UART_PWREMU_MGMT_URRST) |
123                (DAVINCI_UART_PWREMU_MGMT_UTRST),
124                &davinci_uart2_ctrl_regs->pwremu_mgmt);
125
126         NS16550_init((NS16550_t)(DAVINCI_UART2_BASE),
127                         CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
128
129         puts("Nand boot...\n");
130
131         nand_boot();
132 }
133
134 void puts(const char *str)
135 {
136         while (*str)
137                 putc(*str++);
138 }
139
140 void putc(char c)
141 {
142         if (gd->flags & GD_FLG_SILENT)
143                 return;
144
145         if (c == '\n')
146                 NS16550_putc((NS16550_t)(DAVINCI_UART2_BASE), '\r');
147
148         NS16550_putc((NS16550_t)(DAVINCI_UART2_BASE), c);
149 }
150
151 void hang(void)
152 {
153         puts("### ERROR ### Please RESET the board ###\n");
154         for (;;)
155                 ;
156 }