Stephan Gerhold | 4f1170f | 2020-01-04 18:45:17 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | /* |
| 3 | * Copyright (C) 2019 Stephan Gerhold <stephan@gerhold.net> |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <cpu_func.h> |
| 8 | #include <asm/armv7.h> |
| 9 | #include <asm/pl310.h> |
| 10 | |
| 11 | #define PL310_WAY_MASK 0xff |
| 12 | |
| 13 | #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) |
| 14 | void enable_caches(void) |
| 15 | { |
| 16 | /* Enable D-cache. I-cache is already enabled in start.S */ |
| 17 | dcache_enable(); |
| 18 | } |
| 19 | #endif |
| 20 | |
| 21 | #ifdef CONFIG_SYS_L2_PL310 |
| 22 | void v7_outer_cache_disable(void) |
| 23 | { |
| 24 | struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE; |
| 25 | |
| 26 | /* |
| 27 | * Linux expects the L2 cache to be turned off by the bootloader. |
| 28 | * Otherwise, it fails very early (shortly after decompressing the kernel). |
| 29 | * |
| 30 | * On U8500, the L2 cache can be only turned on/off from the secure world. |
| 31 | * Instead, prevent usage of the L2 cache by locking all ways. |
| 32 | * The kernel needs to unlock them to make the L2 cache work again. |
| 33 | */ |
| 34 | writel(PL310_WAY_MASK, &pl310->pl310_lockdown_dbase); |
| 35 | writel(PL310_WAY_MASK, &pl310->pl310_lockdown_ibase); |
| 36 | } |
| 37 | #endif |