History

Merge tag 'iio-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes: First set of IIO new device support, features and cleanup for 5.19 Usual mixed bag. Stand out this time is Andy Shevchenko's continuing effort to move drivers over the generic firmware interfaces. Device support * sprd,sc2720 - upm9620 binding addition. - Refactor and support for sc2720, sc2721 and sc2730. * ti,ads1015 - Refactor driver and add support for TLA2024. Device support (IDs only) * invensense,mpu6050 - Add ID for ICM-20608-D. * st,accel: - Add ID for lis302dl. * st,lsm6dsx - Add support for ASM330LHHX (can fallback to LSM6DSR.) Features * convert drivers to device properties - IIO core - adi,ad7266 - adi,adis16480 - adi,adxl355 - bosch,bmi160 - domintech,dmard06 - fsl,fxas21002c - invensense,mpu3050 - linear,ltc2983 - linear,ltc2632 - maxbotix,mb1232 - maxim,max31856 - maxim,max31865 - multiplexer - ping - rescale - taos,tsl2772 * core - Add runtime check on whether realbits fit in storagebits for each channel. * adi,ad_sigma_delta - Add sequencer support and relevant update_scan_mode callbacks for adi,ad7192 and adi,ad7124. Cleanup and minor fixes * MAINTAINERS - Update Lorenzo Bianconi's email address for IIO drivers. - Add entry for ad3552r and update maintainer in dt-binding doc. * tree-wide - Replace strtobool() with kstrtobool(). - Drop false OF dependencies. * core - Tidy up and document IIO modes. - Take iio_buffer_enabled() out of header allowing current_mode to be moved to the opaque structure. - As all kfifo buffers use the same mode value, drop that parameter and set it unconditionally. - White space fixes and similar. - Drop use of list iterator variable for list_for_each_entry_continue_reverse and use list_prepare_entry to restart. * sysfs-trigger - Replace use of 'found' variable with dedicate list iterator variable. * adi,ad7124 - Drop misleading shift. * adi,ad2s1210 - Remove redundant local variable assignment. * adi,adis16480 - Use local device pointer to reduce repetition. - Improve handling of clocks. * domintech,dmard09 - White space. * dummy driver - Improve error handling. * fsl,mma8452 - Add missing documentation of name element. * invensense,mpu3050 - Stop remove() returning non 0. * kionix,kxsd9 - White space. * linear,ltc2688 - Use local variable for struct device. - Combine of_node_put() error handling paths. * linear,ltc2983 - Avoid use of constants in messages where a define is available. * microchip,mcp4131 - Fix compatible in dt example. * pni,rm3100 - Stop directly accessing iio_dev->current_mode just to find out if the buffer is enabled. * renesas,rzg2l - Relax kconfig constraint to include newer devices. * sprd,sc27xx - Fix wrong scaling mask. - Improve the calibration values. * samsung,ssp - Replace a 'found' variable in favor of an explicit value that was found. * sensortek,stk3xx - Add proximity-near-level binding and driver support. * st,st_sensors: - Drop unused accel_type enum. - Return early in *_write_raw() - Drop unnecessary locking in _avail functions. - Add local lock to protect odr against concurrent updates allowing mlock to no longer be used outside of the core. - Use iio_device_claim_direct_mode() rather than racy checking of the current mode. * st,stmpe-adc - Fix checks on wait_for_completion_timeout(). - Allow use of of_device_id for matching. * st,stm32-dfsdm - Stop accessing iio_dev->current_mode to find out if the buffer is enabled (so we can hide that variable in the opaque structure) * st,vl53l0x - Fix checks on wait_for_completion_timeout. * ti,ads1015 - Add missing ID for ti,ads1115 in binding doc. - Convert from repeated chip ID look up to selecting static const data. - Switch to read_avail() callback. * ti,ads8688 - Use of_device_id for driver matching. * ti,palmas-adc - Drop a warning on minor calibration mismatch leading to slightly negative values after applying the calibration. * tag 'iio-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (95 commits) iio: ti-ads8688: use of_device_id for OF matching iio: stmpe-adc: use of_device_id for OF matching dt-bindings: iio: Fix incorrect compatible strings in examples iio: gyro: mpu3050: Make mpu3050_common_remove() return void iio: dac: ltc2632: Make use of device properties iio: temperature: max31865: Make use of device properties iio: proximity: mb1232: Switch to use fwnode_irq_get() iio: imu: adis16480: Improve getting the optional clocks iio: imu: adis16480: Use temporary variable for struct device iio: imu: adis16480: Make use of device properties staging: iio: ad2s1210: remove redundant assignment to variable negative iio: adc: sc27xx: add support for PMIC sc2730 iio: adc: sc27xx: add support for PMIC sc2720 and sc2721 iio: adc: sc27xx: refactor some functions for support more PMiCs iio: adc: sc27xx: structure adjustment and optimization iio: adc: sc27xx: Fine tune the scale calibration values iio: adc: sc27xx: fix read big scale voltage not right dt-bindings:iio:adc: add sprd,ump9620-adc dt-binding iio: proximity: stk3310: Export near level property for proximity sensor dt-bindings: iio: light: stk33xx: Add proximity-near-level ...

