Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Christophe Leroy | 0ae15b9 | 2017-07-13 15:10:00 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2017 |
| 4 | * Christophe Leroy, CS Systemes d'Information, christophe.leroy@c-s.fr |
Christophe Leroy | 0ae15b9 | 2017-07-13 15:10:00 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 1d91ba7 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 8 | #include <cpu_func.h> |
Christophe Leroy | 0ae15b9 | 2017-07-13 15:10:00 +0200 | [diff] [blame] | 9 | #include <asm/processor.h> |
| 10 | #include <asm/ppc.h> |
| 11 | #include <asm/io.h> |
| 12 | #include <asm/mmu.h> |
| 13 | |
| 14 | int icache_status(void) |
| 15 | { |
| 16 | return !!(mfspr(IC_CST) & IDC_ENABLED); |
| 17 | } |
| 18 | |
| 19 | void icache_enable(void) |
| 20 | { |
| 21 | sync(); |
| 22 | mtspr(IC_CST, IDC_INVALL); |
| 23 | mtspr(IC_CST, IDC_ENABLE); |
| 24 | } |
| 25 | |
| 26 | void icache_disable(void) |
| 27 | { |
| 28 | sync(); |
| 29 | mtspr(IC_CST, IDC_DISABLE); |
| 30 | } |
| 31 | |
| 32 | int dcache_status(void) |
| 33 | { |
| 34 | return !!(mfspr(IC_CST) & IDC_ENABLED); |
| 35 | } |
| 36 | |
| 37 | void dcache_enable(void) |
| 38 | { |
| 39 | mtspr(MD_CTR, MD_RESETVAL); /* Set cache mode with MMU off */ |
| 40 | mtspr(DC_CST, IDC_INVALL); |
| 41 | mtspr(DC_CST, IDC_ENABLE); |
| 42 | } |
| 43 | |
| 44 | void dcache_disable(void) |
| 45 | { |
| 46 | sync(); |
| 47 | mtspr(DC_CST, IDC_DISABLE); |
| 48 | mtspr(DC_CST, IDC_INVALL); |
| 49 | } |