From patchwork Thu Sep 6 15:55:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 146106 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp38482ljw; Thu, 6 Sep 2018 08:56:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbEjMvkbcO2n3y1CPg7p8KFktjwFgD6k2UFlBqfQSDQNBv7IPUlObdqqn+QJhlapDF2RyCB X-Received: by 2002:a63:4204:: with SMTP id p4-v6mr3392932pga.200.1536249362804; Thu, 06 Sep 2018 08:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536249362; cv=none; d=google.com; s=arc-20160816; b=noVDaJlGH0ZnJ0wr9h5iFyREZ7WzXABXWM84bziTtoaSPjkirehCpuqJUeySTY6r+t yrOidNEB9NA6Y+bJNNVi0IKpupIE0jCLrYPs2c0XfbDPuUZkLQrkYHlz8dTaU7+lNFvn VWkcbANf3X+fDlTxVZyUsBUJgY4XOwjsKj7AcbRPQIu2A7R8IJOgdyU8OrTfPuIQMk/U 6UZcN9r3g+VY5R0R1eCqoTTJoRkXYlWOCuyPp+l8eyY8f4WFttza17FJi6i9m5NcCVZm KhiYlgw+RE4uiKxysIK25yT6hGdPm5ntUrGpMySG0SSJNBqnGR7BIH4+cztRVIi4jfXp xcDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=ZzRNgv7l9G4MMJjfXIpCYY4RwcjeLSwooGe7of1Z+c8=; b=RBu9CBOXoNd7Elf4WBBjCwGmYBCHZyCX7iDGzr5IF7jV0fRXpWuiE9RmzucFannOOL x2hEPzGeCrI9Fn3ccGbl9TvCKf1hz9EqV72fThebn3oyHoftUTCb1NAswRP6vJpX90qf 6QZx/yBFIPFid5OxvA8z5zC8r+YFZCkU2TIBmNCsVKhK8+23DzQh6f8Zc17DthK2RHcP YiqU7YbRsGoDARZGMwjkoeFhV6SF+kBssD0x5Pn26jLfr8bylzVKtnepanhf2B0KVlNZ qiy3wJU50dURBwdUi7chi08FdA7Bd3Yvmdsl0neUF2InIaTakRGiqJxbT4C/aXrg5I9A /qYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=O1puGGMO; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k18-v6si5180597pff.91.2018.09.06.08.56.02; Thu, 06 Sep 2018 08:56:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=O1puGGMO; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730447AbeIFUcJ (ORCPT + 3 others); Thu, 6 Sep 2018 16:32:09 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:59532 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730413AbeIFUcI (ORCPT ); Thu, 6 Sep 2018 16:32:08 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180906155558euoutp025b77b8a2343411a8dc8262060132248f~R2qcQL-T63096130961euoutp02W; Thu, 6 Sep 2018 15:55:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180906155558euoutp025b77b8a2343411a8dc8262060132248f~R2qcQL-T63096130961euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1536249359; bh=ZzRNgv7l9G4MMJjfXIpCYY4RwcjeLSwooGe7of1Z+c8=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=O1puGGMOnM0w2bpskngejOR2Jkk29rBvVJTY9uJnASTlKmD0O1WKn/crogKX20QYE gb1UPrt7i0zdV1zwJHJ/mcPyWcDhPuKkK5fdXgr1LcELM1MbdxErySvzbTMoC8mJ79 P8TaYQONpYGcdWur+zpCCxudsgSnmQ09VszX1Ins= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180906155558eucas1p2b71242ff65c451e69057b39ed0f0ff4b~R2qbyRExt0454104541eucas1p2W; Thu, 6 Sep 2018 15:55:58 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 56.31.04806.E0E419B5; Thu, 6 Sep 2018 16:55:58 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180906155557eucas1p2e964b85aa74304c458807ee2f7ffeea7~R2qbFETrQ0610806108eucas1p2k; Thu, 6 Sep 2018 15:55:57 +0000 (GMT) X-AuditID: cbfec7f5-34dff700000012c6-9e-5b914e0e2fc1 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 79.DC.04128.D0E419B5; Thu, 6 Sep 2018 16:55:57 +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:57 +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 08/10] clk: samsung: Add support for setting registers state before suspend Date: Thu, 06 Sep 2018 17:55:30 +0200 Message-id: <20180906155532.4085-9-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+NgFlrIIsWRmVeSWpSXmKPExsWy7djP87p8fhOjDX5v5LbYOGM9q8X1L89Z Lc6f38Bu8bHnHqvFjPP7mCzWHrnLbtH+9CWzA7vHplWdbB59W1YxenzeJBfAHMVlk5Kak1mW WqRvl8CVcevjDNaCFXIVDzsusjcwHpHsYuTkkBAwkdh8vpGti5GLQ0hgBaPE6ev/2EESQgKf GSXurAyGKWr+dpodomgZo8T0c73MEE4Dk8T81asZQarYBAwlut52sYHYIgIOEp8/vWYEKWIW eMwosfXkV2aQhLBAgsT0i3PBGlgEVCWWrX0Ato5XwEbixL+77BDr5CVWbzgAVs8pYCsxY24n K8ggCYGvrBL776+FKnKRONHdyQJhC0u8Or4FKi4jcXlyNwtEQzOjRPuMWewQTg/QGXN2sEFU WUscPn6RFcRmFuCTmLRtOtA6DqA4r0RHmxBEiYfEhSlfWSD+nMAosazxAOsERskFjAyrGMVT S4tz01OLjfNSy/WKE3OLS/PS9ZLzczcxAiPu9L/jX3cw7vuTdIhRgINRiYf3gdHEaCHWxLLi ytxDjBIczEoivO7VE6KFeFMSK6tSi/Lji0pzUosPMUpzsCiJ8/JppUULCaQnlqRmp6YWpBbB ZJk4OKUaGItu+m/rXGn40m0KM3u/etyC0/xZyzdtPW52qf1a0ne2xl+L/q/9dM9tvc7FbSkm oZl3gs8uXbZOVUNNYO95187tkdkTT+ccY+It23bKZN52rW+/J85eUfimiaU/6Zx+vYX6d73V QV4Jh300NpWJsAv4M8+aW7nz0P8H5n+OG5fcPSx3d97KnjtKLMUZiYZazEXFiQAGmv0XtAIA AA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHJMWRmVeSWpSXmKPExsVy+t/xq7q8fhOjDWYu0bDYOGM9q8X1L89Z Lc6f38Bu8bHnHqvFjPP7mCzWHrnLbtH+9CWzA7vHplWdbB59W1YxenzeJBfAHMVlk5Kak1mW WqRvl8CVcevjDNaCFXIVDzsusjcwHpHsYuTkkBAwkWj+dpq9i5GLQ0hgCaPEhoYrTBBOE5NE x4ZFbCBVbAKGEl1vu8BsEQEHic+fXjOCFDELPGaUOLd4AytIQlggQeLchgZmEJtFQFVi2doH 7CA2r4CNxIl/d9kh1slLrN5wAKyGU8BWYsbcTrBeIaCaVY1TWCcw8ixgZFjFKJJaWpybnlts pFecmFtcmpeul5yfu4kRGCrbjv3csoOx613wIUYBDkYlHl4L04nRQqyJZcWVuYcYJTiYlUR4 3asnRAvxpiRWVqUW5ccXleakFh9ilOZgURLnPW9QGSUkkJ5YkpqdmlqQWgSTZeLglGpg7Lg9 7e6ZN/eUtN6eb2hZNHWN4tbV+4SfBZSWap7cbsV24uHFZeKc3b7b7zzVadNXlNkpurracf9q zTaHDesyli6qfZLDNMFzgamLVy9X4J6shXtcQ8KlE06r+cdMmmkdo5TdknzH+7XPQqP6xd/u LFhQHCVr1xCQYXryadCGLscr5uWdYXdWK7EUZyQaajEXFScCADUnA5wRAgAA X-CMS-MailID: 20180906155557eucas1p2e964b85aa74304c458807ee2f7ffeea7 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180906155557eucas1p2e964b85aa74304c458807ee2f7ffeea7 References: <20180906155532.4085-1-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Some registers of clock controller have to be set to certain values before entering system suspend state. Till now drivers did that on their own, but it will be easier to handle it by generic code and let drivers simply to provide the list of registers and their state. Signed-off-by: Marek Szyprowski --- drivers/clk/samsung/clk.c | 23 +++++++++++++---------- drivers/clk/samsung/clk.h | 18 ++++++++++++++++-- 2 files changed, 29 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c index 8634884aa11c..1f6e47cd327d 100644 --- a/drivers/clk/samsung/clk.c +++ b/drivers/clk/samsung/clk.c @@ -290,9 +290,12 @@ static int samsung_clk_suspend(void) { struct samsung_clock_reg_cache *reg_cache; - list_for_each_entry(reg_cache, &clock_reg_cache_list, node) + list_for_each_entry(reg_cache, &clock_reg_cache_list, node) { samsung_clk_save(reg_cache->reg_base, reg_cache->rdump, reg_cache->rd_num); + samsung_clk_restore(reg_cache->reg_base, reg_cache->rsuspend, + reg_cache->rsuspend_num); + } return 0; } @@ -310,9 +313,11 @@ static struct syscore_ops samsung_clk_syscore_ops = { .resume = samsung_clk_resume, }; -void samsung_clk_sleep_init(void __iomem *reg_base, +void samsung_clk_extended_sleep_init(void __iomem *reg_base, const unsigned long *rdump, - unsigned long nr_rdump) + unsigned long nr_rdump, + const struct samsung_clk_reg_dump *rsuspend, + unsigned long nr_rsuspend) { struct samsung_clock_reg_cache *reg_cache; @@ -330,13 +335,10 @@ void samsung_clk_sleep_init(void __iomem *reg_base, reg_cache->reg_base = reg_base; reg_cache->rd_num = nr_rdump; + reg_cache->rsuspend = rsuspend; + reg_cache->rsuspend_num = nr_rsuspend; list_add_tail(®_cache->node, &clock_reg_cache_list); } - -#else -void samsung_clk_sleep_init(void __iomem *reg_base, - const unsigned long *rdump, - unsigned long nr_rdump) {} #endif /* @@ -380,8 +382,9 @@ struct samsung_clk_provider * __init samsung_cmu_register_one( samsung_clk_register_fixed_factor(ctx, cmu->fixed_factor_clks, cmu->nr_fixed_factor_clks); if (cmu->clk_regs) - samsung_clk_sleep_init(reg_base, cmu->clk_regs, - cmu->nr_clk_regs); + samsung_clk_extended_sleep_init(reg_base, + cmu->clk_regs, cmu->nr_clk_regs, + cmu->suspend_regs, cmu->nr_suspend_regs); samsung_clk_of_add_provider(np, ctx); diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index 3880d2f9d582..c3f309d7100d 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -279,6 +279,8 @@ struct samsung_clock_reg_cache { void __iomem *reg_base; struct samsung_clk_reg_dump *rdump; unsigned int rd_num; + const struct samsung_clk_reg_dump *rsuspend; + unsigned int rsuspend_num; }; struct samsung_cmu_info { @@ -358,9 +360,21 @@ extern struct samsung_clk_provider __init *samsung_cmu_register_one( extern unsigned long _get_rate(const char *clk_name); -extern void samsung_clk_sleep_init(void __iomem *reg_base, +#ifdef CONFIG_PM_SLEEP +extern void samsung_clk_extended_sleep_init(void __iomem *reg_base, const unsigned long *rdump, - unsigned long nr_rdump); + unsigned long nr_rdump, + const struct samsung_clk_reg_dump *rsuspend, + unsigned long nr_rsuspend); +#else +static inline void samsung_clk_extended_sleep_init(void __iomem *reg_base, + const unsigned long *rdump, + unsigned long nr_rdump, + const struct samsung_clk_reg_dump *rsuspend, + unsigned long nr_rsuspend) {} +#endif +#define samsung_clk_sleep_init(reg_base, rdump, nr_rdump) \ + samsung_clk_extended_sleep_init(reg_base, rdump, nr_rdump, NULL, 0) extern void samsung_clk_save(void __iomem *base, struct samsung_clk_reg_dump *rd,