xref: /linux/arch/arm/mach-exynos/sleep.S (revision 0898782247ae533d1f4e47a06bc5d4870931b284)
1347863d4SKrzysztof Kozlowski/* SPDX-License-Identifier: GPL-2.0+ */
2d710aa31STomasz Figa/*
3d710aa31STomasz Figa * Copyright (c) 2013 Samsung Electronics Co., Ltd.
4d710aa31STomasz Figa *		http://www.samsung.com
5d710aa31STomasz Figa *
6d710aa31STomasz Figa * Exynos low-level resume code
7d710aa31STomasz Figa */
8d710aa31STomasz Figa
9d710aa31STomasz Figa#include <linux/linkage.h>
1030ad527aSTomasz Figa#include <asm/asm-offsets.h>
1130ad527aSTomasz Figa#include <asm/hardware/cache-l2x0.h>
122b9d9c32STomasz Figa#include "smc.h"
13d710aa31STomasz Figa
14d710aa31STomasz Figa#define CPU_MASK	0xff0ffff0
15d710aa31STomasz Figa#define CPU_CORTEX_A9	0x410fc090
16d710aa31STomasz Figa
1712833bacSArd Biesheuvel	.text
18d710aa31STomasz Figa	.align
19d710aa31STomasz Figa
20d710aa31STomasz Figa	/*
21d710aa31STomasz Figa	 * sleep magic, to allow the bootloader to check for an valid
22d710aa31STomasz Figa	 * image to resume to. Must be the first word before the
23d710aa31STomasz Figa	 * exynos_cpu_resume entry.
24d710aa31STomasz Figa	 */
25d710aa31STomasz Figa
26d710aa31STomasz Figa	.word	0x2bedf00d
27d710aa31STomasz Figa
28d710aa31STomasz Figa	/*
29d710aa31STomasz Figa	 * exynos_cpu_resume
30d710aa31STomasz Figa	 *
31d710aa31STomasz Figa	 * resume code entry for bootloader to call
32d710aa31STomasz Figa	 */
33d710aa31STomasz Figa
34d710aa31STomasz FigaENTRY(exynos_cpu_resume)
35d710aa31STomasz Figa#ifdef CONFIG_CACHE_L2X0
36d710aa31STomasz Figa	mrc	p15, 0, r0, c0, c0, 0
37d710aa31STomasz Figa	ldr	r1, =CPU_MASK
38d710aa31STomasz Figa	and	r0, r0, r1
39d710aa31STomasz Figa	ldr	r1, =CPU_CORTEX_A9
40d710aa31STomasz Figa	cmp	r0, r1
4125a9ef63SRussell King	bleq	l2c310_early_resume
42d710aa31STomasz Figa#endif
43d710aa31STomasz Figa	b	cpu_resume
44d710aa31STomasz FigaENDPROC(exynos_cpu_resume)
452b9d9c32STomasz Figa
462b9d9c32STomasz Figa	.align
47*3fe1ee40SStefan Agner	.arch armv7-a
48*3fe1ee40SStefan Agner	.arch_extension sec
492b9d9c32STomasz FigaENTRY(exynos_cpu_resume_ns)
502b9d9c32STomasz Figa	mrc	p15, 0, r0, c0, c0, 0
512b9d9c32STomasz Figa	ldr	r1, =CPU_MASK
522b9d9c32STomasz Figa	and	r0, r0, r1
532b9d9c32STomasz Figa	ldr	r1, =CPU_CORTEX_A9
542b9d9c32STomasz Figa	cmp	r0, r1
552b9d9c32STomasz Figa	bne	skip_cp15
562b9d9c32STomasz Figa
5712833bacSArd Biesheuvel	adr	r0, _cp15_save_power
582b9d9c32STomasz Figa	ldr	r1, [r0]
5912833bacSArd Biesheuvel	ldr	r1, [r0, r1]
6012833bacSArd Biesheuvel	adr	r0, _cp15_save_diag
612b9d9c32STomasz Figa	ldr	r2, [r0]
6212833bacSArd Biesheuvel	ldr	r2, [r0, r2]
632b9d9c32STomasz Figa	mov	r0, #SMC_CMD_C15RESUME
642b9d9c32STomasz Figa	dsb
652b9d9c32STomasz Figa	smc	#0
6630ad527aSTomasz Figa#ifdef CONFIG_CACHE_L2X0
6730ad527aSTomasz Figa	adr	r0, 1f
6830ad527aSTomasz Figa	ldr	r2, [r0]
6930ad527aSTomasz Figa	add	r0, r2, r0
7030ad527aSTomasz Figa
7130ad527aSTomasz Figa	/* Check that the address has been initialised. */
7230ad527aSTomasz Figa	ldr	r1, [r0, #L2X0_R_PHY_BASE]
7330ad527aSTomasz Figa	teq	r1, #0
7430ad527aSTomasz Figa	beq	skip_l2x0
7530ad527aSTomasz Figa
7630ad527aSTomasz Figa	/* Check if controller has been enabled. */
7730ad527aSTomasz Figa	ldr	r2, [r1, #L2X0_CTRL]
7830ad527aSTomasz Figa	tst	r2, #0x1
7930ad527aSTomasz Figa	bne	skip_l2x0
8030ad527aSTomasz Figa
8130ad527aSTomasz Figa	ldr	r1, [r0, #L2X0_R_TAG_LATENCY]
8230ad527aSTomasz Figa	ldr	r2, [r0, #L2X0_R_DATA_LATENCY]
8330ad527aSTomasz Figa	ldr	r3, [r0, #L2X0_R_PREFETCH_CTRL]
8430ad527aSTomasz Figa	mov	r0, #SMC_CMD_L2X0SETUP1
8530ad527aSTomasz Figa	smc	#0
8630ad527aSTomasz Figa
8730ad527aSTomasz Figa	/* Reload saved regs pointer because smc corrupts registers. */
8830ad527aSTomasz Figa	adr	r0, 1f
8930ad527aSTomasz Figa	ldr	r2, [r0]
9030ad527aSTomasz Figa	add	r0, r2, r0
9130ad527aSTomasz Figa
9230ad527aSTomasz Figa	ldr	r1, [r0, #L2X0_R_PWR_CTRL]
9330ad527aSTomasz Figa	ldr	r2, [r0, #L2X0_R_AUX_CTRL]
9430ad527aSTomasz Figa	mov	r0, #SMC_CMD_L2X0SETUP2
9530ad527aSTomasz Figa	smc	#0
9630ad527aSTomasz Figa
9730ad527aSTomasz Figa	mov	r0, #SMC_CMD_L2X0INVALL
9830ad527aSTomasz Figa	smc	#0
9930ad527aSTomasz Figa
10030ad527aSTomasz Figa	mov	r1, #1
10130ad527aSTomasz Figa	mov	r0, #SMC_CMD_L2X0CTRL
10230ad527aSTomasz Figa	smc	#0
10330ad527aSTomasz Figaskip_l2x0:
10430ad527aSTomasz Figa#endif /* CONFIG_CACHE_L2X0 */
1052b9d9c32STomasz Figaskip_cp15:
1062b9d9c32STomasz Figa	b	cpu_resume
1072b9d9c32STomasz FigaENDPROC(exynos_cpu_resume_ns)
10812833bacSArd Biesheuvel
10912833bacSArd Biesheuvel	.align
11012833bacSArd Biesheuvel_cp15_save_power:
11112833bacSArd Biesheuvel	.long	cp15_save_power - .
11212833bacSArd Biesheuvel_cp15_save_diag:
11312833bacSArd Biesheuvel	.long	cp15_save_diag - .
11412833bacSArd Biesheuvel#ifdef CONFIG_CACHE_L2X0
11512833bacSArd Biesheuvel1:	.long	l2x0_saved_regs - .
11612833bacSArd Biesheuvel#endif /* CONFIG_CACHE_L2X0 */
11712833bacSArd Biesheuvel
11812833bacSArd Biesheuvel	.data
1191abd3502SRussell King	.align	2
1202b9d9c32STomasz Figa	.globl cp15_save_diag
1212b9d9c32STomasz Figacp15_save_diag:
1222b9d9c32STomasz Figa	.long	0	@ cp15 diagnostic
1232b9d9c32STomasz Figa	.globl cp15_save_power
1242b9d9c32STomasz Figacp15_save_power:
1252b9d9c32STomasz Figa	.long	0	@ cp15 power control
126