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
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 static int do_icache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
25 case 2: /* on / off */
26 switch (parse_argv(argv[1])) {
34 invalidate_icache_all();
38 case 1: /* get status */
39 printf("Instruction Cache is %s\n",
40 icache_status() ? "ON" : "OFF");
48 void __weak flush_dcache_all(void)
50 puts("No arch specific flush_dcache_all available!\n");
51 /* please define arch specific flush_dcache_all */
54 static int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
57 case 2: /* on / off */
58 switch (parse_argv(argv[1])) {
70 case 1: /* get status */
71 printf("Data (writethrough) Cache is %s\n",
72 dcache_status() ? "ON" : "OFF");
80 static int parse_argv(const char *s)
82 if (strcmp(s, "flush") == 0)
84 else if (strcmp(s, "on") == 0)
86 else if (strcmp(s, "off") == 0)
94 icache, 2, 1, do_icache,
95 "enable or disable instruction cache",
97 " - enable, disable, or flush instruction cache"
101 dcache, 2, 1, do_dcache,
102 "enable or disable data cache",
104 " - enable, disable, or flush data (writethrough) cache"