Blame view

cmd/mp.c 2.24 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>
62f9b6544   Simon Glass   common: Move olde...
8
  #include <cpu_func.h>
ec2b74ffd   Kumar Gala   85xx: Added suppo...
9

711e5e26b   Michal Simek   cmd_mp: Add suppo...
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  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...
28
  static int
54841ab50   Wolfgang Denk   Make sure that ar...
29
  cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
ec2b74ffd   Kumar Gala   85xx: Added suppo...
30
  {
79679d800   Kumar Gala   85xx: Update mult...
31
  	unsigned long cpuid;
ec2b74ffd   Kumar Gala   85xx: Added suppo...
32

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

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

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