blob: f274c5d564dfafc4583817bac6437d91181635de [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#include <version.h>
11
12#define CONFIG_405GP 1 /* needed for Linux kernel header files */
wdenkfe8c2802002-11-03 00:38:21 +000013
14#include <ppc_asm.tmpl>
15#include <ppc_defs.h>
16
17#include <asm/cache.h>
18#include <asm/mmu.h>
19
Jon Loeliger3a1ed1e2007-07-09 18:57:22 -050020#if defined(CONFIG_CMD_KGDB)
wdenkfe8c2802002-11-03 00:38:21 +000021 /*
22 * cache flushing routines for kgdb
23 */
24
25 .globl kgdb_flush_cache_all
26kgdb_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 Denk53677ef2008-05-20 16:00:29 +020031 addi r7,r0, 128 /* do loop for # of dcache lines */
wdenkfe8c2802002-11-03 00:38:21 +000032 /* NOTE: dccci invalidates both */
wdenk8bde7f72003-06-27 21:31:46 +000033 mtctr r7 /* ways in the D cache */
wdenkfe8c2802002-11-03 00:38:21 +000034..dcloop:
wdenk8bde7f72003-06-27 21:31:46 +000035 dccci 0,r6 /* invalidate line */
36 addi r6,r6, 32 /* bump to next line */
37 bdnz ..dcloop
wdenkfe8c2802002-11-03 00:38:21 +000038 blr
39
40 .globl kgdb_flush_cache_range
41kgdb_flush_cache_range:
Stefan Roese9b94ac62007-10-31 17:55:58 +010042 li r5,L1_CACHE_BYTES-1
wdenkfe8c2802002-11-03 00:38:21 +000043 andc r3,r3,r5
44 subf r4,r3,r4
45 add r4,r4,r5
Stefan Roese9b94ac62007-10-31 17:55:58 +010046 srwi. r4,r4,L1_CACHE_SHIFT
wdenkfe8c2802002-11-03 00:38:21 +000047 beqlr
48 mtctr r4
49 mr r6,r3
501: dcbst 0,r3
Stefan Roese9b94ac62007-10-31 17:55:58 +010051 addi r3,r3,L1_CACHE_BYTES
wdenkfe8c2802002-11-03 00:38:21 +000052 bdnz 1b
53 sync /* wait for dcbst's to get to ram */
54 mtctr r4
552: icbi 0,r6
Stefan Roese9b94ac62007-10-31 17:55:58 +010056 addi r6,r6,L1_CACHE_BYTES
wdenkfe8c2802002-11-03 00:38:21 +000057 bdnz 2b
58 SYNC
59 blr
60
Jon Loeliger068b60a2007-07-10 10:27:39 -050061#endif