Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp5020564pxb; Tue, 5 Oct 2021 15:48:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKLMS5Buto5W0ciag8/CudS6XSA4v3ZTqFSej1YfTSpyd4J9Ze6ICYZG9Cj2EjhCPPoYM0 X-Received: by 2002:a62:1d8a:0:b0:44b:9660:41f6 with SMTP id d132-20020a621d8a000000b0044b966041f6mr33630092pfd.7.1633474081624; Tue, 05 Oct 2021 15:48:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633474081; cv=none; d=google.com; s=arc-20160816; b=WWQAf+Tg7blskSX32EHvf6mDTr18F9L+63RKdLBUrcTHo5EqiPfCE2cMkWD7y2m/x9 WMImGdIINMfsJK27pznMs1enXUALBrFfBFO27FvUJ1XzjznAHXIZMrotNx/qWYTvOPOQ /cZqtt8jBgncHi3iJsmVemYSwO+ZlfXdZR66Y3OlZwdWyCts5WqtwmrQUMTsBkcaZGcX MiXuKJ1VXKwxTVIHmhcxJ/gp5y/D1lKaa9zWWQva8gVlnZDdyVpjCV/zzfgm1i+ByQqY tG8vku8KagO/PYCxBlLBU6RDWGPhERkreygDe/vkbD++xZApzrLWYQ/g374TARzi8kAM g1AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VFvZc24blAvborprFIZbskjuKA2+rXG/KD54iQC+o2k=; b=LLBf4+FbWIzh8SzicHsFnOxgOKqUXFh3iKJpLovdc3w6eau2fHt9+QOYw/ZXXg/BLh ZsxSSLrItWtEgM0Vo8XTu4zV2IeMSc8/bGdckcTy8KJqGLZ7RDJIPyxBlRT4/UNOveHH WPXyRPeFbA4gF8EPKMev7802mqgyNGlcZphkN3PRK9eas046t7DCYCC4WH+j1HVb4aRn 061yh7aogDe22YzNrA/57II4XAqxwudlSh86VCbzomrftU/z89M9XUACJ3EnCnPy+TFk bejAHOmQwVYQj4lRozAA9bTbydXd7dP056cQpcHFExbaPnCMU4gMXX92HbOx7sSLm5Li P3cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kfl7WKFz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot10si1611017pjb.68.2021.10.05.15.47.42; Tue, 05 Oct 2021 15:48:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kfl7WKFz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237006AbhJEWsL (ORCPT + 99 others); Tue, 5 Oct 2021 18:48:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236953AbhJEWsD (ORCPT ); Tue, 5 Oct 2021 18:48:03 -0400 Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97972C061749 for ; Tue, 5 Oct 2021 15:46:12 -0700 (PDT) Received: by mail-oo1-xc2f.google.com with SMTP id z11-20020a4ad1ab000000b0029f085f5f64so274534oor.5 for ; Tue, 05 Oct 2021 15:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VFvZc24blAvborprFIZbskjuKA2+rXG/KD54iQC+o2k=; b=kfl7WKFzeAxKvatS7HOHCSeGXHiLDgd7DiQr20URrbqNEc9STgVIKqfi/qUGY+GCVV miFHtv4EKNr2iclUmz5QRGO6xb2XLY0nNQkr5buSkOIxXhqJsYV4MYdbiG63W1ESf1TN vRIRInL7HPoMuCtm7Bw7nUUfyU+1x4WHU6uNGY8H/1RWheKK+GvQMdqzUPgvh3R1ysM7 zd10xw2jcscrP0jC6eGrNCpLQPkqKbZUjj3U6q0Lu/gZKoToi2ibQXifaC+tZDY7SPTv fh+gj43bCFP0VaKM3QYMZCwkTZ6m0Y5WLA1zrAFZ8NKh7hbdtXxlz7gU9+t7zGtTiE23 J8rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VFvZc24blAvborprFIZbskjuKA2+rXG/KD54iQC+o2k=; b=pQXiR2paw/Wn5OZU3xq25Uos0jgF03dZyxHIke95EC5yN0w7rtgJ3pcwoEqsuQ8Ja1 ubm1UZCH73lIQ0FnO483hC3e0cOqJw1gW02n7MuSQ/W6fsof47FZtV+WxAXDLe1NBGgX 57EYi4BvFadGtn+cZ6Jwueu5souKEmOeWK4BptAR3WmNIVjxTgqYzmT+5OOV23q5lSzi 6Wlq4YrVwTiQP9YFlxiBdlaRvjKSBeWUlXN4YtATzM4dlU+XSPQnLpXIjT8hhM2PzvTb Y++FhCJTwV+075bcovJVFjxx58ST1fuHWHcFnRw54AnoJu12bbCG/WVjftTbDEHeFSLV sRZg== X-Gm-Message-State: AOAM530XBjcO6N4dyXzIp741CtXIOyshSdAJW+vcNAEEoB4gWGdGQJMI 7Y9615xo4oENj8LZzjTr+AMqaQ== X-Received: by 2002:a05:6820:17a:: with SMTP id k26mr15662292ood.37.1633473971915; Tue, 05 Oct 2021 15:46:11 -0700 (PDT) Received: from ripper ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id f10sm3728038ooh.42.2021.10.05.15.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 15:46:11 -0700 (PDT) Date: Tue, 5 Oct 2021 15:47:53 -0700 From: Bjorn Andersson To: Thara Gopinath Cc: Dmitry Baryshkov , Matthias Kaehlcke , Andy Gross , Zhang Rui , Daniel Lezcano , Amit Kucheria , Rob Herring , "open list:DRM DRIVER FOR MSM ADRENO GPU" , Linux PM , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list Subject: Re: [PATCH v2 4/4] arm64: dts: qcom: sdm845: mtp: Add vadc channels and thermal zones Message-ID: References: <20210923212311.2877048-1-bjorn.andersson@linaro.org> <20210923212311.2877048-5-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 05 Oct 15:21 PDT 2021, Thara Gopinath wrote: > > > On 10/5/21 5:52 PM, Bjorn Andersson wrote: > > On Tue 05 Oct 13:30 PDT 2021, Thara Gopinath wrote: > > > > > > > > > > > On 10/4/21 4:56 PM, Dmitry Baryshkov wrote: > > > > On Mon, 4 Oct 2021 at 23:13, Bjorn Andersson wrote: > > > > > > > > > > On Wed 29 Sep 11:40 PDT 2021, Matthias Kaehlcke wrote: > > > > > > > > > > > On Thu, Sep 23, 2021 at 02:23:11PM -0700, Bjorn Andersson wrote: > > > > > > > Downstream defines four ADC channels related to thermal sensors external > > > > > > > to the PM8998 and two channels for internal voltage measurements. > > > > > > > > > > > > > > Add these to the upstream SDM845 MTP, describe the thermal monitor > > > > > > > channels and add thermal_zones for these. > > > > > > > > > > > > > > Signed-off-by: Bjorn Andersson > > > > > > > --- > > > > > > > > > > > > > > In addition to the iio channels exposed by v1, Daniel wanted thermal_zones... > > > > > > > > > > > > > > Changes since v1: > > > > > > > - Enable the pm8998_adc_tm and describe the ADC channels > > > > > > > - Add thermal-zones for the new channels > > > > > > > > > > > > > > arch/arm64/boot/dts/qcom/sdm845-mtp.dts | 128 ++++++++++++++++++++++++ > > > > > > > 1 file changed, 128 insertions(+) > > > > > > > > > > > > > > diff --git a/arch/arm64/boot/dts/qcom/sdm845-mtp.dts b/arch/arm64/boot/dts/qcom/sdm845-mtp.dts > > > > > [..] > > > > > > > +&pm8998_adc { > > > > > > > + adc-chan@4c { > > > > > > > + reg = ; > > > > > > > + label = "xo_therm"; > > > > > > > + }; > > > > > > > + > > > > > > > + adc-chan@4d { > > > > > > > + reg = ; > > > > > > > + label = "msm_therm"; > > > > > > > + }; > > > > > > > + > > > > > > > + adc-chan@4f { > > > > > > > + reg = ; > > > > > > > + label = "pa_therm1"; > > > > > > > + }; > > > > > > > + > > > > > > > + adc-chan@51 { > > > > > > > + reg = ; > > > > > > > + label = "quiet_therm"; > > > > > > > + }; > > > > > > > + > > > > > > > + adc-chan@83 { > > > > > > > + reg = ; > > > > > > > + label = "vph_pwr"; > > > > > > > + }; > > > > > > > + > > > > > > > + adc-chan@85 { > > > > > > > + reg = ; > > > > > > > + label = "vcoin"; > > > > > > > + }; > > > > > > > +}; > > > > > > > + > > > > > > > +&pm8998_adc_tm { > > > > > > > + status = "okay"; > > > > > > > + > > > > > > > + xo-thermistor@1 { > > > > > > > + reg = <1>; > > > > > > > + io-channels = <&pm8998_adc ADC5_XO_THERM_100K_PU>; > > > > > > > + qcom,ratiometric; > > > > > > > + qcom,hw-settle-time-us = <200>; > > > > > > > + }; > > > > > > > + > > > > > > > + msm-thermistor@2 { > > > > > > > + reg = <2>; > > > > > > > + io-channels = <&pm8998_adc ADC5_AMUX_THM1_100K_PU>; > > > > > > > + qcom,ratiometric; > > > > > > > + qcom,hw-settle-time-us = <200>; > > > > > > > + }; > > > > > > > + > > > > > > > + pa-thermistor@3 { > > > > > > > + reg = <3>; > > > > > > > + io-channels = <&pm8998_adc ADC5_AMUX_THM3_100K_PU>; > > > > > > > + qcom,ratiometric; > > > > > > > + qcom,hw-settle-time-us = <200>; > > > > > > > + }; > > > > > > > + > > > > > > > + quiet-thermistor@4 { > > > > > > > + reg = <4>; > > > > > > > + io-channels = <&pm8998_adc ADC5_AMUX_THM5_100K_PU>; > > > > > > > + qcom,ratiometric; > > > > > > > + qcom,hw-settle-time-us = <200>; > > > > > > > + }; > > > > > > > +}; > > > > > > > + > > > > > > > > > > > > The example in the 'qcom,spmi-adc-tm5' binding specifies 'qcom,ratiometric' > > > > > > and 'qcom,hw-settle-time-us' for both the ADC and the thermal monitor, so do > > > > > > several board files (e.g. sm8250-mtp.dts and qrb5165-rb5.dts). This apparent > > > > > > redundancy bothered me earlier, it's not really clear to me whether it's > > > > > > needed/recommended or not. Do you happen to have any insights on this? > > > > > > > > > > Hmm, you're right and I missed this in defining my channels. I've not > > > > > looked at this detail, just got reasonable readings from my thermal > > > > > zones and was happy about that. > > > > > > > > > > Dmitry, do you have any further insights why these properties are > > > > > supposed to be duplicated between the adc channel and the thermal zones? > > > > > > > > Because both ADC channel and thermal zone registers should be > > > > programmed accordingly. > > > > > > > > One not-so-perfect approach would be to use io-channels property to > > > > locate the adc's adc-chan node and to parse it. However this way > > > > thermal driver would have to know the exact structure of adc's device > > > > tree nodes. > > > > Another (even worse) solution would be to introduce qcom-specific API > > > > to query these properties from the IIO channel. > > > > > > > > Selecting between these two options I decided to follow the downstream > > > > path and just to duplicate these few properties. > > > > > > I know I am joining late to this party, since v3 is out. But before I send > > > my acked-by, wanted to check/state a few things. > > > To me, the not-so-perfect approach that you mention here is actually not so > > > bad, considering the thermal sensor driver already is aware of internals of > > > the adc device. The duplicating of node is kind of confusing. > > > Also did you explore using one of _channel_write apis in iio framework to > > > move all the writes into the adc device instead of thermal sensor driver ? > > > > > > > To me the TM hardware block seems to just duplicate some parts of the > > ADC block. Without understanding why the two would need to be configured > > in sync, I don't think we should tie them together further. > > You are right. It is duplicating most of the ADC parts except for > temperature read for which it calls into the adc device. And I don't see any > interface from the ADC driver that can be used to do the configuration TM > needs. Hence the question, have we ever explored this path ? > > > > > > In particular, I get the same readings with or without configuring the > > ADC channels, does this perhaps imply that the TM configuration is used > > to configure the ADC during it's reads (i.e. we don't need to define the > > ADC channels after all), or is this just a coincidence? > > Maybe because of what we do in adc_tm5_init ? > > If needed, we should be able to duplicate the read in the TM as well and get > rid of ADC channels , right ? I don't like this half configuration in TM and > half in ADC device unless there is a reason behind this. > Looking at the registers once more makes me more convinced that the PMIC is using the ADC hardware behind the back of the ADC driver - for the purpose of detecting if we pass the trip points. And then we use the ADC driver to read the temperature, separate of that. To expose a thermal_zone with both trip points and temperature. That way it would be in our best interest to configure the TM and the ADC in the same way, so the trips and temperature readings are matching, but it really is two different interfaces to the underlying ADC hardware. Regards, Bjorn > > > > There are other things in the PMIC, using the ADC seemingly without you > > having to explicitly configure the ADC and there's definitely things > > pointing to the ADC being "timeshared" between various users. > > > > Regards, > > Bjorn > > > > -- > Warm Regards > Thara (She/Her/Hers)