blob: d0d7a814713abc23036b4baaceb52e503ea410af [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Heiko Schocher435199f2011-11-01 20:00:29 +00002/*
3 * Copyright (C) 2011
4 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
Heiko Schocher435199f2011-11-01 20:00:29 +00005 */
6#include <common.h>
Tom Rini3f7f2412012-08-14 12:27:13 -07007#include <config.h>
Simon Glassdb41d652019-12-28 10:45:07 -07008#include <hang.h>
Simon Glass691d7192020-05-10 11:40:02 -06009#include <init.h>
Tom Rini3f7f2412012-08-14 12:27:13 -070010#include <spl.h>
Heiko Schocher435199f2011-11-01 20:00:29 +000011#include <asm/u-boot.h>
12#include <asm/utils.h>
13#include <nand.h>
14#include <asm/arch/dm365_lowlevel.h>
15#include <ns16550.h>
Christian Riesch620fd272011-12-09 09:47:36 +000016#include <malloc.h>
17#include <spi_flash.h>
Lad, Prabhakar0d986e62012-06-24 21:35:20 +000018#include <mmc.h>
Christian Riesch620fd272011-12-09 09:47:36 +000019
Tom Rini3f7f2412012-08-14 12:27:13 -070020#ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
Heiko Schocher435199f2011-11-01 20:00:29 +000021void puts(const char *str)
22{
23 while (*str)
24 putc(*str++);
25}
26
27void putc(char c)
28{
29 if (c == '\n')
Simon Glass2d6bf752020-12-22 19:30:19 -070030 ns16550_putc((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), '\r');
Heiko Schocher435199f2011-11-01 20:00:29 +000031
Simon Glass2d6bf752020-12-22 19:30:19 -070032 ns16550_putc((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), c);
Heiko Schocher435199f2011-11-01 20:00:29 +000033}
Christian Riesch620fd272011-12-09 09:47:36 +000034#endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
35
Sekhar Nori2a766db92019-05-30 19:04:55 +053036void board_init_f(ulong dummy)
Heiko Schocher435199f2011-11-01 20:00:29 +000037{
Christian Riesch620fd272011-12-09 09:47:36 +000038 arch_cpu_init();
Sekhar Nori2a766db92019-05-30 19:04:55 +053039
40 spl_early_init();
41
Tom Rini3f7f2412012-08-14 12:27:13 -070042 preloader_console_init();
43}
Christian Riesch620fd272011-12-09 09:47:36 +000044
Tom Rini3f7f2412012-08-14 12:27:13 -070045u32 spl_boot_device(void)
46{
Fabien Parentc0fa3852017-01-09 11:06:36 +010047 switch (davinci_syscfg_regs->bootcfg) {
48#ifdef CONFIG_SPL_NAND_SUPPORT
49 case DAVINCI_NAND8_BOOT:
50 case DAVINCI_NAND16_BOOT:
51 return BOOT_DEVICE_NAND;
Lad, Prabhakar0d986e62012-06-24 21:35:20 +000052#endif
Fabien Parentc0fa3852017-01-09 11:06:36 +010053
54#ifdef CONFIG_SPL_MMC_SUPPORT
55 case DAVINCI_SD_OR_MMC_BOOT:
56 case DAVINCI_MMC_ONLY_BOOT:
57 return BOOT_DEVICE_MMC1;
58#endif
59
60#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT
61 case DAVINCI_SPI0_FLASH_BOOT:
62 case DAVINCI_SPI1_FLASH_BOOT:
63 return BOOT_DEVICE_SPI;
64#endif
65
66 default:
67 puts("Unknown boot device\n");
68 hang();
69 }
Heiko Schocher435199f2011-11-01 20:00:29 +000070}