blob: 4603c8fbc5759e0105b5c3e932fa0bd1cb4dd8a9 [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 */
Tom Rini12938582012-08-14 12:27:13 -07006#include <config.h>
Simon Glassf11478f2019-12-28 10:45:07 -07007#include <hang.h>
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
Tom Rini12938582012-08-14 12:27:13 -07009#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
Tom Rini12938582012-08-14 12:27:13 -070019#ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
Heiko Schocher565a09c2011-11-01 20:00:29 +000020void puts(const char *str)
21{
22 while (*str)
23 putc(*str++);
24}
25
26void putc(char c)
27{
28 if (c == '\n')
Tom Rinidf6a2152022-11-16 13:10:28 -050029 ns16550_putc((struct ns16550 *)(CFG_SYS_NS16550_COM1), '\r');
Heiko Schocher565a09c2011-11-01 20:00:29 +000030
Tom Rinidf6a2152022-11-16 13:10:28 -050031 ns16550_putc((struct ns16550 *)(CFG_SYS_NS16550_COM1), c);
Heiko Schocher565a09c2011-11-01 20:00:29 +000032}
Christian Riesch17a6a2f2011-12-09 09:47:36 +000033#endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
34
Sekhar Nori68e4f8f2019-05-30 19:04:55 +053035void board_init_f(ulong dummy)
Heiko Schocher565a09c2011-11-01 20:00:29 +000036{
Christian Riesch17a6a2f2011-12-09 09:47:36 +000037 arch_cpu_init();
Sekhar Nori68e4f8f2019-05-30 19:04:55 +053038
39 spl_early_init();
40
Tom Rini12938582012-08-14 12:27:13 -070041 preloader_console_init();
42}
Lad, Prabhakar5dad9212012-06-24 21:35:18 +000043
Tom Rini12938582012-08-14 12:27:13 -070044u32 spl_boot_device(void)
45{
Fabien Parent9efa10f2017-01-09 11:06:36 +010046 switch (davinci_syscfg_regs->bootcfg) {
47#ifdef CONFIG_SPL_NAND_SUPPORT
48 case DAVINCI_NAND8_BOOT:
49 case DAVINCI_NAND16_BOOT:
50 return BOOT_DEVICE_NAND;
51#endif
52
Simon Glassb58bfe02021-08-08 12:20:09 -060053#ifdef CONFIG_SPL_MMC
Fabien Parent9efa10f2017-01-09 11:06:36 +010054 case DAVINCI_SD_OR_MMC_BOOT:
55 case DAVINCI_MMC_ONLY_BOOT:
56 return BOOT_DEVICE_MMC1;
57#endif
58
59#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT
60 case DAVINCI_SPI0_FLASH_BOOT:
61 case DAVINCI_SPI1_FLASH_BOOT:
62 return BOOT_DEVICE_SPI;
Lad, Prabhakar8dc6df82012-06-24 21:35:20 +000063#endif
Fabien Parent9efa10f2017-01-09 11:06:36 +010064
65 default:
66 puts("Unknown boot device\n");
67 hang();
68 }
Heiko Schocher565a09c2011-11-01 20:00:29 +000069}