Greg Kroah-Hartman committed 4 years ago

Commit bcfa9542 parents 33a1c66 eda75f8122 files · +1718 −835Browse files

Showing the changes to include (5 of 122 files). Show all

Unified · Split

5 files
  1. include/linux/iio/adc/ad_sigma_delta.h +38 −0
  2. include/linux/iio/common/st_sensors.h +3 −0
  3. include/linux/iio/iio-opaque.h +4 −0
  4. include/linux/iio/iio.h +56 −14
  5. include/linux/iio/kfifo_buf.h +2 −3
include/linux/iio/adc/ad_sigma_delta.h+38−0
@@ -32,26 +32,34 @@ struct iio_dev; · 31 unmodified lines
3232 /**
3333 * struct ad_sigma_delta_info - Sigma Delta driver specific callbacks and options
3434 * @set_channel: Will be called to select the current channel, may be NULL.
35+ * @append_status: Will be called to enable status append at the end of the sample, may be NULL.
3536 * @set_mode: Will be called to select the current mode, may be NULL.
37+ * @disable_all: Will be called to disable all channels, may be NULL.
3638 * @postprocess_sample: Is called for each sampled data word, can be used to
3739 * modify or drop the sample data, it, may be NULL.
3840 * @has_registers: true if the device has writable and readable registers, false
3941 * if there is just one read-only sample data shift register.
4042 * @addr_shift: Shift of the register address in the communications register.
4143 * @read_mask: Mask for the communications register having the read bit set.
44+ * @status_ch_mask: Mask for the channel number stored in status register.
4245 * @data_reg: Address of the data register, if 0 the default address of 0x3 will
4346 * be used.
4447 * @irq_flags: flags for the interrupt used by the triggered buffer
48+ * @num_slots: Number of sequencer slots
4549 */
4650 struct ad_sigma_delta_info {
4751 int (*set_channel)(struct ad_sigma_delta *, unsigned int channel);
52+ int (*append_status)(struct ad_sigma_delta *, bool append);
4853 int (*set_mode)(struct ad_sigma_delta *, enum ad_sigma_delta_mode mode);
54+ int (*disable_all)(struct ad_sigma_delta *);
4955 int (*postprocess_sample)(struct ad_sigma_delta *, unsigned int raw_sample);
5056 bool has_registers;
5157 unsigned int addr_shift;
5258 unsigned int read_mask;
59+ unsigned int status_ch_mask;
5360 unsigned int data_reg;
5461 unsigned long irq_flags;
62+ unsigned int num_slots;
5563 };
5664
5765 /**
@@ -76,6 +84,13 @@ struct ad_sigma_delta { · 18 unmodified lines
7684 uint8_t comm;
7785
7886 const struct ad_sigma_delta_info *info;
87+ unsigned int active_slots;
88+ unsigned int current_slot;
89+ unsigned int num_slots;
90+ bool status_appended;
91+ /* map slots to channels in order to know what to expect from devices */
92+ unsigned int *slots;
93+ uint8_t *samples_buf;
7994
8095 /*
8196 * DMA (thus cache coherency maintenance) requires the
@@ -97,6 +112,29 @@ static inline int ad_sigma_delta_set_channel(struct ad_sigma_delta *sd, · 15 unmodified lines
97112 return 0;
98113 }
99114
115+static inline int ad_sigma_delta_append_status(struct ad_sigma_delta *sd, bool append)
116+{
117+ int ret;
118+
119+ if (sd->info->append_status) {
120+ ret = sd->info->append_status(sd, append);
121+ if (ret < 0)
122+ return ret;
123+
124+ sd->status_appended = append;
125+ }
126+
127+ return 0;
128+}
129+
130+static inline int ad_sigma_delta_disable_all(struct ad_sigma_delta *sd)
131+{
132+ if (sd->info->disable_all)
133+ return sd->info->disable_all(sd);
134+
135+ return 0;
136+}
137+
100138 static inline int ad_sigma_delta_set_mode(struct ad_sigma_delta *sd,
101139 unsigned int mode)
102140 {
include/linux/iio/common/st_sensors.h+3−0
@@ -237,6 +237,7 @@ struct st_sensor_settings { · 236 unmodified lines
237237 * @hw_irq_trigger: if we're using the hardware interrupt on the sensor.
238238 * @hw_timestamp: Latest timestamp from the interrupt handler, when in use.
239239 * @buffer_data: Data used by buffer part.
240+ * @odr_lock: Local lock for preventing concurrent ODR accesses/changes
240241 */
241242 struct st_sensor_data {
242243 struct iio_trigger *trig;
@@ -261,6 +262,8 @@ struct st_sensor_data { · 18 unmodified lines
261262 s64 hw_timestamp;
262263
263264 char buffer_data[ST_SENSORS_MAX_BUFFER_SIZE] ____cacheline_aligned;
265+
266+ struct mutex odr_lock;
264267 };
265268
266269 #ifdef CONFIG_IIO_BUFFER
include/linux/iio/iio-opaque.h+4−0
@@ -7,6 +7,9 @@ · 6 unmodified lines
77 * struct iio_dev_opaque - industrial I/O device opaque information
88 * @indio_dev: public industrial I/O device information
99 * @id: used to identify device internally
10+ * @currentmode: operating mode currently in use, may be eventually
11+ * checked by device drivers but should be considered
12+ * read-only as this is a core internal bit
1013 * @driver_module: used to make it harder to undercut users
1114 * @info_exist_lock: lock to prevent use during removal
1215 * @trig_readonly: mark the current trigger immutable
@@ -36,6 +39,7 @@ · 23 unmodified lines
3639 */
3740 struct iio_dev_opaque {
3841 struct iio_dev indio_dev;
42+ int currentmode;
3943 int id;
4044 struct module *driver_module;
4145 struct mutex info_exist_lock;
include/linux/iio/iio.h+56−14
@@ -315,7 +315,54 @@ static inline bool iio_channel_has_available(const struct iio_chan_spec *chan, · 314 unmodified lines
315315 s64 iio_get_time_ns(const struct iio_dev *indio_dev);
316316 unsigned int iio_get_time_res(const struct iio_dev *indio_dev);
317317
318−/* Device operating modes */
318+/*
319+ * Device operating modes
320+ * @INDIO_DIRECT_MODE: There is an access to either:
321+ * a) The last single value available for devices that do not provide
322+ * on-demand reads.
323+ * b) A new value after performing an on-demand read otherwise.
324+ * On most devices, this is a single-shot read. On some devices with data
325+ * streams without an 'on-demand' function, this might also be the 'last value'
326+ * feature. Above all, this mode internally means that we are not in any of the
327+ * other modes, and sysfs reads should work.
328+ * Device drivers should inform the core if they support this mode.
329+ * @INDIO_BUFFER_TRIGGERED: Common mode when dealing with kfifo buffers.
330+ * It indicates that an explicit trigger is required. This requests the core to
331+ * attach a poll function when enabling the buffer, which is indicated by the
332+ * _TRIGGERED suffix.
333+ * The core will ensure this mode is set when registering a triggered buffer
334+ * with iio_triggered_buffer_setup().
335+ * @INDIO_BUFFER_SOFTWARE: Another kfifo buffer mode, but not event triggered.
336+ * No poll function can be attached because there is no triggered infrastructure
337+ * we can use to cause capture. There is a kfifo that the driver will fill, but
338+ * not "only one scan at a time". Typically, hardware will have a buffer that
339+ * can hold multiple scans. Software may read one or more scans at a single time
340+ * and push the available data to a Kfifo. This means the core will not attach
341+ * any poll function when enabling the buffer.
342+ * The core will ensure this mode is set when registering a simple kfifo buffer
343+ * with devm_iio_kfifo_buffer_setup().
344+ * @INDIO_BUFFER_HARDWARE: For specific hardware, if unsure do not use this mode.
345+ * Same as above but this time the buffer is not a kfifo where we have direct
346+ * access to the data. Instead, the consumer driver must access the data through
347+ * non software visible channels (or DMA when there is no demux possible in
348+ * software)
349+ * The core will ensure this mode is set when registering a dmaengine buffer
350+ * with devm_iio_dmaengine_buffer_setup().
351+ * @INDIO_EVENT_TRIGGERED: Very unusual mode.
352+ * Triggers usually refer to an external event which will start data capture.
353+ * Here it is kind of the opposite as, a particular state of the data might
354+ * produce an event which can be considered as an event. We don't necessarily
355+ * have access to the data itself, but to the event produced. For example, this
356+ * can be a threshold detector. The internal path of this mode is very close to
357+ * the INDIO_BUFFER_TRIGGERED mode.
358+ * The core will ensure this mode is set when registering a triggered event.
359+ * @INDIO_HARDWARE_TRIGGERED: Very unusual mode.
360+ * Here, triggers can result in data capture and can be routed to multiple
361+ * hardware components, which make them close to regular triggers in the way
362+ * they must be managed by the core, but without the entire interrupts/poll
363+ * functions burden. Interrupts are irrelevant as the data flow is hardware
364+ * mediated and distributed.
365+ */
319366 #define INDIO_DIRECT_MODE 0x01
320367 #define INDIO_BUFFER_TRIGGERED 0x02
321368 #define INDIO_BUFFER_SOFTWARE 0x04
@@ -488,8 +535,12 @@ struct iio_buffer_setup_ops { · 166 unmodified lines
488535
489536 /**
490537 * struct iio_dev - industrial I/O device
491− * @modes: [DRIVER] operating modes supported by device
492− * @currentmode: [INTERN] current operating mode
538+ * @modes: [DRIVER] bitmask listing all the operating modes
539+ * supported by the IIO device. This list should be
540+ * initialized before registering the IIO device. It can
541+ * also be filed up by the IIO core, as a result of
542+ * enabling particular features in the driver
543+ * (see iio_triggered_event_setup()).
493544 * @dev: [DRIVER] device structure, should be assigned a parent
494545 * and owner
495546 * @buffer: [DRIVER] any buffer present
@@ -516,7 +567,6 @@ struct iio_buffer_setup_ops { · 20 unmodified lines
516567 */
517568 struct iio_dev {
518569 int modes;
519− int currentmode;
520570 struct device dev;
521571
522572 struct iio_buffer *buffer;
@@ -543,6 +593,8 @@ struct iio_dev { · 20 unmodified lines
543593 };
544594
545595 int iio_device_id(struct iio_dev *indio_dev);
596+int iio_device_get_current_mode(struct iio_dev *indio_dev);
597+bool iio_buffer_enabled(struct iio_dev *indio_dev);
546598
547599 const struct iio_chan_spec
548600 *iio_find_channel_from_si(struct iio_dev *indio_dev, int si);
@@ -672,16 +724,6 @@ struct iio_dev *devm_iio_device_alloc(struct device *parent, int sizeof_priv); · 123 unmodified lines
672724 __printf(2, 3)
673725 struct iio_trigger *devm_iio_trigger_alloc(struct device *parent,
674726 const char *fmt, ...);
675−/**
676− * iio_buffer_enabled() - helper function to test if the buffer is enabled
677− * @indio_dev: IIO device structure for device
678− **/
679−static inline bool iio_buffer_enabled(struct iio_dev *indio_dev)
680−{
681− return indio_dev->currentmode
682− & (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE |
683− INDIO_BUFFER_SOFTWARE);
684−}
685727
686728 /**
687729 * iio_get_debugfs_dentry() - helper function to get the debugfs_dentry
include/linux/iio/kfifo_buf.h+2−3
@@ -12,11 +12,10 @@ void iio_kfifo_free(struct iio_buffer *r); · 11 unmodified lines
1212
1313 int devm_iio_kfifo_buffer_setup_ext(struct device *dev,
1414 struct iio_dev *indio_dev,
15− int mode_flags,
1615 const struct iio_buffer_setup_ops *setup_ops,
1716 const struct attribute **buffer_attrs);
1817
19−#define devm_iio_kfifo_buffer_setup(dev, indio_dev, mode_flags, setup_ops) \
20− devm_iio_kfifo_buffer_setup_ext((dev), (indio_dev), (mode_flags), (setup_ops), NULL)
18+#define devm_iio_kfifo_buffer_setup(dev, indio_dev, setup_ops) \
19+ devm_iio_kfifo_buffer_setup_ext((dev), (indio_dev), (setup_ops), NULL)
2120
2221 #endif