Tomasz Figa | d710aa3 | 2014-03-18 07:28:27 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 3 | * http://www.samsung.com |
| 4 | * |
| 5 | * Exynos low-level resume code |
| 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; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/linkage.h> |
Tomasz Figa | 30ad527 | 2015-01-08 07:53:56 +0100 | [diff] [blame] | 19 | #include <asm/asm-offsets.h> |
| 20 | #include <asm/hardware/cache-l2x0.h> |
Tomasz Figa | 2b9d9c3 | 2014-09-24 01:24:39 +0900 | [diff] [blame] | 21 | #include "smc.h" |
Tomasz Figa | d710aa3 | 2014-03-18 07:28:27 +0900 | [diff] [blame] | 22 | |
| 23 | #define CPU_MASK 0xff0ffff0 |
| 24 | #define CPU_CORTEX_A9 0x410fc090 |
| 25 | |
Ard Biesheuvel | 12833ba | 2015-03-25 07:41:43 +0100 | [diff] [blame] | 26 | .text |
Tomasz Figa | d710aa3 | 2014-03-18 07:28:27 +0900 | [diff] [blame] | 27 | .align |
| 28 | |
| 29 | /* |
| 30 | * sleep magic, to allow the bootloader to check for an valid |
| 31 | * image to resume to. Must be the first word before the |
| 32 | * exynos_cpu_resume entry. |
| 33 | */ |
| 34 | |
| 35 | .word 0x2bedf00d |
| 36 | |
| 37 | /* |
| 38 | * exynos_cpu_resume |
| 39 | * |
| 40 | * resume code entry for bootloader to call |
| 41 | */ |
| 42 | |
| 43 | ENTRY(exynos_cpu_resume) |
| 44 | #ifdef CONFIG_CACHE_L2X0 |
| 45 | mrc p15, 0, r0, c0, c0, 0 |
| 46 | ldr r1, =CPU_MASK |
| 47 | and r0, r0, r1 |
| 48 | ldr r1, =CPU_CORTEX_A9 |
| 49 | cmp r0, r1 |
Russell King | 25a9ef6 | 2014-04-05 11:45:34 +0100 | [diff] [blame] | 50 | bleq l2c310_early_resume |
Tomasz Figa | d710aa3 | 2014-03-18 07:28:27 +0900 | [diff] [blame] | 51 | #endif |
| 52 | b cpu_resume |
| 53 | ENDPROC(exynos_cpu_resume) |
Tomasz Figa | 2b9d9c3 | 2014-09-24 01:24:39 +0900 | [diff] [blame] | 54 | |
| 55 | .align |
| 56 | |
| 57 | ENTRY(exynos_cpu_resume_ns) |
| 58 | mrc p15, 0, r0, c0, c0, 0 |
| 59 | ldr r1, =CPU_MASK |
| 60 | and r0, r0, r1 |
| 61 | ldr r1, =CPU_CORTEX_A9 |
| 62 | cmp r0, r1 |
| 63 | bne skip_cp15 |
| 64 | |
Ard Biesheuvel | 12833ba | 2015-03-25 07:41:43 +0100 | [diff] [blame] | 65 | adr r0, _cp15_save_power |
Tomasz Figa | 2b9d9c3 | 2014-09-24 01:24:39 +0900 | [diff] [blame] | 66 | ldr r1, [r0] |
Ard Biesheuvel | 12833ba | 2015-03-25 07:41:43 +0100 | [diff] [blame] | 67 | ldr r1, [r0, r1] |
| 68 | adr r0, _cp15_save_diag |
Tomasz Figa | 2b9d9c3 | 2014-09-24 01:24:39 +0900 | [diff] [blame] | 69 | ldr r2, [r0] |
Ard Biesheuvel | 12833ba | 2015-03-25 07:41:43 +0100 | [diff] [blame] | 70 | ldr r2, [r0, r2] |
Tomasz Figa | 2b9d9c3 | 2014-09-24 01:24:39 +0900 | [diff] [blame] | 71 | mov r0, #SMC_CMD_C15RESUME |
| 72 | dsb |
| 73 | smc #0 |
Tomasz Figa | 30ad527 | 2015-01-08 07:53:56 +0100 | [diff] [blame] | 74 | #ifdef CONFIG_CACHE_L2X0 |
| 75 | adr r0, 1f |
| 76 | ldr r2, [r0] |
| 77 | add r0, r2, r0 |
| 78 | |
| 79 | /* Check that the address has been initialised. */ |
| 80 | ldr r1, [r0, #L2X0_R_PHY_BASE] |
| 81 | teq r1, #0 |
| 82 | beq skip_l2x0 |
| 83 | |
| 84 | /* Check if controller has been enabled. */ |
| 85 | ldr r2, [r1, #L2X0_CTRL] |
| 86 | tst r2, #0x1 |
| 87 | bne skip_l2x0 |
| 88 | |
| 89 | ldr r1, [r0, #L2X0_R_TAG_LATENCY] |
| 90 | ldr r2, [r0, #L2X0_R_DATA_LATENCY] |
| 91 | ldr r3, [r0, #L2X0_R_PREFETCH_CTRL] |
| 92 | mov r0, #SMC_CMD_L2X0SETUP1 |
| 93 | smc #0 |
| 94 | |
| 95 | /* Reload saved regs pointer because smc corrupts registers. */ |
| 96 | adr r0, 1f |
| 97 | ldr r2, [r0] |
| 98 | add r0, r2, r0 |
| 99 | |
| 100 | ldr r1, [r0, #L2X0_R_PWR_CTRL] |
| 101 | ldr r2, [r0, #L2X0_R_AUX_CTRL] |
| 102 | mov r0, #SMC_CMD_L2X0SETUP2 |
| 103 | smc #0 |
| 104 | |
| 105 | mov r0, #SMC_CMD_L2X0INVALL |
| 106 | smc #0 |
| 107 | |
| 108 | mov r1, #1 |
| 109 | mov r0, #SMC_CMD_L2X0CTRL |
| 110 | smc #0 |
| 111 | skip_l2x0: |
| 112 | #endif /* CONFIG_CACHE_L2X0 */ |
Tomasz Figa | 2b9d9c3 | 2014-09-24 01:24:39 +0900 | [diff] [blame] | 113 | skip_cp15: |
| 114 | b cpu_resume |
| 115 | ENDPROC(exynos_cpu_resume_ns) |
Ard Biesheuvel | 12833ba | 2015-03-25 07:41:43 +0100 | [diff] [blame] | 116 | |
| 117 | .align |
| 118 | _cp15_save_power: |
| 119 | .long cp15_save_power - . |
| 120 | _cp15_save_diag: |
| 121 | .long cp15_save_diag - . |
| 122 | #ifdef CONFIG_CACHE_L2X0 |
| 123 | 1: .long l2x0_saved_regs - . |
| 124 | #endif /* CONFIG_CACHE_L2X0 */ |
| 125 | |
| 126 | .data |
Tomasz Figa | 2b9d9c3 | 2014-09-24 01:24:39 +0900 | [diff] [blame] | 127 | .globl cp15_save_diag |
| 128 | cp15_save_diag: |
| 129 | .long 0 @ cp15 diagnostic |
| 130 | .globl cp15_save_power |
| 131 | cp15_save_power: |
| 132 | .long 0 @ cp15 power control |