From patchwork Tue Sep 5 08:06:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 9938185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74EDF601EB for ; Tue, 5 Sep 2017 08:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62942288EA for ; Tue, 5 Sep 2017 08:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54901288ED; Tue, 5 Sep 2017 08:18:26 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 70886288EB for ; Tue, 5 Sep 2017 08:18:25 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 12386A70; Tue, 5 Sep 2017 08:17:31 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 4DF8DA67 for ; Tue, 5 Sep 2017 08:17:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from kirsty.vergenet.net (kirsty.vergenet.net [202.4.237.240]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 78EC61F2 for ; Tue, 5 Sep 2017 08:17:29 +0000 (UTC) Received: from penelope.horms.nl (88.red-79-157-204.dynamicip.rima-tde.net [79.157.204.88]) by kirsty.vergenet.net (Postfix) with ESMTPA id 7060D25BE91; Tue, 5 Sep 2017 18:07:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=verge.net.au; s=mail; t=1504598866; bh=w+cYbINAIFL/0wG9x4FehhUK7tjtr3ZhKZki2zPw+Gw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hAgURFHJeeZTXs4SHCJgtLILrSLKi8IeAfiR9zCVxxfJTk0pfOVAnvpHjwriwb6S+ 9uawnLSXIHnfC5tTaYgbYlKGdMIWy4t5uAyTG94RKdNSCqobPCY6hISVxwv7Ua25+8 4PPP+ncWIVkdHxc533wd4NUFCVhfQTvIzppDQUjU= Received: by penelope.horms.nl (Postfix, from userid 7100) id 03C4CE234A8; Tue, 5 Sep 2017 04:07:00 -0400 (EDT) From: Simon Horman To: Greg KH Date: Tue, 5 Sep 2017 10:06:48 +0200 Message-Id: <1504598808-19810-14-git-send-email-horms@verge.net.au> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504598808-19810-1-git-send-email-horms@verge.net.au> References: <1504598808-19810-1-git-send-email-horms@verge.net.au> Cc: ltsi-dev@lists.linuxfoundation.org, linux-renesas-soc@vger.kernel.org, Magnus Damm Subject: [LTSI-dev] [PATCH 13/13] clk: cs2000: add Suspend/Resume feature X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP From: Khiem Nguyen CS2000 needs re-setup when redume, otherwise, it can't handle correct clock rate. Signed-off-by: Khiem Nguyen [Kuninori: cleanup original patch] Signed-off-by: Kuninori Morimoto Signed-off-by: Stephen Boyd (cherry picked from commit c567fb37f123511d752a454fb11d8bcaf46a7895) Signed-off-by: Simon Horman --- drivers/clk/clk-cs2000-cp.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/clk/clk-cs2000-cp.c b/drivers/clk/clk-cs2000-cp.c index 021f3daf34e1..3fca0526d940 100644 --- a/drivers/clk/clk-cs2000-cp.c +++ b/drivers/clk/clk-cs2000-cp.c @@ -59,6 +59,10 @@ struct cs2000_priv { struct i2c_client *client; struct clk *clk_in; struct clk *ref_clk; + + /* suspend/resume */ + unsigned long saved_rate; + unsigned long saved_parent_rate; }; static const struct of_device_id cs2000_of_match[] = { @@ -286,6 +290,9 @@ static int __cs2000_set_rate(struct cs2000_priv *priv, int ch, if (ret < 0) return ret; + priv->saved_rate = rate; + priv->saved_parent_rate = parent_rate; + return 0; } @@ -489,9 +496,24 @@ static int cs2000_probe(struct i2c_client *client, return ret; } +static int cs2000_resume(struct device *dev) +{ + struct cs2000_priv *priv = dev_get_drvdata(dev); + int ch = 0; /* it uses ch0 only at this point */ + + return __cs2000_set_rate(priv, ch, + priv->saved_rate, + priv->saved_parent_rate); +} + +static const struct dev_pm_ops cs2000_pm_ops = { + .resume_early = cs2000_resume, +}; + static struct i2c_driver cs2000_driver = { .driver = { .name = "cs2000-cp", + .pm = &cs2000_pm_ops, .of_match_table = cs2000_of_match, }, .probe = cs2000_probe,