From patchwork Tue Oct 20 13:26:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 7447481 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 473D6BEEA4 for ; Tue, 20 Oct 2015 13:29:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 07C9220867 for ; Tue, 20 Oct 2015 13:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F9A62073A for ; Tue, 20 Oct 2015 13:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752812AbbJTN2x (ORCPT ); Tue, 20 Oct 2015 09:28:53 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:35657 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752194AbbJTN0m (ORCPT ); Tue, 20 Oct 2015 09:26:42 -0400 Received: by wicll6 with SMTP id ll6so45435930wic.0 for ; Tue, 20 Oct 2015 06:26:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5plFGZuC2C8iAaZiPGJZl1nBKMPYLHYBJfWSIN05l6g=; b=ZRrB3CEB9I6Thy9PkjmCAfTtR0tdDu9JGWA2CCeiYL/O7hktkR8U3/68WhWv8b/Voo 55MXZ+QmhBt2vSh3QUUT4lJ/5lU2TTDjEPYuBbX6stMj0qR9k/8b7mK3gs+A0d4U3pno hbApGEsrETsAtPq+t2+jGZ4XtC7HyaFKaNKx4+z/3IrE3i+x5tvjPr4zqBAadgx/tysf l5+49Yh14V8cmdJ/4PCqMfs5uYBPP29wRYqHAWfd1JdYytmdVcjoletF1J8n1Yv0yyWT azweiBPRWEKsnQCVePSRCuACAriht1Ybt2FyNCswt+A72iet1hLsvLWIsWkROp6Gpfhe shOA== X-Gm-Message-State: ALoCoQkJUAdYZYdH6fzTGfOBSBz0PPokYhMpUI0Vimbp1S5Q0M5PewHl/TtS4UC5VDIbGoRXPOKt X-Received: by 10.180.35.163 with SMTP id i3mr29348691wij.55.1445347601142; Tue, 20 Oct 2015 06:26:41 -0700 (PDT) Received: from localhost.localdomain (cag06-6-78-235-100-105.fbx.proxad.net. [78.235.100.105]) by smtp.gmail.com with ESMTPSA id uq5sm3905098wjc.3.2015.10.20.06.26.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Oct 2015 06:26:40 -0700 (PDT) From: ahaslam@baylibre.com To: khilman@linaro.org, ulf.hansson@linaro.org, lina.iyer@linaro.org, geert@glider.be, k.kozlowski.k@gmail.com, rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: bcousson@baylibre.com, mturquette@baylibre.com, Axel Haslam Subject: [PATCH v10 1/6] PM / Domains: prepare for multiple states Date: Tue, 20 Oct 2015 15:26:24 +0200 Message-Id: <1445347589-5626-2-git-send-email-ahaslam@baylibre.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1445347589-5626-1-git-send-email-ahaslam@baylibre.com> References: <1445347589-5626-1-git-send-email-ahaslam@baylibre.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Axel Haslam prepare generic power domain init function parameters to accept a pointer to the states structure that describes the possible states that a power domain can enter. Also, as most platforms are not initializing states or latencies, add pm_genpd_init_simple that allows platfroms to use a default single OFF state with initial latencies set to 0. There is no functional change, as support for multiple domains will be added in subsequent patches. Suggested-by: Lina Iyer Signed-off-by: Axel Haslam --- arch/arm/mach-exynos/pm_domains.c | 2 +- arch/arm/mach-imx/gpc.c | 2 +- arch/arm/mach-s3c64xx/pm.c | 4 ++-- arch/arm/mach-shmobile/pm-rmobile.c | 2 +- arch/arm/mach-ux500/pm_domains.c | 2 +- arch/arm/mach-zx/zx296702-pm-domain.c | 2 +- drivers/base/power/domain.c | 19 ++++++++++++++++++- drivers/clk/qcom/gdsc.c | 2 +- drivers/clk/shmobile/clk-mstp.c | 2 +- drivers/soc/dove/pmu.c | 2 +- drivers/soc/mediatek/mtk-scpsys.c | 2 +- drivers/soc/rockchip/pm_domains.c | 2 +- include/linux/pm_domain.h | 27 ++++++++++++++++++++++++++- 13 files changed, 56 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c index 7c21760..dc36723 100644 --- a/arch/arm/mach-exynos/pm_domains.c +++ b/arch/arm/mach-exynos/pm_domains.c @@ -187,7 +187,7 @@ static __init int exynos4_pm_init_power_domain(void) no_clk: on = __raw_readl(pd->base + 0x4) & INT_LOCAL_PWR_EN; - pm_genpd_init(&pd->pd, NULL, !on); + pm_genpd_init_simple(&pd->pd, NULL, !on); of_genpd_add_provider_simple(np, &pd->pd); } diff --git a/arch/arm/mach-imx/gpc.c b/arch/arm/mach-imx/gpc.c index 10bf715..aefe92d 100644 --- a/arch/arm/mach-imx/gpc.c +++ b/arch/arm/mach-imx/gpc.c @@ -422,7 +422,7 @@ static int imx_gpc_genpd_init(struct device *dev, struct regulator *pu_reg) if (!IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) return 0; - pm_genpd_init(&imx6q_pu_domain.base, NULL, false); + pm_genpd_init_simple(&imx6q_pu_domain.base, NULL, false); return of_genpd_add_provider_onecell(dev->of_node, &imx_gpc_onecell_data); diff --git a/arch/arm/mach-s3c64xx/pm.c b/arch/arm/mach-s3c64xx/pm.c index 75b14e7..d68a45c 100644 --- a/arch/arm/mach-s3c64xx/pm.c +++ b/arch/arm/mach-s3c64xx/pm.c @@ -316,11 +316,11 @@ int __init s3c64xx_pm_init(void) s3c_pm_init(); for (i = 0; i < ARRAY_SIZE(s3c64xx_always_on_pm_domains); i++) - pm_genpd_init(&s3c64xx_always_on_pm_domains[i]->pd, + pm_genpd_init_simple(&s3c64xx_always_on_pm_domains[i]->pd, &pm_domain_always_on_gov, false); for (i = 0; i < ARRAY_SIZE(s3c64xx_pm_domains); i++) - pm_genpd_init(&s3c64xx_pm_domains[i]->pd, NULL, false); + pm_genpd_init_simple(&s3c64xx_pm_domains[i]->pd, NULL, false); #ifdef CONFIG_S3C_DEV_FB if (dev_get_platdata(&s3c_device_fb.dev)) diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c index 46d0a1d..906a2eb 100644 --- a/arch/arm/mach-shmobile/pm-rmobile.c +++ b/arch/arm/mach-shmobile/pm-rmobile.c @@ -131,7 +131,7 @@ static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd) struct dev_power_governor *gov = rmobile_pd->gov; genpd->flags = GENPD_FLAG_PM_CLK; - pm_genpd_init(genpd, gov ? : &simple_qos_governor, false); + pm_genpd_init_simple(genpd, gov ? : &simple_qos_governor, false); genpd->dev_ops.active_wakeup = rmobile_pd_active_wakeup; genpd->power_off = rmobile_pd_power_down; genpd->power_on = rmobile_pd_power_up; diff --git a/arch/arm/mach-ux500/pm_domains.c b/arch/arm/mach-ux500/pm_domains.c index 4d71c90..208e784 100644 --- a/arch/arm/mach-ux500/pm_domains.c +++ b/arch/arm/mach-ux500/pm_domains.c @@ -72,7 +72,7 @@ int __init ux500_pm_domains_init(void) genpd_data->num_domains = ARRAY_SIZE(ux500_pm_domains); for (i = 0; i < ARRAY_SIZE(ux500_pm_domains); ++i) - pm_genpd_init(ux500_pm_domains[i], NULL, false); + pm_genpd_init_simple(ux500_pm_domains[i], NULL, false); of_genpd_add_provider_onecell(np, genpd_data); return 0; diff --git a/arch/arm/mach-zx/zx296702-pm-domain.c b/arch/arm/mach-zx/zx296702-pm-domain.c index e08574d..0ec8f0c 100644 --- a/arch/arm/mach-zx/zx296702-pm-domain.c +++ b/arch/arm/mach-zx/zx296702-pm-domain.c @@ -175,7 +175,7 @@ static int zx296702_pd_probe(struct platform_device *pdev) } for (i = 0; i < ARRAY_SIZE(zx296702_pm_domains); ++i) - pm_genpd_init(zx296702_pm_domains[i], NULL, false); + pm_genpd_init_simple(zx296702_pm_domains[i], NULL, false); of_genpd_add_provider_onecell(pdev->dev.of_node, genpd_data); return 0; diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index b0b5c43..e0b5229 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1447,10 +1447,14 @@ static int pm_genpd_default_restore_state(struct device *dev) * pm_genpd_init - Initialize a generic I/O PM domain object. * @genpd: PM domain object to initialize. * @gov: PM domain governor to associate with the domain (may be NULL). + * @states: Array of possible low power states when powering off. + * @state_count: Number of low power states. * @is_off: Initial value of the domain's power_is_off field. */ void pm_genpd_init(struct generic_pm_domain *genpd, - struct dev_power_governor *gov, bool is_off) + struct dev_power_governor *gov, + const struct genpd_power_state *states, + unsigned int state_count, bool is_off) { if (IS_ERR_OR_NULL(genpd)) return; @@ -1502,6 +1506,19 @@ void pm_genpd_init(struct generic_pm_domain *genpd, } EXPORT_SYMBOL_GPL(pm_genpd_init); +/** + * pm_genpd_init_simple - Initialize a generic I/O PM domain object. + * @genpd: PM domain object to initialize. + * @gov: PM domain governor to associate with the domain (may be NULL). + * @is_off: Initial value of the domain's power_is_off field. + */ +void pm_genpd_init_simple(struct generic_pm_domain *genpd, + struct dev_power_governor *gov, bool is_off) +{ + pm_genpd_init(genpd, gov, NULL, 0, is_off); +} +EXPORT_SYMBOL_GPL(pm_genpd_init_simple); + #ifdef CONFIG_PM_GENERIC_DOMAINS_OF /* * Device Tree based PM domain providers. diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index da9fad8..b709bf3 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -196,7 +196,7 @@ static int gdsc_init(struct gdsc *sc) sc->pd.power_off = gdsc_disable; sc->pd.power_on = gdsc_enable; - pm_genpd_init(&sc->pd, NULL, !on); + pm_genpd_init_simple(&sc->pd, NULL, !on); return 0; } diff --git a/drivers/clk/shmobile/clk-mstp.c b/drivers/clk/shmobile/clk-mstp.c index 3b09716..1f18474 100644 --- a/drivers/clk/shmobile/clk-mstp.c +++ b/drivers/clk/shmobile/clk-mstp.c @@ -320,7 +320,7 @@ void __init cpg_mstp_add_clk_domain(struct device_node *np) pd->name = np->name; pd->flags = GENPD_FLAG_PM_CLK; - pm_genpd_init(pd, &simple_qos_governor, false); + pm_genpd_init_simple(pd, &simple_qos_governor, false); pd->attach_dev = cpg_mstp_attach_dev; pd->detach_dev = cpg_mstp_detach_dev; diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c index abd0879..42adc16 100644 --- a/drivers/soc/dove/pmu.c +++ b/drivers/soc/dove/pmu.c @@ -215,7 +215,7 @@ static void __pmu_domain_register(struct pmu_domain *domain, domain->base.power_off = pmu_domain_power_off; domain->base.power_on = pmu_domain_power_on; - pm_genpd_init(&domain->base, NULL, !(val & domain->pwr_mask)); + pm_genpd_init_simple(&domain->base, NULL, !(val & domain->pwr_mask)); if (np) of_genpd_add_provider_simple(np, &domain->base); diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index 164a7d8..adf364f 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -443,7 +443,7 @@ static int __init scpsys_probe(struct platform_device *pdev) */ genpd->power_on(genpd); - pm_genpd_init(genpd, NULL, false); + pm_genpd_init_simple(genpd, NULL, false); } /* diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c index 534c589..617e219 100644 --- a/drivers/soc/rockchip/pm_domains.c +++ b/drivers/soc/rockchip/pm_domains.c @@ -299,7 +299,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, pd->genpd.attach_dev = rockchip_pd_attach_dev; pd->genpd.detach_dev = rockchip_pd_detach_dev; pd->genpd.flags = GENPD_FLAG_PM_CLK; - pm_genpd_init(&pd->genpd, NULL, false); + pm_genpd_init_simple(&pd->genpd, NULL, false); pmu->genpd_data.domains[id] = &pd->genpd; return 0; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f4dd810..f37faec 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -37,6 +37,17 @@ struct gpd_dev_ops { bool (*active_wakeup)(struct device *dev); }; +struct gpd_cpuidle_data { + unsigned int saved_exit_latency; + struct cpuidle_state *idle_state; +}; + +struct genpd_power_state { + char *name; + s64 power_off_latency_ns; + s64 power_on_latency_ns; +}; + struct generic_pm_domain { struct dev_pm_domain domain; /* PM domain operations */ struct list_head gpd_list_node; /* Node in the global PM domains list */ @@ -124,7 +135,14 @@ extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, struct generic_pm_domain *target); extern void pm_genpd_init(struct generic_pm_domain *genpd, + struct dev_power_governor *gov, + const struct genpd_power_state *states, + unsigned int state_count, bool is_off); +extern void pm_genpd_init_simple(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off); +extern int pm_genpd_poweron(struct generic_pm_domain *genpd); +extern int pm_genpd_name_poweron(const char *domain_name); +extern void pm_genpd_poweroff_unused(void); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -160,7 +178,14 @@ static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, return -ENOSYS; } static inline void pm_genpd_init(struct generic_pm_domain *genpd, - struct dev_power_governor *gov, bool is_off) + struct dev_power_governor *gov, + const struct genpd_power_state *states, + unsigned int state_count, bool is_off) +{ +} +static inline void pm_genpd_init_simple(struct generic_pm_domain *genpd, + struct dev_power_governor *gov, + bool is_off) { } #endif