[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5b62afcb-254d-4dfc-8332-7979c62ea2c2@gmail.com>
Date: Thu, 7 Dec 2023 21:34:58 +0100
From: Javier Carrasco <javier.carrasco.cruz@...il.com>
To: Mark Brown <broonie@...nel.org>
Cc: Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Jean Delvare <jdelvare@...e.com>,
Guenter Roeck <linux@...ck-us.net>,
Jonathan Corbet <corbet@....net>,
Liam Girdwood <lgirdwood@...il.com>,
Rob Herring <robh@...nel.org>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hwmon@...r.kernel.org,
linux-doc@...r.kernel.org
Subject: Re: [PATCH v3 5/5] hwmon: Add support for Amphenol ChipCap 2
On 07.12.23 21:05, Mark Brown wrote:
> On Thu, Dec 07, 2023 at 08:44:55PM +0100, Javier Carrasco wrote:
>
>> + if (regulator_is_enabled(data->regulator)) {
>> + ret = regulator_disable(data->regulator);
>> + if (ret < 0)
>> + return ret;
>> +
>> + msleep(CC2_POWER_CYCLE_MS); /* ensure a clean power cycle */
>> + }
>> +
>> + ret = regulator_enable(data->regulator);
>> + if (ret < 0)
>> + return ret;
>
> This is very buggy. A consumer should only disable a regulator if it
> itself enabled that regulator (or it *requires* an exclusive regulator
> which isn't a good fit here), and there's no guarantee that disabling a
> regulator will actually result in a power off. Either the board might
> not physically or through constraints permit the state to change or
> another user may have enabled the regulator. The driver needs to keep
> track of if it enabled the regulator and only disable it as many times
> as it enabled it.
The idea is actually that if alarms are required, an exclusive regulator
will be necessary to trigger power cycles and enter the command mode.
In summary there would be two options: either a regulator is defined and
can be controlled to trigger the command mode or no regulator was
defined for this device and therefore no command mode is available i.e.
interrupts cannot be configured. That would be the case for example when
the supply is always on.
>
> For this usage with trying to bounce the power of the regulator you can
> keep track of the actual power state of the supply by listening to
> notifications, and should possibly just keep the regulator disabled when
> it's not actively in use (if no alarm is active or measurement in
> progress?).
>
>> + data->regulator = devm_regulator_get_optional(dev, "vdd");
>
> Does the device *really* work without power? The datasheet appears to
> suggest that the device has a non-optional supply Vdd
>
> https://f.hubspotusercontent40.net/hubfs/9035299/Documents/AAS-916-127J-Telaire-ChipCap2-022118-web.pdf
>
The vdd is a non-optional supply and the device cannot run without it.
What is optional is the controllable regulator to enter the command
window. Hence why I used _optional() functions.
I could ban any use without a controllable regulator to make things
simpler, but if no alarms are required, the device should work fine
without command mode. Either way the driver must have some control over
a regulator for the mentioned command window.
> (there's also a Vcore pin but that appears to be for connecting a
> decoupling capacitor rather than a supply).
>
> In general _optional() should only be used for supplies which may be
> physically absentIn the end I need a way to control a regulator to enter in command mode,
but still offering measurement functionality if there is no regulator to
control.
The current approach is that there must be a supply, but the regulator
might be controllable or not.
Thank you for your feedback and best regards,
Javier Carrasco
Powered by blists - more mailing lists