From 87d287f036712efd4095fca320c84c93a10399a2 Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Fri, 19 Sep 2014 20:27:42 +0200 Subject: [PATCH] UPSTREAM: amba: Add support for attach/detach of PM domains AMBA devices may on some SoCs resides in PM domains. To be able to manage these devices from there, let's try to attach devices to their corresponding PM domain during the probe phase. To reverse these actions at the remove phase, we try to detach the device from its PM domain. BUG=chrome-os-partner:30167 TEST=Build and boot; future power domain patches can work Change-Id: Ie09d4d80ce73dd8d9ebe52ec717b51035c33ad74 Signed-off-by: Ulf Hansson Reviewed-by: Kevin Hilman Reviewed-by: Dmitry Torokhov Signed-off-by: Rafael J. Wysocki Signed-off-by: Doug Anderson (cherry picked from git.kernel.org rafael/linux-pm.git linux-next commit 207f1a2d294e3781b56d1acecd48aaa3b4b7b2ad) Reviewed-on: https://chromium-review.googlesource.com/217920 Reviewed-by: Dmitry Torokhov --- drivers/amba/bus.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 9e6029105607..356bdfc3a54f 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -182,10 +182,16 @@ static int amba_probe(struct device *dev) int ret; do { - ret = amba_get_enable_pclk(pcdev); - if (ret) + ret = dev_pm_domain_attach(dev, true); + if (ret == -EPROBE_DEFER) break; + ret = amba_get_enable_pclk(pcdev); + if (ret) { + dev_pm_domain_detach(dev, true); + break; + } + pm_runtime_get_noresume(dev); pm_runtime_set_active(dev); pm_runtime_enable(dev); @@ -199,6 +205,7 @@ static int amba_probe(struct device *dev) pm_runtime_put_noidle(dev); amba_put_disable_pclk(pcdev); + dev_pm_domain_detach(dev, true); } while (0); return ret; @@ -220,6 +227,7 @@ static int amba_remove(struct device *dev) pm_runtime_put_noidle(dev); amba_put_disable_pclk(pcdev); + dev_pm_domain_detach(dev, true); return ret; }