blob: 59b304efcb7cc0d0059d8b15dea52fbfa4d29738 [file] [log] [blame]
Heiko Schocher565a09c2011-11-01 20:00:29 +00001/*
2 * Copyright (C) 2011
3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Heiko Schocher565a09c2011-11-01 20:00:29 +00006 */
7#include <common.h>
Tom Rini12938582012-08-14 12:27:13 -07008#include <config.h>
9#include <spl.h>
Heiko Schocher565a09c2011-11-01 20:00:29 +000010#include <asm/u-boot.h>
11#include <asm/utils.h>
12#include <nand.h>
13#include <asm/arch/dm365_lowlevel.h>
14#include <ns16550.h>
Christian Riesch17a6a2f2011-12-09 09:47:36 +000015#include <malloc.h>
16#include <spi_flash.h>
Lad, Prabhakar8dc6df82012-06-24 21:35:20 +000017#include <mmc.h>
Christian Riesch17a6a2f2011-12-09 09:47:36 +000018
Christian Riesch2513db42011-12-14 09:54:36 +010019DECLARE_GLOBAL_DATA_PTR;
Heiko Schocher565a09c2011-11-01 20:00:29 +000020
Tom Rini12938582012-08-14 12:27:13 -070021#ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
Heiko Schocher565a09c2011-11-01 20:00:29 +000022void puts(const char *str)
23{
24 while (*str)
25 putc(*str++);
26}
27
28void putc(char c)
29{
30 if (c == '\n')
31 NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
32
33 NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c);
34}
Christian Riesch17a6a2f2011-12-09 09:47:36 +000035#endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
36
Heiko Schocher565a09c2011-11-01 20:00:29 +000037void board_init_f(ulong dummy)
38{
Tom Rini12938582012-08-14 12:27:13 -070039 /* First, setup our stack pointer. */
40 asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
41
42 /* Second, perform our low-level init. */
Christian Riesch17a6a2f2011-12-09 09:47:36 +000043#ifdef CONFIG_SOC_DM365
Heiko Schocher565a09c2011-11-01 20:00:29 +000044 dm36x_lowlevel_init(0);
Christian Riesch17a6a2f2011-12-09 09:47:36 +000045#endif
46#ifdef CONFIG_SOC_DA8XX
47 arch_cpu_init();
48#endif
Heiko Schocher565a09c2011-11-01 20:00:29 +000049
Tom Rini12938582012-08-14 12:27:13 -070050 /* Third, we clear the BSS. */
Simon Glassed70c8f2013-03-14 06:54:53 +000051 memset(__bss_start, 0, __bss_end - __bss_start);
Christian Riesch17a6a2f2011-12-09 09:47:36 +000052
Tom Rini12938582012-08-14 12:27:13 -070053 /* Finally, setup gd and move to the next step. */
Christian Riesch17a6a2f2011-12-09 09:47:36 +000054 gd = &gdata;
Tom Rini12938582012-08-14 12:27:13 -070055 board_init_r(NULL, 0);
56}
Christian Riesch17a6a2f2011-12-09 09:47:36 +000057
Tom Rini12938582012-08-14 12:27:13 -070058void spl_board_init(void)
59{
60 preloader_console_init();
61}
Lad, Prabhakar5dad9212012-06-24 21:35:18 +000062
Tom Rini12938582012-08-14 12:27:13 -070063u32 spl_boot_mode(void)
64{
65 return MMCSD_MODE_RAW;
66}
67
68u32 spl_boot_device(void)
69{
70#ifdef CONFIG_SPL_NAND_SIMPLE
71 return BOOT_DEVICE_NAND;
72#elif defined(CONFIG_SPL_SPI_LOAD)
73 return BOOT_DEVICE_SPI;
74#elif defined(CONFIG_SPL_MMC_LOAD)
75 return BOOT_DEVICE_MMC1;
76#else
77 puts("Unknown boot device\n");
78 hang();
Lad, Prabhakar8dc6df82012-06-24 21:35:20 +000079#endif
Heiko Schocher565a09c2011-11-01 20:00:29 +000080}