* [PATCH 0/2] st_lsm6dsx: add vdd-vddio power regulator
@ 2020-11-17 15:11 Lorenzo Bianconi
2020-11-17 15:11 ` [PATCH 1/2] iio: imu: st_lsm6dsx: add vdd-vddio voltage regulator Lorenzo Bianconi
2020-11-17 15:11 ` [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: introduce vdd-vddio regulators bindings Lorenzo Bianconi
0 siblings, 2 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2020-11-17 15:11 UTC (permalink / raw)
To: jic23; +Cc: lorenzo.bianconi, linux-iio, devicetree
Introduce support to control VDD and VDDIO power lines available on
st_lsm6dsx devices
Lorenzo Bianconi (2):
iio: imu: st_lsm6dsx: add vdd-vddio voltage regulator
dt-bindings: iio: imu: st_lsm6dsx: introduce vdd-vddio regulators
bindings
.../bindings/iio/imu/st_lsm6dsx.txt | 4 ++
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 ++
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 42 +++++++++++++++++++
3 files changed, 49 insertions(+)
--
2.26.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] iio: imu: st_lsm6dsx: add vdd-vddio voltage regulator
2020-11-17 15:11 [PATCH 0/2] st_lsm6dsx: add vdd-vddio power regulator Lorenzo Bianconi
@ 2020-11-17 15:11 ` Lorenzo Bianconi
2020-11-17 16:07 ` Jonathan Cameron
2020-11-17 15:11 ` [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: introduce vdd-vddio regulators bindings Lorenzo Bianconi
1 sibling, 1 reply; 6+ messages in thread
From: Lorenzo Bianconi @ 2020-11-17 15:11 UTC (permalink / raw)
To: jic23; +Cc: lorenzo.bianconi, linux-iio, devicetree
Like all other ST sensors, st_lsm6dsx devices have VDD and VDDIO power
lines. Introduce voltage regulators to control them.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 ++
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 42 ++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index 1f31657a7a0e..4b4ec39d4400 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -13,6 +13,7 @@
#include <linux/device.h>
#include <linux/iio/iio.h>
+#include <linux/regulator/consumer.h>
#define ST_LSM6DS3_DEV_NAME "lsm6ds3"
#define ST_LSM6DS3H_DEV_NAME "lsm6ds3h"
@@ -368,6 +369,7 @@ struct st_lsm6dsx_sensor {
* struct st_lsm6dsx_hw - ST IMU MEMS hw instance
* @dev: Pointer to instance of struct device (I2C or SPI).
* @regmap: Register map of the device.
+ * @regulators: VDD/VDDIO voltage regulators.
* @irq: Device interrupt line (I2C or SPI).
* @fifo_lock: Mutex to prevent concurrent access to the hw FIFO.
* @conf_lock: Mutex to prevent concurrent FIFO configuration update.
@@ -390,6 +392,7 @@ struct st_lsm6dsx_sensor {
struct st_lsm6dsx_hw {
struct device *dev;
struct regmap *regmap;
+ struct regulator_bulk_data regulators[2];
int irq;
struct mutex fifo_lock;
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index da91f5e7e86d..8b9b724121a8 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -2549,6 +2549,40 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
return 0;
}
+static int st_lsm6dsx_init_regulators(struct device *dev)
+{
+ struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
+ int err;
+
+ /* vdd-vddio power regulators */
+ hw->regulators[0].supply = "vdd";
+ hw->regulators[1].supply = "vddio";
+ err = devm_regulator_bulk_get(dev, ARRAY_SIZE(hw->regulators),
+ hw->regulators);
+ if (err) {
+ dev_err(dev, "failed to get regulators: %d\n", err);
+ return err;
+ }
+
+ err = regulator_bulk_enable(ARRAY_SIZE(hw->regulators),
+ hw->regulators);
+ if (err) {
+ dev_err(dev, "failed to enable regulators: %d\n", err);
+ return err;
+ }
+
+ msleep(50);
+
+ return 0;
+}
+
+static void st_lsm6dsx_chip_uninit(void *data)
+{
+ struct st_lsm6dsx_hw *hw = data;
+
+ regulator_bulk_disable(ARRAY_SIZE(hw->regulators), hw->regulators);
+}
+
int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
struct regmap *regmap)
{
@@ -2568,6 +2602,14 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
mutex_init(&hw->conf_lock);
mutex_init(&hw->page_lock);
+ err = st_lsm6dsx_init_regulators(dev);
+ if (err)
+ return err;
+
+ err = devm_add_action_or_reset(dev, st_lsm6dsx_chip_uninit, hw);
+ if (err)
+ return err;
+
hw->buff = devm_kzalloc(dev, ST_LSM6DSX_BUFF_SIZE, GFP_KERNEL);
if (!hw->buff)
return -ENOMEM;
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: introduce vdd-vddio regulators bindings
2020-11-17 15:11 [PATCH 0/2] st_lsm6dsx: add vdd-vddio power regulator Lorenzo Bianconi
2020-11-17 15:11 ` [PATCH 1/2] iio: imu: st_lsm6dsx: add vdd-vddio voltage regulator Lorenzo Bianconi
@ 2020-11-17 15:11 ` Lorenzo Bianconi
2020-11-17 16:06 ` Jonathan Cameron
1 sibling, 1 reply; 6+ messages in thread
From: Lorenzo Bianconi @ 2020-11-17 15:11 UTC (permalink / raw)
To: jic23; +Cc: lorenzo.bianconi, linux-iio, devicetree
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
index 7c6742d3e992..bc3448df9647 100644
--- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
+++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
@@ -20,6 +20,10 @@ Required properties:
- reg: i2c address of the sensor / spi cs line
Optional properties:
+- vdd-supply: an optional regulator that needs to be on to provide VDD
+ power to the sensor.
+- vddio-supply: an optional regulator that needs to be on to provide the
+ VDD IO power to the sensor.
- st,drdy-int-pin: the pin on the package that will be used to signal
"data ready" (valid values: 1 or 2).
- st,pullups : enable/disable internal i2c controller pullup resistors.
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: introduce vdd-vddio regulators bindings
2020-11-17 15:11 ` [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: introduce vdd-vddio regulators bindings Lorenzo Bianconi
@ 2020-11-17 16:06 ` Jonathan Cameron
2020-11-17 16:17 ` Lorenzo Bianconi
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2020-11-17 16:06 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: jic23, lorenzo.bianconi, linux-iio, devicetree
On Tue, 17 Nov 2020 16:11:38 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> index 7c6742d3e992..bc3448df9647 100644
> --- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> +++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> @@ -20,6 +20,10 @@ Required properties:
> - reg: i2c address of the sensor / spi cs line
>
> Optional properties:
> +- vdd-supply: an optional regulator that needs to be on to provide VDD
> + power to the sensor.
> +- vddio-supply: an optional regulator that needs to be on to provide the
> + VDD IO power to the sensor.
> - st,drdy-int-pin: the pin on the package that will be used to signal
> "data ready" (valid values: 1 or 2).
> - st,pullups : enable/disable internal i2c controller pullup resistors.
Hi Lorenzo,
Please could you rebase this on top of
https://lore.kernel.org/linux-iio/20201031184854.745828-13-jic23@kernel.org/
Which does a yaml conversion of this file.
I'm working my way through backlog of those this week so will pick that up
at some point very soon.
I'll resend a v2 of some patches in those series, but only those where there
are outstanding comments that aren't trivial.
(Rob's acked most with a few requested tweaks).
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: add vdd-vddio voltage regulator
2020-11-17 15:11 ` [PATCH 1/2] iio: imu: st_lsm6dsx: add vdd-vddio voltage regulator Lorenzo Bianconi
@ 2020-11-17 16:07 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2020-11-17 16:07 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: jic23, lorenzo.bianconi, linux-iio, devicetree
On Tue, 17 Nov 2020 16:11:37 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> Like all other ST sensors, st_lsm6dsx devices have VDD and VDDIO power
> lines. Introduce voltage regulators to control them.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Looks good to me.
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 ++
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 42 ++++++++++++++++++++
> 2 files changed, 45 insertions(+)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 1f31657a7a0e..4b4ec39d4400 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -13,6 +13,7 @@
>
> #include <linux/device.h>
> #include <linux/iio/iio.h>
> +#include <linux/regulator/consumer.h>
>
> #define ST_LSM6DS3_DEV_NAME "lsm6ds3"
> #define ST_LSM6DS3H_DEV_NAME "lsm6ds3h"
> @@ -368,6 +369,7 @@ struct st_lsm6dsx_sensor {
> * struct st_lsm6dsx_hw - ST IMU MEMS hw instance
> * @dev: Pointer to instance of struct device (I2C or SPI).
> * @regmap: Register map of the device.
> + * @regulators: VDD/VDDIO voltage regulators.
> * @irq: Device interrupt line (I2C or SPI).
> * @fifo_lock: Mutex to prevent concurrent access to the hw FIFO.
> * @conf_lock: Mutex to prevent concurrent FIFO configuration update.
> @@ -390,6 +392,7 @@ struct st_lsm6dsx_sensor {
> struct st_lsm6dsx_hw {
> struct device *dev;
> struct regmap *regmap;
> + struct regulator_bulk_data regulators[2];
> int irq;
>
> struct mutex fifo_lock;
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index da91f5e7e86d..8b9b724121a8 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2549,6 +2549,40 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
> return 0;
> }
>
> +static int st_lsm6dsx_init_regulators(struct device *dev)
> +{
> + struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
> + int err;
> +
> + /* vdd-vddio power regulators */
> + hw->regulators[0].supply = "vdd";
> + hw->regulators[1].supply = "vddio";
> + err = devm_regulator_bulk_get(dev, ARRAY_SIZE(hw->regulators),
> + hw->regulators);
> + if (err) {
> + dev_err(dev, "failed to get regulators: %d\n", err);
> + return err;
> + }
> +
> + err = regulator_bulk_enable(ARRAY_SIZE(hw->regulators),
> + hw->regulators);
> + if (err) {
> + dev_err(dev, "failed to enable regulators: %d\n", err);
> + return err;
> + }
> +
> + msleep(50);
> +
> + return 0;
> +}
> +
> +static void st_lsm6dsx_chip_uninit(void *data)
> +{
> + struct st_lsm6dsx_hw *hw = data;
> +
> + regulator_bulk_disable(ARRAY_SIZE(hw->regulators), hw->regulators);
> +}
> +
> int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
> struct regmap *regmap)
> {
> @@ -2568,6 +2602,14 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
> mutex_init(&hw->conf_lock);
> mutex_init(&hw->page_lock);
>
> + err = st_lsm6dsx_init_regulators(dev);
> + if (err)
> + return err;
> +
> + err = devm_add_action_or_reset(dev, st_lsm6dsx_chip_uninit, hw);
> + if (err)
> + return err;
> +
> hw->buff = devm_kzalloc(dev, ST_LSM6DSX_BUFF_SIZE, GFP_KERNEL);
> if (!hw->buff)
> return -ENOMEM;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: introduce vdd-vddio regulators bindings
2020-11-17 16:06 ` Jonathan Cameron
@ 2020-11-17 16:17 ` Lorenzo Bianconi
0 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2020-11-17 16:17 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: jic23, lorenzo.bianconi, linux-iio, devicetree
[-- Attachment #1: Type: text/plain, Size: 1831 bytes --]
> On Tue, 17 Nov 2020 16:11:38 +0100
> Lorenzo Bianconi <lorenzo@kernel.org> wrote:
>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> > index 7c6742d3e992..bc3448df9647 100644
> > --- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> > +++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> > @@ -20,6 +20,10 @@ Required properties:
> > - reg: i2c address of the sensor / spi cs line
> >
> > Optional properties:
> > +- vdd-supply: an optional regulator that needs to be on to provide VDD
> > + power to the sensor.
> > +- vddio-supply: an optional regulator that needs to be on to provide the
> > + VDD IO power to the sensor.
> > - st,drdy-int-pin: the pin on the package that will be used to signal
> > "data ready" (valid values: 1 or 2).
> > - st,pullups : enable/disable internal i2c controller pullup resistors.
>
> Hi Lorenzo,
>
> Please could you rebase this on top of
> https://lore.kernel.org/linux-iio/20201031184854.745828-13-jic23@kernel.org/
>
> Which does a yaml conversion of this file.
Hi Jonathan,
sure, no worries. I was quite sure the yaml conversion was merged but then I
discovered it was not :) I will post v2 soon.
Regards,
Lorenzo
>
> I'm working my way through backlog of those this week so will pick that up
> at some point very soon.
>
> I'll resend a v2 of some patches in those series, but only those where there
> are outstanding comments that aren't trivial.
>
> (Rob's acked most with a few requested tweaks).
>
> Thanks,
>
> Jonathan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-17 16:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-17 15:11 [PATCH 0/2] st_lsm6dsx: add vdd-vddio power regulator Lorenzo Bianconi
2020-11-17 15:11 ` [PATCH 1/2] iio: imu: st_lsm6dsx: add vdd-vddio voltage regulator Lorenzo Bianconi
2020-11-17 16:07 ` Jonathan Cameron
2020-11-17 15:11 ` [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: introduce vdd-vddio regulators bindings Lorenzo Bianconi
2020-11-17 16:06 ` Jonathan Cameron
2020-11-17 16:17 ` Lorenzo Bianconi
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).