]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge tag 'iio-fixes-for-5.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Mar 2020 10:20:42 +0000 (11:20 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Mar 2020 10:20:42 +0000 (11:20 +0100)
Jonathan writes:

First set of IIO fixes in the 5.6 cycle.

* adxl372
  - Fix marking of buffered values as big endian.
* ak8974
  - Fix wrong handling of negative values when read from sysfs.
* at91-sama5d2
  - Fix differential mode by ensuring configuration set correctly.
* ping
  - Use the write sensor type for of_ping_match table.
* sps30
  - Kconfig build dependency fix.
* st-sensors
  - Fix a wrong identification of which part the SMO8840 ACPI ID indicates.
* stm32-dsfdm
  - Fix a sleep in atomic issue by not using a trigger when it makes no sense.
* stm32-timer
  - Make sure master mode is disabled when stopping.
* vcnl400
  - Update some sampling periods based on new docs.

* tag 'iio-fixes-for-5.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: ping: set pa_laser_ping_cfg in of_ping_match
  iio: chemical: sps30: fix missing triggered buffer dependency
  iio: st_sensors: remap SMO8840 to LIS2DH12
  iio: light: vcnl4000: update sampling periods for vcnl4040
  iio: light: vcnl4000: update sampling periods for vcnl4200
  iio: accel: adxl372: Set iio_chan BE
  iio: magnetometer: ak8974: Fix negative raw values in sysfs
  iio: trigger: stm32-timer: disable master mode when stopping
  iio: adc: stm32-dfsdm: fix sleep in atomic context
  iio: adc: at91-sama5d2_adc: fix differential channels in triggered mode

drivers/iio/accel/adxl372.c
drivers/iio/accel/st_accel_i2c.c
drivers/iio/adc/at91-sama5d2_adc.c
drivers/iio/adc/stm32-dfsdm-adc.c
drivers/iio/chemical/Kconfig
drivers/iio/light/vcnl4000.c
drivers/iio/magnetometer/ak8974.c
drivers/iio/proximity/ping.c
drivers/iio/trigger/stm32-timer-trigger.c

index 67b8817995c047b791c638da6e1131f9f967f222..60daf04ce1889f01225d68eead697a8d9610ea90 100644 (file)
@@ -237,6 +237,7 @@ static const struct adxl372_axis_lookup adxl372_axis_lookup_table[] = {
                .realbits = 12,                                         \
                .storagebits = 16,                                      \
                .shift = 4,                                             \
+               .endianness = IIO_BE,                                   \
        },                                                              \
 }
 
index 633955d764cca7c5225f9c29a45b0b7fafca618b..849cf74153c496d0cc57c2d8160a77d71d7ee79e 100644 (file)
@@ -110,7 +110,7 @@ MODULE_DEVICE_TABLE(of, st_accel_of_match);
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id st_accel_acpi_match[] = {
-       {"SMO8840", (kernel_ulong_t)LNG2DM_ACCEL_DEV_NAME},
+       {"SMO8840", (kernel_ulong_t)LIS2DH12_ACCEL_DEV_NAME},
        {"SMO8A90", (kernel_ulong_t)LNG2DM_ACCEL_DEV_NAME},
        { },
 };
index a5c7771227d518e84270f7cd2113ca99f51284e3..9d96f7d08b9567f4ff4663020c4d224cea568756 100644 (file)
@@ -723,6 +723,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
 
        for_each_set_bit(bit, indio->active_scan_mask, indio->num_channels) {
                struct iio_chan_spec const *chan = at91_adc_chan_get(indio, bit);
+               u32 cor;
 
                if (!chan)
                        continue;
@@ -731,6 +732,20 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
                    chan->type == IIO_PRESSURE)
                        continue;
 
