wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2000 Murray Jensen <Murray.Jensen@cmst.csiro.au> |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <config.h> |
| 8 | #include <command.h> |
Stefan Roese | 247e9d7 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 9 | #include <asm/ppc4xx.h> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 10 | #include <version.h> |
| 11 | |
| 12 | #define CONFIG_405GP 1 /* needed for Linux kernel header files */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 13 | |
| 14 | #include <ppc_asm.tmpl> |
| 15 | #include <ppc_defs.h> |
| 16 | |
| 17 | #include <asm/cache.h> |
| 18 | #include <asm/mmu.h> |
| 19 | |
Jon Loeliger | a521774 | 2007-07-09 18:57:22 -0500 | [diff] [blame] | 20 | #if defined(CONFIG_CMD_KGDB) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 21 | /* |
| 22 | * cache flushing routines for kgdb |
| 23 | */ |
| 24 | |
| 25 | .globl kgdb_flush_cache_all |
| 26 | kgdb_flush_cache_all: |
| 27 | /* icache */ |
| 28 | iccci r0,r0 /* iccci invalidates the entire I cache */ |
| 29 | /* dcache */ |
| 30 | addi r6,0,0x0000 /* clear GPR 6 */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 31 | addi r7,r0, 128 /* do loop for # of dcache lines */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 32 | /* NOTE: dccci invalidates both */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 33 | mtctr r7 /* ways in the D cache */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 34 | ..dcloop: |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 35 | dccci 0,r6 /* invalidate line */ |
| 36 | addi r6,r6, 32 /* bump to next line */ |
| 37 | bdnz ..dcloop |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 38 | blr |
| 39 | |
| 40 | .globl kgdb_flush_cache_range |
| 41 | kgdb_flush_cache_range: |
Stefan Roese | eff3a0a | 2007-10-31 17:55:58 +0100 | [diff] [blame] | 42 | li r5,L1_CACHE_BYTES-1 |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 43 | andc r3,r3,r5 |
| 44 | subf r4,r3,r4 |
| 45 | add r4,r4,r5 |
Stefan Roese | eff3a0a | 2007-10-31 17:55:58 +0100 | [diff] [blame] | 46 | srwi. r4,r4,L1_CACHE_SHIFT |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 47 | beqlr |
| 48 | mtctr r4 |
| 49 | mr r6,r3 |
| 50 | 1: dcbst 0,r3 |
Stefan Roese | eff3a0a | 2007-10-31 17:55:58 +0100 | [diff] [blame] | 51 | addi r3,r3,L1_CACHE_BYTES |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 52 | bdnz 1b |
| 53 | sync /* wait for dcbst's to get to ram */ |
| 54 | mtctr r4 |
| 55 | 2: icbi 0,r6 |
Stefan Roese | eff3a0a | 2007-10-31 17:55:58 +0100 | [diff] [blame] | 56 | addi r6,r6,L1_CACHE_BYTES |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 57 | bdnz 2b |
| 58 | SYNC |
| 59 | blr |
| 60 | |
Jon Loeliger | 07efe2a | 2007-07-10 10:27:39 -0500 | [diff] [blame] | 61 | #endif |