linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] hts221: add vdd power regulator
@ 2020-11-22 11:56 Lorenzo Bianconi
  2020-11-22 11:56 ` [PATCH v2 1/2] iio: humidity: hts221: add vdd voltage regulator Lorenzo Bianconi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2020-11-22 11:56 UTC (permalink / raw)
  To: jic23; +Cc: lorenzo.bianconi, devicetree, linux-iio

Introduce support to control VDD power line available on hts221 devices

Changes since v1:
- update vdd-supply binding
- rely on dev_err_probe() in hts221_init_regulators() to avoid
  printing error message is the deferred case

Lorenzo Bianconi (2):
  iio: humidity: hts221: add vdd voltage regulator
  dt-bindings: iio: humidity: hts221: introduce vdd regulator bindings

 .../bindings/iio/humidity/st,hts221.yaml      |  2 +
 drivers/iio/humidity/hts221.h                 |  2 +
 drivers/iio/humidity/hts221_core.c            | 37 +++++++++++++++++++
 3 files changed, 41 insertions(+)

-- 
2.28.0


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

* [PATCH v2 1/2] iio: humidity: hts221: add vdd voltage regulator
  2020-11-22 11:56 [PATCH v2 0/2] hts221: add vdd power regulator Lorenzo Bianconi
@ 2020-11-22 11:56 ` Lorenzo Bianconi
  2020-11-22 11:56 ` [PATCH v2 2/2] dt-bindings: iio: humidity: hts221: introduce vdd regulator bindings Lorenzo Bianconi
  2020-11-28 13:24 ` [PATCH v2 0/2] hts221: add vdd power regulator Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2020-11-22 11:56 UTC (permalink / raw)
  To: jic23; +Cc: lorenzo.bianconi, devicetree, linux-iio

Like all other ST sensors, hts221 devices have VDD power line.
Introduce VDD voltage regulator to control it.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/iio/humidity/hts221.h      |  2 ++
 drivers/iio/humidity/hts221_core.c | 37 ++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/iio/humidity/hts221.h b/drivers/iio/humidity/hts221.h
index 721359e226cb..cf3d8d2dccd6 100644
--- a/drivers/iio/humidity/hts221.h
+++ b/drivers/iio/humidity/hts221.h
@@ -13,6 +13,7 @@
 #define HTS221_DEV_NAME		"hts221"
 
 #include <linux/iio/iio.h>
+#include <linux/regulator/consumer.h>
 
 enum hts221_sensor_type {
 	HTS221_SENSOR_H,
@@ -29,6 +30,7 @@ struct hts221_hw {
 	const char *name;
 	struct device *dev;
 	struct regmap *regmap;
+	struct regulator *vdd;
 
 	struct iio_trigger *trig;
 	int irq;
diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
index 16657789dc45..6a39615b6961 100644
--- a/drivers/iio/humidity/hts221_core.c
+++ b/drivers/iio/humidity/hts221_core.c
@@ -547,6 +547,35 @@ static const struct iio_info hts221_info = {
 
 static const unsigned long hts221_scan_masks[] = {0x3, 0x0};
 
+static int hts221_init_regulators(struct device *dev)
+{
+	struct iio_dev *iio_dev = dev_get_drvdata(dev);
+	struct hts221_hw *hw = iio_priv(iio_dev);
+	int err;
+
+	hw->vdd = devm_regulator_get(dev, "vdd");
+	if (IS_ERR(hw->vdd))
+		return dev_err_probe(dev, PTR_ERR(hw->vdd),
+				     "failed to get vdd regulator\n");
+
+	err = regulator_enable(hw->vdd);
+	if (err) {
+		dev_err(dev, "failed to enable vdd regulator: %d\n", err);
+		return err;
+	}
+
+	msleep(50);
+
+	return 0;
+}
+
+static void hts221_chip_uninit(void *data)
+{
+	struct hts221_hw *hw = data;
+
+	regulator_disable(hw->vdd);
+}
+
 int hts221_probe(struct device *dev, int irq, const char *name,
 		 struct regmap *regmap)
 {
@@ -567,6 +596,14 @@ int hts221_probe(struct device *dev, int irq, const char *name,
 	hw->irq = irq;
 	hw->regmap = regmap;
 
+	err = hts221_init_regulators(dev);
+	if (err)
+		return err;
+
+	err = devm_add_action_or_reset(dev, hts221_chip_uninit, hw);
+	if (err)
+		return err;
+
 	err = hts221_check_whoami(hw);
 	if (err < 0)
 		return err;
-- 
2.28.0


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

* [PATCH v2 2/2] dt-bindings: iio: humidity: hts221: introduce vdd regulator bindings
  2020-11-22 11:56 [PATCH v2 0/2] hts221: add vdd power regulator Lorenzo Bianconi
  2020-11-22 11:56 ` [PATCH v2 1/2] iio: humidity: hts221: add vdd voltage regulator Lorenzo Bianconi
@ 2020-11-22 11:56 ` Lorenzo Bianconi
  2020-11-28 13:24 ` [PATCH v2 0/2] hts221: add vdd power regulator Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2020-11-22 11:56 UTC (permalink / raw)
  To: jic23; +Cc: lorenzo.bianconi, devicetree, linux-iio

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml b/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml
index 396451c26728..598473df74fa 100644
--- a/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml
+++ b/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml
@@ -26,6 +26,8 @@ properties:
       The interrupt/data ready line will be configured as open drain, which
       is useful if several sensors share the same interrupt line.
 
+  vdd-supply: true
+
   interrupts:
     maxItems: 1
 
-- 
2.28.0


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

* Re: [PATCH v2 0/2] hts221: add vdd power regulator
  2020-11-22 11:56 [PATCH v2 0/2] hts221: add vdd power regulator Lorenzo Bianconi
  2020-11-22 11:56 ` [PATCH v2 1/2] iio: humidity: hts221: add vdd voltage regulator Lorenzo Bianconi
  2020-11-22 11:56 ` [PATCH v2 2/2] dt-bindings: iio: humidity: hts221: introduce vdd regulator bindings Lorenzo Bianconi
@ 2020-11-28 13:24 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2020-11-28 13:24 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: lorenzo.bianconi, devicetree, linux-iio

On Sun, 22 Nov 2020 12:56:47 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Introduce support to control VDD power line available on hts221 devices
> 
> Changes since v1:
> - update vdd-supply binding
> - rely on dev_err_probe() in hts221_init_regulators() to avoid
>   printing error message is the deferred case
> 
> Lorenzo Bianconi (2):
>   iio: humidity: hts221: add vdd voltage regulator
>   dt-bindings: iio: humidity: hts221: introduce vdd regulator bindings
> 
>  .../bindings/iio/humidity/st,hts221.yaml      |  2 +
>  drivers/iio/humidity/hts221.h                 |  2 +
>  drivers/iio/humidity/hts221_core.c            | 37 +++++++++++++++++++
>  3 files changed, 41 insertions(+)
> 
Applied to the togreg branch of iio.git and pushed out as testing.

thanks,

Jonathan



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

end of thread, other threads:[~2020-11-28 22:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-22 11:56 [PATCH v2 0/2] hts221: add vdd power regulator Lorenzo Bianconi
2020-11-22 11:56 ` [PATCH v2 1/2] iio: humidity: hts221: add vdd voltage regulator Lorenzo Bianconi
2020-11-22 11:56 ` [PATCH v2 2/2] dt-bindings: iio: humidity: hts221: introduce vdd regulator bindings Lorenzo Bianconi
2020-11-28 13:24 ` [PATCH v2 0/2] hts221: add vdd power regulator Jonathan Cameron

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).