From patchwork Tue Apr 20 18:33:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 424682 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.7 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 48998C43470 for ; Tue, 20 Apr 2021 18:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10791613D9 for ; Tue, 20 Apr 2021 18:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233540AbhDTSeg (ORCPT ); Tue, 20 Apr 2021 14:34:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233381AbhDTSef (ORCPT ); Tue, 20 Apr 2021 14:34:35 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC8F6C06138A; Tue, 20 Apr 2021 11:34:02 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id h10so46254230edt.13; Tue, 20 Apr 2021 11:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TsKSaKVr8eqOkpvXK9OW60ORfpfmzSRm1tZjKRVxrds=; b=d4rHJtqKlz16XoOUweOadeJsl83KmgaprZcKHJKwzLvadt3lMmoCwF17aP22OwVK8g 2/9ndF+dTV9eE2h+3jW6kWwCU/tpctjiQtuuV78FD2JoFj1IyjMgeLKIXMDcewvmC6qI 71C+/qZlTjnX47wuZYhua8qt2nfrpExvgX3Jd7NNYdLLIydrZ1n7ONj4i10JLWzuU0qX fCjvmnM5ZJr2lyajlSpf3e8UAcy7+Z8afoUopFQ8LBwJbd2Y3RYsKibMu+QwE2prqiNa dVbRiyA4H3U3vVycZnn59mRqSKtI7CUrlyROEHrqjb0Z5IOXb2SzFVAqzLNZg+Ch7Ilj XrdA== 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=TsKSaKVr8eqOkpvXK9OW60ORfpfmzSRm1tZjKRVxrds=; b=brp/h8claMexACl6ueNWiMfhXLPzB/vpkbxzRhPCMf0Jx6JDDbXBXkaa4IWkp8GNak 5aytZJ2RpPIgK1Sso8QIhgCYxB4GsWFpFJzWvObnccqEYVWE8nRTOf01drAQ+zYb5hNP YNd/irTn+e73ZXj8FA1ZPxERSjMsjjj6U8nOMuLMRFoiqZf7/Xz0nWZcJCyClcNp+1pO shnRyrhQASRU/kClSsfFH8VBJxp/lEuI9O4C6+8I8GkAgihlcPw4Vc0nkeO+2fgtzQtB 9IfP1snzoP3eYS0+iF0brSGJkTWeapYnKEvm10TKin6hQLdKXPM5eUyMqAR7qplch2Z1 gXMw== X-Gm-Message-State: AOAM5333D3f+VSVAEjRatY0gJWWONrWOkkeCnAxMdX3SUW+Nu5H91rpo 8s9kdZrHS7TFmdzaKkMxtH8= X-Google-Smtp-Source: ABdhPJwVnvlTj/f73js9LWNlyL9kTBLX28ndldorz4gVTC2TLUP3EsIuATQ2N6wfNhOe7Em877HZ/g== X-Received: by 2002:a50:eb0d:: with SMTP id y13mr6090392edp.326.1618943641591; Tue, 20 Apr 2021 11:34:01 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-35-189-2.ip56.fastwebnet.it. [93.35.189.2]) by smtp.googlemail.com with ESMTPSA id n10sm13357141ejg.124.2021.04.20.11.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 11:34:01 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Amit Kucheria , Andy Gross , Bjorn Andersson , Zhang Rui , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [thermal PATCH v15 1/9] drivers: thermal: tsens: Don't hardcode sensor slope Date: Tue, 20 Apr 2021 20:33:35 +0200 Message-Id: <20210420183343.2272-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420183343.2272-1-ansuelsmth@gmail.com> References: <20210420183343.2272-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 Reviewed-by: Thara Gopinath --- drivers/thermal/qcom/tsens.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 8d3e94d2a..562c438ff 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -85,7 +85,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 Tue Apr 20 18:33:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 425415 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.7 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 A1AE5C433ED for ; Tue, 20 Apr 2021 18:34:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6599E613D0 for ; Tue, 20 Apr 2021 18:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233560AbhDTSel (ORCPT ); Tue, 20 Apr 2021 14:34:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233548AbhDTSej (ORCPT ); Tue, 20 Apr 2021 14:34:39 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF25EC06174A; Tue, 20 Apr 2021 11:34:04 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id h10so46254313edt.13; Tue, 20 Apr 2021 11:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=737hIwn3pods25c8zCbCGP0noOsJUI3v0XpSgnln2no=; b=rxiJGGTcBqWxKSZaTlWQtUL6gPZ1Hfbf+P0DLOZjdyP0/rcK021JJYZwkaZnXvFoMa Xs1xAc8sC0KYTO2gmjh7wftkLPkUMZUxnkXkLs3mFGE/EWOTDu9+/f5mwhcyEneDPZO7 NxvZPHbVzR+BbmtG40POUsMW2w9LxMpzeJ8tjIS2GOTJXl82qhplVtnO91UACvrO4H9m cAt3viEIw8ByPRCWq3XM0FK0JidZMKnXCxbrmWzioR5SlQLzf5NkJFbd+RE9ss9tbhg8 Zcyw19+M77jAkm2r0fGrHYW8mdOEJ8mo75YyC2c92+RgGDG0gEOB2SvrWs7P1ADCAM/Q JhUA== 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=737hIwn3pods25c8zCbCGP0noOsJUI3v0XpSgnln2no=; b=KP0JdbBYVHHfRmtd7v4T8H+nnbxk5aaLxLN8LyWjkjiQ0fQyeramV7/UdHcaGbAwr/ C1E5CN5P12cybyd4dIm13ouQ6MXQsYUcCp4+CMDQ6gbIIP8WZr+OC5BfqBeP1MUsS0Wm aohpGOFj9+jzbNi//rvawWbHtqOxWHJk6W+f59UKX1Ptk7zrAmcKAF+BE5RB/KUgLP09 T4lOWDRumdIROX6u8B85iPA+9RhGDF4zFi6tJyuAyethLNjxFPPzy3ks8HQvCH7Zubok pTO+AMC5jGGBFrvRz2UM4jev1OtpuMEHTXeIdeR6DkhiC8p8a6eY9JW9mYKxoy5mPsRH flmQ== X-Gm-Message-State: AOAM530taHPCVFqtg2hbmFOJuBlX+rtooxPOeH7W0UGMr7Dt9y6uofjx SJzv34iU3EJP6mfBCxy07vg3VNcOnKp2VA== X-Google-Smtp-Source: ABdhPJyuMrP9eVLWpML0qlk/eabKQdCAr+2D8Oi5vKhs8Zd3JzzhX0o7j8zL6PuNi2x9Nlal69SnQg== X-Received: by 2002:aa7:cd6e:: with SMTP id ca14mr17477070edb.111.1618943643368; Tue, 20 Apr 2021 11:34:03 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-35-189-2.ip56.fastwebnet.it. [93.35.189.2]) by smtp.googlemail.com with ESMTPSA id n10sm13357141ejg.124.2021.04.20.11.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 11:34:02 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Amit Kucheria , Andy Gross , Bjorn Andersson , Zhang Rui , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [thermal PATCH v15 2/9] drivers: thermal: tsens: Convert msm8960 to reg_field Date: Tue, 20 Apr 2021 20:33:36 +0200 Message-Id: <20210420183343.2272-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420183343.2272-1-ansuelsmth@gmail.com> References: <20210420183343.2272-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 Acked-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 73 ++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 2a28a5af2..0d0c2647d 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; @@ -179,7 +190,7 @@ static int init_8960(struct tsens_priv *priv) */ for (i = 0; i < priv->num_sensors; i++) { if (i >= 5) - priv->sensor[i].status = S0_STATUS_ADDR + 40; + priv->sensor[i].status = S0_STATUS_OFF + 40; priv->sensor[i].status += i * 4; } @@ -269,6 +280,63 @@ static int get_temp_8960(const struct tsens_sensor *s, int *temp) return -ETIMEDOUT; } +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 +350,5 @@ static const struct tsens_ops ops_8960 = { struct tsens_plat_data data_8960 = { .num_sensors = 11, .ops = &ops_8960, + .fields = tsens_8960_regfields, }; From patchwork Tue Apr 20 18:33:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 425414 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.7 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 B1B1FC43460 for ; Tue, 20 Apr 2021 18:34:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DBE9613D0 for ; Tue, 20 Apr 2021 18:34:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233597AbhDTSep (ORCPT ); Tue, 20 Apr 2021 14:34:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233581AbhDTSel (ORCPT ); Tue, 20 Apr 2021 14:34:41 -0400 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 C0322C06138A; Tue, 20 Apr 2021 11:34:06 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id l4so59719401ejc.10; Tue, 20 Apr 2021 11:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cgR5/mxzM1+Fj9kTK0T9EAkQTgjyT5GnY4XwENoVN7s=; b=IY4QZ7lWFo+GW2wHVUz61EMQBwUw3XHRgDxR/HJvOfWuIeuZrAdQt6A1u2azhu6rOd qZPvJ418Ac/ScU1Nzxc79fJ7edY1NMf1eB0gdVTUKsgseenCoCPdxIDoCG1mc0uVzOMj UIuEL18A1mBKYggQFWFl0bAt2Ga8K3dI398+jVP+MooLLaWaq/s0zLRhmJpnD3iWdk7z 7pVTabLKJSc0qSS0qfX07GiVC7aJ4HdRxTaSnK5Ie35e3tryHxG/apiCZchNcAqazQ+S KAyaZ72z3L28GC1yf1UbkHRVcvBJ0YHAaXRpYpMHEGUPkH0MCsmOOaY0iQpwg++v80GX C3Kg== 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=cgR5/mxzM1+Fj9kTK0T9EAkQTgjyT5GnY4XwENoVN7s=; b=N0T3KyCTVcpz5BGdLOXr7PuZYngkMhJQr661RHpZMRrt3nnpDK1KYAhD29jBqM7zwT NNuUgnN11QzO70V75kcQXBNoMFp8Pbv6U6+PlqZE5kS/rYOK13QsL7549ziNRr33AcT1 CiVPIE2N4yLadLmzw2njOlsHY/PFt/vETKKzYkQzVu5fXDRrBNkZCIMBx4EdPVR9smBD LyRlbm9y6iFcWKB5UJTAc5yM2Sz/q/3INvNyO7w6fl5ubCBjV7tJDgm6UPMrenNTwPxl RN0ysWk8P9PXmvJCwJ71lpwz20XhclNhrf6PZbsEYSHT9LszyjjwUN5ootH3E403e6dO 4a9A== X-Gm-Message-State: AOAM531ijRu10uZbrdCMXO9/41lP7l+e1RtJlGysBRvQRCskmTWt0trZ UMl00umq7FrgCpr1DtQ4/pk= X-Google-Smtp-Source: ABdhPJxLNol6C8JGwgifsVn8z4e1vEAehiBwRgbY3GliTwEEZ8URLe8sjvI6SAu3RPbh1CgIaD1tog== X-Received: by 2002:a17:907:3f9f:: with SMTP id hr31mr28658466ejc.349.1618943645397; Tue, 20 Apr 2021 11:34:05 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-35-189-2.ip56.fastwebnet.it. [93.35.189.2]) by smtp.googlemail.com with ESMTPSA id n10sm13357141ejg.124.2021.04.20.11.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 11:34:04 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , kernel test robot , Dan Carpenter , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [thermal PATCH v15 3/9] drivers: thermal: tsens: Add VER_0 tsens version Date: Tue, 20 Apr 2021 20:33:37 +0200 Message-Id: <20210420183343.2272-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420183343.2272-1-ansuelsmth@gmail.com> References: <20210420183343.2272-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. Add support for VER_0 in tsens.c and set the right tsens feat in tsens-8960.c file. Signed-off-by: Ansuel Smith Reviewed-by: Thara Gopinath Reported-by: kernel test robot Reported-by: Dan Carpenter --- drivers/thermal/qcom/tsens-8960.c | 9 ++ drivers/thermal/qcom/tsens.c | 150 ++++++++++++++++++++++++------ drivers/thermal/qcom/tsens.h | 4 +- 3 files changed, 133 insertions(+), 30 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 0d0c2647d..0dd15e812 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -347,8 +347,17 @@ static const struct tsens_ops ops_8960 = { .resume = resume_8960, }; +static struct tsens_features tsens_8960_feat = { + .ver_major = VER_0, + .crit_int = 0, + .adc = 1, + .srot_split = 0, + .max_sensors = 11, +}; + struct tsens_plat_data data_8960 = { .num_sensors = 11, .ops = &ops_8960, + .feat = &tsens_8960_feat, .fields = tsens_8960_regfields, }; diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 562c438ff..be0c5931f 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -516,6 +517,15 @@ 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; @@ -531,6 +541,13 @@ 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); @@ -585,18 +602,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 */ @@ -609,15 +629,29 @@ int get_temp_common(const struct tsens_sensor *s, int *temp) { struct tsens_priv *priv = s->priv; int hw_id = s->hw_id; - int last_temp = 0, ret; + int last_temp = 0, ret, trdy; + unsigned long timeout; - ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp); - if (ret) - return ret; + timeout = jiffies + usecs_to_jiffies(TIMEOUT_US); + do { + if (tsens_version(priv) == VER_0) { + ret = regmap_field_read(priv->rf[TRDY], &trdy); + if (ret) + return ret; + if (!trdy) + continue; + } - *temp = code_to_degc(last_temp, s) * 1000; + ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp); + if (ret) + return ret; - return 0; + *temp = code_to_degc(last_temp, s) * 1000; + + return 0; + } while (time_before(jiffies, timeout)); + + return -ETIMEDOUT; } #ifdef CONFIG_DEBUG_FS @@ -739,19 +773,34 @@ int __init init_common(struct tsens_priv *priv) priv->tm_offset = 0x1000; } - res = platform_get_resource(op, IORESOURCE_MEM, 0); - tm_base = devm_ioremap_resource(dev, res); - if (IS_ERR(tm_base)) { - ret = PTR_ERR(tm_base); - goto err_put_device; + if (tsens_version(priv) >= VER_0_1) { + res = platform_get_resource(op, IORESOURCE_MEM, 0); + tm_base = devm_ioremap_resource(dev, res); + if (IS_ERR(tm_base)) { + ret = PTR_ERR(tm_base); + goto err_put_device; + } + + priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config); + } else { /* VER_0 share the same gcc regs using a syscon */ + struct device *parent = priv->dev->parent; + + if (parent) + priv->tm_map = syscon_node_to_regmap(parent->of_node); } - priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config); - if (IS_ERR(priv->tm_map)) { - ret = PTR_ERR(priv->tm_map); + if (IS_ERR_OR_NULL(priv->tm_map)) { + if (!priv->tm_map) + ret = -ENODEV; + else + ret = PTR_ERR(priv->tm_map); goto err_put_device; } + /* VER_0 have only tm_map */ + if (!priv->srot_map) + priv->srot_map = priv->tm_map; + if (tsens_version(priv) > VER_0_1) { for (i = VER_MAJOR; i <= VER_STEP; i++) { priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map, @@ -770,6 +819,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; @@ -792,6 +845,19 @@ int __init init_common(struct tsens_priv *priv) goto err_put_device; } + priv->rf[TSENS_SW_RST] = + devm_regmap_field_alloc(dev, priv->srot_map, priv->fields[TSENS_SW_RST]); + if (IS_ERR(priv->rf[TSENS_SW_RST])) { + ret = PTR_ERR(priv->rf[TSENS_SW_RST]); + goto err_put_device; + } + + priv->rf[TRDY] = devm_regmap_field_alloc(dev, priv->tm_map, priv->fields[TRDY]); + if (IS_ERR(priv->rf[TRDY])) { + ret = PTR_ERR(priv->rf[TRDY]); + goto err_put_device; + } + /* This loop might need changes if enum regfield_ids is reordered */ for (j = LAST_TEMP_0; j <= UP_THRESH_15; j += 16) { for (i = 0; i < priv->feat->max_sensors; i++) { @@ -807,7 +873,7 @@ int __init init_common(struct tsens_priv *priv) } } - if (priv->feat->crit_int) { + if (priv->feat->crit_int || tsens_version(priv) < VER_0_1) { /* Loop might need changes if enum regfield_ids is reordered */ for (j = CRITICAL_STATUS_0; j <= CRIT_THRESH_15; j += 16) { for (i = 0; i < priv->feat->max_sensors; i++) { @@ -845,7 +911,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: @@ -941,10 +1011,19 @@ static int tsens_register_irq(struct tsens_priv *priv, char *irqname, if (irq == -ENXIO) ret = 0; } else { - ret = devm_request_threaded_irq(&pdev->dev, irq, - NULL, thread_fn, - IRQF_ONESHOT, - dev_name(&pdev->dev), priv); + /* VER_0 interrupt is TRIGGER_RISING, VER_0_1 and up is ONESHOT */ + if (tsens_version(priv) == VER_0) + ret = devm_request_threaded_irq(&pdev->dev, irq, + thread_fn, NULL, + IRQF_TRIGGER_RISING, + dev_name(&pdev->dev), + priv); + else + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + thread_fn, IRQF_ONESHOT, + dev_name(&pdev->dev), + priv); + if (ret) dev_err(&pdev->dev, "%s: failed to get irq\n", __func__); @@ -973,6 +1052,19 @@ static int tsens_register(struct tsens_priv *priv) priv->ops->enable(priv, i); } + /* VER_0 require to set MIN and MAX THRESH + * These 2 regs are set using the: + * - CRIT_THRESH_0 for MAX THRESH hardcoded to 120°C + * - CRIT_THRESH_1 for MIN THRESH hardcoded to 0°C + */ + if (tsens_version(priv) < VER_0_1) { + regmap_field_write(priv->rf[CRIT_THRESH_0], + tsens_mC_to_hw(priv->sensor, 120000)); + + regmap_field_write(priv->rf[CRIT_THRESH_1], + tsens_mC_to_hw(priv->sensor, 0)); + } + ret = tsens_register_irq(priv, "uplow", tsens_irq_thread); if (ret < 0) return ret; diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 59d01162c..5dbed0a3f 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 Tue Apr 20 18:33:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 424681 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.7 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 61C73C433ED for ; Tue, 20 Apr 2021 18:34:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29DC5613D7 for ; Tue, 20 Apr 2021 18:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233092AbhDTSeo (ORCPT ); Tue, 20 Apr 2021 14:34:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233573AbhDTSel (ORCPT ); Tue, 20 Apr 2021 14:34:41 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A19BC06138D; Tue, 20 Apr 2021 11:34:08 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id v6so58463875ejo.6; Tue, 20 Apr 2021 11:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XA8qh0Ts8DSpOtFxtfJGiJPMyRECQNMEtovD7z2ULCI=; b=eueUGv9gjMmz3FIx+YWHONGLzRdIU9n0A7H3FlKWIzo0zJ+8uLHJiT888ntzMSoHXL SVULNdA8lIaS/RoEwnJ/WVPhACVhF09prlvZRrIzrezs8HRs1m3TjpRWPls6DJtFrlt5 YS7xT6ofk33OR9tJ6Rz7nP2tX3mh1p2EIui4CoF7qbA008N3wzDFC5orRyIGPukZS91P ItCXaEGVhBDLh0i7KXL5F9R8Ex0DU+3RWDXwiuG9XROvLYsMWLI5GLoOrWc/lQ72gWgg bIToz+K6x0d/bC4xmfKv2nZrZAv5sVVJEHCRCot9wVf1jnT/r1h5xAVD6Pyt+Bf5INL2 mf7w== 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=XA8qh0Ts8DSpOtFxtfJGiJPMyRECQNMEtovD7z2ULCI=; b=eoGOOaiXy3I6xsG5W6rn06PsSNh/GZhNup08Hpmr4KhhpD4igxle5IcNG6ez4CHUoN D7CvjEjMjtryNwthyb6MUyAIdHd/jajPzOIijqRnnuVDmpwCsIOOWQe0DPiDCTceayDd fHzjDXhaYgk0QhLEDqdwI5mPGV3+d7FvZ14MdecbOULzO1Lh4W79rBu4+eFTlIs8qYlc 1zXIXTLrth7K1N9jyZykYynNuogPmoPQnyaLomPxB4v0GqSanxaiCU2d3EErWmKIuVyd JSsLUbM9WDYqnXnhVp3qjK12YWmgE9jnFGcu0J3TeVmPVQBji+hdykisxaDbWX6YenE0 ey2w== X-Gm-Message-State: AOAM530UPB218+HjtPcsEgpp5Q9zes+At4XC9H3ngcE7jrSl6qvhO/MB wfpoSXXmeeGJC48YdojqAAA= X-Google-Smtp-Source: ABdhPJwqk1HHjXkR2Ys45K0VpyWvJXLmJx8P+wU6Pl0wWaXEwNextjSI4djt7vCLsp5FrhU7n3BFGw== X-Received: by 2002:a17:907:270f:: with SMTP id w15mr29243774ejk.462.1618943646893; Tue, 20 Apr 2021 11:34:06 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-35-189-2.ip56.fastwebnet.it. [93.35.189.2]) by smtp.googlemail.com with ESMTPSA id n10sm13357141ejg.124.2021.04.20.11.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 11:34:06 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Amit Kucheria , Andy Gross , Bjorn Andersson , Zhang Rui , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [thermal PATCH v15 4/9] drivers: thermal: tsens: Use init_common for msm8960 Date: Tue, 20 Apr 2021 20:33:38 +0200 Message-Id: <20210420183343.2272-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420183343.2272-1-ansuelsmth@gmail.com> References: <20210420183343.2272-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 Reviewed-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 52 +------------------------------ 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 0dd15e812..83746ee3f 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_OFF + 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; @@ -338,7 +288,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 Tue Apr 20 18:33:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 424680 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.7 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 A4A6BC433ED for ; Tue, 20 Apr 2021 18:34:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D096613B2 for ; Tue, 20 Apr 2021 18:34:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233628AbhDTSes (ORCPT ); Tue, 20 Apr 2021 14:34:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233592AbhDTSen (ORCPT ); Tue, 20 Apr 2021 14:34:43 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA688C061342; Tue, 20 Apr 2021 11:34:09 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id e7so46198300edu.10; Tue, 20 Apr 2021 11:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bbGEtXvS4MPCAqcooOSZYviKFO5PutHS6qrWdQUGFi0=; b=tVnpsZLuQDzYn4FfMy26p1YDMBWi7MD23/StZ1n+/eIDhDqjU/IpWoKCEsolLO1hGf EG25zYqBRKPhxBuN58GwhOK2F2NcBrrW7nVIdazrp6FzqxZOUO1RxP2WFYKONzkADTCL Vm6UHbFNdFwnOdm7Bx7CEmcR5yCc8RTXAzdufdO+piV2xkWyi5d3oN7DILy7ysjqp/ah OfjjzenUhuwcpr0wVDPT4MfAbIgflGrafRLPUIfH3/JFtY5aXfhB18acPiNEmMpEmZOs Ey/hyS/lnw8tXv/f3XmtBLiuS/Zo+vWq7pembIEkRfHMLNuM4/aWEhJXIaNAXQu5hPCy poRQ== 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=bbGEtXvS4MPCAqcooOSZYviKFO5PutHS6qrWdQUGFi0=; b=HTTEiFGlSJnGggq/PnVU7Sw+SmRJzKna9xFxJjLOEAwe8IRcKsxu8HvnQ0AErtTyEN gTUt10HtywV+YJcLRcpSKQnBeBY5o6CgduNMk40rrLTj6g79rg0YNXGojdLtIKaVkmTe LRScBbE1RKE6+jctERMiedDVWEGJtcU4sR56IkK/MKwCEFvQZFQQjUiqSQIrLEl3yjzA WIL/jP6ytiRkzyH5O6S2lg1AJn4xs0wV00Lg3T5Y7xkQCqifCCMK5H/GSquVuy9DKQYp b5LJqzYYN3f6izbaC75jqB/KqyrJ3x/kc+rVfn/4AiT5WQq+GSqrEA0sHTU1ALmbKc7+ 0rvQ== X-Gm-Message-State: AOAM531SPEtMkOVDCtWzUkp5x2Q2FfsCwdsM2o+m87xQ/chSBFItlOtH 6wiqE2u6vHOvHGR8pKuK8S8= X-Google-Smtp-Source: ABdhPJw0JszHrBS0UC4vVxOJDutyCusIUzjObLYcRDX68OzbNbu0MlS0fbbW44Zvk/rIiN77uZPp5w== X-Received: by 2002:a05:6402:17a8:: with SMTP id j8mr25060879edy.43.1618943648520; Tue, 20 Apr 2021 11:34:08 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-35-189-2.ip56.fastwebnet.it. [93.35.189.2]) by smtp.googlemail.com with ESMTPSA id n10sm13357141ejg.124.2021.04.20.11.34.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 11:34:08 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [thermal PATCH v15 5/9] drivers: thermal: tsens: Fix bug in sensor enable for msm8960 Date: Tue, 20 Apr 2021 20:33:39 +0200 Message-Id: <20210420183343.2272-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420183343.2272-1-ansuelsmth@gmail.com> References: <20210420183343.2272-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Device based on tsens VER_0 contains a hardware bug that results in some problem with sensor enablement. Sensor id 6-11 can't be enabled selectively and all of them must be enabled in one step. Signed-off-by: Ansuel Smith Acked-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 83746ee3f..a96d37c2b 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -27,9 +27,9 @@ #define EN BIT(0) #define SW_RST BIT(1) #define SENSOR0_EN BIT(3) +#define MEASURE_PERIOD BIT(18) #define SLP_CLK_ENA BIT(26) #define SLP_CLK_ENA_8660 BIT(24) -#define MEASURE_PERIOD 1 #define SENSOR0_SHIFT 3 /* INT_STATUS_ADDR bitmasks */ @@ -126,17 +126,34 @@ static int resume_8960(struct tsens_priv *priv) static int enable_8960(struct tsens_priv *priv, int id) { int ret; - u32 reg, mask; + u32 reg, mask = BIT(id); ret = regmap_read(priv->tm_map, CNTL_ADDR, ®); if (ret) return ret; - mask = BIT(id + SENSOR0_SHIFT); + /* HARDWARE BUG: + * On platforms with more than 6 sensors, all remaining sensors + * must be enabled together, otherwise undefined results are expected. + * (Sensor 6-7 disabled, Sensor 3 disabled...) In the original driver, + * all the sensors are enabled in one step hence this bug is not + * triggered. + */ + if (id > 5) + mask = GENMASK(10, 6); + + mask <<= SENSOR0_SHIFT; + + /* Sensors already enabled. Skip. */ + if ((reg & mask) == mask) + return 0; + ret = regmap_write(priv->tm_map, CNTL_ADDR, reg | SW_RST); if (ret) return ret; + reg |= MEASURE_PERIOD; + if (priv->num_sensors > 1) reg |= mask | SLP_CLK_ENA | EN; else From patchwork Tue Apr 20 18:33:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 424679 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.7 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 28CFEC43461 for ; Tue, 20 Apr 2021 18:34:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6C8C613DF for ; Tue, 20 Apr 2021 18:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233639AbhDTSet (ORCPT ); Tue, 20 Apr 2021 14:34:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233582AbhDTSeo (ORCPT ); Tue, 20 Apr 2021 14:34:44 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AE46C06138B; Tue, 20 Apr 2021 11:34:11 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id w3so59796440ejc.4; Tue, 20 Apr 2021 11:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WTz+6s25EfUH+8tRBZQTC1iH8pQVmI7eJrWzBFatbxM=; b=ig3ww2C/9EEkibf0cn+exIA0ocHp/RAKFTzrfrviPuuuVtb23Q7O5WBxn1R+6kT33a 6R4qz+V1VLueUeL1KMhoRHSxq0CzjuxaSny/YBPssNKo/C8cK19HjBpwsnAPnkwA9CuS 1yOy5tNO9kkzSKL2zFBoebMurv+uxZzzVKejefzwzVmMF1xP0smy4NbTWFzM8lOoeJKW Dwr0GY/eZMN17S1Gh8RSpUHMdoG3KG0Syv0Wkvh67yN2Kq/Ygwtx9ALsmjo8ygjQ3UiZ G6MK0Q3lAlXwjhlLArFaCWhTIMkITvFj+Nxjlb3a/rtRhpihmzCYSfZUYkMawi/1M+ly WuHw== 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=WTz+6s25EfUH+8tRBZQTC1iH8pQVmI7eJrWzBFatbxM=; b=OiMdvfzarRdqsLintjulJ6hX994eM28IBPfS+GAqzlWIRZder7FqCsNECadR67AnIT iHaeE+SWg6oxBPF1jLPSaol1SCAHrKCxXGHZ6G6r8bJBzns31KXBjBxRatTHH5709iRS fJxxGUuyZc5pKKzyZLukMnUwU1rOnydGdbNh1UKUlESMTygoOd+X6XshY4LGShgwcKIG v8zt2DOWuZmH7UuQ4dsY5rtNCRv7nN/dublTd+NATbhyrQnCzTuoJt6m1iuwBDDgAh59 SsIOXsjfcikA4OyMTLoh0UZ9Q665OtIOvPNc+0HNijfOJdyfxa3kLxYxiW1Y9wPQvt0B cJEA== X-Gm-Message-State: AOAM531ggZlwM59BDev57SNzNLNJLDQEOJ27Rtflp7F1ZEm7NHCqBf1W lsjcZCOfXHM18JavicT8608= X-Google-Smtp-Source: ABdhPJz0hRgE+ssy2xnPzc27jg3PV3Vy9c10pdn4QzMpdKFjo1wuX2QWzGZdpTE/qdunIs4etMClhQ== X-Received: by 2002:a17:907:9607:: with SMTP id gb7mr28085390ejc.380.1618943650132; Tue, 20 Apr 2021 11:34:10 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-35-189-2.ip56.fastwebnet.it. [93.35.189.2]) by smtp.googlemail.com with ESMTPSA id n10sm13357141ejg.124.2021.04.20.11.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 11:34:09 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Amit Kucheria , Andy Gross , Bjorn Andersson , Zhang Rui , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [thermal PATCH v15 6/9] drivers: thermal: tsens: Replace custom 8960 apis with generic apis Date: Tue, 20 Apr 2021 20:33:40 +0200 Message-Id: <20210420183343.2272-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420183343.2272-1-ansuelsmth@gmail.com> References: <20210420183343.2272-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. Drop custom get_temp function and use generic api. Signed-off-by: Ansuel Smith Acked-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 56 +++++++++---------------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index a96d37c2b..58112f0df 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 - 350 to compensate mC to C inaccuracy */ +static u32 tsens_msm8960_slope[] = { + 826, 826, 804, 826, + 761, 782, 782, 849, + 782, 849, 782 + }; + static int suspend_8960(struct tsens_priv *priv) { int ret; @@ -194,9 +201,7 @@ static int calibrate_8960(struct tsens_priv *priv) { int i; char *data; - - ssize_t num_read = priv->num_sensors; - struct tsens_sensor *s = priv->sensor; + u32 p1[11]; data = qfprom_read(priv->dev, "calib"); if (IS_ERR(data)) @@ -204,49 +209,18 @@ static int calibrate_8960(struct tsens_priv *priv) if (IS_ERR(data)) return PTR_ERR(data); - for (i = 0; i < num_read; i++, s++) - s->offset = data[i]; + for (i = 0; i < priv->num_sensors; i++) { + p1[i] = data[i]; + priv->sensor[i].slope = tsens_msm8960_slope[i]; + } + + compute_intercept_slope(priv, p1, NULL, ONE_PT_CALIB); kfree(data); return 0; } -/* Temperature on y axis and ADC-code on x-axis */ -static inline int code_to_mdegC(u32 adc_code, const struct tsens_sensor *s) -{ - int slope, offset; - - slope = thermal_zone_get_slope(s->tzd); - offset = CAL_MDEGC - slope * s->offset; - - return adc_code * slope + offset; -} - -static int get_temp_8960(const struct tsens_sensor *s, int *temp) -{ - int ret; - u32 code, trdy; - struct tsens_priv *priv = s->priv; - unsigned long timeout; - - timeout = jiffies + usecs_to_jiffies(TIMEOUT_US); - do { - ret = regmap_read(priv->tm_map, INT_STATUS_ADDR, &trdy); - if (ret) - return ret; - if (!(trdy & TRDY_MASK)) - continue; - ret = regmap_read(priv->tm_map, s->status, &code); - if (ret) - return ret; - *temp = code_to_mdegC(code, s); - return 0; - } while (time_before(jiffies, timeout)); - - return -ETIMEDOUT; -} - static const struct reg_field tsens_8960_regfields[MAX_REGFIELDS] = { /* ----- SROT ------ */ /* No VERSION information */ @@ -307,7 +281,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 Tue Apr 20 18:33:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 425413 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.7 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 B60EDC43462 for ; Tue, 20 Apr 2021 18:34:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E150613D3 for ; Tue, 20 Apr 2021 18:34:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233656AbhDTSeu (ORCPT ); Tue, 20 Apr 2021 14:34:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233617AbhDTSeq (ORCPT ); Tue, 20 Apr 2021 14:34:46 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21E85C06138A; Tue, 20 Apr 2021 11:34:13 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id sd23so51110409ejb.12; Tue, 20 Apr 2021 11:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I2U7MnAPAwOrFGhE4r40Lq3vVf52NabEdANX/dIyj30=; b=s0FWufzapRquZB/NUwR2GA54vvYkFWY2Vx7wn+TEALoOjZ9y5rr5XKQB5iln6Cz7+A YMSWktFDT8e9vlcwgmh5t+jLLxIk/fjqzGRZjfLneFzFeEWhClKdn+8vi9eeokQvgz43 V4GOS5d7ezF2TgPvTc68o1YDKFvjqWfmQWvYF16gZF/j0MWa2bqG0IxnKKLtOktawoTh tgdobKVCEmOeMsGPXa4l2je9nzXxntowZZ2i4KnRKEgivmM6U9lfEwEXAmgPsKjFRyiF ZBA0pe/2dJu6BhT+mky5Em66A5mh2DHGrmKk3eDDwvvmwZb/jksrT/r6frSTWHK25InB HDIw== 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=I2U7MnAPAwOrFGhE4r40Lq3vVf52NabEdANX/dIyj30=; b=HNSumHhpWQ3ILKQ6NoFcEtIwC/GPB3FVEmuiGigDNwFAgr8Vv9JrdwNQHiRPyqg3ru 4akzGGjA8qVIOEPlquLlth9MsZy9a5c6rpBRU27XPwX5t5wwYCNoq6z4q34kRmlhVf6Q 4wOm3mYDchoLRQ11ybx5j3c08tdYXys8TLkJnXVtHFMsQL9nsIFweD2WctuCl/1AQYYf YIQ/xy/55C9PFUG+RReswwhmpx58R31DKNqxHZ3Gr/8gjgXqN+GIFDEtxDSx9jVm2eiC B7TCVkkpeFz12e90NL4Jxfuhojq8Q7oCBlPhYyG2uYlFEtVbn4dHj8hkxFHgx0V7xmtL hCwQ== X-Gm-Message-State: AOAM531Iw3z8FyZJrEbCneJRthPRHCp9rfjhrpnnaso8J10p1GahZhB3 yNld5JFXAa6T8yDNWgha9f0= X-Google-Smtp-Source: ABdhPJzM1lVs+WBXxxcGeeBTL2TpVBZHziPNBghXHfRDZDyeKluoSIYfzvLKCXg3+0UUgG/I67No0g== X-Received: by 2002:a17:906:2652:: with SMTP id i18mr28772446ejc.189.1618943651742; Tue, 20 Apr 2021 11:34:11 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-35-189-2.ip56.fastwebnet.it. [93.35.189.2]) by smtp.googlemail.com with ESMTPSA id n10sm13357141ejg.124.2021.04.20.11.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 11:34:11 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [thermal PATCH v15 7/9] drivers: thermal: tsens: Drop unused define for msm8960 Date: Tue, 20 Apr 2021 20:33:41 +0200 Message-Id: <20210420183343.2272-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420183343.2272-1-ansuelsmth@gmail.com> References: <20210420183343.2272-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Drop unused define for msm8960 replaced by generic api and reg_field. Signed-off-by: Ansuel Smith Reviewed-by: Thara Gopinath --- drivers/thermal/qcom/tsens-8960.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 58112f0df..67c1748cd 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -10,8 +10,6 @@ #include #include "tsens.h" -#define CAL_MDEGC 30000 - #define CONFIG_ADDR 0x3640 #define CONFIG_ADDR_8660 0x3620 /* CONFIG_ADDR bitmasks */ @@ -21,39 +19,19 @@ #define CONFIG_SHIFT_8660 28 #define CONFIG_MASK_8660 (3 << CONFIG_SHIFT_8660) -#define STATUS_CNTL_ADDR_8064 0x3660 #define CNTL_ADDR 0x3620 /* CNTL_ADDR bitmasks */ #define EN BIT(0) #define SW_RST BIT(1) -#define SENSOR0_EN BIT(3) + #define MEASURE_PERIOD BIT(18) #define SLP_CLK_ENA BIT(26) #define SLP_CLK_ENA_8660 BIT(24) #define SENSOR0_SHIFT 3 -/* INT_STATUS_ADDR bitmasks */ -#define MIN_STATUS_MASK BIT(0) -#define LOWER_STATUS_CLR BIT(1) -#define UPPER_STATUS_CLR BIT(2) -#define MAX_STATUS_MASK BIT(3) - #define THRESHOLD_ADDR 0x3624 -/* THRESHOLD_ADDR bitmasks */ -#define THRESHOLD_MAX_LIMIT_SHIFT 24 -#define THRESHOLD_MIN_LIMIT_SHIFT 16 -#define THRESHOLD_UPPER_LIMIT_SHIFT 8 -#define THRESHOLD_LOWER_LIMIT_SHIFT 0 - -/* Initial temperature threshold values */ -#define LOWER_LIMIT_TH 0x50 -#define UPPER_LIMIT_TH 0xdf -#define MIN_LIMIT_TH 0x0 -#define MAX_LIMIT_TH 0xff #define INT_STATUS_ADDR 0x363c -#define TRDY_MASK BIT(7) -#define TIMEOUT_US 100 #define S0_STATUS_OFF 0x3628 #define S1_STATUS_OFF 0x362c From patchwork Tue Apr 20 18:33:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 425412 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.7 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 193C3C433B4 for ; Tue, 20 Apr 2021 18:34:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAB2F613D8 for ; Tue, 20 Apr 2021 18:34:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233681AbhDTSe6 (ORCPT ); Tue, 20 Apr 2021 14:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233629AbhDTSes (ORCPT ); Tue, 20 Apr 2021 14:34:48 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9C89C06174A; Tue, 20 Apr 2021 11:34:14 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id x12so38993501ejc.1; Tue, 20 Apr 2021 11:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eZpY6oHW5Nc4qUZgqqVYnVsBY3HZDhln/426SoLXgZU=; b=us7oHf9xkBwsTctKUnEsSJQnNKxA4FgW3e03Dw0jTCia+lBIeSBZ8aL84481Shyi0a uWEoJCVcS2rWzffBLR7rucAwoZYN/Z2SQUCxZnP/E+JAlQZAji6fu0dcxXgpc9n0eJJA 3yeCqrsWOX1yT1JORnx9Jw36/KNmUDdunWElp0tGRtDKTTl3OvbvaBx+oxyZcTu/u+WH ZfSVFeUQ9lwsyJTjXiMxfwRZ8RJ6GjA8i4ZJ5Bv1o6zljmSHiMesXHmeZ/jXkiBhkLbW SbajFfZr6zLalBSIqrSI9MGxOMC4X2HiRK/jwTNdeRZCajq1JaUeQq/z2+8PDFAyZRvP rRdg== 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=eZpY6oHW5Nc4qUZgqqVYnVsBY3HZDhln/426SoLXgZU=; b=sn6z4eo+2QlqFv1Tv0la+xlRvkQ5zlBtzqdLvzW/sbHq4NX4SNyZKhmGnXWMWcrQL2 KVNSEwD+NQ7ngxRQ09tNQjuII85KScTK4hl5SGa2XG2n2qxCmdtaTDphAVH4v0JSD+RT rWe+y5V2JxmyqK+fCDmWzye7ZA2jUWAnkYTus3e/1oNhzJWAgLbDK+R0zhD6IJmyQsGD XBggvPk9KIbMXup4ItOMmImqD8FWmc1y+l3vUNs8vy5mogNPAWRLAvzn7HT9+m/zpIPZ U5QkgQrCDL5d6S3wy0BtcLBnWUrA4OMgvf2fEaPhpc8ljx3dfWTxLSgd8vdN03uoKvGg UOYA== X-Gm-Message-State: AOAM532qdAMeSH7rOxo2s9sfNvsE3qU/D03ikpb4VusERAjXkzo/eckN M3GcKO4SCoQVfO1p0TH45/4= X-Google-Smtp-Source: ABdhPJwN+kQyM51zG2KVPFbcCG7ojJsD6UdCM8qgkqeQmUSNkidiyhp0MbUAglmIp96UyNVlVVLOVA== X-Received: by 2002:a17:906:5487:: with SMTP id r7mr29114732ejo.550.1618943653447; Tue, 20 Apr 2021 11:34:13 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-35-189-2.ip56.fastwebnet.it. [93.35.189.2]) by smtp.googlemail.com with ESMTPSA id n10sm13357141ejg.124.2021.04.20.11.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 11:34:13 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Thara Gopinath , Amit Kucheria , Andy Gross , Bjorn Andersson , Zhang Rui , Rob Herring , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [thermal PATCH v15 8/9] drivers: thermal: tsens: Add support for ipq8064-tsens Date: Tue, 20 Apr 2021 20:33:42 +0200 Message-Id: <20210420183343.2272-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420183343.2272-1-ansuelsmth@gmail.com> References: <20210420183343.2272-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 Reviewed-by: Thara Gopinath --- drivers/thermal/qcom/tsens.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index be0c5931f..56b505f35 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -966,6 +966,9 @@ static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume); static const struct of_device_id tsens_table[] = { { + .compatible = "qcom,ipq8064-tsens", + .data = &data_8960, + }, { .compatible = "qcom,msm8916-tsens", .data = &data_8916, }, { From patchwork Tue Apr 20 18:33:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 424678 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.7 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 38572C43470 for ; Tue, 20 Apr 2021 18:34:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 02A12613DE for ; Tue, 20 Apr 2021 18:34:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233589AbhDTSfD (ORCPT ); Tue, 20 Apr 2021 14:35:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233654AbhDTSeu (ORCPT ); Tue, 20 Apr 2021 14:34:50 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92102C06138B; Tue, 20 Apr 2021 11:34:16 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id w3so59796741ejc.4; Tue, 20 Apr 2021 11:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ka7h2yhzf5rJ0AJdlIXPMvLZF9eZ+jtPp29EnOmIYbU=; b=oKWLl9k0s7WTJasrDiDiAxKaZzVOW4BwfeeHeegWvS5lhoAyu71WNwbvZnxM/16GQD Pyix+a1HY9AUESgF0zPeRFZQfCSkYtMmv0hEqOel51zdqLfIFPxruajDiAZQ/YOqf6eb z7W8hsZR+NcVREh2l6JM0x27BPc9+FwqtJTQvoqwIF5nVitTE5LN9uSvw4Bz/s83v2NU Cj8GzUNhJ9WZLN2YoO/JuIc6feN8Hglh9oAR+g5jGb/YpXXttSyPz8kAz1vbOgxEk3sw qTvwBP6Ms0/hEzdSEOgmYQW6DYX3qPANNA/WuyfmM4VyTj1WEzBkUkvUTTNc8zhT4Tf0 so5A== 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=Ka7h2yhzf5rJ0AJdlIXPMvLZF9eZ+jtPp29EnOmIYbU=; b=folzH3lbQqfRQYguDaInjB+8ZgJwDggMDR0EWNDWe8irH3PC2UE7TcrDnbvO+1VBAI UNgCw/prX33H//NbhGbjS9y3zT4w7aLXVtHF+ZP+w1jI3bS5oK7D0fwc2N4mBT4Mvc5V 1o/LpO1BagT3athvdCKXRuxeSZPcGChojhTTAHnHtJfSOIRtUXgD4lgcBDUausnyI4Mh 9jDa/HVLZbXboAfV21zRmox6Xs8wGVKPwcaGxrqXNC2LuiW09QVqZ5pe0nH6RL2s6y/R vWfrBiCijDtql9IvlpDF1pSDgmohev+M7vQ2imdGDS2HL6ONF+M7bzwsz5C0fmBYeW2Z HeyQ== X-Gm-Message-State: AOAM5320tssxivPlv1YGfJNjZwPsPA2uN0KMLhwg2wTqId/fztpl5yED HWzOKGi3FgACbj2LhHMLkXc= X-Google-Smtp-Source: ABdhPJwv33CLEGrYqkVhLcx/Zsnzo17NjXob6cnEp3+3K39m61LeH+SiigeB+XdpgiNkkvWZCufheQ== X-Received: by 2002:a17:907:7283:: with SMTP id dt3mr28992621ejc.47.1618943655052; Tue, 20 Apr 2021 11:34:15 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-35-189-2.ip56.fastwebnet.it. [93.35.189.2]) by smtp.googlemail.com with ESMTPSA id n10sm13357141ejg.124.2021.04.20.11.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 11:34:14 -0700 (PDT) From: Ansuel Smith To: Daniel Lezcano Cc: Ansuel Smith , Rob Herring , Andy Gross , Bjorn Andersson , Amit Kucheria , Zhang Rui , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [thermal PATCH v15 9/9] dt-bindings: thermal: tsens: Document ipq8064 bindings Date: Tue, 20 Apr 2021 20:33:43 +0200 Message-Id: <20210420183343.2272-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420183343.2272-1-ansuelsmth@gmail.com> References: <20210420183343.2272-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 d7be931b4..2e762596b 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: @@ -70,7 +75,9 @@ properties: maxItems: 2 items: - const: calib - - const: calib_sel + - enum: + - calib_backup + - calib_sel "#qcom,sensors": description: @@ -85,12 +92,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 @@ -111,17 +126,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):