diff options
| author | Mark Brown <broonie@linaro.org> | 2013-11-24 09:35:18 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@linaro.org> | 2013-11-24 09:35:18 -0500 |
| commit | 30c27abd28fa168d7ebd2e5286f1fe473c74bfa9 (patch) | |
| tree | 9936b38c0c81cd430d5e75906c1207d127fe588c /include/linux/iio | |
| parent | 16ec790938d4f356c82fab27b9a9adf4d6fe19a6 (diff) | |
| parent | 6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff) | |
Merge tag 'v3.13-rc1' into asoc-arizona
Linux 3.13-rc1
Diffstat (limited to 'include/linux/iio')
| -rw-r--r-- | include/linux/iio/buffer.h | 61 | ||||
| -rw-r--r-- | include/linux/iio/common/st_sensors.h | 6 | ||||
| -rw-r--r-- | include/linux/iio/consumer.h | 2 | ||||
| -rw-r--r-- | include/linux/iio/events.h | 14 | ||||
| -rw-r--r-- | include/linux/iio/iio.h | 93 | ||||
| -rw-r--r-- | include/linux/iio/sysfs.h | 15 | ||||
| -rw-r--r-- | include/linux/iio/types.h | 20 |
7 files changed, 180 insertions, 31 deletions
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h index 2bac0eb8948d..15607b45221a 100644 --- a/include/linux/iio/buffer.h +++ b/include/linux/iio/buffer.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #define _IIO_BUFFER_GENERIC_H_ | 11 | #define _IIO_BUFFER_GENERIC_H_ |
| 12 | #include <linux/sysfs.h> | 12 | #include <linux/sysfs.h> |
| 13 | #include <linux/iio/iio.h> | 13 | #include <linux/iio/iio.h> |
| 14 | #include <linux/kref.h> | ||
| 14 | 15 | ||
| 15 | #ifdef CONFIG_IIO_BUFFER | 16 | #ifdef CONFIG_IIO_BUFFER |
| 16 | 17 | ||
| @@ -26,6 +27,8 @@ struct iio_buffer; | |||
| 26 | * @set_bytes_per_datum:set number of bytes per datum | 27 | * @set_bytes_per_datum:set number of bytes per datum |
| 27 | * @get_length: get number of datums in buffer | 28 | * @get_length: get number of datums in buffer |
| 28 | * @set_length: set number of datums in buffer | 29 | * @set_length: set number of datums in buffer |
| 30 | * @release: called when the last reference to the buffer is dropped, | ||
| 31 | * should free all resources allocated by the buffer. | ||
| 29 | * | 32 | * |
| 30 | * The purpose of this structure is to make the buffer element | 33 | * The purpose of this structure is to make the buffer element |
| 31 | * modular as event for a given driver, different usecases may require | 34 | * modular as event for a given driver, different usecases may require |
| @@ -36,7 +39,7 @@ struct iio_buffer; | |||
| 36 | * any of them not existing. | 39 | * any of them not existing. |
| 37 | **/ | 40 | **/ |
| 38 | struct iio_buffer_access_funcs { | 41 | struct iio_buffer_access_funcs { |
| 39 | int (*store_to)(struct iio_buffer *buffer, u8 *data); | 42 | int (*store_to)(struct iio_buffer *buffer, const void *data); |
| 40 | int (*read_first_n)(struct iio_buffer *buffer, | 43 | int (*read_first_n)(struct iio_buffer *buffer, |
| 41 | size_t n, | 44 | size_t n, |
| 42 | char __user *buf); | 45 | char __user *buf); |
| @@ -47,6 +50,8 @@ struct iio_buffer_access_funcs { | |||
| 47 | int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd); | 50 | int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd); |
| 48 | int (*get_length)(struct iio_buffer *buffer); | 51 | int (*get_length)(struct iio_buffer *buffer); |
| 49 | int (*set_length)(struct iio_buffer *buffer, int length); | 52 | int (*set_length)(struct iio_buffer *buffer, int length); |
| 53 | |||
| 54 | void (*release)(struct iio_buffer *buffer); | ||
| 50 | }; | 55 | }; |
| 51 | 56 | ||
| 52 | /** | 57 | /** |
| @@ -67,6 +72,7 @@ struct iio_buffer_access_funcs { | |||
| 67 | * @demux_list: [INTERN] list of operations required to demux the scan. | 72 | * @demux_list: [INTERN] list of operations required to demux the scan. |
| 68 | * @demux_bounce: [INTERN] buffer for doing gather from incoming scan. | 73 | * @demux_bounce: [INTERN] buffer for doing gather from incoming scan. |
| 69 | * @buffer_list: [INTERN] entry in the devices list of current buffers. | 74 | * @buffer_list: [INTERN] entry in the devices list of current buffers. |
| 75 | * @ref: [INTERN] reference count of the buffer. | ||
| 70 | */ | 76 | */ |
| 71 | struct iio_buffer { | 77 | struct iio_buffer { |
| 72 | int length; | 78 | int length; |
| @@ -81,8 +87,9 @@ struct iio_buffer { | |||
| 81 | bool stufftoread; | 87 | bool stufftoread; |
| 82 | const struct attribute_group *attrs; | 88 | const struct attribute_group *attrs; |
| 83 | struct list_head demux_list; | 89 | struct list_head demux_list; |
| 84 | unsigned char *demux_bounce; | 90 | void *demux_bounce; |
| 85 | struct list_head buffer_list; | 91 | struct list_head buffer_list; |
| 92 | struct kref ref; | ||
| 86 | }; | 93 | }; |
| 87 | 94 | ||
| 88 | /** | 95 | /** |
| @@ -120,7 +127,32 @@ int iio_scan_mask_set(struct iio_dev *indio_dev, | |||
| 120 | * @indio_dev: iio_dev structure for device. | 127 | * @indio_dev: iio_dev structure for device. |
| 121 | * @data: Full scan. | 128 | * @data: Full scan. |
| 122 | */ | 129 | */ |
| 123 | int iio_push_to_buffers(struct iio_dev *indio_dev, unsigned char *data); | 130 | int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data); |
| 131 | |||
| 132 | /* | ||
| 133 | * iio_push_to_buffers_with_timestamp() - push data and timestamp to buffers | ||
| 134 | * @indio_dev: iio_dev structure for device. | ||
| 135 | * @data: sample data | ||
| 136 | * @timestamp: timestamp for the sample data | ||
| 137 | * | ||
| 138 | * Pushes data to the IIO device's buffers. If timestamps are enabled for the | ||
| 139 | * device the function will store the supplied timestamp as the last element in | ||
| 140 | * the sample data buffer before pushing it to the device buffers. The sample | ||
| 141 | * data buffer needs to be large enough to hold the additional timestamp | ||
| 142 | * (usually the buffer should be indio->scan_bytes bytes large). | ||
| 143 | * | ||
| 144 | * Returns 0 on success, a negative error code otherwise. | ||
| 145 | */ | ||
| 146 | static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev, | ||
| 147 | void *data, int64_t timestamp) | ||
| 148 | { | ||
| 149 | if (indio_dev->scan_timestamp) { | ||
| 150 | size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1; | ||
| 151 | ((int64_t *)data)[ts_offset] = timestamp; | ||
| 152 | } | ||
| 153 | |||
| 154 | return iio_push_to_buffers(indio_dev, data); | ||
| 155 | } | ||
| 124 | 156 | ||
| 125 | int iio_update_demux(struct iio_dev *indio_dev); | 157 | int iio_update_demux(struct iio_dev *indio_dev); |
| 126 | 158 | ||
| @@ -174,11 +206,27 @@ ssize_t iio_buffer_show_enable(struct device *dev, | |||
| 174 | iio_buffer_show_enable, \ | 206 | iio_buffer_show_enable, \ |
| 175 | iio_buffer_store_enable) | 207 | iio_buffer_store_enable) |
| 176 | 208 | ||
| 177 | int iio_sw_buffer_preenable(struct iio_dev *indio_dev); | ||
| 178 | |||
| 179 | bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev, | 209 | bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev, |
| 180 | const unsigned long *mask); | 210 | const unsigned long *mask); |
| 181 | 211 | ||
| 212 | struct iio_buffer *iio_buffer_get(struct iio_buffer *buffer); | ||
| 213 | void iio_buffer_put(struct iio_buffer *buffer); | ||
| 214 | |||
| 215 | /** | ||
| 216 | * iio_device_attach_buffer - Attach a buffer to a IIO device | ||
| 217 | * @indio_dev: The device the buffer should be attached to | ||
| 218 | * @buffer: The buffer to attach to the device | ||
| 219 | * | ||
| 220 | * This function attaches a buffer to a IIO device. The buffer stays attached to | ||
| 221 | * the device until the device is freed. The function should only be called at | ||
| 222 | * most once per device. | ||
| 223 | */ | ||
| 224 | static inline void iio_device_attach_buffer(struct iio_dev *indio_dev, | ||
| 225 | struct iio_buffer *buffer) | ||
| 226 | { | ||
| 227 | indio_dev->buffer = iio_buffer_get(buffer); | ||
| 228 | } | ||
| 229 | |||
| 182 | #else /* CONFIG_IIO_BUFFER */ | 230 | #else /* CONFIG_IIO_BUFFER */ |
| 183 | 231 | ||
| 184 | static inline int iio_buffer_register(struct iio_dev *indio_dev, | 232 | static inline int iio_buffer_register(struct iio_dev *indio_dev, |
| @@ -191,6 +239,9 @@ static inline int iio_buffer_register(struct iio_dev *indio_dev, | |||
| 191 | static inline void iio_buffer_unregister(struct iio_dev *indio_dev) | 239 | static inline void iio_buffer_unregister(struct iio_dev *indio_dev) |
| 192 | {} | 240 | {} |
| 193 | 241 | ||
| 242 | static inline void iio_buffer_get(struct iio_buffer *buffer) {} | ||
| 243 | static inline void iio_buffer_put(struct iio_buffer *buffer) {} | ||
| 244 | |||
| 194 | #endif /* CONFIG_IIO_BUFFER */ | 245 | #endif /* CONFIG_IIO_BUFFER */ |
| 195 | 246 | ||
| 196 | #endif /* _IIO_BUFFER_GENERIC_H_ */ | 247 | #endif /* _IIO_BUFFER_GENERIC_H_ */ |
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index e51f65480ea5..3c005eb3a0a4 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <linux/irqreturn.h> | 16 | #include <linux/irqreturn.h> |
| 17 | #include <linux/iio/trigger.h> | 17 | #include <linux/iio/trigger.h> |
| 18 | #include <linux/bitops.h> | 18 | #include <linux/bitops.h> |
| 19 | #include <linux/regulator/consumer.h> | ||
| 19 | 20 | ||
| 20 | #include <linux/platform_data/st_sensors_pdata.h> | 21 | #include <linux/platform_data/st_sensors_pdata.h> |
| 21 | 22 | ||
| @@ -184,6 +185,7 @@ struct st_sensors { | |||
| 184 | u8 wai; | 185 | u8 wai; |
| 185 | char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME]; | 186 | char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME]; |
| 186 | struct iio_chan_spec *ch; | 187 | struct iio_chan_spec *ch; |
| 188 | int num_ch; | ||
| 187 | struct st_sensor_odr odr; | 189 | struct st_sensor_odr odr; |
| 188 | struct st_sensor_power pw; | 190 | struct st_sensor_power pw; |
| 189 | struct st_sensor_axis enable_axis; | 191 | struct st_sensor_axis enable_axis; |
| @@ -200,6 +202,8 @@ struct st_sensors { | |||
| 200 | * @trig: The trigger in use by the core driver. | 202 | * @trig: The trigger in use by the core driver. |
| 201 | * @sensor: Pointer to the current sensor struct in use. | 203 | * @sensor: Pointer to the current sensor struct in use. |
| 202 | * @current_fullscale: Maximum range of measure by the sensor. | 204 | * @current_fullscale: Maximum range of measure by the sensor. |
| 205 | * @vdd: Pointer to sensor's Vdd power supply | ||
| 206 | * @vdd_io: Pointer to sensor's Vdd-IO power supply | ||
| 203 | * @enabled: Status of the sensor (false->off, true->on). | 207 | * @enabled: Status of the sensor (false->off, true->on). |
| 204 | * @multiread_bit: Use or not particular bit for [I2C/SPI] multiread. | 208 | * @multiread_bit: Use or not particular bit for [I2C/SPI] multiread. |
| 205 | * @buffer_data: Data used by buffer part. | 209 | * @buffer_data: Data used by buffer part. |
| @@ -215,6 +219,8 @@ struct st_sensor_data { | |||
| 215 | struct iio_trigger *trig; | 219 | struct iio_trigger *trig; |
| 216 | struct st_sensors *sensor; | 220 | struct st_sensors *sensor; |
| 217 | struct st_sensor_fullscale_avl *current_fullscale; | 221 | struct st_sensor_fullscale_avl *current_fullscale; |
| 222 | struct regulator *vdd; | ||
| 223 | struct regulator *vdd_io; | ||
| 218 | 224 | ||
| 219 | bool enabled; | 225 | bool enabled; |
| 220 | bool multiread_bit; | 226 | bool multiread_bit; |
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index 833926c91aa8..2752b1fd12be 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h | |||
| @@ -77,7 +77,7 @@ struct iio_cb_buffer; | |||
| 77 | * fail. | 77 | * fail. |
| 78 | */ | 78 | */ |
| 79 | struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, | 79 | struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, |
| 80 | int (*cb)(u8 *data, | 80 | int (*cb)(const void *data, |
| 81 | void *private), | 81 | void *private), |
| 82 | void *private); | 82 | void *private); |
| 83 | /** | 83 | /** |
diff --git a/include/linux/iio/events.h b/include/linux/iio/events.h index 13ce220c7003..5dab2c41031f 100644 --- a/include/linux/iio/events.h +++ b/include/linux/iio/events.h | |||
| @@ -26,20 +26,6 @@ struct iio_event_data { | |||
| 26 | 26 | ||
| 27 | #define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int) | 27 | #define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int) |
| 28 | 28 | ||
| 29 | enum iio_event_type { | ||
| 30 | IIO_EV_TYPE_THRESH, | ||
| 31 | IIO_EV_TYPE_MAG, | ||
| 32 | IIO_EV_TYPE_ROC, | ||
| 33 | IIO_EV_TYPE_THRESH_ADAPTIVE, | ||
| 34 | IIO_EV_TYPE_MAG_ADAPTIVE, | ||
| 35 | }; | ||
| 36 | |||
| 37 | enum iio_event_direction { | ||
| 38 | IIO_EV_DIR_EITHER, | ||
| 39 | IIO_EV_DIR_RISING, | ||
| 40 | IIO_EV_DIR_FALLING, | ||
| 41 | }; | ||
| 42 | |||
| 43 | /** | 29 | /** |
| 44 | * IIO_EVENT_CODE() - create event identifier | 30 | * IIO_EVENT_CODE() - create event identifier |
| 45 | * @chan_type: Type of the channel. Should be one of enum iio_chan_type. | 31 | * @chan_type: Type of the channel. Should be one of enum iio_chan_type. |
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 2103cc32a5fb..256a90a1bea6 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h | |||
| @@ -36,6 +36,14 @@ enum iio_chan_info_enum { | |||
| 36 | IIO_CHAN_INFO_PHASE, | 36 | IIO_CHAN_INFO_PHASE, |
| 37 | IIO_CHAN_INFO_HARDWAREGAIN, | 37 | IIO_CHAN_INFO_HARDWAREGAIN, |
| 38 | IIO_CHAN_INFO_HYSTERESIS, | 38 | IIO_CHAN_INFO_HYSTERESIS, |
| 39 | IIO_CHAN_INFO_INT_TIME, | ||
| 40 | }; | ||
| 41 | |||
| 42 | enum iio_shared_by { | ||
| 43 | IIO_SEPARATE, | ||
| 44 | IIO_SHARED_BY_TYPE, | ||
| 45 | IIO_SHARED_BY_DIR, | ||
| 46 | IIO_SHARED_BY_ALL | ||
| 39 | }; | 47 | }; |
| 40 | 48 | ||
| 41 | enum iio_endian { | 49 | enum iio_endian { |
| @@ -57,7 +65,7 @@ struct iio_dev; | |||
| 57 | */ | 65 | */ |
| 58 | struct iio_chan_spec_ext_info { | 66 | struct iio_chan_spec_ext_info { |
| 59 | const char *name; | 67 | const char *name; |
| 60 | bool shared; | 68 | enum iio_shared_by shared; |
| 61 | ssize_t (*read)(struct iio_dev *, uintptr_t private, | 69 | ssize_t (*read)(struct iio_dev *, uintptr_t private, |
| 62 | struct iio_chan_spec const *, char *buf); | 70 | struct iio_chan_spec const *, char *buf); |
| 63 | ssize_t (*write)(struct iio_dev *, uintptr_t private, | 71 | ssize_t (*write)(struct iio_dev *, uintptr_t private, |
| @@ -125,12 +133,35 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev, | |||
| 125 | #define IIO_ENUM_AVAILABLE(_name, _e) \ | 133 | #define IIO_ENUM_AVAILABLE(_name, _e) \ |
| 126 | { \ | 134 | { \ |
| 127 | .name = (_name "_available"), \ | 135 | .name = (_name "_available"), \ |
| 128 | .shared = true, \ | 136 | .shared = IIO_SHARED_BY_TYPE, \ |
| 129 | .read = iio_enum_available_read, \ | 137 | .read = iio_enum_available_read, \ |
| 130 | .private = (uintptr_t)(_e), \ | 138 | .private = (uintptr_t)(_e), \ |
| 131 | } | 139 | } |
| 132 | 140 | ||
| 133 | /** | 141 | /** |
| 142 | * struct iio_event_spec - specification for a channel event | ||
| 143 | * @type: Type of the event | ||
| 144 | * @dir: Direction of the event | ||
| 145 | * @mask_separate: Bit mask of enum iio_event_info values. Attributes | ||
| 146 | * set in this mask will be registered per channel. | ||
| 147 | * @mask_shared_by_type: Bit mask of enum iio_event_info values. Attributes | ||
| 148 | * set in this mask will be shared by channel type. | ||
| 149 | * @mask_shared_by_dir: Bit mask of enum iio_event_info values. Attributes | ||
| 150 | * set in this mask will be shared by channel type and | ||
| 151 | * direction. | ||
| 152 | * @mask_shared_by_all: Bit mask of enum iio_event_info values. Attributes | ||
| 153 | * set in this mask will be shared by all channels. | ||
| 154 | */ | ||
| 155 | struct iio_event_spec { | ||
| 156 | enum iio_event_type type; | ||
| 157 | enum iio_event_direction dir; | ||
| 158 | unsigned long mask_separate; | ||
| 159 | unsigned long mask_shared_by_type; | ||
| 160 | unsigned long mask_shared_by_dir; | ||
| 161 | unsigned long mask_shared_by_all; | ||
| 162 | }; | ||
| 163 | |||
| 164 | /** | ||
| 134 | * struct iio_chan_spec - specification of a single channel | 165 | * struct iio_chan_spec - specification of a single channel |
| 135 | * @type: What type of measurement is the channel making. | 166 | * @type: What type of measurement is the channel making. |
| 136 | * @channel: What number do we wish to assign the channel. | 167 | * @channel: What number do we wish to assign the channel. |
| @@ -146,13 +177,18 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev, | |||
| 146 | * shift: Shift right by this before masking out | 177 | * shift: Shift right by this before masking out |
| 147 | * realbits. | 178 | * realbits. |
| 148 | * endianness: little or big endian | 179 | * endianness: little or big endian |
| 149 | * @info_mask: What information is to be exported about this channel. | ||
| 150 | * This includes calibbias, scale etc. | ||
| 151 | * @info_mask_separate: What information is to be exported that is specific to | 180 | * @info_mask_separate: What information is to be exported that is specific to |
| 152 | * this channel. | 181 | * this channel. |
| 153 | * @info_mask_shared_by_type: What information is to be exported that is shared | 182 | * @info_mask_shared_by_type: What information is to be exported that is shared |
| 154 | * by all channels of the same type. | 183 | * by all channels of the same type. |
| 184 | * @info_mask_shared_by_dir: What information is to be exported that is shared | ||
| 185 | * by all channels of the same direction. | ||
| 186 | * @info_mask_shared_by_all: What information is to be exported that is shared | ||
| 187 | * by all channels. | ||
| 155 | * @event_mask: What events can this channel produce. | 188 | * @event_mask: What events can this channel produce. |
| 189 | * @event_spec: Array of events which should be registered for this | ||
| 190 | * channel. | ||
| 191 | * @num_event_specs: Size of the event_spec array. | ||
| 156 | * @ext_info: Array of extended info attributes for this channel. | 192 | * @ext_info: Array of extended info attributes for this channel. |
| 157 | * The array is NULL terminated, the last element should | 193 | * The array is NULL terminated, the last element should |
| 158 | * have its name field set to NULL. | 194 | * have its name field set to NULL. |
| @@ -186,10 +222,13 @@ struct iio_chan_spec { | |||
| 186 | u8 shift; | 222 | u8 shift; |
| 187 | enum iio_endian endianness; | 223 | enum iio_endian endianness; |
| 188 | } scan_type; | 224 | } scan_type; |
| 189 | long info_mask; | ||
| 190 | long info_mask_separate; | 225 | long info_mask_separate; |
| 191 | long info_mask_shared_by_type; | 226 | long info_mask_shared_by_type; |
| 227 | long info_mask_shared_by_dir; | ||
| 228 | long info_mask_shared_by_all; | ||
| 192 | long event_mask; | 229 | long event_mask; |
| 230 | const struct iio_event_spec *event_spec; | ||
| 231 | unsigned int num_event_specs; | ||
| 193 | const struct iio_chan_spec_ext_info *ext_info; | 232 | const struct iio_chan_spec_ext_info *ext_info; |
| 194 | const char *extend_name; | 233 | const char *extend_name; |
| 195 | const char *datasheet_name; | 234 | const char *datasheet_name; |
| @@ -212,7 +251,9 @@ static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, | |||
| 212 | enum iio_chan_info_enum type) | 251 | enum iio_chan_info_enum type) |
| 213 | { | 252 | { |
| 214 | return (chan->info_mask_separate & BIT(type)) | | 253 | return (chan->info_mask_separate & BIT(type)) | |
| 215 | (chan->info_mask_shared_by_type & BIT(type)); | 254 | (chan->info_mask_shared_by_type & BIT(type)) | |
| 255 | (chan->info_mask_shared_by_dir & BIT(type)) | | ||
| 256 | (chan->info_mask_shared_by_all & BIT(type)); | ||
| 216 | } | 257 | } |
| 217 | 258 | ||
| 218 | #define IIO_ST(si, rb, sb, sh) \ | 259 | #define IIO_ST(si, rb, sb, sh) \ |
| @@ -270,6 +311,12 @@ struct iio_dev; | |||
| 270 | * is event dependant. event_code specifies which event. | 311 | * is event dependant. event_code specifies which event. |
| 271 | * @write_event_value: write the value associated with the event. | 312 | * @write_event_value: write the value associated with the event. |
| 272 | * Meaning is event dependent. | 313 | * Meaning is event dependent. |
| 314 | * @read_event_config_new: find out if the event is enabled. New style interface. | ||
| 315 | * @write_event_config_new: set if the event is enabled. New style interface. | ||
| 316 | * @read_event_value_new: read a configuration value associated with the event. | ||
| 317 | * New style interface. | ||
| 318 | * @write_event_value_new: write a configuration value for the event. New style | ||
| 319 | * interface. | ||
| 273 | * @validate_trigger: function to validate the trigger when the | 320 | * @validate_trigger: function to validate the trigger when the |
| 274 | * current trigger gets changed. | 321 | * current trigger gets changed. |
| 275 | * @update_scan_mode: function to configure device and scan buffer when | 322 | * @update_scan_mode: function to configure device and scan buffer when |
| @@ -310,6 +357,30 @@ struct iio_info { | |||
| 310 | int (*write_event_value)(struct iio_dev *indio_dev, | 357 | int (*write_event_value)(struct iio_dev *indio_dev, |
| 311 | u64 event_code, | 358 | u64 event_code, |
| 312 | int val); | 359 | int val); |
| 360 | |||
| 361 | int (*read_event_config_new)(struct iio_dev *indio_dev, | ||
| 362 | const struct iio_chan_spec *chan, | ||
| 363 | enum iio_event_type type, | ||
| 364 | enum iio_event_direction dir); | ||
| 365 | |||
| 366 | int (*write_event_config_new)(struct iio_dev *indio_dev, | ||
| 367 | const struct iio_chan_spec *chan, | ||
| 368 | enum iio_event_type type, | ||
| 369 | enum iio_event_direction dir, | ||
| 370 | int state); | ||
| 371 | |||
| 372 | int (*read_event_value_new)(struct iio_dev *indio_dev, | ||
| 373 | const struct iio_chan_spec *chan, | ||
| 374 | enum iio_event_type type, | ||
| 375 | enum iio_event_direction dir, | ||
| 376 | enum iio_event_info info, int *val, int *val2); | ||
| 377 | |||
| 378 | int (*write_event_value_new)(struct iio_dev *indio_dev, | ||
| 379 | const struct iio_chan_spec *chan, | ||
| 380 | enum iio_event_type type, | ||
| 381 | enum iio_event_direction dir, | ||
| 382 | enum iio_event_info info, int val, int val2); | ||
| 383 | |||
| 313 | int (*validate_trigger)(struct iio_dev *indio_dev, | 384 | int (*validate_trigger)(struct iio_dev *indio_dev, |
| 314 | struct iio_trigger *trig); | 385 | struct iio_trigger *trig); |
| 315 | int (*update_scan_mode)(struct iio_dev *indio_dev, | 386 | int (*update_scan_mode)(struct iio_dev *indio_dev, |
| @@ -457,7 +528,7 @@ static inline void iio_device_put(struct iio_dev *indio_dev) | |||
| 457 | { | 528 | { |
| 458 | if (indio_dev) | 529 | if (indio_dev) |
| 459 | put_device(&indio_dev->dev); | 530 | put_device(&indio_dev->dev); |
| 460 | }; | 531 | } |
| 461 | 532 | ||
| 462 | /** | 533 | /** |
| 463 | * dev_to_iio_dev() - Get IIO device struct from a device struct | 534 | * dev_to_iio_dev() - Get IIO device struct from a device struct |
| @@ -593,7 +664,7 @@ static inline bool iio_buffer_enabled(struct iio_dev *indio_dev) | |||
| 593 | { | 664 | { |
| 594 | return indio_dev->currentmode | 665 | return indio_dev->currentmode |
| 595 | & (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE); | 666 | & (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE); |
| 596 | }; | 667 | } |
| 597 | 668 | ||
| 598 | /** | 669 | /** |
| 599 | * iio_get_debugfs_dentry() - helper function to get the debugfs_dentry | 670 | * iio_get_debugfs_dentry() - helper function to get the debugfs_dentry |
| @@ -603,12 +674,12 @@ static inline bool iio_buffer_enabled(struct iio_dev *indio_dev) | |||
| 603 | static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev) | 674 | static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev) |
| 604 | { | 675 | { |
| 605 | return indio_dev->debugfs_dentry; | 676 | return indio_dev->debugfs_dentry; |
| 606 | }; | 677 | } |
| 607 | #else | 678 | #else |
| 608 | static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev) | 679 | static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev) |
| 609 | { | 680 | { |
| 610 | return NULL; | 681 | return NULL; |
| 611 | }; | 682 | } |
| 612 | #endif | 683 | #endif |
| 613 | 684 | ||
| 614 | int iio_str_to_fixpoint(const char *str, int fract_mult, int *integer, | 685 | int iio_str_to_fixpoint(const char *str, int fract_mult, int *integer, |
diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h index 2958c960003a..8a1d18640ab9 100644 --- a/include/linux/iio/sysfs.h +++ b/include/linux/iio/sysfs.h | |||
| @@ -100,6 +100,21 @@ struct iio_const_attr { | |||
| 100 | #define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \ | 100 | #define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \ |
| 101 | IIO_CONST_ATTR(sampling_frequency_available, _string) | 101 | IIO_CONST_ATTR(sampling_frequency_available, _string) |
| 102 | 102 | ||
| 103 | /** | ||
| 104 | * IIO_DEV_ATTR_INT_TIME_AVAIL - list available integration times | ||
| 105 | * @_show: output method for the attribute | ||
| 106 | **/ | ||
| 107 | #define IIO_DEV_ATTR_INT_TIME_AVAIL(_show) \ | ||
| 108 | IIO_DEVICE_ATTR(integration_time_available, S_IRUGO, _show, NULL, 0) | ||
| 109 | /** | ||
| 110 | * IIO_CONST_ATTR_INT_TIME_AVAIL - list available integration times | ||
| 111 | * @_string: frequency string for the attribute | ||
| 112 | * | ||
| 113 | * Constant version | ||
| 114 | **/ | ||
| 115 | #define IIO_CONST_ATTR_INT_TIME_AVAIL(_string) \ | ||
| 116 | IIO_CONST_ATTR(integration_time_available, _string) | ||
| 117 | |||
| 103 | #define IIO_DEV_ATTR_TEMP_RAW(_show) \ | 118 | #define IIO_DEV_ATTR_TEMP_RAW(_show) \ |
| 104 | IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0) | 119 | IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0) |
| 105 | 120 | ||
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 88bf0f0d27b4..4ac928ee31c5 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h | |||
| @@ -54,6 +54,26 @@ enum iio_modifier { | |||
| 54 | IIO_MOD_LIGHT_BLUE, | 54 | IIO_MOD_LIGHT_BLUE, |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | enum iio_event_type { | ||
| 58 | IIO_EV_TYPE_THRESH, | ||
| 59 | IIO_EV_TYPE_MAG, | ||
| 60 | IIO_EV_TYPE_ROC, | ||
| 61 | IIO_EV_TYPE_THRESH_ADAPTIVE, | ||
| 62 | IIO_EV_TYPE_MAG_ADAPTIVE, | ||
| 63 | }; | ||
| 64 | |||
| 65 | enum iio_event_info { | ||
| 66 | IIO_EV_INFO_ENABLE, | ||
| 67 | IIO_EV_INFO_VALUE, | ||
| 68 | IIO_EV_INFO_HYSTERESIS, | ||
| 69 | }; | ||
| 70 | |||
| 71 | enum iio_event_direction { | ||
| 72 | IIO_EV_DIR_EITHER, | ||
| 73 | IIO_EV_DIR_RISING, | ||
| 74 | IIO_EV_DIR_FALLING, | ||
| 75 | }; | ||
| 76 | |||
| 57 | #define IIO_VAL_INT 1 | 77 | #define IIO_VAL_INT 1 |
| 58 | #define IIO_VAL_INT_PLUS_MICRO 2 | 78 | #define IIO_VAL_INT_PLUS_MICRO 2 |
| 59 | #define IIO_VAL_INT_PLUS_NANO 3 | 79 | #define IIO_VAL_INT_PLUS_NANO 3 |
