From patchwork Wed Nov 25 17:48:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 333370 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_06_12, 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 581AEC64E7B for ; Thu, 26 Nov 2020 02:13:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08259207BC for ; Thu, 26 Nov 2020 02:13:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SNBsC6UV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732969AbgKZCM2 (ORCPT ); Wed, 25 Nov 2020 21:12:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgKZCM0 (ORCPT ); Wed, 25 Nov 2020 21:12:26 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 610E2C0613D4; Wed, 25 Nov 2020 18:12:26 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id q16so533084edv.10; Wed, 25 Nov 2020 18:12:26 -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=RAarhppgBK7+aX8M/sAYyN7ZA+uJCDtTAY1PkQ2qLQw=; b=SNBsC6UVQD2oAq98zCCCBBxHADzjs4AGPCIAfGWmyzOssx2F4xFcSh6vppd+krG/wR ScCrRtRxI+EMWpWNhGgRO4UcDhHfXMR8JzDONwsq2vAuV5/YGm5AUh1PpcO/FxcL2V88 JXqMMxRAlKQtfUyf2kA8eNHfCIo220Y1NJ0PWz2Aq7uVffjwbIRSKFu1LpbGcbP9Yu/+ PnNqRgR/BE8SfVHMALhDNlWNWNpeQrIbL0IM/0fXmAEWcXvwdXXVpj38fEMJzFvIhzMP FJs3GTkb7VhDDrdDiiVhu8TXA0He6fDXgtA6Vll3l37fB1m1rsqTvdbr+iKz4rrh/012 ZMZA== 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=RAarhppgBK7+aX8M/sAYyN7ZA+uJCDtTAY1PkQ2qLQw=; b=pXYoRqul5II0yYExdjNE6pIYz0ChzxzVaJU12FWYIzzatNKp9cK6wnAqhV294n4LcI avzehQyD7a6Y1HydJvNWfD7FEVGkvtw6OBhx+zzAW9NT3JEni2YoA+M5I5R/YasFDUad BbPY7yuWIq549J6XrzWxgvM8/AFNI67U7qiEmF8gC8BK4Y9mmpNzH2+isG8aERCkIeXc e0r0xbnBOL0rzGhZ2JKKoo8bFSpWO3/cDk6fceS8V17JaxsZdc8Co1cu6dMmChZMb0Ie ow71gwBb/kiZ7caI/F15YL3XFqi163KN34zdImQVjDtKJ+78tGGDC9mPGp9f1ULSXWOr J2xw== X-Gm-Message-State: AOAM533juRGkV21RWy+SLAbAuMsyj7HFw8nV4JkciXkFbbmLZ4TugBlv xTNs6gQF5J0jEKbJO4SmKiE= X-Google-Smtp-Source: ABdhPJyoiyLD05+CDmcehT6U9g5YXacwvxvoTS+FMElcbdi4JGSRbambxMDI4brGyTkzIkrXg+6l0Q== X-Received: by 2002:a50:c050:: with SMTP id u16mr482267edd.177.1606356744957; Wed, 25 Nov 2020 18:12:24 -0800 (PST) Received: from ansuel-xps20.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id d7sm417276edv.17.2020.11.25.18.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:12:24 -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 v7 1/8] drivers: thermal: tsens: Add VER_0 tsens version Date: Wed, 25 Nov 2020 18:48:18 +0100 Message-Id: <20201125174826.24462-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125174826.24462-1-ansuelsmth@gmail.com> References: <20201125174826.24462-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 --- drivers/thermal/qcom/tsens.c | 166 +++++++++++++++++++++++++++++------ drivers/thermal/qcom/tsens.h | 8 +- 2 files changed, 146 insertions(+), 28 deletions(-) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index d8ce3a687b80..bda965b3ac05 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,61 @@ 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 */ + if (tsens_version(priv) < VER_0_1) { + priv->rf[MIN_THRESH_0] = devm_regmap_field_alloc( + dev, priv->tm_map, priv->fields[MIN_THRESH_0]); + if (IS_ERR(priv->rf[MIN_THRESH_0])) { + ret = PTR_ERR(priv->rf[MIN_THRESH_0]); + goto err_put_device; + } + + priv->rf[MAX_THRESH_0] = devm_regmap_field_alloc( + dev, priv->tm_map, priv->fields[MAX_THRESH_0]); + if (IS_ERR(priv->rf[MAX_THRESH_0])) { + ret = PTR_ERR(priv->rf[MAX_THRESH_0]); + goto err_put_device; + } + + regmap_field_write(priv->rf[MIN_THRESH_0], 0); + regmap_field_write(priv->rf[MAX_THRESH_0], 120000); + } + + 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 +949,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 +1039,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 +1052,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..42c12639582f 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, }; @@ -441,6 +443,10 @@ enum regfield_ids { CRIT_THRESH_14, CRIT_THRESH_15, + /* VER_0 MIN MAX THRESH */ + MIN_THRESH_0, + MAX_THRESH_0, + /* WATCHDOG */ WDOG_BARK_STATUS, WDOG_BARK_CLEAR, From patchwork Wed Nov 25 17:48:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 333948 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_06_12, 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 5FBE7C71156 for ; Thu, 26 Nov 2020 02:13:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BC632075A for ; Thu, 26 Nov 2020 02:13:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N0aQDwHh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733069AbgKZCMb (ORCPT ); Wed, 25 Nov 2020 21:12:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgKZCM2 (ORCPT ); Wed, 25 Nov 2020 21:12:28 -0500 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A23FC0613D4; Wed, 25 Nov 2020 18:12:28 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id k4so588104edl.0; Wed, 25 Nov 2020 18:12:28 -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=O0qe7oIz20vmKxuGqEFKoOxtqbsQn05TcW7sLZuS3Bs=; b=N0aQDwHhQHzYRqKfp748d+z7YntGYV7ipjMrz8zV5WB1ORzQfrnI/mj4fXk+5WeGaD J39vlU5abGU/1KD1JIPFPyj0y2ekQJW/D2hEPyBHRjalGHBHknhA4S14ZhWY07wGWQ/M C1nFR4mdiN4PNoRRWXbG7NcI+qOFgXNkNcJeKLHuxgVPKP87yTYvdDS2b0HSjjvI9DKk lkEWrUd4K2qDUwFizlwFgxCRuV+BxNYfRBtfwjOV+EJ/880KJKLSULtGGgNW8eHOGP1z QRAXXiyaVO6j4VItcY66wkjAS9QdzpX1DlqNMcCsCMmhUZ5UgfMyq/q9/oicILxpPdB/ jOHg== 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=O0qe7oIz20vmKxuGqEFKoOxtqbsQn05TcW7sLZuS3Bs=; b=ZSgNAR7+jAKcT3hj0qaHTv/pH34MRnMMHJF7C667zQh2qV5jrmaRZo3rEJKR0qsDx/ a2au8XPPssUpH/MMU8KeDiSGumPdkM20ws5FlkAMFf6I1jkC+3fgIst3osmJT10vf8bR f8cJ6Qu+Sij9olCDI459eF249bILBc6OpX3wCKFYFzcYcg2YX0ccKE8Ze2zNSsRBgE/r 1xXQ/b6qOuktQ1pzV7st23I1NSmXmsrdX9eTXy4RmyWMhqmQV8tVPBEcMiLwiTCijE+z nfbAXAue6zuviZzKFsMp4wwwL7/9ukbDjX4A4LcPX2azokVatzpa1ilkvYPxm4E8ai5p QrTg== X-Gm-Message-State: AOAM533LGfghnpgGbrz4JbTxlSUojePrXFYpQa8yN8Iyepj3czxUhr2u EOK3hvYxpHRZ4pQ/HKCQDJc= X-Google-Smtp-Source: ABdhPJyBvkkG/E1UWL4vQBngd6UbbvfU36I65vCOb+wVVnnC5bmA29N5JVtN5Bhle8xaa2vi87DRdg== X-Received: by 2002:aa7:c44d:: with SMTP id n13mr529533edr.138.1606356747115; Wed, 25 Nov 2020 18:12:27 -0800 (PST) Received: from ansuel-xps20.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id d7sm417276edv.17.2020.11.25.18.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:12:26 -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 v7 2/8] drivers: thermal: tsens: Don't hardcode sensor slope Date: Wed, 25 Nov 2020 18:48:19 +0100 Message-Id: <20201125174826.24462-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125174826.24462-1-ansuelsmth@gmail.com> References: <20201125174826.24462-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 --- 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 bda965b3ac05..80551e17cdbe 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 Wed Nov 25 17:48:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 333369 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_06_12, 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 BCECCC64E90 for ; Thu, 26 Nov 2020 02:13:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DB952075A for ; Thu, 26 Nov 2020 02:13:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="frZxwhQZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733062AbgKZCMb (ORCPT ); Wed, 25 Nov 2020 21:12:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732932AbgKZCMa (ORCPT ); Wed, 25 Nov 2020 21:12:30 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37D7DC0613D4; Wed, 25 Nov 2020 18:12:30 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id d18so547846edt.7; Wed, 25 Nov 2020 18:12:30 -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=81sqGxzuC6LNmogSg2JIcputtWB+AH0q5r5QvZXa8PQ=; b=frZxwhQZl7qP0c7zff1P4P2kS/TCpZnYDeuL4NnSBOJn3WKRFmspTLf7Ca4tXDJl8w curS+6eUtus+qg54evtD/+hea7f3POKCtNNrzOWSVKjpWmDElNQtCkSbFHakGm2GHv8t k4Tm1opaBkmtaXHtrBl627YZlVm0qpqCNa/eH9YmEqw3YKo7hkgwwgWUZiE4yl0fEpKY RffrxcfkolHNx+JL7UUTQgAjLOiZ+7EMKEm1Uqi7uARt3Soz9LeXCuxfwnqDr5kCnl7F 5K7eIDx3R9RJso2cUTWe+PMjCQXFZa07VK22yr2nbQp2+Xz2mMWdaKQ1LRA7j3E9CLTw XnXA== 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=81sqGxzuC6LNmogSg2JIcputtWB+AH0q5r5QvZXa8PQ=; b=LSpqZ68EefXp/OwGJvjPwSmhzNvVJaB/MOWouk3tJJOCPzEHaGJ7rrQ5wycmL7VpEo xbQs2mKz2RwW3I2IXQjPxbbDwK0BXVcNGNP3PsNmnIW/jBpSuBh/zo4py9mXRQFuq3p2 isWyagGKOgYX9lFF34BIxMH1B/t15yK4ZlWz41PRS/62ltMaUYBK7NdMBWAsZsHoUpdO wvKe22iSSKmGrOw/zuVPhxp6R5Q/5fis5uSGCVw31cIERriwP9+WjjZyqvJJYeQqWI1O 47sdyqAk+6hKfzW0t4T7WbzREHjJCOCRYrbZfE96C2ggqkyZvxd0UFP+ILf0kcx+OR32 5T4Q== X-Gm-Message-State: AOAM5329mBbZCwePOeeOz+Acb7gco5wJn4K30XIPCyOUTS60b9oUrmFj 9E3+SMR18FSgJIzzENAtLtM= X-Google-Smtp-Source: ABdhPJwMOUjOf/52prfJJEGGtuS/jeOaophY3o4X5SswGyRyvEMcmmOFAf7es3Zy37GmH8woGKQEig== X-Received: by 2002:aa7:c6c3:: with SMTP id b3mr543116eds.84.1606356748922; Wed, 25 Nov 2020 18:12:28 -0800 (PST) Received: from ansuel-xps20.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id d7sm417276edv.17.2020.11.25.18.12.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:12:28 -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 v7 3/8] drivers: thermal: tsens: Convert msm8960 to reg_field Date: Wed, 25 Nov 2020 18:48:20 +0100 Message-Id: <20201125174826.24462-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125174826.24462-1-ansuelsmth@gmail.com> References: <20201125174826.24462-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 --- drivers/thermal/qcom/tsens-8960.c | 75 ++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 2a28a5af209e..e383dc545bf0 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,66 @@ 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] = REG_FIELD(THRESHOLD_ADDR, 16, 23), + [MAX_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 +353,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 Wed Nov 25 17:48:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 333949 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_06_12, 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 A365FC63798 for ; Thu, 26 Nov 2020 02:12:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54F2C207BC for ; Thu, 26 Nov 2020 02:12:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hfRE7omb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733112AbgKZCMc (ORCPT ); Wed, 25 Nov 2020 21:12:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgKZCMc (ORCPT ); Wed, 25 Nov 2020 21:12:32 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16340C0613D4; Wed, 25 Nov 2020 18:12:32 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id y4so558858edy.5; Wed, 25 Nov 2020 18:12:32 -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=BSqsyJR1uJjdUfbv6MslglDa94RlSlGvsXMc7VN4ajw=; b=hfRE7ombuJxM5u2HDsgC9CqyeDu7oP8SxLwQhGmR4icpgiMGVEqCxPHdB6jvz6TcFS Zu25VEQZyiRERrZtMJ4R3eYdDHo2alcbeuHtxcwqCcSvfNEkISjaoOfd09Tu73F+kdTq DwDXzcwjISt7pg9uVFp4wIW2Goym2RB/xYj/N7B45N5cYTiPSMqMLD5fYGuKvMlxD9El 42AA77DnS3cvWaZFNs5bEkqn8hwr1XgsA0UhcNbLcmCxvP48iulafxjCcighQkbb50+S CSrJ0KySnCmBos+mVBWzDk2Zigv2BGSTRmf4jhUpXBg04cmqVy4FEuiAsEHVMwcwIY+d TDUQ== 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=BSqsyJR1uJjdUfbv6MslglDa94RlSlGvsXMc7VN4ajw=; b=phlm6dzykgl4+6hB5jSt/HEpjcNLQKDZaLI4Y+3mow/xn702zLaL6vc2F2UT2uVL0s Ep4xC+ROWrktgPRa5lH4ybwEG/DaFx1gXSHyW8Ft+fMH3uxEra3gy/v5fZ/a+/gPfeoH oqPP6ozCoaPxG4chGVbLsfS/ujfoR+T5JSAvByVkJ6/iLgek+dO4oXsbugcaSKF4wSA3 7usaj9T/JwBhaTSkOna1RL8sJqYeS0rIHvCfr4G1/uS7ebl7lKJt9Y+n3oxfA39ndjTa 5aFQQUJ77SJpLQ/urqSIqzyoLBfYgNZIKoKmnoLPSPV+PWCI9nJhR6RruWrLLJyK/wX8 nbBA== X-Gm-Message-State: AOAM530BqQRTOVm/ga7sBy/My8mdcw+JukebcIhEuDNj9k7AMpNWem3B VW81Mn0c3VEYVX8T6joMhdLAUTNTF86QBg== X-Google-Smtp-Source: ABdhPJyORc9i/wzDY1nieyUer9Ad9lDzMYPWeOrKJxHEm3+1NLpRWGiGhJLY0GwTZmoIXKcUN+cLew== X-Received: by 2002:a50:a689:: with SMTP id e9mr477813edc.233.1606356750740; Wed, 25 Nov 2020 18:12:30 -0800 (PST) Received: from ansuel-xps20.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id d7sm417276edv.17.2020.11.25.18.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:12:30 -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 v7 4/8] drivers: thermal: tsens: Use init_common for msm8960 Date: Wed, 25 Nov 2020 18:48:21 +0100 Message-Id: <20201125174826.24462-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125174826.24462-1-ansuelsmth@gmail.com> References: <20201125174826.24462-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 --- 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 e383dc545bf0..93d2c6c7d1bd 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; @@ -341,7 +291,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 Wed Nov 25 17:48:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 333371 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_06_12, 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 29E84C83016 for ; Thu, 26 Nov 2020 02:12:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DCD0020B1F for ; Thu, 26 Nov 2020 02:12:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IVWWFORN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733144AbgKZCMf (ORCPT ); Wed, 25 Nov 2020 21:12:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgKZCMe (ORCPT ); Wed, 25 Nov 2020 21:12:34 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBB8CC0613D4; Wed, 25 Nov 2020 18:12:33 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id oq3so608830ejb.7; Wed, 25 Nov 2020 18:12:33 -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=ILjgLO1gu3OAaJ22R8SZw9mkrx615wQIxgl8+dYN3Gg=; b=IVWWFORNV5BHhFaYS+NvMN3osEnjqv7jCERz48upU8l2dI5uDmpS2Fr24s95chsXFi FBxQ+H54wYOPVxTQ7LzyxGGY162GbqGLaTbP/oSAmYPFAGSiTtq1PW34z+lecYeNa3k0 wqgeO7PSvwj2xZEMuyT1fQVJU9IUftjG3qd0A3QcAusd+AWhUKm7dUZJ3idaOobjqWbb ITH/QEKj9DUA4CicU6sCUSimcr8riZoF254Q0ALKPg3uj6dgVZ03NQUIGdkkmnMo+NZR DyBgICtW98GGYWW7hQgyCVAp/t6RUCCRrBblZm3M8XitZapYntGtGFhBYkVJ62/GixcL alQA== 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=ILjgLO1gu3OAaJ22R8SZw9mkrx615wQIxgl8+dYN3Gg=; b=sZwWIHV5PQaOOzi3Rr6iEHerbZc7p8HkOVwcyuwTg/JQ7IWYe5sVIRJkBiXphRXHEM MQN1tAn8szrju6iOt5AUnPZg1NYPVxUjvrEV2qlSvTfj86yqvWv3tBcVzRi2ZtLCrUmG yehOJwZu/kjBPq9sE0zpglla9oiAqzyUxBReMBR3twJZVRZYkroQZjywmV8R13x0l9PV A28CQajPd8NUHhS+0k4NowRAZDZOzqC+UapN+fTVxjaoMcsDMZfCV6Re2hnH0MKuvLjI wmr+e4RV1wDhWy9jTCBnJyIXaBqZuRVMD1K04/JCRyId/mawFXsiX+xQn/LB1+bpQMM7 MfGg== X-Gm-Message-State: AOAM533HXEA61qj2NWX48HpDMx38f5DBz+dcrAVomsZrwBuIhEsaM39o 6KMcT4E7gUJV+AJrSnKmhuE= X-Google-Smtp-Source: ABdhPJxbDo53ZIGywt/XVzIMgDLvC5bng5aRcQkFz7cZYZDdlAMe6RlLz245mtl3Zqpim/SmadiRJw== X-Received: by 2002:a17:906:7b49:: with SMTP id n9mr730677ejo.418.1606356752572; Wed, 25 Nov 2020 18:12:32 -0800 (PST) Received: from ansuel-xps20.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id d7sm417276edv.17.2020.11.25.18.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:12:31 -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 v7 5/8] drivers: thermal: tsens: Fix bug in sensor enable for msm8960 Date: Wed, 25 Nov 2020 18:48:22 +0100 Message-Id: <20201125174826.24462-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125174826.24462-1-ansuelsmth@gmail.com> References: <20201125174826.24462-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 93d2c6c7d1bd..f786f44f5d5d 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 Wed Nov 25 17:48:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 333950 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_06_12, 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 D2F6AC83013 for ; Thu, 26 Nov 2020 02:12:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84F292075A for ; Thu, 26 Nov 2020 02:12:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VFEEaZJn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733164AbgKZCMg (ORCPT ); Wed, 25 Nov 2020 21:12:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgKZCMg (ORCPT ); Wed, 25 Nov 2020 21:12:36 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B44A0C0613D4; Wed, 25 Nov 2020 18:12:35 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id mc24so621986ejb.6; Wed, 25 Nov 2020 18:12:35 -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=18mjJQ2LV7K44mzxIFRG9iVwB1Fl7ExfbKXsXQSaBWY=; b=VFEEaZJnQLGknvWEhR3vwlpib/YvHL9G5/+B/P2XdKjwGZPzD1sucFuNAas/mqgRBV 4LNHYvZqBQlsXW5KDnr5UO6ckuZV64BO7FGDwMyrlSUjqx3LhyRVh/77+gU/0BEG/R2g AiHw4JtUk1POMDj0gz8iTtKnZR5eJTEHTo3AUnoem30/luugzWHXnLbiTPlJI0iLCr8y kHZPIwp2vk3w73eTvgR1kMf5/yqXpD7i42l4UhyFxE/BU04WiEBFp2xikmu5NAjg2eZ+ QbaYm3WdTYr+F4xiZZBDobhJMjpAcxRKgIXp1pJlTl4IuxDEe7mzoXslmxb1gonWpONQ n4Fw== 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=18mjJQ2LV7K44mzxIFRG9iVwB1Fl7ExfbKXsXQSaBWY=; b=mHy3dnHxlrVbyAEMERODIPFdsL1uoZh3D4b3/s7CN2Aulo5GyDyUqR1sVxR5FxQ/2W 3jI5XbGQhm8aU0uqjgDWoVHm+A+dTem7cHKFCq2wVDWI3R0OUd3fOXC5yS2JHsEp2Ci+ TmU9NR0s7IIKlfIZU0ZYZH3wX1b/2pXL6l3IvhOwmhJXXbOodPbzOy/b/TjF983F67xE AN5LCW99LkB8kl3ewdBE4gEVWhs+6tMDAU4AAJdXm+m3aYDmQWY3fhCDv4Ijlk1+cLnk J2sZ3KTq1jf85Xkt7hEAyhl1N+6FwUQjsm5GYez1dXzNcNOe0OYYjN9dhOcfkQq2m+Tf GLtw== X-Gm-Message-State: AOAM532QkBoCzV3uyv/WBj5nJz5NqKrD9GpYprtVARZAeUl92pj/ska+ H4KEBTTZBkTG/+qbKinl6OjhTUdiFAAssg== X-Google-Smtp-Source: ABdhPJyx3iQ4SToqZSbz6dUucuv5772OZh4Yx2yNaCi56Wr42/0zVyLnVbg3xUrvGGJErwt6l2tLMA== X-Received: by 2002:a17:906:5a97:: with SMTP id l23mr772423ejq.232.1606356754395; Wed, 25 Nov 2020 18:12:34 -0800 (PST) Received: from ansuel-xps20.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id d7sm417276edv.17.2020.11.25.18.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:12:33 -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 v7 6/8] driver: thermal: tsens: Use get_temp_common for msm8960 Date: Wed, 25 Nov 2020 18:48:23 +0100 Message-Id: <20201125174826.24462-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125174826.24462-1-ansuelsmth@gmail.com> References: <20201125174826.24462-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. 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 f786f44f5d5d..4cd2cc14bc4c 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, @@ -308,7 +282,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 Wed Nov 25 17:48:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 333951 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_06_12, 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 A2654C8300C for ; Thu, 26 Nov 2020 02:12:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64628207BC for ; Thu, 26 Nov 2020 02:12:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XMjlfsLS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733185AbgKZCMi (ORCPT ); Wed, 25 Nov 2020 21:12:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgKZCMi (ORCPT ); Wed, 25 Nov 2020 21:12:38 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A79DBC0613D4; Wed, 25 Nov 2020 18:12:37 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id y4so559031edy.5; Wed, 25 Nov 2020 18:12:37 -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=79LT5m1zaUEIWOsVIZn2npQ8OOH0dyimXZhYveTdKSk=; b=XMjlfsLSHHkIbEVSU0E0i78ckvqn6EHeL+XFd67OAgMdnwV8rrihYAiak99JbY0m9x semNdv5hZiK3+BpAwHLPB4o33pSmyyHlORAm4WnyIObyL9Ke4NEDLhFwv66XYGh605Px dgEqcdORufm0U5zygjKd+y/K8Ia9o5lulDOcAT6hqhEyHEJ0MYN1jvU6ZNxctCqqoCP4 ub3OdjOjoajWHicTZ0gyAMalY3ddo1z+4/uk56AaPj0DTovHgb02uXoQrOYiXg6p2MGe IzJw+wk/X5tESgruWGijb+oSee3HFXp9lQZ6bUzQXgwsSTjA6NK1cfandpdhipCKiMdF mvOw== 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=79LT5m1zaUEIWOsVIZn2npQ8OOH0dyimXZhYveTdKSk=; b=uAOHQGPa2Z101yFzFIXhR0G9GtJBee4JFnwLixLinke0SCJclZU6vOfbh7r6Oa1lqF a50yy0sppQggjZJzq/9U0LepT4NePZ3naTMZGMtAClty8v2b4WY5y96aQ9Dbao6xnu9l DJ2l8Z1ReEPhriJr9yIBqPJ8noLnFKx4A7GKEP2eicTCWWFZJxOY98mxzRMNFZGq6sof VV00h373ffW3IuH3EQwDUJ4rloLxxTulZ+xwfU5Durhgz3qlsfEO2kco10OEDwXJF0xj wR32auQ9m+h5ydfwuSyOoQQobNTMuRWzRa5kfSq1YYhtdILbbLnElco2t5tiRly1/51D R2VQ== X-Gm-Message-State: AOAM530JkLkc1IudOD9GVoR5vceAyOerR/OYzYk/ilu8FlTF3lW9Tnw2 vVKVUAUzSzOaUqmF/VG84LyldQ5vwigg9A== X-Google-Smtp-Source: ABdhPJzGhIRKUFYiFTIkbfmOHWRD009oGY7oIb9i20gCyFcA8R/lMKUVvA3F8+i66aUlrvdpp1u9bQ== X-Received: by 2002:aa7:cac2:: with SMTP id l2mr489880edt.141.1606356756395; Wed, 25 Nov 2020 18:12:36 -0800 (PST) Received: from ansuel-xps20.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id d7sm417276edv.17.2020.11.25.18.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:12:35 -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 v7 7/8] drivers: thermal: tsens: Add support for ipq8064-tsens Date: Wed, 25 Nov 2020 18:48:24 +0100 Message-Id: <20201125174826.24462-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125174826.24462-1-ansuelsmth@gmail.com> References: <20201125174826.24462-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 --- 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 80551e17cdbe..cd89492385c7 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -1005,6 +1005,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 Wed Nov 25 17:48:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 333372 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_06_12, 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 3A713C56201 for ; Thu, 26 Nov 2020 02:12:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D83A4207BC for ; Thu, 26 Nov 2020 02:12:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tLIHiQrO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733203AbgKZCMl (ORCPT ); Wed, 25 Nov 2020 21:12:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731709AbgKZCMk (ORCPT ); Wed, 25 Nov 2020 21:12:40 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD2B0C0613D4; Wed, 25 Nov 2020 18:12:39 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id oq3so609108ejb.7; Wed, 25 Nov 2020 18:12:39 -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=STsWBKV7P3A8uOiJCdt6Mbb2TBdOtNAQlU7v5WGuSXU=; b=tLIHiQrO951hbsNyMUZOP1UdI1UnwScKOaNk0JU8OSjYkcnEd/duXLpx7fRCY1lrOU hZ0c3cSlaUJF+iu/y2PBPmvXAcMRvY97VDFYJcEC+2lqfCl4i5L02llVr9ewm+p2uTHZ AHCASmORfPvtUvIj/EidVvDoVvHSI4yhGJRj1LYJHrCrlYU0nXmVG3cTO7TQursKlNLy gQtOWmaRIQwKAbUmIkLU1K6XLCRO4+47NHgK081H9GblBsfKUj3eKM/hiICAdnB7xngS QXxFIi0Ye+ywwu+G2jcMaBUAXnAv/8519p2Rj1Scz25MBEkqrdcge0X2MAzQk3ZYbkuw MzyA== 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=STsWBKV7P3A8uOiJCdt6Mbb2TBdOtNAQlU7v5WGuSXU=; b=kQbl5/OQ5VuyZLNnf69iFTzoJFEHYWzp+ttn+XkDy+dri6p4RbovDaxCGf1WHVu29T a5yRm6zd6bx+tyDyFXYzuErpdgxPH1L2+qOnXIdJ33qOg6qsOx+3Gqua/3TM4FSLt1fL RWnG0xXPTt3StafdxiRVAICArgXkexFMAPqIPO7aWY3ZnRXzFtLxglRFDbtpJbSSBtzG F4O+WseFraLPtTOmkydF0iG9RksEgKY3p2IIk1mKCMMk5kV8uGGYGPQrsMKh0UuuKIPC 6EvzvYrb2g0CsZsQ2/SOqAud2UbNeCir1Huh4au8tJivI9Pnx4IDGn/ncfOoj5c3y/vn a4fw== X-Gm-Message-State: AOAM530Lq3quvsNOzpcIuDZb9dOLFYlxubDoQthMG67zsOyVFuuRk86/ LI/zxAUJAg/VxUh4vYhcwLM= X-Google-Smtp-Source: ABdhPJysOHJnv+URpB6tdCZP+meS8bfcQJsZCG5ovGy5T06CxBx1dAslC3h+MRJQ/C1miejewYxmsw== X-Received: by 2002:a17:906:c357:: with SMTP id ci23mr695636ejb.311.1606356758456; Wed, 25 Nov 2020 18:12:38 -0800 (PST) Received: from ansuel-xps20.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id d7sm417276edv.17.2020.11.25.18.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 18:12:37 -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 v7 8/8] dt-bindings: thermal: tsens: Document ipq8064 bindings Date: Wed, 25 Nov 2020 18:48:25 +0100 Message-Id: <20201125174826.24462-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125174826.24462-1-ansuelsmth@gmail.com> References: <20201125174826.24462-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 --- .../bindings/thermal/qcom-tsens.yaml | 103 ++++++++++++++---- 1 file changed, 79 insertions(+), 24 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml index 95462e071ab4..3aacee5c0632 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: @@ -71,9 +76,6 @@ properties: nvmem-cell-names: minItems: 1 maxItems: 2 - items: - - const: calib - - const: calib_sel "#qcom,sensors": description: @@ -88,43 +90,96 @@ 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,msm8916-tsens - - qcom,msm8974-tsens - - qcom,msm8976-tsens - - qcom,qcs404-tsens - - qcom,tsens-v0_1 - - qcom,tsens-v1 + - qcom,ipq8064-tsens then: properties: - interrupts: - maxItems: 1 - interrupt-names: - maxItems: 1 + nvmem-cell-names: + items: + - const: calib + - const: calib_backup else: properties: - interrupts: - minItems: 2 - interrupt-names: - minItems: 2 + nvmem-cell-names: + items: + - const: calib + - const: calib_sel -required: - - compatible - - reg - - "#qcom,sensors" - - interrupts - - interrupt-names - - "#thermal-sensor-cells" + - if: + properties: + compatible: + contains: + enum: + - qcom,ipq8064-tsens + - qcom,msm8916-tsens + - qcom,msm8974-tsens + - qcom,msm8976-tsens + - qcom,qcs404-tsens + - qcom,tsens-v0_1 + - qcom,tsens-v1 + then: + properties: + interrupts: + maxItems: 1 + interrupt-names: + maxItems: 1 + + else: + properties: + interrupts: + minItems: 2 + interrupt-names: + minItems: 2 + + - 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):