blob: 31abd6989689bad82c7753609c7f2be58298f8ec [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001/*
2 * Copyright (C) 2000 Murray Jensen <Murray.Jensen@cmst.csiro.au>
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
wdenkfe8c2802002-11-03 00:38:21 +00005 */
6
7#include <config.h>
8#include <command.h>
Stefan Roeseb36df562010-09-09 19:18:00 +02009#include <asm/ppc4xx.h>
wdenkfe8c2802002-11-03 00:38:21 +000010
11#define CONFIG_405GP 1 /* needed for Linux kernel header files */
wdenkfe8c2802002-11-03 00:38:21 +000012
13#include <ppc_asm.tmpl>
14#include <ppc_defs.h>
15
16#include <asm/cache.h>
17#include <asm/mmu.h>
18
Jon Loeliger3a1ed1e2007-07-09 18:57:22 -050019#if defined(CONFIG_CMD_KGDB)
wdenkfe8c2802002-11-03 00:38:21 +000020 /*
21 * cache flushing routines for kgdb
22 */
23
24 .globl kgdb_flush_cache_all
25kgdb_flush_cache_all:
26 /* icache */
27 iccci r0,r0 /* iccci invalidates the entire I cache */
28 /* dcache */
29 addi r6,0,0x0000 /* clear GPR 6 */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020030 addi r7,r0, 128 /* do loop for # of dcache lines */
wdenkfe8c2802002-11-03 00:38:21 +000031 /* NOTE: dccci invalidates both */
wdenk8bde7f72003-06-27 21:31:46 +000032 mtctr r7 /* ways in the D cache */
wdenkfe8c2802002-11-03 00:38:21 +000033..dcloop:
wdenk8bde7f72003-06-27 21:31:46 +000034 dccci 0,r6 /* invalidate line */
35 addi r6,r6, 32 /* bump to next line */
36 bdnz ..dcloop
wdenkfe8c2802002-11-03 00:38:21 +000037 blr
38
39 .globl kgdb_flush_cache_range
40kgdb_flush_cache_range:
Stefan Roese9b94ac62007-10-31 17:55:58 +010041 li r5,L1_CACHE_BYTES-1
wdenkfe8c2802002-11-03 00:38:21 +000042 andc r3,r3,r5
43 subf r4,r3,r4
44 add r4,r4,r5
Stefan Roese9b94ac62007-10-31 17:55:58 +010045 srwi. r4,r4,L1_CACHE_SHIFT
wdenkfe8c2802002-11-03 00:38:21 +000046 beqlr
47 mtctr r4
48 mr r6,r3
491: dcbst 0,r3
Stefan Roese9b94ac62007-10-31 17:55:58 +010050 addi r3,r3,L1_CACHE_BYTES
wdenkfe8c2802002-11-03 00:38:21 +000051 bdnz 1b
52 sync /* wait for dcbst's to get to ram */
53 mtctr r4
542: icbi 0,r6
Stefan Roese9b94ac62007-10-31 17:55:58 +010055 addi r6,r6,L1_CACHE_BYTES
wdenkfe8c2802002-11-03 00:38:21 +000056 bdnz 2b
57 SYNC
58 blr
59
Jon Loeliger068b60a2007-07-10 10:27:39 -050060#endif