From patchwork Wed Oct 16 11:08:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3052101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B0F2BF924 for ; Wed, 16 Oct 2013 11:10:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BB9820483 for ; Wed, 16 Oct 2013 11:10:54 +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 F40B620481 for ; Wed, 16 Oct 2013 11:10:52 +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 1VWOz3-0005Ev-3O; Wed, 16 Oct 2013 11:09:45 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWOyl-0004rQ-JA; Wed, 16 Oct 2013 11:09:27 +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 1VWOyB-0004lU-Ao for linux-arm-kernel@lists.infradead.org; Wed, 16 Oct 2013 11:08:53 +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:24 +0100 (BST) X-AuditID: cbfec7f4-b7f0a6d000007b1b-3a-525e73a89bab Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 68.BA.31515.8A37E525; Wed, 16 Oct 2013 12:08:24 +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:24 +0100 (BST) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Subject: [PATCH 2/9] clk: samsung: Provide common helpers for register save/restore Date: Wed, 16 Oct 2013 13:08:11 +0200 Message-id: <1381921698-5060-3-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+NgFupgluLIzCtJLcpLzFFi42I5/e/4Nd0VxXFBBh1f9Sz+P3rNatG74Cqb xdmmN+wWmx5fY7WYcX4fk8XTCRfZLKYsOsxqsX7GaxaLYzOWMFq0/93LZjFn+jsmB26PO9f2 sHlsXlLv0bdlFaPH9mvzmD0+b5ILYI3isklJzcksSy3St0vgyng54yhjwVThiklfe9kbGG/w dzFyckgImEjMfruYGcIWk7hwbz1bFyMXh5DAUkaJr2sOMUM4fUwSLTf6warYBNQkPjc8YgOx RQRUJT63LWAHsZkF5jBLnN6n0cXIwSEsECrxd7MDSJgFqOTnriVMIDavgKPEhsuzmCCWKUgs +7IWbCSngJPEpQdTGEFsIaCapb/2sU1g5F3AyLCKUTS1NLmgOCk911CvODG3uDQvXS85P3cT IyT0vuxgXHzM6hCjAAejEg/viajYICHWxLLiytxDjBIczEoivBHBcUFCvCmJlVWpRfnxRaU5 qcWHGJk4OKUaGDXeK86fZHHkVX4MG0tf7iaXqdLXP/sFlFycabLu3uYotpsmTG6Ryq8i37W/ LfZiOb+7lP8OU+miDfkPvlz1jrvDmnjVaaFpxl7dvbYMBZ1/HuZMDmrtbv4X0vJso7X2mqOz k1cKOt9dsaS/QV9AkP/hmdnVnstD3grsSFwo9sk/QbzTldNIUomlOCPRUIu5qDgRAGuwZE8b AgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131016_070851_523215_E3C97542 X-CRM114-Status: UNSURE ( 8.65 ) X-CRM114-Notice: Please train this message. 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 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 Signed-off-by: Kyungmin Park --- 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 */