devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomasz Figa <tomasz.figa@gmail.com>
To: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
	Russell King <linux@arm.linux.org.uk>,
	Kukjin Kim <kgene.kim@samsung.com>,
	Kumar Gala <galak@codeaurora.org>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Mark Rutland <mark.rutland@arm.com>,
	Pawel Moll <pawel.moll@arm.com>, Rob Herring <robh+dt@kernel.org>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Tomasz Figa <t.figa@samsung.com>,
	Tomasz Figa <tomasz.figa@gmail.com>
Subject: [PATCH RFC 06/10] ARM: s3c64xx: pm: Add device tree based power domain instantiation
Date: Sat, 11 Jan 2014 20:42:48 +0100	[thread overview]
Message-ID: <1389469372-17199-7-git-send-email-tomasz.figa@gmail.com> (raw)
In-Reply-To: <1389469372-17199-1-git-send-email-tomasz.figa@gmail.com>

This patch adds support for registering power domains of S3C64xx SoCs
and binding devices to them using device tree.

Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
---
 arch/arm/mach-s3c64xx/pm.c                      | 71 +++++++++++++++++++++----
 include/dt-bindings/arm/s3c64xx-power-domains.h | 26 +++++++++
 2 files changed, 88 insertions(+), 9 deletions(-)
 create mode 100644 include/dt-bindings/arm/s3c64xx-power-domains.h

diff --git a/arch/arm/mach-s3c64xx/pm.c b/arch/arm/mach-s3c64xx/pm.c
index 717d9be..673baaf 100644
--- a/arch/arm/mach-s3c64xx/pm.c
+++ b/arch/arm/mach-s3c64xx/pm.c
@@ -17,8 +17,11 @@
 #include <linux/serial_core.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
 #include <linux/pm_domain.h>
 
+#include <dt-bindings/arm/s3c64xx-power-domains.h>
+
 #include <mach/map.h>
 #include <mach/irqs.h>
 
@@ -164,17 +167,63 @@ static struct s3c64xx_pm_domain s3c64xx_pm_v = {
 	},
 };
 
