Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 |
| 3 | * Heiko Schocher, DENX Software Engineering, hs@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | #include <common.h> |
Tom Rini | 1293858 | 2012-08-14 12:27:13 -0700 | [diff] [blame] | 24 | #include <config.h> |
| 25 | #include <spl.h> |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 26 | #include <asm/u-boot.h> |
| 27 | #include <asm/utils.h> |
| 28 | #include <nand.h> |
| 29 | #include <asm/arch/dm365_lowlevel.h> |
| 30 | #include <ns16550.h> |
Christian Riesch | 17a6a2f | 2011-12-09 09:47:36 +0000 | [diff] [blame] | 31 | #include <malloc.h> |
| 32 | #include <spi_flash.h> |
Lad, Prabhakar | 8dc6df8 | 2012-06-24 21:35:20 +0000 | [diff] [blame] | 33 | #include <mmc.h> |
Christian Riesch | 17a6a2f | 2011-12-09 09:47:36 +0000 | [diff] [blame] | 34 | |
Christian Riesch | 2513db4 | 2011-12-14 09:54:36 +0100 | [diff] [blame] | 35 | DECLARE_GLOBAL_DATA_PTR; |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 36 | |
Tom Rini | 1293858 | 2012-08-14 12:27:13 -0700 | [diff] [blame] | 37 | #ifndef CONFIG_SPL_LIBCOMMON_SUPPORT |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 38 | void puts(const char *str) |
| 39 | { |
| 40 | while (*str) |
| 41 | putc(*str++); |
| 42 | } |
| 43 | |
| 44 | void putc(char c) |
| 45 | { |
| 46 | if (c == '\n') |
| 47 | NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r'); |
| 48 | |
| 49 | NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c); |
| 50 | } |
Christian Riesch | 17a6a2f | 2011-12-09 09:47:36 +0000 | [diff] [blame] | 51 | #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */ |
| 52 | |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 53 | void board_init_f(ulong dummy) |
| 54 | { |
Tom Rini | 1293858 | 2012-08-14 12:27:13 -0700 | [diff] [blame] | 55 | /* First, setup our stack pointer. */ |
| 56 | asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK)); |
| 57 | |
| 58 | /* Second, perform our low-level init. */ |
Christian Riesch | 17a6a2f | 2011-12-09 09:47:36 +0000 | [diff] [blame] | 59 | #ifdef CONFIG_SOC_DM365 |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 60 | dm36x_lowlevel_init(0); |
Christian Riesch | 17a6a2f | 2011-12-09 09:47:36 +0000 | [diff] [blame] | 61 | #endif |
| 62 | #ifdef CONFIG_SOC_DA8XX |
| 63 | arch_cpu_init(); |
| 64 | #endif |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 65 | |
Tom Rini | 1293858 | 2012-08-14 12:27:13 -0700 | [diff] [blame] | 66 | /* Third, we clear the BSS. */ |
Simon Glass | ed70c8f | 2013-03-14 06:54:53 +0000 | [diff] [blame^] | 67 | memset(__bss_start, 0, __bss_end - __bss_start); |
Christian Riesch | 17a6a2f | 2011-12-09 09:47:36 +0000 | [diff] [blame] | 68 | |
Tom Rini | 1293858 | 2012-08-14 12:27:13 -0700 | [diff] [blame] | 69 | /* Finally, setup gd and move to the next step. */ |
Christian Riesch | 17a6a2f | 2011-12-09 09:47:36 +0000 | [diff] [blame] | 70 | gd = &gdata; |
Tom Rini | 1293858 | 2012-08-14 12:27:13 -0700 | [diff] [blame] | 71 | board_init_r(NULL, 0); |
| 72 | } |
Christian Riesch | 17a6a2f | 2011-12-09 09:47:36 +0000 | [diff] [blame] | 73 | |
Tom Rini | 1293858 | 2012-08-14 12:27:13 -0700 | [diff] [blame] | 74 | void spl_board_init(void) |
| 75 | { |
| 76 | preloader_console_init(); |
| 77 | } |
Lad, Prabhakar | 5dad921 | 2012-06-24 21:35:18 +0000 | [diff] [blame] | 78 | |
Tom Rini | 1293858 | 2012-08-14 12:27:13 -0700 | [diff] [blame] | 79 | u32 spl_boot_mode(void) |
| 80 | { |
| 81 | return MMCSD_MODE_RAW; |
| 82 | } |
| 83 | |
| 84 | u32 spl_boot_device(void) |
| 85 | { |
| 86 | #ifdef CONFIG_SPL_NAND_SIMPLE |
| 87 | return BOOT_DEVICE_NAND; |
| 88 | #elif defined(CONFIG_SPL_SPI_LOAD) |
| 89 | return BOOT_DEVICE_SPI; |
| 90 | #elif defined(CONFIG_SPL_MMC_LOAD) |
| 91 | return BOOT_DEVICE_MMC1; |
| 92 | #else |
| 93 | puts("Unknown boot device\n"); |
| 94 | hang(); |
Lad, Prabhakar | 8dc6df8 | 2012-06-24 21:35:20 +0000 | [diff] [blame] | 95 | #endif |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 96 | } |