Blame view

cmd/mp.c 2.22 KB
ec2b74ffd   Kumar Gala   85xx: Added suppo...
1
  /*
0e870980a   Poonam Aggrwal   8xxx: Removed CON...
2
   * Copyright 2008-2009 Freescale Semiconductor, Inc.
ec2b74ffd   Kumar Gala   85xx: Added suppo...
3
   *
1a4596601   Wolfgang Denk   Add GPL-2.0+ SPDX...
4
   * SPDX-License-Identifier:	GPL-2.0+
ec2b74ffd   Kumar Gala   85xx: Added suppo...
5
6
7
8
   */
  
  #include <common.h>
  #include <command.h>
711e5e26b   Michal Simek   cmd_mp: Add suppo...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  static int cpu_status_all(void)
  {
  	unsigned long cpuid;
  
  	for (cpuid = 0; ; cpuid++) {
  		if (!is_core_valid(cpuid)) {
  			if (cpuid == 0) {
  				printf("Core num: %lu is not valid
  ", cpuid);
  				return 1;
  			}
  			break;
  		}
  		cpu_status(cpuid);
  	}
  
  	return 0;
  }
088f1b199   Kim Phillips   common/cmd_*.c: s...
27
  static int
54841ab50   Wolfgang Denk   Make sure that ar...
28
  cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
ec2b74ffd   Kumar Gala   85xx: Added suppo...
29
  {
79679d800   Kumar Gala   85xx: Update mult...
30
  	unsigned long cpuid;
ec2b74ffd   Kumar Gala   85xx: Added suppo...
31

711e5e26b   Michal Simek   cmd_mp: Add suppo...
32
33
  	if (argc == 2 && strncmp(argv[1], "status", 6) == 0)
  		  return cpu_status_all();
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
34
  	if (argc < 3)
4c12eeb8b   Simon Glass   Convert cmd_usage...
35
  		return CMD_RET_USAGE;
ec2b74ffd   Kumar Gala   85xx: Added suppo...
36
37
  
  	cpuid = simple_strtoul(argv[1], NULL, 10);
fbb9ecf74   Timur Tabi   powerpc/mp: add s...
38
39
40
  	if (!is_core_valid(cpuid)) {
  		printf ("Core num: %lu is not valid
  ",	cpuid);
ec2b74ffd   Kumar Gala   85xx: Added suppo...
41
42
43
44
45
  		return 1;
  	}
  
  
  	if (argc == 3) {
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
46
  		if (strncmp(argv[2], "reset", 5) == 0)
ec2b74ffd   Kumar Gala   85xx: Added suppo...
47
  			cpu_reset(cpuid);
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
48
  		else if (strncmp(argv[2], "status", 6) == 0)
ec2b74ffd   Kumar Gala   85xx: Added suppo...
49
  			cpu_status(cpuid);
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
50
  		else if (strncmp(argv[2], "disable", 7) == 0)
4194b3668   Kumar Gala   Add support to di...
51
  			return cpu_disable(cpuid);
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
52
  		else
4c12eeb8b   Simon Glass   Convert cmd_usage...
53
  			return CMD_RET_USAGE;
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
54

ec2b74ffd   Kumar Gala   85xx: Added suppo...
55
56
57
58
  		return 0;
  	}
  
  	/* 4 or greater, make sure its release */
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
59
  	if (strncmp(argv[2], "release", 7) != 0)
4c12eeb8b   Simon Glass   Convert cmd_usage...
60
  		return CMD_RET_USAGE;
ec2b74ffd   Kumar Gala   85xx: Added suppo...
61

47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
62
  	if (cpu_release(cpuid, argc - 3, argv + 3))
4c12eeb8b   Simon Glass   Convert cmd_usage...
63
  		return CMD_RET_USAGE;
ec2b74ffd   Kumar Gala   85xx: Added suppo...
64
65
66
  
  	return 0;
  }
088f1b199   Kim Phillips   common/cmd_*.c: s...
67
68
69
70
  #ifdef CONFIG_SYS_LONGHELP
  static char cpu_help_text[] =
  	    "<num> reset                 - Reset cpu <num>
  "
711e5e26b   Michal Simek   cmd_mp: Add suppo...
71
72
  	"cpu status                      - Status of all cpus
  "
088f1b199   Kim Phillips   common/cmd_*.c: s...
73
74
75
76
77
  	"cpu <num> status                - Status of cpu <num>
  "
  	"cpu <num> disable               - Disable cpu <num>
  "
  	"cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
ec2b74ffd   Kumar Gala   85xx: Added suppo...
78
  #ifdef CONFIG_PPC
088f1b199   Kim Phillips   common/cmd_*.c: s...
79
80
  	"
  "
79679d800   Kumar Gala   85xx: Update mult...
81
82
  	"                         [args] : <pir> <r3> <r6>
  " \
ec2b74ffd   Kumar Gala   85xx: Added suppo...
83
84
85
86
  	"                                   pir - processor id (if writeable)
  " \
  	"                                    r3 - value for gpr 3
  " \
ec2b74ffd   Kumar Gala   85xx: Added suppo...
87
88
  	"                                    r6 - value for gpr 6
  " \
ec2b74ffd   Kumar Gala   85xx: Added suppo...
89
90
91
92
  	"
  " \
  	"     Use '-' for any arg if you want the default value.
  " \
79679d800   Kumar Gala   85xx: Update mult...
93
94
  	"     Default for r3 is <num> and r6 is 0
  " \
ec2b74ffd   Kumar Gala   85xx: Added suppo...
95
96
  	"
  " \
79679d800   Kumar Gala   85xx: Update mult...
97
98
  	"     When cpu <num> is released r4 and r5 = 0.
  " \
a89c33db9   Wolfgang Denk   General help mess...
99
  	"     r7 will contain the size of the initial mapped area"
ec2b74ffd   Kumar Gala   85xx: Added suppo...
100
  #endif
088f1b199   Kim Phillips   common/cmd_*.c: s...
101
102
  	"";
  #endif
ec2b74ffd   Kumar Gala   85xx: Added suppo...
103
104
  
  U_BOOT_CMD(
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
105
  	cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
088f1b199   Kim Phillips   common/cmd_*.c: s...
106
  	"Multiprocessor CPU boot manipulation and release", cpu_help_text
a89c33db9   Wolfgang Denk   General help mess...
107
  );