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