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
32/**32/**
33 * struct ad_sigma_delta_info - Sigma Delta driver specific callbacks and options33 * struct ad_sigma_delta_info - Sigma Delta driver specific callbacks and options
34 * @set_channel: Will be called to select the current channel, may be NULL.34 * @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.
35 * @set_mode: Will be called to select the current mode, may be NULL.36 * @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.
36 * @postprocess_sample: Is called for each sampled data word, can be used to38 * @postprocess_sample: Is called for each sampled data word, can be used to
37 * modify or drop the sample data, it, may be NULL.39 * modify or drop the sample data, it, may be NULL.
38 * @has_registers: true if the device has writable and readable registers, false40 * @has_registers: true if the device has writable and readable registers, false
39 * if there is just one read-only sample data shift register.41 * if there is just one read-only sample data shift register.
40 * @addr_shift: Shift of the register address in the communications register.42 * @addr_shift: Shift of the register address in the communications register.
41 * @read_mask: Mask for the communications register having the read bit set.43 * @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.
42 * @data_reg: Address of the data register, if 0 the default address of 0x3 will45 * @data_reg: Address of the data register, if 0 the default address of 0x3 will
43 * be used.46 * be used.
44 * @irq_flags: flags for the interrupt used by the triggered buffer47 * @irq_flags: flags for the interrupt used by the triggered buffer
48 * @num_slots: Number of sequencer slots
45 */49 */
46struct ad_sigma_delta_info {50struct ad_sigma_delta_info {
47 int (*set_channel)(struct ad_sigma_delta *, unsigned int channel);51 int (*set_channel)(struct ad_sigma_delta *, unsigned int channel);
52 int (*append_status)(struct ad_sigma_delta *, bool append);
48 int (*set_mode)(struct ad_sigma_delta *, enum ad_sigma_delta_mode mode);53 int (*set_mode)(struct ad_sigma_delta *, enum ad_sigma_delta_mode mode);
54 int (*disable_all)(struct ad_sigma_delta *);
49 int (*postprocess_sample)(struct ad_sigma_delta *, unsigned int raw_sample);55 int (*postprocess_sample)(struct ad_sigma_delta *, unsigned int raw_sample);
50 bool has_registers;56 bool has_registers;
51 unsigned int addr_shift;57 unsigned int addr_shift;
52 unsigned int read_mask;58 unsigned int read_mask;
59 unsigned int status_ch_mask;
53 unsigned int data_reg;60 unsigned int data_reg;
54 unsigned long irq_flags;61 unsigned long irq_flags;
62 unsigned int num_slots;
55};63};
56 64
57/**65/**
@@ -76,6 +84,13 @@ struct ad_sigma_delta { · 18 unmodified lines
76 uint8_t comm;84 uint8_t comm;
77 85
78 const struct ad_sigma_delta_info *info;86 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;
79 94
80 /*95 /*
81 * DMA (thus cache coherency maintenance) requires the96 * 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
97 return 0;112 return 0;
98}113}
99 114
115static 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
130static 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
100static inline int ad_sigma_delta_set_mode(struct ad_sigma_delta *sd,138static inline int ad_sigma_delta_set_mode(struct ad_sigma_delta *sd,
101 unsigned int mode)139 unsigned int mode)
102{140{
include/linux/iio/common/st_sensors.h+3−0
@@ -237,6 +237,7 @@ struct st_sensor_settings { · 236 unmodified lines
237 * @hw_irq_trigger: if we're using the hardware interrupt on the sensor.237 * @hw_irq_trigger: if we're using the hardware interrupt on the sensor.
238 * @hw_timestamp: Latest timestamp from the interrupt handler, when in use.238 * @hw_timestamp: Latest timestamp from the interrupt handler, when in use.
239 * @buffer_data: Data used by buffer part.239 * @buffer_data: Data used by buffer part.
240 * @odr_lock: Local lock for preventing concurrent ODR accesses/changes
240 */241 */
241struct st_sensor_data {242struct st_sensor_data {
242 struct iio_trigger *trig;243 struct iio_trigger *trig;
@@ -261,6 +262,8 @@ struct st_sensor_data { · 18 unmodified lines
261 s64 hw_timestamp;262 s64 hw_timestamp;
262 263
263 char buffer_data[ST_SENSORS_MAX_BUFFER_SIZE] ____cacheline_aligned;264 char buffer_data[ST_SENSORS_MAX_BUFFER_SIZE] ____cacheline_aligned;
265
266 struct mutex odr_lock;
264};267};
265 268
266#ifdef CONFIG_IIO_BUFFER269#ifdef CONFIG_IIO_BUFFER
include/linux/iio/iio-opaque.h+4−0
@@ -7,6 +7,9 @@ · 6 unmodified lines
7 * struct iio_dev_opaque - industrial I/O device opaque information7 * struct iio_dev_opaque - industrial I/O device opaque information
8 * @indio_dev: public industrial I/O device information8 * @indio_dev: public industrial I/O device information
9 * @id: used to identify device internally9 * @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
10 * @driver_module: used to make it harder to undercut users13 * @driver_module: used to make it harder to undercut users
11 * @info_exist_lock: lock to prevent use during removal14 * @info_exist_lock: lock to prevent use during removal
12 * @trig_readonly: mark the current trigger immutable15 * @trig_readonly: mark the current trigger immutable
@@ -36,6 +39,7 @@ · 23 unmodified lines
36 */39 */
37struct iio_dev_opaque {40struct iio_dev_opaque {
38 struct iio_dev indio_dev;41 struct iio_dev indio_dev;
42 int currentmode;
39 int id;43 int id;
40 struct module *driver_module;44 struct module *driver_module;
41 struct mutex info_exist_lock;45 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
315s64 iio_get_time_ns(const struct iio_dev *indio_dev);315s64 iio_get_time_ns(const struct iio_dev *indio_dev);
316unsigned int iio_get_time_res(const struct iio_dev *indio_dev);316unsigned int iio_get_time_res(const struct iio_dev *indio_dev);
317 317
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 */
319#define INDIO_DIRECT_MODE 0x01366#define INDIO_DIRECT_MODE 0x01
320#define INDIO_BUFFER_TRIGGERED 0x02367#define INDIO_BUFFER_TRIGGERED 0x02
321#define INDIO_BUFFER_SOFTWARE 0x04368#define INDIO_BUFFER_SOFTWARE 0x04
@@ -488,8 +535,12 @@ struct iio_buffer_setup_ops { · 166 unmodified lines
488 535
489/**536/**
490 * struct iio_dev - industrial I/O device537 * struct iio_dev - industrial I/O device
491 * @modes: [DRIVER] operating modes supported by device538 * @modes: [DRIVER] bitmask listing all the operating modes
492 * @currentmode: [INTERN] current operating mode539 * 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()).
493 * @dev: [DRIVER] device structure, should be assigned a parent544 * @dev: [DRIVER] device structure, should be assigned a parent
494 * and owner545 * and owner
495 * @buffer: [DRIVER] any buffer present546 * @buffer: [DRIVER] any buffer present
@@ -516,7 +567,6 @@ struct iio_buffer_setup_ops { · 20 unmodified lines
516 */567 */
517struct iio_dev {568struct iio_dev {
518 int modes;569 int modes;
519 int currentmode;
520 struct device dev;570 struct device dev;
521 571
522 struct iio_buffer *buffer;572 struct iio_buffer *buffer;
@@ -543,6 +593,8 @@ struct iio_dev { · 20 unmodified lines
543};593};
544 594
545int iio_device_id(struct iio_dev *indio_dev);595int iio_device_id(struct iio_dev *indio_dev);
596int iio_device_get_current_mode(struct iio_dev *indio_dev);
597bool iio_buffer_enabled(struct iio_dev *indio_dev);
546 598
547const struct iio_chan_spec599const struct iio_chan_spec
548*iio_find_channel_from_si(struct iio_dev *indio_dev, int si);600*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
672__printf(2, 3)724__printf(2, 3)
673struct iio_trigger *devm_iio_trigger_alloc(struct device *parent,725struct iio_trigger *devm_iio_trigger_alloc(struct device *parent,
674 const char *fmt, ...);726 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 **/
679static 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}
685 727
686/**728/**
687 * iio_get_debugfs_dentry() - helper function to get the debugfs_dentry729 * 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
12 12
13int devm_iio_kfifo_buffer_setup_ext(struct device *dev,13int devm_iio_kfifo_buffer_setup_ext(struct device *dev,
14 struct iio_dev *indio_dev,14 struct iio_dev *indio_dev,
15 int mode_flags,
16 const struct iio_buffer_setup_ops *setup_ops,15 const struct iio_buffer_setup_ops *setup_ops,
17 const struct attribute **buffer_attrs);16 const struct attribute **buffer_attrs);
18 17
19#define devm_iio_kfifo_buffer_setup(dev, indio_dev, mode_flags, setup_ops) \18#define devm_iio_kfifo_buffer_setup(dev, indio_dev, setup_ops) \
20 devm_iio_kfifo_buffer_setup_ext((dev), (indio_dev), (mode_flags), (setup_ops), NULL)19 devm_iio_kfifo_buffer_setup_ext((dev), (indio_dev), (setup_ops), NULL)
21 20
22#endif21#endif