Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6899462ybc; Thu, 28 Nov 2019 07:20:38 -0800 (PST) X-Google-Smtp-Source: APXvYqx/25pvN/CPsxBAqdNtAF+5wbTXuaxt4zEqgSWSARNIZjdk6Ookjcvjmivu2y5leZ13VQHH X-Received: by 2002:adf:da52:: with SMTP id r18mr48935363wrl.167.1574954438756; Thu, 28 Nov 2019 07:20:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574954438; cv=none; d=google.com; s=arc-20160816; b=Tah0m/hONtPwQ5mVNp3tijC63KebqYpLBZLVZzPGcSZfROq8/TmrvllXee3RQl8w8U El85DjZAFxRhjnWkLaiZxTbX8h6kFs4nE6Z527ySg/2dDuA0CKLYCOM44cmcuROMRz9e 6oVQEz/vLwzg+OjCn9zeZayoejgD1Lh3K/j9LCiLr3G9g7RMgUPTdLbuzZ5gLtUA17K8 WgsPGfPUkoH7AxxzRezwoapdO5rN/6ltgkiDmuCvqnnjTdqF2yI+CGL78ZAzFa8t+xPL rOSfCeeZjv9lQ9L17I+kDPHEByDt8zgxI9fpSFEcI9BEbTexJywL0AMHSmdw6Mc5HGm6 Xjbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=H82IbOS8sPZjWpvcnPcR/AqjGK/fOT5IpCUad40HLpM=; b=tH89JurcAlSOm88NL6H11afkbeHC5Y+soxZETry4xz+ElyVeWZIAzsn2fFipmkMHnX /pjrvNhGKPrjL1CADBQNMmBY9eXfWEeoclJcnd60iGMvQMuu8sPU97nfIRWNLQm1ot81 NyfyVXBkJLYkPr4AfdznzkPWiOWSPJz/XJospKdTVs+svPnnYKS8W/yzfVIwoMpFhT6i lph17s8HJMS3j4EveN27R4mQ033+GHObQ5MpqaQFDqZtr/7v/2cH7uA8iR9wP5iXH7TW K3Sl2HbuueYucOJBkd1aYpCWRqDSFBqziiXUx3NBlWVvsVlR3rrDI8dEY2nw4EAHy20N eoWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jFkLPx4s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id df4si14913670edb.56.2019.11.28.07.20.14; Thu, 28 Nov 2019 07:20:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@gmail.com header.s=20161025 header.b=jFkLPx4s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfK1PQZ (ORCPT + 99 others); Thu, 28 Nov 2019 10:16:25 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:40985 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbfK1PQZ (ORCPT ); Thu, 28 Nov 2019 10:16:25 -0500 Received: by mail-io1-f67.google.com with SMTP id z26so25792708iot.8; Thu, 28 Nov 2019 07:16:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=H82IbOS8sPZjWpvcnPcR/AqjGK/fOT5IpCUad40HLpM=; b=jFkLPx4spUlCQAlkElZdAN/usQOw62IzHHY17uPCjEjiRvR3Ew45iJgdOCGgFJuwmy tc12rUtvLAumuNtQfgak+gNrU305RyPV5nNUoT7QrbOIGfyQxxTAzCOygwOCq+tAh+ut gDYAhBoodWSub2YT9kgAcE2MXrqf3mafeVeP7law170kSB+R2bPCvMPy/KdmD7H4py9Y 58eIDioECiAEQhzC6sz6ulocyOC0AemYsJeEW2gHOb1tyJeW8BEgoats+Zow/OmWwL3Y nmjee7/mEWcF4WVsGKv5WhR3/6hhUMbmwgH9E4SxczUzaZ2T77SCid6X3ymEkwvqzy9M elhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=H82IbOS8sPZjWpvcnPcR/AqjGK/fOT5IpCUad40HLpM=; b=K3c9GUrxd4BwJPm5uY7GCjTH+dEFA1XskObUrqalN3d30uPsC9C9EFc1eQGnZUNdt4 m/LpOMeeuSGYUY0h4r6QJaOjA8dy+hT6ndZX3Gn+BF7/9sAWXDUkXKdGbMCBOOw+1pwL lwdArvc3YqXiWI8yaw02OyzvluUm43/2S/eIMpPmjkOo/AX8W0g85wQgO6qPlDu7wGO2 F37Fdm5wG8FhRMsDEJK0JqhV6Xy0ho26Ufw//Vx1LUdpGa+v9EydN9px7/b8XdQK8Y4P +nBWLOPllESKzkg7f9t9H41DVyJ0HVTFpGRfMseWTAWsMtpre77su/fYGDkAFaX5m374 Ygcw== X-Gm-Message-State: APjAAAX2nRopO+Glk57paAMB+pv0plZkJaE+Uw3mXrC/vr2kU5t49XJ4 gX2E3487B9TSIta57YWqavHFqVmoFALPNI+S24E= X-Received: by 2002:a5d:9f05:: with SMTP id q5mr40915527iot.295.1574954183712; Thu, 28 Nov 2019 07:16:23 -0800 (PST) MIME-Version: 1.0 References: <20191127052935.1719897-1-anarsoul@gmail.com> <20191127052935.1719897-2-anarsoul@gmail.com> <20191127111419.z5hfu5soxceiivg6@core.my.home> <20191127173547.ch3pcv3lxgdcrfnu@gilmour.lan> <20191127222427.coyeggbxs5miioxn@core.my.home> In-Reply-To: <20191127222427.coyeggbxs5miioxn@core.my.home> From: Frank Lee Date: Thu, 28 Nov 2019 23:16:05 +0800 Message-ID: Subject: Re: [PATCH v6 1/7] thermal: sun8i: add thermal driver for H6/H5/H3/A64/A83T/R40 To: Vasily Khoruzhick , Frank Lee , Mark Rutland , devicetree , Amit Kucheria , Linux PM , Greg Kroah-Hartman , Daniel Lezcano , Linux Kernel Mailing List , Maxime Ripard , Eduardo Valentin , Chen-Yu Tsai , Rob Herring , Mauro Carvalho Chehab , Zhang Rui , "David S. Miller" , Linux ARM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 28, 2019 at 6:24 AM Ond=C5=99ej Jirman wrot= e: > > On Wed, Nov 27, 2019 at 11:48:32AM -0800, Vasily Khoruzhick wrote: > > On Wed, Nov 27, 2019 at 11:44 AM Frank Lee wrot= e: > > > > > > Hello Vasily, > > > > > > Thank you very much for your work on this. > > > This looks good to me. > > > > Thanks! > > > > > By the way, I would like to ask comments about adding the following c= ode. > > > > Can we add it as follow up patch? I don't think that I have a device > > with working suspend to test it and I'm hesitant to add any code that > > I can't test. > > I have, but it doesn't use any of the clocks and resets, so it wouldn't > test this fully, and basicaly doesn't need re-calibration at all, probabl= y. > > So that may be one feedback. On a83t, I'd made these callbacks a no-op. This is just that the mainline code does not yet have the S2RAM code implementation of these SOCs. Each module has its own suspend function and resume function as part of the system suspend function. When the system is in S2RAM, the entire SOC will be completely powered off, and each module needs to save and restore its own state. Yangtao > > regards, > o. > > > > > > > diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_= thermal.c > > > index c0ed60782b11..579dde5e0701 100644 > > > --- a/drivers/thermal/sun8i_thermal.c > > > +++ b/drivers/thermal/sun8i_thermal.c > > > @@ -629,11 +629,63 @@ static const struct of_device_id of_ths_match[]= =3D { > > > }; > > > MODULE_DEVICE_TABLE(of, of_ths_match); > > > > > > +static int __maybe_unused sun8i_thermal_suspend(struct device *dev) > > > +{ > > > + struct ths_device *tmdev; =3D dev_get_drvdata(dev); > > > + > > > + clk_disable(tmdev->mod_clk); > > > + clk_disable(tmdev->bus_clk); > > > + > > > + reset_control_assert(tmdev->reset); > > > + > > > + return 0; > > > +} > > > + > > > +static int __maybe_unused sun8i_thermal_resume(struct device *dev) > > > +{ > > > + struct ths_device *tmdev; =3D dev_get_drvdata(dev); > > > + int error; > > > + > > > + error =3D reset_control_deassert(tmdev->reset); > > > + if (error) > > > + return error; > > > + > > > + error =3D clk_enable(tmdev->bus_clk); > > > + if (error) > > > + goto assert_reset; > > > + > > > + clk_set_rate(tmdev->mod_clk, 24000000); > > > + error =3D clk_enable(tmdev->mod_clk); > > > + if (error) > > > + goto bus_disable; > > > + > > > + sun8i_ths_calibrate(tmdev); > > > + > > > + ret =3D tmdev->chip->init(tmdev); > > > + if (ret) > > > + goto mod_disable; > > > + > > > + return 0; > > > + > > > +mod_disable: > > > + clk_disable(tmdev->mod_clk); > > > +bus_disable: > > > + clk_disable(tmdev->bus_clk); > > > +assert_reset: > > > + reset_control_assert(tmdev->reset); > > > + > > > + return 0; > > > +} > > > + > > > +static SIMPLE_DEV_PM_OPS(sun8i_thermal_pm_ops, > > > + sun8i_thermal_suspend, sun8i_thermal_resume); > > > + > > > static struct platform_driver ths_driver =3D { > > > .probe =3D sun8i_ths_probe, > > > .remove =3D sun8i_ths_remove, > > > .driver =3D { > > > .name =3D "sun8i-thermal", > > > + .pm =3D &sun8i_thermal_pm_ops, > > > .of_match_table =3D of_ths_match, > > > }, > > > }; > > > > > > Yangtao > > > > _______________________________________________ > > linux-arm-kernel mailing list > > linux-arm-kernel@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel