From: Guenter Roeck <linux@roeck-us.net>
To: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: jdelvare@suse.com, robh+dt@kernel.org, mark.rutland@arm.com,
corbet@lwn.net, afd@ti.com, linux-hwmon@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT
Date: Sat, 22 Sep 2018 19:07:02 -0700 [thread overview]
Message-ID: <80510b08-0e89-03ce-7d69-fe51f8b6a7b5@roeck-us.net> (raw)
In-Reply-To: <20180923003841.GA10071@Asurada-Nvidia.nvidia.com>
On 09/22/2018 05:38 PM, Nicolin Chen wrote:
> On Sat, Sep 22, 2018 at 04:59:55PM -0700, Guenter Roeck wrote:
>
>>>>> + /* Disable channels if their inputs are disconnected */
>>>>> + for (i = 0, mask = 0; i < INA3221_NUM_CHANNELS; i++) {
>>>>> + if (ina->inputs[i].disconnected)
>>>>> + mask |= INA3221_CONFIG_CHx_EN(i);
>>>>> + }
>>>>
>>>> Consequently, you should also _enable_ channels which are not explicitly disabled.
>>>
>>> The register has enabled all channels by default. So I felt it'd
>>> be neat to have disabling code only. My v1 actually had enabling
>>> part as well, but I can add it back if you think it'd be better.
>>>
>>>> This can be tricky since you'll have to distinguish non-DT and DT configuration
>>>> and retain the original configuration if no channel configuration data is available
>>>> from devicetree.
>
>>> For non-DT configurations, input->disconnected is always false by
>>> default unless someone adds config for it (through platform_data).
>>> If regmap_update_bits only does disabling like this version does,
>>> non-DT configurations will not get affected since mask = 0. Or if
>>> we change it to do both enabling and disabling, regmap_update_bits
>>> will still ignore since there's no register value changed, though
>>> it won't really hurt even if regmap writes correct configurations
>>> to the register.
>>>
>>> For DT configurations (without channel input source defined), it's
>>> like the same as non-DT configurations. As we have platforms only
>>> enabled ina3221 via DT while they don't have this new DT binding,
>>> the driver has to be backward compatible, so my change only sets
>>> input->disconnected=true when a status="disabled" is present, i.e.
>>> those platforms are treated as all channels getting enabled until
>>> they update their DTs.
>
>> I think your assumption may be that the chip is always in its reset state
>> when Linux is loaded. This is not necessarily the case; it may be
>> preconfigured by BIOS or ROMMON, or even by someone using i2cset before
>> loading the driver. If you add enable/disable functionality, you can
>> not make an assumption about the original state of the chip at probe time;
>> you have to read it from the chip itself.
>
> I see. That made a point. In that case, I think the simplest way
> is probably to do software reset before having configurations.
>
No. If the chip was configured by the BIOS/ROMMON, it is supposed
to be that way. We can not just override that.
Guenter
> The "disconnected" here is to describe the physical connection,
> not exact the switch control status because a channel could be
> connected but disabled. However, a channel would not be enabled
> if it's disconnected. So I think it'd be safe to just disable
> the disconnected channels here as this version does, meanwhile,
> I will add a soft reset to make sure all channels are enabled.
>
> Thanks
> Nicolin
>
next prev parent reply other threads:[~2018-09-23 2:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-21 22:32 [PATCH v3 0/2] Add an initial DT binding doc for ina3221 Nicolin Chen
2018-09-21 22:32 ` [PATCH v3 1/2] dt-bindings: hwmon: Add ina3221 documentation Nicolin Chen
2018-09-22 12:38 ` Guenter Roeck
2018-09-22 18:03 ` Nicolin Chen
2018-09-22 23:56 ` Guenter Roeck
2018-09-21 22:32 ` [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT Nicolin Chen
2018-09-22 12:50 ` Guenter Roeck
2018-09-22 18:46 ` Nicolin Chen
2018-09-22 23:59 ` Guenter Roeck
2018-09-23 0:38 ` Nicolin Chen
2018-09-23 0:50 ` Nicolin Chen
2018-09-23 2:07 ` Guenter Roeck [this message]
2018-09-23 3:33 ` Nicolin Chen
2018-09-23 3:39 ` Nicolin Chen
2018-09-23 5:25 ` Guenter Roeck
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=80510b08-0e89-03ce-7d69-fe51f8b6a7b5@roeck-us.net \
--to=linux@roeck-us.net \
--cc=afd@ti.com \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=nicoleotsuka@gmail.com \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).