1 // SPDX-License-Identifier: GPL-2.0+
8 * Cache support: switch on or off, get status
12 #include <linux/compiler.h>
14 static int parse_argv(const char *);
16 void __weak invalidate_icache_all(void)
18 /* please define arch specific invalidate_icache_all */
19 puts("No arch specific invalidate_icache_all available!\n");
22 __weak void noncached_set_region(void)
26 static int do_icache(struct cmd_tbl *cmdtp, int flag, int argc,
30 case 2: /* on / off / flush */
31 switch (parse_argv(argv[1])) {
39 invalidate_icache_all();
45 case 1: /* get status */
46 printf("Instruction Cache is %s\n",
47 icache_status() ? "ON" : "OFF");
55 void __weak flush_dcache_all(void)
57 puts("No arch specific flush_dcache_all available!\n");
58 /* please define arch specific flush_dcache_all */
61 static int do_dcache(struct cmd_tbl *cmdtp, int flag, int argc,
65 case 2: /* on / off / flush */
66 switch (parse_argv(argv[1])) {
72 noncached_set_region();
81 case 1: /* get status */
82 printf("Data (writethrough) Cache is %s\n",
83 dcache_status() ? "ON" : "OFF");
91 static int parse_argv(const char *s)
93 if (strcmp(s, "flush") == 0)
95 else if (strcmp(s, "on") == 0)
97 else if (strcmp(s, "off") == 0)
105 icache, 2, 1, do_icache,
106 "enable or disable instruction cache",
108 " - enable, disable, or flush instruction cache"
112 dcache, 2, 1, do_dcache,
113 "enable or disable data cache",
115 " - enable, disable, or flush data (writethrough) cache"