blob: 74a4b5d3d1c0e91939803cd6b712ba5c2aed116f [file] [log] [blame]
Shawn Guo9fbbe682011-09-06 14:39:44 +08001/*
2 * Copyright 2011 Freescale Semiconductor, Inc.
3 * Copyright 2011 Linaro Ltd.
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12
13#include <linux/init.h>
14#include <linux/io.h>
15#include <linux/of.h>
16#include <linux/of_address.h>
Will Deaconeaa142c2011-08-09 12:24:07 +010017#include <linux/smp.h>
Shawn Guo9fbbe682011-09-06 14:39:44 +080018
19#define SRC_SCR 0x000
20#define SRC_GPR1 0x020
21#define BP_SRC_SCR_CORE1_RST 14
22#define BP_SRC_SCR_CORE1_ENABLE 22
23
24static void __iomem *src_base;
25
Will Deaconeaa142c2011-08-09 12:24:07 +010026#ifndef CONFIG_SMP
27#define cpu_logical_map(cpu) 0
28#endif
29
Shawn Guo9fbbe682011-09-06 14:39:44 +080030void imx_enable_cpu(int cpu, bool enable)
31{
32 u32 mask, val;
33
Will Deaconeaa142c2011-08-09 12:24:07 +010034 cpu = cpu_logical_map(cpu);
Shawn Guo9fbbe682011-09-06 14:39:44 +080035 mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1);
36 val = readl_relaxed(src_base + SRC_SCR);
37 val = enable ? val | mask : val & ~mask;
38 writel_relaxed(val, src_base + SRC_SCR);
39}
40
41void imx_set_cpu_jump(int cpu, void *jump_addr)
42{
Will Deaconeaa142c2011-08-09 12:24:07 +010043 cpu = cpu_logical_map(cpu);
Rob Herring0a60cb12012-01-09 15:41:40 -060044 writel_relaxed(virt_to_phys(jump_addr),
Shawn Guo9fbbe682011-09-06 14:39:44 +080045 src_base + SRC_GPR1 + cpu * 8);
46}
47
48void __init imx_src_init(void)
49{
50 struct device_node *np;
51
52 np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src");
53 src_base = of_iomap(np, 0);
54 WARN_ON(!src_base);
55}