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: 9249851 X-Patchwork-Delegate: rui.zhang@intel.com 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 6245C607D8 for ; Wed, 27 Jul 2016 14:10:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5275226D06 for ; Wed, 27 Jul 2016 14:10:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45B0C271FD; Wed, 27 Jul 2016 14:10:59 +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=-6.9 required=2.0 tests=BAYES_00,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 5314226D06 for ; Wed, 27 Jul 2016 14:10:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754295AbcG0OK4 (ORCPT ); Wed, 27 Jul 2016 10:10:56 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36657 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754048AbcG0OKz (ORCPT ); Wed, 27 Jul 2016 10:10:55 -0400 Received: by mail-pf0-f195.google.com with SMTP id y134so1928331pfg.3; 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=DyUsR7Y34oR2O84gTACUEOnnl27wuv06Q9RJ/I62lc2mkQqHF1GS376L9HLxk8Pbhi fYDcCXI/cU5mYqo7yf8e+DO3b8RicAn5ulsMGf6GxAOQI7Lh6ArJ9D3gxIVwBugnexi9 TEuYjcasrmVsGIogJcPlML7YCMEoC7LkW7UdAgY1xelmyp50kPZeoSJ2oA5MOyB6LG8d Ma4LFMNdiCsLbnyQFvt1A25RSO10gWA+lwucUywua5W/dV+ZtuMRjGNfR97dn0QphH8B 0pWRswwxwOkLFmK9b25m9/UUih4q3sYVsomMCgo6tqY3rG1kMCwZVXque0jQq3a/CB+5 oVBw== X-Gm-Message-State: AEkoouuLTzhYa6FGv2KQOPoggSppnjISx2m3vyHA9UMYgRP4r9OgSx6lMQagyC0KWEgaQw== 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 Cc: smbarber@chromium.org, dianders@chromium.org, briannorris@chromium.org, Rocky Hao , Caesar Wang , Zhang Rui , Heiko Stuebner , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org 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 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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);