Tom Rini | 4549e78 | 2018-05-06 18:27:01 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
Patrick Delaunay | 2514c2d | 2018-03-12 10:46:10 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2018, STMicroelectronics - All Rights Reserved |
Patrick Delaunay | 2514c2d | 2018-03-12 10:46:10 +0100 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <spl.h> |
Patrick Delaunay | 11dfd1a | 2018-03-20 10:54:54 +0100 | [diff] [blame] | 9 | #include <asm/io.h> |
Patrick Delaunay | 2514c2d | 2018-03-12 10:46:10 +0100 | [diff] [blame] | 10 | |
| 11 | u32 spl_boot_device(void) |
| 12 | { |
Patrick Delaunay | 11dfd1a | 2018-03-20 10:54:54 +0100 | [diff] [blame] | 13 | u32 boot_mode; |
| 14 | |
Patrick Delaunay | 7f63c1e | 2019-02-27 17:01:12 +0100 | [diff] [blame^] | 15 | boot_mode = get_bootmode(); |
Patrick Delaunay | 11dfd1a | 2018-03-20 10:54:54 +0100 | [diff] [blame] | 16 | |
| 17 | switch (boot_mode) { |
| 18 | case BOOT_FLASH_SD_1: |
| 19 | case BOOT_FLASH_EMMC_1: |
| 20 | return BOOT_DEVICE_MMC1; |
| 21 | case BOOT_FLASH_SD_2: |
| 22 | case BOOT_FLASH_EMMC_2: |
| 23 | return BOOT_DEVICE_MMC2; |
Patrick Delaunay | 7f63c1e | 2019-02-27 17:01:12 +0100 | [diff] [blame^] | 24 | case BOOT_SERIAL_UART_1: |
| 25 | case BOOT_SERIAL_UART_2: |
| 26 | case BOOT_SERIAL_UART_3: |
| 27 | case BOOT_SERIAL_UART_4: |
| 28 | case BOOT_SERIAL_UART_5: |
| 29 | case BOOT_SERIAL_UART_6: |
| 30 | case BOOT_SERIAL_UART_7: |
| 31 | case BOOT_SERIAL_UART_8: |
| 32 | return BOOT_DEVICE_UART; |
| 33 | case BOOT_SERIAL_USB_OTG: |
| 34 | return BOOT_DEVICE_USB; |
| 35 | case BOOT_FLASH_NAND_FMC: |
| 36 | return BOOT_DEVICE_NAND; |
| 37 | case BOOT_FLASH_NOR_QSPI: |
| 38 | return BOOT_DEVICE_SPI; |
Patrick Delaunay | 11dfd1a | 2018-03-20 10:54:54 +0100 | [diff] [blame] | 39 | } |
| 40 | |
Patrick Delaunay | 2514c2d | 2018-03-12 10:46:10 +0100 | [diff] [blame] | 41 | return BOOT_DEVICE_MMC1; |
| 42 | } |
| 43 | |
| 44 | u32 spl_boot_mode(const u32 boot_device) |
| 45 | { |
| 46 | return MMCSD_MODE_RAW; |
| 47 | } |
| 48 | |
Patrick Delaunay | 11dfd1a | 2018-03-20 10:54:54 +0100 | [diff] [blame] | 49 | int spl_boot_partition(const u32 boot_device) |
| 50 | { |
| 51 | switch (boot_device) { |
| 52 | case BOOT_DEVICE_MMC1: |
| 53 | return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION; |
| 54 | case BOOT_DEVICE_MMC2: |
| 55 | return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2; |
| 56 | default: |
| 57 | return -EINVAL; |
| 58 | } |
| 59 | } |
| 60 | |
Patrick Delaunay | 2514c2d | 2018-03-12 10:46:10 +0100 | [diff] [blame] | 61 | void board_init_f(ulong dummy) |
| 62 | { |
| 63 | struct udevice *dev; |
| 64 | int ret; |
| 65 | |
| 66 | arch_cpu_init(); |
| 67 | |
| 68 | ret = spl_early_init(); |
| 69 | if (ret) { |
| 70 | debug("spl_early_init() failed: %d\n", ret); |
| 71 | hang(); |
| 72 | } |
| 73 | |
| 74 | ret = uclass_get_device(UCLASS_CLK, 0, &dev); |
| 75 | if (ret) { |
| 76 | debug("Clock init failed: %d\n", ret); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | ret = uclass_get_device(UCLASS_RESET, 0, &dev); |
| 81 | if (ret) { |
| 82 | debug("Reset init failed: %d\n", ret); |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev); |
| 87 | if (ret) { |
| 88 | debug("%s: Cannot find pinctrl device\n", __func__); |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | /* enable console uart printing */ |
| 93 | preloader_console_init(); |
| 94 | |
| 95 | ret = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 96 | if (ret) { |
| 97 | debug("DRAM init failed: %d\n", ret); |
| 98 | return; |
| 99 | } |
| 100 | } |