Peter De Schrijver | c76fcc8 | 2012-01-26 18:22:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-tegra/sleep.S |
| 3 | * |
| 4 | * Copyright (c) 2010-2011, NVIDIA Corporation. |
| 5 | * Copyright (c) 2011, Google, Inc. |
| 6 | * |
| 7 | * Author: Colin Cross <ccross@android.com> |
| 8 | * Gary King <gking@nvidia.com> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 18 | * more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License along |
| 21 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 23 | */ |
| 24 | |
| 25 | #include <linux/linkage.h> |
Stephen Warren | 7175f80 | 2012-03-19 09:55:12 -0600 | [diff] [blame] | 26 | |
| 27 | #include <asm/assembler.h> |
Joseph Lo | d552920 | 2012-10-31 17:41:21 +0800 | [diff] [blame^] | 28 | #include <asm/cache.h> |
Joseph Lo | d457ef35 | 2012-10-31 17:41:17 +0800 | [diff] [blame] | 29 | #include <asm/cp15.h> |
Stephen Warren | 7175f80 | 2012-03-19 09:55:12 -0600 | [diff] [blame] | 30 | |
Stephen Warren | 2be39c0 | 2012-10-04 14:24:09 -0600 | [diff] [blame] | 31 | #include "iomap.h" |
Peter De Schrijver | c76fcc8 | 2012-01-26 18:22:02 +0200 | [diff] [blame] | 32 | |
| 33 | #include "flowctrl.h" |
Joseph Lo | c2be5bf | 2012-08-16 17:31:50 +0800 | [diff] [blame] | 34 | #include "sleep.h" |
Peter De Schrijver | c76fcc8 | 2012-01-26 18:22:02 +0200 | [diff] [blame] | 35 | |
Joseph Lo | d457ef35 | 2012-10-31 17:41:17 +0800 | [diff] [blame] | 36 | #ifdef CONFIG_PM_SLEEP |
| 37 | /* |
| 38 | * tegra_disable_clean_inv_dcache |
| 39 | * |
| 40 | * disable, clean & invalidate the D-cache |
| 41 | * |
| 42 | * Corrupted registers: r1-r3, r6, r8, r9-r11 |
| 43 | */ |
| 44 | ENTRY(tegra_disable_clean_inv_dcache) |
| 45 | stmfd sp!, {r0, r4-r5, r7, r9-r11, lr} |
| 46 | dmb @ ensure ordering |
| 47 | |
| 48 | /* Disable the D-cache */ |
| 49 | mrc p15, 0, r2, c1, c0, 0 |
| 50 | bic r2, r2, #CR_C |
| 51 | mcr p15, 0, r2, c1, c0, 0 |
| 52 | isb |
| 53 | |
| 54 | /* Flush the D-cache */ |
| 55 | bl v7_flush_dcache_louis |
| 56 | |
| 57 | /* Trun off coherency */ |
| 58 | exit_smp r4, r5 |
| 59 | |
| 60 | ldmfd sp!, {r0, r4-r5, r7, r9-r11, pc} |
| 61 | ENDPROC(tegra_disable_clean_inv_dcache) |
| 62 | |
Joseph Lo | d552920 | 2012-10-31 17:41:21 +0800 | [diff] [blame^] | 63 | /* |
| 64 | * tegra_sleep_cpu_finish(unsigned long v2p) |
| 65 | * |
| 66 | * enters suspend in LP2 by turning off the mmu and jumping to |
| 67 | * tegra?_tear_down_cpu |
| 68 | */ |
| 69 | ENTRY(tegra_sleep_cpu_finish) |
| 70 | /* Flush and disable the L1 data cache */ |
| 71 | bl tegra_disable_clean_inv_dcache |
| 72 | |
| 73 | mov32 r6, tegra_tear_down_cpu |
| 74 | ldr r1, [r6] |
| 75 | add r1, r1, r0 |
| 76 | |
| 77 | mov32 r3, tegra_shut_off_mmu |
| 78 | add r3, r3, r0 |
| 79 | mov r0, r1 |
| 80 | |
| 81 | mov pc, r3 |
| 82 | ENDPROC(tegra_sleep_cpu_finish) |
| 83 | |
| 84 | /* |
| 85 | * tegra_shut_off_mmu |
| 86 | * |
| 87 | * r0 = physical address to jump to with mmu off |
| 88 | * |
| 89 | * called with VA=PA mapping |
| 90 | * turns off MMU, icache, dcache and branch prediction |
| 91 | */ |
| 92 | .align L1_CACHE_SHIFT |
| 93 | .pushsection .idmap.text, "ax" |
| 94 | ENTRY(tegra_shut_off_mmu) |
| 95 | mrc p15, 0, r3, c1, c0, 0 |
| 96 | movw r2, #CR_I | CR_Z | CR_C | CR_M |
| 97 | bic r3, r3, r2 |
| 98 | dsb |
| 99 | mcr p15, 0, r3, c1, c0, 0 |
| 100 | isb |
| 101 | mov pc, r0 |
| 102 | ENDPROC(tegra_shut_off_mmu) |
| 103 | .popsection |
Joseph Lo | d457ef35 | 2012-10-31 17:41:17 +0800 | [diff] [blame] | 104 | #endif |