]> Pileus Git - ~andy/linux/commitdiff
iio: pressure-core: st: Provide support for the Vdd_IO power supply
authorLee Jones <lee.jones@linaro.org>
Mon, 16 Sep 2013 16:02:00 +0000 (17:02 +0100)
committerJonathan Cameron <jic23@kernel.org>
Mon, 23 Sep 2013 19:17:58 +0000 (20:17 +0100)
The power to some of the sensors are controlled by regulators. In most
cases these are 'always on', but if not they will fail to work until
the regulator is enabled using the relevant APIs. This patch allows for
the Vdd_IO power supply to be specified by either platform data or
Device Tree.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/pressure/st_pressure_core.c
include/linux/iio/common/st_sensors.h

index baeab109f41db6456a3a7f0f72ddf4616fe87b0b..58083f9d51c56691281891e4afbbe368d92697ab 100644 (file)
@@ -319,7 +319,7 @@ static void st_press_power_enable(struct iio_dev *indio_dev)
        struct st_sensor_data *pdata = iio_priv(indio_dev);
        int err;
 
-       /* Regulators not mandatory, but if requested we should enable it. */
+       /* Regulators not mandatory, but if requested we should enable them. */
        pdata->vdd = devm_regulator_get_optional(&indio_dev->dev, "vdd");
        if (!IS_ERR(pdata->vdd)) {
                err = regulator_enable(pdata->vdd);
@@ -327,6 +327,14 @@ static void st_press_power_enable(struct iio_dev *indio_dev)
                        dev_warn(&indio_dev->dev,
                                 "Failed to enable specified Vdd supply\n");
        }
+
+       pdata->vdd_io = devm_regulator_get_optional(&indio_dev->dev, "vddio");
+       if (!IS_ERR(pdata->vdd_io)) {
+               err = regulator_enable(pdata->vdd_io);
+               if (err != 0)
+                       dev_warn(&indio_dev->dev,
+                                "Failed to enable specified Vdd_IO supply\n");
+       }
 }
 
 static void st_press_power_disable(struct iio_dev *indio_dev)
@@ -335,6 +343,9 @@ static void st_press_power_disable(struct iio_dev *indio_dev)
 
        if (!IS_ERR(pdata->vdd))
                regulator_disable(pdata->vdd);
+
+       if (!IS_ERR(pdata->vdd_io))
+               regulator_disable(pdata->vdd_io);
 }
 
 int st_press_common_probe(struct iio_dev *indio_dev,
index 968b84e5f380aa11624ee0ddcb8fd70e77c6cfb0..3c005eb3a0a4bab608479bd3ba7cd4d3dc65cd5f 100644 (file)
@@ -203,6 +203,7 @@ struct st_sensors {
  * @sensor: Pointer to the current sensor struct in use.
  * @current_fullscale: Maximum range of measure by the sensor.
  * @vdd: Pointer to sensor's Vdd power supply
+ * @vdd_io: Pointer to sensor's Vdd-IO power supply
  * @enabled: Status of the sensor (false->off, true->on).
  * @multiread_bit: Use or not particular bit for [I2C/SPI] multiread.
  * @buffer_data: Data used by buffer part.
@@ -219,6 +220,7 @@ struct st_sensor_data {
        struct st_sensors *sensor;
        struct st_sensor_fullscale_avl *current_fullscale;
        struct regulator *vdd;
+       struct regulator *vdd_io;
 
        bool enabled;
        bool multiread_bit;