aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoren Brinkmann <soren.brinkmann@xilinx.com>2014-09-02 17:19:09 -0400
committerMichal Simek <michal.simek@xilinx.com>2014-09-16 06:55:07 -0400
commit0beb2bd36f6216f455363f47f8ba32fdf26667fb (patch)
treefb371f2b3d8c5e23b81cd714d697042227c3dc6b
parent36ad5ae6dea7ae6abbb7bdf25078e7d1dabcecad (diff)
ARM: zynq: PM: Enable DDR clock stop
The DDR controller can detect idle periods and leverage low power features clock stop. When new requests occur, the DDRC resumes normal operation. Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
-rw-r--r--arch/arm/mach-zynq/Makefile2
-rw-r--r--arch/arm/mach-zynq/common.c1
-rw-r--r--arch/arm/mach-zynq/common.h2
-rw-r--r--arch/arm/mach-zynq/pm.c83
4 files changed, 87 insertions, 1 deletions
diff --git a/arch/arm/mach-zynq/Makefile b/arch/arm/mach-zynq/Makefile
index 1b25d92ebf22..820dff6e1eba 100644
--- a/arch/arm/mach-zynq/Makefile
+++ b/arch/arm/mach-zynq/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# Common support 5# Common support
6obj-y := common.o slcr.o 6obj-y := common.o slcr.o pm.o
7CFLAGS_REMOVE_hotplug.o =-march=armv6k 7CFLAGS_REMOVE_hotplug.o =-march=armv6k
8CFLAGS_hotplug.o =-Wa,-march=armv7-a -mcpu=cortex-a9 8CFLAGS_hotplug.o =-Wa,-march=armv7-a -mcpu=cortex-a9
9obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 9obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 3cb7c198615a..6bd13e5ce6b7 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -101,6 +101,7 @@ static int __init zynq_get_revision(void)
101static void __init zynq_init_late(void) 101static void __init zynq_init_late(void)
102{ 102{
103 zynq_core_pm_init(); 103 zynq_core_pm_init();
104 zynq_pm_late_init();
104} 105}
105 106
106/** 107/**
diff --git a/arch/arm/mach-zynq/common.h b/arch/arm/mach-zynq/common.h
index 596ef0b5067c..0edbb6997b1c 100644
--- a/arch/arm/mach-zynq/common.h
+++ b/arch/arm/mach-zynq/common.h
@@ -40,6 +40,8 @@ extern void __iomem *zynq_scu_base;
40/* Hotplug */ 40/* Hotplug */
41extern void zynq_platform_cpu_die(unsigned int cpu); 41extern void zynq_platform_cpu_die(unsigned int cpu);
42 42
43void zynq_pm_late_init(void);
44
43static inline void zynq_core_pm_init(void) 45static inline void zynq_core_pm_init(void)
44{ 46{
45 /* A9 clock gating */ 47 /* A9 clock gating */
diff --git a/arch/arm/mach-zynq/pm.c b/arch/arm/mach-zynq/pm.c
new file mode 100644
index 000000000000..911fcf865be8
--- /dev/null
+++ b/arch/arm/mach-zynq/pm.c
@@ -0,0 +1,83 @@
1/*
2 * Zynq power management
3 *
4 * Copyright (C) 2012 - 2014 Xilinx
5 *
6 * Sören Brinkmann <soren.brinkmann@xilinx.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <linux/io.h>
23#include <linux/of_address.h>
24#include <linux/of_device.h>
25#include "common.h"
26
27/* register offsets */
28#define DDRC_CTRL_REG1_OFFS 0x60
29#define DDRC_DRAM_PARAM_REG3_OFFS 0x20
30
31/* bitfields */
32#define DDRC_CLOCKSTOP_MASK BIT(23)
33#define DDRC_SELFREFRESH_MASK BIT(12)
34
35static void __iomem *ddrc_base;
36
37/**
38 * zynq_pm_ioremap() - Create IO mappings
39 * @comp: DT compatible string
40 * Return: Pointer to the mapped memory or NULL.
41 *
42 * Remap the memory region for a compatible DT node.
43 */
44static void __iomem *zynq_pm_ioremap(const char *comp)
45{
46 struct device_node *np;
47 void __iomem *base = NULL;
48
49 np = of_find_compatible_node(NULL, NULL, comp);
50 if (np) {
51 base = of_iomap(np, 0);
52 of_node_put(np);
53 } else {
54 pr_warn("%s: no compatible node found for '%s'\n", __func__,
55 comp);
56 }
57
58 return base;
59}
60
61/**
62 * zynq_pm_late_init() - Power management init
63 *
64 * Initialization of power management related featurs and infrastructure.
65 */
66void __init zynq_pm_late_init(void)
67{
68 u32 reg;
69
70 ddrc_base = zynq_pm_ioremap("xlnx,zynq-ddrc-a05");
71 if (!ddrc_base) {
72 pr_warn("%s: Unable to map DDRC IO memory.\n", __func__);
73 } else {
74 /*
75 * Enable DDRC clock stop feature. The HW takes care of
76 * entering/exiting the correct mode depending
77 * on activity state.
78 */
79 reg = readl(ddrc_base + DDRC_DRAM_PARAM_REG3_OFFS);
80 reg |= DDRC_CLOCKSTOP_MASK;
81 writel(reg, ddrc_base + DDRC_DRAM_PARAM_REG3_OFFS);
82 }
83}