+               if (state) {
+                       cor = at91_adc_readl(st, AT91_SAMA5D2_COR);
+
+                       if (chan->differential)
+                               cor |= (BIT(chan->channel) |
+                                       BIT(chan->channel2)) <<
+                                       AT91_SAMA5D2_COR_DIFF_OFFSET;
+                       else
+                               cor &= ~(BIT(chan->channel) <<
+                                      AT91_SAMA5D2_COR_DIFF_OFFSET);
+
+                       at91_adc_writel(st, AT91_SAMA5D2_COR, cor);
+               }
+
                if (state) {
                        at91_adc_writel(st, AT91_SAMA5D2_CHER,
                                        BIT(chan->channel));
index 2aad2cda6943e1bd1e17340b38c64ba20c1d195c..76a60d93fe23f148791adb6e78b663a8b7363156 100644 (file)
@@ -842,31 +842,6 @@ static inline void stm32_dfsdm_process_data(struct stm32_dfsdm_adc *adc,
        }
 }
 
-static irqreturn_t stm32_dfsdm_adc_trigger_handler(int irq, void *p)
-{
-       struct iio_poll_func *pf = p;
-       struct iio_dev *indio_dev = pf->indio_dev;
-       struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
-       int available = stm32_dfsdm_adc_dma_residue(adc);
-
-       while (available >= indio_dev->scan_bytes) {
-               s32 *buffer = (s32 *)&adc->rx_buf[adc->bufi];
-
-               stm32_dfsdm_process_data(adc, buffer);
-
-               iio_push_to_buffers_with_timestamp(indio_dev, buffer,
-                                                  pf->timestamp);
-               available -= indio_dev->scan_bytes;
-               adc->bufi += indio_dev->scan_bytes;
-               if (adc->bufi >= adc->buf_sz)
-                       adc->bufi = 0;
-       }
-
-       iio_trigger_notify_done(indio_dev->trig);
-
-       return IRQ_HANDLED;
-}
-
 static void stm32_dfsdm_dma_buffer_done(void *data)
 {
        struct iio_dev *indio_dev = data;
@@ -874,11 +849,6 @@ static void stm32_dfsdm_dma_buffer_done(void *data)
        int available = stm32_dfsdm_adc_dma_residue(adc);
        size_t old_pos;
 
-       if (indio_dev->currentmode & INDIO_BUFFER_TRIGGERED) {
-               iio_trigger_poll_chained(indio_dev->trig);
-               return;
-       }
-
        /*
         * FIXME: In Kernel interface does not support cyclic DMA buffer,and
         * offers only an interface to push data samples per samples.
@@ -906,7 +876,15 @@ static void stm32_dfsdm_dma_buffer_done(void *data)
                        adc->bufi = 0;
                        old_pos = 0;
                }
-               /* regular iio buffer without trigger */
+               /*
+                * In DMA mode the trigger services of IIO are not used
+                * (e.g. no call to iio_trigger_poll).
+                * Calling irq handler associated to the hardware trigger is not
+                * relevant as the conversions have already been done. Data
+                * transfers are performed directly in DMA callback instead.
+                * This implementation avoids to call trigger irq handler that
+                * may sleep, in an atomic context (DMA irq handler context).
+                */
                if (adc->dev_data->type == DFSDM_IIO)
                        iio_push_to_buffers(indio_dev, buffer);
        }
