Blame view

common/cmd_cache.c 2.76 KB
3863585bb   wdenk   Initial revision
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  /*
   * (C) Copyright 2000
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
   *
   * See file CREDITS for list of people who contributed to this
   * project.
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License as
   * published by the Free Software Foundation; either version 2 of
   * the License, or (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   * MA 02111-1307 USA
   */
  
  /*
   * Cache support: switch on or off, get status
   */
  #include <common.h>
  #include <command.h>
d0c4c3385   Matthew McClintock   command/cmd_cache...
29
  #include <linux/compiler.h>
3863585bb   wdenk   Initial revision
30

d0c4c3385   Matthew McClintock   command/cmd_cache...
31
  static int parse_argv(const char *);
23498935f   Stefan Kristiansson   cmd_cache: use ca...
32
  void __weak invalidate_icache_all(void)
d0c4c3385   Matthew McClintock   command/cmd_cache...
33
  {
23498935f   Stefan Kristiansson   cmd_cache: use ca...
34
35
36
  	/* please define arch specific invalidate_icache_all */
  	puts("No arch specific invalidate_icache_all available!
  ");
d0c4c3385   Matthew McClintock   command/cmd_cache...
37
  }
3863585bb   wdenk   Initial revision
38

54841ab50   Wolfgang Denk   Make sure that ar...
39
  int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585bb   wdenk   Initial revision
40
41
42
  {
  	switch (argc) {
  	case 2:			/* on / off	*/
d0c4c3385   Matthew McClintock   command/cmd_cache...
43
  		switch (parse_argv(argv[1])) {
3863585bb   wdenk   Initial revision
44
45
46
47
  		case 0:	icache_disable();
  			break;
  		case 1:	icache_enable ();
  			break;
23498935f   Stefan Kristiansson   cmd_cache: use ca...
48
  		case 2: invalidate_icache_all();
d0c4c3385   Matthew McClintock   command/cmd_cache...
49
  			break;
3863585bb   wdenk   Initial revision
50
51
52
53
54
55
56
57
  		}
  		/* FALL TROUGH */
  	case 1:			/* get status */
  		printf ("Instruction Cache is %s
  ",
  			icache_status() ? "ON" : "OFF");
  		return 0;
  	default:
4c12eeb8b   Simon Glass   Convert cmd_usage...
58
  		return CMD_RET_USAGE;
3863585bb   wdenk   Initial revision
59
60
61
  	}
  	return 0;
  }
23498935f   Stefan Kristiansson   cmd_cache: use ca...
62
  void __weak flush_dcache_all(void)
d0c4c3385   Matthew McClintock   command/cmd_cache...
63
  {
23498935f   Stefan Kristiansson   cmd_cache: use ca...
64
65
66
  	puts("No arch specific flush_dcache_all available!
  ");
  	/* please define arch specific flush_dcache_all */
d0c4c3385   Matthew McClintock   command/cmd_cache...
67
  }
54841ab50   Wolfgang Denk   Make sure that ar...
68
  int do_dcache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
3863585bb   wdenk   Initial revision
69
70
71
  {
  	switch (argc) {
  	case 2:			/* on / off	*/
d0c4c3385   Matthew McClintock   command/cmd_cache...
72
  		switch (parse_argv(argv[1])) {
3863585bb   wdenk   Initial revision
73
74
75
76
  		case 0:	dcache_disable();
  			break;
  		case 1:	dcache_enable ();
  			break;
23498935f   Stefan Kristiansson   cmd_cache: use ca...
77
  		case 2: flush_dcache_all();
d0c4c3385   Matthew McClintock   command/cmd_cache...
78
  			break;
3863585bb   wdenk   Initial revision
79
80
81
82
83
84
85
86
  		}
  		/* FALL TROUGH */
  	case 1:			/* get status */
  		printf ("Data (writethrough) Cache is %s
  ",
  			dcache_status() ? "ON" : "OFF");
  		return 0;
  	default:
4c12eeb8b   Simon Glass   Convert cmd_usage...
87
  		return CMD_RET_USAGE;
3863585bb   wdenk   Initial revision
88
89
90
91
  	}
  	return 0;
  
  }
d0c4c3385   Matthew McClintock   command/cmd_cache...
92
  static int parse_argv(const char *s)
3863585bb   wdenk   Initial revision
93
  {
d0c4c3385   Matthew McClintock   command/cmd_cache...
94
95
96
  	if (strcmp(s, "flush") == 0) {
  		return (2);
  	} else if (strcmp(s, "on") == 0) {
3863585bb   wdenk   Initial revision
97
98
99
100
101
102
  		return (1);
  	} else if (strcmp(s, "off") == 0) {
  		return (0);
  	}
  	return (-1);
  }
8bde7f776   wdenk   * Code cleanup:
103

0d4983930   wdenk   Patch by Kenneth ...
104
105
  U_BOOT_CMD(
  	icache,   2,   1,     do_icache,
2fb2604d5   Peter Tyser   Command usage cle...
106
  	"enable or disable instruction cache",
d0c4c3385   Matthew McClintock   command/cmd_cache...
107
108
109
  	"[on, off, flush]
  "
  	"    - enable, disable, or flush instruction cache"
8bde7f776   wdenk   * Code cleanup:
110
  );
0d4983930   wdenk   Patch by Kenneth ...
111
112
  U_BOOT_CMD(
  	dcache,   2,   1,     do_dcache,
2fb2604d5   Peter Tyser   Command usage cle...
113
  	"enable or disable data cache",
d0c4c3385   Matthew McClintock   command/cmd_cache...
114
115
116
  	"[on, off, flush]
  "
  	"    - enable, disable, or flush data (writethrough) cache"
8bde7f776   wdenk   * Code cleanup:
117
  );