From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@kernel.org>, Crt Mori <cmo@melexis.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] iio: temperature: mlx90632 Add supply regulator to sensor
Date: Sat, 6 Aug 2022 18:29:11 +0200 [thread overview]
Message-ID: <c28e5dfa-9ce8-a60e-a72a-1c733711ccca@metafoo.de> (raw)
In-Reply-To: <20220806171345.45cf1228@jic23-huawei>
On 8/6/22 18:15, Jonathan Cameron wrote:
> On Tue, 2 Aug 2022 12:30:22 +0200
> Crt Mori <cmo@melexis.com> wrote:
>
>> Provide possibility to toggle power supply to the sensor so that user
>> can optimize their setup and not have the sensor constantly powered.
>>
>> Signed-off-by: Crt Mori <cmo@melexis.com>
>> ---
>> drivers/iio/temperature/mlx90632.c | 52 ++++++++++++++++++++++++++++++
>> 1 file changed, 52 insertions(+)
>>
>> diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
>> index 7ee7ff8047a4..e6e5e649a9f9 100644
>> --- a/drivers/iio/temperature/mlx90632.c
>> +++ b/drivers/iio/temperature/mlx90632.c
>> @@ -18,6 +18,7 @@
>> #include <linux/math64.h>
>> #include <linux/pm_runtime.h>
>> #include <linux/regmap.h>
>> +#include <linux/regulator/consumer.h>
>>
>> #include <linux/iio/iio.h>
>> #include <linux/iio/sysfs.h>
>> @@ -128,6 +129,7 @@
>> * calculations
>> * @object_ambient_temperature: Ambient temperature at object (might differ of
>> * the ambient temperature of sensor.
>> + * @regulator: Regulator of the device
>> */
>> struct mlx90632_data {
>> struct i2c_client *client;
>> @@ -136,6 +138,7 @@ struct mlx90632_data {
>> u16 emissivity;
>> u8 mtyp;
>> u32 object_ambient_temperature;
>> + struct regulator *regulator;
>> };
>>
>> static const struct regmap_range mlx90632_volatile_reg_range[] = {
>> @@ -841,6 +844,37 @@ static int mlx90632_wakeup(struct mlx90632_data *data)
>> return mlx90632_pwr_continuous(data->regmap);
>> }
>>
>> +static void mlx90632_disable_regulator(void *_data)
>> +{
>> + struct mlx90632_data *data = _data;
>> + int ret;
>> +
>> + ret = regulator_disable(data->regulator);
>> + if (ret < 0)
>> + dev_err(regmap_get_device(data->regmap),
>> + "Failed to disable power regulator: %d\n", ret);
>> +}
>> +
>> +static int mlx90632_enable_regulator(struct mlx90632_data *data)
>> +{
>> + int ret;
>> +
>> + ret = regulator_set_voltage(data->regulator, 3200000, 3600000);
>> + if (ret < 0) {
> Hmm. This can be problematic, as a valid option is for the a stub regulator to
> have been returned. Mostly for device where it is common for them to be wired
> to fixed regulators, we just assume the firmware set the voltage correctly.
> Ideally it provides a fixed (or controllable) regulator to make that clear.
Just to add to what Jonathan said. For configurable regulators the
allowed voltage values should be provided in the devicetree and the
regulator framework will set it automatically. See the
regulator-min-microvolt and regulator-max-microvolt DT properties.
prev parent reply other threads:[~2022-08-06 16:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 10:30 [PATCH 1/2] iio: temperature: mlx90632 Add supply regulator to sensor Crt Mori
2022-08-06 16:15 ` Jonathan Cameron
2022-08-06 16:29 ` Lars-Peter Clausen [this message]
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=c28e5dfa-9ce8-a60e-a72a-1c733711ccca@metafoo.de \
--to=lars@metafoo.de \
--cc=cmo@melexis.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.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).