From patchwork Wed Jul 27 14:10:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9249863 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 F3DCA60757 for ; Wed, 27 Jul 2016 14:13:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1AF1269B2 for ; Wed, 27 Jul 2016 14:13:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D341526D06; Wed, 27 Jul 2016 14:13:22 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 686CC269B2 for ; Wed, 27 Jul 2016 14:13:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bSPYP-0006Cx-4S; Wed, 27 Jul 2016 14:11:21 +0000 Received: from mail-pf0-f194.google.com ([209.85.192.194]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bSPYK-0006AG-7W; Wed, 27 Jul 2016 14:11:18 +0000 Received: by mail-pf0-f194.google.com with SMTP id i6so1935773pfe.0; Wed, 27 Jul 2016 07:10:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=feRxXroL8tz9b/tUWuPfp2viDCE6XIAlG0+esnMv7IE=; b=kdQxEK5R2BzaoG0JmnqC+IXZ4rlVMP0P2X/eAdBBLKCZNhaXEOeGCTeFLRxUhnnBGJ DxxlosCY/dGUO35WTSslxxsncFidNkh4N7q2lVpHQhhxhj4B8coQ/pd7icePtGHS3R27 Zre63GecgyShWyNQqIqgfPcJCwq9O2WQTQGrcuu0rMkDU+/qGKX1wvQyetWsOyYghsJO L2aThZgaVeZgXSOYMpshOSzx0VQ9y8XUesguTaIdFk0piZjDiVo+FUikJTVeW1vZyE3B EbKL8qy3n9W9N4dy2kpfHCeQv98XvA8lpY0+uAjEJhewcgNZ+A1UX7NfOqyJ76mknMFd tR/A== X-Gm-Message-State: AEkoouuo7v/0TP38q1KNWe2DrGCkkPuM7yD04QIE8tuDxH812YlNgE386fvp9FaNj3beOQ== X-Received: by 10.98.41.195 with SMTP id p186mr48009727pfp.81.1469628655080; Wed, 27 Jul 2016 07:10:55 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id b90sm9728138pfc.29.2016.07.27.07.10.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jul 2016 07:10:53 -0700 (PDT) From: Caesar Wang To: Eduardo Valentin Subject: [PATCH 1/2] thermal: rockchip: enhance the tsadc's bandgap feature for rk3399 Date: Wed, 27 Jul 2016 22:10:42 +0800 Message-Id: <1469628643-29661-1-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160727_071116_290705_2BB50DAC X-CRM114-Status: UNSURE ( 8.50 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, briannorris@chromium.org, dianders@chromium.org, smbarber@chromium.org, linux-rockchip@lists.infradead.org, Zhang Rui , Rocky Hao , linux-arm-kernel@lists.infradead.org, Caesar Wang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rocky Hao Due to the voltage ripple, the sensing data of the tsadc is not accurate. And in this patch, the bandgap feature is enhanced to remove the voltage ripple, and then the tsadc can sense the temperature more precisely. Obsolete codes are removed as well. Signed-off-by: Rocky Hao Signed-off-by: Caesar Wang Cc: Eduardo Valentin Cc: Zhang Rui Cc: Heiko Stuebner Cc: linux-pm@vger.kernel.org Tested-by: Stephen Barber --- drivers/thermal/rockchip_thermal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index db5ecc5..a90423d 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -222,10 +222,10 @@ struct rockchip_thermal_data { #define GRF_TSADC_TESTBIT_L 0x0e648 #define GRF_TSADC_TESTBIT_H 0x0e64c -#define GRF_TSADC_TSEN_PD_ON (0x30003 << 0) -#define GRF_TSADC_TSEN_PD_OFF (0x30000 << 0) #define GRF_SARADC_TESTBIT_ON (0x10001 << 2) #define GRF_TSADC_TESTBIT_H_ON (0x10001 << 2) +#define GRF_TSADC_VCM_EN_L (0x10001 << 7) +#define GRF_TSADC_VCM_EN_H (0x10001 << 7) /** * struct tsadc_table - code to temperature conversion table @@ -567,9 +567,10 @@ static void rk_tsadcv3_initialize(struct regmap *grf, void __iomem *regs, regs + TSADCV2_HIGHT_TSHUT_DEBOUNCE); } else { - regmap_write(grf, GRF_TSADC_TESTBIT_L, GRF_TSADC_TSEN_PD_ON); - mdelay(10); - regmap_write(grf, GRF_TSADC_TESTBIT_L, GRF_TSADC_TSEN_PD_OFF); + /* Enable the voltage common mode feature */ + regmap_write(grf, GRF_TSADC_TESTBIT_L, GRF_TSADC_VCM_EN_L); + regmap_write(grf, GRF_TSADC_TESTBIT_H, GRF_TSADC_VCM_EN_H); + usleep_range(15, 100); /* The spec note says at least 15 us */ regmap_write(grf, GRF_SARADC_TESTBIT, GRF_SARADC_TESTBIT_ON); regmap_write(grf, GRF_TSADC_TESTBIT_H, GRF_TSADC_TESTBIT_H_ON);