From patchwork Thu Feb 6 18:16:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3597661 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 322BB9F2F5 for ; Thu, 6 Feb 2014 18:21:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3DFEE2012F for ; Thu, 6 Feb 2014 18:21:14 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 3B39C20109 for ; Thu, 6 Feb 2014 18:21:13 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBTXQ-0004jX-HJ; Thu, 06 Feb 2014 18:19:01 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBTWr-0007y2-JO; Thu, 06 Feb 2014 18:18:25 +0000 Received: from mailout3.w1.samsung.com ([210.118.77.13]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBTVy-0007rR-BH for linux-arm-kernel@lists.infradead.org; Thu, 06 Feb 2014 18:17:36 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N0L00FP56SGJAA0@mailout3.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 06 Feb 2014 18:17:04 +0000 (GMT) X-AuditID: cbfec7f4-b7f796d000005a13-68-52f3d19fd673 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id FD.DB.23059.F91D3F25; Thu, 06 Feb 2014 18:17:03 +0000 (GMT) Received: from AMDC1227.digital.local ([106.116.147.199]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N0L00ISD6SBFN00@eusync1.samsung.com>; Thu, 06 Feb 2014 18:17:03 +0000 (GMT) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Subject: [PATCH v2 3/9] clk: samsung: exynos4: Move suspend/resume handling to SoC driver Date: Thu, 06 Feb 2014 19:16:50 +0100 Message-id: <1391710616-14226-4-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.8.5.2 In-reply-to: <1391710616-14226-1-git-send-email-t.figa@samsung.com> References: <1391710616-14226-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphluLIzCtJLcpLzFFi42I5/e/4Zd35Fz8HGcy8qGHx/9FrVoveBVfZ LM42vWG32PT4GqvFjPP7mCzWHrnLbvF0wkU2i4Uv4i3Wz3jNYnFsxhJGBy6PnbPusnvcubaH zWPzknqPvi2rGD22X5vH7PF5k1wAWxSXTUpqTmZZapG+XQJXxv7OXYwFT5Urpn6yb2D8LtvF yMEhIWAi0X8ms4uRE8gUk7hwbz1bFyMXh5DAUkaJ4ycfs0I4fUwSczdfZwKpYhNQk/jc8IgN xBYRUJX43LaAHaSIWeAPk8SpG3fBEsIC0RKzXkLYLEBFf4/OZwXZxivgJLH+pyfEYgWJ1deF QExOAWeJp+fBpgsBFUx/+pR9AiPvAkaGVYyiqaXJBcVJ6bmGesWJucWleel6yfm5mxghIfdl B+PiY1aHGAU4GJV4eE8s/RwkxJpYVlyZe4hRgoNZSYRXcy9QiDclsbIqtSg/vqg0J7X4ECMT B6dUAyOjil6WAquy4qmw1gb5F3sWLGNaaDl9v+Hia54HFp9aNWe1yQEF27MPVqyp1rL/wal9 dD1T2I4v6VLyLG6pLt93nt0q+2SK0BHeZQ8Ul5SfWHDo2+FgJqWFjYuOaQj+zwoXM2f5YG9c Mau8UUB9akiKFwN3vMF/lWWFkrxH1C6YNU5+39jBvFaJpTgj0VCLuag4EQDEF78XFwIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140206_131730_532313_B281C613 X-CRM114-Status: GOOD ( 12.47 ) X-Spam-Score: -7.4 (-------) Cc: Kukjin Kim , Mike Turquette , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Tomasz Figa , Kyungmin Park , Thomas Abraham , Rahul Sharma , linux-arm-kernel@lists.infradead.org, Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Since there are multiple differences in how suspend/resume of particular Exynos SoCs must be handled, SoC driver is better place for suspend/resume handlers and so this patch moves them. Signed-off-by: Tomasz Figa Acked-by: Kyungmin Park --- drivers/clk/samsung/clk-exynos4.c | 90 ++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 10 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c index 12a9f28..325f292 100644 --- a/drivers/clk/samsung/clk-exynos4.c +++ b/drivers/clk/samsung/clk-exynos4.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "clk.h" @@ -130,6 +131,16 @@ enum exynos4_plls { nr_plls /* number of PLLs */ }; +static void __iomem *reg_base; +static enum exynos4_soc exynos4_soc; + +/* + * Support for CMU save/restore across system suspends + */ +#ifdef CONFIG_PM_SLEEP +static struct samsung_clk_reg_dump *exynos4_save_common; +static struct samsung_clk_reg_dump *exynos4_save_soc; + /* * list of controller registers to be saved and restored during a * suspend/resume cycle. @@ -227,6 +238,70 @@ static unsigned long exynos4_clk_regs[] __initdata = { GATE_IP_CPU, }; +static int exynos4_clk_suspend(void) +{ + samsung_clk_save(reg_base, exynos4_save_common, + ARRAY_SIZE(exynos4_clk_regs)); + + if (exynos4_soc == EXYNOS4210) + samsung_clk_save(reg_base, exynos4_save_soc, + ARRAY_SIZE(exynos4210_clk_save)); + else + samsung_clk_save(reg_base, exynos4_save_soc, + ARRAY_SIZE(exynos4x12_clk_save)); + + return 0; +} + +static void exynos4_clk_resume(void) +{ + samsung_clk_restore(reg_base, exynos4_save_common, + ARRAY_SIZE(exynos4_clk_regs)); + + if (exynos4_soc == EXYNOS4210) + samsung_clk_restore(reg_base, exynos4_save_soc, + ARRAY_SIZE(exynos4210_clk_save)); + else + samsung_clk_restore(reg_base, exynos4_save_soc, + ARRAY_SIZE(exynos4x12_clk_save)); +} + +static struct syscore_ops exynos4_clk_syscore_ops = { + .suspend = exynos4_clk_suspend, + .resume = exynos4_clk_resume, +}; + +static void exynos4_clk_sleep_init(void) +{ + exynos4_save_common = samsung_clk_alloc_reg_dump(exynos4_clk_regs, + ARRAY_SIZE(exynos4_clk_regs)); + if (!exynos4_save_common) + goto err_warn; + + if (exynos4_soc == EXYNOS4210) + exynos4_save_soc = samsung_clk_alloc_reg_dump( + exynos4210_clk_save, + ARRAY_SIZE(exynos4210_clk_save)); + else + exynos4_save_soc = samsung_clk_alloc_reg_dump( + exynos4x12_clk_save, + ARRAY_SIZE(exynos4x12_clk_save)); + if (!exynos4_save_soc) + goto err_common; + + register_syscore_ops(&exynos4_clk_syscore_ops); + return; + +err_common: + kfree(exynos4_save_common); +err_warn: + pr_warn("%s: failed to allocate sleep save data, no sleep support!\n", + __func__); +} +#else +static void exynos4_clk_sleep_init(void) {} +#endif + /* list of all parent clock list */ PNAME(mout_apll_p) = { "fin_pll", "fout_apll", }; PNAME(mout_mpll_p) = { "fin_pll", "fout_mpll", }; @@ -1039,22 +1114,15 @@ static struct samsung_pll_clock exynos4x12_plls[nr_plls] __initdata = { /* register exynos4 clocks */ static void __init exynos4_clk_init(struct device_node *np, - enum exynos4_soc exynos4_soc) + enum exynos4_soc soc) { - void __iomem *reg_base; + exynos4_soc = soc; reg_base = of_iomap(np, 0); if (!reg_base) panic("%s: failed to map registers\n", __func__); - if (exynos4_soc == EXYNOS4210) - samsung_clk_init(np, reg_base, CLK_NR_CLKS, - exynos4_clk_regs, ARRAY_SIZE(exynos4_clk_regs), - exynos4210_clk_save, ARRAY_SIZE(exynos4210_clk_save)); - else - samsung_clk_init(np, reg_base, CLK_NR_CLKS, - exynos4_clk_regs, ARRAY_SIZE(exynos4_clk_regs), - exynos4x12_clk_save, ARRAY_SIZE(exynos4x12_clk_save)); + samsung_clk_init(np, reg_base, CLK_NR_CLKS, NULL, 0, NULL, 0); samsung_clk_of_register_fixed_ext(exynos4_fixed_rate_ext_clks, ARRAY_SIZE(exynos4_fixed_rate_ext_clks), @@ -1127,6 +1195,8 @@ static void __init exynos4_clk_init(struct device_node *np, samsung_clk_register_alias(exynos4_aliases, ARRAY_SIZE(exynos4_aliases)); + exynos4_clk_sleep_init(); + pr_info("%s clocks: sclk_apll = %ld, sclk_mpll = %ld\n" "\tsclk_epll = %ld, sclk_vpll = %ld, arm_clk = %ld\n", exynos4_soc == EXYNOS4210 ? "Exynos4210" : "Exynos4x12",