blob: 53f4840e494914526b4ab23fa09b7a19473c4476 [file] [log] [blame]
Magnus Damm97991652011-04-29 02:28:08 +09001/*
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 Damm06b84162011-09-25 23:18:42 +020033#include <linux/init.h>
34#include <asm/memory.h>
Magnus Damm97991652011-04-29 02:28:08 +090035#include <asm/assembler.h>
36
Magnus Damma0089bd62011-09-25 23:21:02 +020037#if defined(CONFIG_SUSPEND) || defined(CONFIG_CPU_IDLE)
Magnus Damm97991652011-04-29 02:28:08 +090038 .align 12
39 .text
Magnus Dammf7dadb32011-12-23 01:23:07 +010040 .global sh7372_resume_core_standby_sysc
41sh7372_resume_core_standby_sysc:
Magnus Damm06b84162011-09-25 23:18:42 +020042 ldr pc, 1f
Magnus Damme26f4062013-06-05 16:45:53 +090043
44 .globl sh7372_cpu_resume
45sh7372_cpu_resume:
461: .space 4
Magnus Dammcf338352011-09-25 23:20:49 +020047
Magnus Dammf7dadb32011-12-23 01:23:07 +010048#define SPDCR 0xe6180008
49
50 /* A3SM & A4S power down */
51 .global sh7372_do_idle_sysc
52sh7372_do_idle_sysc:
53 mov r8, r0 /* sleep mode passed in r0 */
54
Magnus Dammcf338352011-09-25 23:20:49 +020055 /*
56 * Clear the SCTLR.C bit to prevent further data cache
57 * allocation. Clearing SCTLR.C would make all the data accesses
58 * strongly ordered and would not hit the cache.
59 */
60 mrc p15, 0, r0, c1, c0, 0
61 bic r0, r0, #(1 << 2) @ Disable the C bit
62 mcr p15, 0, r0, c1, c0, 0
63 isb
64
Guennadi Liakhovetski99161522012-12-28 12:32:54 +010065 /*
66 * Clean and invalidate data cache again.
67 */
68 ldr r1, kernel_flush
69 blx r1
70
Magnus Dammcf338352011-09-25 23:20:49 +020071 /* disable L2 cache in the aux control register */
72 mrc p15, 0, r10, c1, c0, 1
73 bic r10, r10, #2
74 mcr p15, 0, r10, c1, c0, 1
Guennadi Liakhovetski99161522012-12-28 12:32:54 +010075 isb
Magnus Dammcf338352011-09-25 23:20:49 +020076
77 /*
Magnus Dammcf338352011-09-25 23:20:49 +020078 * The kernel doesn't interwork: v7_flush_dcache_all in particluar will
79 * always return in Thumb state when CONFIG_THUMB2_KERNEL is enabled.
80 * This sequence switches back to ARM. Note that .align may insert a
81 * nop: bx pc needs to be word-aligned in order to work.
82 */
83 THUMB( .thumb )
84 THUMB( .align )
85 THUMB( bx pc )
86 THUMB( nop )
87 .arm
88
89 /* Data memory barrier and Data sync barrier */
90 dsb
91 dmb
92
Magnus Dammf7dadb32011-12-23 01:23:07 +010093 /* SYSC power down */
Magnus Dammcf338352011-09-25 23:20:49 +020094 ldr r0, =SPDCR
Magnus Dammf7dadb32011-12-23 01:23:07 +010095 str r8, [r0]
Magnus Dammcf338352011-09-25 23:20:49 +0200961:
97 b 1b
98
99kernel_flush:
100 .word v7_flush_dcache_all
Magnus Damma0089bd62011-09-25 23:21:02 +0200101#endif