All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] dt-bindings: iio: gyroscope: bmg160: Document regulator supplies
@ 2020-12-11 18:38 Stephan Gerhold
  2020-12-11 18:38 ` [PATCH v2 2/2] iio: gyro: bmg160: Add rudimentary regulator support Stephan Gerhold
  0 siblings, 1 reply; 5+ messages in thread
From: Stephan Gerhold @ 2020-12-11 18:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	linux-iio, devicetree, H . Nikolaus Schaller, Linus Walleij,
	Stephan Gerhold, Rob Herring

BMG160 needs VDD and VDDIO regulators that might need to be explicitly
enabled. Document support for vdd/vddio-supply to implement this.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
Changes in v2:
  - Split from patches for bmc150
  - Add Reviewed-by:
---
 .../devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml        | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml b/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml
index 0466483be6bb..b6bbc312a7cf 100644
--- a/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml
+++ b/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml
@@ -19,6 +19,9 @@ properties:
   reg:
     maxItems: 1
 
+  vdd-supply: true
+  vddio-supply: true
+
   interrupts:
     minItems: 1
     description:
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] iio: gyro: bmg160: Add rudimentary regulator support
  2020-12-11 18:38 [PATCH v2 1/2] dt-bindings: iio: gyroscope: bmg160: Document regulator supplies Stephan Gerhold
@ 2020-12-11 18:38 ` Stephan Gerhold
  2020-12-13 13:03   ` Jonathan Cameron
  2020-12-14  8:57   ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Stephan Gerhold @ 2020-12-11 18:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	linux-iio, devicetree, H . Nikolaus Schaller, Linus Walleij,
	Stephan Gerhold

BMG160 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 using a devm action.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
Changes in v2:
  - Do regulator_bulk_enable() immediately after devm_regulator_bulk_get()
  - Simplify error handling using devm_add_action_or_reset()
---
 drivers/iio/gyro/bmg160_core.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
index 2d5015801a75..029ef4c34604 100644
--- a/drivers/iio/gyro/bmg160_core.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -19,6 +19,7 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 #include "bmg160.h"
 
 #define BMG160_IRQ_NAME		"bmg160_event"
@@ -92,6 +93,7 @@
 
 struct bmg160_data {
 	struct regmap *regmap;
+	struct regulator_bulk_data regulators[2];
 	struct iio_trigger *dready_trig;
 	struct iio_trigger *motion_trig;
 	struct iio_mount_matrix orientation;
@@ -1061,6 +1063,13 @@ static const char *bmg160_match_acpi_device(struct device *dev)
 	return dev_name(dev);
 }
 
+static void bmg160_disable_regulators(void *d)
+{
+	struct bmg160_data *data = d;
+
+	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
+}
+
 int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
 		      const char *name)
 {
@@ -1077,6 +1086,22 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
 	data->irq = irq;
 	data->regmap = regmap;
 
+	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 = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
+				    data->regulators);
+	if (ret)
+		return ret;
+
+	ret = devm_add_action_or_reset(dev, bmg160_disable_regulators, data);
+	if (ret)
+		return ret;
+
 	ret = iio_read_mount_matrix(dev, "mount-matrix",
 				&data->orientation);
 	if (ret)
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] iio: gyro: bmg160: Add rudimentary regulator support
  2020-12-11 18:38 ` [PATCH v2 2/2] iio: gyro: bmg160: Add rudimentary regulator support Stephan Gerhold
