Mike Frysinger | 86a20fb | 2008-02-16 07:40:36 -0500 | [diff] [blame] | 1 | /* |
| 2 | * U-boot - bootldr.c |
| 3 | * |
| 4 | * Copyright (c) 2005-2008 Analog Devices Inc. |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * Licensed under the GPL-2 or later. |
| 10 | */ |
| 11 | |
| 12 | #include <config.h> |
| 13 | #include <common.h> |
| 14 | #include <command.h> |
| 15 | |
| 16 | #include <asm/blackfin.h> |
| 17 | #include <asm/mach-common/bits/bootrom.h> |
| 18 | |
| 19 | /* |
| 20 | * the bootldr command loads an address, checks to see if there |
| 21 | * is a Boot stream that the on-chip BOOTROM can understand, |
| 22 | * and loads it via the BOOTROM Callback. It is possible |
| 23 | * to also add booting from SPI, or TWI, but this function does |
| 24 | * not currently support that. |
| 25 | */ |
| 26 | |
| 27 | int do_bootldr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 28 | { |
| 29 | void *addr; |
| 30 | uint32_t *data; |
| 31 | |
| 32 | /* Get the address */ |
| 33 | if (argc < 2) |
| 34 | addr = (void *)load_addr; |
| 35 | else |
| 36 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 37 | |
| 38 | /* Check if it is a LDR file */ |
| 39 | data = addr; |
| 40 | #if defined(__ADSPBF54x__) || defined(__ADSPBF52x__) |
| 41 | if ((*data & 0xFF000000) == 0xAD000000 && data[2] == 0x00000000) { |
| 42 | #else |
| 43 | if (*data == 0xFF800060 || *data == 0xFF800040 || *data == 0xFF800020) { |
| 44 | #endif |
| 45 | /* We want to boot from FLASH or SDRAM */ |
| 46 | printf("## Booting ldr image at 0x%p ...\n", addr); |
| 47 | |
| 48 | icache_disable(); |
| 49 | dcache_disable(); |
| 50 | |
| 51 | __asm__( |
| 52 | "jump (%1);" |
| 53 | : |
| 54 | : "q7" (addr), "a" (_BOOTROM_MEMBOOT)); |
| 55 | } else |
| 56 | printf("## No ldr image at address 0x%p\n", addr); |
| 57 | |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | U_BOOT_CMD(bootldr, 2, 0, do_bootldr, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 62 | "boot ldr image from memory", |
Mike Frysinger | 86a20fb | 2008-02-16 07:40:36 -0500 | [diff] [blame] | 63 | "[addr]\n" |
| 64 | " - boot ldr image stored in memory\n"); |