blob: dbc4a6c8812dacbe41841e267d7679cdc302c231 [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001/*
2 * Copyright (C) 2000 Murray Jensen <Murray.Jensen@cmst.csiro.au>
3 *
Wolfgang Denkd79de1d2013-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 Roese247e9d72010-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 */
13#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
14
15#include <ppc_asm.tmpl>
16#include <ppc_defs.h>
17
18#include <asm/cache.h>
19#include <asm/mmu.h>
20
Jon Loeligera5217742007-07-09 18:57:22 -050021#if defined(CONFIG_CMD_KGDB)
wdenkfe8c2802002-11-03 00:38:21 +000022 /*
23 * cache flushing routines for kgdb
24 */
25
26 .globl kgdb_flush_cache_all
27kgdb_flush_cache_all:
28 /* icache */
29 iccci r0,r0 /* iccci invalidates the entire I cache */
30 /* dcache */
31 addi r6,0,0x0000 /* clear GPR 6 */
Wolfgang Denka1be4762008-05-20 16:00:29 +020032 addi r7,r0, 128 /* do loop for # of dcache lines */
wdenkfe8c2802002-11-03 00:38:21 +000033 /* NOTE: dccci invalidates both */
wdenk57b2d802003-06-27 21:31:46 +000034 mtctr r7 /* ways in the D cache */
wdenkfe8c2802002-11-03 00:38:21 +000035..dcloop:
wdenk57b2d802003-06-27 21:31:46 +000036 dccci 0,r6 /* invalidate line */
37 addi r6,r6, 32 /* bump to next line */
38 bdnz ..dcloop
wdenkfe8c2802002-11-03 00:38:21 +000039 blr
40
41 .globl kgdb_flush_cache_range
42kgdb_flush_cache_range:
Stefan Roeseeff3a0a2007-10-31 17:55:58 +010043 li r5,L1_CACHE_BYTES-1
wdenkfe8c2802002-11-03 00:38:21 +000044 andc r3,r3,r5
45 subf r4,r3,r4
46 add r4,r4,r5
Stefan Roeseeff3a0a2007-10-31 17:55:58 +010047 srwi. r4,r4,L1_CACHE_SHIFT
wdenkfe8c2802002-11-03 00:38:21 +000048 beqlr
49 mtctr r4
50 mr r6,r3
511: dcbst 0,r3
Stefan Roeseeff3a0a2007-10-31 17:55:58 +010052 addi r3,r3,L1_CACHE_BYTES
wdenkfe8c2802002-11-03 00:38:21 +000053 bdnz 1b
54 sync /* wait for dcbst's to get to ram */
55 mtctr r4
562: icbi 0,r6
Stefan Roeseeff3a0a2007-10-31 17:55:58 +010057 addi r6,r6,L1_CACHE_BYTES
wdenkfe8c2802002-11-03 00:38:21 +000058 bdnz 2b
59 SYNC
60 blr
61
Jon Loeliger07efe2a2007-07-10 10:27:39 -050062#endif