Sughosh Ganu | 1b9c52b | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 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> |
Christian Riesch | f49896d | 2011-11-28 23:46:19 +0000 | [diff] [blame] | 30 | #include <asm/arch/pinmux_defs.h> |
Sughosh Ganu | 1b9c52b | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 31 | #include <ns16550.h> |
Wolfgang Denk | 0ae439f | 2011-09-10 22:26:28 +0200 | [diff] [blame] | 32 | #include <nand.h> |
Sughosh Ganu | 1b9c52b | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 33 | |
| 34 | DECLARE_GLOBAL_DATA_PTR; |
| 35 | |
Sughosh Ganu | 1b9c52b | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 36 | static const struct pinmux_resource pinmuxes[] = { |
Christian Riesch | f49896d | 2011-11-28 23:46:19 +0000 | [diff] [blame] | 37 | PINMUX_ITEM(emac_pins_mii), |
| 38 | PINMUX_ITEM(emac_pins_mdio), |
| 39 | PINMUX_ITEM(emifa_pins_cs3), |
| 40 | PINMUX_ITEM(emifa_pins_cs4), |
| 41 | PINMUX_ITEM(emifa_pins_nand), |
| 42 | PINMUX_ITEM(uart2_pins_txrx), |
| 43 | PINMUX_ITEM(uart2_pins_rtscts), |
Sughosh Ganu | 1b9c52b | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | static const struct lpsc_resource lpsc[] = { |
| 47 | { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */ |
| 48 | { DAVINCI_LPSC_SPI1 }, /* Serial Flash */ |
| 49 | { DAVINCI_LPSC_EMAC }, /* image download */ |
| 50 | { DAVINCI_LPSC_UART2 }, /* console */ |
| 51 | { DAVINCI_LPSC_GPIO }, |
| 52 | }; |
| 53 | |
| 54 | void board_init_f(ulong bootflag) |
| 55 | { |
| 56 | /* |
| 57 | * Kick Registers need to be set to allow access to Pin Mux registers |
| 58 | */ |
Christian Riesch | af5829ce | 2011-11-19 00:45:44 +0000 | [diff] [blame] | 59 | writel(DV_SYSCFG_KICK0_UNLOCK, &davinci_syscfg_regs->kick0); |
| 60 | writel(DV_SYSCFG_KICK1_UNLOCK, &davinci_syscfg_regs->kick1); |
Sughosh Ganu | 1b9c52b | 2010-11-30 11:25:01 -0500 | [diff] [blame] | 61 | |
| 62 | /* setup the SUSPSRC for ARM to control emulation suspend */ |
| 63 | writel(readl(&davinci_syscfg_regs->suspsrc) & |
| 64 | ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C | |
| 65 | DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 | |
| 66 | DAVINCI_SYSCFG_SUSPSRC_UART2), &davinci_syscfg_regs->suspsrc); |
| 67 | |
| 68 | /* Power on required peripherals |
| 69 | * ARM does not have acess by default to PSC0 and PSC1 |
| 70 | * assuming here that the DSP bootloader has set the IOPU |
| 71 | * such that PSC access is available to ARM |
| 72 | */ |
| 73 | da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)); |
| 74 | |
| 75 | /* configure pinmux settings */ |
| 76 | davinci_configure_pin_mux_items(pinmuxes, |
| 77 | ARRAY_SIZE(pinmuxes)); |
| 78 | |
| 79 | writel(readl(&davinci_uart2_ctrl_regs->pwremu_mgmt) | |
| 80 | (DAVINCI_UART_PWREMU_MGMT_FREE) | |
| 81 | (DAVINCI_UART_PWREMU_MGMT_URRST) | |
| 82 | (DAVINCI_UART_PWREMU_MGMT_UTRST), |
| 83 | &davinci_uart2_ctrl_regs->pwremu_mgmt); |
| 84 | |
| 85 | NS16550_init((NS16550_t)(DAVINCI_UART2_BASE), |
| 86 | CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); |
| 87 | |
| 88 | puts("Nand boot...\n"); |
| 89 | |
| 90 | nand_boot(); |
| 91 | } |
| 92 | |
| 93 | void puts(const char *str) |
| 94 | { |
| 95 | while (*str) |
| 96 | putc(*str++); |
| 97 | } |
| 98 | |
| 99 | void putc(char c) |
| 100 | { |
| 101 | if (gd->flags & GD_FLG_SILENT) |
| 102 | return; |
| 103 | |
| 104 | if (c == '\n') |
| 105 | NS16550_putc((NS16550_t)(DAVINCI_UART2_BASE), '\r'); |
| 106 | |
| 107 | NS16550_putc((NS16550_t)(DAVINCI_UART2_BASE), c); |
| 108 | } |
| 109 | |
| 110 | void hang(void) |
| 111 | { |
| 112 | puts("### ERROR ### Please RESET the board ###\n"); |
| 113 | for (;;) |
| 114 | ; |
| 115 | } |