blob: be3daa9bc02dfe715d72bc12897be10b66774d7f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Heiko Schocher565a09c2011-11-01 20:00:29 +00002/*
3 * Copyright (C) 2011
4 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
Heiko Schocher565a09c2011-11-01 20:00:29 +00005 */
6#include <common.h>
Tom Rini12938582012-08-14 12:27:13 -07007#include <config.h>
8#include <spl.h>
Heiko Schocher565a09c2011-11-01 20:00:29 +00009#include <asm/u-boot.h>
10#include <asm/utils.h>
11#include <nand.h>
12#include <asm/arch/dm365_lowlevel.h>
13#include <ns16550.h>
Christian Riesch17a6a2f2011-12-09 09:47:36 +000014#include <malloc.h>
15#include <spi_flash.h>
Lad, Prabhakar8dc6df82012-06-24 21:35:20 +000016#include <mmc.h>
Christian Riesch17a6a2f2011-12-09 09:47:36 +000017
Tom Rini12938582012-08-14 12:27:13 -070018#ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
Heiko Schocher565a09c2011-11-01 20:00:29 +000019void puts(const char *str)
20{
21 while (*str)
22 putc(*str++);
23}
24
25void putc(char c)
26{
27 if (c == '\n')
28 NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
29
30 NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c);
31}
Christian Riesch17a6a2f2011-12-09 09:47:36 +000032#endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
33
Sekhar Nori68e4f8f2019-05-30 19:04:55 +053034void board_init_f(ulong dummy)
Heiko Schocher565a09c2011-11-01 20:00:29 +000035{
Christian Riesch17a6a2f2011-12-09 09:47:36 +000036 arch_cpu_init();
Sekhar Nori68e4f8f2019-05-30 19:04:55 +053037
38 spl_early_init();
39
Tom Rini12938582012-08-14 12:27:13 -070040 preloader_console_init();
41}
Lad, Prabhakar5dad9212012-06-24 21:35:18 +000042
Tom Rini12938582012-08-14 12:27:13 -070043u32 spl_boot_device(void)
44{
Fabien Parent9efa10f2017-01-09 11:06:36 +010045 switch (davinci_syscfg_regs->bootcfg) {
46#ifdef CONFIG_SPL_NAND_SUPPORT
47 case DAVINCI_NAND8_BOOT:
48 case DAVINCI_NAND16_BOOT:
49 return BOOT_DEVICE_NAND;
50#endif
51
52#ifdef CONFIG_SPL_MMC_SUPPORT
53 case DAVINCI_SD_OR_MMC_BOOT:
54 case DAVINCI_MMC_ONLY_BOOT:
55 return BOOT_DEVICE_MMC1;
56#endif
57
58#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT
59 case DAVINCI_SPI0_FLASH_BOOT:
60 case DAVINCI_SPI1_FLASH_BOOT:
61 return BOOT_DEVICE_SPI;
Lad, Prabhakar8dc6df82012-06-24 21:35:20 +000062#endif
Fabien Parent9efa10f2017-01-09 11:06:36 +010063
64 default:
65 puts("Unknown boot device\n");
66 hang();
67 }
Heiko Schocher565a09c2011-11-01 20:00:29 +000068}