From: Jonathan Cameron <jic23@kernel.org>
To: Stephan Gerhold <stephan@gerhold.net>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Rob Herring <robh+dt@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
"H . Nikolaus Schaller" <hns@goldelico.com>,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 2/4] iio: magnetometer: bmc150: Add rudimentary regulator support
Date: Sat, 9 Jan 2021 14:21:36 +0000 [thread overview]
Message-ID: <20210109142136.7057260c@archlinux> (raw)
In-Reply-To: <X/WR+/PDhLRk7Yek@gerhold.net>
On Wed, 6 Jan 2021 11:33:31 +0100
Stephan Gerhold <stephan@gerhold.net> wrote:
> Hi Jonathan,
>
> On Wed, Dec 02, 2020 at 10:33:20AM +0100, Stephan Gerhold wrote:
> > BMC150 needs VDD and VDDIO regulators that might need to be explicitly
> > enabled. Add some rudimentary support to obtain and enable these
> > regulators during probe() and disable them during remove()
> > or on the error path.
> >
> > Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
>
> I think we forgot about the bmc150_magn part of this patch series. :)
>
> This is likely my mistake - I only sent a v2 for the bmg160 part of this
> patch series, but not for the bmc150_magn part (since it's not affected
> by the problem you mentioned for the bmg160 patch). Sorry for the confusion!
>
> Should I re-send the bmc150_magn part (with or without some changes)?
Please resend. Don't think any changes are needed.
I tend to use the b4 tool to apply patches. I can pick individual
patches out of a series, but it's much easier to just pick up a full
series once it's ready.
Thanks,
Jonathan
>
> Thanks!
> Stephan
>
> > ---
> > This is mostly copy-paste of
> > 079c1c3f2082 ("iio: accel: bmc150-accel: Add rudimentary regulator support")
> > from Linus Walleij but for the BMC150 magnetometer driver.
> > ---
> > drivers/iio/magnetometer/bmc150_magn.c | 26 +++++++++++++++++++++++++-
> > 1 file changed, 25 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
> > index fa09fcab620a..b2f3129e1b4f 100644
> > --- a/drivers/iio/magnetometer/bmc150_magn.c
> > +++ b/drivers/iio/magnetometer/bmc150_magn.c
> > @@ -25,6 +25,7 @@
> > #include <linux/iio/trigger_consumer.h>
> > #include <linux/iio/triggered_buffer.h>
> > #include <linux/regmap.h>
> > +#include <linux/regulator/consumer.h>
> >
> > #include "bmc150_magn.h"
> >
> > @@ -135,6 +136,7 @@ struct bmc150_magn_data {
> > */
> > struct mutex mutex;
> > struct regmap *regmap;
> > + struct regulator_bulk_data regulators[2];
> > struct iio_mount_matrix orientation;
> > /* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */
> > s32 buffer[6];
> > @@ -692,12 +694,24 @@ static int bmc150_magn_init(struct bmc150_magn_data *data)
> > int ret, chip_id;
> > struct bmc150_magn_preset preset;
> >
> > + ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
> > + data->regulators);
> > + if (ret < 0) {
> > + dev_err(data->dev, "Failed to enable regulators: %d\n", ret);
> > + return ret;
> > + }
> > + /*
> > + * 3ms power-on time according to datasheet, let's better
> > + * be safe than sorry and set this delay to 5ms.
> > + */
> > + msleep(5);
> > +
> > ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND,
> > false);
> > if (ret < 0) {
> > dev_err(data->dev,
> > "Failed to bring up device from suspend mode\n");
> > - return ret;
> > + goto err_regulator_disable;
> > }
> >
> > ret = regmap_read(data->regmap, BMC150_MAGN_REG_CHIP_ID, &chip_id);
> > @@ -752,6 +766,8 @@ static int bmc150_magn_init(struct bmc150_magn_data *data)
> >
> > err_poweroff:
> > bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true);
> > +err_regulator_disable:
> > + regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
> > return ret;
> > }
> >
> > @@ -867,6 +883,13 @@ int bmc150_magn_probe(struct device *dev, struct regmap *regmap,
> > data->irq = irq;
> > data->dev = dev;
> >
> > + data->regulators[0].supply = "vdd";
> > + data->regulators[1].supply = "vddio";
> > + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators),
> > + data->regulators);
> > + if (ret)
> > + return dev_err_probe(dev, ret, "failed to get regulators\n");
> > +
> > ret = iio_read_mount_matrix(dev, "mount-matrix",
> > &data->orientation);
> > if (ret)
> > @@ -984,6 +1007,7 @@ int bmc150_magn_remove(struct device *dev)
> > bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true);
> > mutex_unlock(&data->mutex);
> >
> > + regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
> > return 0;
> > }
> > EXPORT_SYMBOL(bmc150_magn_remove);
> > --
> > 2.29.2
> >
next prev parent reply other threads:[~2021-01-09 14:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-02 9:33 [PATCH 1/4] dt-bindings: iio: magnetometer: bmc150: Document regulator supplies Stephan Gerhold
2020-12-02 9:33 ` [PATCH 2/4] iio: magnetometer: bmc150: Add rudimentary regulator support Stephan Gerhold
2020-12-02 12:01 ` Linus Walleij
2021-01-06 10:33 ` Stephan Gerhold
2021-01-09 14:21 ` Jonathan Cameron [this message]
2020-12-02 9:33 ` [PATCH 3/4] dt-bindings: iio: gyroscope: bmg160: Document regulator supplies Stephan Gerhold
2020-12-02 12:02 ` Linus Walleij
2020-12-09 19:45 ` Rob Herring
2020-12-02 9:33 ` [PATCH 4/4] iio: gyro: bmg160: Add rudimentary regulator support Stephan Gerhold
2020-12-02 12:03 ` Linus Walleij
2020-12-05 15:38 ` Jonathan Cameron
2020-12-11 18:36 ` Stephan Gerhold
2020-12-02 12:00 ` [PATCH 1/4] dt-bindings: iio: magnetometer: bmc150: Document regulator supplies Linus Walleij
2020-12-09 19:40 ` Rob Herring
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=20210109142136.7057260c@archlinux \
--to=jic23@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hns@goldelico.com \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=robh+dt@kernel.org \
--cc=stephan@gerhold.net \
/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).