blob: c3806dca3ad03db998209819651c80d1a53f8e43 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Gabriel Huau170ceaf2014-07-26 11:35:43 -07002/*
3 * (C) Copyright 2014
4 * Gabriel Huau <contact@huau-gabriel.fr>
5 *
6 * (C) Copyright 2009 Freescale Semiconductor, Inc.
Gabriel Huau170ceaf2014-07-26 11:35:43 -07007 */
8
9#include <common.h>
10#include <asm/io.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090011#include <linux/errno.h>
Gabriel Huau170ceaf2014-07-26 11:35:43 -070012#include <asm/arch/sys_proto.h>
13#include <asm/arch/imx-regs.h>
14
15#define MAX_CPUS 4
16static struct src *src = (struct src *)SRC_BASE_ADDR;
17
18static uint32_t cpu_reset_mask[MAX_CPUS] = {
19 0, /* We don't really want to modify the cpu0 */
20 SRC_SCR_CORE_1_RESET_MASK,
21 SRC_SCR_CORE_2_RESET_MASK,
22 SRC_SCR_CORE_3_RESET_MASK
23};
24
25static uint32_t cpu_ctrl_mask[MAX_CPUS] = {
26 0, /* We don't really want to modify the cpu0 */
27 SRC_SCR_CORE_1_ENABLE_MASK,
28 SRC_SCR_CORE_2_ENABLE_MASK,
29 SRC_SCR_CORE_3_ENABLE_MASK
30};
31
32int cpu_reset(int nr)
33{
34 /* Software reset of the CPU N */
35 src->scr |= cpu_reset_mask[nr];
36 return 0;
37}
38
39int cpu_status(int nr)
40{
41 printf("core %d => %d\n", nr, !!(src->scr & cpu_ctrl_mask[nr]));
42 return 0;
43}
44
45int cpu_release(int nr, int argc, char *const argv[])
46{
47 uint32_t boot_addr;
48
49 boot_addr = simple_strtoul(argv[0], NULL, 16);
50
51 switch (nr) {
52 case 1:
53 src->gpr3 = boot_addr;
54 break;
55 case 2:
56 src->gpr5 = boot_addr;
57 break;
58 case 3:
59 src->gpr7 = boot_addr;
60 break;
61 default:
62 return 1;
63 }
64
65 /* CPU N is ready to start */
66 src->scr |= cpu_ctrl_mask[nr];
67
68 return 0;
69}
70
71int is_core_valid(unsigned int core)
72{
73 uint32_t nr_cores = get_nr_cpus();
74
75 if (core > nr_cores)
76 return 0;
77
78 return 1;
79}
80
81int cpu_disable(int nr)
82{
83 /* Disable the CPU N */
84 src->scr &= ~cpu_ctrl_mask[nr];
85 return 0;
86}