diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-10 05:18:37 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-10 05:18:37 -0400 |
commit | 3f3d31622a2c18b644328965925110dd7638b376 (patch) | |
tree | 8581263c35a4b13ca4d88e295162da8e55ae0417 | |
parent | 80b15db5e1e9c3300de299b2d43d1aafb593e6ac (diff) | |
parent | a26e0fbe06e20077afdaa40d1a90092f16b0bc67 (diff) |
Merge tag 'iio-fixes-for-5.4a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes:
First set of IIO fixes for the 5.4 cycle.
* adis16400
- Make sure to free memory on a few failure paths.
* adxl372
- Fix wrong fifo depth
- Fix wrong indexing of data from the fifo.
- Perform a reset at startup to avoid a problem with inconsistent state.
* axp288
- This is a fix for a fix. The original fix made sure we kept the
configuration from some firmwares to preserve a bias current.
Unfortunately it appears the previous behaviour was working around
a buggy firmware by overwriting the wrong value it had. Hence
a regression was seen.
* bmc150
- Fix the centre temperature. This was due to an error in one of the
datasheets.
* hx711
- Fix an issue where a badly timed interrupt could lead to a control
line being high long enough to put the device into a low power state.
* meson_sar_adc
- Fix a case where the irq was enabled before everything it uses was
allocated.
* st_lsm6dsx
- Ensure we don't set the sensor sensitivity to 0 as it will force
all readings to 0.
- Fix a wait time for the slave i2c controller when the accelerometer
is not enabled.
* stm32-adc
- Precursor for fix. Move a set of register definitions to a header.
- Fix a race when several ADCs are in use with some using interrupts
to control the dataflow and some using DMA.
* vcnl4000
- Fix a garbage of_match_table in which a string was passed instead
of the intended enum.
* tag 'iio-fixes-for-5.4a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
iio: Fix an undefied reference error in noa1305_probe
iio: light: opt3001: fix mutex unlock race
iio: adc: ad799x: fix probe error handling
iio: light: add missing vcnl4040 of_compatible
iio: light: fix vcnl4000 devicetree hooks
iio: imu: st_lsm6dsx: fix waitime for st_lsm6dsx i2c controller
iio: adc: axp288: Override TS pin bias current for some models
iio: imu: adis16400: fix memory leak
iio: imu: adis16400: release allocated memory on failure
iio: adc: stm32-adc: fix a race when using several adcs with dma and irq
iio: adc: stm32-adc: move registers definitions
iio: accel: adxl372: Perform a reset at start up
iio: accel: adxl372: Fix push to buffers lost samples
iio: accel: adxl372: Fix/remove limitation for FIFO samples
iio: adc: hx711: fix bug in sampling of data
iio: fix center temperature of bmc150-accel-core
iio: imu: st_lsm6dsx: forbid 0 sensor sensitivity
iio: adc: meson_saradc: Fix memory allocation order
-rw-r--r-- | drivers/iio/accel/adxl372.c | 22 | ||||
-rw-r--r-- | drivers/iio/accel/bmc150-accel-core.c | 2 | ||||
-rw-r--r-- | drivers/iio/adc/ad799x.c | 4 | ||||
-rw-r--r-- | drivers/iio/adc/axp288_adc.c | 32 | ||||
-rw-r--r-- | drivers/iio/adc/hx711.c | 10 | ||||
-rw-r--r-- | drivers/iio/adc/meson_saradc.c | 10 | ||||
-rw-r--r-- | drivers/iio/adc/stm32-adc-core.c | 70 | ||||
-rw-r--r-- | drivers/iio/adc/stm32-adc-core.h | 137 | ||||
-rw-r--r-- | drivers/iio/adc/stm32-adc.c | 109 | ||||
-rw-r--r-- | drivers/iio/imu/adis_buffer.c | 10 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 28 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 15 | ||||
-rw-r--r-- | drivers/iio/light/Kconfig | 1 | ||||
-rw-r--r-- | drivers/iio/light/opt3001.c | 6 | ||||
-rw-r--r-- | drivers/iio/light/vcnl4000.c | 14 |
16 files changed, 290 insertions, 182 deletions
diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c index 055227cb3d43..67b8817995c0 100644 --- a/drivers/iio/accel/adxl372.c +++ b/drivers/iio/accel/adxl372.c | |||
@@ -474,12 +474,17 @@ static int adxl372_configure_fifo(struct adxl372_state *st) | |||
474 | if (ret < 0) | 474 | if (ret < 0) |
475 | return ret; | 475 | return ret; |
476 | 476 | ||
477 | fifo_samples = st->watermark & 0xFF; | 477 | /* |
478 | * watermark stores the number of sets; we need to write the FIFO | ||
479 | * registers with the number of samples | ||
480 | */ | ||
481 | fifo_samples = (st->watermark * st->fifo_set_size); | ||
478 | fifo_ctl = ADXL372_FIFO_CTL_FORMAT_MODE(st->fifo_format) | | 482 | fifo_ctl = ADXL372_FIFO_CTL_FORMAT_MODE(st->fifo_format) | |
479 | ADXL372_FIFO_CTL_MODE_MODE(st->fifo_mode) | | 483 | ADXL372_FIFO_CTL_MODE_MODE(st->fifo_mode) | |
480 | ADXL372_FIFO_CTL_SAMPLES_MODE(st->watermark); | 484 | ADXL372_FIFO_CTL_SAMPLES_MODE(fifo_samples); |
481 | 485 | ||
482 | ret = regmap_write(st->regmap, ADXL372_FIFO_SAMPLES, fifo_samples); | 486 | ret = regmap_write(st->regmap, |
487 | ADXL372_FIFO_SAMPLES, fifo_samples & 0xFF); | ||
483 | if (ret < 0) | 488 | if (ret < 0) |
484 | return ret; | 489 | return ret; |
485 | 490 | ||
@@ -548,8 +553,7 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p) | |||
548 | goto err; | 553 | goto err; |
549 | 554 | ||
550 | /* Each sample is 2 bytes */ | 555 | /* Each sample is 2 bytes */ |
551 | for (i = 0; i < fifo_entries * sizeof(u16); | 556 | for (i = 0; i < fifo_entries; i += st->fifo_set_size) |
552 | i += st->fifo_set_size * sizeof(u16)) | ||
553 | iio_push_to_buffers(indio_dev, &st->fifo_buf[i]); | 557 | iio_push_to_buffers(indio_dev, &st->fifo_buf[i]); |
554 | } | 558 | } |
555 | err: | 559 | err: |
@@ -571,6 +575,14 @@ static int adxl372_setup(struct adxl372_state *st) | |||
571 | return -ENODEV; | 575 | return -ENODEV; |
572 | } | 576 | } |
573 | 577 | ||
578 | /* | ||
579 | * Perform a software reset to make sure the device is in a consistent | ||
580 | * state after start up. | ||
581 | */ | ||
582 | ret = regmap_write(st->regmap, ADXL372_RESET, ADXL372_RESET_CODE); | ||
583 | if (ret < 0) | ||
584 | return ret; | ||
585 | |||
574 | ret = adxl372_set_op_mode(st, ADXL372_STANDBY); | 586 | ret = adxl372_set_op_mode(st, ADXL372_STANDBY); |
575 | if (ret < 0) | 587 | if (ret < 0) |
576 | return ret; | 588 | return ret; |
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index cf6c0e3a83d3..121b4e89f038 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c | |||
@@ -117,7 +117,7 @@ | |||
117 | #define BMC150_ACCEL_SLEEP_1_SEC 0x0F | 117 | #define BMC150_ACCEL_SLEEP_1_SEC 0x0F |
118 | 118 | ||
119 | #define BMC150_ACCEL_REG_TEMP 0x08 | 119 | #define BMC150_ACCEL_REG_TEMP 0x08 |
120 | #define BMC150_ACCEL_TEMP_CENTER_VAL 24 | 120 | #define BMC150_ACCEL_TEMP_CENTER_VAL 23 |
121 | 121 | ||
122 | #define BMC150_ACCEL_AXIS_TO_REG(axis) (BMC150_ACCEL_REG_XOUT_L + (axis * 2)) | 122 | #define BMC150_ACCEL_AXIS_TO_REG(axis) (BMC150_ACCEL_REG_XOUT_L + (axis * 2)) |
123 | #define BMC150_AUTO_SUSPEND_DELAY_MS 2000 | 123 | #define BMC150_AUTO_SUSPEND_DELAY_MS 2000 |
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 5a3ca5904ded..f658012baad8 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c | |||
@@ -810,10 +810,10 @@ static int ad799x_probe(struct i2c_client *client, | |||
810 | 810 | ||
811 | ret = ad799x_write_config(st, st->chip_config->default_config); | 811 | ret = ad799x_write_config(st, st->chip_config->default_config); |
812 | if (ret < 0) | 812 | if (ret < 0) |
813 | goto error_disable_reg; | 813 | goto error_disable_vref; |
814 | ret = ad799x_read_config(st); | 814 | ret = ad799x_read_config(st); |
815 | if (ret < 0) | 815 | if (ret < 0) |
816 | goto error_disable_reg; | 816 | goto error_disable_vref; |
817 | st->config = ret; | 817 | st->config = ret; |
818 | 818 | ||
819 | ret = iio_triggered_buffer_setup(indio_dev, NULL, | 819 | ret = iio_triggered_buffer_setup(indio_dev, NULL, |
diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c index adc9cf7a075d..8ea2aed6d6f5 100644 --- a/drivers/iio/adc/axp288_adc.c +++ b/drivers/iio/adc/axp288_adc.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/dmi.h> | ||
10 | #include <linux/module.h> | 11 | #include <linux/module.h> |
11 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
12 | #include <linux/device.h> | 13 | #include <linux/device.h> |
@@ -25,6 +26,11 @@ | |||
25 | #define AXP288_ADC_EN_MASK 0xF0 | 26 | #define AXP288_ADC_EN_MASK 0xF0 |
26 | #define AXP288_ADC_TS_ENABLE 0x01 | 27 | #define AXP288_ADC_TS_ENABLE 0x01 |
27 | 28 | ||
29 | #define AXP288_ADC_TS_BIAS_MASK GENMASK(5, 4) | ||
30 | #define AXP288_ADC_TS_BIAS_20UA (0 << 4) | ||
31 | #define AXP288_ADC_TS_BIAS_40UA (1 << 4) | ||
32 | #define AXP288_ADC_TS_BIAS_60UA (2 << 4) | ||
33 | #define AXP288_ADC_TS_BIAS_80UA (3 << 4) | ||
28 | #define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0) | 34 | #define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0) |
29 | #define AXP288_ADC_TS_CURRENT_OFF (0 << 0) | 35 | #define AXP288_ADC_TS_CURRENT_OFF (0 << 0) |
30 | #define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING (1 << 0) | 36 | #define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING (1 << 0) |
@@ -177,10 +183,36 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev, | |||
177 | return ret; | 183 | return ret; |
178 | } | 184 | } |
179 | 185 | ||
186 | /* | ||
187 | * We rely on the machine's firmware to correctly setup the TS pin bias current | ||
188 | * at boot. This lists systems with broken fw where we need to set it ourselves. | ||
189 | */ | ||
190 | static const struct dmi_system_id axp288_adc_ts_bias_override[] = { | ||
191 | { | ||
192 | /* Lenovo Ideapad 100S (11 inch) */ | ||
193 | .matches = { | ||
194 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | ||
195 | DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad 100S-11IBY"), | ||
196 | }, | ||
197 | .driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA, | ||
198 | }, | ||
199 | {} | ||
200 | }; | ||
201 | |||
180 | static int axp288_adc_initialize(struct axp288_adc_info *info) | 202 | static int axp288_adc_initialize(struct axp288_adc_info *info) |
181 | { | 203 | { |
204 | const struct dmi_system_id *bias_override; | ||
182 | int ret, adc_enable_val; | 205 | int ret, adc_enable_val; |
183 | 206 | ||
207 | bias_override = dmi_first_match(axp288_adc_ts_bias_override); | ||
208 | if (bias_override) { | ||
209 | ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, | ||
210 | AXP288_ADC_TS_BIAS_MASK, | ||
211 | (uintptr_t)bias_override->driver_data); | ||
212 | if (ret) | ||
213 | return ret; | ||
214 | } | ||
215 | |||
184 | /* | 216 | /* |
185 | * Determine if the TS pin is enabled and set the TS current-source | 217 | * Determine if the TS pin is enabled and set the TS current-source |
186 | * accordingly. | 218 | * accordingly. |
diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 88c7fe15003b..62e6c8badd22 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c | |||
@@ -100,14 +100,14 @@ struct hx711_data { | |||
100 | 100 | ||
101 | static int hx711_cycle(struct hx711_data *hx711_data) | 101 | static int hx711_cycle(struct hx711_data *hx711_data) |
102 | { | 102 | { |
103 | int val; | 103 | unsigned long flags; |
104 | 104 | ||
105 | /* | 105 | /* |
106 | * if preempted for more then 60us while PD_SCK is high: | 106 | * if preempted for more then 60us while PD_SCK is high: |
107 | * hx711 is going in reset | 107 | * hx711 is going in reset |
108 | * ==> measuring is false | 108 | * ==> measuring is false |
109 | */ | 109 | */ |
110 | preempt_disable(); | 110 | local_irq_save(flags); |
111 | gpiod_set_value(hx711_data->gpiod_pd_sck, 1); | 111 | gpiod_set_value(hx711_data->gpiod_pd_sck, 1); |
112 | 112 | ||
113 | /* | 113 | /* |
@@ -117,7 +117,6 @@ static int hx711_cycle(struct hx711_data *hx711_data) | |||
117 | */ | 117 | */ |
118 | ndelay(hx711_data->data_ready_delay_ns); | 118 | ndelay(hx711_data->data_ready_delay_ns); |
119 | 119 | ||
120 | val = gpiod_get_value(hx711_data->gpiod_dout); | ||
121 | /* | 120 | /* |
122 | * here we are not waiting for 0.2 us as suggested by the datasheet, | 121 | * here we are not waiting for 0.2 us as suggested by the datasheet, |
123 | * because the oscilloscope showed in a test scenario | 122 | * because the oscilloscope showed in a test scenario |
@@ -125,7 +124,7 @@ static int hx711_cycle(struct hx711_data *hx711_data) | |||
125 | * and 0.56 us for PD_SCK low on TI Sitara with 800 MHz | 124 | * and 0.56 us for PD_SCK low on TI Sitara with 800 MHz |
126 | */ | 125 | */ |
127 | gpiod_set_value(hx711_data->gpiod_pd_sck, 0); | 126 | gpiod_set_value(hx711_data->gpiod_pd_sck, 0); |
128 | preempt_enable(); | 127 | local_irq_restore(flags); |
129 | 128 | ||
130 | /* | 129 | /* |
131 | * make it a square wave for addressing cases with capacitance on | 130 | * make it a square wave for addressing cases with capacitance on |
@@ -133,7 +132,8 @@ static int hx711_cycle(struct hx711_data *hx711_data) | |||
133 | */ | 132 | */ |
134 | ndelay(hx711_data->data_ready_delay_ns); | 133 | ndelay(hx711_data->data_ready_delay_ns); |
135 | 134 | ||
136 | return val; | 135 | /* sample as late as possible */ |
136 | return gpiod_get_value(hx711_data->gpiod_dout); | ||
137 | } | 137 | } |
138 | 138 | ||
139 | static int hx711_read(struct hx711_data *hx711_data) | 139 | static int hx711_read(struct hx711_data *hx711_data) |
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 7b28d045d271..7b27306330a3 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c | |||
@@ -1219,6 +1219,11 @@ static int meson_sar_adc_probe(struct platform_device *pdev) | |||
1219 | if (IS_ERR(base)) | 1219 | if (IS_ERR(base)) |
1220 | return PTR_ERR(base); | 1220 | return PTR_ERR(base); |
1221 | 1221 | ||
1222 | priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, | ||
1223 | priv->param->regmap_config); | ||
1224 | if (IS_ERR(priv->regmap)) | ||
1225 | return PTR_ERR(priv->regmap); | ||
1226 | |||
1222 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | 1227 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); |
1223 | if (!irq) | 1228 | if (!irq) |
1224 | return -EINVAL; | 1229 | return -EINVAL; |
@@ -1228,11 +1233,6 @@ static int meson_sar_adc_probe(struct platform_device *pdev) | |||
1228 | if (ret) | 1233 | if (ret) |
1229 | return ret; | 1234 | return ret; |
1230 | 1235 | ||
1231 | priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, | ||
1232 | priv->param->regmap_config); | ||
1233 | if (IS_ERR(priv->regmap)) | ||
1234 | return PTR_ERR(priv->regmap); | ||
1235 | |||
1236 | priv->clkin = devm_clk_get(&pdev->dev, "clkin"); | 1236 | priv->clkin = devm_clk_get(&pdev->dev, "clkin"); |
1237 | if (IS_ERR(priv->clkin)) { | 1237 | if (IS_ERR(priv->clkin)) { |
1238 | dev_err(&pdev->dev, "failed to get clkin\n"); | 1238 | dev_err(&pdev->dev, "failed to get clkin\n"); |
diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c index 9b85fefc0a96..93a096a91f8c 100644 --- a/drivers/iio/adc/stm32-adc-core.c +++ b/drivers/iio/adc/stm32-adc-core.c | |||
@@ -24,33 +24,6 @@ | |||
24 | 24 | ||
25 | #include "stm32-adc-core.h" | 25 | #include "stm32-adc-core.h" |
26 | 26 | ||
27 | /* STM32F4 - common registers for all ADC instances: 1, 2 & 3 */ | ||
28 | #define STM32F4_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) | ||
29 | #define STM32F4_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x04) | ||
30 | |||
31 | /* STM32F4_ADC_CSR - bit fields */ | ||
32 | #define STM32F4_EOC3 BIT(17) | ||
33 | #define STM32F4_EOC2 BIT(9) | ||
34 | #define STM32F4_EOC1 BIT(1) | ||
35 | |||
36 | /* STM32F4_ADC_CCR - bit fields */ | ||
37 | #define STM32F4_ADC_ADCPRE_SHIFT 16 | ||
38 | #define STM32F4_ADC_ADCPRE_MASK GENMASK(17, 16) | ||
39 | |||
40 | /* STM32H7 - common registers for all ADC instances */ | ||
41 | #define STM32H7_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) | ||
42 | #define STM32H7_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x08) | ||
43 | |||
44 | /* STM32H7_ADC_CSR - bit fields */ | ||
45 | #define STM32H7_EOC_SLV BIT(18) | ||
46 | #define STM32H7_EOC_MST BIT(2) | ||
47 | |||
48 | /* STM32H7_ADC_CCR - bit fields */ | ||
49 | #define STM32H7_PRESC_SHIFT 18 | ||
50 | #define STM32H7_PRESC_MASK GENMASK(21, 18) | ||
51 | #define STM32H7_CKMODE_SHIFT 16 | ||
52 | #define STM32H7_CKMODE_MASK GENMASK(17, 16) | ||
53 | |||
54 | #define STM32_ADC_CORE_SLEEP_DELAY_MS 2000 | 27 | #define STM32_ADC_CORE_SLEEP_DELAY_MS 2000 |
55 | 28 | ||
56 | /* SYSCFG registers */ | 29 | /* SYSCFG registers */ |
@@ -71,6 +44,8 @@ | |||
71 | * @eoc1: adc1 end of conversion flag in @csr | 44 | * @eoc1: adc1 end of conversion flag in @csr |
72 | * @eoc2: adc2 end of conversion flag in @csr | 45 | * @eoc2: adc2 end of conversion flag in @csr |
73 | * @eoc3: adc3 end of conversion flag in @csr | 46 | * @eoc3: adc3 end of conversion flag in @csr |
47 | * @ier: interrupt enable register offset for each adc | ||
48 | * @eocie_msk: end of conversion interrupt enable mask in @ier | ||
74 | */ | 49 | */ |
75 | struct stm32_adc_common_regs { | 50 | struct stm32_adc_common_regs { |
76 | u32 csr; | 51 | u32 csr; |
@@ -78,6 +53,8 @@ struct stm32_adc_common_regs { | |||
78 | u32 eoc1_msk; | 53 | u32 eoc1_msk; |
79 | u32 eoc2_msk; | 54 | u32 eoc2_msk; |
80 | u32 eoc3_msk; | 55 | u32 eoc3_msk; |
56 | u32 ier; | ||
57 | u32 eocie_msk; | ||
81 | }; | 58 | }; |
82 | 59 | ||
83 | struct stm32_adc_priv; | 60 | struct stm32_adc_priv; |
@@ -303,6 +280,8 @@ static const struct stm32_adc_common_regs stm32f4_adc_common_regs = { | |||
303 | .eoc1_msk = STM32F4_EOC1, | 280 | .eoc1_msk = STM32F4_EOC1, |
304 | .eoc2_msk = STM32F4_EOC2, | 281 | .eoc2_msk = STM32F4_EOC2, |
305 | .eoc3_msk = STM32F4_EOC3, | 282 | .eoc3_msk = STM32F4_EOC3, |
283 | .ier = STM32F4_ADC_CR1, | ||
284 | .eocie_msk = STM32F4_EOCIE, | ||
306 | }; | 285 | }; |
307 | 286 | ||
308 | /* STM32H7 common registers definitions */ | 287 | /* STM32H7 common registers definitions */ |
@@ -311,8 +290,24 @@ static const struct stm32_adc_common_regs stm32h7_adc_common_regs = { | |||
311 | .ccr = STM32H7_ADC_CCR, | 290 | .ccr = STM32H7_ADC_CCR, |
312 | .eoc1_msk = STM32H7_EOC_MST, | 291 | .eoc1_msk = STM32H7_EOC_MST, |
313 | .eoc2_msk = STM32H7_EOC_SLV, | 292 | .eoc2_msk = STM32H7_EOC_SLV, |
293 | .ier = STM32H7_ADC_IER, | ||
294 | .eocie_msk = STM32H7_EOCIE, | ||
295 | }; | ||
296 | |||
297 | static const unsigned int stm32_adc_offset[STM32_ADC_MAX_ADCS] = { | ||
298 | 0, STM32_ADC_OFFSET, STM32_ADC_OFFSET * 2, | ||
314 | }; | 299 | }; |
315 | 300 | ||
301 | static unsigned int stm32_adc_eoc_enabled(struct stm32_adc_priv *priv, | ||
302 | unsigned int adc) | ||
303 | { | ||
304 | u32 ier, offset = stm32_adc_offset[adc]; | ||
305 | |||
306 | ier = readl_relaxed(priv->common.base + offset + priv->cfg->regs->ier); | ||
307 | |||
308 | return ier & priv->cfg->regs->eocie_msk; | ||
309 | } | ||
310 | |||
316 | /* ADC common interrupt for all instances */ | 311 | /* ADC common interrupt for all instances */ |
317 | static void stm32_adc_irq_handler(struct irq_desc *desc) | 312 | static void stm32_adc_irq_handler(struct irq_desc *desc) |
318 | { | 313 | { |
@@ -323,13 +318,28 @@ static void stm32_adc_irq_handler(struct irq_desc *desc) | |||
323 | chained_irq_enter(chip, desc); | 318 | chained_irq_enter(chip, desc); |
324 | status = readl_relaxed(priv->common.base + priv->cfg->regs->csr); | 319 | status = readl_relaxed(priv->common.base + priv->cfg->regs->csr); |
325 | 320 | ||
326 | if (status & priv->cfg->regs->eoc1_msk) | 321 | /* |
322 | * End of conversion may be handled by using IRQ or DMA. There may be a | ||
323 | * race here when two conversions complete at the same time on several | ||
324 | * ADCs. EOC may be read 'set' for several ADCs, with: | ||
325 | * - an ADC configured to use DMA (EOC triggers the DMA request, and | ||
326 | * is then automatically cleared by DR read in hardware) | ||
327 | * - an ADC configured to use IRQs (EOCIE bit is set. The handler must | ||
328 | * be called in this case) | ||
329 | * So both EOC status bit in CSR and EOCIE control bit must be checked | ||
330 | * before invoking the interrupt handler (e.g. call ISR only for | ||
331 | * IRQ-enabled ADCs). | ||
332 | */ | ||
333 | if (status & priv->cfg->regs->eoc1_msk && | ||
334 | stm32_adc_eoc_enabled(priv, 0)) | ||
327 | generic_handle_irq(irq_find_mapping(priv->domain, 0)); | 335 | generic_handle_irq(irq_find_mapping(priv->domain, 0)); |
328 | 336 | ||
329 | if (status & priv->cfg->regs->eoc2_msk) | 337 | if (status & priv->cfg->regs->eoc2_msk && |
338 | stm32_adc_eoc_enabled(priv, 1)) | ||
330 | generic_handle_irq(irq_find_mapping(priv->domain, 1)); | 339 | generic_handle_irq(irq_find_mapping(priv->domain, 1)); |
331 | 340 | ||
332 | if (status & priv->cfg->regs->eoc3_msk) | 341 | if (status & priv->cfg->regs->eoc3_msk && |
342 | stm32_adc_eoc_enabled(priv, 2)) | ||
333 | generic_handle_irq(irq_find_mapping(priv->domain, 2)); | 343 | generic_handle_irq(irq_find_mapping(priv->domain, 2)); |
334 | 344 | ||
335 | chained_irq_exit(chip, desc); | 345 | chained_irq_exit(chip, desc); |
diff --git a/drivers/iio/adc/stm32-adc-core.h b/drivers/iio/adc/stm32-adc-core.h index 8af507b3f32d..2579d514c2a3 100644 --- a/drivers/iio/adc/stm32-adc-core.h +++ b/drivers/iio/adc/stm32-adc-core.h | |||
@@ -25,8 +25,145 @@ | |||
25 | * -------------------------------------------------------- | 25 | * -------------------------------------------------------- |
26 | */ | 26 | */ |
27 | #define STM32_ADC_MAX_ADCS 3 | 27 | #define STM32_ADC_MAX_ADCS 3 |
28 | #define STM32_ADC_OFFSET 0x100 | ||
28 | #define STM32_ADCX_COMN_OFFSET 0x300 | 29 | #define STM32_ADCX_COMN_OFFSET 0x300 |
29 | 30 | ||
31 | /* STM32F4 - Registers for each ADC instance */ | ||
32 | #define STM32F4_ADC_SR 0x00 | ||
33 | #define STM32F4_ADC_CR1 0x04 | ||
34 | #define STM32F4_ADC_CR2 0x08 | ||
35 | #define STM32F4_ADC_SMPR1 0x0C | ||
36 | #define STM32F4_ADC_SMPR2 0x10 | ||
37 | #define STM32F4_ADC_HTR 0x24 | ||
38 | #define STM32F4_ADC_LTR 0x28 | ||
39 | #define STM32F4_ADC_SQR1 0x2C | ||
40 | #define STM32F4_ADC_SQR2 0x30 | ||
41 | #define STM32F4_ADC_SQR3 0x34 | ||
42 | #define STM32F4_ADC_JSQR 0x38 | ||
43 | #define STM32F4_ADC_JDR1 0x3C | ||
44 | #define STM32F4_ADC_JDR2 0x40 | ||
45 | #define STM32F4_ADC_JDR3 0x44 | ||
46 | #define STM32F4_ADC_JDR4 0x48 | ||
47 | #define STM32F4_ADC_DR 0x4C | ||
48 | |||
49 | /* STM32F4 - common registers for all ADC instances: 1, 2 & 3 */ | ||
50 | #define STM32F4_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) | ||
51 | #define STM32F4_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x04) | ||
52 | |||
53 | /* STM32F4_ADC_SR - bit fields */ | ||
54 | #define STM32F4_STRT BIT(4) | ||
55 | #define STM32F4_EOC BIT(1) | ||
56 | |||
57 | /* STM32F4_ADC_CR1 - bit fields */ | ||
58 | #define STM32F4_RES_SHIFT 24 | ||
59 | #define STM32F4_RES_MASK GENMASK(25, 24) | ||
60 | #define STM32F4_SCAN BIT(8) | ||
61 | #define STM32F4_EOCIE BIT(5) | ||
62 | |||
63 | /* STM32F4_ADC_CR2 - bit fields */ | ||
64 | #define STM32F4_SWSTART BIT(30) | ||
65 | #define STM32F4_EXTEN_SHIFT 28 | ||
66 | #define STM32F4_EXTEN_MASK GENMASK(29, 28) | ||
67 | #define STM32F4_EXTSEL_SHIFT 24 | ||
68 | #define STM32F4_EXTSEL_MASK GENMASK(27, 24) | ||
69 | #define STM32F4_EOCS BIT(10) | ||
70 | #define STM32F4_DDS BIT(9) | ||
71 | #define STM32F4_DMA BIT(8) | ||
72 | #define STM32F4_ADON BIT(0) | ||
73 | |||
74 | /* STM32F4_ADC_CSR - bit fields */ | ||
75 | #define STM32F4_EOC3 BIT(17) | ||
76 | #define STM32F4_EOC2 BIT(9) | ||
77 | #define STM32F4_EOC1 BIT(1) | ||
78 | |||
79 | /* STM32F4_ADC_CCR - bit fields */ | ||
80 | #define STM32F4_ADC_ADCPRE_SHIFT 16 | ||
81 | #define STM32F4_ADC_ADCPRE_MASK GENMASK(17, 16) | ||
82 | |||
83 | /* STM32H7 - Registers for each ADC instance */ | ||
84 | #define STM32H7_ADC_ISR 0x00 | ||
85 | #define STM32H7_ADC_IER 0x04 | ||
86 | #define STM32H7_ADC_CR 0x08 | ||
87 | #define STM32H7_ADC_CFGR 0x0C | ||
88 | #define STM32H7_ADC_SMPR1 0x14 | ||
89 | #define STM32H7_ADC_SMPR2 0x18 | ||
90 | #define STM32H7_ADC_PCSEL 0x1C | ||
91 | #define STM32H7_ADC_SQR1 0x30 | ||
92 | #define STM32H7_ADC_SQR2 0x34 | ||
93 | #define STM32H7_ADC_SQR3 0x38 | ||
94 | #define STM32H7_ADC_SQR4 0x3C | ||
95 | #define STM32H7_ADC_DR 0x40 | ||
96 | #define STM32H7_ADC_DIFSEL 0xC0 | ||
97 | #define STM32H7_ADC_CALFACT 0xC4 | ||
98 | #define STM32H7_ADC_CALFACT2 0xC8 | ||
99 | |||
100 | /* STM32H7 - common registers for all ADC instances */ | ||
101 | #define STM32H7_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) | ||
102 | #define STM32H7_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x08) | ||
103 | |||
104 | /* STM32H7_ADC_ISR - bit fields */ | ||
105 | #define STM32MP1_VREGREADY BIT(12) | ||
106 | #define STM32H7_EOC BIT(2) | ||
107 | #define STM32H7_ADRDY BIT(0) | ||
108 | |||
109 | /* STM32H7_ADC_IER - bit fields */ | ||
110 | #define STM32H7_EOCIE STM32H7_EOC | ||
111 | |||
112 | /* STM32H7_ADC_CR - bit fields */ | ||
113 | #define STM32H7_ADCAL BIT(31) | ||
114 | #define STM32H7_ADCALDIF BIT(30) | ||
115 | #define STM32H7_DEEPPWD BIT(29) | ||
116 | #define STM32H7_ADVREGEN BIT(28) | ||
117 | #define STM32H7_LINCALRDYW6 BIT(27) | ||
118 | #define STM32H7_LINCALRDYW5 BIT(26) | ||
119 | #define STM32H7_LINCALRDYW4 BIT(25) | ||
120 | #define STM32H7_LINCALRDYW3 BIT(24) | ||
121 | #define STM32H7_LINCALRDYW2 BIT(23) | ||
122 | #define STM32H7_LINCALRDYW1 BIT(22) | ||
123 | #define STM32H7_ADCALLIN BIT(16) | ||
124 | #define STM32H7_BOOST BIT(8) | ||
125 | #define STM32H7_ADSTP BIT(4) | ||
126 | #define STM32H7_ADSTART BIT(2) | ||
127 | #define STM32H7_ADDIS BIT(1) | ||
128 | #define STM32H7_ADEN BIT(0) | ||
129 | |||
130 | /* STM32H7_ADC_CFGR bit fields */ | ||
131 | #define STM32H7_EXTEN_SHIFT 10 | ||
132 | #define STM32H7_EXTEN_MASK GENMASK(11, 10) | ||
133 | #define STM32H7_EXTSEL_SHIFT 5 | ||
134 | #define STM32H7_EXTSEL_MASK GENMASK(9, 5) | ||
135 | #define STM32H7_RES_SHIFT 2 | ||
136 | #define STM32H7_RES_MASK GENMASK(4, 2) | ||
137 | #define STM32H7_DMNGT_SHIFT 0 | ||
138 | #define STM32H7_DMNGT_MASK GENMASK(1, 0) | ||
139 | |||
140 | enum stm32h7_adc_dmngt { | ||
141 | STM32H7_DMNGT_DR_ONLY, /* Regular data in DR only */ | ||
142 | STM32H7_DMNGT_DMA_ONESHOT, /* DMA one shot mode */ | ||
143 | STM32H7_DMNGT_DFSDM, /* DFSDM mode */ | ||
144 | STM32H7_DMNGT_DMA_CIRC, /* DMA circular mode */ | ||
145 | }; | ||
146 | |||
147 | /* STM32H7_ADC_CALFACT - bit fields */ | ||
148 | #define STM32H7_CALFACT_D_SHIFT 16 | ||
149 | #define STM32H7_CALFACT_D_MASK GENMASK(26, 16) | ||
150 | #define STM32H7_CALFACT_S_SHIFT 0 | ||
151 | #define STM32H7_CALFACT_S_MASK GENMASK(10, 0) | ||
152 | |||
153 | /* STM32H7_ADC_CALFACT2 - bit fields */ | ||
154 | #define STM32H7_LINCALFACT_SHIFT 0 | ||
155 | #define STM32H7_LINCALFACT_MASK GENMASK(29, 0) | ||
156 | |||
157 | /* STM32H7_ADC_CSR - bit fields */ | ||
158 | #define STM32H7_EOC_SLV BIT(18) | ||
159 | #define STM32H7_EOC_MST BIT(2) | ||
160 | |||
161 | /* STM32H7_ADC_CCR - bit fields */ | ||
162 | #define STM32H7_PRESC_SHIFT 18 | ||
163 | #define STM32H7_PRESC_MASK GENMASK(21, 18) | ||
164 | #define STM32H7_CKMODE_SHIFT 16 | ||
165 | #define STM32H7_CKMODE_MASK GENMASK(17, 16) | ||
166 | |||
30 | /** | 167 | /** |
31 | * struct stm32_adc_common - stm32 ADC driver common data (for all instances) | 168 | * struct stm32_adc_common - stm32 ADC driver common data (for all instances) |
32 | * @base: control registers base cpu addr | 169 | * @base: control registers base cpu addr |
diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 6a7dd08b1e0b..663f8a5012d6 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c | |||
@@ -28,115 +28,6 @@ | |||
28 | 28 | ||
29 | #include "stm32-adc-core.h" | 29 | #include "stm32-adc-core.h" |
30 | 30 | ||
31 | /* STM32F4 - Registers for each ADC instance */ | ||
32 | #define STM32F4_ADC_SR 0x00 | ||
33 | #define STM32F4_ADC_CR1 0x04 | ||
34 | #define STM32F4_ADC_CR2 0x08 | ||
35 | #define STM32F4_ADC_SMPR1 0x0C | ||
36 | #define STM32F4_ADC_SMPR2 0x10 | ||
37 | #define STM32F4_ADC_HTR 0x24 | ||
38 | #define STM32F4_ADC_LTR 0x28 | ||
39 | #define STM32F4_ADC_SQR1 0x2C | ||
40 | #define STM32F4_ADC_SQR2 0x30 | ||
41 | #define STM32F4_ADC_SQR3 0x34 | ||
42 | #define STM32F4_ADC_JSQR 0x38 | ||
43 | #define STM32F4_ADC_JDR1 0x3C | ||
44 | #define STM32F4_ADC_JDR2 0x40 | ||
45 | #define STM32F4_ADC_JDR3 0x44 | ||
46 | #define STM32F4_ADC_JDR4 0x48 | ||
47 | #define STM32F4_ADC_DR 0x4C | ||
48 | |||
49 | /* STM32F4_ADC_SR - bit fields */ | ||
50 | #define STM32F4_STRT BIT(4) | ||
51 | #define STM32F4_EOC BIT(1) | ||
52 | |||
53 | /* STM32F4_ADC_CR1 - bit fields */ | ||
54 | #define STM32F4_RES_SHIFT 24 | ||
55 | #define STM32F4_RES_MASK GENMASK(25, 24) | ||
56 | #define STM32F4_SCAN BIT(8) | ||
57 | #define STM32F4_EOCIE BIT(5) | ||
58 | |||
59 | /* STM32F4_ADC_CR2 - bit fields */ | ||
60 | #define STM32F4_SWSTART BIT(30) | ||
61 | #define STM32F4_EXTEN_SHIFT 28 | ||
62 | #define STM32F4_EXTEN_MASK GENMASK(29, 28) | ||
63 | #define STM32F4_EXTSEL_SHIFT 24 | ||
64 | #define STM32F4_EXTSEL_MASK GENMASK(27, 24) | ||
65 | #define STM32F4_EOCS BIT(10) | ||
66 | #define STM32F4_DDS BIT(9) | ||
67 | #define STM32F4_DMA BIT(8) | ||
68 | #define STM32F4_ADON BIT(0) | ||
69 | |||
70 | /* STM32H7 - Registers for each ADC instance */ | ||
71 | #define STM32H7_ADC_ISR 0x00 | ||
72 | #define STM32H7_ADC_IER 0x04 | ||
73 | #define STM32H7_ADC_CR 0x08 | ||
74 | #define STM32H7_ADC_CFGR 0x0C | ||
75 | #define STM32H7_ADC_SMPR1 0x14 | ||
76 | #define STM32H7_ADC_SMPR2 0x18 | ||
77 | #define STM32H7_ADC_PCSEL 0x1C | ||
78 | #define STM32H7_ADC_SQR1 0x30 | ||
79 | #define STM32H7_ADC_SQR2 0x34 | ||
80 | #define STM32H7_ADC_SQR3 0x38 | ||
81 | #define STM32H7_ADC_SQR4 0x3C | ||
82 | #define STM32H7_ADC_DR 0x40 | ||
83 | #define STM32H7_ADC_DIFSEL 0xC0 | ||
84 | #define STM32H7_ADC_CALFACT 0xC4 | ||
85 | #define STM32H7_ADC_CALFACT2 0xC8 | ||
86 | |||
87 | /* STM32H7_ADC_ISR - bit fields */ | ||
88 | #define STM32MP1_VREGREADY BIT(12) | ||
89 | #define STM32H7_EOC BIT(2) | ||
90 | #define STM32H7_ADRDY BIT(0) | ||
91 | |||
92 | /* STM32H7_ADC_IER - bit fields */ | ||
93 | #define STM32H7_EOCIE STM32H7_EOC | ||
94 | |||
95 | /* STM32H7_ADC_CR - bit fields */ | ||
96 | #define STM32H7_ADCAL BIT(31) | ||
97 | #define STM32H7_ADCALDIF BIT(30) | ||
98 | #define STM32H7_DEEPPWD BIT(29) | ||
99 | #define STM32H7_ADVREGEN BIT(28) | ||
100 | #define STM32H7_LINCALRDYW6 BIT(27) | ||
101 | #define STM32H7_LINCALRDYW5 BIT(26) | ||
102 | #define STM32H7_LINCALRDYW4 BIT(25) | ||
103 | #define STM32H7_LINCALRDYW3 BIT(24) | ||
104 | #define STM32H7_LINCALRDYW2 BIT(23) | ||
105 | #define STM32H7_LINCALRDYW1 BIT(22) | ||
106 | #define STM32H7_ADCALLIN BIT(16) | ||
107 | #define STM32H7_BOOST BIT(8) | ||
108 | #define STM32H7_ADSTP BIT(4) | ||
109 | #define STM32H7_ADSTART BIT(2) | ||
110 | #define STM32H7_ADDIS BIT(1) | ||
111 | #define STM32H7_ADEN BIT(0) | ||
112 | |||
113 | /* STM32H7_ADC_CFGR bit fields */ | ||
114 | #define STM32H7_EXTEN_SHIFT 10 | ||
115 | #define STM32H7_EXTEN_MASK GENMASK(11, 10) | ||
116 | #define STM32H7_EXTSEL_SHIFT 5 | ||
117 | #define STM32H7_EXTSEL_MASK GENMASK(9, 5) | ||
118 | #define STM32H7_RES_SHIFT 2 | ||
119 | #define STM32H7_RES_MASK GENMASK(4, 2) | ||
120 | #define STM32H7_DMNGT_SHIFT 0 | ||
121 | #define STM32H7_DMNGT_MASK GENMASK(1, 0) | ||
122 | |||
123 | enum stm32h7_adc_dmngt { | ||
124 | STM32H7_DMNGT_DR_ONLY, /* Regular data in DR only */ | ||
125 | STM32H7_DMNGT_DMA_ONESHOT, /* DMA one shot mode */ | ||
126 | STM32H7_DMNGT_DFSDM, /* DFSDM mode */ | ||
127 | STM32H7_DMNGT_DMA_CIRC, /* DMA circular mode */ | ||
128 | }; | ||
129 | |||
130 | /* STM32H7_ADC_CALFACT - bit fields */ | ||
131 | #define STM32H7_CALFACT_D_SHIFT 16 | ||
132 | #define STM32H7_CALFACT_D_MASK GENMASK(26, 16) | ||
133 | #define STM32H7_CALFACT_S_SHIFT 0 | ||
134 | #define STM32H7_CALFACT_S_MASK GENMASK(10, 0) | ||
135 | |||
136 | /* STM32H7_ADC_CALFACT2 - bit fields */ | ||
137 | #define STM32H7_LINCALFACT_SHIFT 0 | ||
138 | #define STM32H7_LINCALFACT_MASK GENMASK(29, 0) | ||
139 | |||
140 | /* Number of linear calibration shadow registers / LINCALRDYW control bits */ | 31 | /* Number of linear calibration shadow registers / LINCALRDYW control bits */ |
141 | #define STM32H7_LINCALFACT_NUM 6 | 32 | #define STM32H7_LINCALFACT_NUM 6 |
142 | 33 | ||
diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c index 9ac8356d9a95..4998a89d083d 100644 --- a/drivers/iio/imu/adis_buffer.c +++ b/drivers/iio/imu/adis_buffer.c | |||
@@ -35,8 +35,11 @@ static int adis_update_scan_mode_burst(struct iio_dev *indio_dev, | |||
35 | return -ENOMEM; | 35 | return -ENOMEM; |
36 | 36 | ||
37 | adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL); | 37 | adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL); |
38 | if (!adis->buffer) | 38 | if (!adis->buffer) { |
39 | kfree(adis->xfer); | ||
40 | adis->xfer = NULL; | ||
39 | return -ENOMEM; | 41 | return -ENOMEM; |
42 | } | ||
40 | 43 | ||
41 | tx = adis->buffer + burst_length; | 44 | tx = adis->buffer + burst_length; |
42 | tx[0] = ADIS_READ_REG(adis->burst->reg_cmd); | 45 | tx[0] = ADIS_READ_REG(adis->burst->reg_cmd); |
@@ -78,8 +81,11 @@ int adis_update_scan_mode(struct iio_dev *indio_dev, | |||
78 | return -ENOMEM; | 81 | return -ENOMEM; |
79 | 82 | ||
80 | adis->buffer = kcalloc(indio_dev->scan_bytes, 2, GFP_KERNEL); | 83 | adis->buffer = kcalloc(indio_dev->scan_bytes, 2, GFP_KERNEL); |
81 | if (!adis->buffer) | 84 | if (!adis->buffer) { |
85 | kfree(adis->xfer); | ||
86 | adis->xfer = NULL; | ||
82 | return -ENOMEM; | 87 | return -ENOMEM; |
88 | } | ||
83 | 89 | ||
84 | rx = adis->buffer; | 90 | rx = adis->buffer; |
85 | tx = rx + scan_count; | 91 | tx = rx + scan_count; |
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 80e42c7dbcbe..0fe6999b8257 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | |||
@@ -99,7 +99,9 @@ struct st_lsm6dsx_fs { | |||
99 | #define ST_LSM6DSX_FS_LIST_SIZE 4 | 99 | #define ST_LSM6DSX_FS_LIST_SIZE 4 |
100 | struct st_lsm6dsx_fs_table_entry { | 100 | struct st_lsm6dsx_fs_table_entry { |
101 | struct st_lsm6dsx_reg reg; | 101 | struct st_lsm6dsx_reg reg; |
102 | |||
102 | struct st_lsm6dsx_fs fs_avl[ST_LSM6DSX_FS_LIST_SIZE]; | 103 | struct st_lsm6dsx_fs fs_avl[ST_LSM6DSX_FS_LIST_SIZE]; |
104 | int fs_len; | ||
103 | }; | 105 | }; |
104 | 106 | ||
105 | /** | 107 | /** |
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 2d3495560136..fd5ebe1e1594 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | |||
@@ -145,6 +145,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
145 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, | 145 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, |
146 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, | 146 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, |
147 | .fs_avl[3] = { IIO_G_TO_M_S_2(732), 0x1 }, | 147 | .fs_avl[3] = { IIO_G_TO_M_S_2(732), 0x1 }, |
148 | .fs_len = 4, | ||
148 | }, | 149 | }, |
149 | [ST_LSM6DSX_ID_GYRO] = { | 150 | [ST_LSM6DSX_ID_GYRO] = { |
150 | .reg = { | 151 | .reg = { |
@@ -154,6 +155,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
154 | .fs_avl[0] = { IIO_DEGREE_TO_RAD(245), 0x0 }, | 155 | .fs_avl[0] = { IIO_DEGREE_TO_RAD(245), 0x0 }, |
155 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(500), 0x1 }, | 156 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(500), 0x1 }, |
156 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(2000), 0x3 }, | 157 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(2000), 0x3 }, |
158 | .fs_len = 3, | ||
157 | }, | 159 | }, |
158 | }, | 160 | }, |
159 | }, | 161 | }, |
@@ -215,6 +217,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
215 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, | 217 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, |
216 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, | 218 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, |
217 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, | 219 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, |
220 | .fs_len = 4, | ||
218 | }, | 221 | }, |
219 | [ST_LSM6DSX_ID_GYRO] = { | 222 | [ST_LSM6DSX_ID_GYRO] = { |
220 | .reg = { | 223 | .reg = { |
@@ -225,6 +228,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
225 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, | 228 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, |
226 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, | 229 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, |
227 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, | 230 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, |
231 | .fs_len = 4, | ||
228 | }, | 232 | }, |
229 | }, | 233 | }, |
230 | .decimator = { | 234 | .decimator = { |
@@ -327,6 +331,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
327 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, | 331 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, |
328 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, | 332 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, |
329 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, | 333 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, |
334 | .fs_len = 4, | ||
330 | }, | 335 | }, |
331 | [ST_LSM6DSX_ID_GYRO] = { | 336 | [ST_LSM6DSX_ID_GYRO] = { |
332 | .reg = { | 337 | .reg = { |
@@ -337,6 +342,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
337 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, | 342 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, |
338 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, | 343 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, |
339 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, | 344 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, |
345 | .fs_len = 4, | ||
340 | }, | 346 | }, |
341 | }, | 347 | }, |
342 | .decimator = { | 348 | .decimator = { |
@@ -448,6 +454,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
448 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, | 454 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, |
449 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, | 455 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, |
450 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, | 456 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, |
457 | .fs_len = 4, | ||
451 | }, | 458 | }, |
452 | [ST_LSM6DSX_ID_GYRO] = { | 459 | [ST_LSM6DSX_ID_GYRO] = { |
453 | .reg = { | 460 | .reg = { |
@@ -458,6 +465,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
458 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, | 465 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, |
459 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, | 466 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, |
460 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, | 467 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, |
468 | .fs_len = 4, | ||
461 | }, | 469 | }, |
462 | }, | 470 | }, |
463 | .decimator = { | 471 | .decimator = { |
@@ -563,6 +571,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
563 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, | 571 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, |
564 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, | 572 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, |
565 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, | 573 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, |
574 | .fs_len = 4, | ||
566 | }, | 575 | }, |
567 | [ST_LSM6DSX_ID_GYRO] = { | 576 | [ST_LSM6DSX_ID_GYRO] = { |
568 | .reg = { | 577 | .reg = { |
@@ -573,6 +582,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
573 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, | 582 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, |
574 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, | 583 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, |
575 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, | 584 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, |
585 | .fs_len = 4, | ||
576 | }, | 586 | }, |
577 | }, | 587 | }, |
578 | .batch = { | 588 | .batch = { |
@@ -693,6 +703,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
693 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, | 703 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, |
694 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, | 704 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, |
695 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, | 705 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, |
706 | .fs_len = 4, | ||
696 | }, | 707 | }, |
697 | [ST_LSM6DSX_ID_GYRO] = { | 708 | [ST_LSM6DSX_ID_GYRO] = { |
698 | .reg = { | 709 | .reg = { |
@@ -703,6 +714,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
703 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, | 714 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, |
704 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, | 715 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, |
705 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, | 716 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, |
717 | .fs_len = 4, | ||
706 | }, | 718 | }, |
707 | }, | 719 | }, |
708 | .batch = { | 720 | .batch = { |
@@ -800,6 +812,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
800 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, | 812 | .fs_avl[1] = { IIO_G_TO_M_S_2(122), 0x2 }, |
801 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, | 813 | .fs_avl[2] = { IIO_G_TO_M_S_2(244), 0x3 }, |
802 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, | 814 | .fs_avl[3] = { IIO_G_TO_M_S_2(488), 0x1 }, |
815 | .fs_len = 4, | ||
803 | }, | 816 | }, |
804 | [ST_LSM6DSX_ID_GYRO] = { | 817 | [ST_LSM6DSX_ID_GYRO] = { |
805 | .reg = { | 818 | .reg = { |
@@ -810,6 +823,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { | |||
810 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, | 823 | .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500), 0x1 }, |
811 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, | 824 | .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000), 0x2 }, |
812 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, | 825 | .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, |
826 | .fs_len = 4, | ||
813 | }, | 827 | }, |
814 | }, | 828 | }, |
815 | .batch = { | 829 | .batch = { |
@@ -933,11 +947,12 @@ static int st_lsm6dsx_set_full_scale(struct st_lsm6dsx_sensor *sensor, | |||
933 | int i, err; | 947 | int i, err; |
934 | 948 | ||
935 | fs_table = &sensor->hw->settings->fs_table[sensor->id]; | 949 | fs_table = &sensor->hw->settings->fs_table[sensor->id]; |
936 | for (i = 0; i < ST_LSM6DSX_FS_LIST_SIZE; i++) | 950 | for (i = 0; i < fs_table->fs_len; i++) { |
937 | if (fs_table->fs_avl[i].gain == gain) | 951 | if (fs_table->fs_avl[i].gain == gain) |
938 | break; | 952 | break; |
953 | } | ||
939 | 954 | ||
940 | if (i == ST_LSM6DSX_FS_LIST_SIZE) | 955 | if (i == fs_table->fs_len) |
941 | return -EINVAL; | 956 | return -EINVAL; |
942 | 957 | ||
943 | data = ST_LSM6DSX_SHIFT_VAL(fs_table->fs_avl[i].val, | 958 | data = ST_LSM6DSX_SHIFT_VAL(fs_table->fs_avl[i].val, |
@@ -1196,18 +1211,13 @@ static ssize_t st_lsm6dsx_sysfs_scale_avail(struct device *dev, | |||
1196 | { | 1211 | { |
1197 | struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev)); | 1212 | struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev)); |
1198 | const struct st_lsm6dsx_fs_table_entry *fs_table; | 1213 | const struct st_lsm6dsx_fs_table_entry *fs_table; |
1199 | enum st_lsm6dsx_sensor_id id = sensor->id; | ||
1200 | struct st_lsm6dsx_hw *hw = sensor->hw; | 1214 | struct st_lsm6dsx_hw *hw = sensor->hw; |
1201 | int i, len = 0; | 1215 | int i, len = 0; |
1202 | 1216 | ||
1203 | fs_table = &hw->settings->fs_table[id]; | 1217 | fs_table = &hw->settings->fs_table[sensor->id]; |
1204 | for (i = 0; i < ST_LSM6DSX_FS_LIST_SIZE; i++) { | 1218 | for (i = 0; i < fs_table->fs_len; i++) |
1205 | if (!fs_table->fs_avl[i].gain) | ||
1206 | break; | ||
1207 | |||
1208 | len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ", | 1219 | len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ", |
1209 | fs_table->fs_avl[i].gain); | 1220 | fs_table->fs_avl[i].gain); |
1210 | } | ||
1211 | buf[len - 1] = '\n'; | 1221 | buf[len - 1] = '\n'; |
1212 | 1222 | ||
1213 | return len; | 1223 | return len; |
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c index 66fbcd94642d..ea472cf6db7b 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | |||
@@ -61,6 +61,7 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { | |||
61 | .gain = 1500, | 61 | .gain = 1500, |
62 | .val = 0x0, | 62 | .val = 0x0, |
63 | }, /* 1500 uG/LSB */ | 63 | }, /* 1500 uG/LSB */ |
64 | .fs_len = 1, | ||
64 | }, | 65 | }, |
65 | .temp_comp = { | 66 | .temp_comp = { |
66 | .addr = 0x60, | 67 | .addr = 0x60, |
@@ -92,9 +93,11 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { | |||
92 | static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw) | 93 | static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw) |
93 | { | 94 | { |
94 | struct st_lsm6dsx_sensor *sensor; | 95 | struct st_lsm6dsx_sensor *sensor; |
96 | u16 odr; | ||
95 | 97 | ||
96 | sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]); | 98 | sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]); |
97 | msleep((2000U / sensor->odr) + 1); | 99 | odr = (hw->enable_mask & BIT(ST_LSM6DSX_ID_ACC)) ? sensor->odr : 13; |
100 | msleep((2000U / odr) + 1); | ||
98 | } | 101 | } |
99 | 102 | ||
100 | /** | 103 | /** |
@@ -555,13 +558,9 @@ static ssize_t st_lsm6dsx_shub_scale_avail(struct device *dev, | |||
555 | int i, len = 0; | 558 | int i, len = 0; |
556 | 559 | ||
557 | settings = sensor->ext_info.settings; | 560 | settings = sensor->ext_info.settings; |
558 | for (i = 0; i < ST_LSM6DSX_FS_LIST_SIZE; i++) { | 561 | for (i = 0; i < settings->fs_table.fs_len; i++) |
559 | u16 val = settings->fs_table.fs_avl[i].gain; | 562 | len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ", |
560 | 563 | settings->fs_table.fs_avl[i].gain); | |
561 | if (val > 0) | ||
562 | len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ", | ||
563 | val); | ||
564 | } | ||
565 | buf[len - 1] = '\n'; | 564 | buf[len - 1] = '\n'; |
566 | 565 | ||
567 | return len; | 566 | return len; |
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 08d7e1ef2186..4a1a883dc061 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig | |||
@@ -314,6 +314,7 @@ config MAX44009 | |||
314 | config NOA1305 | 314 | config NOA1305 |
315 | tristate "ON Semiconductor NOA1305 ambient light sensor" | 315 | tristate "ON Semiconductor NOA1305 ambient light sensor" |
316 | depends on I2C | 316 | depends on I2C |
317 | select REGMAP_I2C | ||
317 | help | 318 | help |
318 | Say Y here if you want to build support for the ON Semiconductor | 319 | Say Y here if you want to build support for the ON Semiconductor |
319 | NOA1305 ambient light sensor. | 320 | NOA1305 ambient light sensor. |
diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c index e666879007d2..92004a2563ea 100644 --- a/drivers/iio/light/opt3001.c +++ b/drivers/iio/light/opt3001.c | |||
@@ -686,6 +686,7 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) | |||
686 | struct iio_dev *iio = _iio; | 686 | struct iio_dev *iio = _iio; |
687 | struct opt3001 *opt = iio_priv(iio); | 687 | struct opt3001 *opt = iio_priv(iio); |
688 | int ret; | 688 | int ret; |
689 | bool wake_result_ready_queue = false; | ||
689 | 690 | ||
690 | if (!opt->ok_to_ignore_lock) | 691 | if (!opt->ok_to_ignore_lock) |
691 | mutex_lock(&opt->lock); | 692 | mutex_lock(&opt->lock); |
@@ -720,13 +721,16 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) | |||
720 | } | 721 | } |
721 | opt->result = ret; | 722 | opt->result = ret; |
722 | opt->result_ready = true; | 723 | opt->result_ready = true; |
723 | wake_up(&opt->result_ready_queue); | 724 | wake_result_ready_queue = true; |
724 | } | 725 | } |
725 | 726 | ||
726 | out: | 727 | out: |
727 | if (!opt->ok_to_ignore_lock) | 728 | if (!opt->ok_to_ignore_lock) |
728 | mutex_unlock(&opt->lock); | 729 | mutex_unlock(&opt->lock); |
729 | 730 | ||
731 | if (wake_result_ready_queue) | ||
732 | wake_up(&opt->result_ready_queue); | ||
733 | |||
730 | return IRQ_HANDLED; | 734 | return IRQ_HANDLED; |
731 | } | 735 | } |
732 | 736 | ||
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 51421ac32517..16dacea9eadf 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c | |||
@@ -398,19 +398,23 @@ static int vcnl4000_probe(struct i2c_client *client, | |||
398 | static const struct of_device_id vcnl_4000_of_match[] = { | 398 | static const struct of_device_id vcnl_4000_of_match[] = { |
399 | { | 399 | { |
400 | .compatible = "vishay,vcnl4000", | 400 | .compatible = "vishay,vcnl4000", |
401 | .data = "VCNL4000", | 401 | .data = (void *)VCNL4000, |
402 | }, | 402 | }, |
403 | { | 403 | { |
404 | .compatible = "vishay,vcnl4010", | 404 | .compatible = "vishay,vcnl4010", |
405 | .data = "VCNL4010", | 405 | .data = (void *)VCNL4010, |
406 | }, | 406 | }, |
407 | { | 407 | { |
408 | .compatible = "vishay,vcnl4010", | 408 | .compatible = "vishay,vcnl4020", |
409 | .data = "VCNL4020", | 409 | .data = (void *)VCNL4010, |
410 | }, | ||
411 | { | ||
412 | .compatible = "vishay,vcnl4040", | ||
413 | .data = (void *)VCNL4040, | ||
410 | }, | 414 | }, |
411 | { | 415 | { |
412 | .compatible = "vishay,vcnl4200", | 416 | .compatible = "vishay,vcnl4200", |
413 | .data = "VCNL4200", | 417 | .data = (void *)VCNL4200, |
414 | }, | 418 | }, |
415 | {}, | 419 | {}, |
416 | }; | 420 | }; |