xref: /openbmc/linux/arch/arm/mm/l2c-l2x0-resume.S (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */
2de7e7532SRussell King/*
3de7e7532SRussell King * L2C-310 early resume code.  This can be used by platforms to restore
4de7e7532SRussell King * the settings of their L2 cache controller before restoring the
5de7e7532SRussell King * processor state.
6de7e7532SRussell King *
7de7e7532SRussell King * This code can only be used to if you are running in the secure world.
8de7e7532SRussell King */
9de7e7532SRussell King#include <linux/linkage.h>
106ebbf2ceSRussell King#include <asm/assembler.h>
11de7e7532SRussell King#include <asm/hardware/cache-l2x0.h>
12de7e7532SRussell King
13de7e7532SRussell King	.text
14de7e7532SRussell King
15de7e7532SRussell KingENTRY(l2c310_early_resume)
16de7e7532SRussell King	adr	r0, 1f
17de7e7532SRussell King	ldr	r2, [r0]
18de7e7532SRussell King	add	r0, r2, r0
19de7e7532SRussell King
20de7e7532SRussell King	ldmia	r0, {r1, r2, r3, r4, r5, r6, r7, r8}
21de7e7532SRussell King	@ r1 = phys address of L2C-310 controller
22de7e7532SRussell King	@ r2 = aux_ctrl
23de7e7532SRussell King	@ r3 = tag_latency
24de7e7532SRussell King	@ r4 = data_latency
25de7e7532SRussell King	@ r5 = filter_start
26de7e7532SRussell King	@ r6 = filter_end
27de7e7532SRussell King	@ r7 = prefetch_ctrl
28de7e7532SRussell King	@ r8 = pwr_ctrl
29de7e7532SRussell King
30de7e7532SRussell King	@ Check that the address has been initialised
31de7e7532SRussell King	teq	r1, #0
326ebbf2ceSRussell King	reteq	lr
33de7e7532SRussell King
34de7e7532SRussell King	@ The prefetch and power control registers are revision dependent
35de7e7532SRussell King	@ and can be written whether or not the L2 cache is enabled
36de7e7532SRussell King	ldr	r0, [r1, #L2X0_CACHE_ID]
37de7e7532SRussell King	and	r0, r0, #L2X0_CACHE_ID_RTL_MASK
38de7e7532SRussell King	cmp	r0, #L310_CACHE_ID_RTL_R2P0
39de7e7532SRussell King	strcs	r7, [r1, #L310_PREFETCH_CTRL]
40de7e7532SRussell King	cmp	r0, #L310_CACHE_ID_RTL_R3P0
41de7e7532SRussell King	strcs	r8, [r1, #L310_POWER_CTRL]
42de7e7532SRussell King
43de7e7532SRussell King	@ Don't setup the L2 cache if it is already enabled
44de7e7532SRussell King	ldr	r0, [r1, #L2X0_CTRL]
45de7e7532SRussell King	tst	r0, #L2X0_CTRL_EN
466ebbf2ceSRussell King	retne	lr
47de7e7532SRussell King
48de7e7532SRussell King	str	r3, [r1, #L310_TAG_LATENCY_CTRL]
49de7e7532SRussell King	str	r4, [r1, #L310_DATA_LATENCY_CTRL]
50de7e7532SRussell King	str	r6, [r1, #L310_ADDR_FILTER_END]
51de7e7532SRussell King	str	r5, [r1, #L310_ADDR_FILTER_START]
52de7e7532SRussell King
53de7e7532SRussell King	str	r2, [r1, #L2X0_AUX_CTRL]
54de7e7532SRussell King	mov	r9, #L2X0_CTRL_EN
55de7e7532SRussell King	str	r9, [r1, #L2X0_CTRL]
566ebbf2ceSRussell King	ret	lr
57de7e7532SRussell KingENDPROC(l2c310_early_resume)
58de7e7532SRussell King
59de7e7532SRussell King	.align
60de7e7532SRussell King1:	.long	l2x0_saved_regs - .
61