From patchwork Thu Apr 30 07:05:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6300071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5F3E29F326 for ; Thu, 30 Apr 2015 07:08:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73A08201C0 for ; Thu, 30 Apr 2015 07:08:09 +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 772F12018E for ; Thu, 30 Apr 2015 07:08:08 +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 1YniXt-0005Fh-Ol; Thu, 30 Apr 2015 07:06:05 +0000 Received: from mailout4.w1.samsung.com ([210.118.77.14]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YniXp-00056Y-9D for linux-arm-kernel@lists.infradead.org; Thu, 30 Apr 2015 07:06:02 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NNL00KHIYDBK450@mailout4.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 30 Apr 2015 08:05:35 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-ec-5541d4431d98 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id FB.2D.04846.344D1455; Thu, 30 Apr 2015 08:05:39 +0100 (BST) Received: from localhost.localdomain ([10.252.80.64]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NNL003CTYD3LC20@eusync2.samsung.com>; Thu, 30 Apr 2015 08:05:35 +0100 (BST) From: Krzysztof Kozlowski To: Kukjin Kim , Russell King , Javier Martinez Canillas , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] ARM: EXYNOS: Get current parent clock for power domain on/off Date: Thu, 30 Apr 2015 16:05:24 +0900 Message-id: <1430377525-3145-1-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJLMWRmVeSWpSXmKPExsVy+t/xK7rOVxxDDZ6vkLC4te4cq8XGGetZ La5/ec5qMf8IkDvp/gQWi6O/CyxevzC06H/8mtli0+NrrBaXd81hs5hxfh+Txe3LvBZrj9xl d+D1aGnuYfP4+/w6i8emVZ1sHpuX1Hv0bVnF6PF5k1wAWxSXTUpqTmZZapG+XQJXxubpqgVr 5CvOT+RrYJwi2cXIySEhYCLx/sFXNghbTOLCvfVANheHkMBSRomLx18wQTj/GSVeru5jAali EzCW2Lx8CViHiEAvk8SOG3kgRcwCHUwSjz7OYwVJCAuES6w69I0dxGYRUJX4t3sb0CQODl4B N4m9H2wgtslJnDw2mXUCI/cCRoZVjKKppckFxUnpuYZ6xYm5xaV56XrJ+bmbGCEB9mUH4+Jj VocYBTgYlXh4GaY5hgqxJpYVV+YeYpTgYFYS4ZVYDxTiTUmsrEotyo8vKs1JLT7EKM3BoiTO O3fX+xAhgfTEktTs1NSC1CKYLBMHp1QDow/H+so1lr78fGx9aqnpJVN0o/Kny50L/JKpn3Th Onfn6pmLNj1Z/TXMZMOVKQ4nou4GZCw8f/7j0fIZvPcuKX87LtObf+lX8dL/4icjuS+E/fT6 06H8ZsnhRdcVXM7ozndn66jWeuz+7VUYo8CvZWv6fWucuJKlt2VvL1r5sKa6ZWd1xDWL00os xRmJhlrMRcWJABHYb0QsAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150430_000601_503004_B2EFD72B X-CRM114-Status: GOOD ( 14.93 ) X-Spam-Score: -5.0 (-----) Cc: Krzysztof Kozlowski , Andrzej Hajda , Bartlomiej Zolnierkiewicz , Inki Dae , Chanwoo Choi , Marek Szyprowski 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Using a fixed (by DTS) parent for clocks when turning on the power domain may introduce issues in other drivers. For example when such driver changes the parent during runtime and expects that he is the only place of such change. Do not rely on DTS providing the fixed parent for such clocks. Instead before switching domain off, grab a current parent of a clock with clk_get_parent(). Signed-off-by: Krzysztof Kozlowski Reviewed-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas --- Changes since v2: 1. Don't store the parent of the clock on driver init but instead mark it as -EINVAL. This means that on first power up of the domain (when system is booted with domain being off) the parent won't be set. This is a special rare condition because all domains are being turned on: either by reset value or by bootloader. Javier's reviewed by retained. 2. Add Javier's tags. Changes since v1: 1. Drop "pclk" bindings entirely as suggested by Andrzej Hajda. This was significant change so I did not add Javier's reviewed/tested tags. --- .../devicetree/bindings/arm/exynos/power_domain.txt | 7 ++++--- arch/arm/mach-exynos/pm_domains.c | 16 +++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt index 5da38c5ed476..e151057d92f0 100644 --- a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt +++ b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt @@ -19,9 +19,10 @@ Optional Properties: domains. - clock-names: The following clocks can be specified: - oscclk: Oscillator clock. - - pclkN, clkN: Pairs of parent of input clock and input clock to the - devices in this power domain. Maximum of 4 pairs (N = 0 to 3) - are supported currently. + - clkN: Input clocks to the devices in this power domain. These clocks + will be reparented to oscclk before swithing power domain off. + Their original parent will be brought back after turning on + the domain. Maximum of 4 clocks (N = 0 to 3) are supported. - asbN: Clocks required by asynchronous bridges (ASB) present in the power domain. These clock should be enabled during power domain on/off operations. diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c index cbe56b35aea0..294fc7e956aa 100644 --- a/arch/arm/mach-exynos/pm_domains.c +++ b/arch/arm/mach-exynos/pm_domains.c @@ -62,6 +62,7 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) { if (IS_ERR(pd->clk[i])) break; + pd->pclk[i] = clk_get_parent(pd->clk[i]); if (clk_set_parent(pd->clk[i], pd->oscclk)) pr_err("%s: error setting oscclk as parent to clock %d\n", pd->name, i); @@ -90,6 +91,9 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) { if (IS_ERR(pd->clk[i])) break; + + if (IS_ERR(pd->clk[i])) + continue; /* Skip on first power up */ if (clk_set_parent(pd->clk[i], pd->pclk[i])) pr_err("%s: error setting parent to clock%d\n", pd->name, i); @@ -161,13 +165,11 @@ static __init int exynos4_pm_init_power_domain(void) pd->clk[i] = clk_get(dev, clk_name); if (IS_ERR(pd->clk[i])) break; - snprintf(clk_name, sizeof(clk_name), "pclk%d", i); - pd->pclk[i] = clk_get(dev, clk_name); - if (IS_ERR(pd->pclk[i])) { - clk_put(pd->clk[i]); - pd->clk[i] = ERR_PTR(-EINVAL); - break; - } + /* + * Skip setting parent on first power up. + * The parent at this time may not be useful at all. + */ + pd->pclk[i] = ERR_PTR(-EINVAL); } if (IS_ERR(pd->clk[0]))