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(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
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(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
64 case 2: /* on / off / flush */
65 switch (parse_argv(argv[1])) {
71 noncached_set_region();
80 case 1: /* get status */
81 printf("Data (writethrough) Cache is %s\n",
82 dcache_status() ? "ON" : "OFF");
90 static int parse_argv(const char *s)
92 if (strcmp(s, "flush") == 0)
94 else if (strcmp(s, "on") == 0)
96 else if (strcmp(s, "off") == 0)
104 icache, 2, 1, do_icache,
105 "enable or disable instruction cache",
107 " - enable, disable, or flush instruction cache"
111 dcache, 2, 1, do_dcache,
112 "enable or disable data cache",
114 " - enable, disable, or flush data (writethrough) cache"