2 * Copyright (C) 2013 Atmel Corporation
3 * Bo Shen <voice.shen@atmel.com>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/at91_common.h>
11 #include <asm/arch/at91_wdt.h>
12 #include <asm/arch/clk.h>
15 #if defined(CONFIG_AT91SAM9_WATCHDOG)
16 void at91_disable_wdt(void) { }
18 void at91_disable_wdt(void)
20 struct at91_wdt *wdt = (struct at91_wdt *)ATMEL_BASE_WDT;
22 writel(AT91_WDT_MR_WDDIS, &wdt->mr);
26 #if defined(CONFIG_SAMA5D2) || defined(CONFIG_SAMA5D3) || \
27 defined(CONFIG_SAMA5D4)
28 #include <asm/arch/sama5_boot.h>
31 } bootrom_stash __attribute__((section(".data")));
33 u32 spl_boot_device(void)
35 u32 dev = (bootrom_stash.r4 >> ATMEL_SAMA5_BOOT_FROM_OFF) &
36 ATMEL_SAMA5_BOOT_FROM_MASK;
37 u32 off = (bootrom_stash.r4 >> ATMEL_SAMA5_BOOT_DEV_ID_OFF) &
38 ATMEL_SAMA5_BOOT_DEV_ID_MASK;
40 #if defined(CONFIG_SYS_USE_MMC)
41 if (dev == ATMEL_SAMA5_BOOT_FROM_MCI) {
43 return BOOT_DEVICE_MMC1;
45 return BOOT_DEVICE_MMC2;
46 printf("ERROR: MMC controller %i not present!\n", dev);
51 #if defined(CONFIG_SYS_USE_SERIALFLASH) || defined(CONFIG_SYS_USE_SPIFLASH)
52 if (dev == ATMEL_SAMA5_BOOT_FROM_SPI)
53 return BOOT_DEVICE_SPI;
56 if (dev == ATMEL_SAMA5_BOOT_FROM_SAMBA)
57 return BOOT_DEVICE_USB;
59 printf("ERROR: SMC/TWI/QSPI boot device not supported!\n"
60 " Boot device %i, controller number %i\n", dev, off);
62 return BOOT_DEVICE_NONE;
65 u32 spl_boot_device(void)
67 #ifdef CONFIG_SYS_USE_MMC
68 return BOOT_DEVICE_MMC1;
69 #elif CONFIG_SYS_USE_NANDFLASH
70 return BOOT_DEVICE_NAND;
71 #elif CONFIG_SYS_USE_SERIALFLASH || CONFIG_SYS_USE_SPIFLASH
72 return BOOT_DEVICE_SPI;
74 return BOOT_DEVICE_NONE;
78 u32 spl_boot_mode(const u32 boot_device)
80 switch (boot_device) {
81 #ifdef CONFIG_SYS_USE_MMC
82 case BOOT_DEVICE_MMC1:
83 case BOOT_DEVICE_MMC2:
87 case BOOT_DEVICE_NONE: