blob: 7541b567d0fd0fb0cbd3cf4721ec61d180188e09 [file] [log] [blame]
Stephan Gerhold4f1170f2020-01-04 18:45:17 +01001// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (C) 2019 Stephan Gerhold <stephan@gerhold.net>
4 */
5
Tom Rinidec7ea02024-05-20 13:35:03 -06006#include <config.h>
Stephan Gerhold4f1170f2020-01-04 18:45:17 +01007#include <cpu_func.h>
8#include <asm/armv7.h>
Simon Glass274e0b02020-05-10 11:39:56 -06009#include <asm/cache.h>
Stephan Gerhold4f1170f2020-01-04 18:45:17 +010010#include <asm/pl310.h>
11
12#define PL310_WAY_MASK 0xff
13
14#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
15void enable_caches(void)
16{
17 /* Enable D-cache. I-cache is already enabled in start.S */
18 dcache_enable();
19}
20#endif
21
22#ifdef CONFIG_SYS_L2_PL310
23void v7_outer_cache_disable(void)
24{
Tom Rini6a5dccc2022-11-16 13:10:41 -050025 struct pl310_regs *const pl310 = (struct pl310_regs *)CFG_SYS_PL310_BASE;
Stephan Gerhold4f1170f2020-01-04 18:45:17 +010026
27 /*
28 * Linux expects the L2 cache to be turned off by the bootloader.
29 * Otherwise, it fails very early (shortly after decompressing the kernel).
30 *
31 * On U8500, the L2 cache can be only turned on/off from the secure world.
32 * Instead, prevent usage of the L2 cache by locking all ways.
33 * The kernel needs to unlock them to make the L2 cache work again.
34 */
35 writel(PL310_WAY_MASK, &pl310->pl310_lockdown_dbase);
36 writel(PL310_WAY_MASK, &pl310->pl310_lockdown_ibase);
37}
38#endif