-static struct s3c64xx_pm_domain *s3c64xx_pm_domains[] = {
-	&s3c64xx_pm_irom,
-	&s3c64xx_pm_etm,
-	&s3c64xx_pm_g,
-	&s3c64xx_pm_v,
-	&s3c64xx_pm_i,
-	&s3c64xx_pm_p,
-	&s3c64xx_pm_s,
-	&s3c64xx_pm_f,
+static struct s3c64xx_pm_domain *s3c64xx_pm_domains[NR_DOMAINS] = {
+	[DOMAIN_V] = &s3c64xx_pm_v,
+	[DOMAIN_G] = &s3c64xx_pm_g,
+	[DOMAIN_I] = &s3c64xx_pm_i,
+	[DOMAIN_P] = &s3c64xx_pm_p,
+	[DOMAIN_F] = &s3c64xx_pm_f,
+	[DOMAIN_S] = &s3c64xx_pm_s,
+	[DOMAIN_ETM] = &s3c64xx_pm_etm,
+	[DOMAIN_IROM] = &s3c64xx_pm_irom,
+};
+
+#ifdef CONFIG_OF
+static struct of_device_id s3c64xx_pd_matches[] = {
+	{ .compatible = "samsung,s3c6400-clock", },
+	{ .compatible = "samsung,s3c6410-clock", },
+	{ },
 };
 
+static struct genpd_onecell_data pd_data;
+
+static int s3c64xx_pm_parse_domains(void)
+{
+	struct device_node *np;
+	int i;
+
+	np = of_find_matching_node(NULL, s3c64xx_pd_matches);
+	if (!np)
+		return -ENODEV;
+
+	pd_data.domains = kcalloc(ARRAY_SIZE(s3c64xx_pm_domains),
+				  sizeof(*pd_data.domains), GFP_KERNEL);
+	if (!pd_data.domains)
+		return -ENOMEM;
+
+	for (i = 0; i < ARRAY_SIZE(s3c64xx_pm_domains); ++i) {
+		struct s3c64xx_pm_domain *pd = s3c64xx_pm_domains[i];
+		struct dev_power_governor *gov = NULL;
+		int on;
+
+		on = __raw_readl(S3C64XX_NORMAL_CFG) & pd->ena;
+
+		if (pd->always_on)
+			gov = &pm_domain_always_on_gov;
+
+		pm_genpd_init(&pd->pd, gov, !on);
+		pd_data.domains[i] = &pd->pd;
+
+		pr_debug("%s: registered domain %s\n", __func__, pd->pd.name);
+	}
+
+	pd_data.domain_num = ARRAY_SIZE(s3c64xx_pm_domains);
+	of_genpd_add_provider(np, of_genpd_xlate_onecell, &pd_data);
+
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK
 void s3c_pm_debug_smdkled(u32 set, u32 clear)
 {
@@ -311,6 +360,10 @@ int __init s3c64xx_pm_init(void)
 
 	s3c_pm_init();
 
+#ifdef CONFIG_OF
+	if (of_have_populated_dt())
+		return s3c64xx_pm_parse_domains();
+#endif
 
 	for (i = 0; i < ARRAY_SIZE(s3c64xx_pm_domains); i++) {
 		struct s3c64xx_pm_domain *pd = s3c64xx_pm_domains[i];
diff --git a/include/dt-bindings/arm/s3c64xx-power-domains.h b/include/dt-bindings/arm/s3c64xx-power-domains.h
new file mode 100644
index 0000000..ce39bef
--- /dev/null
+++ b/include/dt-bindings/arm/s3c64xx-power-domains.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2014 Tomasz Figa <tomasz.figa at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Device Tree binding constants for Samsung S3C64xx power domains.
+*/
+
+#ifndef _DT_BINDINGS_ARM_S3C64XX_POWER_DOMAINS_H
+#define _DT_BINDINGS_ARM_S3C64XX_POWER_DOMAINS_H
+
+#define DOMAIN_V		0
+#define DOMAIN_G		1
+#define DOMAIN_I		2
+#define DOMAIN_P		3
+#define DOMAIN_F		4
+#define DOMAIN_S		5
+#define DOMAIN_ETM		6
+#define DOMAIN_IROM		7
+
+/* Total number of clocks. */
+#define NR_DOMAINS		(DOMAIN_IROM + 1)
+
+#endif /* _DT_BINDINGS_ARM_S3C64XX_POWER_DOMAINS_H */
-- 
1.8.5.2

  parent reply	other threads:[~2014-01-11 19:42 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-11 19:42 [PATCH RFC 00/10] Generic Device Tree based power domain look-up Tomasz Figa
2014-01-11 19:42 ` [PATCH RFC 01/10] ARM: s3c64xx: pm: Use name field of generic_pm_domain Tomasz Figa
2014-01-12 11:47   ` Pavel Machek
2014-01-12 12:16     ` Tomasz Figa
2014-01-12 18:53       ` Pavel Machek
2014-01-12 19:03         ` Tomasz Figa
2014-01-12 19:24           ` Mark Brown
2014-01-12 19:20   ` Mark Brown
2014-01-12 19:25     ` Tomasz Figa
2014-01-11 19:42 ` [PATCH RFC 02/10] ARM: s3c64xx: pm: Add always_on field to s3c64xx_pm_domain struct Tomasz Figa
2014-01-11 19:42 ` [PATCH RFC 03/10] ARM: s3c64xx: pm: Add pwr_stat bit for domain G Tomasz Figa
2014-01-11 19:42 ` [PATCH RFC 04/10] base: power: Add generic OF-based power domain look-up Tomasz Figa
2014-01-14 15:42   ` Kevin Hilman
     [not found]     ` <87r48a8t99.fsf-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-01-20 16:24       ` Tomasz Figa
2014-01-23  0:32         ` Stephen Boyd
2014-01-16 16:34   ` Lorenzo Pieralisi
2014-01-20 17:32     ` Tomasz Figa
2014-01-22 11:00       ` Lorenzo Pieralisi
2014-01-23  0:18   ` Stephen Boyd
     [not found]     ` <20140123001802.GF13785-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2014-01-23  0:31       ` Tomasz Figa
2014-02-24 12:11         ` Ulf Hansson
2014-02-19 16:53   ` Philipp Zabel
2014-02-23 17:07     ` Tomasz Figa
2014-02-24 10:56       ` Philipp Zabel
2014-01-11 19:42 ` [PATCH RFC 05/10] ARM: exynos: Move to generic power domain bindings Tomasz Figa
2014-01-11 19:42 ` Tomasz Figa [this message]
2014-01-12 19:29   ` [PATCH RFC 06/10] ARM: s3c64xx: pm: Add device tree based power domain instantiation Mark Brown
     [not found]     ` <20140112192910.GW29039-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-01-12 19:34       ` Tomasz Figa
2014-01-13 11:09         ` Mark Brown
2014-01-13 12:13           ` Tomasz Figa
2014-01-13 12:17             ` Mark Brown
2014-01-11 19:42 ` [PATCH RFC 07/10] ARM: s3c64xx: dt: Enable SoC-level power management Tomasz Figa
2014-01-11 19:42 ` [PATCH RFC 08/10] ARM: dts: s3c64xx: Add nodes for power domains Tomasz Figa
2014-01-11 19:42 ` [PATCH RFC 09/10] ARM: dts: s3c64xx: Add node for display controller Tomasz Figa
2014-01-11 19:42 ` [PATCH RFC 10/10] ARM: dts: s3c6410-mini6410: Add support for LCD screen Tomasz Figa
2014-01-11 19:52 ` [PATCH RFC 00/10] Generic Device Tree based power domain look-up Tomasz Figa

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=1389469372-17199-7-git-send-email-tomasz.figa@gmail.com \
    --to=tomasz.figa@gmail.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kgene.kim@samsung.com \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=pavel@ucw.cz \
    --cc=pawel.moll@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=swarren@wwwdotorg.org \
    --cc=t.figa@samsung.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).