From: snjw23@gmail.com (Sylwester Nawrocki)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: Exynos: Hook up power domains to generic power domain infrastructure
Date: Wed, 28 Dec 2011 00:14:28 +0100 [thread overview]
Message-ID: <4EFA5154.9060606@gmail.com> (raw)
In-Reply-To: <1323704789-23923-3-git-send-email-thomas.abraham@linaro.org>
Hi Thomas,
On 12/12/2011 04:46 PM, Thomas Abraham wrote:
> 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,
> + },
> +};
I'm not sure if arch/arm/mach-exynos/pm.c is the right place to add this.
IMHO it would be much better to put PD in separate file, pm-runtime.c
or something like this.
Can we assume various exynos versions will have same S5P_PMU_*_CONF
addresses? For old s3c64xx SoCs such assumption could be valid but I'm
a bit uncertain about Exynos series.
IMHO the proper way to proceed would be to convert Samsung power domains
to generic power domains and then add device tree support. Rather than
doing a sort of work around. Much of the conversion to genpd work have
been already done [1]. We would perhaps just need to drop the clock gating
as there seem to be no agreement about this.
[1]. http://www.mail-archive.com/linux-samsung-soc at vger.kernel.org/msg07431.html
--
Thanks,
Sylwester
next prev parent reply other threads:[~2011-12-27 23:14 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 ` [PATCH 2/2] ARM: Exynos: Hook up power domains to generic power domain infrastructure Thomas Abraham
2011-12-26 19:06 ` Mark Brown
2011-12-27 22:16 ` Sylwester Nawrocki
2011-12-27 23:14 ` Sylwester Nawrocki [this message]
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
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=4EFA5154.9060606@gmail.com \
--to=snjw23@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).