Blame view

cmd/cache.c 2 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
3863585bb   wdenk   Initial revision
2
3
4
  /*
   * (C) Copyright 2000
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
3863585bb   wdenk   Initial revision
5
6
7
8
9
10
11
   */
  
  /*
   * Cache support: switch on or off, get status
   */
  #include <common.h>
  #include <command.h>
d0c4c3385   Matthew McClintock   command/cmd_cache...
12
  #include <linux/compiler.h>
3863585bb   wdenk   Initial revision
13

d0c4c3385   Matthew McClintock   command/cmd_cache...
14
  static int parse_argv(const char *);
23498935f   Stefan Kristiansson   cmd_cache: use ca...
15
  void __weak invalidate_icache_all(void)
d0c4c3385   Matthew McClintock   command/cmd_cache...
16
  {
23498935f   Stefan Kristiansson   cmd_cache: use ca...
17
18
19
  	/* please define arch specific invalidate_icache_all */
  	puts("No arch specific invalidate_icache_all available!
  ");
d0c4c3385   Matthew McClintock   command/cmd_cache...
20
  }
3863585bb   wdenk   Initial revision
21

0e350f81e   Jeroen Hofstee   common: commands:...
22
  static int do_icache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585bb   wdenk   Initial revision
23
24
25
  {
  	switch (argc) {
  	case 2:			/* on / off	*/
d0c4c3385   Matthew McClintock   command/cmd_cache...
26
  		switch (parse_argv(argv[1])) {
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
27
28
  		case 0:
  			icache_disable();
3863585bb   wdenk   Initial revision
29
  			break;
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
30
31
  		case 1:
  			icache_enable();
3863585bb   wdenk   Initial revision
32
  			break;
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
33
34
  		case 2:
  			invalidate_icache_all();
d0c4c3385   Matthew McClintock   command/cmd_cache...
35
  			break;
3863585bb   wdenk   Initial revision
36
  		}
36180d96c   Joe Hershberger   Cleanup cache com...
37
  		break;
3863585bb   wdenk   Initial revision
38
  	case 1:			/* get status */
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
39
40
  		printf("Instruction Cache is %s
  ",
3863585bb   wdenk   Initial revision
41
42
43
  			icache_status() ? "ON" : "OFF");
  		return 0;
  	default:
4c12eeb8b   Simon Glass   Convert cmd_usage...
44
  		return CMD_RET_USAGE;
3863585bb   wdenk   Initial revision
45
46
47
  	}
  	return 0;
  }
23498935f   Stefan Kristiansson   cmd_cache: use ca...
48
  void __weak flush_dcache_all(void)
d0c4c3385   Matthew McClintock   command/cmd_cache...
49
  {
23498935f   Stefan Kristiansson   cmd_cache: use ca...
50
51
52
  	puts("No arch specific flush_dcache_all available!
  ");
  	/* please define arch specific flush_dcache_all */
d0c4c3385   Matthew McClintock   command/cmd_cache...
53
  }
0e350f81e   Jeroen Hofstee   common: commands:...
54
  static int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585bb   wdenk   Initial revision
55
56
  {
  	switch (argc) {
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
57
  	case 2:			/* on / off */
d0c4c3385   Matthew McClintock   command/cmd_cache...
58
  		switch (parse_argv(argv[1])) {
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
59
60
  		case 0:
  			dcache_disable();
3863585bb   wdenk   Initial revision
61
  			break;
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
62
63
  		case 1:
  			dcache_enable();
3863585bb   wdenk   Initial revision
64
  			break;
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
65
66
  		case 2:
  			flush_dcache_all();
d0c4c3385   Matthew McClintock   command/cmd_cache...
67
  			break;
3863585bb   wdenk   Initial revision
68
  		}
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
69
  		break;
3863585bb   wdenk   Initial revision
70
  	case 1:			/* get status */
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
71
72
  		printf("Data (writethrough) Cache is %s
  ",
3863585bb   wdenk   Initial revision
73
74
75
  			dcache_status() ? "ON" : "OFF");
  		return 0;
  	default:
4c12eeb8b   Simon Glass   Convert cmd_usage...
76
  		return CMD_RET_USAGE;
3863585bb   wdenk   Initial revision
77
78
  	}
  	return 0;
3863585bb   wdenk   Initial revision
79
  }
d0c4c3385   Matthew McClintock   command/cmd_cache...
80
  static int parse_argv(const char *s)
3863585bb   wdenk   Initial revision
81
  {
e9455fcc4   Joe Hershberger   Fix checkpatch.pl...
82
83
84
85
86
87
88
89
  	if (strcmp(s, "flush") == 0)
  		return 2;
  	else if (strcmp(s, "on") == 0)
  		return 1;
  	else if (strcmp(s, "off") == 0)
  		return 0;
  
  	return -1;
3863585bb   wdenk   Initial revision
90
  }
8bde7f776   wdenk   * Code cleanup:
91

0d4983930   wdenk   Patch by Kenneth ...
92
93
  U_BOOT_CMD(
  	icache,   2,   1,     do_icache,
2fb2604d5   Peter Tyser   Command usage cle...
94
  	"enable or disable instruction cache",
d0c4c3385   Matthew McClintock   command/cmd_cache...
95
96
97
  	"[on, off, flush]
  "
  	"    - enable, disable, or flush instruction cache"
8bde7f776   wdenk   * Code cleanup:
98
  );
0d4983930   wdenk   Patch by Kenneth ...
99
100
  U_BOOT_CMD(
  	dcache,   2,   1,     do_dcache,
2fb2604d5   Peter Tyser   Command usage cle...
101
  	"enable or disable data cache",
d0c4c3385   Matthew McClintock   command/cmd_cache...
102
103
104
  	"[on, off, flush]
  "
  	"    - enable, disable, or flush data (writethrough) cache"
8bde7f776   wdenk   * Code cleanup:
105
  );