]> Git Repo - J-u-boot.git/blame - cmd/cache.c
env: Move set_default_vars to env.h
[J-u-boot.git] / cmd / cache.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
3863585b
WD
2/*
3 * (C) Copyright 2000
4 * Wolfgang Denk, DENX Software Engineering, [email protected].
3863585b
WD
5 */
6
7/*
8 * Cache support: switch on or off, get status
9 */
10#include <common.h>
11#include <command.h>
d0c4c338 12#include <linux/compiler.h>
3863585b 13
d0c4c338
MM
14static int parse_argv(const char *);
15
23498935 16void __weak invalidate_icache_all(void)
d0c4c338 17{
23498935
SK
18 /* please define arch specific invalidate_icache_all */
19 puts("No arch specific invalidate_icache_all available!\n");
d0c4c338 20}
3863585b 21
0e350f81 22static int do_icache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b
WD
23{
24 switch (argc) {
f043dc28 25 case 2: /* on / off / flush */
d0c4c338 26 switch (parse_argv(argv[1])) {
e9455fcc
JH
27 case 0:
28 icache_disable();
3863585b 29 break;
e9455fcc
JH
30 case 1:
31 icache_enable();
3863585b 32 break;
e9455fcc
JH
33 case 2:
34 invalidate_icache_all();
d0c4c338 35 break;
f043dc28
EP
36 default:
37 return CMD_RET_USAGE;
3863585b 38 }
36180d96 39 break;
3863585b 40 case 1: /* get status */
e9455fcc 41 printf("Instruction Cache is %s\n",
3863585b
WD
42 icache_status() ? "ON" : "OFF");
43 return 0;
44 default:
4c12eeb8 45 return CMD_RET_USAGE;
3863585b
WD
46 }
47 return 0;
48}
49
23498935 50void __weak flush_dcache_all(void)
d0c4c338 51{
23498935
SK
52 puts("No arch specific flush_dcache_all available!\n");
53 /* please define arch specific flush_dcache_all */
d0c4c338
MM
54}
55
0e350f81 56static int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585b
WD
57{
58 switch (argc) {
f043dc28 59 case 2: /* on / off / flush */
d0c4c338 60 switch (parse_argv(argv[1])) {
e9455fcc
JH
61 case 0:
62 dcache_disable();
3863585b 63 break;
e9455fcc
JH
64 case 1:
65 dcache_enable();
3863585b 66 break;
e9455fcc
JH
67 case 2:
68 flush_dcache_all();
d0c4c338 69 break;
f043dc28
EP
70 default:
71 return CMD_RET_USAGE;
3863585b 72 }
e9455fcc 73 break;
3863585b 74 case 1: /* get status */
e9455fcc 75 printf("Data (writethrough) Cache is %s\n",
3863585b
WD
76 dcache_status() ? "ON" : "OFF");
77 return 0;
78 default:
4c12eeb8 79 return CMD_RET_USAGE;
3863585b
WD
80 }
81 return 0;
3863585b
WD
82}
83
d0c4c338 84static int parse_argv(const char *s)
3863585b 85{
e9455fcc
JH
86 if (strcmp(s, "flush") == 0)
87 return 2;
88 else if (strcmp(s, "on") == 0)
89 return 1;
90 else if (strcmp(s, "off") == 0)
91 return 0;
92
93 return -1;
3863585b
WD
94}
95
8bde7f77 96
0d498393
WD
97U_BOOT_CMD(
98 icache, 2, 1, do_icache,
2fb2604d 99 "enable or disable instruction cache",
d0c4c338
MM
100 "[on, off, flush]\n"
101 " - enable, disable, or flush instruction cache"
8bde7f77
WD
102);
103
0d498393
WD
104U_BOOT_CMD(
105 dcache, 2, 1, do_dcache,
2fb2604d 106 "enable or disable data cache",
d0c4c338
MM
107 "[on, off, flush]\n"
108 " - enable, disable, or flush data (writethrough) cache"
8bde7f77 109);
This page took 0.472735 seconds and 4 git commands to generate.