1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 * Cache support: switch on or off, get status
13 #include <linux/compiler.h>
15 static int parse_argv(const char *);
17 void __weak invalidate_icache_all(void)
19 /* please define arch specific invalidate_icache_all */
20 puts("No arch specific invalidate_icache_all available!\n");
23 static int do_icache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
26 case 2: /* on / off / flush */
27 switch (parse_argv(argv[1])) {
35 invalidate_icache_all();
41 case 1: /* get status */
42 printf("Instruction Cache is %s\n",
43 icache_status() ? "ON" : "OFF");
51 void __weak flush_dcache_all(void)
53 puts("No arch specific flush_dcache_all available!\n");
54 /* please define arch specific flush_dcache_all */
57 static int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
60 case 2: /* on / off / flush */
61 switch (parse_argv(argv[1])) {
75 case 1: /* get status */
76 printf("Data (writethrough) Cache is %s\n",
77 dcache_status() ? "ON" : "OFF");
85 static int parse_argv(const char *s)
87 if (strcmp(s, "flush") == 0)
89 else if (strcmp(s, "on") == 0)
91 else if (strcmp(s, "off") == 0)
99 icache, 2, 1, do_icache,
100 "enable or disable instruction cache",
102 " - enable, disable, or flush instruction cache"
106 dcache, 2, 1, do_dcache,
107 "enable or disable data cache",
109 " - enable, disable, or flush data (writethrough) cache"