blob: f4553160027e1b57143eab78ae30418b6999da71 [file] [log] [blame]
Heiko Schocher435199f2011-11-01 20:00:29 +00001/*
2 * Copyright (C) 2011
3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Heiko Schocher435199f2011-11-01 20:00:29 +00006 */
7#include <common.h>
Tom Rini3f7f2412012-08-14 12:27:13 -07008#include <config.h>
9#include <spl.h>
Heiko Schocher435199f2011-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 Riesch620fd272011-12-09 09:47:36 +000015#include <malloc.h>
16#include <spi_flash.h>
Lad, Prabhakar0d986e62012-06-24 21:35:20 +000017#include <mmc.h>
Christian Riesch620fd272011-12-09 09:47:36 +000018
Tom Rini3f7f2412012-08-14 12:27:13 -070019#ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
Heiko Schocher435199f2011-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')
29 NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
30
31 NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c);
32}
Christian Riesch620fd272011-12-09 09:47:36 +000033#endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
34
Tom Rini212324a2015-01-22 09:38:10 -050035void spl_board_init(void)
Heiko Schocher435199f2011-11-01 20:00:29 +000036{
Christian Riesch620fd272011-12-09 09:47:36 +000037#ifdef CONFIG_SOC_DM365
Heiko Schocher435199f2011-11-01 20:00:29 +000038 dm36x_lowlevel_init(0);
Christian Riesch620fd272011-12-09 09:47:36 +000039#endif
40#ifdef CONFIG_SOC_DA8XX
41 arch_cpu_init();
42#endif
Tom Rini3f7f2412012-08-14 12:27:13 -070043 preloader_console_init();
44}
Christian Riesch620fd272011-12-09 09:47:36 +000045
Tom Rini3f7f2412012-08-14 12:27:13 -070046u32 spl_boot_device(void)
47{
Fabien Parentc0fa3852017-01-09 11:06:36 +010048 switch (davinci_syscfg_regs->bootcfg) {
49#ifdef CONFIG_SPL_NAND_SUPPORT
50 case DAVINCI_NAND8_BOOT:
51 case DAVINCI_NAND16_BOOT:
52 return BOOT_DEVICE_NAND;
Lad, Prabhakar0d986e62012-06-24 21:35:20 +000053#endif
Fabien Parentc0fa3852017-01-09 11:06:36 +010054
55#ifdef CONFIG_SPL_MMC_SUPPORT
56 case DAVINCI_SD_OR_MMC_BOOT:
57 case DAVINCI_MMC_ONLY_BOOT:
58 return BOOT_DEVICE_MMC1;
59#endif
60
61#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT
62 case DAVINCI_SPI0_FLASH_BOOT:
63 case DAVINCI_SPI1_FLASH_BOOT:
64 return BOOT_DEVICE_SPI;
65#endif
66
67 default:
68 puts("Unknown boot device\n");
69 hang();
70 }
Heiko Schocher435199f2011-11-01 20:00:29 +000071}