From patchwork Wed Mar 20 13:17:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 160680 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp282800jan; Wed, 20 Mar 2019 06:19:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYsosQuwRcuM4iH9oSERXqFo2L7xXLkds4NXY8NytC3UCkqgBfTju+r/QLjiOJ5pLk6pvj X-Received: by 2002:a63:1014:: with SMTP id f20mr7460160pgl.293.1553087965688; Wed, 20 Mar 2019 06:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553087965; cv=none; d=google.com; s=arc-20160816; b=UYG1neY5hzCB7qHeZnK/6Hpan0JTu6Hqk1JAncks7XVq3FB/R8gcZTCI1SBHqEUl7W hsJ0mRb6B4A30ys/KuPgkMKxLfdfkJjiO9dxHfyUZuqrnqSmSnDu42jraN0yGHfYH8cn 5UYktIoI1qf6NIPMHVRKJu1uEVFjgpFbru6oS29IkLna59lwRnc2EyRiT9vLOcXPk9Fx 59W2C1hlp2xLZapS7vb5363hUMu4XEddZVG/rZ0MUcYoyEulnh37+kL782nofVecOMHT IRNdd4kI+pHyMv0703sa+K7+vA6WNAa2LJnSUzAEYt03pgyJwPRe2jrNJHdcVa6cAfYk BsAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=J8JlGYbgg/zRqWjBOjDxf78JZ4BdingiWMKoRwZVd2w=; b=nbhPJ3So1t41O0AINkZkoLECehg48pBEwTarE1dBrEYw1+ep9xjY9Q3SQbT64NAtVO ByD1HxXZj7IFPUq5HWi4TN+i7S3lb8uNbcqPusvxRZYlopEsLzwoe6bzTeDMijyn/gcQ 2+UfymIf1uyI+7Sr3KZ3cSSRo588aDRkzBTfX34L+WNWUS+y8RcWDMpEmoygoWhMYdik u0UTP0vnOhfKEcBiH5XIHbl+1PO8ddTqyEo0tx333ERynxnm5hkS8ZOsYIcM2CFQGpRD +pYY6GeMnFpD3jXg1gZC4U41SXRGnWcbJZdrBVqV9/QGS1GAy1bJVFWsHxs7MhE2UoK4 FU+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iWl+Jh9l; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 139si1631572pga.219.2019.03.20.06.19.25; Wed, 20 Mar 2019 06:19:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=@linaro.org header.s=google header.b=iWl+Jh9l; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728267AbfCTNTY (ORCPT + 11 others); Wed, 20 Mar 2019 09:19:24 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44541 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728235AbfCTNTS (ORCPT ); Wed, 20 Mar 2019 09:19:18 -0400 Received: by mail-pf1-f194.google.com with SMTP id a3so1899946pff.11 for ; Wed, 20 Mar 2019 06:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=J8JlGYbgg/zRqWjBOjDxf78JZ4BdingiWMKoRwZVd2w=; b=iWl+Jh9lxol2sN66KVe+2+jJwlqM+v2Sl2GnWQwxNRv4PVDX1DEtKSrsoBB6Qch0rH U/qFwGXqMkbG58fzPYfTKEbpF6tSLb7kRg38a9BZ0gVI9NpkhqBLScgb5YStrLtHyWpw VFFCsZFJAy6xi3tPGWeP8b2FBGh5SRMcSGHg30bhWomsAHb0R/mdTGkq38HBicgImpZd LUYhfTvq+l4i5X9wxDekvm5AdK9tFHKfXUkA9z7v+Aca/dIrfsiNLB6EBl7FdRM32CHB UsWnoRlfC3oIwiAAv+1J0eAtkfGqaxCZpd2vhMYyZNR0rseJUguKhiSVXe7//ZSOTIEt iHGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=J8JlGYbgg/zRqWjBOjDxf78JZ4BdingiWMKoRwZVd2w=; b=lw0cyuEGlbSr12teuHa+AAisNpr6o51lo4moD36ZHTcw3v0jev+6HU6VU4wfI4NCDj hPI5v0PIcRXDS9NHQEyJonDrPGzECPqkU07iTVffog/JdztTCd2oLZIwxqlvqWUYEN92 308gp5+dFQJ5xIwkpezcrOrR3OytasFreq7Gkc0Kq698qUP/ErrqMbC93T0gsi0Usect W8GEkpnc4KZh4M42huoNW5pVAy8VSyqm3edQIlGMjwbTv+jjUAbaILjHLBA/gbTvsf7K oCBKeaaAf3wdY8nYqOJ68Xfu6WnkZ1Ufjj1yy4Ydd21SivvLcZBTJn6x4FiHTFIdJz7R 8IQw== X-Gm-Message-State: APjAAAXqT41HTs/8qY4QHITJsmbsCbuMpUvj5IAh3m8qjF0ewWpsbZ07 MvQzaaD/deANnMlr3Zsc7QHxiQ== X-Received: by 2002:a17:902:2f43:: with SMTP id s61mr8037789plb.158.1553087957020; Wed, 20 Mar 2019 06:19:17 -0700 (PDT) Received: from localhost ([114.143.122.221]) by smtp.gmail.com with ESMTPSA id j6sm3801719pfe.79.2019.03.20.06.19.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Mar 2019 06:19:16 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Daniel Lezcano , David Brown , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCHv3 12/23] drivers: thermal: tsens: Don't print error message on -EPROBE_DEFER Date: Wed, 20 Mar 2019 18:47:52 +0530 Message-Id: <71817f920176103fa387cad14e8d7d38b3636e6a.1553086065.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org We print a calibration failure message on -EPROBE_DEFER from nvmem/qfprom as follows: [ 3.003090] qcom-tsens 4a9000.thermal-sensor: version: 1.4 [ 3.005376] qcom-tsens 4a9000.thermal-sensor: tsens calibration failed [ 3.113248] qcom-tsens 4a9000.thermal-sensor: version: 1.4 This confuses people when, in fact, calibration succeeds later when nvmem/qfprom device is available. Don't print this message on a -EPROBE_DEFER. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index b91a0b88d33c..057b33353ba3 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -159,7 +159,8 @@ static int tsens_probe(struct platform_device *pdev) if (priv->ops->calibrate) { ret = priv->ops->calibrate(priv); if (ret < 0) { - dev_err(dev, "tsens calibration failed\n"); + if (ret != -EPROBE_DEFER) + dev_err(dev, "tsens calibration failed\n"); return ret; } } From patchwork Wed Mar 20 13:17:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 160682 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp282943jan; Wed, 20 Mar 2019 06:19:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVRw6U58ckrGNW7unLRftkORds/7qqv7ljC9D+jlt/xKQimH6GWFaYkIDGsgcvOrprEh9P X-Received: by 2002:a17:902:b68b:: with SMTP id c11mr8421584pls.79.1553087972994; Wed, 20 Mar 2019 06:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553087972; cv=none; d=google.com; s=arc-20160816; b=C8XQ/5EKbfIaMmyMLz145+7FFEhpbYVYpGiKZzn9AOep/laFSgndj2VCMH7YdTwNMz Z1TJUrLWJNm79d0l8ZMyCxDUXhk2vCf2GLFB8P2/2mi1FoujgxA+PphSDAi1iixOstJ+ gAhit/DgUtrI7PiRR/3fbWhX4/bOMV3SOxcj6+S85JhTizAwn2QMmWYSk/L6IU4fQHFv 4WiV5onVTku82W3nKXYzUp0Zv+5wfpXQZyBciXCUXEjJti0398ChJ88wCo3hpC6ugjgn paB1QKfZwK3Zyjayiq3aAJ0rn4SR7i0WsdOG2+frOn8jCk2AEZCrnN8Axa3JMBvCmyDr J3zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=fm65ZPfRVy8TLS4M5vhWmy5kJkboJ+fvo0pgjB8oBQU=; b=OBCUNdY9rqO9eOjE8TKDtPwvD7Wg3Ym0cQSGCpcIU4QU+tCwq01CoaE9MTsgGGX0QJ yNToGQe54bkcVqp2kEd19yE6r/yZ4eO74rmjyz4vUqVglVye7bk5Miq+RpzM6KOtUho5 lGzWEVhLKl7Y9Fz/hyQmJzKRCTHndCgJ0hKSHTxE+KWdhhUwGud7wKewRZnexv3o5sYE p4vavGFHDe3aI7iVV8pTvgDB4G8TkWFRrpUVc+2+YR14V/Ma5t+EnQBOwzjOvTMpbjGo ehPqch2fQiErx/rybE0HC9ZT+XUSxEG4Mat1RTVjbSucrotgIuaQwmZW/qeZQXwINhCY rR3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dQcP30GH; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si1797032pls.237.2019.03.20.06.19.32; Wed, 20 Mar 2019 06:19:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=@linaro.org header.s=google header.b=dQcP30GH; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728300AbfCTNTb (ORCPT + 11 others); Wed, 20 Mar 2019 09:19:31 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44357 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728292AbfCTNTa (ORCPT ); Wed, 20 Mar 2019 09:19:30 -0400 Received: by mail-pg1-f193.google.com with SMTP id i2so1779085pgj.11 for ; Wed, 20 Mar 2019 06:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=fm65ZPfRVy8TLS4M5vhWmy5kJkboJ+fvo0pgjB8oBQU=; b=dQcP30GHRPPju0MN6y8Db/okxfda7Z1No4bPn2lh4jpUBwRxVCzPm11HUC57dcwFPR AIdKfMSohhipypGn0UCE6ceUDB9u98rvEtgVe9eFxgvCDiRP8WUylLUiIAsWIxmJaOMJ DXTFSpmO5F7kalRiXvKCAIfQUf+WRjKBJpSFt+ED5GZevwojY7QRAos3mUxZROqwJPL0 MM1PjSCM5pbJk1IlbABFh4NstzTJuVa7gkiS3cleEZQhyBG6oRqajFBFKS3WF3zTOeZ6 5DVAOD1FgzQ22Ns4UbqUv1uJwVF+NkbgwwwGPoWq2eqO2AuuKyyE91dVCAR2eRJdpepX AC5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=fm65ZPfRVy8TLS4M5vhWmy5kJkboJ+fvo0pgjB8oBQU=; b=YgygqDnWIpR8DCxQW4rahDb+PVDatnmRRUTKjHqOyOPVx/hsEje20ADHTB7eXama59 yvmyGbGPKoqT+j5S7E0unubO9Ky2ngW5Ev+oUV0KWdUrjV2qLqptVicGJ3yaO5IHX4Ld YUOCfMGvRWHDm9O0AveOh/JgdQLCAk2EBJT/eS7bcmXWhxysqfs2Jh3UyR9CUbij/zJw VD45/akIpRMVXkD9/7Jo4rYwqkYcmycAbptHdNKt1YqFgglw28EAM3eHAQm7gRXpv6dZ ZWNbLychXW3vytbHuy3KE/YDrW1ZzLiiV6/23Xi2ZfBTkl4LccMstbWxbA+Mtx5vQ2VP JTMg== X-Gm-Message-State: APjAAAW5Wjzk4znfbCkqaeaRLTAHGRPu1Cq+FHvDx7rcHffgbCtmUJHt 6odXRAhUV3QeaLFN85fGlkcDSQ== X-Received: by 2002:a65:50c8:: with SMTP id s8mr7323893pgp.308.1553087969883; Wed, 20 Mar 2019 06:19:29 -0700 (PDT) Received: from localhost ([114.143.122.221]) by smtp.gmail.com with ESMTPSA id r3sm5913429pgb.82.2019.03.20.06.19.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Mar 2019 06:19:29 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Daniel Lezcano , David Brown , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCHv3 15/23] drivers: thermal: tsens: Introduce IP-specific max_sensor count Date: Wed, 20 Mar 2019 18:47:55 +0530 Message-Id: <5cfa53072a0aa76b1a37c69b64d4ed74633f0000.1553086065.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The IP can support 'm' sensors while the platform can enable 'n' sensors of the 'm' where n <= m. Track maximum sensors supported by the IP so that we can correctly track what subset of the sensors are supported on the platform. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 4 ++-- drivers/thermal/qcom/tsens-v0_1.c | 1 + drivers/thermal/qcom/tsens-v2.c | 1 + drivers/thermal/qcom/tsens.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index c76f8cfb25a2..5607c5cc635c 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -198,7 +198,7 @@ int __init init_common(struct tsens_priv *priv) goto err_put_device; } /* now alloc regmap_fields in tm_map */ - for (i = 0, j = LAST_TEMP_0; i < priv->num_sensors; i++, j++) { + for (i = 0, j = LAST_TEMP_0; i < priv->feat->max_sensors; i++, j++) { priv->rf[j] = devm_regmap_field_alloc(dev, priv->tm_map, priv->fields[j]); if (IS_ERR(priv->rf[j])) { @@ -206,7 +206,7 @@ int __init init_common(struct tsens_priv *priv) goto err_put_device; } } - for (i = 0, j = VALID_0; i < priv->num_sensors; i++, j++) { + for (i = 0, j = VALID_0; i < priv->feat->max_sensors; i++, j++) { priv->rf[j] = devm_regmap_field_alloc(dev, priv->tm_map, priv->fields[j]); if (IS_ERR(priv->rf[j])) { diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c index 431255bfd0ef..b3a63d7b19ea 100644 --- a/drivers/thermal/qcom/tsens-v0_1.c +++ b/drivers/thermal/qcom/tsens-v0_1.c @@ -324,6 +324,7 @@ const struct tsens_features tsens_v0_1_feat = { .crit_int = 0, .adc = 1, .srot_split = 1, + .max_sensors = 11, }; const struct reg_field tsens_v0_1_regfields[MAX_REGFIELDS] = { diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index 4b98dbe4e3c3..f3eb8661cf7a 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -88,6 +88,7 @@ const struct tsens_features tsens_v2_feat = { .crit_int = 1, .adc = 0, .srot_split = 1, + .max_sensors = 16, }; const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = { diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 527c42cfd2d5..080e15a09ac2 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -242,12 +242,14 @@ enum regfield_ids { * @adc: do the sensors only output adc code (instead of temperature)? * @srot_split: does the IP neatly splits the register space into SROT and TM, * with SROT only being available to secure boot firmware? + * @max_sensors: maximum sensors supported by this version of the IP */ struct tsens_features { unsigned int ver_major; unsigned int crit_int:1; unsigned int adc:1; unsigned int srot_split:1; + unsigned int max_sensors; }; /** From patchwork Wed Mar 20 13:17:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 160683 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp283024jan; Wed, 20 Mar 2019 06:19:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEEttCI9UCkqTtfNuovN2YYdzao/LpsA0Xe/VujWHiEwp0GN7BnVt8i9Fv6bosEoicuiSi X-Received: by 2002:a65:50cc:: with SMTP id s12mr7727440pgp.130.1553087977905; Wed, 20 Mar 2019 06:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553087977; cv=none; d=google.com; s=arc-20160816; b=Dm0WDGEMi4M8Yqm7uP2qQ3+s6u74RyC0iT6HjbQdf6fDG64LMuTgyXuZtZat0Gx1OA DFMqeJ2Z5ccSotx9PiEpA+MheHcTaHV+9D0KWz3yDJ5N+tQXQaMI2eKLKp764behOgZ1 lOKTM9QHjDiajWFUNZfS5ClBiBDaiMnyx/FXwodrkN3dUbomvZ63497d2RxTv942Xww7 sknEITk7vxUGXi+fogDqlaofJW1dG4StkoyQRsvz4LGpP8P4DsZgLpDHAsu47weK8Hvg fhczeduiCYmXmSEc6VmxxeU9Zz3afnofRiLYUtxVKU5RfAkNY5DcgE/YgtCtMH/dZGST +OPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=M+ri0/t8z+fxO1Ckfy5EpkjgMAx02hieB7076U60UDM=; b=SyOfadsb1aIikVtlwLZ00Xb50NlN3M8VSuF9e/lj3n6eihJtDmyTbPhovA7X5SvSfx kcZqyfdzEDV1nOd8c+d3FcBSeYhl4Y5+8e2TlG5eKJeHMpOx/0TZmcJKESLXj3fXql3X SKVp+YGk7C9uwIxj/UkTrZxzrkwZ17YfSG3HF2kmqSgYpRjdCXzuEJI3Sm5Xp3Va6YSe t6DAKu16UVUPp/3a3Kt5P8uqblDXKr1flZ6KsQPrZciEVXRIwATIXlPRUgvjew3amA/t zXAqZJIEbXyNvWsjV6qAeUy/P59Dv4n8xTW5y4/VEEHT6NqKA5BNc32bWhi87z8KoUsn 8Paw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d5w7gFx+; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i31si1596189pgi.284.2019.03.20.06.19.37; Wed, 20 Mar 2019 06:19:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=@linaro.org header.s=google header.b=d5w7gFx+; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728307AbfCTNTg (ORCPT + 11 others); Wed, 20 Mar 2019 09:19:36 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46824 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728311AbfCTNTf (ORCPT ); Wed, 20 Mar 2019 09:19:35 -0400 Received: by mail-pg1-f196.google.com with SMTP id a22so1767796pgg.13 for ; Wed, 20 Mar 2019 06:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=M+ri0/t8z+fxO1Ckfy5EpkjgMAx02hieB7076U60UDM=; b=d5w7gFx+s6qEhPWnyeJ50nwZRlljAtcyHQH3+Bqw1x7yrPSK4dgon1Ns8xBU0HqNBn fQXwMdPrAU6UJzoT4Mc2BblS/cmGX1ozJY7h46Kh/6/Az/T34lZsmBPQamUwr04OH6WC spn6F+RRmMgmZYIst/odl5A+WxCmSLusToJ2tKWpAcrLD22BQ0v0gmUXw3B7A+canCO5 tbvFlmmYcapUoqyeUvdFNA8VBj7/Iuo7MrxdYKWh8Fdgvrwgk8vztU9LSG5k7ux1zeYO irMTwluddlSF4W6l9uezv9QH9Xa1/O1FOnwe50FtUkBqxAxiQ7KVnvCNp8oCVUKe48wr Um8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=M+ri0/t8z+fxO1Ckfy5EpkjgMAx02hieB7076U60UDM=; b=qs6Wzh9Jz/ZmDjsN74TNHUcGZHDttKu96fOaqC3EBgfXcz08KXXjPQ6C7O6bSiGMhl 1YnDwTm/rscQOnB7s/6MNG3/3sB/DobLk+KGk5fLjaL65o3buzT41MkJH/6oSnF5lSrE 0/Pt7F16T7n+O4RNx9MAIQGia8JkzhB1xt86o57Kfo7wf/NM02cfDrU/rWwYDw5qb7rd VPq/gr5RU5OMCplScSQ+W0ukIqAtoKWkQB8LRYoWqp58yIw7fIo35XkQjHm6dxnCo9Zg A+aEmr7tbyzdfQAJ5Lf0jaInWpCbb+rlja657ao5pnSzvZsI1zhHw/1wRJues9BqUgVt Cy2A== X-Gm-Message-State: APjAAAX5zAwiJyorzwffDJ+MY3ADyVFaeKiIZ2aMFYNP2S6BFEN6joJl 3y4QDlu7i5PGD8z7CZHuz981qQ== X-Received: by 2002:a17:902:8c8a:: with SMTP id t10mr32048360plo.160.1553087974103; Wed, 20 Mar 2019 06:19:34 -0700 (PDT) Received: from localhost ([114.143.122.221]) by smtp.gmail.com with ESMTPSA id 17sm2716025pgt.0.2019.03.20.06.19.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Mar 2019 06:19:33 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Daniel Lezcano , David Brown , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCHv3 16/23] drivers: thermal: tsens: simplify get_temp_tsens_v2 routine Date: Wed, 20 Mar 2019 18:47:56 +0530 Message-Id: <5646f7e3bd90e4644718f380b28c6115c01bcb7a.1553086065.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The current implementation is based on an algorithm published in the docs. Instead of reading the temperature thrice w/o any explanation, improve the algorithm. This will become the basis for a common get_temp routine in the future. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-v2.c | 55 ++++++++++----------------------- 1 file changed, 17 insertions(+), 38 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index f3eb8661cf7a..716d7f827459 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -25,58 +25,37 @@ #define TM_Sn_STATUS_OFF 0x00a0 #define TM_TRDY_OFF 0x00e4 -#define LAST_TEMP_MASK 0xfff - -static int get_temp_tsens_v2(struct tsens_priv *priv, int id, int *temp) +static int get_temp_tsens_v2(struct tsens_priv *priv, int i, int *temp) { - struct tsens_sensor *s = &priv->sensor[id]; + struct tsens_sensor *s = &priv->sensor[i]; u32 temp_idx = LAST_TEMP_0 + s->hw_id; u32 valid_idx = VALID_0 + s->hw_id; - u32 last_temp = 0, last_temp2 = 0, last_temp3 = 0, valid; + u32 last_temp = 0, valid, mask; int ret; - ret = regmap_field_read(priv->rf[temp_idx], &last_temp); - if (ret) - return ret; - ret = regmap_field_read(priv->rf[valid_idx], &valid); if (ret) return ret; - - if (valid) - goto done; - - /* Try a second time */ - ret = regmap_field_read(priv->rf[valid_idx], &valid); - if (ret) - return ret; - ret = regmap_field_read(priv->rf[temp_idx], &last_temp2); - if (ret) - return ret; - if (valid) { - last_temp = last_temp2; - goto done; + while (!valid) { + /* Valid bit is 0 for 6 AHB clock cycles. + * At 19.2MHz, 1 AHB clock is ~60ns. + * We should enter this loop very, very rarely. + */ + ndelay(400); + ret = regmap_field_read(priv->rf[valid_idx], &valid); + if (ret) + return ret; } - /* Try a third/last time */ - ret = regmap_field_read(priv->rf[valid_idx], &valid); - if (ret) - return ret; - ret = regmap_field_read(priv->rf[temp_idx], &last_temp3); + /* Valid bit is set, OK to read the temperature */ + ret = regmap_field_read(priv->rf[temp_idx], &last_temp); if (ret) return ret; - if (valid) { - last_temp = last_temp3; - goto done; - } - if (last_temp == last_temp2) - last_temp = last_temp2; - else if (last_temp2 == last_temp3) - last_temp = last_temp3; -done: + mask = GENMASK(priv->fields[LAST_TEMP_0].msb, + priv->fields[LAST_TEMP_0].lsb); /* Convert temperature from deciCelsius to milliCelsius */ - *temp = sign_extend32(last_temp, fls(LAST_TEMP_MASK) - 1) * 100; + *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; return 0; }