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 __weak void noncached_set_region(void)
27 static int do_icache(struct cmd_tbl *cmdtp, int flag, int argc,
31 case 2: /* on / off / flush */
32 switch (parse_argv(argv[1])) {
40 invalidate_icache_all();
46 case 1: /* get status */
47 printf("Instruction Cache is %s\n",
48 icache_status() ? "ON" : "OFF");
56 void __weak flush_dcache_all(void)
58 puts("No arch specific flush_dcache_all available!\n");
59 /* please define arch specific flush_dcache_all */
62 static int do_dcache(struct cmd_tbl *cmdtp, int flag, int argc,
66 case 2: /* on / off / flush */
67 switch (parse_argv(argv[1])) {
73 noncached_set_region();
82 case 1: /* get status */
83 printf("Data (writethrough) Cache is %s\n",
84 dcache_status() ? "ON" : "OFF");
92 static int parse_argv(const char *s)
94 if (strcmp(s, "flush") == 0)
96 else if (strcmp(s, "on") == 0)
98 else if (strcmp(s, "off") == 0)
106 icache, 2, 1, do_icache,
107 "enable or disable instruction cache",
109 " - enable, disable, or flush instruction cache"
113 dcache, 2, 1, do_dcache,
114 "enable or disable data cache",
116 " - enable, disable, or flush data (writethrough) cache"