iio: imu: st_lsm6dsx: add wakeup_source in st_sensors_platform_data
authorLorenzo Bianconi <lorenzo@kernel.org>
Sun, 6 Oct 2019 13:22:04 +0000 (15:22 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 15 Oct 2019 20:11:05 +0000 (21:11 +0100)
Add the possibility to enable/disable wakeup source through
st_sensors_platform_data and not only through device tree

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
include/linux/platform_data/st_sensors_pdata.h

index c0df261..5be372d 100644 (file)
@@ -2099,7 +2099,9 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
 int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
                     struct regmap *regmap)
 {
+       struct st_sensors_platform_data *pdata = dev->platform_data;
        const struct st_lsm6dsx_shub_settings *hub_settings;
+       struct device_node *np = dev->of_node;
        struct st_lsm6dsx_hw *hw;
        const char *name = NULL;
        int i, err;
@@ -2162,8 +2164,8 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
                        return err;
        }
 
-       if (dev->of_node &&
-           of_property_read_bool(dev->of_node, "wakeup-source"))
+       if ((np && of_property_read_bool(np, "wakeup-source")) ||
+           (pdata && pdata->wakeup_source))
                device_init_wakeup(dev, true);
 
        return 0;
index 30929c2..e40b28c 100644 (file)
  * @open_drain: set the interrupt line to be open drain if possible.
  * @spi_3wire: enable spi-3wire mode.
  * @pullups: enable/disable i2c controller pullup resistors.
+ * @wakeup_source: enable/disable device as wakeup generator.
  */
 struct st_sensors_platform_data {
        u8 drdy_int_pin;
        bool open_drain;
        bool spi_3wire;
        bool pullups;
+       bool wakeup_source;
 };
 
 #endif /* ST_SENSORS_PDATA_H */