@@ -1536,8 +1514,7 @@ static int stm32_dfsdm_adc_init(struct iio_dev *indio_dev)
        }
 
        ret = iio_triggered_buffer_setup(indio_dev,
-                                        &iio_pollfunc_store_time,
-                                        &stm32_dfsdm_adc_trigger_handler,
+                                        &iio_pollfunc_store_time, NULL,
                                         &stm32_dfsdm_buffer_setup_ops);
        if (ret) {
                stm32_dfsdm_dma_release(indio_dev);
index 0b91de4df8f4609daf0ad14d80db9f3665d38d34..a7e65a59bf42996a1923c8db8dbbeba4252cab5b 100644 (file)
@@ -91,6 +91,8 @@ config SPS30
        tristate "SPS30 particulate matter sensor"
        depends on I2C
        select CRC8
+       select IIO_BUFFER
+       select IIO_TRIGGERED_BUFFER
        help
          Say Y here to build support for the Sensirion SPS30 particulate
          matter sensor.
index b0e241aaefb48863c28f06235bdab3b3ac221fa7..e5b00a6611acd28f9a6a34131e8d1f7da01be4a9 100644 (file)
@@ -167,16 +167,17 @@ static int vcnl4200_init(struct vcnl4000_data *data)
        data->vcnl4200_ps.reg = VCNL4200_PS_DATA;
        switch (id) {
        case VCNL4200_PROD_ID:
-               /* Integration time is 50ms, but the experiments */
-               /* show 54ms in total. */
-               data->vcnl4200_al.sampling_rate = ktime_set(0, 54000 * 1000);
-               data->vcnl4200_ps.sampling_rate = ktime_set(0, 4200 * 1000);
+               /* Default wait time is 50ms, add 20% tolerance. */
+               data->vcnl4200_al.sampling_rate = ktime_set(0, 60000 * 1000);
+               /* Default wait time is 4.8ms, add 20% tolerance. */
+               data->vcnl4200_ps.sampling_rate = ktime_set(0, 5760 * 1000);
                data->al_scale = 24000;
                break;
        case VCNL4040_PROD_ID:
-               /* Integration time is 80ms, add 10ms. */
-               data->vcnl4200_al.sampling_rate = ktime_set(0, 100000 * 1000);
-               data->vcnl4200_ps.sampling_rate = ktime_set(0, 100000 * 1000);
+               /* Default wait time is 80ms, add 20% tolerance. */
+               data->vcnl4200_al.sampling_rate = ktime_set(0, 96000 * 1000);
+               /* Default wait time is 5ms, add 20% tolerance. */
+               data->vcnl4200_ps.sampling_rate = ktime_set(0, 6000 * 1000);
                data->al_scale = 120000;
                break;
        }
index fc7e910f8e8bfd1c7bf63664d20a6e7133e847f5..d3299670211035236a20cc0ee83130a9dbb4c904 100644 (file)
@@ -564,7 +564,7 @@ static int ak8974_read_raw(struct iio_dev *indio_dev,
                 * We read all axes and discard all but one, for optimized
                 * reading, use the triggered buffer.
                 */
-               *val = le16_to_cpu(hw_values[chan->address]);
+               *val = (s16)le16_to_cpu(hw_values[chan->address]);
 
                ret = IIO_VAL_INT;
        }
index 34aff108dff54dfed75e0821515f7370d5d81f0d..12b893c5b0eed33781634d9a4d039d7c7f8afc1a 100644 (file)
@@ -269,7 +269,7 @@ static const struct iio_chan_spec ping_chan_spec[] = {
 
 static const struct of_device_id of_ping_match[] = {
        { .compatible = "parallax,ping", .data = &pa_ping_cfg},
-       { .compatible = "parallax,laserping", .data = &pa_ping_cfg},
+       { .compatible = "parallax,laserping", .data = &pa_laser_ping_cfg},
        {},
 };
 
index 2e0d32aa843665af68dcc0ffe1215444d02a7f06..2f82e8c32186fdd66fa5cfb1aa386f0f8813082d 100644 (file)
@@ -161,7 +161,8 @@ static int stm32_timer_start(struct stm32_timer_trigger *priv,
        return 0;
 }
 
-static void stm32_timer_stop(struct stm32_timer_trigger *priv)
+static void stm32_timer_stop(struct stm32_timer_trigger *priv,
+                            struct iio_trigger *trig)
 {
        u32 ccer, cr1;
 
@@ -179,6 +180,12 @@ static void stm32_timer_stop(struct stm32_timer_trigger *priv)
        regmap_write(priv->regmap, TIM_PSC, 0);
        regmap_write(priv->regmap, TIM_ARR, 0);
 
+       /* Force disable master mode */
+       if (stm32_timer_is_trgo2_name(trig->name))
+               regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2, 0);
+       else
+               regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS, 0);
+
        /* Make sure that registers are updated */
        regmap_update_bits(priv->regmap, TIM_EGR, TIM_EGR_UG, TIM_EGR_UG);
 }
@@ -197,7 +204,7 @@ static ssize_t stm32_tt_store_frequency(struct device *dev,
                return ret;
 
        if (freq == 0) {
-               stm32_timer_stop(priv);
+               stm32_timer_stop(priv, trig);
        } else {
                ret = stm32_timer_start(priv, trig, freq);
                if (ret)