From patchwork Wed Oct 16 11:08:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3052121 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 9E0FD9F2B7 for ; Wed, 16 Oct 2013 11:12:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A982201FA for ; Wed, 16 Oct 2013 11:12:06 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF350201BF for ; Wed, 16 Oct 2013 11:12:04 +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 1VWOzg-0005ZX-AO; Wed, 16 Oct 2013 11:10:24 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWOz9-0004sn-RD; Wed, 16 Oct 2013 11:09:51 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWOyD-0004lU-9a for linux-arm-kernel@lists.infradead.org; Wed, 16 Oct 2013 11:08:57 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MUR00GEODLNYT70@mailout1.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 16 Oct 2013 12:08:25 +0100 (BST) X-AuditID: cbfec7f4-b7f0a6d000007b1b-3c-525e73a9b17c Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 99.BA.31515.9A37E525; Wed, 16 Oct 2013 12:08:25 +0100 (BST) Received: from amdc1227.digital.local ([106.116.147.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MUR00FDLDLXRKB0@eusync4.samsung.com>; Wed, 16 Oct 2013 12:08:25 +0100 (BST) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Subject: [PATCH 4/9] clk: samsung: exynos5250: Move suspend/resume handling to SoC driver Date: Wed, 16 Oct 2013 13:08:13 +0200 Message-id: <1381921698-5060-5-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.8.3.2 In-reply-to: <1381921698-5060-1-git-send-email-t.figa@samsung.com> References: <1381921698-5060-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkluLIzCtJLcpLzFFi42I5/e/4Nd2VxXFBBuff6lv8f/Sa1aJ3wVU2 i7NNb9gtNj2+xmox4/w+JounEy6yWUxZdJjVYv2M1ywWx2YsYbRo/7uXzWLO9HdMDtwed67t YfPYvKTeo2/LKkaP7dfmMXt83iQXwBrFZZOSmpNZllqkb5fAlbHyy0/mgonKFR8al7A2MM6Q 7WLk5JAQMJG4/WMvG4QtJnHh3nogm4tDSGApo8T51bOZIZw+JonTq76CVbEJqEl8bngEZosI qEp8blvADmIzC8xhlji9TwPEFhaIlujb9R6shgWo5vHJFkYQm1fAUWJJQzc7xDYFiWVf1jKD 2JwCThKXHkwBqxECqln6ax/bBEbeBYwMqxhFU0uTC4qT0nMN9YoTc4tL89L1kvNzNzFCgu/L DsbFx6wOMQpwMCrx8J6Iig0SYk0sK67MPcQowcGsJMIbERwXJMSbklhZlVqUH19UmpNafIiR iYNTqoExt30fL89Lkx/Cqzu4dNLeMHE5qFnv2aJmz/zhZFW9pUhJZYqdtpBztFiT6Mu5Wzje Su18NrG2V/5SKbee+ey2Kt9/NT4N64SUX55986Xq88qQO3vWHbX5dj7Sx+/LCjW5lf9Zv/BF O/HO6D9fFpGz5OEhtWJllbd5hQ0Ltz91nCGr/c1PWUeJpTgj0VCLuag4EQB7qByNHAIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131016_070853_485333_661BF03F X-CRM114-Status: GOOD ( 13.96 ) X-Spam-Score: -4.4 (----) Cc: Yadwinder Singh Brar , Kukjin Kim , Mike Turquette , Heiko Stuebner , Tomasz Figa , Kyungmin Park , Thomas Abraham , Tushar Behera , linux-arm-kernel@lists.infradead.org, Rahul Sharma 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=-1.7 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no 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 Signed-off-by: Kyungmin Park --- drivers/clk/samsung/clk-exynos5250.c | 49 ++++++++++++++++++++++++++++++++---- drivers/clk/samsung/clk.c | 5 ++-- drivers/clk/samsung/clk.h | 4 +-- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c index 93b82db..8c1ce49 100644 --- a/drivers/clk/samsung/clk-exynos5250.c +++ b/drivers/clk/samsung/clk-exynos5250.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "clk.h" @@ -129,6 +130,11 @@ enum exynos5250_clks { nr_clks, }; +static void __iomem *reg_base; + +#ifdef CONFIG_PM_SLEEP +static struct samsung_clk_reg_dump *exynos5250_save; + /* * list of controller registers to be saved and restored during a * suspend/resume cycle. @@ -181,6 +187,41 @@ static unsigned long exynos5250_clk_regs[] __initdata = { GATE_IP_ACP, }; +static int exynos5250_clk_suspend(void) +{ + samsung_clk_save(reg_base, exynos5250_save, + ARRAY_SIZE(exynos5250_clk_regs)); + + return 0; +} + +static void exynos5250_clk_resume(void) +{ + samsung_clk_restore(reg_base, exynos5250_save, + ARRAY_SIZE(exynos5250_clk_regs)); +} + +static struct syscore_ops exynos5250_clk_syscore_ops = { + .suspend = exynos5250_clk_suspend, + .resume = exynos5250_clk_resume, +}; + +static void exynos5250_clk_sleep_init(void) +{ + exynos5250_save = samsung_clk_alloc_reg_dump(exynos5250_clk_regs, + ARRAY_SIZE(exynos5250_clk_regs)); + if (!exynos5250_save) { + pr_warn("%s: failed to allocate sleep save data, no sleep support!\n", + __func__); + return; + } + + register_syscore_ops(&exynos5250_clk_syscore_ops); +} +#else +static void exynos5250_clk_sleep_init(void) {} +#endif + /* list of all parent clock list */ PNAME(mout_apll_p) = { "fin_pll", "fout_apll", }; PNAME(mout_cpu_p) = { "mout_apll", "mout_mpll", }; @@ -650,8 +691,6 @@ static struct of_device_id ext_clk_match[] __initdata = { /* register exynox5250 clocks */ static void __init exynos5250_clk_init(struct device_node *np) { - void __iomem *reg_base; - if (np) { reg_base = of_iomap(np, 0); if (!reg_base) @@ -660,9 +699,7 @@ static void __init exynos5250_clk_init(struct device_node *np) panic("%s: unable to determine soc\n", __func__); } - samsung_clk_init(np, reg_base, nr_clks, - exynos5250_clk_regs, ARRAY_SIZE(exynos5250_clk_regs), - NULL, 0); + samsung_clk_init(np, reg_base, nr_clks, NULL, 0, NULL, 0); samsung_clk_of_register_fixed_ext(exynos5250_fixed_rate_ext_clks, ARRAY_SIZE(exynos5250_fixed_rate_ext_clks), ext_clk_match); @@ -688,6 +725,8 @@ static void __init exynos5250_clk_init(struct device_node *np) samsung_clk_register_gate(exynos5250_gate_clks, ARRAY_SIZE(exynos5250_gate_clks)); + exynos5250_clk_sleep_init(); + pr_info("Exynos5250: clock setup completed, armclk=%ld\n", _get_rate("div_arm2")); } diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c index c0a716b..ec761e3 100644 --- a/drivers/clk/samsung/clk.c +++ b/drivers/clk/samsung/clk.c @@ -38,8 +38,9 @@ void samsung_clk_restore(void __iomem *base, writel(rd->value, base + rd->offset); } -struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump(unsigned long *rdump, - unsigned long nr_rdump) +struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump( + const unsigned long *rdump, + unsigned long nr_rdump) { struct samsung_clk_reg_dump *rd; unsigned int i; diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index ec8d46b..93cb8a0 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -347,7 +347,7 @@ extern void samsung_clk_restore(void __iomem *base, const struct samsung_clk_reg_dump *rd, unsigned int num_regs); extern struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump( - unsigned long *rdump, - unsigned long nr_rdump); + const unsigned long *rdump, + unsigned long nr_rdump); #endif /* __SAMSUNG_CLK_H */