Kuninori Morimoto | 9a4af11 | 2010-12-01 07:45:00 +0100 | [diff] [blame] | 1 | /* |
| 2 | * The head-file for SH-Mobile ARM platforms |
| 3 | * |
| 4 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 5 | * Simon Horman <horms@verge.net.au> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #ifdef CONFIG_ZBOOT_ROM |
| 22 | |
| 23 | .section ".start", "ax" |
| 24 | |
| 25 | /* load board-specific initialization code */ |
| 26 | #include <mach/zboot.h> |
| 27 | |
Simon Horman | 090ab3f | 2011-04-26 06:29:53 +0100 | [diff] [blame] | 28 | #if defined(CONFIG_ZBOOT_ROM_MMCIF) || defined(CONFIG_ZBOOT_ROM_SH_MOBILE_SDHI) |
| 29 | /* Load image from MMC/SD */ |
| 30 | adr sp, __tmp_stack + 256 |
Simon Horman | f45b114 | 2011-01-11 04:01:08 +0100 | [diff] [blame] | 31 | ldr r0, __image_start |
| 32 | ldr r1, __image_end |
| 33 | subs r1, r1, r0 |
| 34 | ldr r0, __load_base |
Simon Horman | 090ab3f | 2011-04-26 06:29:53 +0100 | [diff] [blame] | 35 | bl mmc_loader |
Simon Horman | f45b114 | 2011-01-11 04:01:08 +0100 | [diff] [blame] | 36 | |
| 37 | /* Jump to loaded code */ |
| 38 | ldr r0, __loaded |
| 39 | ldr r1, __image_start |
| 40 | sub r0, r0, r1 |
| 41 | ldr r1, __load_base |
| 42 | add pc, r0, r1 |
| 43 | |
| 44 | __image_start: |
| 45 | .long _start |
| 46 | __image_end: |
| 47 | .long _got_end |
| 48 | __load_base: |
Magnus Damm | 4f309d2 | 2013-06-05 16:55:31 +0900 | [diff] [blame] | 49 | .long MEMORY_START + 0x02000000 @ Load at 32Mb into SDRAM |
Simon Horman | f45b114 | 2011-01-11 04:01:08 +0100 | [diff] [blame] | 50 | __loaded: |
| 51 | .long __continue |
| 52 | .align |
| 53 | __tmp_stack: |
Simon Horman | 090ab3f | 2011-04-26 06:29:53 +0100 | [diff] [blame] | 54 | .space 256 |
Simon Horman | f45b114 | 2011-01-11 04:01:08 +0100 | [diff] [blame] | 55 | __continue: |
Simon Horman | 090ab3f | 2011-04-26 06:29:53 +0100 | [diff] [blame] | 56 | #endif /* CONFIG_ZBOOT_ROM_MMC || CONFIG_ZBOOT_ROM_SH_MOBILE_SDHI */ |
Simon Horman | f45b114 | 2011-01-11 04:01:08 +0100 | [diff] [blame] | 57 | |
Magnus Damm | 2c408d1 | 2013-06-27 08:48:07 +0900 | [diff] [blame] | 58 | adr r0, dtb_info |
| 59 | ldmia r0, {r1, r3, r4, r5, r7} |
| 60 | |
| 61 | sub r0, r0, r1 @ calculate the delta offset |
| 62 | add r5, r5, r0 @ _edata |
| 63 | |
| 64 | ldr lr, [r5, #0] @ check if valid DTB is present |
| 65 | cmp lr, r3 |
| 66 | bne 0f |
| 67 | |
| 68 | add r9, r7, #31 @ rounded up to a multiple |
| 69 | bic r9, r9, #31 @ ... of 32 bytes |
| 70 | |
| 71 | add r6, r9, r5 @ copy from _edata |
| 72 | add r9, r9, r4 @ to MEMORY_START |
| 73 | |
| 74 | 1: ldmdb r6!, {r0 - r3, r10 - r12, lr} |
| 75 | cmp r6, r5 |
| 76 | stmdb r9!, {r0 - r3, r10 - r12, lr} |
| 77 | bhi 1b |
| 78 | |
| 79 | /* Success: Zero board ID, pointer to start of memory for atag/dtb */ |
| 80 | mov r7, #0 |
| 81 | mov r8, r4 |
Kuninori Morimoto | 9a4af11 | 2010-12-01 07:45:00 +0100 | [diff] [blame] | 82 | b 2f |
| 83 | |
Magnus Damm | 2c408d1 | 2013-06-27 08:48:07 +0900 | [diff] [blame] | 84 | .align 2 |
| 85 | dtb_info: |
| 86 | .word dtb_info |
| 87 | #ifndef __ARMEB__ |
| 88 | .word 0xedfe0dd0 @ sig is 0xd00dfeed big endian |
| 89 | #else |
| 90 | .word 0xd00dfeed |
| 91 | #endif |
| 92 | .word MEMORY_START |
| 93 | .word _edata |
| 94 | .word 0x4000 @ maximum DTB size |
| 95 | 0: |
| 96 | /* Failure: Zero board ID, NULL atag/dtb */ |
| 97 | mov r7, #0 |
| 98 | mov r8, #0 @ pass null pointer as atag |
Kuninori Morimoto | 9a4af11 | 2010-12-01 07:45:00 +0100 | [diff] [blame] | 99 | 2 : |
| 100 | |
| 101 | #endif /* CONFIG_ZBOOT_ROM */ |