[PATCH 4/9] iio: pressure: bmp280: support optional supply regulators

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The BMP058/BMP180/BMP280 is supplied with two power sources:
VDDA (analog power) and VDDD (digital power). As these may come
from regulators (as on the APQ8060 Dragonboard) we need the driver
to attempt to fetch and enable these regulators.

Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
 drivers/iio/pressure/bmp280.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c
index bde21c532fc7..343e97efad19 100644
--- a/drivers/iio/pressure/bmp280.c
+++ b/drivers/iio/pressure/bmp280.c
@@ -23,6 +23,7 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/gpio/consumer.h>
+#include <linux/regulator/consumer.h>
 
 /* BMP280 specific registers */
 #define BMP280_REG_TEMP_XLSB		0xFC
@@ -101,6 +102,8 @@ struct bmp280_data {
 	struct mutex lock;
 	struct regmap *regmap;
 	const struct bmp280_chip_info *chip_info;
+	struct regulator *vddd;
+	struct regulator *vdda;
 
 	/* log of base 2 of oversampling rate */
 	u8 oversampling_press;
@@ -871,6 +874,20 @@ static int bmp280_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
+	/* Optionally bring up regulators */
+	data->vddd = devm_regulator_get_optional(&client->dev, "vddd");
+	if (!IS_ERR(data->vddd)) {
+		ret = regulator_enable(data->vddd);
+		if (ret)
+			dev_err(&client->dev, "failed to enable VDDD\n");
+	}
+	data->vdda = devm_regulator_get_optional(&client->dev, "vdda");
+	if (!IS_ERR(data->vdda)) {
+		ret = regulator_enable(data->vdda);
+		if (ret)
+			dev_err(&client->dev, "failed to enable VDDA\n");
+	}
+
 	/* Bring chip out of reset if there is an assigned GPIO line */
 	gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
 	/* Deassert the signal */
-- 
2.4.11

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux