// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright 2008-2009 Freescale Semiconductor, Inc.
 */

#include <command.h>
#include <cpu_func.h>
#include <vsprintf.h>

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\n", cpuid);
				return 1;
			}
			break;
		}
		cpu_status(cpuid);
	}

	return 0;
}

static int
cpu_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
	unsigned long cpuid;

	if (argc == 2 && strncmp(argv[1], "status", 6) == 0)
		  return cpu_status_all();

	if (argc < 3)
		return CMD_RET_USAGE;

	cpuid = dectoul(argv[1], NULL);
	if (!is_core_valid(cpuid)) {
		printf ("Core num: %lu is not valid\n",	cpuid);
		return 1;
	}


	if (argc == 3) {
		if (strncmp(argv[2], "reset", 5) == 0)
			cpu_reset(cpuid);
		else if (strncmp(argv[2], "status", 6) == 0)
			cpu_status(cpuid);
		else if (strncmp(argv[2], "disable", 7) == 0)
			return cpu_disable(cpuid);
		else
			return CMD_RET_USAGE;

		return 0;
	}

	/* 4 or greater, make sure its release */
	if (strncmp(argv[2], "release", 7) != 0)
		return CMD_RET_USAGE;

	if (cpu_release(cpuid, argc - 3, argv + 3))
		return CMD_RET_USAGE;

	return 0;
}

U_BOOT_LONGHELP(cpu,
	    "<num> reset                 - Reset cpu <num>\n"
	"cpu status                      - Status of all cpus\n"
	"cpu <num> status                - Status of cpu <num>\n"
	"cpu <num> disable               - Disable cpu <num>\n"
	"cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
#ifdef CONFIG_PPC
	"\n"
	"                         [args] : <pir> <r3> <r6>\n" \
	"                                   pir - processor id (if writeable)\n" \
	"                                    r3 - value for gpr 3\n" \
	"                                    r6 - value for gpr 6\n" \
	"\n" \
	"     Use '-' for any arg if you want the default value.\n" \
	"     Default for r3 is <num> and r6 is 0\n" \
	"\n" \
	"     When cpu <num> is released r4 and r5 = 0.\n" \
	"     r7 will contain the size of the initial mapped area"
#endif
	);

U_BOOT_CMD(
	cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
	"Multiprocessor CPU boot manipulation and release", cpu_help_text
);
