From: Thomas Abraham <thomas.abraham@linaro.org>
To: linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org
Cc: rjw@sisk.pl, linux-arm-kernel@lists.infradead.org,
devicetree-discuss@lists.ozlabs.org, rob.herring@calxeda.com,
grant.likely@secretlab.ca, kgene.kim@samsung.com,
broonie@opensource.wolfsonmicro.com, patches@linaro.org
Subject: [PATCH 2/2] ARM: Exynos: Hook up power domains to generic power domain infrastructure
Date: Mon, 12 Dec 2011 21:16:29 +0530 [thread overview]
Message-ID: <1323704789-23923-3-git-send-email-thomas.abraham@linaro.org> (raw)
In-Reply-To: <1323704789-23923-2-git-send-email-thomas.abraham@linaro.org>
The generic power domain infrastructure is used to control the power domains
available on Exynos4. For non-dt platforms, the power domains are statically
instantiated. For dt platforms, the power domain nodes found in the device
tree are instantiated.
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
This patch is mainly derived from Mark Brown's work on generic power domain
support for s3c64xx platforms. The existing exynos4 power domain implementation
is not removed in this patch. The devices are not yet registered with the power
domains for non-dt platforms.
arch/arm/mach-exynos/Kconfig | 1 +
arch/arm/mach-exynos/pm.c | 179 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 180 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index 0afcc3b..c1f77c7 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -29,6 +29,7 @@ config CPU_EXYNOS4210
default y
depends on ARCH_EXYNOS4
select SAMSUNG_DMADEV
+ select PM_GENERIC_DOMAINS
select ARM_CPU_SUSPEND if PM
select S5P_PM if PM
select S5P_SLEEP if PM
diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index 4093fea..a471ea6 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -20,6 +20,10 @@
#include <linux/io.h>
#include <linux/err.h>
#include <linux/clk.h>
+#include <linux/slab.h>
+#include <linux/pm_domain.h>
+#include <linux/delay.h>
+#include <linux/of_address.h>
#include <asm/cacheflush.h>
#include <asm/hardware/cache-l2x0.h>
@@ -37,6 +41,13 @@
#include <mach/pm-core.h>
#include <mach/pmu.h>
+struct exynos4_pm_domain {
+ void __iomem *base;
+ char const *name;
+ bool is_off;
+ struct generic_pm_domain pd;
+};
+
static struct sleep_save exynos4_set_clksrc[] = {
{ .reg = S5P_CLKSRC_MASK_TOP , .val = 0x00000001, },
{ .reg = S5P_CLKSRC_MASK_CAM , .val = 0x11111111, },
@@ -285,12 +296,172 @@ static struct sysdev_driver exynos4_pm_driver = {
.add = exynos4_pm_add,
};
+static int exynos4_pd_power_on(struct generic_pm_domain *domain)
+{
+ struct exynos4_pm_domain *pd;
+ void __iomem *base;
+ u32 timeout;
+
+ pd = container_of(domain, struct exynos4_pm_domain, pd);
+ base = pd->base;
+
+ __raw_writel(S5P_INT_LOCAL_PWR_EN, base);
+
+ /* Wait max 1ms */
+ timeout = 10;
+ while ((__raw_readl(base + 0x4) & S5P_INT_LOCAL_PWR_EN)
+ != S5P_INT_LOCAL_PWR_EN) {
+ if (!timeout) {
+ pr_err("Power domain %s enable failed\n", domain->name);
+ return -ETIMEDOUT;
+ }
+ timeout--;
+ udelay(100);
+ }
+ return 0;
+}
+
+static int exynos4_pd_power_off(struct generic_pm_domain *domain)
+{
+ struct exynos4_pm_domain *pd;
+ void __iomem *base;
+ u32 timeout;
+
+ pd = container_of(domain, struct exynos4_pm_domain, pd);
+ base = pd->base;
+
+ __raw_writel(0, base);
+
+ /* Wait max 1ms */
+ timeout = 10;
+ while (__raw_readl(base + 0x4) & S5P_INT_LOCAL_PWR_EN) {
+ if (!timeout) {
+ pr_err("Power domain %s disable failed\n", domain->name);
+ return -ETIMEDOUT;
+ }
+ timeout--;
+ udelay(100);
+ }
+ return 0;
+}
+
+static struct exynos4_pm_domain exynos4_pd_mfc = {
+ .base = (void __iomem *)S5P_PMU_MFC_CONF,
+ .name = "pd-mfc",
+ .pd = {
+ .power_off = exynos4_pd_power_off,
+ .power_on = exynos4_pd_power_on,
+ },
+};
+
+static struct exynos4_pm_domain exynos4_pd_g3d = {
+ .base = (void __iomem *)S5P_PMU_G3D_CONF,
+ .name = "pd-g3d",
+ .pd = {
+ .power_off = exynos4_pd_power_off,
+ .power_on = exynos4_pd_power_on,
+ },
+};
+
+static struct exynos4_pm_domain exynos4_pd_lcd0 = {
+ .base = (void __iomem *)S5P_PMU_LCD0_CONF,
+ .name = "pd-lcd0",
+ .pd = {
+ .power_off = exynos4_pd_power_off,
+ .power_on = exynos4_pd_power_on,
+ },
+};
+
+static struct exynos4_pm_domain exynos4_pd_lcd1 = {
+ .base = (void __iomem *)S5P_PMU_LCD1_CONF,
+ .name = "pd-lcd1",
+ .pd = {
+ .power_off = exynos4_pd_power_off,
+ .power_on = exynos4_pd_power_on,
+ },
+};
+
+static struct exynos4_pm_domain exynos4_pd_tv = {
+ .base = (void __iomem *)S5P_PMU_TV_CONF,
+ .name = "pd-tv",
+ .pd = {
+ .power_off = exynos4_pd_power_off,
+ .power_on = exynos4_pd_power_on,
+ },
+};
+
+static struct exynos4_pm_domain exynos4_pd_cam = {
+ .base = (void __iomem *)S5P_PMU_CAM_CONF,
+ .name = "pd-cam",
+ .pd = {
+ .power_off = exynos4_pd_power_off,
+ .power_on = exynos4_pd_power_on,
+ },
+};
+
+static struct exynos4_pm_domain exynos4_pd_gps = {
+ .base = (void __iomem *)S5P_PMU_GPS_CONF,
+ .name = "pd-gps",
+ .pd = {
+ .power_off = exynos4_pd_power_off,
+ .power_on = exynos4_pd_power_on,
+ },
+};
+
+static struct exynos4_pm_domain *exynos4_pm_domains[] = {
+ &exynos4_pd_mfc,
+ &exynos4_pd_g3d,
+ &exynos4_pd_lcd0,
+ &exynos4_pd_lcd1,
+ &exynos4_pd_tv,
+ &exynos4_pd_cam,
+ &exynos4_pd_gps,
+};
+
+static __init void exynos4_pm_init_power_domain(void)
+{
+ int idx;
+ struct device_node *np;
+
+#ifdef CONFIG_OF
+ if (!of_have_populated_dt())
+ goto no_dt;
+
+ for_each_compatible_node(np, NULL, "samsung,exynos4210-pd") {
+ struct exynos4_pm_domain *pd;
+
+ pd = kzalloc(sizeof(*pd), GFP_KERNEL);
+ if (!pd) {
+ pr_err("exynos4_pm_init_power_domain: memalloc "
+ "failed\n");
+ return;
+ }
+
+ if (of_get_property(np, "samsung,exynos4210-pd-off", NULL))
+ pd->is_off = true;
+ pd->name = np->name;
+ pd->base = of_iomap(np, 0);
+ pd->pd.power_off = exynos4_pd_power_off;
+ pd->pd.power_on = exynos4_pd_power_on;
+ pd->pd.of_node = np;
+ pm_genpd_init(&pd->pd, NULL, false);
+ }
+ return;
+#endif /* CONFIG_OF */
+
+no_dt:
+ for (idx = 0; idx < ARRAY_SIZE(exynos4_pm_domains); idx++)
+ pm_genpd_init(&exynos4_pm_domains[idx]->pd, NULL,
+ exynos4_pm_domains[idx]->is_off);
+}
+
static __init int exynos4_pm_drvinit(void)
{
struct clk *pll_base;
unsigned int tmp;
s3c_pm_init();
+ exynos4_pm_init_power_domain();
/* All wakeup disable */
@@ -406,3 +577,11 @@ static __init int exynos4_pm_syscore_init(void)
return 0;
}
arch_initcall(exynos4_pm_syscore_init);
+
+
+static __init int exynos4_pm_late_initcall(void)
+{
+ pm_genpd_poweroff_unused();
+ return 0;
+}
+late_initcall(exynos4_pm_late_initcall);
--
1.6.6.rc2
next prev parent reply other threads:[~2011-12-12 15:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 15:46 [PATCH 0/2] ARM: Exynos: Adapt to generic power domain Thomas Abraham
2011-12-12 15:46 ` [PATCH 1/2] PM / Domains: Add OF support Thomas Abraham
2011-12-12 15:46 ` Thomas Abraham [this message]
2011-12-26 19:06 ` [PATCH 2/2] ARM: Exynos: Hook up power domains to generic power domain infrastructure Mark Brown
2011-12-27 22:16 ` Sylwester Nawrocki
2011-12-27 23:14 ` Sylwester Nawrocki
2011-12-28 5:25 ` Thomas Abraham
2011-12-28 11:09 ` Sylwester Nawrocki
2011-12-28 18:58 ` Sylwester Nawrocki
2012-01-02 2:14 ` Thomas Abraham
2012-01-02 22:19 ` Sylwester Nawrocki
[not found] ` <4F022D7D.3060802-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-03 8:23 ` Thomas Abraham
2012-01-04 7:00 ` Grant Likely
2012-01-04 7:29 ` Kukjin Kim
2011-12-26 11:29 ` [PATCH 1/2] PM / Domains: Add OF support Mark Brown
2011-12-26 19:13 ` Rafael J. Wysocki
2011-12-26 19:24 ` Mark Brown
2011-12-26 20:44 ` Rafael J. Wysocki
2011-12-28 5:10 ` Thomas Abraham
2011-12-28 22:17 ` Rafael J. Wysocki
2012-01-02 3:47 ` Thomas Abraham
2012-01-03 22:30 ` Rafael J. Wysocki
2012-01-05 15:42 ` Thomas Abraham
2012-01-02 6:59 ` Grant Likely
2012-01-03 22:28 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323704789-23923-3-git-send-email-thomas.abraham@linaro.org \
--to=thomas.abraham@linaro.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=kgene.kim@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=patches@linaro.org \
--cc=rjw@sisk.pl \
--cc=rob.herring@calxeda.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).