]>
Commit | Line | Data |
---|---|---|
b0f80b91 | 1 | /* |
a5f88877 | 2 | * Copyright (C) 2014-2016 Stefan Roese <sr@denx.de> |
b0f80b91 SR |
3 | * |
4 | * SPDX-License-Identifier: GPL-2.0+ | |
5 | */ | |
6 | ||
7 | #include <common.h> | |
6451223a SR |
8 | #include <dm.h> |
9 | #include <debug_uart.h> | |
10 | #include <fdtdec.h> | |
b0f80b91 SR |
11 | #include <spl.h> |
12 | #include <asm/io.h> | |
13 | #include <asm/arch/cpu.h> | |
14 | #include <asm/arch/soc.h> | |
15 | ||
a5f88877 | 16 | static u32 get_boot_device(void) |
b0f80b91 | 17 | { |
a5f88877 SR |
18 | u32 val; |
19 | u32 boot_device; | |
20 | ||
f4db6c97 SR |
21 | /* |
22 | * First check, if UART boot-mode is active. This can only | |
23 | * be done, via the bootrom error register. Here the | |
24 | * MSB marks if the UART mode is active. | |
25 | */ | |
26 | val = readl(CONFIG_BOOTROM_ERR_REG); | |
27 | boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS; | |
28 | debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device); | |
e83e2b39 SN |
29 | #if defined(CONFIG_ARMADA_38X) |
30 | /* | |
31 | * If the bootrom error register contains any else than zeros | |
32 | * in the first 8 bits it's an error condition. And in that case | |
33 | * try to boot from UART. | |
34 | */ | |
35 | if (boot_device) | |
36 | #else | |
f4db6c97 | 37 | if (boot_device == BOOTROM_ERR_MODE_UART) |
e83e2b39 | 38 | #endif |
f4db6c97 SR |
39 | return BOOT_DEVICE_UART; |
40 | ||
41 | /* | |
42 | * Now check the SAR register for the strapped boot-device | |
43 | */ | |
a5f88877 SR |
44 | val = readl(CONFIG_SAR_REG); /* SAR - Sample At Reset */ |
45 | boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS; | |
f4db6c97 | 46 | debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device); |
a5f88877 SR |
47 | switch (boot_device) { |
48 | #ifdef CONFIG_SPL_MMC_SUPPORT | |
49 | case BOOT_FROM_MMC: | |
50 | case BOOT_FROM_MMC_ALT: | |
51 | return BOOT_DEVICE_MMC1; | |
8ed43b96 | 52 | #endif |
a5f88877 | 53 | case BOOT_FROM_UART: |
f3a88e2c BS |
54 | #ifdef BOOT_FROM_UART_ALT |
55 | case BOOT_FROM_UART_ALT: | |
56 | #endif | |
a5f88877 SR |
57 | return BOOT_DEVICE_UART; |
58 | case BOOT_FROM_SPI: | |
59 | default: | |
60 | return BOOT_DEVICE_SPI; | |
61 | }; | |
62 | } | |
63 | ||
64 | u32 spl_boot_device(void) | |
65 | { | |
66 | return get_boot_device(); | |
b0f80b91 SR |
67 | } |
68 | ||
8ed43b96 | 69 | #ifdef CONFIG_SPL_MMC_SUPPORT |
2b1cdafa | 70 | u32 spl_boot_mode(const u32 boot_device) |
8ed43b96 SR |
71 | { |
72 | return MMCSD_MODE_RAW; | |
73 | } | |
74 | #endif | |
75 | ||
b0f80b91 SR |
76 | void board_init_f(ulong dummy) |
77 | { | |
6451223a SR |
78 | int ret; |
79 | ||
e3cccf9e SR |
80 | /* |
81 | * Pin muxing needs to be done before UART output, since | |
82 | * on A38x the UART pins need some re-muxing for output | |
83 | * to work. | |
84 | */ | |
85 | board_early_init_f(); | |
86 | ||
6451223a SR |
87 | /* Example code showing how to enable the debug UART on MVEBU */ |
88 | #ifdef EARLY_UART | |
89 | /* | |
90 | * Debug UART can be used from here if required: | |
91 | * | |
92 | * debug_uart_init(); | |
93 | * printch('a'); | |
94 | * printhex8(0x1234); | |
95 | * printascii("string"); | |
96 | */ | |
97 | #endif | |
98 | ||
99 | ret = spl_init(); | |
100 | if (ret) { | |
101 | debug("spl_init() failed: %d\n", ret); | |
102 | hang(); | |
103 | } | |
104 | ||
105 | /* Use special translation offset for SPL */ | |
106 | dm_set_translation_offset(0xd0000000 - 0xf1000000); | |
107 | ||
b0f80b91 SR |
108 | preloader_console_init(); |
109 | ||
ade741b3 SR |
110 | timer_init(); |
111 | ||
09e89ab4 SR |
112 | /* Armada 375 does not support SerDes and DDR3 init yet */ |
113 | #if !defined(CONFIG_ARMADA_375) | |
b0f80b91 SR |
114 | /* First init the serdes PHY's */ |
115 | serdes_phy_config(); | |
116 | ||
117 | /* Setup DDR */ | |
118 | ddr3_init(); | |
09e89ab4 | 119 | #endif |
b0f80b91 | 120 | |
944c7a31 SR |
121 | /* |
122 | * Return to the BootROM to continue the Marvell xmodem | |
123 | * UART boot protocol. As initiated by the kwboot tool. | |
124 | * | |
125 | * This can only be done by the BootROM and not by the | |
126 | * U-Boot SPL infrastructure, since the beginning of the | |
127 | * image is already read and interpreted by the BootROM. | |
128 | * SPL has no chance to receive this information. So we | |
129 | * need to return to the BootROM to enable this xmodem | |
130 | * UART download. | |
131 | */ | |
f4db6c97 SR |
132 | if (get_boot_device() == BOOT_DEVICE_UART) |
133 | return_to_bootrom(); | |
b0f80b91 | 134 | } |