From patchwork Wed Sep 11 07:16:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 173589 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp374101ilq; Wed, 11 Sep 2019 00:16:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYTx60akevb4yz8/aYSXwVxq7rcQ+90SbgMisA3orD/Kl90Sz54ar09DY+m7JBIytp8Jb6 X-Received: by 2002:a50:adea:: with SMTP id b39mr34360759edd.16.1568186208608; Wed, 11 Sep 2019 00:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568186208; cv=none; d=google.com; s=arc-20160816; b=Fy7zeYa9vy7wLwY9AiQB/wVg55W49p8IMC8NwEq0lac9bdvxc1amDFyf1+XlxbAXAp 2olJvrNz4Nn5rMCFTB5mOKouzmzuScKORbOffkaGxmMKy7IX649PhOwxujtwgqsNfZoR Df0Uc+6YwKzBxWNbDDzVkKrbr5iSkOFeO+wTVqnvs81cyg8oyB2TIzRO6IoB3z7GJsRD 8Jx8Bva+dfTeutp0SczL2G85nyzaDuJeeEPIer8eA9rXoNZaJuo09nZ4SAiluzxi0f3/ 56zUHyOWOK95bePmC9Z9cG94xXZStk4T2/CumBpuSl7/UkUs+msUTaJ8rgXonZaqFCaY APaA== 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=TYv2LRSteD77Ft4oMs2p5uadS2z0S5817oCjy76gUik=; b=yQqksBxjmcGYlHiomFkFs8kFT+3FT10rHD6ROk1hRLsGvtqvX/fkISOVWWfNkJHbOr ATQ/A6m4PyGww9kb8SNDCbF4jnGDk3G1Gz//qmnLsyyccWa0/0fuHk+qah1TFEfhXhFo FPIXN3pCCQIA3I1moIy86EYtYpLLWszmGbKpfg5EBwDZsfUlA0QRtTj5topD56DSUtLS NQKKUkdhUSRujSB6EX95mzdA+mLNb7qvJ/v0e2lbrsUonECKT/akUE05oY9u9NvXiKNb qbm9lUE0/8/sC6x7MPakFIsopjx+YE8ALvqFQFHV99MF8vgJMVGaC33o+H3lbSGLAZWn 6vMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kj1j7ZaZ; 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=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 u2si2623689edp.191.2019.09.11.00.16.47; Wed, 11 Sep 2019 00:16:48 -0700 (PDT) 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=@linaro.org header.s=google header.b=kj1j7ZaZ; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726981AbfIKHQq (ORCPT + 27 others); Wed, 11 Sep 2019 03:16:46 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:43842 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726838AbfIKHQp (ORCPT ); Wed, 11 Sep 2019 03:16:45 -0400 Received: by mail-pl1-f194.google.com with SMTP id 4so9766047pld.10 for ; Wed, 11 Sep 2019 00:16:44 -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=TYv2LRSteD77Ft4oMs2p5uadS2z0S5817oCjy76gUik=; b=kj1j7ZaZnPMmsnHMvLk21yvm6k06hUpqx9YhvZYRoF6tMhQMm0Xwl9/12rAOGIgwzx eq7LSwvZ4sQ+28fB0GlNOPcQAO3YX3dYBDIaViLNagUmizZpuQ6Di0kx8+8BVsqL+s7N 00GftV/JgicBTz/hUdyP5F676NgJcH3W8ipSdvX2WpWvjRALyUOXSdeLmH9foo3KszN1 V7uKmYfr2nV4eXhYXRSet6ddkiSS7qTTz5/723Vn5/wQReRwyM+Wc3qtErxADzeRSngj dkNSJqcMxS4eZxtOMzpLdkxgr/+uinY1c9PS8tL188zltSAY6AZAfsP25ffuY1jclE76 xH5w== 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=TYv2LRSteD77Ft4oMs2p5uadS2z0S5817oCjy76gUik=; b=d5+mGtJ9LsVxDeTx9yoDeYuVusoo6LD+qWdqN3yMZKuHJGtDfGjgxKkqrE56SvYjM6 CictoTxotJH3sHWKLEjPqyTqP8cK245UjC8mKQZMNThiSTkZVxfEyYY9hV2i90t0Uqwt Hqm52gRf3cFImznL6y3oh1LKq/Vr0P3jf9F+j38saofUGFoajMZ9OyVFtJTLUBULh5mf Z71OlbEQEo3TpiP1Vk87fEDxWVXqJkmo0C9uw5FpH2AAKe3BncFY81cS1Xvw8mdwuKlt A26iNAQZFKS1y8VJoS952T2n09VVnPHLy9D8KiiPNi7tx2J2HYLydVXq5JBxVw3BGdTA 4Sxw== X-Gm-Message-State: APjAAAVnga14FDAF44RftaQUFl+I0GIBdcci4Wss9yJaUQjk8seugnjW mqWhmmgjDN7G5jY9pKtEU6HLFPOWKV5+Sw== X-Received: by 2002:a17:902:8506:: with SMTP id bj6mr36138092plb.79.1568186204168; Wed, 11 Sep 2019 00:16:44 -0700 (PDT) Received: from localhost ([49.248.201.118]) by smtp.gmail.com with ESMTPSA id j2sm20842070pfe.130.2019.09.11.00.16.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2019 00:16:43 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, agross@kernel.org, masneyb@onstation.org, swboyd@chromium.org, Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v3 01/15] drivers: thermal: tsens: Get rid of id field in tsens_sensor Date: Wed, 11 Sep 2019 12:46:18 +0530 Message-Id: <0ada60b1b216346e3e9e2429af8c2b7c9901c938.1568185732.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are two fields - id and hw_id - to track what sensor an action was to performed on. This was because the sensors connected to a TSENS IP might not be contiguous i.e. 1, 2, 4, 5 with 3 being skipped. This causes confusion in the code which uses hw_id sometimes and id other times (tsens_get_temp, tsens_get_trend). Switch to only using the hw_id field to track the physical ID of the sensor. When we iterate through all the sensors connected to an IP block, we use an index i to loop through the list of sensors, and then return the actual hw_id that is registered on that index. Signed-off-by: Amit Kucheria Reviewed-by: Stephen Boyd Reviewed-by: Daniel Lezcano --- drivers/thermal/qcom/tsens-8960.c | 4 ++-- drivers/thermal/qcom/tsens-common.c | 16 +++++++++------- drivers/thermal/qcom/tsens.c | 11 +++++------ drivers/thermal/qcom/tsens.h | 10 ++++------ 4 files changed, 20 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 8d9b721dadb6..3e1436fda1eb 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -243,11 +243,11 @@ static inline int code_to_mdegC(u32 adc_code, const struct tsens_sensor *s) return adc_code * slope + offset; } -static int get_temp_8960(struct tsens_priv *priv, int id, int *temp) +static int get_temp_8960(struct tsens_sensor *s, int *temp) { int ret; u32 code, trdy; - const struct tsens_sensor *s = &priv->sensor[id]; + struct tsens_priv *priv = s->priv; unsigned long timeout; timeout = jiffies + usecs_to_jiffies(TIMEOUT_US); diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 528df8801254..c037bdf92c66 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -83,11 +83,12 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s) return degc; } -int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp) +int get_temp_tsens_valid(struct tsens_sensor *s, int *temp) { - struct tsens_sensor *s = &priv->sensor[i]; - u32 temp_idx = LAST_TEMP_0 + s->hw_id; - u32 valid_idx = VALID_0 + s->hw_id; + struct tsens_priv *priv = s->priv; + int hw_id = s->hw_id; + u32 temp_idx = LAST_TEMP_0 + hw_id; + u32 valid_idx = VALID_0 + hw_id; u32 last_temp = 0, valid, mask; int ret; @@ -123,12 +124,13 @@ int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp) return 0; } -int get_temp_common(struct tsens_priv *priv, int i, int *temp) +int get_temp_common(struct tsens_sensor *s, int *temp) { - struct tsens_sensor *s = &priv->sensor[i]; + struct tsens_priv *priv = s->priv; + int hw_id = s->hw_id; int last_temp = 0, ret; - ret = regmap_field_read(priv->rf[LAST_TEMP_0 + s->hw_id], &last_temp); + ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp); if (ret) return ret; diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 0627d8615c30..6ed687a6e53c 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -14,19 +14,19 @@ static int tsens_get_temp(void *data, int *temp) { - const struct tsens_sensor *s = data; + struct tsens_sensor *s = data; struct tsens_priv *priv = s->priv; - return priv->ops->get_temp(priv, s->id, temp); + return priv->ops->get_temp(s, temp); } static int tsens_get_trend(void *data, int trip, enum thermal_trend *trend) { - const struct tsens_sensor *s = data; + struct tsens_sensor *s = data; struct tsens_priv *priv = s->priv; if (priv->ops->get_trend) - return priv->ops->get_trend(priv, s->id, trend); + return priv->ops->get_trend(s, trend); return -ENOTSUPP; } @@ -86,8 +86,7 @@ static int tsens_register(struct tsens_priv *priv) for (i = 0; i < priv->num_sensors; i++) { priv->sensor[i].priv = priv; - priv->sensor[i].id = i; - tzd = devm_thermal_zone_of_sensor_register(priv->dev, i, + tzd = devm_thermal_zone_of_sensor_register(priv->dev, priv->sensor[i].hw_id, &priv->sensor[i], &tsens_of_ops); if (IS_ERR(tzd)) diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 2fd94997245b..d022e726d074 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -31,7 +31,6 @@ enum tsens_ver { * @priv: tsens device instance that this sensor is connected to * @tzd: pointer to the thermal zone that this sensor is in * @offset: offset of temperature adjustment curve - * @id: Sensor ID * @hw_id: HW ID can be used in case of platform-specific IDs * @slope: slope of temperature adjustment curve * @status: 8960-specific variable to track 8960 and 8660 status register offset @@ -40,7 +39,6 @@ struct tsens_sensor { struct tsens_priv *priv; struct thermal_zone_device *tzd; int offset; - unsigned int id; unsigned int hw_id; int slope; u32 status; @@ -61,13 +59,13 @@ struct tsens_ops { /* mandatory callbacks */ int (*init)(struct tsens_priv *priv); int (*calibrate)(struct tsens_priv *priv); - int (*get_temp)(struct tsens_priv *priv, int i, int *temp); + int (*get_temp)(struct tsens_sensor *s, int *temp); /* optional callbacks */ int (*enable)(struct tsens_priv *priv, int i); void (*disable)(struct tsens_priv *priv); int (*suspend)(struct tsens_priv *priv); int (*resume)(struct tsens_priv *priv); - int (*get_trend)(struct tsens_priv *priv, int i, enum thermal_trend *trend); + int (*get_trend)(struct tsens_sensor *s, enum thermal_trend *trend); }; #define REG_FIELD_FOR_EACH_SENSOR11(_name, _offset, _startbit, _stopbit) \ @@ -313,8 +311,8 @@ struct tsens_priv { char *qfprom_read(struct device *dev, const char *cname); void compute_intercept_slope(struct tsens_priv *priv, u32 *pt1, u32 *pt2, u32 mode); int init_common(struct tsens_priv *priv); -int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp); -int get_temp_common(struct tsens_priv *priv, int i, int *temp); +int get_temp_tsens_valid(struct tsens_sensor *s, int *temp); +int get_temp_common(struct tsens_sensor *s, int *temp); /* TSENS target */ extern const struct tsens_plat_data data_8960; From patchwork Wed Sep 11 07:16:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 173597 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp374570ilq; Wed, 11 Sep 2019 00:17:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwY72zNW1rgoiA9UOFoqszQoKcVCG0wdUyyegbAMQcFb/z83XRa1JT5KAC91R91IuSMZh2c X-Received: by 2002:a17:906:4e12:: with SMTP id z18mr28901959eju.187.1568186237843; Wed, 11 Sep 2019 00:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568186237; cv=none; d=google.com; s=arc-20160816; b=W1/QGJPUMjNuMACo6BZrg6mrBc9FpDBlE2oWk2WQoELaHl+HViWZSLjjjT+Wm85fU4 6YpHH7i1jnxW5TgKpAdJyfb5k/STgEXRTIjxxyLpPwMpS6i61ER0XNVVwIDDor73/Jiz C8h3nLnHT8vajWd/qxhA4aZmCT7hwjbx2TpYkzjQI1mpiZMXrrn4ci9o8IVl/DQTIaVC IO945jPZZuuDfMJp6Jf7wyJtYN48ATMNtUKWFVPQ5AO1AcWRIRcPrv/K7kzliPaZRs3h 5vVCSViqVbN8foyZCQ6NbAMnwBMU1vW2XVZ3qawQdxL0dolEZ1Tl/w/K/yyOeAFYZenq /yCw== 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=ZwCxmgUQhS9SSaQKkkkSIJsmLTrN1BacMY6pM2O/8bI=; b=sQYp0gV5beSX1xKXWomPghZcIWtP9HfJ7TMUrkHMppHwJ0G4st8Wjt1oU6FRWqsQrn DZJaCcDbY0zFdGVbFq7H37pz6IKpgVmeqh3LmEuIokRRm+Ovl+cJu2KFri5MLZxXFMru QeQpfvYXDpWSQ9n8XzV6ofIMwmGC1GjUeoI3snd4QlVKUrXAcPrqz5J/BLi5bMKU3VpM dH5RQ8N1raZf6dQKiyJz4E0JRHBhFAY7ZQ0t098R6+q67Fy+cEnFRTFx9QDLUS25kvBz co8m5pUqilYP+gHpaviW48A3Fa3fQiFI2aese/quNRoMCpS0x3YDWmnnfaFBZC2no6tD AwKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fDRUh7QT; 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=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 z10si10468766ejx.208.2019.09.11.00.17.17; Wed, 11 Sep 2019 00:17:17 -0700 (PDT) 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=@linaro.org header.s=google header.b=fDRUh7QT; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727206AbfIKHRQ (ORCPT + 27 others); Wed, 11 Sep 2019 03:17:16 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:37053 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbfIKHRO (ORCPT ); Wed, 11 Sep 2019 03:17:14 -0400 Received: by mail-pl1-f194.google.com with SMTP id b10so9801609plr.4 for ; Wed, 11 Sep 2019 00:17:14 -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=ZwCxmgUQhS9SSaQKkkkSIJsmLTrN1BacMY6pM2O/8bI=; b=fDRUh7QTThqydKCBTQPbfRYwl0z34T8dbU2Dyp/0QF7I3egtSz88/gYhodRI06NaBi oaTncQGl6i8akjx2JPQNmanIeMXe98CLtgGq0WzXl8n/gaWXE1pcT3DfF6//KrhY8YJ2 FjklrSTcnEvInaoSdDHkppmXdAU5ANe6frRaX3Du4tBZx2qZXNLqSzNlqybK1dho4yAo 36QtA7fWNLqP5KlAQojBoYuH3ALUu51s642ehm9+Q4yj1uIXCoNscofj44vEgBS/uvts 5IDwlXBYu3u6x2qHXTi2wYdm2XejMq2iW1xWz18Hs9+J3jPWroLrrTMAuylyHN5aPwni qrBA== 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=ZwCxmgUQhS9SSaQKkkkSIJsmLTrN1BacMY6pM2O/8bI=; b=PpCJ8G15iG8dsBhuOF30sGEYb4unCS7674hjTr+RNAHU/ruMlAbZE2ElQ3k/8Q7a8i R2M3tRN1ykm/dx8LINAjRxL1lUFHcXfpuJtReF2kMsgsKGDTPio8b4iJBY+bsrL5Sai3 P5iYJsgogVFuhBhjahBNw1iEwHUwJ5ctFrc95icmVXrHh5dU2mhpsrbzL4MN6Wd21Tfb 63IhEy3P+vvus3xij6J8LtCmOKwAOu0MAmDpqrQ1wN9xgrBpLwRYUUKyqNuaSokv4KHs nZkW0tDGKTF+WJapMu3Z+d+ueB878Fk0C3mhxwNnbuoFJI8mNSOeNyIZcV0d2hmms++D /eyg== X-Gm-Message-State: APjAAAVbsJf0DMokNwgABwTc+bLbxyyn1309wkN0NPTSKIJiFbsiTBuW 0bIyG8ljFjbS0fSrlNiM7g3GR9uJo3KvXA== X-Received: by 2002:a17:902:36e:: with SMTP id 101mr33887914pld.51.1568186233640; Wed, 11 Sep 2019 00:17:13 -0700 (PDT) Received: from localhost ([49.248.201.118]) by smtp.gmail.com with ESMTPSA id x5sm21705278pfn.149.2019.09.11.00.17.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2019 00:17:13 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, agross@kernel.org, masneyb@onstation.org, swboyd@chromium.org, Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: devicetree@vger.kernel.org Subject: [PATCH v3 09/15] arm64: dts: msm8996: thermal: Add interrupt support Date: Wed, 11 Sep 2019 12:46:26 +0530 Message-Id: <955d8c4a928405d7830bdf76101dc1c3c9898853.1568185732.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Register upper-lower interrupts for each of the two tsens controllers. Signed-off-by: Amit Kucheria --- arch/arm64/boot/dts/qcom/msm8996.dtsi | 60 ++++++++++++++------------- 1 file changed, 32 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi index 96c0a481f454..bb763b362c16 100644 --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi @@ -175,8 +175,8 @@ thermal-zones { cpu0-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens0 3>; @@ -196,8 +196,8 @@ }; cpu1-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens0 5>; @@ -217,8 +217,8 @@ }; cpu2-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens0 8>; @@ -238,8 +238,8 @@ }; cpu3-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens0 10>; @@ -259,8 +259,8 @@ }; gpu-thermal-top { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens1 6>; @@ -274,8 +274,8 @@ }; gpu-thermal-bottom { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens1 7>; @@ -289,8 +289,8 @@ }; m4m-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens0 1>; @@ -304,8 +304,8 @@ }; l3-or-venus-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens0 2>; @@ -319,8 +319,8 @@ }; cluster0-l2-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens0 7>; @@ -334,8 +334,8 @@ }; cluster1-l2-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens0 12>; @@ -349,8 +349,8 @@ }; camera-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens1 1>; @@ -364,8 +364,8 @@ }; q6-dsp-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens1 2>; @@ -379,8 +379,8 @@ }; mem-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens1 3>; @@ -394,8 +394,8 @@ }; modemtx-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens1 4>; @@ -591,6 +591,8 @@ reg = <0x4a9000 0x1000>, /* TM */ <0x4a8000 0x1000>; /* SROT */ #qcom,sensors = <13>; + interrupts = ; + interrupt-names = "uplow"; #thermal-sensor-cells = <1>; }; @@ -599,6 +601,8 @@ reg = <0x4ad000 0x1000>, /* TM */ <0x4ac000 0x1000>; /* SROT */ #qcom,sensors = <8>; + interrupts = ; + interrupt-names = "uplow"; #thermal-sensor-cells = <1>; }; From patchwork Wed Sep 11 07:16:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 173601 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp374818ilq; Wed, 11 Sep 2019 00:17:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLr+UUHNTbsv2tEmZ6zQPeKyKJkiy/FFTLn0KakHzNo1Zxbc9P6Auhep/R7lX8KOKonEzM X-Received: by 2002:a17:907:41e5:: with SMTP id nb5mr28399256ejb.91.1568186254275; Wed, 11 Sep 2019 00:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568186254; cv=none; d=google.com; s=arc-20160816; b=hYXd0A4A0V3sxF5uz5cie6hh0/V0Kb43iBayESYwlRfX1Vub8lty+kUnrsEdNJvgka 0/iWpZRvAe7c90NhBbEvTclfVhsq9LKQW33wm9j4k7c/septVi0hAkk0i3xfxfLBaLgs S4WrVSL24I382l4Zs630qAGUhgGcPIXT0hwHyNduL8JiGM4S2GAh4zHzKkC6EUR1q1Ny bSfJyLWoTF5Fn/dsAjv3Mvv9jlhu6RxYvkqKJwLpPmVdtyAgiZop6HeSIOyFITBEpBIK E843a2fnOhcwgEBoitG1gw+tRjkc2egDZJcf/XLTKNmYKctuwcX67burn8WkT1e8kyue 079w== 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=IJ4n28SxZJ7IvqWaQtHl+XJExCPSVNY+ailM0rBB2SU=; b=HP8+f6i4i4fIkz4uJXSiNsxLV0Q9/R5DwSpOK5zirVsF2xZADg2z904nBhFB/1v+/b JAMiTA5x4Surun7XVdAtSHbxL+DIU+V0hN+8/cLz9hOuTlZ7F0wj9T1uegtYjezxSILj PSV0eAfo4CYmbDefidWOtXkgO0+soOtYMlFh8xdGldj7qlOMZd7ozbZcgCOlJc7uK1rE aWZk70oL78kl/qr/fjL0MlFoEs3z/jHyR4PhhyUM6UyaxyWVturIlpXzlVUqRfhiRWSb dsg/kXe97DKXjR36b3u8STgUC2Fly33dX6s7wuwrr9OfRfVgfTAn4MBGC3kqvEZhIpSB ap2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ahSGl97f; 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=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 a53si11898538edc.175.2019.09.11.00.17.34; Wed, 11 Sep 2019 00:17:34 -0700 (PDT) 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=@linaro.org header.s=google header.b=ahSGl97f; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727297AbfIKHRa (ORCPT + 27 others); Wed, 11 Sep 2019 03:17:30 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36373 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727264AbfIKHR2 (ORCPT ); Wed, 11 Sep 2019 03:17:28 -0400 Received: by mail-pf1-f195.google.com with SMTP id y22so13116142pfr.3 for ; Wed, 11 Sep 2019 00:17:28 -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=IJ4n28SxZJ7IvqWaQtHl+XJExCPSVNY+ailM0rBB2SU=; b=ahSGl97fGWSaYEP376oOKRUvzQemigNFfYzPJEDbyo9WNAIjnvccVhzpgfcoFx6tCj Kjnz0OJXrlo8BX4DpWjSq2xtErHTYecQSlFmkSrscP/EJUJ9nBRAnHb2C2OE6i1FrD95 5m4FwSD2bdglb78BkdowdMcQnQ8YmBOBUY0hzfnyrk3bZI/13MVhuooetfyH4I0+R3JN bbvAyhoOwZU8N4laiXBsxCKVRJ3JhqLT7/S8bNbKhFZsHgQYMlWarHv0VmNCgkq5R6ZB eKhl7/FLRzAv/fFJQHdkdLFXM+nm0TWEFOnGPSZYSl0unAz3CmLjLQhFoNHYBk7li1CL KLGA== 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=IJ4n28SxZJ7IvqWaQtHl+XJExCPSVNY+ailM0rBB2SU=; b=s8rekK2Ma9Vg5lA5Qp8oAZHFxQxV9mCt5RdtO2G8+VYx3GSQP/qbDwoNCbqN2wavSb siZU36l8teRQCOK6f547XTLazXUzJCtAnshp1DYMy/Gn7jNzElb6cMhcuOmts7EzDkPb fRIkLhyYTqHwOZCD28FaTTcxJpgc0RBDoDICV4LiTyAManC8Uh5LWdEd2U3t8vHz+/PL PYVNxwkrahHHbiiQ8HX3/jV6UTcJG4VvSSKRKWFgn47+NR0s5wMrMxJuStDvylMs6sZ8 uvpMisQBa5PT1IIxddHCQF1ZnbVc7IKgRs1kMl6KffGF2hOeL/MvNcJzRyugoF4atmkQ vfsg== X-Gm-Message-State: APjAAAXI+E6YRCexzL7/CkRF6Nv0d20N3AMZdTQLqnFheMNkHo7rfRwM FxgFfAL5HDZC2N9er1ZcYsLaGo3ceQdQmw== X-Received: by 2002:a63:dd17:: with SMTP id t23mr981886pgg.295.1568186247507; Wed, 11 Sep 2019 00:17:27 -0700 (PDT) Received: from localhost ([49.248.201.118]) by smtp.gmail.com with ESMTPSA id s97sm1680031pjc.4.2019.09.11.00.17.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2019 00:17:26 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, agross@kernel.org, masneyb@onstation.org, swboyd@chromium.org, Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: devicetree@vger.kernel.org Subject: [PATCH v3 13/15] arm64: dts: msm8916: thermal: Add interrupt support Date: Wed, 11 Sep 2019 12:46:30 +0530 Message-Id: <29a78d620007af45ed94fa9f3a2199142bae5683.1568185732.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Register upper-lower interrupt for the tsens controller. Signed-off-by: Amit Kucheria --- arch/arm64/boot/dts/qcom/msm8916.dtsi | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi index 8686e101905c..c0d0492d90ec 100644 --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi @@ -176,8 +176,8 @@ thermal-zones { cpu0_1-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens 5>; @@ -206,8 +206,8 @@ }; cpu2_3-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens 4>; @@ -236,8 +236,8 @@ }; gpu-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens 2>; @@ -256,8 +256,8 @@ }; camera-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens 1>; @@ -271,8 +271,8 @@ }; modem-thermal { - polling-delay-passive = <250>; - polling-delay = <1000>; + polling-delay-passive = <0>; + polling-delay = <0>; thermal-sensors = <&tsens 0>; @@ -816,6 +816,8 @@ nvmem-cells = <&tsens_caldata>, <&tsens_calsel>; nvmem-cell-names = "calib", "calib_sel"; #qcom,sensors = <5>; + interrupts = ; + interrupt-names = "uplow"; #thermal-sensor-cells = <1>; }; From patchwork Wed Sep 11 07:16:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 173602 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp374829ilq; Wed, 11 Sep 2019 00:17:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXVwhtkEDbDwRK2bzk/w6FhgCBchkSFkaoCKxZJ3apwm+oz5+FGt3l6iOdpToLbDVDW4FT X-Received: by 2002:a17:906:e0d9:: with SMTP id gl25mr28729565ejb.101.1568186254996; Wed, 11 Sep 2019 00:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568186254; cv=none; d=google.com; s=arc-20160816; b=MhYk6pIXfsOm+daEPrDfXQ7tksYCD9yhsDRzsURmOs41ygRrPLsNDi2nZMixVZHbh9 /chfjQnDnDF7ryd297SEolpAwYMvgYzEGFsIYqBTAL7XT+pAORd4PjE/VotrKWaT9uXy e1WbVEzslmn38UR+dJvD3dyw2PYpWSbzAJpOZ5HqpSEjRiIlKtoSiJSDE2lWXDAh2sNl zWGcsvEYQTBd+Z0W6t13t6wwaAok2DNdBsajw72CsOGGSUqIhq8PfkJnvO1u1xCrK+Rv dFP8Pcwv1inDbFIjzNkkSvbfyK2oRf5bMnkA6v/hPsPoHgh4lu3I2upkB/s5f8ck73CZ 4K0A== 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=3XLPlhPImWAomUfs/g8BXhfm3lVXoZB+dL/zQw9KVyY=; b=JAi3BnOGbHhEN0PwjOkBVSICYahhov70ugq0PsS/5D1AxuRtZuc5lIY/zaYLaYf5aG t6wTZ0QJJeHpoLNE6dkPT0lXs6gN+3bop4lDoGMc866A+6ii8eFg50mJLPKxPrzeW3E7 44mMJHFlMGFZEW7YpSagoLMdVA21KEvxbSzJrgrY9ir9Nv6UkQTwO4x/YDfwpf4EzZDc UcRv6h01CKk8l8/QdxPibocCRVWamkUd8/ILbUy4DfNaOjunbBCKnwJL+EW/EK9eWBkK tZcdAxGNkMC8KO5SfUFM65WGd4thjOnTDAelokFS1J9GhKbQqihNn+HEYTN+B6g7QBKX +0bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GJlxsZb2; 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=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 a53si11898538edc.175.2019.09.11.00.17.34; Wed, 11 Sep 2019 00:17:34 -0700 (PDT) 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=@linaro.org header.s=google header.b=GJlxsZb2; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727313AbfIKHRd (ORCPT + 27 others); Wed, 11 Sep 2019 03:17:33 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38315 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727299AbfIKHRc (ORCPT ); Wed, 11 Sep 2019 03:17:32 -0400 Received: by mail-pf1-f196.google.com with SMTP id h195so13099239pfe.5 for ; Wed, 11 Sep 2019 00:17:31 -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=3XLPlhPImWAomUfs/g8BXhfm3lVXoZB+dL/zQw9KVyY=; b=GJlxsZb21zDn7otYAc58zN7PyahcMkAX7EQUNWffJZs6M0x8PWTmcZ1KKAhmuxa7/v ue70ggqmS5flX5o6oKsh1Yz/o9isB7U1Q3arBhYZJUbO9XqYbFzYbdN35eDe8QaTjGvp tUPhdIgxrboTihBK+X6FS+TpH+nZkcLCRz45g2Mlk3LqqkhmthATiA41Bw20vGxFJbIc MBXQvVkz7jJ0GrBYNYyZOy6cQc9epnmjzyWMhWZ9AMKHyiYXXrk7TZrfRuLmxWtBBz5j i1H1Q4fuYCbQgJ4p+8GfZQLgM5HRg7nrOmYVRS+chWO1JrYsfTnRUS0G5WIPkBXF9PbX z7Nw== 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=3XLPlhPImWAomUfs/g8BXhfm3lVXoZB+dL/zQw9KVyY=; b=o9avzmV/nQ1eXF5NYuRqjDyhv0XQQkKUYgc7H821bjjgVvL14v+0jzav4/36kDYURz jenLzuSTUsMtHX8ozlRf9FkxXU9sYSu5bNS2tbM3+c+P4VNkTYRE6j8oeXXpHXsQhHLO P1eYeI7I1eXaXkbGXAimtoVLA9aRSnOlbAPjXlZ5CTw+8E8b5RZFKvFxvDgeRwfZ0jGp zKPA0DZTj5N1obnDzd+WBbr2YYFiADgj3GKSzoM33U5fuRybhwAqMs8U+sPq0BlO/avI QWw0x8r6a51S8T4vFSX+MH9EqXGuofT0UuejBI15NLGxHs4xXZhEKdvHptDPEHigok08 5Fyw== X-Gm-Message-State: APjAAAXpnbpYWLiPFhcGACURvVvtE9yt8MHTwqnywGoSr7xAHnbL4e6t QMVbgnDLV7bVfF/pnXbgPRj7UwtgA8kcDw== X-Received: by 2002:a65:6097:: with SMTP id t23mr31510470pgu.357.1568186251210; Wed, 11 Sep 2019 00:17:31 -0700 (PDT) Received: from localhost ([49.248.201.118]) by smtp.gmail.com with ESMTPSA id h3sm833961pgb.13.2019.09.11.00.17.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2019 00:17:30 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, agross@kernel.org, masneyb@onstation.org, swboyd@chromium.org, Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v3 14/15] drivers: thermal: tsens: Create function to return sign-extended temperature Date: Wed, 11 Sep 2019 12:46:31 +0530 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hide the details of how to convert values read from TSENS HW to mCelsius behind a function. All versions of the IP can be supported as a result. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 50 +++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index ea2c46cc6a66..6b6b3841c2d0 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -84,13 +84,46 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s) return degc; } +/** + * tsens_hw_to_mC - Return sign-extended temperature in mCelsius. + * @s: Pointer to sensor struct + * @field: Index into regmap_field array pointing to temperature data + * + * This function handles temperature returned in ADC code or deciCelsius + * depending on IP version. + * + * Return: Temperature in milliCelsius on success, a negative errno will + * be returned in error cases + */ +static int tsens_hw_to_mC(struct tsens_sensor *s, int field) +{ + struct tsens_priv *priv = s->priv; + u32 resolution; + u32 temp = 0; + int ret; + + resolution = priv->fields[LAST_TEMP_0].msb - + priv->fields[LAST_TEMP_0].lsb; + + ret = regmap_field_read(priv->rf[field], &temp); + if (ret) + return ret; + + /* Convert temperature from ADC code to milliCelsius */ + if (priv->feat->adc) + return code_to_degc(temp, s) * 1000; + + /* deciCelsius -> milliCelsius along with sign extension */ + return sign_extend32(temp, resolution) * 100; +} + int get_temp_tsens_valid(struct tsens_sensor *s, int *temp) { struct tsens_priv *priv = s->priv; int hw_id = s->hw_id; u32 temp_idx = LAST_TEMP_0 + hw_id; u32 valid_idx = VALID_0 + hw_id; - u32 last_temp = 0, valid, mask; + u32 valid; int ret; ret = regmap_field_read(priv->rf[valid_idx], &valid); @@ -108,19 +141,7 @@ int get_temp_tsens_valid(struct tsens_sensor *s, int *temp) } /* Valid bit is set, OK to read the temperature */ - ret = regmap_field_read(priv->rf[temp_idx], &last_temp); - if (ret) - return ret; - - if (priv->feat->adc) { - /* Convert temperature from ADC code to milliCelsius */ - *temp = code_to_degc(last_temp, s) * 1000; - } else { - 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(mask) - 1) * 100; - } + *temp = tsens_hw_to_mC(s, temp_idx); return 0; } @@ -310,6 +331,7 @@ int __init init_common(struct tsens_priv *priv) goto err_put_device; } } + 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]);