From patchwork Tue Nov 6 06:08:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?44Kw44Kn44Oz44O744Ki44Oz44O744Ob44Kh44Oz?= X-Patchwork-Id: 10669679 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECD2215E9 for ; Tue, 6 Nov 2018 06:08:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC466294CF for ; Tue, 6 Nov 2018 06:08:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D09DB294D6; Tue, 6 Nov 2018 06:08:34 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00B7A294CF for ; Tue, 6 Nov 2018 06:08:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729922AbeKFPcH (ORCPT ); Tue, 6 Nov 2018 10:32:07 -0500 Received: from www3345.sakura.ne.jp ([49.212.235.55]:36646 "EHLO www3345.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729342AbeKFPcH (ORCPT ); Tue, 6 Nov 2018 10:32:07 -0500 Received: from fsav103.sakura.ne.jp (fsav103.sakura.ne.jp [27.133.134.230]) by www3345.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id wA668UDm083798; Tue, 6 Nov 2018 15:08:31 +0900 (JST) (envelope-from na-hoan@jinso.co.jp) Received: from www3345.sakura.ne.jp (49.212.235.55) by fsav103.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav103.sakura.ne.jp); Tue, 06 Nov 2018 15:08:30 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav103.sakura.ne.jp) Received: from localhost (p14010-ipadfx41marunouchi.tokyo.ocn.ne.jp [61.118.107.10]) (authenticated bits=0) by www3345.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id wA668Qw8083781 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 6 Nov 2018 15:08:30 +0900 (JST) (envelope-from na-hoan@jinso.co.jp) From: Nguyen An Hoan To: linux-renesas-soc@vger.kernel.org, geert+renesas@glider.be, wsa@sang-engineering.com Cc: niklas.soderlund@ragnatech.se, kuninori.morimoto.gx@renesas.com, yoshihiro.shimoda.uh@renesas.com, h-inayoshi@jinso.co.jp, nv-dung@jinso.co.jp, na-hoan@jinso.co.jp, cv-dong@jinso.co.jp Subject: [v2 PATCH] thermal: rcar_gen3_thermal: Add Standby/Reset Mode support Date: Tue, 6 Nov 2018 15:08:26 +0900 Message-Id: <1541484506-30736-1-git-send-email-na-hoan@jinso.co.jp> X-Mailer: git-send-email 2.7.4 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hoan Nguyen An According to the hardware manual, Gen3 supports Standby/Reset mode. Add this function, and we should use this function while suspend to reduce the energy consumption. Signed-off-by: Hoan Nguyen An Reviewed-by: Niklas Söderlund Tested-by: Niklas Söderlund --- drivers/thermal/rcar_gen3_thermal.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 7aed533..e654519 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -447,11 +447,32 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) return ret; } +static int rcar_gen3_thermal_reset(struct rcar_gen3_thermal_priv* priv) +{ + unsigned int i; + u32 reg_val; + + for (i = 0; i < priv->num_tscs; i++) { + struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; + + rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, 0); + rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); + + reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR); + rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val & ~THCTR_THSST); + } + + usleep_range(1000, 2000); + + return 0; +} + static int __maybe_unused rcar_gen3_thermal_suspend(struct device *dev) { struct rcar_gen3_thermal_priv *priv = dev_get_drvdata(dev); - rcar_thermal_irq_set(priv, false); + /* Reset to enter standby mode */ + rcar_gen3_thermal_reset(priv); return 0; }