Linux IIO development
 help / color / mirror / Atom feed
From: Jishnu Prakash <quic_jprakash@quicinc.com>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: <jic23@kernel.org>, <robh+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <conor+dt@kernel.org>,
	<andersson@kernel.org>, <konrad.dybcio@linaro.org>,
	<lee@kernel.org>, <andriy.shevchenko@linux.intel.com>,
	<daniel.lezcano@linaro.org>, <lars@metafoo.de>, <luca@z3ntu.xyz>,
	<marijn.suijten@somainline.org>, <agross@kernel.org>,
	<sboyd@kernel.org>, <rafael@kernel.org>, <rui.zhang@intel.com>,
	<lukasz.luba@arm.com>, <linus.walleij@linaro.org>,
	<quic_subbaram@quicinc.com>, <quic_collinsd@quicinc.com>,
	<quic_amelende@quicinc.com>, <quic_kamalw@quicinc.com>,
	<kernel@quicinc.com>, <linux-kernel@vger.kernel.org>,
	<linux-arm-msm@vger.kernel.org>,
	<linux-arm-msm-owner@vger.kernel.org>,
	<linux-iio@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<devicetree@vger.kernel.org>,
	<cros-qcom-dts-watchers@chromium.org>
Subject: Re: [PATCH v3 3/3] iio: adc: Add support for QCOM PMIC5 Gen3 ADC
Date: Wed, 14 Feb 2024 19:28:26 +0530	[thread overview]
Message-ID: <e5a5b32c-bc9d-42b7-b1a8-90e22b957915@quicinc.com> (raw)
In-Reply-To: <CAA8EJpr4q7pFF44oUjJSWGYKgiUCB_23zVHw6J3a3mwn7cKgyg@mail.gmail.com>

Hi Dmitry,

On 12/31/2023 11:16 PM, Dmitry Baryshkov wrote:
> On Sun, 31 Dec 2023 at 19:13, Jishnu Prakash <quic_jprakash@quicinc.com> wrote:
>> The ADC architecture on PMIC5 Gen3 is similar to that on PMIC5 Gen2,
>> with all SW communication to ADC going through PMK8550 which
>> communicates with other PMICs through PBS.

>> +static int adc_tm_register_tzd(struct adc5_chip *adc)
>> +{
>> +       unsigned int i, channel;
>> +       struct thermal_zone_device *tzd;
>> +
>> +       for (i = 0; i < adc->nchannels; i++) {
>> +               channel = V_CHAN(adc->chan_props[i]);
>> +
>> +               if (!adc->chan_props[i].adc_tm)
>> +                       continue;
>> +               tzd = devm_thermal_of_zone_register(adc->dev, channel,
>> +                       &adc->chan_props[i], &adc_tm_ops);
> It is _very_ useful to register a hwmon too by calling
> devm_thermal_add_hwmon_sysfs(). However this becomes tricky, as this
> function is not defined in one of the global headers.
>
> This actually points out an issue. You have the ADC driver fused
> together with the thermal driver. Can I suggest using the aux device
> to split the thermal functionality to the separate driver?
>
> This way it would be possible to use the ADC without any thermal
> monitoring in place.


There are a couple of issues which may make it harder to split the 
thermal functionality from this driver into an auxiliary driver as you 
mentioned.

For one, we use the same set of registers (offsets 0x4f-0x55) for both 
VADC function(requesting an immediate channel reading) and ADC_TM 
function (setting upper/lower thermal thresholds on a channel). To avoid 
any race conditions, we would need to share a mutex between the 
top-level ADC driver and the auxiliary ADC_TM thermal driver to avoid 
concurrently accessing these or any other shared registers.

In addition, the device has only one interrupt with one interrupt 
handler, and it gets triggered for both VADC and ADC_TM  events (end of 
conversion and threshold violation, respectively). The handler checks 
for both types of event and handles it as required.

For the shared interrupt, we may be able to keep the interrupt handler 
in the top-level driver and just notify the auxiliary TM driver if a 
threshold violation is detected. For the shared mutex, I think the 
auxiliary driver may be able to access the parent driver's mutex, but 
I'll need to check more for the implementation in both of these cases.

Please let me know if you see any problems with this kind of 
implementation or if you have any additional comments.

Thanks,

Jishnu

>> +
>> +               if (IS_ERR(tzd)) {
>> +                       if (PTR_ERR(tzd) == -ENODEV) {
>> +                               dev_warn(adc->dev, "thermal sensor on channel %d is not used\n",
>> +                                        channel);
>> +                               continue;
>> +                       }
>> +
>>
>

  reply	other threads:[~2024-02-14 13:59 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-31 17:12 [PATCH v3 0/3] iio: adc: Add support for QCOM SPMI PMIC5 Gen3 ADC Jishnu Prakash
2023-12-31 17:12 ` [PATCH v3 1/3] dt-bindings: iio/adc: Move QCOM ADC bindings to iio/adc folder Jishnu Prakash
2024-01-01 10:35   ` kernel test robot
2024-01-04  8:08   ` Krzysztof Kozlowski
2023-12-31 17:12 ` [PATCH v3 2/3] dt-bindings: iio: adc: Add support for QCOM PMIC5 Gen3 ADC Jishnu Prakash
2023-12-31 17:41   ` Dmitry Baryshkov
2024-01-01 18:02   ` Jonathan Cameron
2024-02-16 10:39     ` Jishnu Prakash
2024-02-16 13:45       ` Jonathan Cameron
2024-01-04  8:18   ` Krzysztof Kozlowski
2024-02-16 11:44     ` Jishnu Prakash
2024-02-17 14:15       ` Krzysztof Kozlowski
     [not found]     ` <13f2b558-a50d-44d3-85de-38e230212732@quicinc.com>
2024-02-16 10:48       ` Dmitry Baryshkov
2024-02-16 11:18         ` Jishnu Prakash
2024-02-17 14:13       ` Krzysztof Kozlowski
2024-02-21  5:36         ` Jishnu Prakash
2024-02-21  7:19           ` Krzysztof Kozlowski
2024-03-14  8:28             ` Jishnu Prakash
2024-03-14  8:36               ` Krzysztof Kozlowski
2023-12-31 17:12 ` [PATCH v3 3/3] " Jishnu Prakash
2023-12-31 17:46   ` Dmitry Baryshkov
2024-02-14 13:58     ` Jishnu Prakash [this message]
2024-02-16 10:52       ` Dmitry Baryshkov
2023-12-31 19:54   ` kernel test robot
2024-01-01 17:54   ` Jonathan Cameron
2024-02-16 11:44     ` Jishnu Prakash
     [not found]     ` <b02f20fd-c682-4b47-8d61-1d0e2adbdd57@quicinc.com>
2024-02-16 13:54       ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5a5b32c-bc9d-42b7-b1a8-90e22b957915@quicinc.com \
    --to=quic_jprakash@quicinc.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=conor+dt@kernel.org \
    --cc=cros-qcom-dts-watchers@chromium.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=jic23@kernel.org \
    --cc=kernel@quicinc.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-msm-owner@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=luca@z3ntu.xyz \
    --cc=lukasz.luba@arm.com \
    --cc=marijn.suijten@somainline.org \
    --cc=quic_amelende@quicinc.com \
    --cc=quic_collinsd@quicinc.com \
    --cc=quic_kamalw@quicinc.com \
    --cc=quic_subbaram@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox