blob: 778996eff54b78e3f2d85325a7a91246b46e0649 [file] [log] [blame]
Stefan Roesee463bf32015-01-19 11:33:42 +01001/*
Stefan Roese44e7ebd2016-01-07 14:09:09 +01002 * Copyright (C) 2014-2016 Stefan Roese <sr@denx.de>
Stefan Roesee463bf32015-01-19 11:33:42 +01003 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
Stefan Roese83097cf2015-11-25 07:37:00 +01008#include <dm.h>
9#include <debug_uart.h>
10#include <fdtdec.h>
Stefan Roesee463bf32015-01-19 11:33:42 +010011#include <spl.h>
12#include <asm/io.h>
13#include <asm/arch/cpu.h>
14#include <asm/arch/soc.h>
15
16DECLARE_GLOBAL_DATA_PTR;
17
Stefan Roese44e7ebd2016-01-07 14:09:09 +010018static u32 get_boot_device(void)
Stefan Roesee463bf32015-01-19 11:33:42 +010019{
Stefan Roese44e7ebd2016-01-07 14:09:09 +010020 u32 val;
21 u32 boot_device;
22
23 val = readl(CONFIG_SAR_REG); /* SAR - Sample At Reset */
24 boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
25 switch (boot_device) {
26#ifdef CONFIG_SPL_MMC_SUPPORT
27 case BOOT_FROM_MMC:
28 case BOOT_FROM_MMC_ALT:
29 return BOOT_DEVICE_MMC1;
Stefan Roese63962132015-07-20 11:20:36 +020030#endif
Stefan Roese44e7ebd2016-01-07 14:09:09 +010031 case BOOT_FROM_UART:
32 return BOOT_DEVICE_UART;
33 case BOOT_FROM_SPI:
34 default:
35 return BOOT_DEVICE_SPI;
36 };
37}
38
39u32 spl_boot_device(void)
40{
41 return get_boot_device();
Stefan Roese63962132015-07-20 11:20:36 +020042}
43
44#ifdef CONFIG_SPL_MMC_SUPPORT
45u32 spl_boot_mode(void)
46{
47 return MMCSD_MODE_RAW;
Stefan Roesee463bf32015-01-19 11:33:42 +010048}
Stefan Roese63962132015-07-20 11:20:36 +020049#endif
Stefan Roesee463bf32015-01-19 11:33:42 +010050
51void board_init_f(ulong dummy)
52{
Stefan Roese83097cf2015-11-25 07:37:00 +010053 int ret;
54
Stefan Roesed7f2c122015-04-17 18:13:06 +020055 /*
56 * Pin muxing needs to be done before UART output, since
57 * on A38x the UART pins need some re-muxing for output
58 * to work.
59 */
60 board_early_init_f();
61
Stefan Roese83097cf2015-11-25 07:37:00 +010062 /* Example code showing how to enable the debug UART on MVEBU */
63#ifdef EARLY_UART
64 /*
65 * Debug UART can be used from here if required:
66 *
67 * debug_uart_init();
68 * printch('a');
69 * printhex8(0x1234);
70 * printascii("string");
71 */
72#endif
73
74 ret = spl_init();
75 if (ret) {
76 debug("spl_init() failed: %d\n", ret);
77 hang();
78 }
79
80 /* Use special translation offset for SPL */
81 dm_set_translation_offset(0xd0000000 - 0xf1000000);
82
Stefan Roesee463bf32015-01-19 11:33:42 +010083 preloader_console_init();
84
Stefan Roesed04fe8b2015-07-15 15:36:52 +020085 timer_init();
86
Stefan Roesee463bf32015-01-19 11:33:42 +010087 /* First init the serdes PHY's */
88 serdes_phy_config();
89
90 /* Setup DDR */
91 ddr3_init();
92
Stefan Roese99b3ea72015-08-25 13:49:41 +020093#ifdef CONFIG_MVEBU_BOOTROM_UARTBOOT
94 /*
95 * Return to the BootROM to continue the Marvell xmodem
96 * UART boot protocol. As initiated by the kwboot tool.
97 *
98 * This can only be done by the BootROM and not by the
99 * U-Boot SPL infrastructure, since the beginning of the
100 * image is already read and interpreted by the BootROM.
101 * SPL has no chance to receive this information. So we
102 * need to return to the BootROM to enable this xmodem
103 * UART download.
104 */
105 return_to_bootrom();
106#endif
Stefan Roesee463bf32015-01-19 11:33:42 +0100107}