From patchwork Fri Jan 22 14:55:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 369567 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=-15.8 required=3.0 tests=BAYES_00,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 33D43C433E6 for ; Fri, 22 Jan 2021 15:43:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F287D21D81 for ; Fri, 22 Jan 2021 15:43:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728692AbhAVPnV (ORCPT ); Fri, 22 Jan 2021 10:43:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728846AbhAVO4t (ORCPT ); Fri, 22 Jan 2021 09:56:49 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 573DDC061788; Fri, 22 Jan 2021 06:56:09 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id y187so4580906wmd.3; Fri, 22 Jan 2021 06:56:09 -0800 (PST) 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=Ch8IKvo9eT0XCMxC8iMOyIdf1EBIrdJx0brQO9yCesY=; b=SYfsz/O1Aox4iJ3pToBchspRTvbLnUaI3Mg6AllFe4aHAZ8+OFq/I32HGCYLWrjY5k kYRJAVZ5HZF+GENsOG6uUSJ/uOlXLOaJLPS/2RS+bLlZ92JVEKHD4mAB9HonXbsngJNf loWRuYyfjPYBFfxS3bnGIz6Z+r1rM9P4YCLOdUBVQHkNVmF6CQHK1jpzgPYM4lz76/Rb lsm1t8kwN+UwJUqkv20nbw57AwCljTK5wOQ74yYoXjqWE+k0OeEcnJ39Af6V6t+SkN51 x9LMPRvF1AeQQVJ4bC4EoH5JpyIXwYrvc0uRycHlP2ywUxd5UKPgjTE7EdSK7xeDIPGn jLvQ== 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=Ch8IKvo9eT0XCMxC8iMOyIdf1EBIrdJx0brQO9yCesY=; b=EahQU82UZWpqyMXZ6r9CnBXu3u7HScPbjkt+0TZtiqEoawD9YxmqOoa7pnCS33PsNr af8HAjc72ck5lx0U6We5OGS1KAL1aR4iF7RXJ9fWmdSUA8mKxbgbs5uo6M7nVhOHi20d C+JyS3/hpN32v5qJRpwt+4r8tDjyLoJZ/8cZqXwj4WOd4p9QnlmLCekmjRmWA+VplbkZ T4dgN83a+Yc4ZPGHUscTtqel6ZkIrzqhK6c3z/KSjVzg8/vWxJaLgA6+svaMtqTaP/Tx y9bJJIbMqfSnqnvvvQgTtR2HoLgBvWwlZNt2ZmzjyJc9VFK+UAwfz4KxqmrNk8pwcTzm fe+g== X-Gm-Message-State: AOAM5317GDop1FKUB8eMKp/WoLpMSQ7hvYylOC0+Zc3pDIkwD8gbqK9V TFKMcFWI8GxBYkCwCoRry1g= X-Google-Smtp-Source: ABdhPJyLT1y+exfr8wGr/+kmb97MYHPL2RXhOAj2FSg8k56X2x0dyjJYuVkcB5La+X6JugZ8jD11hA== X-Received: by 2002:a1c:68c5:: with SMTP id d188mr4466710wmc.64.1611327367982; Fri, 22 Jan 2021 06:56:07 -0800 (PST) Received: from ansuel-xps20.localdomain (host-79-45-3-77.retail.telecomitalia.it. [79.45.3.77]) by smtp.googlemail.com with ESMTPSA id t67sm12061106wmt.28.2021.01.22.06.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 06:56:07 -0800 (PST) From: Ansuel Smith To: Amit Kucheria Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , Zhang Rui , Daniel Lezcano , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 1/8] drivers: thermal: tsens: Add VER_0 tsens version Date: Fri, 22 Jan 2021 15:55:50 +0100 Message-Id: <20210122145558.4982-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122145558.4982-1-ansuelsmth@gmail.com> References: <20210122145558.4982-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 --- drivers/thermal/qcom/tsens.c | 171 +++++++++++++++++++++++++++++------ drivers/thermal/qcom/tsens.h | 4 +- 2 files changed, 147 insertions(+), 28 deletions(-) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index d8ce3a687b80..eaeaa1d69d92 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 (priv->rf[TRDY]) { + ret = regmap_field_read(priv->rf[TRDY], &trdy); + if (ret) + return ret; + if (!trdy) + continue; + } + + ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp); + if (ret) + return ret; - *temp = code_to_degc(last_temp, s) * 1000; + *temp = code_to_degc(last_temp, s) * 1000; - return 0; + return 0; + } while (time_before(jiffies, timeout)); + + return -ETIMEDOUT; } #ifdef CONFIG_DEBUG_FS @@ -738,19 +772,31 @@ 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)) { + if (IS_ERR_OR_NULL(priv->tm_map)) { 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 +815,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 +841,66 @@ int __init init_common(struct tsens_priv *priv) goto err_put_device; } + priv->rf[TSENS_EN] = devm_regmap_field_alloc(dev, priv->tm_map, + priv->fields[TSENS_EN]); + if (IS_ERR(priv->rf[TSENS_EN])) { + ret = PTR_ERR(priv->rf[TSENS_EN]); + goto err_put_device; + } + + priv->rf[TSENS_SW_RST] = devm_regmap_field_alloc( + dev, priv->tm_map, priv->fields[TSENS_EN]); + if (IS_ERR(priv->rf[TSENS_EN])) { + ret = PTR_ERR(priv->rf[TSENS_EN]); + goto err_put_device; + } + + priv->rf[LOW_INT_CLEAR_0] = devm_regmap_field_alloc( + dev, priv->tm_map, priv->fields[LOW_INT_CLEAR_0]); + if (IS_ERR(priv->rf[LOW_INT_CLEAR_0])) { + ret = PTR_ERR(priv->rf[LOW_INT_CLEAR_0]); + goto err_put_device; + } + + priv->rf[UP_INT_CLEAR_0] = devm_regmap_field_alloc( + dev, priv->tm_map, priv->fields[UP_INT_CLEAR_0]); + if (IS_ERR(priv->rf[UP_INT_CLEAR_0])) { + ret = PTR_ERR(priv->rf[UP_INT_CLEAR_0]); + goto err_put_device; + } + + /* 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) { + priv->rf[CRIT_THRESH_0] = devm_regmap_field_alloc( + dev, priv->tm_map, priv->fields[CRIT_THRESH_0]); + if (IS_ERR(priv->rf[CRIT_THRESH_0])) { + ret = PTR_ERR(priv->rf[CRIT_THRESH_0]); + goto err_put_device; + } + regmap_field_write(priv->rf[CRIT_THRESH_0], + tsens_mC_to_hw(priv->sensor, 120000)); + + priv->rf[CRIT_THRESH_1] = devm_regmap_field_alloc( + dev, priv->tm_map, priv->fields[CRIT_THRESH_1]); + if (IS_ERR(priv->rf[CRIT_THRESH_1])) { + ret = PTR_ERR(priv->rf[CRIT_THRESH_1]); + goto err_put_device; + } + regmap_field_write(priv->rf[CRIT_THRESH_1], + tsens_mC_to_hw(priv->sensor, 0)); + } + + 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++) { @@ -844,7 +954,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: @@ -930,7 +1044,7 @@ static int tsens_register_irq(struct tsens_priv *priv, char *irqname, irq_handler_t thread_fn) { struct platform_device *pdev; - int ret, irq; + int ret, irq, irq_type = IRQF_ONESHOT; pdev = of_find_device_by_node(priv->dev->of_node); if (!pdev) @@ -943,9 +1057,12 @@ 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, + /* VER_0 interrupt is TRIGGER_RISING, VER_0_1 and up is ONESHOT */ + if (tsens_version(priv) == VER_0) + irq_type = IRQF_TRIGGER_RISING; + + ret = devm_request_threaded_irq(&pdev->dev, irq, thread_fn, + NULL, irq_type, dev_name(&pdev->dev), priv); if (ret) dev_err(&pdev->dev, "%s: failed to get irq\n", 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 Fri Jan 22 14:55:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 369568 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=-15.8 required=3.0 tests=BAYES_00,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 1E2A6C433E9 for ; Fri, 22 Jan 2021 15:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9BF6221FF for ; Fri, 22 Jan 2021 15:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729039AbhAVPm6 (ORCPT ); Fri, 22 Jan 2021 10:42:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728892AbhAVO4v (ORCPT ); Fri, 22 Jan 2021 09:56:51 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FECFC06178B; Fri, 22 Jan 2021 06:56:11 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id 7so5376042wrz.0; Fri, 22 Jan 2021 06:56:11 -0800 (PST) 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=9TJ+/IkMxCE3Me3OscF6ay8YRP3qL8IEtjgxoP99DSE=; b=cxHyY/FVCw/X5svm8Qu0VnrrVJEGOazWmHO4CB17IYWyA0fsxqZCY/QYNy4YyKEJeT aU20Dlyb1VDlfbF+gMPP5TE8Ng/d6b9PrI+8QkXqpjYuN2sLY6Hf+B3RpM0jowo9Mn/g 9IPbvXl9il4Xj79wsvAnFlb/Ej5O3/VqrU3o7AjIdJ0ImxLWtODdGkYqmaOn/3VPcabf 336K5SklrCsdAyxbvvs9nYi2EwbbZ8IZtYhEDJVyJ6NGFMZ2mR8Hh8jgMT5uWyir+RK2 1BOJ7Mi7KTHEH6hZePGKlFvWXy056xPJ8lVtATmVHaGCW5pODM8KMJytqR6DL790PnLg 0y0A== 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=9TJ+/IkMxCE3Me3OscF6ay8YRP3qL8IEtjgxoP99DSE=; b=WiaPrGs8OihYOZMPc9lQJ4Hwq9tB7TsNtmlCdOLS4O/C2HrcwNGW/tr7FpOX91usRN Xm2nJZvxUspuuJuQlCP958oz8IvCyLFPIIOGyDpcwXIffNJ0xn5lovdVpgAl8hhSPo8q H56JKZxD/MWSBf9cY9lTIByHnjEse6OOsBT3KWy1/wS42bTAn5UNN14BDSLzFD+ltaRn B3Ml61an0ZZ3utpC6sdVFwwsD8tPaVwfEtloeNV+jQ51KS2zwk1eO6ycIaHJvrnGx+CV 5dM8SzDZZcFhuG5r2IfWcEXMSu9DVHGQSGgC7omEZJePqg6+ijPgOr6uO5BeKrWfQc2e 0x0g== X-Gm-Message-State: AOAM532RbKXd4P9UPe8ge9xxp0Mh2u571CIpgiiyBiuCxlDu7dbDroZ9 a7WpbLnLl68D07UAE6tqiGUdkAggk5c= X-Google-Smtp-Source: ABdhPJzsO04XZDJRgeeAPrSvIZafo4LUEtAla8FgFzhnj7krLNREArmsRUIzWiFcTUHpdgQerj0epg== X-Received: by 2002:adf:eb4c:: with SMTP id u12mr4744207wrn.79.1611327369963; Fri, 22 Jan 2021 06:56:09 -0800 (PST) Received: from ansuel-xps20.localdomain (host-79-45-3-77.retail.telecomitalia.it. [79.45.3.77]) by smtp.googlemail.com with ESMTPSA id t67sm12061106wmt.28.2021.01.22.06.56.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 06:56:09 -0800 (PST) From: Ansuel Smith To: Amit Kucheria Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , Zhang Rui , Daniel Lezcano , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 2/8] drivers: thermal: tsens: Don't hardcode sensor slope Date: Fri, 22 Jan 2021 15:55:51 +0100 Message-Id: <20210122145558.4982-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122145558.4982-1-ansuelsmth@gmail.com> References: <20210122145558.4982-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 --- 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 eaeaa1d69d92..dd9b41157894 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 Fri Jan 22 14:55:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 368824 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=-15.8 required=3.0 tests=BAYES_00,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 D4D93C433E6 for ; Fri, 22 Jan 2021 15:42:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FF1321D81 for ; Fri, 22 Jan 2021 15:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728944AbhAVPly (ORCPT ); Fri, 22 Jan 2021 10:41:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbhAVO4x (ORCPT ); Fri, 22 Jan 2021 09:56:53 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ABE8C061793; Fri, 22 Jan 2021 06:56:13 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id v15so5356266wrx.4; Fri, 22 Jan 2021 06:56:13 -0800 (PST) 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=TUyV4UxuBDG5mZmRaEbJxIt6bYkgDPDRVG86Pvqb/08=; b=UjKxO3JoxsqYP452rB9TFmbHhZlS2GZAwPerSoEu7+tFI7m+zyVTS7/RsfNl+o4GkG w86t/MTERm/WtmzkP8gFss7vGcyp2iQld8xqtl9zlp0iiHDMVo+4urJzR3ZLX8hBPwtS vXwCIrydO4pM1bOr2sDeq8ejI7Is5MvTMvSuG5hm9KcXizgPdudPlAcP8g4+995wy/uo opvAwdidAUhi1BOl9zaIeqSRxOMl8N4eJvuAGSBuKy9Nyjq8wvAeA4o+bn53Gt5hz5K1 l9CqpQZ2/ASwDDyVegOMR1kOU5GtSPCNCNBKaJ4x4Nwt8votptpqnKLUeCGwiRXrma3Q bqFQ== 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=TUyV4UxuBDG5mZmRaEbJxIt6bYkgDPDRVG86Pvqb/08=; b=sGLxAWQt/6vera4DeaMNirPr4SjSrJ1zlykdAFKooVsPM3239Nf2jwpmqZmARVXj4f N5XIM8I5grEK09TjlW3q5XcGckb+o8PjqKUCwWnq0qKIGOZA0JFf6i3WS2ftxsKMQANx zinW6ve/gVmxS24deWhmS8zkJesyEyduQ9rhJZXJR4OTvJFYGyDKQ2ht4v0qIMEcOTYY 9v6uKCZNqUhQa5zxUWsy2UV/VjYjRa6scKHGeNQayy1UmTWjTBnk2WbTz3edXuX2hlo0 jce3/DoVur8YbpdmJQs/bUjpofUQZ+mErJ054hG0rySBnjmSdDdB+H2QJxPWGF39NLl3 Jn+A== X-Gm-Message-State: AOAM53271ambd3IboPSRLwzF1zcGFYJAHvo0DbB8u6fyKPw1RwEvO0gB TWty3DjGiFP4Dy1SCdYA/84= X-Google-Smtp-Source: ABdhPJzMOJV57z6zDjH66FHX/UuH5601F+jXz5C/lpXaqkCkxA//tnGijxjazBQmisocKPgL+qK4aA== X-Received: by 2002:a5d:53c3:: with SMTP id a3mr4757045wrw.43.1611327371803; Fri, 22 Jan 2021 06:56:11 -0800 (PST) Received: from ansuel-xps20.localdomain (host-79-45-3-77.retail.telecomitalia.it. [79.45.3.77]) by smtp.googlemail.com with ESMTPSA id t67sm12061106wmt.28.2021.01.22.06.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 06:56:11 -0800 (PST) From: Ansuel Smith To: Amit Kucheria Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , Zhang Rui , Daniel Lezcano , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 3/8] drivers: thermal: tsens: Convert msm8960 to reg_field Date: Fri, 22 Jan 2021 15:55:52 +0100 Message-Id: <20210122145558.4982-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122145558.4982-1-ansuelsmth@gmail.com> References: <20210122145558.4982-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Convert msm9860 driver to reg_field to use the init_common function. Signed-off-by: Ansuel Smith --- 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 Fri Jan 22 14:55:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 369569 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=-15.8 required=3.0 tests=BAYES_00,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 A879FC433DB for ; Fri, 22 Jan 2021 15:42:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B2C720702 for ; Fri, 22 Jan 2021 15:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728863AbhAVPkX (ORCPT ); Fri, 22 Jan 2021 10:40:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728922AbhAVO5P (ORCPT ); Fri, 22 Jan 2021 09:57:15 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF1C2C061794; Fri, 22 Jan 2021 06:56:14 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id c12so5359508wrc.7; Fri, 22 Jan 2021 06:56:14 -0800 (PST) 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=yP+8b8XvGsdxgGgAFZqhFaVyr9bwBdl4LtN4K2NEQ40=; b=f05PEk0c5HWVGdKSSzSm7fRbXgjAkneXwjqBtUS5hRazeOkj213OlHBdTdCNgb8rtQ 4dQerMKq2A6Nx64Mgcbuxu19WKl1PO1rOEexAzAPu6XP8ydbzoMtzcI9P9DUzp2vx2rv DU/GiDVDZQfWVbXZpY1onv/FISZdzrmy20jPs0c9t4Ye1t1N1Xk+11tPXSR9x3JonRzL yplshh0tIe5322XtY886fDVEcONrmlHsLC7jjydMgISIOxRWUKIPKovqv2nv9LVWn2FD DZO+hliwSWBSRLmkQ70ufzS752M7FV9qNCdLqawShFIYUKFT9osF/ThzkWC+a41k6yfV +hdg== 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=yP+8b8XvGsdxgGgAFZqhFaVyr9bwBdl4LtN4K2NEQ40=; b=QMnB1q96/8fHGo7N7zPa4aLZolQkd34kBHiiLW8+raINkDVsdE9/N5uoWw2U3h85Od ldqdnkvw+afIaursecjYe1HD4SDzy9eLfIIjhi7WRoGYiKRYS6XHUZlcYRc4TWIqvBAy FHM4hxDBFDhQDu/0TVW11rUs6DPZIQo3c0b3efxv1ZpGVDkH3eXwbgcmgO1MiY9n3/9b 0qtQ26UxRp9xYB9jnBXSn2eibiK827IcFrxwMzk83DGnVyiePV/bWPn+BK40lIXcDYcI vP0SGUQDJae45fvfJXaQbWKNQOwVaiyYwCeVKlbnoDV+rmr3IkjhMXg54TNxXQ2pcM8C FqLQ== X-Gm-Message-State: AOAM533V7wd6mie5GVVYNI8N5t/F+rVdxXKqpb2bBzS8xjNC8W12lfp3 K/NnCiybuDh/3BhqkNhhfqA= X-Google-Smtp-Source: ABdhPJyRqwyuJ3LS7JNe80cWqU1vQj4b6II8iiTduSfOwyhpUHvZsTxfwYg3SMgpR1SNbwV73LD51Q== X-Received: by 2002:adf:9e04:: with SMTP id u4mr4913396wre.362.1611327373669; Fri, 22 Jan 2021 06:56:13 -0800 (PST) Received: from ansuel-xps20.localdomain (host-79-45-3-77.retail.telecomitalia.it. [79.45.3.77]) by smtp.googlemail.com with ESMTPSA id t67sm12061106wmt.28.2021.01.22.06.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 06:56:13 -0800 (PST) From: Ansuel Smith To: Amit Kucheria Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , Zhang Rui , Daniel Lezcano , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 4/8] drivers: thermal: tsens: Use init_common for msm8960 Date: Fri, 22 Jan 2021 15:55:53 +0100 Message-Id: <20210122145558.4982-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122145558.4982-1-ansuelsmth@gmail.com> References: <20210122145558.4982-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Use init_common and drop custom init for msm8960. Signed-off-by: Ansuel Smith --- 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 Fri Jan 22 14:55:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 368825 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=-15.8 required=3.0 tests=BAYES_00,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 0355BC433E6 for ; Fri, 22 Jan 2021 15:40:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFE1D20684 for ; Fri, 22 Jan 2021 15:40:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728777AbhAVPka (ORCPT ); Fri, 22 Jan 2021 10:40:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728918AbhAVO5P (ORCPT ); Fri, 22 Jan 2021 09:57:15 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 035FBC061797; Fri, 22 Jan 2021 06:56:17 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id o10so6838057wmc.1; Fri, 22 Jan 2021 06:56:16 -0800 (PST) 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=//vxmImvEZezGNbMSIPWRQhGQeqxvlD68gBH9D1FgFg=; b=JPar7D3w+4QjE7ggC2yQUd84apZvRlfnhsMeP3VfxutsXPkOv2YARWvy7r+jcSbjMz g9e1j6lqPQRFHjBJLwCKF/yyOxsVyHSXDhaZOWxRPDxtjcwM870Lcn9ffBsEHLO+hCpS plyVfXmYe1PVCbAlQwRpAqQm6oHJ57wUVckSujUam2Pxem58n9WZXuGRQCJ3DJFLKuiW yiBwT3Eh5IlssUVChG9xxlTkYC0KYBfzSdJY1OzZxBqc9SEG/hgwIJbWHA4NP2hXDGip u0qYtwhxyTziey28d+SPlzqRWSrQaE/MHZXIX6H41fzr8jdJNItEMgVlf9OerZ/RYLBE 2i9w== 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=//vxmImvEZezGNbMSIPWRQhGQeqxvlD68gBH9D1FgFg=; b=Rb9s2c1I/s2c7VAMqkBz/vGDeiW6Av3SkodDVLVNlxn0whaPuoGzx7dygLRst1Mp4m TQAOKW7eU7vY3EidqweiGXVD54nHknLOuAj8Hjj5mm7DrPmvDKe5u7GIr2SLQV1rLABR mwAF4iXuulhSfUqloZOTknRlbiAhmUL6BRbG1vGFmnJ+VWw0kzely30i1+X6GgzOla9g MM47QO3hyKCXq2GunjYnkVso1UzFeTO66G7ANucZIlM4qMHNCM7p1VB+voKUJZYuw5Jt UMw8hijNcf5OUlBtXdbLi+QC2KKagjX5PgYWt2M5vu3pTGOxYeUNntf4DTiXD3vZIpSO KJ3w== X-Gm-Message-State: AOAM533ut2WruRREcc3EV+GZVhtmAXMNkHi2BKVqRcYYKzMVn1YWmuE7 d7gH8mbh98ig/y7ENiL8nUw= X-Google-Smtp-Source: ABdhPJzsPfIhwyo5zD/eGSjW/yDGzdjyLGuFZrXt5nMls6xsdf7VpzXEuw2Eosd2paxB7oLsbK7wbg== X-Received: by 2002:a7b:c779:: with SMTP id x25mr4322874wmk.138.1611327375585; Fri, 22 Jan 2021 06:56:15 -0800 (PST) Received: from ansuel-xps20.localdomain (host-79-45-3-77.retail.telecomitalia.it. [79.45.3.77]) by smtp.googlemail.com with ESMTPSA id t67sm12061106wmt.28.2021.01.22.06.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 06:56:15 -0800 (PST) From: Ansuel Smith To: Amit Kucheria Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , Zhang Rui , Daniel Lezcano , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 5/8] drivers: thermal: tsens: Fix bug in sensor enable for msm8960 Date: Fri, 22 Jan 2021 15:55:54 +0100 Message-Id: <20210122145558.4982-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122145558.4982-1-ansuelsmth@gmail.com> References: <20210122145558.4982-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org It's present a hardware bug in tsens VER_0 where if sensors upper to id 6 are enabled selectively, underfined results are expected. Fix this by enabling all the remaining sensor in one step. Signed-off-by: Ansuel Smith --- drivers/thermal/qcom/tsens-8960.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 86585f439985..248aaa65b5b0 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 */ @@ -132,11 +132,26 @@ static int enable_8960(struct tsens_priv *priv, int id) if (ret) return ret; - mask = BIT(id + SENSOR0_SHIFT); + /* HARDWARE BUG: + * On platform with more than 5 sensors, all the remaining + * sensors needs to be enabled all togheder or underfined + * 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); + else + mask = BIT(id); + + mask <<= SENSOR0_SHIFT; + 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 Fri Jan 22 14:55:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 369570 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=-15.8 required=3.0 tests=BAYES_00,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 00387C433E9 for ; Fri, 22 Jan 2021 15:27:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C643523AC9 for ; Fri, 22 Jan 2021 15:27:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbhAVP13 (ORCPT ); Fri, 22 Jan 2021 10:27:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729000AbhAVO6c (ORCPT ); Fri, 22 Jan 2021 09:58:32 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03B6FC0617A7; Fri, 22 Jan 2021 06:56:19 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id c12so5359726wrc.7; Fri, 22 Jan 2021 06:56:18 -0800 (PST) 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=2bCUVYm5PTbXlWccEltwKHodbOdPVGehKn93HfL2DGM=; b=t7CvHMhH2VnX6/nw9MHOmL+jH7YzDjLWJxJEob8JyzUUfB0eRR3WfaO++FkmysERJC 9omrrTyJmdDcan4VKHfMTDAEHo6QRjxnuMZSO1XVhUyylyUM97IWVCmi1X3vu/QvbKF7 SqM49a5o0J2WWlhWBBvNvf3RCBlcu535dKstKTTqKkyh8qzUq59ON7Anhp/+LXYJx/EA vPqB3fiIamti06sq7X1gn9urgNYsvwgzaZPvETJuZ0Hf1cG8Y0iHQrVWORfn+5dWjrSW L117IcEy+EFFFdyZ464k0JDDZmx601tCjX9A9L9Lh7PIWuQZ49cN/bmPafNFCuJji4De Iryg== 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=2bCUVYm5PTbXlWccEltwKHodbOdPVGehKn93HfL2DGM=; b=r7paTqIdik6VEeTxsEyKQjT4ug23FbtJVAT3YTALX7XNmfb070BVz8kZ6s2VSP6T1G n+XZlDmm/1KIyMUMpDLbib4+E8s6zLB/NuytH8WY9n94XJcnlgHImC9oqevHkOxOQE8R wwDYsv4aYjxj6GMMWhFd0rBLc/XpV+bhHU6Q6fFIrfzovkQ4R4PVTsmVeKSL+asBK85x oGOqpwQWRY65jEL0oQp7qOsbEMcqSdDKzgnapTtMduVxKiOaEjzYyZUECF3kmz0NgJZX 7MpnmGZJe6GSskF5yywNQsx2JneiohAf/WzgVM3OcC0TmWkdoeYn9D8/FNuP0KgxYrmM QjJQ== X-Gm-Message-State: AOAM533Pjl2sHhR4i6SgCYI1Aey1IGmluc7LBACbzUYxrJelBsXc+bMq ofUprc2sQssCOTpS/LnBqyg= X-Google-Smtp-Source: ABdhPJwZKXjVgEPuYTX3Ov3t+V9Rekl3EjhYmDqvz4Cyk937lWhvMTlS1jZi1KCMEwZ/KZJh+/Ke1A== X-Received: by 2002:adf:81e4:: with SMTP id 91mr5012620wra.161.1611327377679; Fri, 22 Jan 2021 06:56:17 -0800 (PST) Received: from ansuel-xps20.localdomain (host-79-45-3-77.retail.telecomitalia.it. [79.45.3.77]) by smtp.googlemail.com with ESMTPSA id t67sm12061106wmt.28.2021.01.22.06.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 06:56:17 -0800 (PST) From: Ansuel Smith To: Amit Kucheria Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , Zhang Rui , Daniel Lezcano , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 6/8] drivers: thermal: tsens: Use get_temp_common for msm8960 Date: Fri, 22 Jan 2021 15:55:55 +0100 Message-Id: <20210122145558.4982-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122145558.4982-1-ansuelsmth@gmail.com> References: <20210122145558.4982-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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. Signed-off-by: Ansuel Smith --- 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 248aaa65b5b0..43ebe4d54672 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 */ +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; @@ -192,9 +199,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)) @@ -202,49 +207,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, @@ -313,7 +287,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 Fri Jan 22 14:55:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 368826 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=-15.8 required=3.0 tests=BAYES_00,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 E301DC433DB for ; Fri, 22 Jan 2021 15:27:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA4A423A9A for ; Fri, 22 Jan 2021 15:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728912AbhAVP11 (ORCPT ); Fri, 22 Jan 2021 10:27:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728999AbhAVO6c (ORCPT ); Fri, 22 Jan 2021 09:58:32 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6404C0617AA; Fri, 22 Jan 2021 06:56:20 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id j18so4572331wmi.3; Fri, 22 Jan 2021 06:56:20 -0800 (PST) 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=oRiSzjbPGSuciDDwZK/ZEDlRzVvbEgMvnG2EnKEi2b8=; b=L6Ygo3hK0BX1f3+JDGOMBtHh+qr8OWGp7hGmkGE3+w/e+knL6x+oTl2BV0sSqO+a5F TA1tWDw43iMxVR5C10gDvsGnkOnWRspKb4tvCES3y6A5racbtxoZPkeroJpCkDBAS8MT psGxTuIJ/jTzDVzkt4OBouoK9mfTJT2gta+kiaPxnH95J6Iw1qCqnM8xMFfY5vdWbrDg vgE4njiu6DpSoWyTKXiCOZpnADC0rJjT1865LBH2CJZ0yJ+iCtD95gXs8Ifvoydywzx0 wGPRqQhQ3Dwq67kIvmI+/cpiu9IiQPWZ1tvyeQreqnM0kE5csocdQi/b825Z/dCmN7QA 9DNQ== 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=oRiSzjbPGSuciDDwZK/ZEDlRzVvbEgMvnG2EnKEi2b8=; b=L11xWiaDQvOJCwEydJje4nd/k5o6HxPYDvx4XyDHDjd49XU38IjC0WybmnB4Cqs0in 6/3pezk0TyD4Sbm1BHRAqzn9wjobEjTw1wOwJux3E+Z27wQjcyYciZaITG84H7Ntm7j6 tvTs7vAdWVOdZUsUjuaUiFXnTjM9PunBkqWx72AI3Fp0vS1S8dLUbsEpl+zPtkQHd7jw P/JWdaX2L3Qb70yffahKaJn6MfDr8YUPNLkwXrRCH1HZnxS1ogAg3iBOdz/6U4yGG8Ea 8v+UOU3r4BqL9vARIUN+lcEKvCT22jLuoP2rJeWjQ09MvRfY0Wg+x/rv21s3gl9izo80 pX0Q== X-Gm-Message-State: AOAM530czRtbmZKe1UEzssUSAjF2S+uxjrn49tz+TjSdWeLecQWzRLul 4CgEkzhbmh8g9cM3h2Gif24= X-Google-Smtp-Source: ABdhPJxFShSH4Koq6q9pe58TzCj1QaVOsfdgQV2tiwpaANLabv9sCSYTZGjenu2JNEr93hee4eE/qg== X-Received: by 2002:a1c:bcd4:: with SMTP id m203mr4318428wmf.120.1611327379576; Fri, 22 Jan 2021 06:56:19 -0800 (PST) Received: from ansuel-xps20.localdomain (host-79-45-3-77.retail.telecomitalia.it. [79.45.3.77]) by smtp.googlemail.com with ESMTPSA id t67sm12061106wmt.28.2021.01.22.06.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 06:56:19 -0800 (PST) From: Ansuel Smith To: Amit Kucheria Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , Zhang Rui , Daniel Lezcano , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 7/8] drivers: thermal: tsens: Add support for ipq8064-tsens Date: Fri, 22 Jan 2021 15:55:56 +0100 Message-Id: <20210122145558.4982-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122145558.4982-1-ansuelsmth@gmail.com> References: <20210122145558.4982-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support for tsens present in ipq806x SoCs based on generic msm8960 tsens driver. Signed-off-by: Ansuel Smith --- 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 dd9b41157894..586b90962605 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -1010,6 +1010,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 Fri Jan 22 14:55:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 368827 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=-15.8 required=3.0 tests=BAYES_00,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 5CDB7C433DB for ; Fri, 22 Jan 2021 15:27:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26B6623A9A for ; Fri, 22 Jan 2021 15:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728826AbhAVP0t (ORCPT ); Fri, 22 Jan 2021 10:26:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729015AbhAVO6g (ORCPT ); Fri, 22 Jan 2021 09:58:36 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6159C0617AB; Fri, 22 Jan 2021 06:56:22 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id o10so6838214wmc.1; Fri, 22 Jan 2021 06:56:22 -0800 (PST) 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=B7EH7hNQ0zHbFUPaZhxibjy/gRki2XnmNMbonXYtYOI=; b=sIESIdpSd7hwu8Ko1MbUFAXvXE1SUmmw12lygBcnZviJN/KjPQWGg75jvFEolD5wLa MJIMJFW02nLX6CBEj0mh7lK+FQuiwAKMMbDfxuWw4Rna/CueS44ZYsKAcBVQ9iRpIAFj WJO+By6WHksqkavTUVbHimMas+yOwaJ0xGGg/JJrit2KzefnbEHwmxSad9we9EAL2CgE hy06PZ3n6kAsfKO5jO5h7aENu/1m+81xuRs16S+M47NDU/iQWJ9TfxoGyzFO1WhK99ug QGxM6z4NgvmeB+nKguIn2Zi5OdrxseKZimBYhLRt06MlB74fh+FjhsLAi5zMuEqRyxkD XZvw== 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=B7EH7hNQ0zHbFUPaZhxibjy/gRki2XnmNMbonXYtYOI=; b=YPHEKCNE+snLftdPyw3bMss1xciOweiX7XOPN3S9SNrqwjbESPtyrApWHDcUf+Nt0m I7dOH59IiusPSjOd7Fh+AssOydHRLUqhmfwVpZQQTwoy3I9O4XuD2gIoCcmYMeDmXXth VWZ4D+xAUrRcH0oc5+XsLRjnoXvqjbUdSCHIOCJ8aOuxDzm+OijGArVGMe+vT8KL+ZYY GqJNkm1TqLZw0CHo2L2AKZlOP3gdSinbThEph94Cs106GW4EfpZavILA5IhXTA2edP3g b2Gr0ooGzZ0r9aT2s4PgLazypkC7LNzrBKKF/SniPwBVwLlVKFZvuUQ22jg5h1usbWTr tZSQ== X-Gm-Message-State: AOAM531vVVGLPTSa6bHCz2+n9HN6TWWYvJ3Grg+5sji0PDf6idq74fwo UguygfJBPAivLWuyS/f9ufQ= X-Google-Smtp-Source: ABdhPJznkSwyqoo2U/wWDUkykiCgx3b/7Y3zWLXo7VtZ8AeRrIMPIYsLaxuveBRIMEmKsp/3rAEh6w== X-Received: by 2002:a1c:1f83:: with SMTP id f125mr4415561wmf.82.1611327381526; Fri, 22 Jan 2021 06:56:21 -0800 (PST) Received: from ansuel-xps20.localdomain (host-79-45-3-77.retail.telecomitalia.it. [79.45.3.77]) by smtp.googlemail.com with ESMTPSA id t67sm12061106wmt.28.2021.01.22.06.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 06:56:20 -0800 (PST) From: Ansuel Smith To: Amit Kucheria Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , Zhang Rui , Daniel Lezcano , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 8/8] dt-bindings: thermal: tsens: Document ipq8064 bindings Date: Fri, 22 Jan 2021 15:55:57 +0100 Message-Id: <20210122145558.4982-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122145558.4982-1-ansuelsmth@gmail.com> References: <20210122145558.4982-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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):