From patchwork Wed Aug 29 15:50:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 145457 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp831338ljw; Wed, 29 Aug 2018 08:51:09 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbMm9aXXiZKTra8Clq6oLqFPljp/2YGtVcSvUZA9WMLqVWiip/vJ1FH4rpDWhZvqoRntYC7 X-Received: by 2002:a17:902:4601:: with SMTP id o1-v6mr6625466pld.202.1535557869761; Wed, 29 Aug 2018 08:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535557869; cv=none; d=google.com; s=arc-20160816; b=o6VuXo+DNRuAO0buaGDsJPBheHycCWhEhc1mhrO2F9Ea0M58VAYkJFY1QImgmUajdR PgJKnzWqBaAWzt6szSe2Mi5+KG7NX8UbOM0wRFu+iF4ZfDmRtPX8sAWIkWQBgSefUeSw Q7QEjIMAP/kbeirES3N1EyUPRJnLaaRHffLlTZanxtjvfEeXu/qmrISjmiZ4S98/uP0H 1TVFS8SOPPCXEosiLStDJE89jkrlFcL/l7BdDt99rl4B4+97s3QHV/FWzCjKK2hzf91J 1AYydp7uqZrv5n2/DIDo/5OWf1gW7Cgr67TeiPnwuut8+RK0nBFLSVlVMfLF5LP9j3si IBxg== 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 :arc-authentication-results; bh=0ZOvo/7v0e4RpMKaRQStI++zq3ROZmJ4knCcBT7gPxs=; b=JYGghHPC2Cc9p7D9cxM9R1Q4i/50+IToiE8dznWYjtmdJOK+EBBm6t5l+GOOqyRHGF hlWrjb7CypqTn1kzchjJ6CiijyIWnR9gtWaAPJ0iTWCn/1xWa8P6PAJDYPIX9LZDS4J+ tkRE0xFo6L2a/gweIJ8U1xD5hDe1duAlKGVhlxICu/V+N6Cb+e+Vnz3ZmDnEa2ivAbc6 Edrzb4x2pX/NbPOaUgN7aP5bYG6t7uJn7f/rcDSF7x1Gz/NeUCC0D/97Pponsvlnupz3 hgdgnJJ+4qsPg5EITCYeOjyaJoZ6QOQhszibC54w0Uc7Mrrd9BDWhz1IlSshvgsn4cW9 c6eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=hc+BFqyE; 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 32-v6si4160278pgk.59.2018.08.29.08.51.09; Wed, 29 Aug 2018 08:51:09 -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=hc+BFqyE; 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 S1729218AbeH2Tsj (ORCPT + 3 others); Wed, 29 Aug 2018 15:48:39 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:35935 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729206AbeH2Tsi (ORCPT ); Wed, 29 Aug 2018 15:48:38 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180829155103euoutp02d71e2d1966ccc84a53a1d54cd9a23ce7~PZb3XBA7r2539125391euoutp02E; Wed, 29 Aug 2018 15:51:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180829155103euoutp02d71e2d1966ccc84a53a1d54cd9a23ce7~PZb3XBA7r2539125391euoutp02E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1535557864; bh=0ZOvo/7v0e4RpMKaRQStI++zq3ROZmJ4knCcBT7gPxs=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=hc+BFqyEuf4Skd0RCCfZftk+dMRiX6u7RUoHxLvspRgaYmzQd1X/IrSuDKs7mymfl NyG2SwvKkcKfialJtxWyBSqt8AlrHztKvNni4e8Mz8npgpGYyzEuS/P8G2918u7OK/ RHW5kUqFUbWHg3SPQtwCPceuiPcXU+5tR1X3aBfU= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180829155103eucas1p205b40a3cf84527029e919066e6d359eb~PZb2zqZyV2216722167eucas1p2q; Wed, 29 Aug 2018 15:51:03 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id CE.FA.04806.7E0C68B5; Wed, 29 Aug 2018 16:51:03 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180829155102eucas1p1ca7a26c10847dcb585f01b54657e29cb~PZb166KBg1936219362eucas1p12; Wed, 29 Aug 2018 15:51:02 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-3d-5b86c0e7f882 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A7.76.04128.5E0C68B5; Wed, 29 Aug 2018 16:51:01 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PE800FCUC0UPL60@eusync4.samsung.com>; Wed, 29 Aug 2018 16:51:01 +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 08/10] clk: samsung: Add support for setting registers state before suspend Date: Wed, 29 Aug 2018 17:50:44 +0200 Message-id: <20180829155046.29359-9-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20180829155046.29359-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIIsWRmVeSWpSXmKPExsWy7djP87rPD7RFGxw9wWyxccZ6VovrX56z Wpw/v4Hd4mPPPVaLGef3MVmsPXKX3aL96UtmB3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoErY82btUwFTXIVS/etYWlgnCDZxcjJISFgInHt11KmLkYuDiGBFYwSv7oXM0M4nxkl Wq5fY4apatsxgQUisYxRYuOKlVAtDUwS21+BZDg52AQMJbredrGB2CICDhKfP71mBCliFnjM KLH15FewUcICsRJPtj8Es1kEVCUutd4As3kFbCWa11xjgVgnL7F6wwGwOKeAncSL472sIIMk BL6ySuw8NZURoshF4sTKJiYIW1ji1fEt7BC2jMTlyd0sEA3NjBLtM2axQzg9QGfM2cEGUWUt cfj4RVYQm1mAT2LStulA6ziA4rwSHW1CECUeErdunQNbICQwkVFi58rACYySCxgZVjGKp5YW 56anFhvnpZbrFSfmFpfmpesl5+duYgRG3Ol/x7/uYNz3J+kQowAHoxIP74UZbdFCrIllxZW5 hxglOJiVRHj3LgQK8aYkVlalFuXHF5XmpBYfYpTmYFES5+XTSosWEkhPLEnNTk0tSC2CyTJx cEo1MN5gv/KGj/Wpe8LtriQ2t+fbbs7YqvLr/vPVvZxXo55kidReXNPUJX7qIscE249pZm9v W0t5azDXfjcIX2OYeEHlwFtJ/tYDByM+Pmo1OB7/KunlpOQz9q93FLHyh0zR9VqU6Maz88fv VXH+da2z1y1znLDk0OJ7PTPW7k/imbjbU6zD0W3vhBNKLMUZiYZazEXFiQAyW+v3tAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHJMWRmVeSWpSXmKPExsVy+t/xa7pPD7RFG0y6aWSxccZ6VovrX56z Wpw/v4Hd4mPPPVaLGef3MVmsPXKX3aL96UtmB3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoErY82btUwFTXIVS/etYWlgnCDZxcjJISFgItG2YwJLFyMXh5DAEkaJE+ePMkM4TUwS D5c8YAepYhMwlOh628UGYosIOEh8/vSaEaSIWeAxo8S5xRtYQRLCArEST7Y/ZAaxWQRUJS61 3gCzeQVsJZrXXGOBWCcvsXrDAbA4p4CdxIvjvWC9QkA1C+98Z5zAyLOAkWEVo0hqaXFuem6x kV5xYm5xaV66XnJ+7iZGYKhsO/Zzyw7GrnfBhxgFOBiVeHgNFrVFC7EmlhVX5h5ilOBgVhLh 3bsQKMSbklhZlVqUH19UmpNafIhRmoNFSZz3vEFllJBAemJJanZqakFqEUyWiYNTqoFRSf2e bFTtdvkNcgppNp5bxI+zXHk8/WJEX+wGNw/zk1v2GDUV/L1yo0eo5r3FuwK7ig3PV4ccu8Sc vbbFWEuhf/oqEcPL9offN/uHmlpO9XP7yK+b/fDCReZ5GzYo9Wwsn3rvq8NLZ8+jTglTeosV 5Mom/J8Rt5xZ4I2Txm1tn39B5gybVFyUWIozEg21mIuKEwGxzrNnEQIAAA== X-CMS-MailID: 20180829155102eucas1p1ca7a26c10847dcb585f01b54657e29cb X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180829155102eucas1p1ca7a26c10847dcb585f01b54657e29cb References: <20180829155046.29359-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..ab467a7f973a 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_sleep_init2(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_sleep_init2(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..854d0b52ef5f 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_sleep_init2(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 +void samsung_clk_sleep_init2(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_sleep_init2(reg_base, rdump, nr_rdump, NULL, 0) extern void samsung_clk_save(void __iomem *base, struct samsung_clk_reg_dump *rd,