3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 * 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 */
27 switch (parse_argv(argv[1])) {
35 invalidate_icache_all();
39 case 1: /* get status */
40 printf("Instruction Cache is %s\n",
41 icache_status() ? "ON" : "OFF");
49 void __weak flush_dcache_all(void)
51 puts("No arch specific flush_dcache_all available!\n");
52 /* please define arch specific flush_dcache_all */
55 static int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
58 case 2: /* on / off */
59 switch (parse_argv(argv[1])) {
71 case 1: /* get status */
72 printf("Data (writethrough) Cache is %s\n",
73 dcache_status() ? "ON" : "OFF");
81 static int parse_argv(const char *s)
83 if (strcmp(s, "flush") == 0)
85 else if (strcmp(s, "on") == 0)
87 else if (strcmp(s, "off") == 0)
95 icache, 2, 1, do_icache,
96 "enable or disable instruction cache",
98 " - enable, disable, or flush instruction cache"
102 dcache, 2, 1, do_dcache,
103 "enable or disable data cache",
105 " - enable, disable, or flush data (writethrough) cache"