common: Move hang() to the same header as panic()
[oweals/u-boot.git] / arch / arm / mach-davinci / spl.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2011
4  * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5  */
6 #include <common.h>
7 #include <config.h>
8 #include <hang.h>
9 #include <spl.h>
10 #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>
15 #include <malloc.h>
16 #include <spi_flash.h>
17 #include <mmc.h>
18
19 #ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
20 void puts(const char *str)
21 {
22         while (*str)
23                 putc(*str++);
24 }
25
26 void 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 }
33 #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
34
35 void board_init_f(ulong dummy)
36 {
37         arch_cpu_init();
38
39         spl_early_init();
40
41         preloader_console_init();
42 }
43
44 u32 spl_boot_device(void)
45 {
46         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
53 #ifdef CONFIG_SPL_MMC_SUPPORT
54         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;
63 #endif
64
65         default:
66                 puts("Unknown boot device\n");
67                 hang();
68         }
69 }