From patchwork Thu Sep 6 15:55:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10590809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 933F814BD for ; Thu, 6 Sep 2018 15:56:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87C652ACF0 for ; Thu, 6 Sep 2018 15:56:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C3E82AE96; Thu, 6 Sep 2018 15:56:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 129322ACF0 for ; Thu, 6 Sep 2018 15:56:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730422AbeIFUcJ (ORCPT ); Thu, 6 Sep 2018 16:32:09 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:46889 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730432AbeIFUcJ (ORCPT ); Thu, 6 Sep 2018 16:32:09 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180906155559euoutp01226a8396b59047d081f50efcd49b34a9~R2qc7mxe01529315293euoutp01W; Thu, 6 Sep 2018 15:55:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180906155559euoutp01226a8396b59047d081f50efcd49b34a9~R2qc7mxe01529315293euoutp01W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1536249359; bh=rY/bSwnJXBqprcu8Tamfh60rexcrlVXVTpaEwehjUGU=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=BxefgBhz6rgXJ9FH5gQg1wPCwaQW/biOoJeGOwYBM2CLjK949zb9D2cEFJcAWGUFg 85v8zNKJvyb6V1zvCFwASENbYaSH8+LntMkQXQmdTDr2QkcogHxW0VDzPXw41HlK38 0YnhHvPBSFUhoIyicgAMseCtbPY/m0QUSrh3niYs= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180906155559eucas1p26bae61b57db744cd547c3b88c586903f~R2qch045R2541725417eucas1p2M; Thu, 6 Sep 2018 15:55:59 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 3A.85.04441.E0E419B5; Thu, 6 Sep 2018 16:55:58 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180906155558eucas1p2df01efef605c1261cc8aaf53a7157614~R2qbutfGS0558005580eucas1p2Q; Thu, 6 Sep 2018 15:55:58 +0000 (GMT) X-AuditID: cbfec7f2-5c9ff70000001159-14-5b914e0e6053 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5A.CE.04284.E0E419B5; Thu, 6 Sep 2018 16:55:58 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PEN009IJ5L4PE10@eusync3.samsung.com>; Thu, 06 Sep 2018 16:55:58 +0100 (BST) From: Marek Szyprowski To: linux-clk@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 10/10] clk: samsung: exynos5420: Use generic helper for handling suspend/resume Date: Thu, 06 Sep 2018 17:55:32 +0200 Message-id: <20180906155532.4085-11-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20180906155532.4085-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIIsWRmVeSWpSXmKPExsWy7djP87p8fhOjDU6vs7TYOGM9q8X1L89Z Lc6f38Bu8bHnHqvFjPP7mCzWHrnLbtH+9CWzA7vHplWdbB59W1YxenzeJBfAHMVlk5Kak1mW WqRvl8CVsWLWC6aCNTIVZ55uZ25g/C3excjJISFgInF4znPWLkYuDiGBFYwSl599YoRwPjNK rLhxlBmmasnPBywQiWWMEtufzmIFSQgJNDBJbN4dD2KzCRhKdL3tYgOxRQQcJD5/eg02iVng MaPE1pNfwSYJC6RIzNz+hwnEZhFQlWheMJURxOYVsJXY1HuHEWKbvMTqDQfA6jmB4jPmdoLd JyHwlVWifUoLO0SRi8TH7VugbGGJV8dhbBmJzo6DTBANzYwS7TNmsUM4PUBnzNnBBlFlLXH4 +EWwH5gF+CQmbZsOtI4DKM4r0dEmBFHiIfFpag8zxM8TGCVenTzPMoFRcgEjwypG8dTS4tz0 1GLDvNRyveLE3OLSvHS95PzcTYzAiDv97/inHYxfLyUdYhTgYFTi4X1gNDFaiDWxrLgy9xCj BAezkgive/WEaCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8fFpp0UIC6YklqdmpqQWpRTBZJg5O qQZGj2Uq/f0bpbfv3pmgvPCN1uzr586sdXum+PIdx9Jth7Z9/zwtqrBl4s+92dEsb+elPb2h +3Lqg9SA0zPMGw1nPj3SPu1vjZGB4p63QsU3sk2uV2i+v/pyi8nskg2//c6m+HKkp75a4XD8 /fsPv7puTf5aevBKY8vq24kLPh/3C9rb8vDkJr1HAk1KLMUZiYZazEXFiQCgAtTVtAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHJMWRmVeSWpSXmKPExsVy+t/xq7p8fhOjDZY9FrfYOGM9q8X1L89Z Lc6f38Bu8bHnHqvFjPP7mCzWHrnLbtH+9CWzA7vHplWdbB59W1YxenzeJBfAHMVlk5Kak1mW WqRvl8CVsWLWC6aCNTIVZ55uZ25g/C3excjJISFgIrHk5wOWLkYuDiGBJYwSi7c+Z4Rwmpgk Nr3+xgRSxSZgKNH1tosNxBYRcJD4/Ok1WBGzwGNGiXOLN7CCJIQFUiRmbv8D1sAioCrRvGAq I4jNK2Arsan3DiPEOnmJ1RsOMIPYnEDxGXM7wXqFBGwkVjVOYZ3AyLOAkWEVo0hqaXFuem6x oV5xYm5xaV66XnJ+7iZGYKhsO/Zz8w7GSxuDDzEKcDAq8fBamE6MFmJNLCuuzD3EKMHBrCTC 6149IVqINyWxsiq1KD++qDQntfgQozQHi5I473mDyighgfTEktTs1NSC1CKYLBMHp1QD4zRt vsKFfUXHKwp1nD8d1m7acr27ovjUtVRjlvyId0yWDz8v5Z+qdy+KZf5507P8hwJvn/4p8Pgb K8vH+9tKGOSPGYmffbrt1IucOcwizgrJ23SWTa7c9/voRpkNJuzsR9fGLpzuF8OirVN7MkjB wabwVJr0BL/Dxjvfmk5X05bSq37A++iMjxJLcUaioRZzUXEiACC+MQMRAgAA X-CMS-MailID: 20180906155558eucas1p2df01efef605c1261cc8aaf53a7157614 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180906155558eucas1p2df01efef605c1261cc8aaf53a7157614 References: <20180906155532.4085-1-m.szyprowski@samsung.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace common suspend/resume handling code by generic helper. Almost no functional change, the only difference is in handling of hypothetical memory allocation failure on boot. Signed-off-by: Marek Szyprowski --- drivers/clk/samsung/clk-exynos5420.c | 72 +++------------------------- 1 file changed, 6 insertions(+), 66 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c index 95e1bf69449b..76e7686c6162 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c @@ -15,7 +15,6 @@ #include #include #include -#include #include "clk.h" #include "clk-cpu.h" @@ -156,10 +155,6 @@ enum exynos5x_plls { static void __iomem *reg_base; static enum exynos5x_soc exynos5x_soc; -#ifdef CONFIG_PM_SLEEP -static struct samsung_clk_reg_dump *exynos5x_save; -static struct samsung_clk_reg_dump *exynos5800_save; - /* * list of controller registers to be saved and restored during a * suspend/resume cycle. @@ -283,66 +278,6 @@ static const struct samsung_clk_reg_dump exynos5420_set_clksrc[] = { { .offset = GATE_IP_PERIC, .value = 0xffffffff, }, }; -static int exynos5420_clk_suspend(void) -{ - samsung_clk_save(reg_base, exynos5x_save, - ARRAY_SIZE(exynos5x_clk_regs)); - - if (exynos5x_soc == EXYNOS5800) - samsung_clk_save(reg_base, exynos5800_save, - ARRAY_SIZE(exynos5800_clk_regs)); - - samsung_clk_restore(reg_base, exynos5420_set_clksrc, - ARRAY_SIZE(exynos5420_set_clksrc)); - - return 0; -} - -static void exynos5420_clk_resume(void) -{ - samsung_clk_restore(reg_base, exynos5x_save, - ARRAY_SIZE(exynos5x_clk_regs)); - - if (exynos5x_soc == EXYNOS5800) - samsung_clk_restore(reg_base, exynos5800_save, - ARRAY_SIZE(exynos5800_clk_regs)); -} - -static struct syscore_ops exynos5420_clk_syscore_ops = { - .suspend = exynos5420_clk_suspend, - .resume = exynos5420_clk_resume, -}; - -static void __init exynos5420_clk_sleep_init(void) -{ - exynos5x_save = samsung_clk_alloc_reg_dump(exynos5x_clk_regs, - ARRAY_SIZE(exynos5x_clk_regs)); - if (!exynos5x_save) { - pr_warn("%s: failed to allocate sleep save data, no sleep support!\n", - __func__); - return; - } - - if (exynos5x_soc == EXYNOS5800) { - exynos5800_save = - samsung_clk_alloc_reg_dump(exynos5800_clk_regs, - ARRAY_SIZE(exynos5800_clk_regs)); - if (!exynos5800_save) - goto err_soc; - } - - register_syscore_ops(&exynos5420_clk_syscore_ops); - return; -err_soc: - kfree(exynos5x_save); - pr_warn("%s: failed to allocate sleep save data, no sleep support!\n", - __func__); - return; -} -#else -static void __init exynos5420_clk_sleep_init(void) {} -#endif - /* list of all parent clocks */ PNAME(mout_mspll_cpu_p) = {"mout_sclk_cpll", "mout_sclk_dpll", "mout_sclk_mpll", "mout_sclk_spll"}; @@ -1540,7 +1475,12 @@ static void __init exynos5x_clk_init(struct device_node *np, mout_kfc_p[0], mout_kfc_p[1], 0x28200, exynos5420_kfcclk_d, ARRAY_SIZE(exynos5420_kfcclk_d), 0); - exynos5420_clk_sleep_init(); + samsung_clk_extended_sleep_init(reg_base, + exynos5x_clk_regs, ARRAY_SIZE(exynos5x_clk_regs), + exynos5420_set_clksrc, ARRAY_SIZE(exynos5420_set_clksrc)); + if (soc == EXYNOS5800) + samsung_clk_sleep_init(reg_base, exynos5800_clk_regs, + ARRAY_SIZE(exynos5800_clk_regs)); exynos5_subcmus_init(ctx, ARRAY_SIZE(exynos5x_subcmus), exynos5x_subcmus);