From patchwork Sun Apr 4 14:48:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 415221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E60CCC433B4 for ; Sun, 4 Apr 2021 20:35:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B42D06138B for ; Sun, 4 Apr 2021 20:35:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231584AbhDDUfO (ORCPT ); Sun, 4 Apr 2021 16:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbhDDUfM (ORCPT ); Sun, 4 Apr 2021 16:35:12 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE3CC061756; Sun, 4 Apr 2021 13:35:07 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id h10so10614525edt.13; Sun, 04 Apr 2021 13:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u+Dypwo8bRi3OE80rQmXq/yza31ikZ/pQ/H724ZGyZc=; b=XLMbUX9xVKRSxS4GhHhdck0jLklux7iHiyLYfsYlmLV92fIMCBo1Za0op+e5i9H7rY XAOowvX3hEhooPKzznX8JFqpVyS6DKPi5/yE0tLhTggtrgmwAsehhVHe5Nr8yO8wYEbO 1CYMnNIXPVZB0yjqHlKg2o6S4E/AlQaGj+RCe3F7gjmO/nu34YzHVtCgZO1ftU44IYhT ShQNIrI5JRbviHYXDoVvWVtr6OOeY/232izRGsIl3St72Fxqfb6q9f7Eb33gjLPC2StI m88IA6cZ+2yFJa63buhM+hq2ees2D+rGlhFtsg8saQeo8HmFPdwxUXDXpFaXVFiquQKF MbqQ== 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:mime-version:content-transfer-encoding; bh=u+Dypwo8bRi3OE80rQmXq/yza31ikZ/pQ/H724ZGyZc=; b=ixJJS6pf9YDqg7RBPsvZPYg+m/bRzKULTtgJIfH7dO5383KEJwaFz6+ATsdAeBPjgl uZ6uwh7J5B+y7DqI/ygdhKUF+fS5zP9+1N+e5EMKbCvnpSOALgMHwNvVfY2GyxK2rVKw Baqsentxl4J3iG1EYBfw93vHTHxNNXsk+jBBL7AsaOS07FxKOcD8Fn5zfzjOJtG6Dahp 1RY/ok5lFY1I1pIdIIJXWwMNLUjxApSmNEpotpjooq0LRmIOr00FUY7atGSHfhP4hHFc OWgMxA0HnLWyL2Mu41J72rMf2IIcrQB4AP91vEHOivQJ512wq4z63Wt9owypk9VfPFEa UwcQ== X-Gm-Message-State: AOAM532lF23PGwxm8NKu6pnh5ZObqiXf02ghP2gg+TSZx1F/egGwSXto kwWB7K/8nfchvnjkR99srx0= X-Google-Smtp-Source: ABdhPJwUj6M7SWuR5g9OLX5Ees7R9OYGfFLqah8mjly49k+084aOC72+9ArC1Bd/7o0+B2p5TWx2VQ== X-Received: by 2002:a05:6402:441:: with SMTP id p1mr14470902edw.298.1617568506230; Sun, 04 Apr 2021 13:35:06 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-79-52-251-187.retail.telecomitalia.it. [79.52.251.187]) by smtp.googlemail.com with ESMTPSA id s4sm7191140ejf.108.2021.04.04.13.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 13:35:05 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , kernel test robot , Dan Carpenter , Amit Kucheria , Andy Gross , Bjorn Andersson , Zhang Rui , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 1/9] drivers: thermal: tsens: Add VER_0 tsens version Date: Sun, 4 Apr 2021 16:48:15 +0200 Message-Id: <20210404144823.31867-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210404144823.31867-1-ansuelsmth@gmail.com> References: <20210404144823.31867-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org VER_0 is used to describe device based on tsens version before v0.1. These device are devices based on msm8960 for example apq8064 or ipq806x. Signed-off-by: Ansuel Smith Reviewed-by: Thara Gopinath Reported-by: kernel test robot Reported-by: Dan Carpenter --- drivers/thermal/qcom/tsens.c | 150 ++++++++++++++++++++++++++++------- drivers/thermal/qcom/tsens.h | 4 +- 2 files changed, 124 insertions(+), 30 deletions(-) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index d8ce3a687b80..9a7e991d4bd2 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -515,6 +516,15 @@ static irqreturn_t tsens_irq_thread(int irq, void *data) dev_dbg(priv->dev, "[%u] %s: no violation: %d\n", hw_id, __func__, temp); } + + if (tsens_version(priv) < VER_0_1) { + /* Constraint: There is only 1 interrupt control register for all + * 11 temperature sensor. So monitoring more than 1 sensor based + * on interrupts will yield inconsistent result. To overcome this + * issue we will monitor only sensor 0 which is the master sensor. + */ + break; + } } return IRQ_HANDLED; @@ -530,6 +540,13 @@ static int tsens_set_trips(void *_sensor, int low, int high) int high_val, low_val, cl_high, cl_low; u32 hw_id = s->hw_id; + if (tsens_version(priv) < VER_0_1) { + /* Pre v0.1 IP had a single register for each type of interrupt + * and thresholds + */ + hw_id = 0; + } + dev_dbg(dev, "[%u] %s: proposed thresholds: (%d:%d)\n", hw_id, __func__, low, high); @@ -584,18 +601,21 @@ int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp) u32 valid; int ret; - ret = regmap_field_read(priv->rf[valid_idx], &valid); - if (ret) - return ret; - 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); + /* VER_0 doesn't have VALID bit */ + if (tsens_version(priv) >= VER_0_1) { ret = regmap_field_read(priv->rf[valid_idx], &valid); if (ret) return ret; + 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; + } } /* Valid bit is set, OK to read the temperature */ @@ -608,15 +628,29 @@ int get_temp_common(const struct tsens_sensor *s, int *temp) { struct tsens_priv *priv = s->priv; int hw_id = s->hw_id; - int last_temp = 0, ret; + int last_temp = 0, ret, trdy; + unsigned long timeout; - ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp); - if (ret) - return ret; + timeout = jiffies + usecs_to_jiffies(TIMEOUT_US); + do { + if (tsens_version(priv) == VER_0) { + ret = regmap_field_read(priv->rf[TRDY], &trdy); + if (ret) + return ret; + if (!trdy) + continue; + } - *temp = code_to_degc(last_temp, s) * 1000; + ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp); + if (ret) + return ret; - return 0; + *temp = code_to_degc(last_temp, s) * 1000; + + return 0; + } while (time_before(jiffies, timeout)); + + return -ETIMEDOUT; } #ifdef CONFIG_DEBUG_FS @@ -738,19 +772,34 @@ int __init init_common(struct tsens_priv *priv) priv->tm_offset = 0x1000; } - res = platform_get_resource(op, IORESOURCE_MEM, 0); - tm_base = devm_ioremap_resource(dev, res); - if (IS_ERR(tm_base)) { - ret = PTR_ERR(tm_base); - goto err_put_device; + if (tsens_version(priv) >= VER_0_1) { + res = platform_get_resource(op, IORESOURCE_MEM, 0); + tm_base = devm_ioremap_resource(dev, res); + if (IS_ERR(tm_base)) { + ret = PTR_ERR(tm_base); + goto err_put_device; + } + + priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config); + } else { /* VER_0 share the same gcc regs using a syscon */ + struct device *parent = priv->dev->parent; + + if (parent) + priv->tm_map = syscon_node_to_regmap(parent->of_node); } - priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config); - if (IS_ERR(priv->tm_map)) { - ret = PTR_ERR(priv->tm_map); + if (IS_ERR_OR_NULL(priv->tm_map)) { + if (!priv->tm_map) + ret = -ENODEV; + else + ret = PTR_ERR(priv->tm_map); goto err_put_device; } + /* VER_0 have only tm_map */ + if (!priv->srot_map) + priv->srot_map = priv->tm_map; + if (tsens_version(priv) > VER_0_1) { for (i = VER_MAJOR; i <= VER_STEP; i++) { priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map, @@ -769,6 +818,10 @@ int __init init_common(struct tsens_priv *priv) ret = PTR_ERR(priv->rf[TSENS_EN]); goto err_put_device; } + /* in VER_0 TSENS need to be explicitly enabled */ + if (tsens_version(priv) == VER_0) + regmap_field_write(priv->rf[TSENS_EN], 1); + ret = regmap_field_read(priv->rf[TSENS_EN], &enabled); if (ret) goto err_put_device; @@ -791,6 +844,19 @@ int __init init_common(struct tsens_priv *priv) goto err_put_device; } + priv->rf[TSENS_SW_RST] = + devm_regmap_field_alloc(dev, priv->srot_map, priv->fields[TSENS_SW_RST]); + if (IS_ERR(priv->rf[TSENS_SW_RST])) { + ret = PTR_ERR(priv->rf[TSENS_SW_RST]); + goto err_put_device; + } + + priv->rf[TRDY] = devm_regmap_field_alloc(dev, priv->tm_map, priv->fields[TRDY]); + if (IS_ERR(priv->rf[TRDY])) { + ret = PTR_ERR(priv->rf[TRDY]); + goto err_put_device; + } + /* This loop might need changes if enum regfield_ids is reordered */ for (j = LAST_TEMP_0; j <= UP_THRESH_15; j += 16) { for (i = 0; i < priv->feat->max_sensors; i++) { @@ -806,7 +872,7 @@ int __init init_common(struct tsens_priv *priv) } } - if (priv->feat->crit_int) { + if (priv->feat->crit_int || tsens_version(priv) < VER_0_1) { /* Loop might need changes if enum regfield_ids is reordered */ for (j = CRITICAL_STATUS_0; j <= CRIT_THRESH_15; j += 16) { for (i = 0; i < priv->feat->max_sensors; i++) { @@ -844,7 +910,11 @@ int __init init_common(struct tsens_priv *priv) } spin_lock_init(&priv->ul_lock); - tsens_enable_irq(priv); + + /* VER_0 interrupt doesn't need to be enabled */ + if (tsens_version(priv) >= VER_0_1) + tsens_enable_irq(priv); + tsens_debug_init(op); err_put_device: @@ -943,10 +1013,19 @@ static int tsens_register_irq(struct tsens_priv *priv, char *irqname, if (irq == -ENXIO) ret = 0; } else { - ret = devm_request_threaded_irq(&pdev->dev, irq, - NULL, thread_fn, - IRQF_ONESHOT, - dev_name(&pdev->dev), priv); + /* VER_0 interrupt is TRIGGER_RISING, VER_0_1 and up is ONESHOT */ + if (tsens_version(priv) == VER_0) + ret = devm_request_threaded_irq(&pdev->dev, irq, + thread_fn, NULL, + IRQF_TRIGGER_RISING, + dev_name(&pdev->dev), + priv); + else + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + thread_fn, IRQF_ONESHOT, + dev_name(&pdev->dev), + priv); + if (ret) dev_err(&pdev->dev, "%s: failed to get irq\n", __func__); @@ -975,6 +1054,19 @@ static int tsens_register(struct tsens_priv *priv) priv->ops->enable(priv, i); } + /* VER_0 require to set MIN and MAX THRESH + * These 2 regs are set using the: + * - CRIT_THRESH_0 for MAX THRESH hardcoded to 120°C + * - CRIT_THRESH_1 for MIN THRESH hardcoded to 0°C + */ + if (tsens_version(priv) < VER_0_1) { + regmap_field_write(priv->rf[CRIT_THRESH_0], + tsens_mC_to_hw(priv->sensor, 120000)); + + regmap_field_write(priv->rf[CRIT_THRESH_1], + tsens_mC_to_hw(priv->sensor, 0)); + } + ret = tsens_register_irq(priv, "uplow", tsens_irq_thread); if (ret < 0) return ret; diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index f40b625f897e..8e6c1fd3ccf5 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -13,6 +13,7 @@ #define CAL_DEGC_PT2 120 #define SLOPE_FACTOR 1000 #define SLOPE_DEFAULT 3200 +#define TIMEOUT_US 100 #define THRESHOLD_MAX_ADC_CODE 0x3ff #define THRESHOLD_MIN_ADC_CODE 0x0 @@ -25,7 +26,8 @@ struct tsens_priv; /* IP version numbers in ascending order */ enum tsens_ver { - VER_0_1 = 0, + VER_0 = 0, + VER_0_1, VER_1_X, VER_2_X, }; From patchwork Sun Apr 4 14:48:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 415512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 107B2C43470 for ; Sun, 4 Apr 2021 20:35:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4A8B61242 for ; Sun, 4 Apr 2021 20:35:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbhDDUfR (ORCPT ); Sun, 4 Apr 2021 16:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231574AbhDDUfO (ORCPT ); Sun, 4 Apr 2021 16:35:14 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56E59C061756; Sun, 4 Apr 2021 13:35:09 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id b16so10657990eds.7; Sun, 04 Apr 2021 13:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y1h0oiEek06TjmRnvW1TJaDu7rsgnhNEzErPgw04aKg=; b=WyMg4llpDHhYk+dirmTjlo5L6ARjO9nMv/pG5rQ1cw8aDVQNO1qlsr6IhlD4p6il/5 7z9jrP0dli2MziQGOf8OJ+94NUO5c4LyVPbl+gJIlc3UgZJqCSH1nfd3f4YNBgH/kjKZ np6I9Hyl1P4U8/1C79jVsr6ca/v+GwbOLDR4vNMLrQ5k8XYCJWMb515+rrWYdCUKWhRP Ywd4PnkenTYv2k4F3fN60ThHQwW/rLTD63zNs8zfGAr710wbwjQJ/qbZ4EKB5Po85TsR 0XYRBIIPz82Ga7h91wEdCsbnI91UrGBZFy5QIuh/rSOLAf5NCYdp0a9N/Cvrr77x3QB/ N7kw== 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:mime-version:content-transfer-encoding; bh=y1h0oiEek06TjmRnvW1TJaDu7rsgnhNEzErPgw04aKg=; b=J0yfr5gtnj2SGuGI0UnyANOVQhGEsk2j3yjrtuYP+Ll1eGpG4bfZXg6EZr/bG+i5Tq WK3aByXsx090lnLEd/2m6IfrytPv7Ax6zN3R0uDOpuCFUk+xJ1WnBYYDF4z66uyiBve4 98OB4mJ28ycg2OQd49GC1JAfwNKA8jVCF2znuFZVaZGGFvnr+oB6G3s/bX1Y7ZmGNS08 OCnwt0Q2d4w9pOJXVg3nEp/mJe59XJCNCrbPE2ElfMQkTxPnXSYhqwgL4CzyiEh4e8pm 0ioXC6xSxPhG12Pvjk7FiP3s6CbKrxH5kdId3DH/IlA/JGhxm7ffqSSJGDshFNNSpbiL p3bA== X-Gm-Message-State: AOAM531h01lId35427mrAS6YJu+QJ99BJMJJLerBCDRfRa9QSNzTqdnx 9JIdrkpQTFXfsYjXEdNsXj4= X-Google-Smtp-Source: ABdhPJy5doSxPDqTSDD1JLI32N/uyQe8L6mCX80MEZp48J03nM50Z4bv0P2nE3kyuMGbnKrRN1spSw== X-Received: by 2002:aa7:ca12:: with SMTP id y18mr12424381eds.41.1617568507968; Sun, 04 Apr 2021 13:35:07 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-79-52-251-187.retail.telecomitalia.it. [79.52.251.187]) by smtp.googlemail.com with ESMTPSA id s4sm7191140ejf.108.2021.04.04.13.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 13:35:07 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Amit Kucheria , Andy Gross , Bjorn Andersson , Zhang Rui , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 2/9] drivers: thermal: tsens: Don't hardcode sensor slope Date: Sun, 4 Apr 2021 16:48:16 +0200 Message-Id: <20210404144823.31867-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210404144823.31867-1-ansuelsmth@gmail.com> References: <20210404144823.31867-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Function compute_intercept_slope hardcode the sensor slope to SLOPE_DEFAULT. Change this and use the default value only if a slope is not defined. This is needed for tsens VER_0 that has a hardcoded slope table. Signed-off-by: Ansuel Smith Reviewed-by: Thara Gopinath --- drivers/thermal/qcom/tsens.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 9a7e991d4bd2..38b9936def1a 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -86,7 +86,8 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1, "%s: sensor%d - data_point1:%#x data_point2:%#x\n", __func__, i, p1[i], p2[i]); - priv->sensor[i].slope = SLOPE_DEFAULT; + if (!priv->sensor[i].slope) + priv->sensor[i].slope = SLOPE_DEFAULT; if (mode == TWO_PT_CALIB) { /* * slope (m) = adc_code2 - adc_code1 (y2 - y1)/ From patchwork Sun Apr 4 14:48:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 415220 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F693C43460 for ; Sun, 4 Apr 2021 20:35:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A2C66121E for ; Sun, 4 Apr 2021 20:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbhDDUfS (ORCPT ); Sun, 4 Apr 2021 16:35:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231597AbhDDUfR (ORCPT ); Sun, 4 Apr 2021 16:35:17 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29CB8C061756; Sun, 4 Apr 2021 13:35:11 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id n2so8089577ejy.7; Sun, 04 Apr 2021 13:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fu81fKlLAFW3uWu/bLxRNDUvKBG2yYeAnb3WyHS2HYs=; b=oHdeN+HWREMDFKHEiq6vJ1juBIUqR+r8sa3Z/GUyIpYBuy31O7khXOlOsiUUt+VWp5 9epJ7pAVKhC09oU5ZSWD+gRKgg7L0ZvxETIlnpt19EAIowKK/XXIK5CZI3tOUiTEIoll hH2u8o9/40VqiCU0MUgqv7jJiC2hEeL8duMXsv6mC28sXEUFm0PON4zUBAzmTw6+kfuN gukrwp1eLGhJ8+NhgKN1uohFWGftr9nE1DigCMDE5vnOv6sFFhGrXSaKeJc5p9hs1pJ9 VZtG5+jnI3ck52YAadeNS3Zd0tVKo/X5Osq0ZoumBmgRWamVr+cYXUwtsOEU+DmaD9ka 0SIg== 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:mime-version:content-transfer-encoding; bh=fu81fKlLAFW3uWu/bLxRNDUvKBG2yYeAnb3WyHS2HYs=; b=evQd89RYShBdBUEnxikUtYSn2p9vjUblOtvnhB+D0CjXuJHDicEO8vBKVSRSp0UoKW jfTKqs5xQwi9GT1tCwLMvTt+Xr4bro+sNgLWxtHyUoWKem1J+EDSwlkB3tq0vc73BVZ1 E5BI2pYBTTspPr90IqwBkGNSWZx+4dKFD4++LB1C/OpA8CENiReiYd56fKADfPUVgAQx 3/+15Tfu+cB4k8bZeCMRB20nZ00z1axxPNudcJHrGRm/bSAPu7hSVH4i8d2UiHOW3Anu RFzKKyYtJTWyC2YrN0uCa0VzQqcCoaij31WLgIlHFb3xw/1yUMLUWpmMdcAW7AWmvGR2 e2QQ== X-Gm-Message-State: AOAM533SHZR0ka/6m+EucLaGIjIHDRr10COBJ3L5rKRSukykNpEWuGOq IHC4FsOtXVLn9/4/WJHiFVc= X-Google-Smtp-Source: ABdhPJzp5wanaQiKFAM8qZJ+bJAEvYco5nxRmyhNphZu+F5jf+tmtCqL8CdetYRJS4jVjme7V/ttzg== X-Received: by 2002:a17:906:9501:: with SMTP id u1mr25435512ejx.324.1617568509727; Sun, 04 Apr 2021 13:35:09 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-79-52-251-187.retail.telecomitalia.it. [79.52.251.187]) by smtp.googlemail.com with ESMTPSA id s4sm7191140ejf.108.2021.04.04.13.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 13:35:09 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 3/9] drivers: thermal: tsens: Convert msm8960 to reg_field Date: Sun, 4 Apr 2021 16:48:17 +0200 Message-Id: <20210404144823.31867-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210404144823.31867-1-ansuelsmth@gmail.com> References: <20210404144823.31867-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Convert msm9860 driver to reg_field to use the init_common function. Signed-off-by: Ansuel Smith Acked-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 80 ++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 2a28a5af209e..3f4fc1ffe679 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -51,11 +51,22 @@ #define MIN_LIMIT_TH 0x0 #define MAX_LIMIT_TH 0xff -#define S0_STATUS_ADDR 0x3628 #define INT_STATUS_ADDR 0x363c #define TRDY_MASK BIT(7) #define TIMEOUT_US 100 +#define S0_STATUS_OFF 0x3628 +#define S1_STATUS_OFF 0x362c +#define S2_STATUS_OFF 0x3630 +#define S3_STATUS_OFF 0x3634 +#define S4_STATUS_OFF 0x3638 +#define S5_STATUS_OFF 0x3664 /* Sensors 5-10 found on apq8064/msm8960 */ +#define S6_STATUS_OFF 0x3668 +#define S7_STATUS_OFF 0x366c +#define S8_STATUS_OFF 0x3670 +#define S9_STATUS_OFF 0x3674 +#define S10_STATUS_OFF 0x3678 + static int suspend_8960(struct tsens_priv *priv) { int ret; @@ -269,6 +280,71 @@ static int get_temp_8960(const struct tsens_sensor *s, int *temp) return -ETIMEDOUT; } +static struct tsens_features tsens_8960_feat = { + .ver_major = VER_0, + .crit_int = 0, + .adc = 1, + .srot_split = 0, + .max_sensors = 11, +}; + +static const struct reg_field tsens_8960_regfields[MAX_REGFIELDS] = { + /* ----- SROT ------ */ + /* No VERSION information */ + + /* CNTL */ + [TSENS_EN] = REG_FIELD(CNTL_ADDR, 0, 0), + [TSENS_SW_RST] = REG_FIELD(CNTL_ADDR, 1, 1), + /* 8960 has 5 sensors, 8660 has 11, we only handle 5 */ + [SENSOR_EN] = REG_FIELD(CNTL_ADDR, 3, 7), + + /* ----- TM ------ */ + /* INTERRUPT ENABLE */ + /* NO INTERRUPT ENABLE */ + + /* Single UPPER/LOWER TEMPERATURE THRESHOLD for all sensors */ + [LOW_THRESH_0] = REG_FIELD(THRESHOLD_ADDR, 0, 7), + [UP_THRESH_0] = REG_FIELD(THRESHOLD_ADDR, 8, 15), + /* MIN_THRESH_0 and MAX_THRESH_0 are not present in the regfield + * Recycle CRIT_THRESH_0 and 1 to set the required regs to hardcoded temp + * MIN_THRESH_0 -> CRIT_THRESH_1 + * MAX_THRESH_0 -> CRIT_THRESH_0 + */ + [CRIT_THRESH_1] = REG_FIELD(THRESHOLD_ADDR, 16, 23), + [CRIT_THRESH_0] = REG_FIELD(THRESHOLD_ADDR, 24, 31), + + /* UPPER/LOWER INTERRUPT [CLEAR/STATUS] */ + /* 1 == clear, 0 == normal operation */ + [LOW_INT_CLEAR_0] = REG_FIELD(CNTL_ADDR, 9, 9), + [UP_INT_CLEAR_0] = REG_FIELD(CNTL_ADDR, 10, 10), + + /* NO CRITICAL INTERRUPT SUPPORT on 8960 */ + + /* Sn_STATUS */ + [LAST_TEMP_0] = REG_FIELD(S0_STATUS_OFF, 0, 7), + [LAST_TEMP_1] = REG_FIELD(S1_STATUS_OFF, 0, 7), + [LAST_TEMP_2] = REG_FIELD(S2_STATUS_OFF, 0, 7), + [LAST_TEMP_3] = REG_FIELD(S3_STATUS_OFF, 0, 7), + [LAST_TEMP_4] = REG_FIELD(S4_STATUS_OFF, 0, 7), + [LAST_TEMP_5] = REG_FIELD(S5_STATUS_OFF, 0, 7), + [LAST_TEMP_6] = REG_FIELD(S6_STATUS_OFF, 0, 7), + [LAST_TEMP_7] = REG_FIELD(S7_STATUS_OFF, 0, 7), + [LAST_TEMP_8] = REG_FIELD(S8_STATUS_OFF, 0, 7), + [LAST_TEMP_9] = REG_FIELD(S9_STATUS_OFF, 0, 7), + [LAST_TEMP_10] = REG_FIELD(S10_STATUS_OFF, 0, 7), + + /* No VALID field on 8960 */ + /* TSENS_INT_STATUS bits: 1 == threshold violated */ + [MIN_STATUS_0] = REG_FIELD(INT_STATUS_ADDR, 0, 0), + [LOWER_STATUS_0] = REG_FIELD(INT_STATUS_ADDR, 1, 1), + [UPPER_STATUS_0] = REG_FIELD(INT_STATUS_ADDR, 2, 2), + /* No CRITICAL field on 8960 */ + [MAX_STATUS_0] = REG_FIELD(INT_STATUS_ADDR, 3, 3), + + /* TRDY: 1=ready, 0=in progress */ + [TRDY] = REG_FIELD(INT_STATUS_ADDR, 7, 7), +}; + static const struct tsens_ops ops_8960 = { .init = init_8960, .calibrate = calibrate_8960, @@ -282,4 +358,6 @@ static const struct tsens_ops ops_8960 = { struct tsens_plat_data data_8960 = { .num_sensors = 11, .ops = &ops_8960, + .feat = &tsens_8960_feat, + .fields = tsens_8960_regfields, }; From patchwork Sun Apr 4 14:48:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 415511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E602C43603 for ; Sun, 4 Apr 2021 20:35:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B60B61385 for ; Sun, 4 Apr 2021 20:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231614AbhDDUfU (ORCPT ); Sun, 4 Apr 2021 16:35:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231601AbhDDUfS (ORCPT ); Sun, 4 Apr 2021 16:35:18 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA970C061788; Sun, 4 Apr 2021 13:35:12 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id w3so14337866ejc.4; Sun, 04 Apr 2021 13:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EDfaDBQwdj1r2Yr+BxzE8VnBhjB9D9cT/n8UjW/MV9w=; b=Aze1QDeonXwMNGhzRavTs7Eth2conRKTpO33XAZrCeDHOo7ayejcQ7Cvwr/wmvkv2a gvZn4KTuH/Mo+EJcsuHKNiYg7EP/reoW9ulVUBUPCy5nVR2HpQIeXSP7sH6nwHeo4FUZ WVsKbyVOQLJ2ukQHBACMcXr+IpXuG0Om/BMep+HVtJ4ALxw48IvRklgAxawAumz4uPYx KDi8wnDt/2Jg8rFuh/RTOgGlE7OLtwnGQCU7agK2eA62XApDTvfg2W1zXxv/es3Kr16y hnjRBaHV6lAmVUQmW+jOVjhv5mDURsvnJu2io67uzwOM7IShfSOiJTQmrMES771t1/zp n6sQ== 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:mime-version:content-transfer-encoding; bh=EDfaDBQwdj1r2Yr+BxzE8VnBhjB9D9cT/n8UjW/MV9w=; b=XrqpofZJ8VTJhFeoPUIru2AbEhip/x9AYhokJxgmFNIgingd+eMAIDM6R8JXImQ+CX IWTur4eG+nJk4EWZPmkBc2zWyZD/jsFBodWYpyCiGFh/ufiJIbGy155dFhwCfCzh3qh5 3iorHDLWArhWPBGURFUJ+ySRhAKaKazxfveKmzuBJATS7YZoxs6yKlLKTZLqtMdw+HI7 k74mMCCTIg4Qdk8ZAVUay/ktPZwEBNKJZDhDuyGlHNSk8W6XBxSD/uwi8eihHXvJPXIs pXgM01242XD5a8x2d8pxGS7qjfScsthq7xjH8w6OnaOhVDonO9GQJzFq3j/1VbvXF4ZK TTLg== X-Gm-Message-State: AOAM530fC8cXdNSxYIdooZ9Iq7HWpYC4iljuikY5/BiyEw/uEcBGJKai N2A6kELtN7h5XoFBnuIOHy8= X-Google-Smtp-Source: ABdhPJw7a7eaH7hcklDqCOBU6qUiRGu42Eoj2Pptad1kLUo0DqoudmQ+L+fiNxvMZIgyYLUqwi/SFA== X-Received: by 2002:a17:906:ce4e:: with SMTP id se14mr12246031ejb.54.1617568511454; Sun, 04 Apr 2021 13:35:11 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-79-52-251-187.retail.telecomitalia.it. [79.52.251.187]) by smtp.googlemail.com with ESMTPSA id s4sm7191140ejf.108.2021.04.04.13.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 13:35:11 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Amit Kucheria , Andy Gross , Bjorn Andersson , Zhang Rui , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 4/9] drivers: thermal: tsens: Use init_common for msm8960 Date: Sun, 4 Apr 2021 16:48:18 +0200 Message-Id: <20210404144823.31867-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210404144823.31867-1-ansuelsmth@gmail.com> References: <20210404144823.31867-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use init_common and drop custom init for msm8960. Signed-off-by: Ansuel Smith Reviewed-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 52 +------------------------------ 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 3f4fc1ffe679..86585f439985 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -173,56 +173,6 @@ static void disable_8960(struct tsens_priv *priv) regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); } -static int init_8960(struct tsens_priv *priv) -{ - int ret, i; - u32 reg_cntl; - - priv->tm_map = dev_get_regmap(priv->dev, NULL); - if (!priv->tm_map) - return -ENODEV; - - /* - * The status registers for each sensor are discontiguous - * because some SoCs have 5 sensors while others have more - * but the control registers stay in the same place, i.e - * directly after the first 5 status registers. - */ - for (i = 0; i < priv->num_sensors; i++) { - if (i >= 5) - priv->sensor[i].status = S0_STATUS_ADDR + 40; - priv->sensor[i].status += i * 4; - } - - reg_cntl = SW_RST; - ret = regmap_update_bits(priv->tm_map, CNTL_ADDR, SW_RST, reg_cntl); - if (ret) - return ret; - - if (priv->num_sensors > 1) { - reg_cntl |= SLP_CLK_ENA | (MEASURE_PERIOD << 18); - reg_cntl &= ~SW_RST; - ret = regmap_update_bits(priv->tm_map, CONFIG_ADDR, - CONFIG_MASK, CONFIG); - } else { - reg_cntl |= SLP_CLK_ENA_8660 | (MEASURE_PERIOD << 16); - reg_cntl &= ~CONFIG_MASK_8660; - reg_cntl |= CONFIG_8660 << CONFIG_SHIFT_8660; - } - - reg_cntl |= GENMASK(priv->num_sensors - 1, 0) << SENSOR0_SHIFT; - ret = regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); - if (ret) - return ret; - - reg_cntl |= EN; - ret = regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); - if (ret) - return ret; - - return 0; -} - static int calibrate_8960(struct tsens_priv *priv) { int i; @@ -346,7 +296,7 @@ static const struct reg_field tsens_8960_regfields[MAX_REGFIELDS] = { }; static const struct tsens_ops ops_8960 = { - .init = init_8960, + .init = init_common, .calibrate = calibrate_8960, .get_temp = get_temp_8960, .enable = enable_8960, From patchwork Sun Apr 4 14:48:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 415219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1882AC433ED for ; Sun, 4 Apr 2021 20:35:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE5416121E for ; Sun, 4 Apr 2021 20:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231645AbhDDUfa (ORCPT ); Sun, 4 Apr 2021 16:35:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbhDDUfU (ORCPT ); Sun, 4 Apr 2021 16:35:20 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB4EC061756; Sun, 4 Apr 2021 13:35:14 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id o19so10656695edc.3; Sun, 04 Apr 2021 13:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N4I8SseA+uAjlNmTN1EGCZ72iXk5YAbU2hCUeH8QSlQ=; b=gHVVrudpqwk6BKc70SzI/EGmRh+XiyHKhjeOSRp+GVIReRWn7bsViLC7DVk/ZiitSD ZqAayRhmK7Ys+/BSJ4V9DJ+HGKSVtAW3DhnwUKzYRFe3mSmbvxeZDm8S7hkgvF/yX20h NGIxNSsA21VUYl6KftVAfKBW+mAvNdpHBkGxNzaRrrFocvKedXy03ajxPdISxVm0iu8y MDCo3IBJki3jNkAJyyffrXe84OMNM00Hdx+i7n50W0FoEZl7xrucBWY/VZsYCBSK9WqC B0CXqINlGV4V9YfjHud7bNHmKSEXl7GWfRBMFVzpxDgJS+DVHGbUo9Kiz5zifY6GZ9KT YBaw== 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:mime-version:content-transfer-encoding; bh=N4I8SseA+uAjlNmTN1EGCZ72iXk5YAbU2hCUeH8QSlQ=; b=ueOl65JVeOA+rSWWHMqjwV0JMYhImvCLHVOJtGKMeTtLBj3MoC2HVetfRqwAKkICyC vl1YeTQfE8cdjVVSjj0NCpUZSoxK4YYDOnn+EebT/+GW0R/Z7dqY8xuMR9IyP8C7mPu6 lbw7gZCQxNVp1Bez1RG+RVAyDThJROs2r12ubqRFUoNeEF6Xfh63yteEhqY1vyOZAQu/ aSO6WV/eEC1HAab2f4XMrf9nTJoI2aK6GbMo5OXEvL+Y7w+xoAjbrWE2kvs1ix2za2Ep oFszZTrWXPehFh4E6sI1zeNK2TCbuEHOpczFzDxW6k1QToTqfakNb0f7qzYkQxA9eROQ PnpQ== X-Gm-Message-State: AOAM533/9Hf0VSxP8dM3XmRz2vXi3fgNPSpir0Ocylg2kNmZi2DtGYIu aQNYZuT9bE1C3P1nsWh9lmQ9V/kBLQY= X-Google-Smtp-Source: ABdhPJxCG1LbUCc2+gqmgWSDiRCJIaQRZTpaweAIh3eGU+m8dYKt8HwUZh9EbwbNARARrlKw6iAWrg== X-Received: by 2002:aa7:c957:: with SMTP id h23mr27276746edt.301.1617568513184; Sun, 04 Apr 2021 13:35:13 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-79-52-251-187.retail.telecomitalia.it. [79.52.251.187]) by smtp.googlemail.com with ESMTPSA id s4sm7191140ejf.108.2021.04.04.13.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 13:35:12 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 5/9] drivers: thermal: tsens: Fix bug in sensor enable for msm8960 Date: Sun, 4 Apr 2021 16:48:19 +0200 Message-Id: <20210404144823.31867-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210404144823.31867-1-ansuelsmth@gmail.com> References: <20210404144823.31867-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Device based on tsens VER_0 contains a hardware bug that results in some problem with sensor enablement. Sensor id 6-11 can't be enabled selectively and all of them must be enabled in one step. Signed-off-by: Ansuel Smith Acked-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 86585f439985..95fcccafae14 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -27,9 +27,9 @@ #define EN BIT(0) #define SW_RST BIT(1) #define SENSOR0_EN BIT(3) +#define MEASURE_PERIOD BIT(18) #define SLP_CLK_ENA BIT(26) #define SLP_CLK_ENA_8660 BIT(24) -#define MEASURE_PERIOD 1 #define SENSOR0_SHIFT 3 /* INT_STATUS_ADDR bitmasks */ @@ -126,17 +126,34 @@ static int resume_8960(struct tsens_priv *priv) static int enable_8960(struct tsens_priv *priv, int id) { int ret; - u32 reg, mask; + u32 reg, mask = BIT(id); ret = regmap_read(priv->tm_map, CNTL_ADDR, ®); if (ret) return ret; - mask = BIT(id + SENSOR0_SHIFT); + /* HARDWARE BUG: + * On platforms with more than 6 sensors, all remaining sensors + * must be enabled together, otherwise undefined results are expected. + * (Sensor 6-7 disabled, Sensor 3 disabled...) In the original driver, + * all the sensors are enabled in one step hence this bug is not + * triggered. + */ + if (id > 5) + mask = GENMASK(10, 6); + + mask <<= SENSOR0_SHIFT; + + /* Sensors already enabled. Skip. */ + if ((reg & mask) == mask) + return 0; + ret = regmap_write(priv->tm_map, CNTL_ADDR, reg | SW_RST); if (ret) return ret; + reg |= MEASURE_PERIOD; + if (priv->num_sensors > 1) reg |= mask | SLP_CLK_ENA | EN; else From patchwork Sun Apr 4 14:48:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 415510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57C3EC433B4 for ; Sun, 4 Apr 2021 20:35:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31EB861205 for ; Sun, 4 Apr 2021 20:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231654AbhDDUfh (ORCPT ); Sun, 4 Apr 2021 16:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbhDDUfW (ORCPT ); Sun, 4 Apr 2021 16:35:22 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 519F7C0613E6; Sun, 4 Apr 2021 13:35:16 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id b7so14375235ejv.1; Sun, 04 Apr 2021 13:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eiZ/OUht/kOLQVInECTqjo/bGxXXWMawhAot8IzJzB8=; b=DHgxKcJdJl1+vBQUGSCqG+/SLDhkt1Q3G+9lcmhsqkGtWkzG9+qlvfWSavVfqwyP7O YevRlqyBeY3QrRdPnPTzGIx30I49xurWtmoPPjiNZlPdJZYtB5hSHKM5xnbQaNCGQq1w NHS81GrUBmCC2RDGwLlid+mrcU1W0PEJbVgi/2fujGyk7xollBDoVySOWBhU5bupPAJM WABs8j0XP7Bf36lZrOfaC53LmN8uBOAL6HXBIiA1uP91WtBIuwy3MoSS++l6Iw9aGuDF O57iHGDdtd3iaiKk6tnmVOK83bLD7HJ9P2E7mOpNshVKfgfQX1sqM6Id30XOrbkYezXm ll+g== 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:mime-version:content-transfer-encoding; bh=eiZ/OUht/kOLQVInECTqjo/bGxXXWMawhAot8IzJzB8=; b=QoeFsj2X/QjfnGZg6W2jo30h2hMoKs4ztiOrR+Mult1xF3Rx/ffnMKPCGUwUs1mQSV JHVEc4ZVxTCulj3+WQW0SYkm635Oaabq+9EX1jrGcrGxl8zNLPuh6a2rzRQY4FiLzf6Q nLXWRyDA5y3TLRz3f005gd24m8t3Cit0wZxUj7wo9zGZ/Ldll8Coe2IHAd2hxmVGstkY a5srQeQv0seuDE/qAKWEy/TDnA/JIvQRUOTuOlvKOBKyZX3Pehue9bDvznOniySomL7I NORnIZbFg8iSRzeMtOtJpFGUK0qS36f5AOQ7iM44dPtAxN2jRgOiu95EtoJl7gxu/mCi aNQw== X-Gm-Message-State: AOAM533QS9DgfbHgbou/nUjKHhNnMs/l8KdZQnr5oYCWSqRTyV+Jy12Q Ljauv/G8RDQQJSNggwmUkL8= X-Google-Smtp-Source: ABdhPJwlbubgxeuDgASnmPC8a2FPnxZM7NG/BYBrNI7bca9JRkKuwn6Z7GGA1UMC7K1adhc/GF2OgQ== X-Received: by 2002:a17:906:2dcb:: with SMTP id h11mr5964602eji.278.1617568514914; Sun, 04 Apr 2021 13:35:14 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-79-52-251-187.retail.telecomitalia.it. [79.52.251.187]) by smtp.googlemail.com with ESMTPSA id s4sm7191140ejf.108.2021.04.04.13.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 13:35:14 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 6/9] drivers: thermal: tsens: Replace custom 8960 apis with generic apis Date: Sun, 4 Apr 2021 16:48:20 +0200 Message-Id: <20210404144823.31867-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210404144823.31867-1-ansuelsmth@gmail.com> References: <20210404144823.31867-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Rework calibrate function to use common function. Derive the offset from a missing hardcoded slope table and the data from the nvmem calib efuses. Drop custom get_temp function and use generic api. Signed-off-by: Ansuel Smith Acked-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 56 +++++++++---------------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 95fcccafae14..9cc8a7dd23ae 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -67,6 +67,13 @@ #define S9_STATUS_OFF 0x3674 #define S10_STATUS_OFF 0x3678 +/* Original slope - 200 to compensate mC to C inaccuracy */ +static u32 tsens_msm8960_slope[] = { + 976, 976, 954, 976, + 911, 932, 932, 999, + 932, 999, 932 + }; + static int suspend_8960(struct tsens_priv *priv) { int ret; @@ -194,9 +201,7 @@ static int calibrate_8960(struct tsens_priv *priv) { int i; char *data; - - ssize_t num_read = priv->num_sensors; - struct tsens_sensor *s = priv->sensor; + u32 p1[11]; data = qfprom_read(priv->dev, "calib"); if (IS_ERR(data)) @@ -204,49 +209,18 @@ static int calibrate_8960(struct tsens_priv *priv) if (IS_ERR(data)) return PTR_ERR(data); - for (i = 0; i < num_read; i++, s++) - s->offset = data[i]; + for (i = 0; i < priv->num_sensors; i++) { + p1[i] = data[i]; + priv->sensor[i].slope = tsens_msm8960_slope[i]; + } + + compute_intercept_slope(priv, p1, NULL, ONE_PT_CALIB); kfree(data); return 0; } -/* Temperature on y axis and ADC-code on x-axis */ -static inline int code_to_mdegC(u32 adc_code, const struct tsens_sensor *s) -{ - int slope, offset; - - slope = thermal_zone_get_slope(s->tzd); - offset = CAL_MDEGC - slope * s->offset; - - return adc_code * slope + offset; -} - -static int get_temp_8960(const struct tsens_sensor *s, int *temp) -{ - int ret; - u32 code, trdy; - struct tsens_priv *priv = s->priv; - unsigned long timeout; - - timeout = jiffies + usecs_to_jiffies(TIMEOUT_US); - do { - ret = regmap_read(priv->tm_map, INT_STATUS_ADDR, &trdy); - if (ret) - return ret; - if (!(trdy & TRDY_MASK)) - continue; - ret = regmap_read(priv->tm_map, s->status, &code); - if (ret) - return ret; - *temp = code_to_mdegC(code, s); - return 0; - } while (time_before(jiffies, timeout)); - - return -ETIMEDOUT; -} - static struct tsens_features tsens_8960_feat = { .ver_major = VER_0, .crit_int = 0, @@ -315,7 +289,7 @@ static const struct reg_field tsens_8960_regfields[MAX_REGFIELDS] = { static const struct tsens_ops ops_8960 = { .init = init_common, .calibrate = calibrate_8960, - .get_temp = get_temp_8960, + .get_temp = get_temp_common, .enable = enable_8960, .disable = disable_8960, .suspend = suspend_8960, From patchwork Sun Apr 4 14:48:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 415218 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C7DCC43462 for ; Sun, 4 Apr 2021 20:35:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F52B61383 for ; Sun, 4 Apr 2021 20:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231661AbhDDUfl (ORCPT ); Sun, 4 Apr 2021 16:35:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231623AbhDDUfX (ORCPT ); Sun, 4 Apr 2021 16:35:23 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0049CC061788; Sun, 4 Apr 2021 13:35:17 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id ap14so14394959ejc.0; Sun, 04 Apr 2021 13:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SSBymFhhyIOqT321UgDWQ2JC+SXzbKlWvarnWPwT9jc=; b=bed2VDtdrBvmbK1cD6XYkh/Z2MBHlk4qHfuFUwjHt03mtOZ1NMjvlt+weiD154CMW/ KSwGDtPcG0MeL2fxGWnNn3KbP05+M+dE4W4bmZVDBFJIe6NcywZy/yBhG3p3eOCIY7iG 8MDCZSk7XVD9//joptDe6XR8NncpZYcnEQSp+Tj/VpOH20/OgfGK63ejwTIStimqZNXd dJ8qiWmIOb3c+3Y+BI1Ys46d3b75GpwiVD4N7V5TGeqTtdGfihIGQOKi/xS3SDeWYRgF phhywvULnfpybJR4y9+xw6/rFLE9d4HAwJGIhOkTFuvIKdnxpoWaiTktBEGSbulp1Dui sltA== 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:mime-version:content-transfer-encoding; bh=SSBymFhhyIOqT321UgDWQ2JC+SXzbKlWvarnWPwT9jc=; b=rdijtgO0gsalFfqAn1UoRa7fKsr3YvEDkwGjtSBA5d9YlnzKrOHBCW3Ws4c/99gQyM UcohuonzCkPe+jtjEW9q0MUNiNC7LUnH6IEAlDFcQSIpw6rXgKz+W9WNWh3qu3Bhs2zK 5Sl2Hm9LKq8Qb2dfSeNpXVk2uc9qq+wAQ3feKQ7R1YYhHFOxzybGHF5bVoseJm+elE1s xkcKGeMcByMYmllkOQoI8zBp7Zp/UAtKfryW2mxkhWniM5LLqFsgcsn+znPzTwHNXA0z A/Rb4y0tHlpRO8zGsfnkhmImgUppNGt7vVWWh4Hn5E5O0uIcgKMhImiYVxzn75Bc5DWv DWvQ== X-Gm-Message-State: AOAM533TAUF8mquEQQu2R4ZGh/3rDc1cgn/DlLZeNzFVXS7BGY8XxkCr y8IAyS0aWoR7tll7Qa3Vxco= X-Google-Smtp-Source: ABdhPJzhcFfEv0pDiSkqaudYaSWgzrzFCiy+bfJ9/yHSePw7GYcI12Xc2lwuhg+EN+bWYHe//Ng+ZQ== X-Received: by 2002:a17:906:b341:: with SMTP id cd1mr24876762ejb.391.1617568516617; Sun, 04 Apr 2021 13:35:16 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-79-52-251-187.retail.telecomitalia.it. [79.52.251.187]) by smtp.googlemail.com with ESMTPSA id s4sm7191140ejf.108.2021.04.04.13.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 13:35:16 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 7/9] drivers: thermal: tsens: Drop unused define for msm8960 Date: Sun, 4 Apr 2021 16:48:21 +0200 Message-Id: <20210404144823.31867-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210404144823.31867-1-ansuelsmth@gmail.com> References: <20210404144823.31867-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Drop unused define for msm8960 replaced by generic api and reg_field. Signed-off-by: Ansuel Smith Reviewed-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 9cc8a7dd23ae..58d09e927383 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -10,8 +10,6 @@ #include #include "tsens.h" -#define CAL_MDEGC 30000 - #define CONFIG_ADDR 0x3640 #define CONFIG_ADDR_8660 0x3620 /* CONFIG_ADDR bitmasks */ @@ -21,39 +19,19 @@ #define CONFIG_SHIFT_8660 28 #define CONFIG_MASK_8660 (3 << CONFIG_SHIFT_8660) -#define STATUS_CNTL_ADDR_8064 0x3660 #define CNTL_ADDR 0x3620 /* CNTL_ADDR bitmasks */ #define EN BIT(0) #define SW_RST BIT(1) -#define SENSOR0_EN BIT(3) + #define MEASURE_PERIOD BIT(18) #define SLP_CLK_ENA BIT(26) #define SLP_CLK_ENA_8660 BIT(24) #define SENSOR0_SHIFT 3 -/* INT_STATUS_ADDR bitmasks */ -#define MIN_STATUS_MASK BIT(0) -#define LOWER_STATUS_CLR BIT(1) -#define UPPER_STATUS_CLR BIT(2) -#define MAX_STATUS_MASK BIT(3) - #define THRESHOLD_ADDR 0x3624 -/* THRESHOLD_ADDR bitmasks */ -#define THRESHOLD_MAX_LIMIT_SHIFT 24 -#define THRESHOLD_MIN_LIMIT_SHIFT 16 -#define THRESHOLD_UPPER_LIMIT_SHIFT 8 -#define THRESHOLD_LOWER_LIMIT_SHIFT 0 - -/* Initial temperature threshold values */ -#define LOWER_LIMIT_TH 0x50 -#define UPPER_LIMIT_TH 0xdf -#define MIN_LIMIT_TH 0x0 -#define MAX_LIMIT_TH 0xff #define INT_STATUS_ADDR 0x363c -#define TRDY_MASK BIT(7) -#define TIMEOUT_US 100 #define S0_STATUS_OFF 0x3628 #define S1_STATUS_OFF 0x362c From patchwork Sun Apr 4 14:48:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 415509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3BC9C433B4 for ; Sun, 4 Apr 2021 20:35:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B22816121E for ; Sun, 4 Apr 2021 20:35:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231597AbhDDUfo (ORCPT ); Sun, 4 Apr 2021 16:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231628AbhDDUf0 (ORCPT ); Sun, 4 Apr 2021 16:35:26 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE735C06178C; Sun, 4 Apr 2021 13:35:19 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id dd20so3416277edb.12; Sun, 04 Apr 2021 13:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/vvpDlvlraOIdoUzIW5H4uGiOSzjTMGPHJIWK4bxYUM=; b=C0D7Mbxv9sfBvnKZc4QHHznrU6EKL+tu9rkF+brzwi/syphuHPGTrObh2NG9zfhdSy sKOBwfvmsZP4wPz3ydo5PAlKy02rVl9M30qXSCrMzFre1az6Fx29jji0xzVkhi/14Rg7 j0AFHD2FN5XEXGxsyTjlA6zU2Xd1H+5z24g7jwbYHqQpoSBGgzZD+eTWFAqcLgEVpHcq TjFH2Z5/d9CEjUsPVtfbyvf9EUyA72QjhpOYGQmfGSK9w+xds4KxpgB2e5YDkuPlz4bp Uc8feYJGYa7Gp+/6JaC8reUf3A/6gHJcwSza948TghvAjWf72LAa4/R/W5gfBWhxCiRi /BGw== 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:mime-version:content-transfer-encoding; bh=/vvpDlvlraOIdoUzIW5H4uGiOSzjTMGPHJIWK4bxYUM=; b=EBpEB/Ho1hKeGU53U/hXwKsTpOwV1/W4SfOPjuKPe31zPRQgy4SfFdwxXsTqOuOjLh eUzncTwm+aHy5KPbic0ouMP4oCcIaNCierpYxPW76xbmcgqQNwf7y5ZvPapTegY3su17 uygHtpHerF2xHk7Qv96gm7nqWv13/VNB2MET7YE7SPR/dvwt0MOLmIBu0bPNOaFhUqXe /cxAGZhCDrdN8dd2JnYbmZeWTmK/ZYAzKgr0PdAd0BybyfO66613dBFSNKts8LbdVpg5 qhBKpSKsT2Lek9pOPiVARwqUUE3rM8WOGCtWRjagYs/UdmzDUWwJrzS1lG5TuV2ip9yU 6+og== X-Gm-Message-State: AOAM531hGgBa7ewnBnwG4QjjFtceabpPwmS9FLFYn9gLotTHyye2DS0T r3Gx0KgLhDTXF9tkVydLhSo= X-Google-Smtp-Source: ABdhPJwqP6atKY9GH9tk0azNO+jfyBYEQdG6uSkhS2+OeQN8Rgury4gCcEGrr0b7TdAk8jkrmd71aA== X-Received: by 2002:a05:6402:1109:: with SMTP id u9mr13398187edv.174.1617568518375; Sun, 04 Apr 2021 13:35:18 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-79-52-251-187.retail.telecomitalia.it. [79.52.251.187]) by smtp.googlemail.com with ESMTPSA id s4sm7191140ejf.108.2021.04.04.13.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 13:35:18 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 8/9] drivers: thermal: tsens: Add support for ipq8064-tsens Date: Sun, 4 Apr 2021 16:48:22 +0200 Message-Id: <20210404144823.31867-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210404144823.31867-1-ansuelsmth@gmail.com> References: <20210404144823.31867-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add support for tsens present in ipq806x SoCs based on generic msm8960 tsens driver. Signed-off-by: Ansuel Smith Reviewed-by: Thara Gopinath --- drivers/thermal/qcom/tsens.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 38b9936def1a..58073dc5d30b 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -966,6 +966,9 @@ static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume); static const struct of_device_id tsens_table[] = { { + .compatible = "qcom,ipq8064-tsens", + .data = &data_8960, + }, { .compatible = "qcom,msm8916-tsens", .data = &data_8916, }, { From patchwork Sun Apr 4 14:48:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 415217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D2ADC43461 for ; Sun, 4 Apr 2021 20:35:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4A0161205 for ; Sun, 4 Apr 2021 20:35:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbhDDUfp (ORCPT ); Sun, 4 Apr 2021 16:35:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbhDDUf3 (ORCPT ); Sun, 4 Apr 2021 16:35:29 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70805C061797; Sun, 4 Apr 2021 13:35:21 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id ap14so14395069ejc.0; Sun, 04 Apr 2021 13:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=21TRq5T7n/YlJzaiHd/rYW7/ONn9U06XAcWKZPDtNYI=; b=M4eDEHA7l9wyZKJKdkZ3+WB+zAsyqVMa09C0V4FY+OtPURMur+wQEEu556G6Vr60aE JHYzgsAezfJLn4gGjtWhb5HOtAsNhd4RKEaZJ7R72PJNNC5hv7+1jEBoTArQvhd5nv3o d4/yEs0fGzaJGecJ0yYA8b/MjPUFNst42iBh1Vku40ntMYrw7SyUFbAJQuz0m1uawdwo zSFXgjFfm7ChRDZ3prphxFwfglmu3y80bJJ295zfk8diP14mvMKOcvAfbddFAaNum2tI 3rnGtbyuJF0ZOXeFiWVr7x1jO7uEVo+7XExUfzmroDb+OsbfcEhox7RmWMHca/13+F3+ I5GQ== 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:mime-version:content-transfer-encoding; bh=21TRq5T7n/YlJzaiHd/rYW7/ONn9U06XAcWKZPDtNYI=; b=cqMlfzxDY+W3WIaamf7rik0PZ0ucZcXsqnpku7VwUzPI3Vzo5DFi30r6ykI/c7O5+8 Dx4tMILNceEJTKIWyCNw4YyckMHeUqSh1ixh5rLyWJ/cfYCIOKRI/iLx4zLfr5tfQsCN ZdFp3ywQd+9TcPO6kI3dVFMEOS59+3rBaxuOEBX8mL6j6jcdlF+SMY3tkQhZxJNPXONY xO2VOi04osvvF5JY3MrzZdn0J6C/As6KccGm6P0nyhSYAka0O0FH2rdS27XfB5m0e3dR mylOS+Vhl63iXJp5AabKbIYis5fJZ88VH8Omll8guaGuafsiOEwGPOawctWzGKwn7GG0 oqgA== X-Gm-Message-State: AOAM531axKRuECrKuTQ0oB0Q6d2Rl9NY86dQxAvNC4KbublNaS1xCtw9 qKlAUDN7rL7qpslzCCMXuo8hHQzatkU= X-Google-Smtp-Source: ABdhPJyNXcRjlippyXIMc/+PnZGk2e+9H+1Uy7aUEKqxmoGDzV/o/WLhyc7AWbrwvZr1LTAO9WqoBw== X-Received: by 2002:a17:906:814a:: with SMTP id z10mr11054668ejw.476.1617568520142; Sun, 04 Apr 2021 13:35:20 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-79-52-251-187.retail.telecomitalia.it. [79.52.251.187]) by smtp.googlemail.com with ESMTPSA id s4sm7191140ejf.108.2021.04.04.13.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 13:35:19 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Rob Herring , Amit Kucheria , Andy Gross , Bjorn Andersson , Zhang Rui , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 9/9] dt-bindings: thermal: tsens: Document ipq8064 bindings Date: Sun, 4 Apr 2021 16:48:23 +0200 Message-Id: <20210404144823.31867-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210404144823.31867-1-ansuelsmth@gmail.com> References: <20210404144823.31867-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Document the use of bindings used for msm8960 tsens based devices. msm8960 use the same gcc regs and is set as a child of the qcom gcc. Signed-off-by: Ansuel Smith Reviewed-by: Rob Herring --- .../bindings/thermal/qcom-tsens.yaml | 56 ++++++++++++++++--- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml index 95462e071ab4..1785b1c75a3c 100644 --- a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml +++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml @@ -19,6 +19,11 @@ description: | properties: compatible: oneOf: + - description: msm9860 TSENS based + items: + - enum: + - qcom,ipq8064-tsens + - description: v0.1 of TSENS items: - enum: @@ -73,7 +78,9 @@ properties: maxItems: 2 items: - const: calib - - const: calib_sel + - enum: + - calib_backup + - calib_sel "#qcom,sensors": description: @@ -88,12 +95,20 @@ properties: Number of cells required to uniquely identify the thermal sensors. Since we have multiple sensors this is set to 1 +required: + - compatible + - interrupts + - interrupt-names + - "#thermal-sensor-cells" + - "#qcom,sensors" + allOf: - if: properties: compatible: contains: enum: + - qcom,ipq8064-tsens - qcom,msm8916-tsens - qcom,msm8974-tsens - qcom,msm8976-tsens @@ -114,17 +129,42 @@ allOf: interrupt-names: minItems: 2 -required: - - compatible - - reg - - "#qcom,sensors" - - interrupts - - interrupt-names - - "#thermal-sensor-cells" + - if: + properties: + compatible: + contains: + enum: + - qcom,tsens-v0_1 + - qcom,tsens-v1 + - qcom,tsens-v2 + + then: + required: + - reg additionalProperties: false examples: + - | + #include + // Example msm9860 based SoC (ipq8064): + gcc: clock-controller { + + /* ... */ + + tsens: thermal-sensor { + compatible = "qcom,ipq8064-tsens"; + + nvmem-cells = <&tsens_calib>, <&tsens_calib_backup>; + nvmem-cell-names = "calib", "calib_backup"; + interrupts = ; + interrupt-names = "uplow"; + + #qcom,sensors = <11>; + #thermal-sensor-cells = <1>; + }; + }; + - | #include // Example 1 (legacy: for pre v1 IP):