From patchwork Thu Feb 6 18:16:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3597521 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 1B9199F382 for ; Thu, 6 Feb 2014 18:17:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3696E20109 for ; Thu, 6 Feb 2014 18:17:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2AD7F2012F for ; Thu, 6 Feb 2014 18:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757012AbaBFSRI (ORCPT ); Thu, 6 Feb 2014 13:17:08 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:12398 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752942AbaBFSRG (ORCPT ); Thu, 6 Feb 2014 13:17:06 -0500 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N0L008QE6SGT1A0@mailout4.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 06 Feb 2014 18:17:04 +0000 (GMT) X-AuditID: cbfec7f4-b7f796d000005a13-64-52f3d19f4b69 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 3C.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 Cc: linux-arm-kernel@lists.infradead.org, Kukjin Kim , Mike Turquette , Rahul Sharma , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Thomas Abraham , Marek Szyprowski , Kyungmin Park , Tomasz Figa Subject: [PATCH v2 2/9] clk: samsung: Provide common helpers for register save/restore Date: Thu, 06 Feb 2014 19:16:49 +0100 Message-id: <1391710616-14226-3-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+NgFmpnluLIzCtJLcpLzFFi42I5/e/4Zd35Fz8HGezp57b4/+g1q0Xvgqts Fmeb3rBbbHp8jdVixvl9TBZrj9xlt3g64SKbxcIX8RbrZ7xmsTg2YwmjA5fHzll32T3uXNvD 5rF5Sb1H35ZVjB7br81j9vi8SS6ALYrLJiU1J7MstUjfLoErY+GDtywFE4Qrns3sZmpgvMzf xcjJISFgIrHxTDMrhC0mceHeerYuRi4OIYGljBKfTl5nh3D6mCTmbr7OBFLFJqAm8bnhERuI LSKgKvG5bQFYEbPAHyaJUzfugiWEBSIkHt7/zAhiswAV/XvaCGbzCjhJdEyZATSIA2idgsTq 60IgJqeAs8TT82DjhYAqpj99yj6BkXcBI8MqRtHU0uSC4qT0XEO94sTc4tK8dL3k/NxNjJDA +7KDcfExq0OMAhyMSjy8J5Z+DhJiTSwrrsw9xCjBwawkwqu5FyjEm5JYWZValB9fVJqTWnyI kYmDU6qBMW+5fdfSGmGxU54TuOTZ3hZYZVx6s9Xiw23TwiN39r1KLO45UXzJ88HRskrWL8sP fHufanjyY/dR4RaWnou/Pbz/CT3SCJjDffCBWW3ETO6rrmEHljL3Hcr5OjNL+oHXL8f5evNK Lrf8vruxRtNwSp/Ap16lVnaR6H9mrlt2HrwyfxlDcLX/VSWW4oxEQy3mouJEAPN0kFoaAgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 As suspend/resume handlers are being moved to SoC specific code, due to differencies in suspend/resume handling of particular SoCs, to minimize code duplication this patch provides common register save/restore helpers that save/restore given list of registers of clock controller. Signed-off-by: Tomasz Figa Acked-by: Kyungmin Park Acked-by: Heiko Stuebner Reviewed-by: Sylwester Nawrocki --- drivers/clk/samsung/clk.c | 32 ++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk.h | 10 ++++++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c index f503f32..c0a716b 100644 --- a/drivers/clk/samsung/clk.c +++ b/drivers/clk/samsung/clk.c @@ -22,6 +22,38 @@ static struct clk_onecell_data clk_data; #endif #ifdef CONFIG_PM_SLEEP +void samsung_clk_save(void __iomem *base, + struct samsung_clk_reg_dump *rd, + unsigned int num_regs) +{ + for (; num_regs > 0; --num_regs, ++rd) + rd->value = readl(base + rd->offset); +} + +void samsung_clk_restore(void __iomem *base, + const struct samsung_clk_reg_dump *rd, + unsigned int num_regs) +{ + for (; num_regs > 0; --num_regs, ++rd) + 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 *rd; + unsigned int i; + + rd = kcalloc(nr_rdump, sizeof(*rd), GFP_KERNEL); + if (!rd) + return NULL; + + for (i = 0; i < nr_rdump; ++i) + rd[i].offset = rdump[i]; + + return rd; +} + static struct samsung_clk_reg_dump *reg_dump; static unsigned long nr_reg_dump; diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index 31b4174..ec8d46b 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -340,4 +340,14 @@ extern void __init samsung_clk_register_pll(struct samsung_pll_clock *pll_list, extern unsigned long _get_rate(const char *clk_name); +extern void samsung_clk_save(void __iomem *base, + struct samsung_clk_reg_dump *rd, + unsigned int num_regs); +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); + #endif /* __SAMSUNG_CLK_H */