Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bo Shen | f92b298 | 2013-11-15 11:12:38 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013 Atmel Corporation |
| 4 | * Bo Shen <voice.shen@atmel.com> |
Bo Shen | f92b298 | 2013-11-15 11:12:38 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 7 | #include <hang.h> |
Bo Shen | f92b298 | 2013-11-15 11:12:38 +0800 | [diff] [blame] | 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/at91_common.h> |
Bo Shen | f92b298 | 2013-11-15 11:12:38 +0800 | [diff] [blame] | 10 | #include <asm/arch/at91_wdt.h> |
| 11 | #include <asm/arch/clk.h> |
| 12 | #include <spl.h> |
| 13 | |
Prasanthi Chellakumar | 0509c4e | 2018-10-09 11:46:40 -0700 | [diff] [blame] | 14 | #if !defined(CONFIG_WDT_AT91) |
Heiko Schocher | f1e3a8c | 2014-10-31 08:31:04 +0100 | [diff] [blame] | 15 | void at91_disable_wdt(void) |
Bo Shen | f92b298 | 2013-11-15 11:12:38 +0800 | [diff] [blame] | 16 | { |
| 17 | struct at91_wdt *wdt = (struct at91_wdt *)ATMEL_BASE_WDT; |
| 18 | |
| 19 | writel(AT91_WDT_MR_WDDIS, &wdt->mr); |
| 20 | } |
Heiko Schocher | 62e6137 | 2015-01-21 08:38:20 +0100 | [diff] [blame] | 21 | #endif |
Bo Shen | f92b298 | 2013-11-15 11:12:38 +0800 | [diff] [blame] | 22 | |
Marek Vasut | f5e7513 | 2016-05-14 23:43:01 +0200 | [diff] [blame] | 23 | #if defined(CONFIG_SAMA5D2) || defined(CONFIG_SAMA5D3) || \ |
| 24 | defined(CONFIG_SAMA5D4) |
| 25 | #include <asm/arch/sama5_boot.h> |
Marek Vasut | 4d88f1c | 2016-04-22 21:56:21 +0200 | [diff] [blame] | 26 | struct { |
| 27 | u32 r4; |
Marek BehĂșn | 4bebdd3 | 2021-05-20 13:23:52 +0200 | [diff] [blame] | 28 | } bootrom_stash __section(".data"); |
Marek Vasut | 4d88f1c | 2016-04-22 21:56:21 +0200 | [diff] [blame] | 29 | |
| 30 | u32 spl_boot_device(void) |
| 31 | { |
Marek Vasut | f5e7513 | 2016-05-14 23:43:01 +0200 | [diff] [blame] | 32 | u32 dev = (bootrom_stash.r4 >> ATMEL_SAMA5_BOOT_FROM_OFF) & |
| 33 | ATMEL_SAMA5_BOOT_FROM_MASK; |
| 34 | u32 off = (bootrom_stash.r4 >> ATMEL_SAMA5_BOOT_DEV_ID_OFF) & |
| 35 | ATMEL_SAMA5_BOOT_DEV_ID_MASK; |
Marek Vasut | 4d88f1c | 2016-04-22 21:56:21 +0200 | [diff] [blame] | 36 | |
Wenyou Yang | 5561f6f | 2017-09-14 11:07:43 +0800 | [diff] [blame] | 37 | #if defined(CONFIG_SYS_USE_MMC) || defined(CONFIG_SD_BOOT) |
Marek Vasut | f5e7513 | 2016-05-14 23:43:01 +0200 | [diff] [blame] | 38 | if (dev == ATMEL_SAMA5_BOOT_FROM_MCI) { |
Wenyou Yang | 71806ec | 2017-03-24 11:34:03 +0800 | [diff] [blame] | 39 | #if defined(CONFIG_SPL_OF_CONTROL) |
| 40 | return BOOT_DEVICE_MMC1; |
| 41 | #else |
Marek Vasut | 4d88f1c | 2016-04-22 21:56:21 +0200 | [diff] [blame] | 42 | if (off == 0) |
| 43 | return BOOT_DEVICE_MMC1; |
| 44 | if (off == 1) |
| 45 | return BOOT_DEVICE_MMC2; |
| 46 | printf("ERROR: MMC controller %i not present!\n", dev); |
| 47 | hang(); |
Wenyou Yang | 71806ec | 2017-03-24 11:34:03 +0800 | [diff] [blame] | 48 | #endif |
Marek Vasut | 4d88f1c | 2016-04-22 21:56:21 +0200 | [diff] [blame] | 49 | } |
| 50 | #endif |
| 51 | |
Wenyou Yang | 5561f6f | 2017-09-14 11:07:43 +0800 | [diff] [blame] | 52 | #if defined(CONFIG_SYS_USE_SERIALFLASH) || \ |
| 53 | defined(CONFIG_SYS_USE_SPIFLASH) || \ |
| 54 | defined(CONFIG_SPI_BOOT) |
Marek Vasut | f5e7513 | 2016-05-14 23:43:01 +0200 | [diff] [blame] | 55 | if (dev == ATMEL_SAMA5_BOOT_FROM_SPI) |
Marek Vasut | 4d88f1c | 2016-04-22 21:56:21 +0200 | [diff] [blame] | 56 | return BOOT_DEVICE_SPI; |
| 57 | #endif |
Wenyou Yang | 0e97cad | 2017-09-13 14:58:51 +0800 | [diff] [blame] | 58 | if (dev == ATMEL_SAMA5_BOOT_FROM_QSPI) |
| 59 | return BOOT_DEVICE_SPI; |
Marek Vasut | 4d88f1c | 2016-04-22 21:56:21 +0200 | [diff] [blame] | 60 | |
Wenyou Yang | 71806ec | 2017-03-24 11:34:03 +0800 | [diff] [blame] | 61 | if (dev == ATMEL_SAMA5_BOOT_FROM_SMC) |
| 62 | return BOOT_DEVICE_NAND; |
| 63 | |
Marek Vasut | f5e7513 | 2016-05-14 23:43:01 +0200 | [diff] [blame] | 64 | if (dev == ATMEL_SAMA5_BOOT_FROM_SAMBA) |
| 65 | return BOOT_DEVICE_USB; |
| 66 | |
Marek Vasut | 4d88f1c | 2016-04-22 21:56:21 +0200 | [diff] [blame] | 67 | printf("ERROR: SMC/TWI/QSPI boot device not supported!\n" |
| 68 | " Boot device %i, controller number %i\n", dev, off); |
| 69 | |
| 70 | return BOOT_DEVICE_NONE; |
| 71 | } |
| 72 | #else |
Bo Shen | f92b298 | 2013-11-15 11:12:38 +0800 | [diff] [blame] | 73 | u32 spl_boot_device(void) |
| 74 | { |
Wenyou Yang | 5561f6f | 2017-09-14 11:07:43 +0800 | [diff] [blame] | 75 | #if defined(CONFIG_SYS_USE_MMC) || defined(CONFIG_SD_BOOT) |
Bo Shen | f92b298 | 2013-11-15 11:12:38 +0800 | [diff] [blame] | 76 | return BOOT_DEVICE_MMC1; |
Wenyou Yang | 5561f6f | 2017-09-14 11:07:43 +0800 | [diff] [blame] | 77 | #elif defined(CONFIG_SYS_USE_NANDFLASH) || defined(CONFIG_NAND_BOOT) |
Bo Shen | 540c031 | 2014-03-03 14:47:17 +0800 | [diff] [blame] | 78 | return BOOT_DEVICE_NAND; |
Wenyou Yang | 5561f6f | 2017-09-14 11:07:43 +0800 | [diff] [blame] | 79 | #elif defined(CONFIG_SYS_USE_SERIALFLASH) || \ |
| 80 | defined(CONFIG_SYS_USE_SPIFLASH) || \ |
| 81 | defined(CONFIG_SPI_BOOT) |
Bo Shen | 37a36b3 | 2014-03-03 14:47:15 +0800 | [diff] [blame] | 82 | return BOOT_DEVICE_SPI; |
Bo Shen | f92b298 | 2013-11-15 11:12:38 +0800 | [diff] [blame] | 83 | #endif |
| 84 | return BOOT_DEVICE_NONE; |
| 85 | } |
Marek Vasut | 4d88f1c | 2016-04-22 21:56:21 +0200 | [diff] [blame] | 86 | #endif |