From patchwork Tue Sep 16 18:48:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 4919321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7164EBEEA5 for ; Tue, 16 Sep 2014 18:53:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 915882010E for ; Tue, 16 Sep 2014 18:53:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE12920179 for ; Tue, 16 Sep 2014 18:53:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XTxqd-0003CM-P2; Tue, 16 Sep 2014 18:51:31 +0000 Received: from albert.telenet-ops.be ([195.130.137.90]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XTxow-0000ju-KZ for linux-arm-kernel@lists.infradead.org; Tue, 16 Sep 2014 18:49:50 +0000 Received: from ayla.of.borg ([84.193.84.167]) by albert.telenet-ops.be with bizsmtp id rup71o0123cczKo06up7Lu; Tue, 16 Sep 2014 20:49:23 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.76) (envelope-from ) id 1XTxoI-0001jZ-Uf; Tue, 16 Sep 2014 20:49:06 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1XTxoP-0001fe-Ma; Tue, 16 Sep 2014 20:49:13 +0200 From: Geert Uytterhoeven To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Simon Horman , Magnus Damm , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala Subject: [PATCH/RFC v2 04/12] PM / Domains: Add genpd attach/detach callbacks Date: Tue, 16 Sep 2014 20:48:51 +0200 Message-Id: <1410893339-6361-5-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410893339-6361-1-git-send-email-geert+renesas@glider.be> References: <1410893339-6361-1-git-send-email-geert+renesas@glider.be> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140916_114946_864027_E729ECCA X-CRM114-Status: GOOD ( 11.18 ) X-Spam-Score: -0.4 (/) Cc: devicetree@vger.kernel.org, Ulf Hansson , Kevin Hilman , Geert Uytterhoeven , linux-pm@vger.kernel.org, linux-sh@vger.kernel.org, Tomasz Figa , linux-kernel@vger.kernel.org, Grygorii Strashko , Philipp Zabel , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 While a PM domain can enable PM runtime management of its devices' module clocks by setting genpd->dev_ops.stop = pm_clk_suspend; genpd->dev_ops.start = pm_clk_resume; this also requires registering the clocks with the pm_clk subsystem. In the legacy case, this is handled by the platform code, after attaching the device to its PM domain. When the devices are instantiated from DT, devices are attached to their PM domains by generic code, leaving no method for the platform-specific PM domain code to register their clocks. Add two callbacks, allowing a PM domain to perform platform-specific tasks when a device is attached to or detached from a PM domain. Signed-off-by: Geert Uytterhoeven Reviewed-by: Ulf Hansson Acked-by: Kevin Hilman --- v2: - New --- drivers/base/power/domain.c | 12 ++++++++++++ include/linux/pm_domain.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index f09b615e61515d11..3fa15b6c54f09b36 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1418,6 +1418,12 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (ret) goto out; + if (genpd->attach_dev) { + ret = genpd->attach_dev(genpd, dev); + if (ret) + goto out; + } + genpd->device_count++; genpd->max_off_time_changed = true; @@ -1541,6 +1547,12 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd, spin_unlock_irq(&dev->power.lock); + if (genpd->detach_dev) { + ret = genpd->detach_dev(genpd, dev); + if (ret) + goto out; + } + mutex_lock(&gpd_data->lock); pdd->dev = NULL; mutex_unlock(&gpd_data->lock); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index ff128c1ec0de231c..ac07918f907b7495 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -73,6 +73,8 @@ struct generic_pm_domain { bool cached_power_down_ok; struct device_node *of_node; /* Node in device tree */ struct gpd_cpu_data *cpu_data; + int (*attach_dev)(struct generic_pm_domain *domain, struct device *dev); + int (*detach_dev)(struct generic_pm_domain *domain, struct device *dev); }; static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)