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 | |
| 15 | boot_mode = (readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_MODE_MASK) >> |
| 16 | TAMP_BOOT_MODE_SHIFT; |
| 17 | clrsetbits_le32(TAMP_BOOT_CONTEXT, |
| 18 | TAMP_BOOT_MODE_MASK, |
| 19 | boot_mode << TAMP_BOOT_MODE_SHIFT); |
| 20 | |
| 21 | switch (boot_mode) { |
| 22 | case BOOT_FLASH_SD_1: |
| 23 | case BOOT_FLASH_EMMC_1: |
| 24 | return BOOT_DEVICE_MMC1; |
| 25 | case BOOT_FLASH_SD_2: |
| 26 | case BOOT_FLASH_EMMC_2: |
| 27 | return BOOT_DEVICE_MMC2; |
| 28 | } |
| 29 | |
Patrick Delaunay | 2514c2d | 2018-03-12 10:46:10 +0100 | [diff] [blame] | 30 | return BOOT_DEVICE_MMC1; |
| 31 | } |
| 32 | |
| 33 | u32 spl_boot_mode(const u32 boot_device) |
| 34 | { |
| 35 | return MMCSD_MODE_RAW; |
| 36 | } |
| 37 | |
Patrick Delaunay | 11dfd1a | 2018-03-20 10:54:54 +0100 | [diff] [blame] | 38 | int spl_boot_partition(const u32 boot_device) |
| 39 | { |
| 40 | switch (boot_device) { |
| 41 | case BOOT_DEVICE_MMC1: |
| 42 | return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION; |
| 43 | case BOOT_DEVICE_MMC2: |
| 44 | return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2; |
| 45 | default: |
| 46 | return -EINVAL; |
| 47 | } |
| 48 | } |
| 49 | |
Patrick Delaunay | 2514c2d | 2018-03-12 10:46:10 +0100 | [diff] [blame] | 50 | void board_init_f(ulong dummy) |
| 51 | { |
| 52 | struct udevice *dev; |
| 53 | int ret; |
| 54 | |
| 55 | arch_cpu_init(); |
| 56 | |
| 57 | ret = spl_early_init(); |
| 58 | if (ret) { |
| 59 | debug("spl_early_init() failed: %d\n", ret); |
| 60 | hang(); |
| 61 | } |
| 62 | |
| 63 | ret = uclass_get_device(UCLASS_CLK, 0, &dev); |
| 64 | if (ret) { |
| 65 | debug("Clock init failed: %d\n", ret); |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | ret = uclass_get_device(UCLASS_RESET, 0, &dev); |
| 70 | if (ret) { |
| 71 | debug("Reset init failed: %d\n", ret); |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev); |
| 76 | if (ret) { |
| 77 | debug("%s: Cannot find pinctrl device\n", __func__); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | /* enable console uart printing */ |
| 82 | preloader_console_init(); |
| 83 | |
| 84 | ret = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 85 | if (ret) { |
| 86 | debug("DRAM init failed: %d\n", ret); |
| 87 | return; |
| 88 | } |
| 89 | } |