Shawn Guo | 9fbbe68 | 2011-09-06 14:39:44 +0800 | [diff] [blame] | 1 | /* |
| 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 Deacon | eaa142c | 2011-08-09 12:24:07 +0100 | [diff] [blame] | 17 | #include <linux/smp.h> |
Will Deacon | eb50439 | 2012-01-20 12:01:12 +0100 | [diff] [blame] | 18 | #include <asm/smp_plat.h> |
Fabio Estevam | 0989857 | 2013-03-25 09:20:43 -0300 | [diff] [blame^] | 19 | #include "common.h" |
Shawn Guo | 9fbbe68 | 2011-09-06 14:39:44 +0800 | [diff] [blame] | 20 | |
| 21 | #define SRC_SCR 0x000 |
| 22 | #define SRC_GPR1 0x020 |
Shawn Guo | 0575fb7 | 2011-12-09 00:51:26 +0100 | [diff] [blame] | 23 | #define BP_SRC_SCR_WARM_RESET_ENABLE 0 |
Shawn Guo | 9fbbe68 | 2011-09-06 14:39:44 +0800 | [diff] [blame] | 24 | #define BP_SRC_SCR_CORE1_RST 14 |
| 25 | #define BP_SRC_SCR_CORE1_ENABLE 22 |
| 26 | |
| 27 | static void __iomem *src_base; |
| 28 | |
| 29 | void imx_enable_cpu(int cpu, bool enable) |
| 30 | { |
| 31 | u32 mask, val; |
| 32 | |
Will Deacon | eaa142c | 2011-08-09 12:24:07 +0100 | [diff] [blame] | 33 | cpu = cpu_logical_map(cpu); |
Shawn Guo | 9fbbe68 | 2011-09-06 14:39:44 +0800 | [diff] [blame] | 34 | mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1); |
| 35 | val = readl_relaxed(src_base + SRC_SCR); |
| 36 | val = enable ? val | mask : val & ~mask; |
| 37 | writel_relaxed(val, src_base + SRC_SCR); |
| 38 | } |
| 39 | |
| 40 | void imx_set_cpu_jump(int cpu, void *jump_addr) |
| 41 | { |
Will Deacon | eaa142c | 2011-08-09 12:24:07 +0100 | [diff] [blame] | 42 | cpu = cpu_logical_map(cpu); |
Rob Herring | 0a60cb1 | 2012-01-09 15:41:40 -0600 | [diff] [blame] | 43 | writel_relaxed(virt_to_phys(jump_addr), |
Shawn Guo | 9fbbe68 | 2011-09-06 14:39:44 +0800 | [diff] [blame] | 44 | src_base + SRC_GPR1 + cpu * 8); |
| 45 | } |
| 46 | |
Shawn Guo | 0575fb7 | 2011-12-09 00:51:26 +0100 | [diff] [blame] | 47 | void imx_src_prepare_restart(void) |
| 48 | { |
| 49 | u32 val; |
| 50 | |
| 51 | /* clear enable bits of secondary cores */ |
| 52 | val = readl_relaxed(src_base + SRC_SCR); |
| 53 | val &= ~(0x7 << BP_SRC_SCR_CORE1_ENABLE); |
| 54 | writel_relaxed(val, src_base + SRC_SCR); |
| 55 | |
| 56 | /* clear persistent entry register of primary core */ |
| 57 | writel_relaxed(0, src_base + SRC_GPR1); |
| 58 | } |
| 59 | |
Shawn Guo | 9fbbe68 | 2011-09-06 14:39:44 +0800 | [diff] [blame] | 60 | void __init imx_src_init(void) |
| 61 | { |
| 62 | struct device_node *np; |
Shawn Guo | 0575fb7 | 2011-12-09 00:51:26 +0100 | [diff] [blame] | 63 | u32 val; |
Shawn Guo | 9fbbe68 | 2011-09-06 14:39:44 +0800 | [diff] [blame] | 64 | |
| 65 | np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src"); |
| 66 | src_base = of_iomap(np, 0); |
| 67 | WARN_ON(!src_base); |
Shawn Guo | 0575fb7 | 2011-12-09 00:51:26 +0100 | [diff] [blame] | 68 | |
| 69 | /* |
| 70 | * force warm reset sources to generate cold reset |
| 71 | * for a more reliable restart |
| 72 | */ |
| 73 | val = readl_relaxed(src_base + SRC_SCR); |
| 74 | val &= ~(1 << BP_SRC_SCR_WARM_RESET_ENABLE); |
| 75 | writel_relaxed(val, src_base + SRC_SCR); |
Shawn Guo | 9fbbe68 | 2011-09-06 14:39:44 +0800 | [diff] [blame] | 76 | } |