Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4893974rdb; Fri, 15 Sep 2023 16:09:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5sJLwVxlyu3QaFeZ9fuc2d5twEqG6248pqxS7+25/8ThXOuxjIxCrUus3KWNGSitkpY0s X-Received: by 2002:a05:6a20:e10b:b0:137:23a2:2b3c with SMTP id kr11-20020a056a20e10b00b0013723a22b3cmr4589683pzb.49.1694819382649; Fri, 15 Sep 2023 16:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694819382; cv=none; d=google.com; s=arc-20160816; b=pz7zLGqlZsQFJ2rKnTe2l7Plur9amRQEzuq1W4X21w4QeEVGQeytU036EvrUQkbGeC 0doini0Iwokzs6xIWqIcC/UCjXmt5QmpCZVLQ7iqbOmM0Jc0Vym6vdZqq6WtDHykSVSj H1F9f5kOYJlOBrEVY3YFh5Rz8buhX8TrTbRLqGJhpxCUwrLiTQn13F5oGkKcrSbxgBGu k1FYixXtQWeVXdQbgRVuZhS/5uhRkpbPVUHBaJH4GvXnZGK3Sq+N+bSVxM/cMW+Goow+ v9Su7e3C6nxDxHWL2C+Ovv6H6yUr2efQiFks8UvY/ygM7kYyh3Q3/iCLkmqg8gvkTAjM XM8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mb/JbSxTOf6YSrodg1aYhJ0ml5QYx/b8sq5qwirE40g=; fh=6JKr/yiNaJSJrhiSyCX+DX0SPrqPEwotScGsaXxXIsU=; b=k94lUruA6dMp6OP3b5lgqsM91seEE8/wbO8I4Rc3+vAkhW12VV7rsZ/nDTgZAm0IOL LIzW/YV9XI+JO3dgqYeZqXCYUHb+j/q5p2JxI+l4gAOmKoDzy69llVe1yadPzXVlBHYB Qb2LnvhXTyb5zHz7+bwJXQ1bOqnV3GzhGrBpidl9Klnk+T+xQRThlbjE9JNjqrBvv2aj i5fvusUvnXlvxmPhUMdShbcri2gK8AgZrJ3GVA11psDIlpe2FXocsjXH1atq3xJfFGoX rNf82L3sai3iIHjo/UgI76jgZm/P89zo0GfCyyVh94RBgppx8wdl4sU1cViD6qww6P33 pEbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rVYwpiEH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id t187-20020a632dc4000000b00565322ef4f1si3898770pgt.348.2023.09.15.16.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 16:09:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rVYwpiEH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1A327821885E; Fri, 15 Sep 2023 11:47:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236652AbjIOSq2 (ORCPT + 99 others); Fri, 15 Sep 2023 14:46:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237246AbjIOSqY (ORCPT ); Fri, 15 Sep 2023 14:46:24 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 360FA49E0 for ; Fri, 15 Sep 2023 11:45:11 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-d81b42a3108so1574797276.1 for ; Fri, 15 Sep 2023 11:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694803508; x=1695408308; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=mb/JbSxTOf6YSrodg1aYhJ0ml5QYx/b8sq5qwirE40g=; b=rVYwpiEHoZUTb1RScl189CXIouKvFDbkstbiscDXabsDRCbOkQytbby89efW935GVw Y7iB7bty48aTBdwfgSVDtMTpq67HjL+hX5phLgUhI4laX6oC1huweqVHOFr0oP0KxNqq 7bIe/ssZObIkQ2Lqbw3MfS7pu1fvw6+adj5tNUW6VaW3KAs4nbUQgRMWR25zr4MMsX7x Krjss6t7VlOOJQsEjSxqa2n2EJwQqDLT4eflNwpbf/yLG9YE1ilfLItiQBQm5ybigNQT ib961tpk2lBHMIDi1YxrT4dJZY8Aixjrpf54+p3GW7tuurNzBUOVn0hEL0yhEdNbk+RT gT8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694803508; x=1695408308; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mb/JbSxTOf6YSrodg1aYhJ0ml5QYx/b8sq5qwirE40g=; b=ErtBPbtq622F9x4lVV5w2xMyEz1hDkIUBKzRhege0pShtkqJ9XESgeGN/yUMgirPGN ySbzwxoNmb9ZsPuqSTOGEXfFfRpDR6vIlc0W98oqpbrJ/jSfYjwRZw9lGUEcAtT9Zw7r vvcTlWWBsrU7k4WtWQ2/d11rbdIA/2Cs96uvujNp7OvEJUDPU0nTabjcDskfNmB2ixtk phB27m32SCKqGsSc2qTziuxgYU2+f9WiaNgiua/Uxz7GjtuAh0cJRh5p3mbc1zlhtT8+ 4OqE076v8iw5o9nxEAVU3Sa0eNINt0+tXtMMtm4wduMGMkVQv4Xrxuiy8z+XEP8u4oI8 kXtA== X-Gm-Message-State: AOJu0Yx7H+aNQ4c28PHvxpnBcH+ZKzsaqz4WO47Eqkm4XKKqMBbURgFH ky1GNdy526I+bTN+2V95X2wiecJrRPb7V8kfdMxYdg== X-Received: by 2002:a25:cf09:0:b0:d0e:c8fb:986a with SMTP id f9-20020a25cf09000000b00d0ec8fb986amr2587928ybg.42.1694803508490; Fri, 15 Sep 2023 11:45:08 -0700 (PDT) MIME-Version: 1.0 References: <20230915121504.806672-1-quic_srichara@quicinc.com> <20230915121504.806672-4-quic_srichara@quicinc.com> In-Reply-To: <20230915121504.806672-4-quic_srichara@quicinc.com> From: Dmitry Baryshkov Date: Fri, 15 Sep 2023 21:44:57 +0300 Message-ID: Subject: Re: [PATCH V2 3/4] thermal/drivers/tsens: Add support for IPQ5018 tsens To: Sricharan Ramabadhran Cc: krzysztof.kozlowski@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, srinivas.kandagatla@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, thara.gopinath@gmail.com, rafael@kernel.org, daniel.lezcano@linaro.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:47:00 -0700 (PDT) On Fri, 15 Sept 2023 at 15:16, Sricharan Ramabadhran wrote: > > IPQ5018 has tsens IP V1.0, 4 sensors and 1 interrupt. > The soc does not have a RPM, hence tsens has to be reset and > enabled in the driver init. Adding the driver support for same. > > Signed-off-by: Sricharan Ramabadhran > --- > [v2] Used tsens_calibrate_common instead of legacy > and addressed comments from Dmitry. > > drivers/thermal/qcom/tsens-v1.c | 58 +++++++++++++++++++++++++++++++++ > drivers/thermal/qcom/tsens.c | 3 ++ > drivers/thermal/qcom/tsens.h | 2 +- > 3 files changed, 62 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c > index dc1c4ae2d8b0..ed5c017905ab 100644 > --- a/drivers/thermal/qcom/tsens-v1.c > +++ b/drivers/thermal/qcom/tsens-v1.c > @@ -79,6 +79,18 @@ static struct tsens_features tsens_v1_feat = { > .trip_max_temp = 120000, > }; > > +static struct tsens_features tsens_v1_ipq5018_feat = { > + .ver_major = VER_1_X, > + .crit_int = 0, > + .combo_int = 0, > + .adc = 1, > + .srot_split = 1, > + .max_sensors = 11, > + .trip_min_temp = -40000, > + .trip_max_temp = 120000, > + .ignore_enable = 1, > +}; > + > static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = { > /* ----- SROT ------ */ > /* VERSION */ > @@ -150,6 +162,39 @@ static int __init init_8956(struct tsens_priv *priv) { > return init_common(priv); > } > > +static int init_ipq5018(struct tsens_priv *priv) > +{ > + int ret; > + u32 mask; > + > + init_common(priv); Please take care of init_common()'s return code. Don't continue init if init_common() fails. > + if (!priv->tm_map) > + return -ENODEV; Why? > + > + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 1); > + if (ret) { > + dev_err(priv->dev, "Reset failed\n"); > + return ret; > + } > + > + mask = GENMASK(priv->num_sensors, 0); > + ret = regmap_field_update_bits(priv->rf[SENSOR_EN], mask, mask); > + if (ret) { > + dev_err(priv->dev, "Sensor Enable failed\n"); > + return ret; > + } > + > + ret = regmap_field_write(priv->rf[TSENS_EN], 1); > + if (ret) { > + dev_err(priv->dev, "Enable failed\n"); > + return ret; > + } > + > + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 0); > + > + return ret; > +} > + > static const struct tsens_ops ops_generic_v1 = { > .init = init_common, > .calibrate = calibrate_v1, > @@ -187,3 +232,16 @@ struct tsens_plat_data data_8976 = { > .feat = &tsens_v1_feat, > .fields = tsens_v1_regfields, > }; > + > +const struct tsens_ops ops_ipq5018 = { > + .init = init_ipq5018, > + .calibrate = tsens_calibrate_common, > + .get_temp = get_temp_tsens_valid, > +}; > + > +struct tsens_plat_data data_ipq5018 = { > + .num_sensors = 5, > + .ops = &ops_ipq5018, > + .feat = &tsens_v1_ipq5018_feat, > + .fields = tsens_v1_regfields, > +}; > diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c > index 0a43ccf02ec4..c792b9dc6676 100644 > --- a/drivers/thermal/qcom/tsens.c > +++ b/drivers/thermal/qcom/tsens.c > @@ -1101,6 +1101,9 @@ static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume); > > static const struct of_device_id tsens_table[] = { > { > + .compatible = "qcom,ipq5018-tsens", > + .data = &data_ipq5018, > + }, { > .compatible = "qcom,ipq8064-tsens", > .data = &data_8960, > }, { > diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h > index e254cd2df904..b6594b546d11 100644 > --- a/drivers/thermal/qcom/tsens.h > +++ b/drivers/thermal/qcom/tsens.h > @@ -645,7 +645,7 @@ extern struct tsens_plat_data data_8960; > extern struct tsens_plat_data data_8226, data_8909, data_8916, data_8939, data_8974, data_9607; > > /* TSENS v1 targets */ > -extern struct tsens_plat_data data_tsens_v1, data_8976, data_8956; > +extern struct tsens_plat_data data_tsens_v1, data_8976, data_8956, data_ipq5018; > > /* TSENS v2 targets */ > extern struct tsens_plat_data data_8996, data_ipq8074, data_tsens_v2; > -- > 2.34.1 > -- With best wishes Dmitry