diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2013-03-28 12:35:19 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2013-04-12 07:28:13 -0400 |
commit | 02985b94638b4de3ef9f2eb2ac5befe5bab12c26 (patch) | |
tree | d37b1596e40c3289d14038b0610402e9467ae21f /arch/arm/mach-imx/src.c | |
parent | 7006ba24c26313631f21fff5a087c971f5c7d2ef (diff) |
ARM i.MX6q: Add GPU, VPU, IPU, and OpenVG resets to System Reset Controller (SRC)
The SRC has auto-deasserting reset bits that control reset lines to
the GPU, VPU, IPU, and OpenVG IP modules. This patch adds a reset
controller that can be controlled by those devices using the
reset controller API.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Diffstat (limited to 'arch/arm/mach-imx/src.c')
-rw-r--r-- | arch/arm/mach-imx/src.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/src.c b/arch/arm/mach-imx/src.c index 09a742f8c7ab..dec641108b54 100644 --- a/arch/arm/mach-imx/src.c +++ b/arch/arm/mach-imx/src.c | |||
@@ -14,16 +14,72 @@ | |||
14 | #include <linux/io.h> | 14 | #include <linux/io.h> |
15 | #include <linux/of.h> | 15 | #include <linux/of.h> |
16 | #include <linux/of_address.h> | 16 | #include <linux/of_address.h> |
17 | #include <linux/reset-controller.h> | ||
17 | #include <linux/smp.h> | 18 | #include <linux/smp.h> |
18 | #include <asm/smp_plat.h> | 19 | #include <asm/smp_plat.h> |
19 | 20 | ||
20 | #define SRC_SCR 0x000 | 21 | #define SRC_SCR 0x000 |
21 | #define SRC_GPR1 0x020 | 22 | #define SRC_GPR1 0x020 |
22 | #define BP_SRC_SCR_WARM_RESET_ENABLE 0 | 23 | #define BP_SRC_SCR_WARM_RESET_ENABLE 0 |
24 | #define BP_SRC_SCR_SW_GPU_RST 1 | ||
25 | #define BP_SRC_SCR_SW_VPU_RST 2 | ||
26 | #define BP_SRC_SCR_SW_IPU1_RST 3 | ||
27 | #define BP_SRC_SCR_SW_OPEN_VG_RST 4 | ||
28 | #define BP_SRC_SCR_SW_IPU2_RST 12 | ||
23 | #define BP_SRC_SCR_CORE1_RST 14 | 29 | #define BP_SRC_SCR_CORE1_RST 14 |
24 | #define BP_SRC_SCR_CORE1_ENABLE 22 | 30 | #define BP_SRC_SCR_CORE1_ENABLE 22 |
25 | 31 | ||
26 | static void __iomem *src_base; | 32 | static void __iomem *src_base; |
33 | static DEFINE_SPINLOCK(scr_lock); | ||
34 | |||
35 | static const int sw_reset_bits[5] = { | ||
36 | BP_SRC_SCR_SW_GPU_RST, | ||
37 | BP_SRC_SCR_SW_VPU_RST, | ||
38 | BP_SRC_SCR_SW_IPU1_RST, | ||
39 | BP_SRC_SCR_SW_OPEN_VG_RST, | ||
40 | BP_SRC_SCR_SW_IPU2_RST | ||
41 | }; | ||
42 | |||
43 | static int imx_src_reset_module(struct reset_controller_dev *rcdev, | ||
44 | unsigned long sw_reset_idx) | ||
45 | { | ||
46 | unsigned long timeout; | ||
47 | unsigned long flags; | ||
48 | int bit; | ||
49 | u32 val; | ||
50 | |||
51 | if (!src_base) | ||
52 | return -ENODEV; | ||
53 | |||
54 | if (sw_reset_idx >= ARRAY_SIZE(sw_reset_bits)) | ||
55 | return -EINVAL; | ||
56 | |||
57 | bit = 1 << sw_reset_bits[sw_reset_idx]; | ||
58 | |||
59 | spin_lock_irqsave(&scr_lock, flags); | ||
60 | val = readl_relaxed(src_base + SRC_SCR); | ||
61 | val |= bit; | ||
62 | writel_relaxed(val, src_base + SRC_SCR); | ||
63 | spin_unlock_irqrestore(&scr_lock, flags); | ||
64 | |||
65 | timeout = jiffies + msecs_to_jiffies(1000); | ||
66 | while (readl(src_base + SRC_SCR) & bit) { | ||
67 | if (time_after(jiffies, timeout)) | ||
68 | return -ETIME; | ||
69 | cpu_relax(); | ||
70 | } | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static struct reset_control_ops imx_src_ops = { | ||
76 | .reset = imx_src_reset_module, | ||
77 | }; | ||
78 | |||
79 | static struct reset_controller_dev imx_reset_controller = { | ||
80 | .ops = &imx_src_ops, | ||
81 | .nr_resets = ARRAY_SIZE(sw_reset_bits), | ||
82 | }; | ||
27 | 83 | ||
28 | void imx_enable_cpu(int cpu, bool enable) | 84 | void imx_enable_cpu(int cpu, bool enable) |
29 | { | 85 | { |
@@ -31,9 +87,11 @@ void imx_enable_cpu(int cpu, bool enable) | |||
31 | 87 | ||
32 | cpu = cpu_logical_map(cpu); | 88 | cpu = cpu_logical_map(cpu); |
33 | mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1); | 89 | mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1); |
90 | spin_lock(&scr_lock); | ||
34 | val = readl_relaxed(src_base + SRC_SCR); | 91 | val = readl_relaxed(src_base + SRC_SCR); |
35 | val = enable ? val | mask : val & ~mask; | 92 | val = enable ? val | mask : val & ~mask; |
36 | writel_relaxed(val, src_base + SRC_SCR); | 93 | writel_relaxed(val, src_base + SRC_SCR); |
94 | spin_unlock(&scr_lock); | ||
37 | } | 95 | } |
38 | 96 | ||
39 | void imx_set_cpu_jump(int cpu, void *jump_addr) | 97 | void imx_set_cpu_jump(int cpu, void *jump_addr) |
@@ -60,9 +118,11 @@ void imx_src_prepare_restart(void) | |||
60 | u32 val; | 118 | u32 val; |
61 | 119 | ||
62 | /* clear enable bits of secondary cores */ | 120 | /* clear enable bits of secondary cores */ |
121 | spin_lock(&scr_lock); | ||
63 | val = readl_relaxed(src_base + SRC_SCR); | 122 | val = readl_relaxed(src_base + SRC_SCR); |
64 | val &= ~(0x7 << BP_SRC_SCR_CORE1_ENABLE); | 123 | val &= ~(0x7 << BP_SRC_SCR_CORE1_ENABLE); |
65 | writel_relaxed(val, src_base + SRC_SCR); | 124 | writel_relaxed(val, src_base + SRC_SCR); |
125 | spin_unlock(&scr_lock); | ||
66 | 126 | ||
67 | /* clear persistent entry register of primary core */ | 127 | /* clear persistent entry register of primary core */ |
68 | writel_relaxed(0, src_base + SRC_GPR1); | 128 | writel_relaxed(0, src_base + SRC_GPR1); |
@@ -77,11 +137,16 @@ void __init imx_src_init(void) | |||
77 | src_base = of_iomap(np, 0); | 137 | src_base = of_iomap(np, 0); |
78 | WARN_ON(!src_base); | 138 | WARN_ON(!src_base); |
79 | 139 | ||
140 | imx_reset_controller.of_node = np; | ||
141 | reset_controller_register(&imx_reset_controller); | ||
142 | |||
80 | /* | 143 | /* |
81 | * force warm reset sources to generate cold reset | 144 | * force warm reset sources to generate cold reset |
82 | * for a more reliable restart | 145 | * for a more reliable restart |
83 | */ | 146 | */ |
147 | spin_lock(&scr_lock); | ||
84 | val = readl_relaxed(src_base + SRC_SCR); | 148 | val = readl_relaxed(src_base + SRC_SCR); |
85 | val &= ~(1 << BP_SRC_SCR_WARM_RESET_ENABLE); | 149 | val &= ~(1 << BP_SRC_SCR_WARM_RESET_ENABLE); |
86 | writel_relaxed(val, src_base + SRC_SCR); | 150 | writel_relaxed(val, src_base + SRC_SCR); |
151 | spin_unlock(&scr_lock); | ||
87 | } | 152 | } |