summaryrefslogtreecommitdiffstats
path: root/drivers/iio/dummy/iio_simple_dummy.h
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-12-01 09:13:29 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-12-01 09:13:29 -0800
commitf3cf3fb7ec854c2b2429e5bb23186746e6511dae (patch)
treeb4e71d2a6422ca33a95f9a1e0458ab90c3b89846 /drivers/iio/dummy/iio_simple_dummy.h
parentf84a187019ccfce97fbf38fa9f3a8261fef91d8e (diff)
parent4ac4e086fd8c59e6b69089e6f7605500b63a6d17 (diff)
downloadlinux-f3cf3fb7ec854c2b2429e5bb23186746e6511dae.tar.bz2
Merge tag 'iio-for-4.5a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes: First set of new device support, features and cleanups for IIO in the 4.5 cycle Usual mixed bag, but the big item perhaps in this series is the DMA buffer support added by Lars-Peter Clausen. It's been in the works for a long time and it will be interesting to see what hardware support shows up now that this is available. New core features + associate cleanup. * Add generic DMA buffer infrastructure * Add a DMAengine framework based buffer Also associated minor changes. - Set the device buffer watermark based on the minimum watermark for all attached buffers rather than just the 'primary' one. - iio_buffer_init - only set the watermark default if one hasn't already been provided. This allows simple support for devices with a fixed watermark. - read only attribute for watermark on fixed watermark devices. - add explicit buffer enable/disable callbacks to allow the buffer to do more than trivial actions when it is being turned on and off. * IIO_VAL_INT support in write_raw_get_fmt function. New device support * Freescale MMA7455/7456L accelerometers * Memsic MXC6255XC accelerometer * ST lis2dh12 accelerometer * TI ADS8688 ADC * TI Palamas (twl6035/7) gpadc New driver features * mma8452 - support either of the available interrupt pins to cope with the case where board layout has lead to a particular one being connected. Staging graduation * Dummy driver - this driver acts as both an example and a test device for those with out hardware to develop userspace code against. Cleanups and minor bits and bobs. * treewide - Sort out the ordering of iio_device_register/unregister vs runtime pm function calls so that it's all nice and consistent and not race prone. - Check sscanf return values. None of the cases will actually happen as the strings are supplied internally, but best to be consistent on this. * ad7780 - switch over to the gpio descriptor interface and remove the now unused platform data which gets rid of a header entirely. * ad7793 - drop a pointless else statement. * at91_adc - Swap kmalloc_array in for a kmalloc doing the same job. * dummy - get rid of some commented out lines that snuck in during the move of the driver. * lm3533-als - Print an error message on provision of an invalid resistance. * mcp320x - Add compatible strings with vendor prefix and deprecate those with no vendor prefix. * mxs-lradc - Use BIT macro in various places rather than shifted ones. * pa12203001 - Power off the chip if the registration fails. * pulsedlight-lidar-lite - add runtime PM support. * xilinx XADC - constify an iio_buffer_setup_ops structure.
Diffstat (limited to 'drivers/iio/dummy/iio_simple_dummy.h')
-rw-r--r--drivers/iio/dummy/iio_simple_dummy.h129
1 files changed, 129 insertions, 0 deletions
diff --git a/drivers/iio/dummy/iio_simple_dummy.h b/drivers/iio/dummy/iio_simple_dummy.h
new file mode 100644
index 000000000000..b9069a180672
--- /dev/null
+++ b/drivers/iio/dummy/iio_simple_dummy.h
@@ -0,0 +1,129 @@
+/**
+ * Copyright (c) 2011 Jonathan Cameron
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * Join together the various functionality of iio_simple_dummy driver
+ */
+
+#ifndef _IIO_SIMPLE_DUMMY_H_
+#define _IIO_SIMPLE_DUMMY_H_
+#include <linux/kernel.h>
+
+struct iio_dummy_accel_calibscale;
+struct iio_dummy_regs;
+
+/**
+ * struct iio_dummy_state - device instance specific state.
+ * @dac_val: cache for dac value
+ * @single_ended_adc_val: cache for single ended adc value
+ * @differential_adc_val: cache for differential adc value
+ * @accel_val: cache for acceleration value
+ * @accel_calibbias: cache for acceleration calibbias
+ * @accel_calibscale: cache for acceleration calibscale
+ * @lock: lock to ensure state is consistent
+ * @event_irq: irq number for event line (faked)
+ * @event_val: cache for event threshold value
+ * @event_en: cache of whether event is enabled
+ */
+struct iio_dummy_state {
+ int dac_val;
+ int single_ended_adc_val;
+ int differential_adc_val[2];
+ int accel_val;
+ int accel_calibbias;
+ int activity_running;
+ int activity_walking;
+ const struct iio_dummy_accel_calibscale *accel_calibscale;
+ struct mutex lock;
+ struct iio_dummy_regs *regs;
+ int steps_enabled;
+ int steps;
+ int height;
+#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
+ int event_irq;
+ int event_val;
+ bool event_en;
+ s64 event_timestamp;
+#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
+};
+
+#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
+
+struct iio_dev;
+
+int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir);
+
+int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ int state);
+
+int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info, int *val,
+ int *val2);
+
+int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info, int val,
+ int val2);
+
+int iio_simple_dummy_events_register(struct iio_dev *indio_dev);
+void iio_simple_dummy_events_unregister(struct iio_dev *indio_dev);
+
+#else /* Stubs for when events are disabled at compile time */
+
+static inline int
+iio_simple_dummy_events_register(struct iio_dev *indio_dev)
+{
+ return 0;
+};
+
+static inline void
+iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)
+{ };
+
+#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/
+
+/**
+ * enum iio_simple_dummy_scan_elements - scan index enum
+ * @DUMMY_INDEX_VOLTAGE_0: the single ended voltage channel
+ * @DUMMY_INDEX_DIFFVOLTAGE_1M2: first differential channel
+ * @DUMMY_INDEX_DIFFVOLTAGE_3M4: second differential channel
+ * @DUMMY_INDEX_ACCELX: acceleration channel
+ *
+ * Enum provides convenient numbering for the scan index.
+ */
+enum iio_simple_dummy_scan_elements {
+ DUMMY_INDEX_VOLTAGE_0,
+ DUMMY_INDEX_DIFFVOLTAGE_1M2,
+ DUMMY_INDEX_DIFFVOLTAGE_3M4,
+ DUMMY_INDEX_ACCELX,
+};
+
+#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
+int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev);
+void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev);
+#else
+static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
+{
+ return 0;
+};
+
+static inline
+void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
+{};
+
+#endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */
+#endif /* _IIO_SIMPLE_DUMMY_H_ */