Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Nobuhiro Iwamatsu <nobuhiro.Iwamatsu.yj@renesas.com> |
| 3 | * Copyright (C) 2012 Renesas Solutions Corp. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <config.h> |
| 25 | #include <linux/linkage.h> |
| 26 | |
| 27 | ENTRY(lowlevel_init) |
| 28 | ldr r0, =MERAM_BASE |
| 29 | mov r1, #0x0 |
| 30 | str r1, [r0] |
| 31 | |
| 32 | mrc p15, 0, r0, c0, c0, 5 |
| 33 | ands r0, r0, #0xF |
| 34 | beq lowlevel_init__ |
| 35 | b wait_interrupt |
| 36 | |
| 37 | .pool |
| 38 | .align 4 |
| 39 | |
| 40 | wait_interrupt: |
Nobuhiro Iwamatsu | fe1c4bc | 2012-07-25 15:48:27 +0900 | [diff] [blame^] | 41 | #ifdef ICCICR |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 42 | ldr r1, =ICCICR |
| 43 | mov r2, #0x0 |
| 44 | str r2, [r1] |
| 45 | mov r2, #0xF0 |
| 46 | adds r1, r1, #4 /* ICCPMR */ |
| 47 | str r2, [r1] |
| 48 | ldr r1, =ICCICR |
| 49 | mov r2, #0x1 |
| 50 | str r2, [r1] |
Nobuhiro Iwamatsu | fe1c4bc | 2012-07-25 15:48:27 +0900 | [diff] [blame^] | 51 | #endif |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 52 | |
| 53 | wait_loop: |
Nobuhiro Iwamatsu | 7cd76e1 | 2012-07-06 08:53:02 +0900 | [diff] [blame] | 54 | .long 0xE320F003 /* wfi */ |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 55 | |
| 56 | ldr r2, [r1, #0xC] |
| 57 | str r2, [r1, #0x10] |
| 58 | |
| 59 | ldr r0, =MERAM_BASE |
| 60 | ldr r2, [r0] |
| 61 | cmp r2, #0 |
| 62 | movne pc, r2 |
| 63 | |
| 64 | b wait_loop |
| 65 | |
| 66 | wait_loop_end: |
| 67 | .pool |
| 68 | .align 4 |
| 69 | |
| 70 | lowlevel_init__: |
| 71 | |
| 72 | mov r0, #0x200000 |
| 73 | |
| 74 | loop0: |
| 75 | subs r0, r0, #1 |
| 76 | bne loop0 |
| 77 | |
| 78 | ldr sp, MERAM_STACK |
| 79 | |
| 80 | str ip, [sp] /* stash old link register */ |
| 81 | mov ip, lr /* save link reg across call */ |
Nobuhiro Iwamatsu | fe1c4bc | 2012-07-25 15:48:27 +0900 | [diff] [blame^] | 82 | |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 83 | bl s_init |
| 84 | |
| 85 | ldr ip, [sp] /* restore save ip */ |
| 86 | mov lr, ip /* restore link reg */ |
| 87 | |
| 88 | /* back to arch calling code */ |
| 89 | mov pc, lr |
| 90 | |
| 91 | .pool |
| 92 | .align 4 |
| 93 | |
| 94 | ENDPROC(lowlevel_init) |
| 95 | .ltorg |
| 96 | |
| 97 | MERAM_STACK: |
| 98 | .word LOW_LEVEL_MERAM_STACK |