Blame view

cmd/mp.c 2.22 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
ec2b74ffd   Kumar Gala   85xx: Added suppo...
2
  /*
0e870980a   Poonam Aggrwal   8xxx: Removed CON...
3
   * Copyright 2008-2009 Freescale Semiconductor, Inc.
ec2b74ffd   Kumar Gala   85xx: Added suppo...
4
5
6
7
   */
  
  #include <common.h>
  #include <command.h>
711e5e26b   Michal Simek   cmd_mp: Add suppo...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  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...
26
  static int
54841ab50   Wolfgang Denk   Make sure that ar...
27
  cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
ec2b74ffd   Kumar Gala   85xx: Added suppo...
28
  {
79679d800   Kumar Gala   85xx: Update mult...
29
  	unsigned long cpuid;
ec2b74ffd   Kumar Gala   85xx: Added suppo...
30

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

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

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