Magnus Damm | 9799165 | 2011-04-29 02:28:08 +0900 | [diff] [blame] | 1 | /* |
| 2 | * sh7372 lowlevel sleep code for "Core Standby Mode" |
| 3 | * |
| 4 | * Copyright (C) 2011 Magnus Damm |
| 5 | * |
| 6 | * In "Core Standby Mode" the ARM core is off, but L2 cache is still on |
| 7 | * |
| 8 | * Based on mach-omap2/sleep34xx.S |
| 9 | * |
| 10 | * (C) Copyright 2007 Texas Instruments |
| 11 | * Karthik Dasu <karthik-dp@ti.com> |
| 12 | * |
| 13 | * (C) Copyright 2004 Texas Instruments, <www.ti.com> |
| 14 | * Richard Woodruff <r-woodruff2@ti.com> |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or |
| 17 | * modify it under the terms of the GNU General Public License as |
| 18 | * published by the Free Software Foundation; either version 2 of |
| 19 | * the License, or (at your option) any later version. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
| 25 | * |
| 26 | * You should have received a copy of the GNU General Public License |
| 27 | * along with this program; if not, write to the Free Software |
| 28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 29 | * MA 02111-1307 USA |
| 30 | */ |
| 31 | |
| 32 | #include <linux/linkage.h> |
Magnus Damm | 06b8416 | 2011-09-25 23:18:42 +0200 | [diff] [blame] | 33 | #include <linux/init.h> |
| 34 | #include <asm/memory.h> |
Magnus Damm | 9799165 | 2011-04-29 02:28:08 +0900 | [diff] [blame] | 35 | #include <asm/assembler.h> |
| 36 | |
Magnus Damm | a0089bd | 2011-09-25 23:21:02 +0200 | [diff] [blame] | 37 | #if defined(CONFIG_SUSPEND) || defined(CONFIG_CPU_IDLE) |
Magnus Damm | 9799165 | 2011-04-29 02:28:08 +0900 | [diff] [blame] | 38 | .align 12 |
| 39 | .text |
Magnus Damm | f7dadb3 | 2011-12-23 01:23:07 +0100 | [diff] [blame] | 40 | .global sh7372_resume_core_standby_sysc |
| 41 | sh7372_resume_core_standby_sysc: |
Magnus Damm | 06b8416 | 2011-09-25 23:18:42 +0200 | [diff] [blame] | 42 | ldr pc, 1f |
Magnus Damm | e26f406 | 2013-06-05 16:45:53 +0900 | [diff] [blame] | 43 | |
Tetsuyuki Kobayashi | 0b933cb | 2013-07-10 10:56:37 +0900 | [diff] [blame] | 44 | .align 2 |
Magnus Damm | e26f406 | 2013-06-05 16:45:53 +0900 | [diff] [blame] | 45 | .globl sh7372_cpu_resume |
| 46 | sh7372_cpu_resume: |
| 47 | 1: .space 4 |
Magnus Damm | cf33835 | 2011-09-25 23:20:49 +0200 | [diff] [blame] | 48 | |
Magnus Damm | f7dadb3 | 2011-12-23 01:23:07 +0100 | [diff] [blame] | 49 | #define SPDCR 0xe6180008 |
| 50 | |
| 51 | /* A3SM & A4S power down */ |
| 52 | .global sh7372_do_idle_sysc |
| 53 | sh7372_do_idle_sysc: |
| 54 | mov r8, r0 /* sleep mode passed in r0 */ |
| 55 | |
Magnus Damm | cf33835 | 2011-09-25 23:20:49 +0200 | [diff] [blame] | 56 | /* |
| 57 | * Clear the SCTLR.C bit to prevent further data cache |
| 58 | * allocation. Clearing SCTLR.C would make all the data accesses |
| 59 | * strongly ordered and would not hit the cache. |
| 60 | */ |
| 61 | mrc p15, 0, r0, c1, c0, 0 |
| 62 | bic r0, r0, #(1 << 2) @ Disable the C bit |
| 63 | mcr p15, 0, r0, c1, c0, 0 |
| 64 | isb |
| 65 | |
Guennadi Liakhovetski | 9916152 | 2012-12-28 12:32:54 +0100 | [diff] [blame] | 66 | /* |
| 67 | * Clean and invalidate data cache again. |
| 68 | */ |
| 69 | ldr r1, kernel_flush |
| 70 | blx r1 |
| 71 | |
Magnus Damm | cf33835 | 2011-09-25 23:20:49 +0200 | [diff] [blame] | 72 | /* disable L2 cache in the aux control register */ |
| 73 | mrc p15, 0, r10, c1, c0, 1 |
| 74 | bic r10, r10, #2 |
| 75 | mcr p15, 0, r10, c1, c0, 1 |
Guennadi Liakhovetski | 9916152 | 2012-12-28 12:32:54 +0100 | [diff] [blame] | 76 | isb |
Magnus Damm | cf33835 | 2011-09-25 23:20:49 +0200 | [diff] [blame] | 77 | |
| 78 | /* |
Magnus Damm | cf33835 | 2011-09-25 23:20:49 +0200 | [diff] [blame] | 79 | * The kernel doesn't interwork: v7_flush_dcache_all in particluar will |
| 80 | * always return in Thumb state when CONFIG_THUMB2_KERNEL is enabled. |
| 81 | * This sequence switches back to ARM. Note that .align may insert a |
| 82 | * nop: bx pc needs to be word-aligned in order to work. |
| 83 | */ |
| 84 | THUMB( .thumb ) |
| 85 | THUMB( .align ) |
| 86 | THUMB( bx pc ) |
| 87 | THUMB( nop ) |
| 88 | .arm |
| 89 | |
| 90 | /* Data memory barrier and Data sync barrier */ |
| 91 | dsb |
| 92 | dmb |
| 93 | |
Magnus Damm | f7dadb3 | 2011-12-23 01:23:07 +0100 | [diff] [blame] | 94 | /* SYSC power down */ |
Magnus Damm | cf33835 | 2011-09-25 23:20:49 +0200 | [diff] [blame] | 95 | ldr r0, =SPDCR |
Magnus Damm | f7dadb3 | 2011-12-23 01:23:07 +0100 | [diff] [blame] | 96 | str r8, [r0] |
Magnus Damm | cf33835 | 2011-09-25 23:20:49 +0200 | [diff] [blame] | 97 | 1: |
| 98 | b 1b |
| 99 | |
Tetsuyuki Kobayashi | 0b933cb | 2013-07-10 10:56:37 +0900 | [diff] [blame] | 100 | .align 2 |
Magnus Damm | cf33835 | 2011-09-25 23:20:49 +0200 | [diff] [blame] | 101 | kernel_flush: |
| 102 | .word v7_flush_dcache_all |
Magnus Damm | a0089bd | 2011-09-25 23:21:02 +0200 | [diff] [blame] | 103 | #endif |