1 // SPDX-License-Identifier: GPL-2.0-only
3 * Murata ZPA2326 pressure and temperature sensor IIO driver
5 * Copyright (c) 2016 Parrot S.A.
7 * Author: Gregor Boirie <gregor.boirie@parrot.com>
11 * DOC: ZPA2326 theory of operations
13 * This driver supports %INDIO_DIRECT_MODE and %INDIO_BUFFER_TRIGGERED IIO
15 * A internal hardware trigger is also implemented to dispatch registered IIO
16 * trigger consumers upon "sample ready" interrupts.
18 * ZPA2326 hardware supports 2 sampling mode: one shot and continuous.
20 * A complete one shot sampling cycle gets device out of low power mode,
21 * performs pressure and temperature measurements, then automatically switches
22 * back to low power mode. It is meant for on demand sampling with optimal power
23 * saving at the cost of lower sampling rate and higher software overhead.
24 * This is a natural candidate for IIO read_raw hook implementation
25 * (%INDIO_DIRECT_MODE). It is also used for triggered buffering support to
26 * ensure explicit synchronization with external trigger events
27 * (%INDIO_BUFFER_TRIGGERED).
29 * The continuous mode works according to a periodic hardware measurement
30 * process continuously pushing samples into an internal hardware FIFO (for
31 * pressure samples only). Measurement cycle completion may be signaled by a
32 * "sample ready" interrupt.
33 * Typical software sequence of operations :
34 * - get device out of low power mode,
35 * - setup hardware sampling period,
36 * - at end of period, upon data ready interrupt: pop pressure samples out of
37 * hardware FIFO and fetch temperature sample
38 * - when no longer needed, stop sampling process by putting device into
40 * This mode is used to implement %INDIO_BUFFER_TRIGGERED mode if device tree
41 * declares a valid interrupt line. In this case, the internal hardware trigger
44 * Note that hardware sampling frequency is taken into account only when
45 * internal hardware trigger is attached as the highest sampling rate seems to
46 * be the most energy efficient.
49 * preset pressure threshold crossing / IIO events ;
50 * differential pressure sampling ;
51 * hardware samples averaging.
54 #include <linux/module.h>
55 #include <linux/kernel.h>
56 #include <linux/delay.h>
57 #include <linux/interrupt.h>
58 #include <linux/regulator/consumer.h>
59 #include <linux/pm_runtime.h>
60 #include <linux/regmap.h>
61 #include <linux/iio/iio.h>
62 #include <linux/iio/sysfs.h>
63 #include <linux/iio/buffer.h>
64 #include <linux/iio/trigger.h>
65 #include <linux/iio/trigger_consumer.h>
66 #include <linux/iio/triggered_buffer.h>
69 /* 200 ms should be enough for the longest conversion time in one-shot mode. */
70 #define ZPA2326_CONVERSION_JIFFIES (HZ / 5)
72 /* There should be a 1 ms delay (Tpup) after getting out of reset. */
73 #define ZPA2326_TPUP_USEC_MIN (1000)
74 #define ZPA2326_TPUP_USEC_MAX (2000)
77 * struct zpa2326_frequency - Hardware sampling frequency descriptor
78 * @hz : Frequency in Hertz.
79 * @odr: Output Data Rate word as expected by %ZPA2326_CTRL_REG3_REG.
81 struct zpa2326_frequency
{
87 * Keep these in strict ascending order: last array entry is expected to
88 * correspond to the highest sampling frequency.
90 static const struct zpa2326_frequency zpa2326_sampling_frequencies
[] = {
91 { .hz
= 1, .odr
= 1 << ZPA2326_CTRL_REG3_ODR_SHIFT
},
92 { .hz
= 5, .odr
= 5 << ZPA2326_CTRL_REG3_ODR_SHIFT
},
93 { .hz
= 11, .odr
= 6 << ZPA2326_CTRL_REG3_ODR_SHIFT
},
94 { .hz
= 23, .odr
= 7 << ZPA2326_CTRL_REG3_ODR_SHIFT
},
97 /* Return the highest hardware sampling frequency available. */
98 static const struct zpa2326_frequency
*zpa2326_highest_frequency(void)
100 return &zpa2326_sampling_frequencies
[
101 ARRAY_SIZE(zpa2326_sampling_frequencies
) - 1];
105 * struct zpa_private - Per-device internal private state
106 * @timestamp: Buffered samples ready datum.
107 * @regmap: Underlying I2C / SPI bus adapter used to abstract slave register
109 * @result: Allows sampling logic to get completion status of operations
110 * that interrupt handlers perform asynchronously.
111 * @data_ready: Interrupt handler uses this to wake user context up at sampling
112 * operation completion.
113 * @trigger: Optional hardware / interrupt driven trigger used to notify
114 * external devices a new sample is ready.
115 * @waken: Flag indicating whether or not device has just been powered on.
116 * @irq: Optional interrupt line: negative or zero if not declared into
117 * DT, in which case sampling logic keeps polling status register
118 * to detect completion.
119 * @frequency: Current hardware sampling frequency.
120 * @vref: Power / voltage reference.
121 * @vdd: Power supply.
123 struct zpa2326_private
{
125 struct regmap
*regmap
;
127 struct completion data_ready
;
128 struct iio_trigger
*trigger
;
131 const struct zpa2326_frequency
*frequency
;
132 struct regulator
*vref
;
133 struct regulator
*vdd
;
136 #define zpa2326_err(idev, fmt, ...) \
137 dev_err(idev->dev.parent, fmt "\n", ##__VA_ARGS__)
139 #define zpa2326_warn(idev, fmt, ...) \
140 dev_warn(idev->dev.parent, fmt "\n", ##__VA_ARGS__)
142 #define zpa2326_dbg(idev, fmt, ...) \
143 dev_dbg(idev->dev.parent, fmt "\n", ##__VA_ARGS__)
145 bool zpa2326_isreg_writeable(struct device
*dev
, unsigned int reg
)
148 case ZPA2326_REF_P_XL_REG
:
149 case ZPA2326_REF_P_L_REG
:
150 case ZPA2326_REF_P_H_REG
:
151 case ZPA2326_RES_CONF_REG
:
152 case ZPA2326_CTRL_REG0_REG
:
153 case ZPA2326_CTRL_REG1_REG
:
154 case ZPA2326_CTRL_REG2_REG
:
155 case ZPA2326_CTRL_REG3_REG
:
156 case ZPA2326_THS_P_LOW_REG
:
157 case ZPA2326_THS_P_HIGH_REG
:
164 EXPORT_SYMBOL_GPL(zpa2326_isreg_writeable
);
166 bool zpa2326_isreg_readable(struct device
*dev
, unsigned int reg
)
169 case ZPA2326_REF_P_XL_REG
:
170 case ZPA2326_REF_P_L_REG
:
171 case ZPA2326_REF_P_H_REG
:
172 case ZPA2326_DEVICE_ID_REG
:
173 case ZPA2326_RES_CONF_REG
:
174 case ZPA2326_CTRL_REG0_REG
:
175 case ZPA2326_CTRL_REG1_REG
:
176 case ZPA2326_CTRL_REG2_REG
:
177 case ZPA2326_CTRL_REG3_REG
:
178 case ZPA2326_INT_SOURCE_REG
:
179 case ZPA2326_THS_P_LOW_REG
:
180 case ZPA2326_THS_P_HIGH_REG
:
181 case ZPA2326_STATUS_REG
:
182 case ZPA2326_PRESS_OUT_XL_REG
:
183 case ZPA2326_PRESS_OUT_L_REG
:
184 case ZPA2326_PRESS_OUT_H_REG
:
185 case ZPA2326_TEMP_OUT_L_REG
:
186 case ZPA2326_TEMP_OUT_H_REG
:
193 EXPORT_SYMBOL_GPL(zpa2326_isreg_readable
);
195 bool zpa2326_isreg_precious(struct device
*dev
, unsigned int reg
)
198 case ZPA2326_INT_SOURCE_REG
:
199 case ZPA2326_PRESS_OUT_H_REG
:
206 EXPORT_SYMBOL_GPL(zpa2326_isreg_precious
);
209 * zpa2326_enable_device() - Enable device, i.e. get out of low power mode.
210 * @indio_dev: The IIO device associated with the hardware to enable.
212 * Required to access complete register space and to perform any sampling
213 * or control operations.
215 * Return: Zero when successful, a negative error code otherwise.
217 static int zpa2326_enable_device(const struct iio_dev
*indio_dev
)
221 err
= regmap_write(((struct zpa2326_private
*)
222 iio_priv(indio_dev
))->regmap
,
223 ZPA2326_CTRL_REG0_REG
, ZPA2326_CTRL_REG0_ENABLE
);
225 zpa2326_err(indio_dev
, "failed to enable device (%d)", err
);
229 zpa2326_dbg(indio_dev
, "enabled");
235 * zpa2326_sleep() - Disable device, i.e. switch to low power mode.
236 * @indio_dev: The IIO device associated with the hardware to disable.
238 * Only %ZPA2326_DEVICE_ID_REG and %ZPA2326_CTRL_REG0_REG registers may be
239 * accessed once device is in the disabled state.
241 * Return: Zero when successful, a negative error code otherwise.
243 static int zpa2326_sleep(const struct iio_dev
*indio_dev
)
247 err
= regmap_write(((struct zpa2326_private
*)
248 iio_priv(indio_dev
))->regmap
,
249 ZPA2326_CTRL_REG0_REG
, 0);
251 zpa2326_err(indio_dev
, "failed to sleep (%d)", err
);
255 zpa2326_dbg(indio_dev
, "sleeping");
261 * zpa2326_reset_device() - Reset device to default hardware state.
262 * @indio_dev: The IIO device associated with the hardware to reset.
264 * Disable sampling and empty hardware FIFO.
265 * Device must be enabled before reset, i.e. not in low power mode.
267 * Return: Zero when successful, a negative error code otherwise.
269 static int zpa2326_reset_device(const struct iio_dev
*indio_dev
)
273 err
= regmap_write(((struct zpa2326_private
*)
274 iio_priv(indio_dev
))->regmap
,
275 ZPA2326_CTRL_REG2_REG
, ZPA2326_CTRL_REG2_SWRESET
);
277 zpa2326_err(indio_dev
, "failed to reset device (%d)", err
);
281 usleep_range(ZPA2326_TPUP_USEC_MIN
, ZPA2326_TPUP_USEC_MAX
);
283 zpa2326_dbg(indio_dev
, "reset");
289 * zpa2326_start_oneshot() - Start a single sampling cycle, i.e. in one shot
291 * @indio_dev: The IIO device associated with the sampling hardware.
293 * Device must have been previously enabled and configured for one shot mode.
294 * Device will be switched back to low power mode at end of cycle.
296 * Return: Zero when successful, a negative error code otherwise.
298 static int zpa2326_start_oneshot(const struct iio_dev
*indio_dev
)
302 err
= regmap_write(((struct zpa2326_private
*)
303 iio_priv(indio_dev
))->regmap
,
304 ZPA2326_CTRL_REG0_REG
,
305 ZPA2326_CTRL_REG0_ENABLE
|
306 ZPA2326_CTRL_REG0_ONE_SHOT
);
308 zpa2326_err(indio_dev
, "failed to start one shot cycle (%d)",
313 zpa2326_dbg(indio_dev
, "one shot cycle started");
319 * zpa2326_power_on() - Power on device to allow subsequent configuration.
320 * @indio_dev: The IIO device associated with the sampling hardware.
321 * @private: Internal private state related to @indio_dev.
323 * Sampling will be disabled, preventing strange things from happening in our
324 * back. Hardware FIFO content will be cleared.
325 * When successful, device will be left in the enabled state to allow further
328 * Return: Zero when successful, a negative error code otherwise.
330 static int zpa2326_power_on(const struct iio_dev
*indio_dev
,
331 const struct zpa2326_private
*private)
335 err
= regulator_enable(private->vref
);
339 err
= regulator_enable(private->vdd
);
343 zpa2326_dbg(indio_dev
, "powered on");
345 err
= zpa2326_enable_device(indio_dev
);
349 err
= zpa2326_reset_device(indio_dev
);
356 zpa2326_sleep(indio_dev
);
358 regulator_disable(private->vdd
);
360 regulator_disable(private->vref
);
362 zpa2326_dbg(indio_dev
, "powered off");
368 * zpa2326_power_off() - Power off device, i.e. disable attached power
370 * @indio_dev: The IIO device associated with the sampling hardware.
371 * @private: Internal private state related to @indio_dev.
373 * Return: Zero when successful, a negative error code otherwise.
375 static void zpa2326_power_off(const struct iio_dev
*indio_dev
,
376 const struct zpa2326_private
*private)
378 regulator_disable(private->vdd
);
379 regulator_disable(private->vref
);
381 zpa2326_dbg(indio_dev
, "powered off");
385 * zpa2326_config_oneshot() - Setup device for one shot / on demand mode.
386 * @indio_dev: The IIO device associated with the sampling hardware.
387 * @irq: Optional interrupt line the hardware uses to notify new data
388 * samples are ready. Negative or zero values indicate no interrupts
389 * are available, meaning polling is required.
391 * Output Data Rate is configured for the highest possible rate so that
392 * conversion time and power consumption are reduced to a minimum.
393 * Note that hardware internal averaging machinery (not implemented in this
394 * driver) is not applicable in this mode.
396 * Device must have been previously enabled before calling
397 * zpa2326_config_oneshot().
399 * Return: Zero when successful, a negative error code otherwise.
401 static int zpa2326_config_oneshot(const struct iio_dev
*indio_dev
,
404 struct regmap
*regs
= ((struct zpa2326_private
*)
405 iio_priv(indio_dev
))->regmap
;
406 const struct zpa2326_frequency
*freq
= zpa2326_highest_frequency();
409 /* Setup highest available Output Data Rate for one shot mode. */
410 err
= regmap_write(regs
, ZPA2326_CTRL_REG3_REG
, freq
->odr
);
415 /* Request interrupt when new sample is available. */
416 err
= regmap_write(regs
, ZPA2326_CTRL_REG1_REG
,
417 (u8
)~ZPA2326_CTRL_REG1_MASK_DATA_READY
);
420 dev_err(indio_dev
->dev
.parent
,
421 "failed to setup one shot mode (%d)", err
);
426 zpa2326_dbg(indio_dev
, "one shot mode setup @%dHz", freq
->hz
);
432 * zpa2326_clear_fifo() - Clear remaining entries in hardware FIFO.
433 * @indio_dev: The IIO device associated with the sampling hardware.
434 * @min_count: Number of samples present within hardware FIFO.
436 * @min_count argument is a hint corresponding to the known minimum number of
437 * samples currently living in the FIFO. This allows to reduce the number of bus
438 * accesses by skipping status register read operation as long as we know for
439 * sure there are still entries left.
441 * Return: Zero when successful, a negative error code otherwise.
443 static int zpa2326_clear_fifo(const struct iio_dev
*indio_dev
,
444 unsigned int min_count
)
446 struct regmap
*regs
= ((struct zpa2326_private
*)
447 iio_priv(indio_dev
))->regmap
;
453 * No hint: read status register to determine whether FIFO is
456 err
= regmap_read(regs
, ZPA2326_STATUS_REG
, &val
);
461 if (val
& ZPA2326_STATUS_FIFO_E
)
462 /* Fifo is empty: nothing to trash. */
469 * A single fetch from pressure MSB register is enough to pop
470 * values out of FIFO.
472 err
= regmap_read(regs
, ZPA2326_PRESS_OUT_H_REG
, &val
);
478 * We know for sure there are at least min_count entries
479 * left in FIFO. Skip status register read.
485 err
= regmap_read(regs
, ZPA2326_STATUS_REG
, &val
);
489 } while (!(val
& ZPA2326_STATUS_FIFO_E
));
491 zpa2326_dbg(indio_dev
, "FIFO cleared");
496 zpa2326_err(indio_dev
, "failed to clear FIFO (%d)", err
);
502 * zpa2326_dequeue_pressure() - Retrieve the most recent pressure sample from
504 * @indio_dev: The IIO device associated with the sampling hardware.
505 * @pressure: Sampled pressure output.
507 * Note that ZPA2326 hardware FIFO stores pressure samples only.
509 * Return: Zero when successful, a negative error code otherwise.
511 static int zpa2326_dequeue_pressure(const struct iio_dev
*indio_dev
,
514 struct regmap
*regs
= ((struct zpa2326_private
*)
515 iio_priv(indio_dev
))->regmap
;
520 err
= regmap_read(regs
, ZPA2326_STATUS_REG
, &val
);
526 if (val
& ZPA2326_STATUS_P_OR
) {
528 * Fifo overrun : first sample dequeued from FIFO is the
531 zpa2326_warn(indio_dev
, "FIFO overflow");
533 err
= regmap_bulk_read(regs
, ZPA2326_PRESS_OUT_XL_REG
, pressure
,
538 #define ZPA2326_FIFO_DEPTH (16U)
539 /* Hardware FIFO may hold no more than 16 pressure samples. */
540 return zpa2326_clear_fifo(indio_dev
, ZPA2326_FIFO_DEPTH
- 1);
544 * Fifo has not overflown : retrieve newest sample. We need to pop
545 * values out until FIFO is empty : last fetched pressure is the newest.
546 * In nominal cases, we should find a single queued sample only.
549 err
= regmap_bulk_read(regs
, ZPA2326_PRESS_OUT_XL_REG
, pressure
,
554 err
= regmap_read(regs
, ZPA2326_STATUS_REG
, &val
);
559 } while (!(val
& ZPA2326_STATUS_FIFO_E
));
563 * Samples were pushed by hardware during previous rounds but we
564 * didn't consume them fast enough: inform user.
566 zpa2326_dbg(indio_dev
, "cleared %d FIFO entries", cleared
);
572 * zpa2326_fill_sample_buffer() - Enqueue new channel samples to IIO buffer.
573 * @indio_dev: The IIO device associated with the sampling hardware.
574 * @private: Internal private state related to @indio_dev.
576 * Return: Zero when successful, a negative error code otherwise.
578 static int zpa2326_fill_sample_buffer(struct iio_dev
*indio_dev
,
579 const struct zpa2326_private
*private)
588 if (test_bit(0, indio_dev
->active_scan_mask
)) {
589 /* Get current pressure from hardware FIFO. */
590 err
= zpa2326_dequeue_pressure(indio_dev
, &sample
.pressure
);
592 zpa2326_warn(indio_dev
, "failed to fetch pressure (%d)",
598 if (test_bit(1, indio_dev
->active_scan_mask
)) {
599 /* Get current temperature. */
600 err
= regmap_bulk_read(private->regmap
, ZPA2326_TEMP_OUT_L_REG
,
601 &sample
.temperature
, 2);
603 zpa2326_warn(indio_dev
,
604 "failed to fetch temperature (%d)", err
);
610 * Now push samples using timestamp stored either :
611 * - by hardware interrupt handler if interrupt is available: see
612 * zpa2326_handle_irq(),
613 * - or oneshot completion polling machinery : see
614 * zpa2326_trigger_handler().
616 zpa2326_dbg(indio_dev
, "filling raw samples buffer");
618 iio_push_to_buffers_with_timestamp(indio_dev
, &sample
,
625 static int zpa2326_runtime_suspend(struct device
*parent
)
627 const struct iio_dev
*indio_dev
= dev_get_drvdata(parent
);
629 if (pm_runtime_autosuspend_expiration(parent
))
630 /* Userspace changed autosuspend delay. */
633 zpa2326_power_off(indio_dev
, iio_priv(indio_dev
));
638 static int zpa2326_runtime_resume(struct device
*parent
)
640 const struct iio_dev
*indio_dev
= dev_get_drvdata(parent
);
642 return zpa2326_power_on(indio_dev
, iio_priv(indio_dev
));
645 const struct dev_pm_ops zpa2326_pm_ops
= {
646 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend
,
647 pm_runtime_force_resume
)
648 SET_RUNTIME_PM_OPS(zpa2326_runtime_suspend
, zpa2326_runtime_resume
,
651 EXPORT_SYMBOL_GPL(zpa2326_pm_ops
);
654 * zpa2326_resume() - Request the PM layer to power supply the device.
655 * @indio_dev: The IIO device associated with the sampling hardware.
658 * < 0 - a negative error code meaning failure ;
659 * 0 - success, device has just been powered up ;
660 * 1 - success, device was already powered.
662 static int zpa2326_resume(const struct iio_dev
*indio_dev
)
666 err
= pm_runtime_get_sync(indio_dev
->dev
.parent
);
672 * Device was already power supplied: get it out of low power
673 * mode and inform caller.
675 zpa2326_enable_device(indio_dev
);
679 /* Inform caller device has just been brought back to life. */
684 * zpa2326_suspend() - Schedule a power down using autosuspend feature of PM
686 * @indio_dev: The IIO device associated with the sampling hardware.
688 * Device is switched to low power mode at first to save power even when
689 * attached regulator is a "dummy" one.
691 static void zpa2326_suspend(struct iio_dev
*indio_dev
)
693 struct device
*parent
= indio_dev
->dev
.parent
;
695 zpa2326_sleep(indio_dev
);
697 pm_runtime_mark_last_busy(parent
);
698 pm_runtime_put_autosuspend(parent
);
701 static void zpa2326_init_runtime(struct device
*parent
)
703 pm_runtime_get_noresume(parent
);
704 pm_runtime_set_active(parent
);
705 pm_runtime_enable(parent
);
706 pm_runtime_set_autosuspend_delay(parent
, 1000);
707 pm_runtime_use_autosuspend(parent
);
708 pm_runtime_mark_last_busy(parent
);
709 pm_runtime_put_autosuspend(parent
);
712 static void zpa2326_fini_runtime(struct device
*parent
)
714 pm_runtime_disable(parent
);
715 pm_runtime_set_suspended(parent
);
717 #else /* !CONFIG_PM */
718 static int zpa2326_resume(const struct iio_dev
*indio_dev
)
720 zpa2326_enable_device(indio_dev
);
725 static void zpa2326_suspend(struct iio_dev
*indio_dev
)
727 zpa2326_sleep(indio_dev
);
730 #define zpa2326_init_runtime(_parent)
731 #define zpa2326_fini_runtime(_parent)
732 #endif /* !CONFIG_PM */
735 * zpa2326_handle_irq() - Process hardware interrupts.
736 * @irq: Interrupt line the hardware uses to notify new data has arrived.
737 * @data: The IIO device associated with the sampling hardware.
739 * Timestamp buffered samples as soon as possible then schedule threaded bottom
742 * Return: Always successful.
744 static irqreturn_t
zpa2326_handle_irq(int irq
, void *data
)
746 struct iio_dev
*indio_dev
= data
;
748 if (iio_buffer_enabled(indio_dev
)) {
749 /* Timestamping needed for buffered sampling only. */
750 ((struct zpa2326_private
*)
751 iio_priv(indio_dev
))->timestamp
= iio_get_time_ns(indio_dev
);
754 return IRQ_WAKE_THREAD
;
758 * zpa2326_handle_threaded_irq() - Interrupt bottom-half handler.
759 * @irq: Interrupt line the hardware uses to notify new data has arrived.
760 * @data: The IIO device associated with the sampling hardware.
762 * Mainly ensures interrupt is caused by a real "new sample available"
763 * condition. This relies upon the ability to perform blocking / sleeping bus
764 * accesses to slave's registers. This is why zpa2326_handle_threaded_irq() is
765 * called from within a thread, i.e. not called from hard interrupt context.
767 * When device is using its own internal hardware trigger in continuous sampling
768 * mode, data are available into hardware FIFO once interrupt has occurred. All
769 * we have to do is to dispatch the trigger, which in turn will fetch data and
772 * When not using its own internal hardware trigger, the device has been
773 * configured in one-shot mode either by an external trigger or the IIO read_raw
774 * hook. This means one of the latter is currently waiting for sampling
775 * completion, in which case we must simply wake it up.
777 * See zpa2326_trigger_handler().
780 * %IRQ_NONE - no consistent interrupt happened ;
781 * %IRQ_HANDLED - there was new samples available.
783 static irqreturn_t
zpa2326_handle_threaded_irq(int irq
, void *data
)
785 struct iio_dev
*indio_dev
= data
;
786 struct zpa2326_private
*priv
= iio_priv(indio_dev
);
789 irqreturn_t ret
= IRQ_NONE
;
792 * Are we using our own internal trigger in triggered buffer mode, i.e.,
793 * currently working in continuous sampling mode ?
795 cont
= (iio_buffer_enabled(indio_dev
) &&
796 iio_trigger_using_own(indio_dev
));
799 * Device works according to a level interrupt scheme: reading interrupt
800 * status de-asserts interrupt line.
802 priv
->result
= regmap_read(priv
->regmap
, ZPA2326_INT_SOURCE_REG
, &val
);
803 if (priv
->result
< 0) {
810 /* Data ready is the only interrupt source we requested. */
811 if (!(val
& ZPA2326_INT_SOURCE_DATA_READY
)) {
813 * Interrupt happened but no new sample available: likely caused
814 * by spurious interrupts, in which case, returning IRQ_NONE
815 * allows to benefit from the generic spurious interrupts
818 zpa2326_warn(indio_dev
, "unexpected interrupt status %02x",
824 priv
->result
= -ENODATA
;
828 /* New sample available: dispatch internal trigger consumers. */
829 iio_trigger_poll_chained(priv
->trigger
);
833 * Internal hardware trigger has been scheduled above : it will
834 * fetch data on its own.
842 * Wake up direct or externaly triggered buffer mode waiters: see
843 * zpa2326_sample_oneshot() and zpa2326_trigger_handler().
845 complete(&priv
->data_ready
);
851 * zpa2326_wait_oneshot_completion() - Wait for oneshot data ready interrupt.
852 * @indio_dev: The IIO device associated with the sampling hardware.
853 * @private: Internal private state related to @indio_dev.
855 * Return: Zero when successful, a negative error code otherwise.
857 static int zpa2326_wait_oneshot_completion(const struct iio_dev
*indio_dev
,
858 struct zpa2326_private
*private)
863 zpa2326_dbg(indio_dev
, "waiting for one shot completion interrupt");
865 timeout
= wait_for_completion_interruptible_timeout(
866 &private->data_ready
, ZPA2326_CONVERSION_JIFFIES
);
869 * Interrupt handler completed before timeout: return operation
872 return private->result
;
874 /* Clear all interrupts just to be sure. */
875 regmap_read(private->regmap
, ZPA2326_INT_SOURCE_REG
, &val
);
879 zpa2326_warn(indio_dev
, "no one shot interrupt occurred (%ld)",
884 zpa2326_warn(indio_dev
, "wait for one shot interrupt cancelled");
888 static int zpa2326_init_managed_irq(struct device
*parent
,
889 struct iio_dev
*indio_dev
,
890 struct zpa2326_private
*private,
899 * Platform declared no interrupt line: device will be polled
900 * for data availability.
902 dev_info(parent
, "no interrupt found, running in polling mode");
906 init_completion(&private->data_ready
);
908 /* Request handler to be scheduled into threaded interrupt context. */
909 err
= devm_request_threaded_irq(parent
, irq
, zpa2326_handle_irq
,
910 zpa2326_handle_threaded_irq
,
911 IRQF_TRIGGER_RISING
| IRQF_ONESHOT
,
912 dev_name(parent
), indio_dev
);
914 dev_err(parent
, "failed to request interrupt %d (%d)", irq
,
919 dev_info(parent
, "using interrupt %d", irq
);
925 * zpa2326_poll_oneshot_completion() - Actively poll for one shot data ready.
926 * @indio_dev: The IIO device associated with the sampling hardware.
928 * Loop over registers content to detect end of sampling cycle. Used when DT
929 * declared no valid interrupt lines.
931 * Return: Zero when successful, a negative error code otherwise.
933 static int zpa2326_poll_oneshot_completion(const struct iio_dev
*indio_dev
)
935 unsigned long tmout
= jiffies
+ ZPA2326_CONVERSION_JIFFIES
;
936 struct regmap
*regs
= ((struct zpa2326_private
*)
937 iio_priv(indio_dev
))->regmap
;
941 zpa2326_dbg(indio_dev
, "polling for one shot completion");
944 * At least, 100 ms is needed for the device to complete its one-shot
947 if (msleep_interruptible(100))
950 /* Poll for conversion completion in hardware. */
952 err
= regmap_read(regs
, ZPA2326_CTRL_REG0_REG
, &val
);
956 if (!(val
& ZPA2326_CTRL_REG0_ONE_SHOT
))
957 /* One-shot bit self clears at conversion end. */
960 if (time_after(jiffies
, tmout
)) {
961 /* Prevent from waiting forever : let's time out. */
966 usleep_range(10000, 20000);
970 * In oneshot mode, pressure sample availability guarantees that
971 * temperature conversion has also completed : just check pressure
972 * status bit to keep things simple.
974 err
= regmap_read(regs
, ZPA2326_STATUS_REG
, &val
);
978 if (!(val
& ZPA2326_STATUS_P_DA
)) {
979 /* No sample available. */
987 zpa2326_warn(indio_dev
, "failed to poll one shot completion (%d)", err
);
993 * zpa2326_fetch_raw_sample() - Retrieve a raw sample and convert it to CPU
995 * @indio_dev: The IIO device associated with the sampling hardware.
996 * @type: Type of measurement / channel to fetch from.
997 * @value: Sample output.
999 * Return: Zero when successful, a negative error code otherwise.
1001 static int zpa2326_fetch_raw_sample(const struct iio_dev
*indio_dev
,
1002 enum iio_chan_type type
,
1005 struct regmap
*regs
= ((struct zpa2326_private
*)
1006 iio_priv(indio_dev
))->regmap
;
1011 zpa2326_dbg(indio_dev
, "fetching raw pressure sample");
1013 err
= regmap_bulk_read(regs
, ZPA2326_PRESS_OUT_XL_REG
, value
,
1016 zpa2326_warn(indio_dev
, "failed to fetch pressure (%d)",
1021 /* Pressure is a 24 bits wide little-endian unsigned int. */
1022 *value
= (((u8
*)value
)[2] << 16) | (((u8
*)value
)[1] << 8) |
1028 zpa2326_dbg(indio_dev
, "fetching raw temperature sample");
1030 err
= regmap_bulk_read(regs
, ZPA2326_TEMP_OUT_L_REG
, value
, 2);
1032 zpa2326_warn(indio_dev
,
1033 "failed to fetch temperature (%d)", err
);
1037 /* Temperature is a 16 bits wide little-endian signed int. */
1038 *value
= (int)le16_to_cpup((__le16
*)value
);
1048 * zpa2326_sample_oneshot() - Perform a complete one shot sampling cycle.
1049 * @indio_dev: The IIO device associated with the sampling hardware.
1050 * @type: Type of measurement / channel to fetch from.
1051 * @value: Sample output.
1053 * Return: Zero when successful, a negative error code otherwise.
1055 static int zpa2326_sample_oneshot(struct iio_dev
*indio_dev
,
1056 enum iio_chan_type type
,
1060 struct zpa2326_private
*priv
;
1062 ret
= iio_device_claim_direct_mode(indio_dev
);
1066 ret
= zpa2326_resume(indio_dev
);
1070 priv
= iio_priv(indio_dev
);
1074 * We were already power supplied. Just clear hardware FIFO to
1075 * get rid of samples acquired during previous rounds (if any).
1076 * Sampling operation always generates both temperature and
1077 * pressure samples. The latter are always enqueued into
1078 * hardware FIFO. This may lead to situations were pressure
1079 * samples still sit into FIFO when previous cycle(s) fetched
1080 * temperature data only.
1081 * Hence, we need to clear hardware FIFO content to prevent from
1082 * getting outdated values at the end of current cycle.
1084 if (type
== IIO_PRESSURE
) {
1085 ret
= zpa2326_clear_fifo(indio_dev
, 0);
1091 * We have just been power supplied, i.e. device is in default
1092 * "out of reset" state, meaning we need to reconfigure it
1095 ret
= zpa2326_config_oneshot(indio_dev
, priv
->irq
);
1100 /* Start a sampling cycle in oneshot mode. */
1101 ret
= zpa2326_start_oneshot(indio_dev
);
1105 /* Wait for sampling cycle to complete. */
1107 ret
= zpa2326_wait_oneshot_completion(indio_dev
, priv
);
1109 ret
= zpa2326_poll_oneshot_completion(indio_dev
);
1114 /* Retrieve raw sample value and convert it to CPU endianness. */
1115 ret
= zpa2326_fetch_raw_sample(indio_dev
, type
, value
);
1118 zpa2326_suspend(indio_dev
);
1120 iio_device_release_direct_mode(indio_dev
);
1126 * zpa2326_trigger_handler() - Perform an IIO buffered sampling round in one
1128 * @irq: The software interrupt assigned to @data
1129 * @data: The IIO poll function dispatched by external trigger our device is
1132 * Bottom-half handler called by the IIO trigger to which our device is
1133 * currently attached. Allows us to synchronize this device buffered sampling
1134 * either with external events (such as timer expiration, external device sample
1135 * ready, etc...) or with its own interrupt (internal hardware trigger).
1137 * When using an external trigger, basically run the same sequence of operations
1138 * as for zpa2326_sample_oneshot() with the following hereafter. Hardware FIFO
1139 * is not cleared since already done at buffering enable time and samples
1140 * dequeueing always retrieves the most recent value.
1142 * Otherwise, when internal hardware trigger has dispatched us, just fetch data
1143 * from hardware FIFO.
1145 * Fetched data will pushed unprocessed to IIO buffer since samples conversion
1146 * is delegated to userspace in buffered mode (endianness, etc...).
1149 * %IRQ_NONE - no consistent interrupt happened ;
1150 * %IRQ_HANDLED - there was new samples available.
1152 static irqreturn_t
zpa2326_trigger_handler(int irq
, void *data
)
1154 struct iio_dev
*indio_dev
= ((struct iio_poll_func
*)
1156 struct zpa2326_private
*priv
= iio_priv(indio_dev
);
1160 * We have been dispatched, meaning we are in triggered buffer mode.
1161 * Using our own internal trigger implies we are currently in continuous
1162 * hardware sampling mode.
1164 cont
= iio_trigger_using_own(indio_dev
);
1167 /* On demand sampling : start a one shot cycle. */
1168 if (zpa2326_start_oneshot(indio_dev
))
1171 /* Wait for sampling cycle to complete. */
1172 if (priv
->irq
<= 0) {
1173 /* No interrupt available: poll for completion. */
1174 if (zpa2326_poll_oneshot_completion(indio_dev
))
1177 /* Only timestamp sample once it is ready. */
1178 priv
->timestamp
= iio_get_time_ns(indio_dev
);
1180 /* Interrupt handlers will timestamp for us. */
1181 if (zpa2326_wait_oneshot_completion(indio_dev
, priv
))
1186 /* Enqueue to IIO buffer / userspace. */
1187 zpa2326_fill_sample_buffer(indio_dev
, priv
);
1191 /* Don't switch to low power if sampling continuously. */
1192 zpa2326_sleep(indio_dev
);
1194 /* Inform attached trigger we are done. */
1195 iio_trigger_notify_done(indio_dev
->trig
);
1201 * zpa2326_preenable_buffer() - Prepare device for configuring triggered
1204 * @indio_dev: The IIO device associated with the sampling hardware.
1206 * Basically power up device.
1207 * Called with IIO device's lock held.
1209 * Return: Zero when successful, a negative error code otherwise.
1211 static int zpa2326_preenable_buffer(struct iio_dev
*indio_dev
)
1213 int ret
= zpa2326_resume(indio_dev
);
1218 /* Tell zpa2326_postenable_buffer() if we have just been powered on. */
1219 ((struct zpa2326_private
*)
1220 iio_priv(indio_dev
))->waken
= iio_priv(indio_dev
);
1226 * zpa2326_postenable_buffer() - Configure device for triggered sampling.
1227 * @indio_dev: The IIO device associated with the sampling hardware.
1229 * Basically setup one-shot mode if plugging external trigger.
1230 * Otherwise, let internal trigger configure continuous sampling :
1231 * see zpa2326_set_trigger_state().
1233 * If an error is returned, IIO layer will call our postdisable hook for us,
1234 * i.e. no need to explicitly power device off here.
1235 * Called with IIO device's lock held.
1237 * Called with IIO device's lock held.
1239 * Return: Zero when successful, a negative error code otherwise.
1241 static int zpa2326_postenable_buffer(struct iio_dev
*indio_dev
)
1243 const struct zpa2326_private
*priv
= iio_priv(indio_dev
);
1246 /* Plug our own trigger event handler. */
1247 err
= iio_triggered_buffer_postenable(indio_dev
);
1253 * We were already power supplied. Just clear hardware FIFO to
1254 * get rid of samples acquired during previous rounds (if any).
1256 err
= zpa2326_clear_fifo(indio_dev
, 0);
1258 goto err_buffer_predisable
;
1261 if (!iio_trigger_using_own(indio_dev
) && priv
->waken
) {
1263 * We are using an external trigger and we have just been
1264 * powered up: reconfigure one-shot mode.
1266 err
= zpa2326_config_oneshot(indio_dev
, priv
->irq
);
1268 goto err_buffer_predisable
;
1273 err_buffer_predisable
:
1274 iio_triggered_buffer_predisable(indio_dev
);
1276 zpa2326_err(indio_dev
, "failed to enable buffering (%d)", err
);
1281 static int zpa2326_postdisable_buffer(struct iio_dev
*indio_dev
)
1283 zpa2326_suspend(indio_dev
);
1288 static const struct iio_buffer_setup_ops zpa2326_buffer_setup_ops
= {
1289 .preenable
= zpa2326_preenable_buffer
,
1290 .postenable
= zpa2326_postenable_buffer
,
1291 .predisable
= iio_triggered_buffer_predisable
,
1292 .postdisable
= zpa2326_postdisable_buffer
1296 * zpa2326_set_trigger_state() - Start / stop continuous sampling.
1297 * @trig: The trigger being attached to IIO device associated with the sampling
1299 * @state: Tell whether to start (true) or stop (false)
1301 * Basically enable / disable hardware continuous sampling mode.
1303 * Called with IIO device's lock held at postenable() or predisable() time.
1305 * Return: Zero when successful, a negative error code otherwise.
1307 static int zpa2326_set_trigger_state(struct iio_trigger
*trig
, bool state
)
1309 const struct iio_dev
*indio_dev
= dev_get_drvdata(
1311 const struct zpa2326_private
*priv
= iio_priv(indio_dev
);
1316 * Switch trigger off : in case of failure, interrupt is left
1317 * disabled in order to prevent handler from accessing released
1323 * As device is working in continuous mode, handlers may be
1324 * accessing resources we are currently freeing...
1325 * Prevent this by disabling interrupt handlers and ensure
1326 * the device will generate no more interrupts unless explicitly
1327 * required to, i.e. by restoring back to default one shot mode.
1329 disable_irq(priv
->irq
);
1332 * Disable continuous sampling mode to restore settings for
1333 * one shot / direct sampling operations.
1335 err
= regmap_write(priv
->regmap
, ZPA2326_CTRL_REG3_REG
,
1336 zpa2326_highest_frequency()->odr
);
1341 * Now that device won't generate interrupts on its own,
1342 * acknowledge any currently active interrupts (may happen on
1343 * rare occasions while stopping continuous mode).
1345 err
= regmap_read(priv
->regmap
, ZPA2326_INT_SOURCE_REG
, &val
);
1350 * Re-enable interrupts only if we can guarantee the device will
1351 * generate no more interrupts to prevent handlers from
1352 * accessing released resources.
1354 enable_irq(priv
->irq
);
1356 zpa2326_dbg(indio_dev
, "continuous mode stopped");
1359 * Switch trigger on : start continuous sampling at required
1364 /* Enable interrupt if getting out of reset. */
1365 err
= regmap_write(priv
->regmap
, ZPA2326_CTRL_REG1_REG
,
1367 ~ZPA2326_CTRL_REG1_MASK_DATA_READY
);
1372 /* Enable continuous sampling at specified frequency. */
1373 err
= regmap_write(priv
->regmap
, ZPA2326_CTRL_REG3_REG
,
1374 ZPA2326_CTRL_REG3_ENABLE_MEAS
|
1375 priv
->frequency
->odr
);
1379 zpa2326_dbg(indio_dev
, "continuous mode setup @%dHz",
1380 priv
->frequency
->hz
);
1386 static const struct iio_trigger_ops zpa2326_trigger_ops
= {
1387 .set_trigger_state
= zpa2326_set_trigger_state
,
1391 * zpa2326_init_trigger() - Create an interrupt driven / hardware trigger
1392 * allowing to notify external devices a new sample is
1394 * @parent: Hardware sampling device @indio_dev is a child of.
1395 * @indio_dev: The IIO device associated with the sampling hardware.
1396 * @private: Internal private state related to @indio_dev.
1397 * @irq: Optional interrupt line the hardware uses to notify new data
1398 * samples are ready. Negative or zero values indicate no interrupts
1399 * are available, meaning polling is required.
1401 * Only relevant when DT declares a valid interrupt line.
1403 * Return: Zero when successful, a negative error code otherwise.
1405 static int zpa2326_init_managed_trigger(struct device
*parent
,
1406 struct iio_dev
*indio_dev
,
1407 struct zpa2326_private
*private,
1410 struct iio_trigger
*trigger
;
1416 trigger
= devm_iio_trigger_alloc(parent
, "%s-dev%d",
1417 indio_dev
->name
, indio_dev
->id
);
1422 trigger
->dev
.parent
= parent
;
1423 trigger
->ops
= &zpa2326_trigger_ops
;
1425 private->trigger
= trigger
;
1427 /* Register to triggers space. */
1428 ret
= devm_iio_trigger_register(parent
, trigger
);
1430 dev_err(parent
, "failed to register hardware trigger (%d)",
1436 static int zpa2326_get_frequency(const struct iio_dev
*indio_dev
)
1438 return ((struct zpa2326_private
*)iio_priv(indio_dev
))->frequency
->hz
;
1441 static int zpa2326_set_frequency(struct iio_dev
*indio_dev
, int hz
)
1443 struct zpa2326_private
*priv
= iio_priv(indio_dev
);
1447 /* Check if requested frequency is supported. */
1448 for (freq
= 0; freq
< ARRAY_SIZE(zpa2326_sampling_frequencies
); freq
++)
1449 if (zpa2326_sampling_frequencies
[freq
].hz
== hz
)
1451 if (freq
== ARRAY_SIZE(zpa2326_sampling_frequencies
))
1454 /* Don't allow changing frequency if buffered sampling is ongoing. */
1455 err
= iio_device_claim_direct_mode(indio_dev
);
1459 priv
->frequency
= &zpa2326_sampling_frequencies
[freq
];
1461 iio_device_release_direct_mode(indio_dev
);
1466 /* Expose supported hardware sampling frequencies (Hz) through sysfs. */
1467 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("1 5 11 23");
1469 static struct attribute
*zpa2326_attributes
[] = {
1470 &iio_const_attr_sampling_frequency_available
.dev_attr
.attr
,
1474 static const struct attribute_group zpa2326_attribute_group
= {
1475 .attrs
= zpa2326_attributes
,
1478 static int zpa2326_read_raw(struct iio_dev
*indio_dev
,
1479 struct iio_chan_spec
const *chan
,
1485 case IIO_CHAN_INFO_RAW
:
1486 return zpa2326_sample_oneshot(indio_dev
, chan
->type
, val
);
1488 case IIO_CHAN_INFO_SCALE
:
1489 switch (chan
->type
) {
1492 * Pressure resolution is 1/64 Pascal. Scale to kPascal
1493 * as required by IIO ABI.
1497 return IIO_VAL_FRACTIONAL
;
1501 * Temperature follows the equation:
1502 * Temp[degC] = Tempcode * 0.00649 - 176.83
1504 * Tempcode is composed the raw sampled 16 bits.
1506 * Hence, to produce a temperature in milli-degrees
1507 * Celsius according to IIO ABI, we need to apply the
1508 * following equation to raw samples:
1509 * Temp[milli degC] = (Tempcode + Offset) * Scale
1511 * Offset = -176.83 / 0.00649
1512 * Scale = 0.00649 * 1000
1516 return IIO_VAL_INT_PLUS_MICRO
;
1522 case IIO_CHAN_INFO_OFFSET
:
1523 switch (chan
->type
) {
1527 return IIO_VAL_FRACTIONAL
;
1533 case IIO_CHAN_INFO_SAMP_FREQ
:
1534 *val
= zpa2326_get_frequency(indio_dev
);
1542 static int zpa2326_write_raw(struct iio_dev
*indio_dev
,
1543 const struct iio_chan_spec
*chan
,
1548 if ((mask
!= IIO_CHAN_INFO_SAMP_FREQ
) || val2
)
1551 return zpa2326_set_frequency(indio_dev
, val
);
1554 static const struct iio_chan_spec zpa2326_channels
[] = {
1556 .type
= IIO_PRESSURE
,
1562 .endianness
= IIO_LE
,
1564 .info_mask_separate
= BIT(IIO_CHAN_INFO_RAW
) |
1565 BIT(IIO_CHAN_INFO_SCALE
),
1566 .info_mask_shared_by_all
= BIT(IIO_CHAN_INFO_SAMP_FREQ
),
1575 .endianness
= IIO_LE
,
1577 .info_mask_separate
= BIT(IIO_CHAN_INFO_RAW
) |
1578 BIT(IIO_CHAN_INFO_SCALE
) |
1579 BIT(IIO_CHAN_INFO_OFFSET
),
1580 .info_mask_shared_by_all
= BIT(IIO_CHAN_INFO_SAMP_FREQ
),
1582 [2] = IIO_CHAN_SOFT_TIMESTAMP(2),
1585 static const struct iio_info zpa2326_info
= {
1586 .attrs
= &zpa2326_attribute_group
,
1587 .read_raw
= zpa2326_read_raw
,
1588 .write_raw
= zpa2326_write_raw
,
1591 static struct iio_dev
*zpa2326_create_managed_iiodev(struct device
*device
,
1593 struct regmap
*regmap
)
1595 struct iio_dev
*indio_dev
;
1597 /* Allocate space to hold IIO device internal state. */
1598 indio_dev
= devm_iio_device_alloc(device
,
1599 sizeof(struct zpa2326_private
));
1603 /* Setup for userspace synchronous on demand sampling. */
1604 indio_dev
->modes
= INDIO_DIRECT_MODE
;
1605 indio_dev
->dev
.parent
= device
;
1606 indio_dev
->channels
= zpa2326_channels
;
1607 indio_dev
->num_channels
= ARRAY_SIZE(zpa2326_channels
);
1608 indio_dev
->name
= name
;
1609 indio_dev
->info
= &zpa2326_info
;
1614 int zpa2326_probe(struct device
*parent
,
1618 struct regmap
*regmap
)
1620 struct iio_dev
*indio_dev
;
1621 struct zpa2326_private
*priv
;
1625 indio_dev
= zpa2326_create_managed_iiodev(parent
, name
, regmap
);
1629 priv
= iio_priv(indio_dev
);
1631 priv
->vref
= devm_regulator_get(parent
, "vref");
1632 if (IS_ERR(priv
->vref
))
1633 return PTR_ERR(priv
->vref
);
1635 priv
->vdd
= devm_regulator_get(parent
, "vdd");
1636 if (IS_ERR(priv
->vdd
))
1637 return PTR_ERR(priv
->vdd
);
1639 /* Set default hardware sampling frequency to highest rate supported. */
1640 priv
->frequency
= zpa2326_highest_frequency();
1643 * Plug device's underlying bus abstraction : this MUST be set before
1644 * registering interrupt handlers since an interrupt might happen if
1645 * power up sequence is not properly applied.
1647 priv
->regmap
= regmap
;
1649 err
= devm_iio_triggered_buffer_setup(parent
, indio_dev
, NULL
,
1650 zpa2326_trigger_handler
,
1651 &zpa2326_buffer_setup_ops
);
1655 err
= zpa2326_init_managed_trigger(parent
, indio_dev
, priv
, irq
);
1659 err
= zpa2326_init_managed_irq(parent
, indio_dev
, priv
, irq
);
1663 /* Power up to check device ID and perform initial hardware setup. */
1664 err
= zpa2326_power_on(indio_dev
, priv
);
1668 /* Read id register to check we are talking to the right slave. */
1669 err
= regmap_read(regmap
, ZPA2326_DEVICE_ID_REG
, &id
);
1674 dev_err(parent
, "found device with unexpected id %02x", id
);
1679 err
= zpa2326_config_oneshot(indio_dev
, irq
);
1683 /* Setup done : go sleeping. Device will be awaken upon user request. */
1684 err
= zpa2326_sleep(indio_dev
);
1688 dev_set_drvdata(parent
, indio_dev
);
1690 zpa2326_init_runtime(parent
);
1692 err
= iio_device_register(indio_dev
);
1694 zpa2326_fini_runtime(parent
);
1701 /* Put to sleep just in case power regulators are "dummy" ones. */
1702 zpa2326_sleep(indio_dev
);
1704 zpa2326_power_off(indio_dev
, priv
);
1708 EXPORT_SYMBOL_GPL(zpa2326_probe
);
1710 void zpa2326_remove(const struct device
*parent
)
1712 struct iio_dev
*indio_dev
= dev_get_drvdata(parent
);
1714 iio_device_unregister(indio_dev
);
1715 zpa2326_fini_runtime(indio_dev
->dev
.parent
);
1716 zpa2326_sleep(indio_dev
);
1717 zpa2326_power_off(indio_dev
, iio_priv(indio_dev
));
1719 EXPORT_SYMBOL_GPL(zpa2326_remove
);
1721 MODULE_AUTHOR("Gregor Boirie <gregor.boirie@parrot.com>");
1722 MODULE_DESCRIPTION("Core driver for Murata ZPA2326 pressure sensor");
1723 MODULE_LICENSE("GPL v2");