@ 2020-12-13 13:03   ` Jonathan Cameron
  2020-12-14  8:57   ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2020-12-13 13:03 UTC (permalink / raw)
  To: Stephan Gerhold
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	linux-iio, devicetree, H . Nikolaus Schaller, Linus Walleij

On Fri, 11 Dec 2020 19:38:15 +0100
Stephan Gerhold <stephan@gerhold.net> wrote:

> BMG160 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 using a devm action.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Looks good to me.  I'm going to let this sit a little longer though
(we've missed the merge window anyway so lots of time) in order to
give Linus a chance to look at this new version seeing as he
gave a Reviewed-by on previous but this is significantly different.

If it looks like I've managed to loose this (it has happened a few times!)
then please give me a poke in a few weeks time.

Thanks,

Jonathan

> ---
> Changes in v2:
>   - Do regulator_bulk_enable() immediately after devm_regulator_bulk_get()
>   - Simplify error handling using devm_add_action_or_reset()
> ---
>  drivers/iio/gyro/bmg160_core.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
> index 2d5015801a75..029ef4c34604 100644
> --- a/drivers/iio/gyro/bmg160_core.c
> +++ b/drivers/iio/gyro/bmg160_core.c
> @@ -19,6 +19,7 @@
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/regmap.h>
> +#include <linux/regulator/consumer.h>
>  #include "bmg160.h"
>  
>  #define BMG160_IRQ_NAME		"bmg160_event"
> @@ -92,6 +93,7 @@
>  
>  struct bmg160_data {
>  	struct regmap *regmap;
> +	struct regulator_bulk_data regulators[2];
>  	struct iio_trigger *dready_trig;
>  	struct iio_trigger *motion_trig;
>  	struct iio_mount_matrix orientation;
> @@ -1061,6 +1063,13 @@ static const char *bmg160_match_acpi_device(struct device *dev)
>  	return dev_name(dev);
>  }
>  
> +static void bmg160_disable_regulators(void *d)
> +{
> +	struct bmg160_data *data = d;
> +
> +	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
> +}
> +
>  int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
>  		      const char *name)
>  {
> @@ -1077,6 +1086,22 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
>  	data->irq = irq;
>  	data->regmap = regmap;
>  
> +	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 = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
> +				    data->regulators);
> +	if (ret)
> +		return ret;
> +
> +	ret = devm_add_action_or_reset(dev, bmg160_disable_regulators, data);
> +	if (ret)
> +		return ret;
> +
>  	ret = iio_read_mount_matrix(dev, "mount-matrix",
>  				&data->orientation);
>  	if (ret)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] iio: gyro: bmg160: Add rudimentary regulator support
  2020-12-11 18:38 ` [PATCH v2 2/2] iio: gyro: bmg160: Add rudimentary regulator support Stephan Gerhold
  2020-12-13 13:03   ` Jonathan Cameron
@ 2020-12-14  8:57   ` Linus Walleij
  2020-12-29 18:30     ` Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2020-12-14  8:57 UTC (permalink / raw)
  To: Stephan Gerhold
  Cc: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, linux-iio,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	H . Nikolaus Schaller

On Fri, Dec 11, 2020 at 7:39 PM Stephan Gerhold <stephan@gerhold.net> wrote:

> BMG160 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 using a devm action.
>
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
> Changes in v2:
>   - Do regulator_bulk_enable() immediately after devm_regulator_bulk_get()
>   - Simplify error handling using devm_add_action_or_reset()

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] iio: gyro: bmg160: Add rudimentary regulator support
  2020-12-14  8:57   ` Linus Walleij
@ 2020-12-29 18:30     ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2020-12-29 18:30 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Stephan Gerhold, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, linux-iio,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	H . Nikolaus Schaller

On Mon, 14 Dec 2020 09:57:06 +0100
Linus Walleij <linus.walleij@linaro.org> wrote:

> On Fri, Dec 11, 2020 at 7:39 PM Stephan Gerhold <stephan@gerhold.net> wrote:
> 
> > BMG160 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 using a devm action.
> >
> > Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> > ---
> > Changes in v2:
> >   - Do regulator_bulk_enable() immediately after devm_regulator_bulk_get()
> >   - Simplify error handling using devm_add_action_or_reset()  
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Series applied,

Thanks,

Jonathan

> 
> Yours,
> Linus Walleij


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-29 18:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 18:38 [PATCH v2 1/2] dt-bindings: iio: gyroscope: bmg160: Document regulator supplies Stephan Gerhold
2020-12-11 18:38 ` [PATCH v2 2/2] iio: gyro: bmg160: Add rudimentary regulator support Stephan Gerhold
2020-12-13 13:03   ` Jonathan Cameron
2020-12-14  8:57   ` Linus Walleij
2020-12-29 18:30     ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.