History

Merge tag 'iio-for-4.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes: First round of new IIO device support, features and cleanups for the 4.6 cycle. Device Support * ad5761 - new driver * at91_sama5d2 ADC. - new driver and MAINTAINERS entry. - minor cleanups followed. * atlas pH-SM - new driver (this has possibly the prettiest data sheet I've ever seen) * mcp3422 - mcp3425 ADC added. * mcp4725 - mcp4726 DAC added. * mma8452 - mma8451q accelerometer added. * mpl115 - mpl115a1 added (a lot bigger than it seems as this is an SPI part whereas previous parts were i2c). * si7005 - Hoperf th02 (seems to be a repackaged part) * si7020 - Hoperf th06 (seems to be a repackaged part) New features * Core - IIO_PH type. Does what it says on the tin. * max30100 - LED current configuration support. * mcp320x - more differential measurement combinations. * mma8452 - free fall deteciton - opt3001 - enable operation without a IRQ line. - device tree docs. Somehow the original docs have disappeared down a rabbit hole, so here is a new set. * st-sensors - Support active-low interrupts. Cleanups and minor / not so minor reworks * Documentation - drop some defunct ABI from the docs in staging. * presure / Kconfig - white space cleanup. * ad7150 - BIT macro usage - Alignment fixes * ad7192 - false indent fixed. * ak8975 - constify the ak_def structures * axp288 - drop a redundant double const. * dht11 - substantial reliability improvements by being more tolerant of missing start bits. - simplify the decoding algorithm * mma8452 - whitespace cleanup * mpl115 - don't bother setting i2c_client_data as nothing uses it. * mpu6050 - drop unused function parameter. * opt3001 - extract integration time as constants. - trivial refactoring.

Greg Kroah-Hartman committed 10 years ago

Commit fec2f332 parents 4cff7ad ea4570d53 files · +2531 −265Browse files

Unified · Split

53 files
  1. CREDITS +1 −0
  2. Documentation/ABI/testing/sysfs-bus-iio +9 −0
  3. Documentation/devicetree/bindings/iio/accel/mma8452.txt +3 −1
  4. Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt +28 −0
  5. Documentation/devicetree/bindings/iio/adc/mcp3422.txt +1 −0
  6. Documentation/devicetree/bindings/iio/chemical/atlas,ph-sm.txt +22 −0
  7. Documentation/devicetree/bindings/iio/health/max30100.txt +8 −0
  8. Documentation/devicetree/bindings/iio/light/opt3001.txt +26 −0
  9. Documentation/devicetree/bindings/vendor-prefixes.txt +1 −0
  10. MAINTAINERS +6 −0
  11. drivers/iio/accel/Kconfig +1 −1
  12. drivers/iio/accel/mma8452.c +182 −24
  13. drivers/iio/accel/st_accel_core.c +16 −0
  14. drivers/iio/adc/Kconfig +13 −3
  15. drivers/iio/adc/Makefile +1 −0
  16. drivers/iio/adc/at91-sama5d2_adc.c +508 −0
  17. drivers/iio/adc/axp288_adc.c +1 −1
  18. drivers/iio/adc/mcp320x.c +19 −12
  19. drivers/iio/adc/mcp3422.c +5 −2
  20. drivers/iio/chemical/Kconfig +13 −0
  21. drivers/iio/chemical/Makefile +1 −0
  22. drivers/iio/chemical/atlas-ph-sensor.c +511 −0
  23. drivers/iio/common/st_sensors/st_sensors_core.c +4 −2
  24. drivers/iio/common/st_sensors/st_sensors_core.h +8 −0
  25. drivers/iio/common/st_sensors/st_sensors_trigger.c +42 −10
  26. drivers/iio/dac/Kconfig +12 −2
  27. drivers/iio/dac/Makefile +1 −0
  28. drivers/iio/dac/ad5761.c +430 −0
  29. drivers/iio/dac/mcp4725.c +67 −20
  30. drivers/iio/gyro/st_gyro_core.c +15 −0
  31. drivers/iio/health/max30100.c +75 −6
  32. drivers/iio/humidity/Kconfig +4 −2
  33. drivers/iio/humidity/dht11.c +50 −27
  34. drivers/iio/humidity/si7005.c +1 −0
  35. drivers/iio/humidity/si7020.c +1 −0
  36. drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2 −3
  37. drivers/iio/industrialio-core.c +1 −0
  38. drivers/iio/light/opt3001.c +106 −50
  39. drivers/iio/magnetometer/ak8975.c +2 −2
  40. drivers/iio/magnetometer/st_magn_core.c +4 −0
  41. drivers/iio/pressure/Kconfig +28 −13
  42. drivers/iio/pressure/Makefile +2 −0
  43. drivers/iio/pressure/mpl115.c +27 −39
  44. drivers/iio/pressure/mpl115.h +24 −0
  45. drivers/iio/pressure/mpl115_i2c.c +67 −0
  46. drivers/iio/pressure/mpl115_spi.c +106 −0
  47. drivers/iio/pressure/st_pressure_core.c +8 −0
  48. drivers/staging/iio/Documentation/sysfs-bus-iio-light +0 −28
  49. drivers/staging/iio/adc/ad7192.c +1 −1
  50. drivers/staging/iio/cdc/ad7150.c +18 −16
  51. include/linux/iio/common/st_sensors.h +4 −0
  52. include/linux/platform_data/ad5761.h +44 −0
  53. include/uapi/linux/iio/types.h +1 −0
CREDITS+1−0
@@ -3054,6 +3054,7 @@ D: PLX USB338x driver · 3053 unmodified lines
30543054 D: PCA9634 driver
30553055 D: Option GTM671WFS
30563056 D: Fintek F81216A
3057+D: AD5761 iio driver
30573058 D: Various kernel hacks
30583059 S: Qtechnology A/S
30593060 S: Valby Langgade 142
Documentation/ABI/testing/sysfs-bus-iio+9−0
@@ -497,7 +497,9 @@ Description: · 496 unmodified lines
497497 6kohm_to_gnd: connected to ground via a 6kOhm resistor,
498498 20kohm_to_gnd: connected to ground via a 20kOhm resistor,
499499 100kohm_to_gnd: connected to ground via an 100kOhm resistor,
500+ 125kohm_to_gnd: connected to ground via an 125kOhm resistor,
500501 500kohm_to_gnd: connected to ground via a 500kOhm resistor,
502+ 640kohm_to_gnd: connected to ground via a 640kOhm resistor,
501503 three_state: left floating.
502504 For a list of available output power down options read
503505 outX_powerdown_mode_available. If Y is not present the
@@ -1491,3 +1493,10 @@ Description: · 987 unmodified lines
14911493 This ABI is especially applicable for humidity sensors
14921494 to heatup the device and get rid of any condensation
14931495 in some humidity environment
1496+
1497+What: /sys/bus/iio/devices/iio:deviceX/in_ph_raw
1498+KernelVersion: 4.5
1499+Contact: linux-iio@vger.kernel.org
1500+Description:
1501+ Raw (unscaled no offset etc.) pH reading of a substance as a negative
1502+ base-10 logarithm of hydrodium ions in a litre of water.
Documentation/devicetree/bindings/iio/accel/mma8452.txt+3−1
@@ -1,8 +1,10 @@
1−Freescale MMA8452Q, MMA8453Q, MMA8652FC or MMA8653FC triaxial accelerometer
1+Freescale MMA8451Q, MMA8452Q, MMA8453Q, MMA8652FC or MMA8653FC
2+triaxial accelerometer
23
34 Required properties:
45
56 - compatible: should contain one of
7+ * "fsl,mma8451"
68 * "fsl,mma8452"
79 * "fsl,mma8453"
810 * "fsl,mma8652"
Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt+28−0
@@ -0,0 +1,28 @@
1+* AT91 SAMA5D2 Analog to Digital Converter (ADC)
2+
3+Required properties:
4+ - compatible: Should be "atmel,sama5d2-adc".
5+ - reg: Should contain ADC registers location and length.
6+ - interrupts: Should contain the IRQ line for the ADC.
7+ - clocks: phandle to device clock.
8+ - clock-names: Must be "adc_clk".
9+ - vref-supply: Supply used as reference for conversions.
10+ - vddana-supply: Supply for the adc device.
11+ - atmel,min-sample-rate-hz: Minimum sampling rate, it depends on SoC.
12+ - atmel,max-sample-rate-hz: Maximum sampling rate, it depends on SoC.
13+ - atmel,startup-time-ms: Startup time expressed in ms, it depends on SoC.
14+
15+Example:
16+
17+adc: adc@fc030000 {
18+ compatible = "atmel,sama5d2-adc";
19+ reg = <0xfc030000 0x100>;
20+ interrupts = <40 IRQ_TYPE_LEVEL_HIGH 7>;
21+ clocks = <&adc_clk>;
22+ clock-names = "adc_clk";
23+ atmel,min-sample-rate-hz = <200000>;
24+ atmel,max-sample-rate-hz = <20000000>;
25+ atmel,startup-time-ms = <4>;
26+ vddana-supply = <&vdd_3v3_lp_reg>;
27+ vref-supply = <&vdd_3v3_lp_reg>;
28+}
Documentation/devicetree/bindings/iio/adc/mcp3422.txt+1−0
@@ -6,6 +6,7 @@ Required properties: · 5 unmodified lines
66 "microchip,mcp3422" or
77 "microchip,mcp3423" or
88 "microchip,mcp3424" or
9+ "microchip,mcp3425" or
910 "microchip,mcp3426" or
1011 "microchip,mcp3427" or
1112 "microchip,mcp3428"
Documentation/devicetree/bindings/iio/chemical/atlas,ph-sm.txt+22−0
@@ -0,0 +1,22 @@
1+* Atlas Scientific pH-SM OEM sensor
2+
3+http://www.atlas-scientific.com/_files/_datasheets/_oem/pH_oem_datasheet.pdf
4+
5+Required properties:
6+
7+ - compatible: must be "atlas,ph-sm"
8+ - reg: the I2C address of the sensor
9+ - interrupt-parent: should be the phandle for the interrupt controller
10+ - interrupts: the sole interrupt generated by the device
11+
12+ Refer to interrupt-controller/interrupts.txt for generic interrupt client
13+ node bindings.
14+
15+Example:
16+
17+atlas@65 {
18+ compatible = "atlas,ph-sm";
19+ reg = <0x65>;
20+ interrupt-parent = <&gpio1>;
21+ interrupts = <16 2>;
22+};
Documentation/devicetree/bindings/iio/health/max30100.txt+8−0
@@ -11,11 +11,19 @@ Required properties: · 10 unmodified lines
1111 Refer to interrupt-controller/interrupts.txt for generic
1212 interrupt client node bindings.
1313
14+Optional properties:
15+ - maxim,led-current-microamp: configuration for LED current in microamperes
16+ while the engine is running. First indexed value is the configuration for
17+ the RED LED, and second value is for the IR LED.
18+
19+ Refer to the datasheet for the allowed current values.
20+
1421 Example:
1522
1623 max30100@057 {
1724 compatible = "maxim,max30100";
1825 reg = <57>;
26+ maxim,led-current-microamp = <24000 50000>;
1927 interrupt-parent = <&gpio1>;
2028 interrupts = <16 2>;
2129 };
Documentation/devicetree/bindings/iio/light/opt3001.txt+26−0
@@ -0,0 +1,26 @@
1+* Texas Instruments OPT3001 Ambient Light Sensor
2+
3+The driver supports interrupt-driven and interrupt-less operation, depending
4+on whether an interrupt property has been populated into the DT. Note that
5+the optional generation of IIO events on rising/falling light threshold changes
6+requires the use of interrupts. Without interrupts, only the simple reading
7+of the current light value is supported through the IIO API.
8+
9+http://www.ti.com/product/opt3001
10+
11+Required properties:
12+ - compatible: should be "ti,opt3001"
13+ - reg: the I2C address of the sensor
14+
15+Optional properties:
16+ - interrupt-parent: should be the phandle for the interrupt controller
17+ - interrupts: interrupt mapping for GPIO IRQ (configure for falling edge)
18+
19+Example:
20+
21+opt3001@44 {
22+ compatible = "ti,opt3001";
23+ reg = <0x44>;
24+ interrupt-parent = <&gpio1>;
25+ interrupts = <28 IRQ_TYPE_EDGE_FALLING>;
26+};
Documentation/devicetree/bindings/vendor-prefixes.txt+1−0
@@ -28,6 +28,7 @@ arm ARM Ltd. · 27 unmodified lines
2828 armadeus ARMadeus Systems SARL
2929 artesyn Artesyn Embedded Technologies Inc.
3030 asahi-kasei Asahi Kasei Corp.
31+atlas Atlas Scientific LLC
3132 atmel Atmel Corporation
3233 auo AU Optronics Corporation
3334 avago Avago Technologies
MAINTAINERS+6−0
@@ -1945,6 +1945,12 @@ M: Nicolas Ferre <nicolas.ferre@atmel.com> · 1944 unmodified lines
19451945 S: Supported
19461946 F: drivers/tty/serial/atmel_serial.c
19471947
1948+ATMEL SAMA5D2 ADC DRIVER
1949+M: Ludovic Desroches <ludovic.desroches@atmel.com>
1950+L: linux-iio@vger.kernel.org
1951+S: Supported
1952+F: drivers/iio/adc/at91-sama5d2_adc.c
1953+
19481954 ATMEL Audio ALSA driver
19491955 M: Nicolas Ferre <nicolas.ferre@atmel.com>
19501956 L: alsa-devel@alsa-project.org (moderated for non-subscribers)
drivers/iio/accel/Kconfig+1−1
@@ -143,7 +143,7 @@ config MMA8452 · 142 unmodified lines
143143 select IIO_TRIGGERED_BUFFER
144144 help
145145 Say yes here to build support for the following Freescale 3-axis
146− accelerometers: MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC.
146+ accelerometers: MMA8451Q, MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC.
147147
148148 To compile this driver as a module, choose M here: the module
149149 will be called mma8452.
drivers/iio/accel/mma8452.c+182−24
@@ -1,6 +1,7 @@
11 /*
22 * mma8452.c - Support for following Freescale 3-axis accelerometers:
33 *
4+ * MMA8451Q (14 bit)
45 * MMA8452Q (12 bit)
56 * MMA8453Q (10 bit)
67 * MMA8652FC (12 bit)
@@ -15,7 +16,7 @@ · 8 unmodified lines
1516 *
1617 * 7-bit I2C slave address 0x1c/0x1d (pin selectable)
1718 *
18− * TODO: orientation / freefall events, autosleep
19+ * TODO: orientation events, autosleep
1920 */
2021
2122 #include <linux/module.h>
@@ -85,8 +86,9 @@ · 63 unmodified lines
8586 #define MMA8452_INT_FF_MT BIT(2)
8687 #define MMA8452_INT_TRANS BIT(5)
8788
88−#define MMA8452_DEVICE_ID 0x2a
89−#define MMA8453_DEVICE_ID 0x3a
89+#define MMA8451_DEVICE_ID 0x1a
90+#define MMA8452_DEVICE_ID 0x2a
91+#define MMA8453_DEVICE_ID 0x3a
9092 #define MMA8652_DEVICE_ID 0x4a
9193 #define MMA8653_DEVICE_ID 0x5a
9294
@@ -416,6 +418,51 @@ fail: · 323 unmodified lines
416418 return ret;
417419 }
418420
421+/* returns >0 if in freefall mode, 0 if not or <0 if an error occured */
422+static int mma8452_freefall_mode_enabled(struct mma8452_data *data)
423+{
424+ int val;
425+ const struct mma_chip_info *chip = data->chip_info;
426+
427+ val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg);
428+ if (val < 0)
429+ return val;
430+
431+ return !(val & MMA8452_FF_MT_CFG_OAE);
432+}
433+
434+static int mma8452_set_freefall_mode(struct mma8452_data *data, bool state)
435+{
436+ int val;
437+ const struct mma_chip_info *chip = data->chip_info;
438+
439+ if ((state && mma8452_freefall_mode_enabled(data)) ||
440+ (!state && !(mma8452_freefall_mode_enabled(data))))
441+ return 0;
442+
443+ val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg);
444+ if (val < 0)
445+ return val;
446+
447+ if (state) {
448+ val |= BIT(idx_x + chip->ev_cfg_chan_shift);
449+ val |= BIT(idx_y + chip->ev_cfg_chan_shift);
450+ val |= BIT(idx_z + chip->ev_cfg_chan_shift);
451+ val &= ~MMA8452_FF_MT_CFG_OAE;
452+ } else {
453+ val &= ~BIT(idx_x + chip->ev_cfg_chan_shift);
454+ val &= ~BIT(idx_y + chip->ev_cfg_chan_shift);
455+ val &= ~BIT(idx_z + chip->ev_cfg_chan_shift);
456+ val |= MMA8452_FF_MT_CFG_OAE;
457+ }
458+
459+ val = mma8452_change_config(data, chip->ev_cfg, val);
460+ if (val)
461+ return val;
462+
463+ return 0;
464+}
465+
419466 static int mma8452_set_hp_filter_frequency(struct mma8452_data *data,
420467 int val, int val2)
421468 {
@@ -609,12 +656,22 @@ static int mma8452_read_event_config(struct iio_dev *indio_dev, · 187 unmodified lines
609656 const struct mma_chip_info *chip = data->chip_info;
610657 int ret;
611658
612− ret = i2c_smbus_read_byte_data(data->client,
613− data->chip_info->ev_cfg);
614− if (ret < 0)
615− return ret;
659+ switch (dir) {
660+ case IIO_EV_DIR_FALLING:
661+ return mma8452_freefall_mode_enabled(data);
662+ case IIO_EV_DIR_RISING:
663+ if (mma8452_freefall_mode_enabled(data))
664+ return 0;
665+
666+ ret = i2c_smbus_read_byte_data(data->client,
667+ data->chip_info->ev_cfg);
668+ if (ret < 0)
669+ return ret;
616670
617− return !!(ret & BIT(chan->scan_index + chip->ev_cfg_chan_shift));
671+ return !!(ret & BIT(chan->scan_index + chip->ev_cfg_chan_shift));
672+ default:
673+ return -EINVAL;
674+ }
618675 }
619676
620677 static int mma8452_write_event_config(struct iio_dev *indio_dev,
@@ -627,19 +684,35 @@ static int mma8452_write_event_config(struct iio_dev *indio_dev, · 6 unmodified lines
627684 const struct mma_chip_info *chip = data->chip_info;
628685 int val;
629686
630− val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg);
631− if (val < 0)
632− return val;
687+ switch (dir) {
688+ case IIO_EV_DIR_FALLING:
689+ return mma8452_set_freefall_mode(data, state);
690+ case IIO_EV_DIR_RISING:
691+ val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg);
692+ if (val < 0)
693+ return val;
694+
695+ if (state) {
696+ if (mma8452_freefall_mode_enabled(data)) {
697+ val &= ~BIT(idx_x + chip->ev_cfg_chan_shift);
698+ val &= ~BIT(idx_y + chip->ev_cfg_chan_shift);
699+ val &= ~BIT(idx_z + chip->ev_cfg_chan_shift);
700+ val |= MMA8452_FF_MT_CFG_OAE;
701+ }
702+ val |= BIT(chan->scan_index + chip->ev_cfg_chan_shift);
703+ } else {
704+ if (mma8452_freefall_mode_enabled(data))
705+ return 0;
633706
634− if (state)
635− val |= BIT(chan->scan_index + chip->ev_cfg_chan_shift);
636− else
637− val &= ~BIT(chan->scan_index + chip->ev_cfg_chan_shift);
707+ val &= ~BIT(chan->scan_index + chip->ev_cfg_chan_shift);
708+ }
638709
639− val |= chip->ev_cfg_ele;
640− val |= MMA8452_FF_MT_CFG_OAE;
710+ val |= chip->ev_cfg_ele;
641711
642− return mma8452_change_config(data, chip->ev_cfg, val);
712+ return mma8452_change_config(data, chip->ev_cfg, val);
713+ default:
714+ return -EINVAL;
715+ }
643716 }
644717
645718 static void mma8452_transient_interrupt(struct iio_dev *indio_dev)
@@ -652,6 +725,16 @@ static void mma8452_transient_interrupt(struct iio_dev *indio_dev) · 6 unmodified lines
652725 if (src < 0)
653726 return;
654727
728+ if (mma8452_freefall_mode_enabled(data)) {
729+ iio_push_event(indio_dev,
730+ IIO_MOD_EVENT_CODE(IIO_ACCEL, 0,
731+ IIO_MOD_X_AND_Y_AND_Z,
732+ IIO_EV_TYPE_MAG,
733+ IIO_EV_DIR_FALLING),
734+ ts);
735+ return;
736+ }
737+
655738 if (src & data->chip_info->ev_src_xe)
656739 iio_push_event(indio_dev,
657740 IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X,
@@ -745,6 +828,27 @@ static int mma8452_reg_access_dbg(struct iio_dev *indio_dev, · 87 unmodified lines
745828 return 0;
746829 }
747830
831+static const struct iio_event_spec mma8452_freefall_event[] = {
832+ {
833+ .type = IIO_EV_TYPE_MAG,
834+ .dir = IIO_EV_DIR_FALLING,
835+ .mask_separate = BIT(IIO_EV_INFO_ENABLE),
836+ .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) |
837+ BIT(IIO_EV_INFO_PERIOD) |
838+ BIT(IIO_EV_INFO_HIGH_PASS_FILTER_3DB)
839+ },
840+};
841+
842+static const struct iio_event_spec mma8652_freefall_event[] = {
843+ {
844+ .type = IIO_EV_TYPE_MAG,
845+ .dir = IIO_EV_DIR_FALLING,
846+ .mask_separate = BIT(IIO_EV_INFO_ENABLE),
847+ .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) |
848+ BIT(IIO_EV_INFO_PERIOD)
849+ },
850+};
851+
748852 static const struct iio_event_spec mma8452_transient_event[] = {
749853 {
750854 .type = IIO_EV_TYPE_MAG,
@@ -781,6 +885,24 @@ static struct attribute_group mma8452_event_attribute_group = { · 30 unmodified lines
781885 .attrs = mma8452_event_attributes,
782886 };
783887
888+#define MMA8452_FREEFALL_CHANNEL(modifier) { \
889+ .type = IIO_ACCEL, \
890+ .modified = 1, \
891+ .channel2 = modifier, \
892+ .scan_index = -1, \
893+ .event_spec = mma8452_freefall_event, \
894+ .num_event_specs = ARRAY_SIZE(mma8452_freefall_event), \
895+}
896+
897+#define MMA8652_FREEFALL_CHANNEL(modifier) { \
898+ .type = IIO_ACCEL, \
899+ .modified = 1, \
900+ .channel2 = modifier, \
901+ .scan_index = -1, \
902+ .event_spec = mma8652_freefall_event, \
903+ .num_event_specs = ARRAY_SIZE(mma8652_freefall_event), \
904+}
905+
784906 #define MMA8452_CHANNEL(axis, idx, bits) { \
785907 .type = IIO_ACCEL, \
786908 .modified = 1, \
@@ -822,11 +944,20 @@ static struct attribute_group mma8452_event_attribute_group = { · 35 unmodified lines
822944 .num_event_specs = ARRAY_SIZE(mma8452_motion_event), \
823945 }
824946
947+static const struct iio_chan_spec mma8451_channels[] = {
948+ MMA8452_CHANNEL(X, idx_x, 14),
949+ MMA8452_CHANNEL(Y, idx_y, 14),
950+ MMA8452_CHANNEL(Z, idx_z, 14),
951+ IIO_CHAN_SOFT_TIMESTAMP(idx_ts),
952+ MMA8452_FREEFALL_CHANNEL(IIO_MOD_X_AND_Y_AND_Z),
953+};
954+
825955 static const struct iio_chan_spec mma8452_channels[] = {
826956 MMA8452_CHANNEL(X, idx_x, 12),
827957 MMA8452_CHANNEL(Y, idx_y, 12),
828958 MMA8452_CHANNEL(Z, idx_z, 12),
829959 IIO_CHAN_SOFT_TIMESTAMP(idx_ts),
960+ MMA8452_FREEFALL_CHANNEL(IIO_MOD_X_AND_Y_AND_Z),
830961 };
831962
832963 static const struct iio_chan_spec mma8453_channels[] = {
@@ -834,6 +965,7 @@ static const struct iio_chan_spec mma8453_channels[] = { · 1 unmodified line
834965 MMA8452_CHANNEL(Y, idx_y, 10),
835966 MMA8452_CHANNEL(Z, idx_z, 10),
836967 IIO_CHAN_SOFT_TIMESTAMP(idx_ts),
968+ MMA8452_FREEFALL_CHANNEL(IIO_MOD_X_AND_Y_AND_Z),
837969 };
838970
839971 static const struct iio_chan_spec mma8652_channels[] = {
@@ -841,6 +973,7 @@ static const struct iio_chan_spec mma8652_channels[] = { · 1 unmodified line
841973 MMA8652_CHANNEL(Y, idx_y, 12),
842974 MMA8652_CHANNEL(Z, idx_z, 12),
843975 IIO_CHAN_SOFT_TIMESTAMP(idx_ts),
976+ MMA8652_FREEFALL_CHANNEL(IIO_MOD_X_AND_Y_AND_Z),
844977 };
845978
846979 static const struct iio_chan_spec mma8653_channels[] = {
@@ -848,9 +981,11 @@ static const struct iio_chan_spec mma8653_channels[] = { · 1 unmodified line
848981 MMA8652_CHANNEL(Y, idx_y, 10),
849982 MMA8652_CHANNEL(Z, idx_z, 10),
850983 IIO_CHAN_SOFT_TIMESTAMP(idx_ts),
984+ MMA8652_FREEFALL_CHANNEL(IIO_MOD_X_AND_Y_AND_Z),
851985 };
852986
853987 enum {
988+ mma8451,
854989 mma8452,
855990 mma8453,
856991 mma8652,
@@ -858,17 +993,34 @@ enum { · 1 unmodified line
858993 };
859994
860995 static const struct mma_chip_info mma_chip_info_table[] = {
861− [mma8452] = {
862− .chip_id = MMA8452_DEVICE_ID,
863− .channels = mma8452_channels,
864− .num_channels = ARRAY_SIZE(mma8452_channels),
996+ [mma8451] = {
997+ .chip_id = MMA8451_DEVICE_ID,
998+ .channels = mma8451_channels,
999+ .num_channels = ARRAY_SIZE(mma8451_channels),
8651000 /*
8661001 * Hardware has fullscale of -2G, -4G, -8G corresponding to
867− * raw value -2048 for 12 bit or -512 for 10 bit.
1002+ * raw value -8192 for 14 bit, -2048 for 12 bit or -512 for 10
1003+ * bit.
8681004 * The userspace interface uses m/s^2 and we declare micro units
8691005 * So scale factor for 12 bit here is given by:
870− * g * N * 1000000 / 2048 for N = 2, 4, 8 and g=9.80665
1006+ * g * N * 1000000 / 2048 for N = 2, 4, 8 and g=9.80665
8711007 */
1008+ .mma_scales = { {0, 2394}, {0, 4788}, {0, 9577} },
1009+ .ev_cfg = MMA8452_TRANSIENT_CFG,
1010+ .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
1011+ .ev_cfg_chan_shift = 1,
1012+ .ev_src = MMA8452_TRANSIENT_SRC,
1013+ .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE,
1014+ .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE,
1015+ .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE,
1016+ .ev_ths = MMA8452_TRANSIENT_THS,
1017+ .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK,
1018+ .ev_count = MMA8452_TRANSIENT_COUNT,
1019+ },
1020+ [mma8452] = {
1021+ .chip_id = MMA8452_DEVICE_ID,
1022+ .channels = mma8452_channels,
1023+ .num_channels = ARRAY_SIZE(mma8452_channels),
8721024 .mma_scales = { {0, 9577}, {0, 19154}, {0, 38307} },
8731025 .ev_cfg = MMA8452_TRANSIENT_CFG,
8741026 .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
@@ -1049,6 +1201,7 @@ static int mma8452_reset(struct i2c_client *client) · 174 unmodified lines
10491201 }
10501202
10511203 static const struct of_device_id mma8452_dt_ids[] = {
1204+ { .compatible = "fsl,mma8451", .data = &mma_chip_info_table[mma8451] },
10521205 { .compatible = "fsl,mma8452", .data = &mma_chip_info_table[mma8452] },
10531206 { .compatible = "fsl,mma8453", .data = &mma_chip_info_table[mma8453] },
10541207 { .compatible = "fsl,mma8652", .data = &mma_chip_info_table[mma8652] },
@@ -1085,6 +1238,7 @@ static int mma8452_probe(struct i2c_client *client, · 30 unmodified lines
10851238 return ret;
10861239
10871240 switch (ret) {
1241+ case MMA8451_DEVICE_ID:
10881242 case MMA8452_DEVICE_ID:
10891243 case MMA8453_DEVICE_ID:
10901244 case MMA8652_DEVICE_ID:
@@ -1190,6 +1344,10 @@ static int mma8452_probe(struct i2c_client *client, · 99 unmodified lines
11901344 if (ret < 0)
11911345 goto buffer_cleanup;
11921346
1347+ ret = mma8452_set_freefall_mode(data, false);
1348+ if (ret)
1349+ return ret;
1350+
11931351 return 0;
11941352
11951353 buffer_cleanup:
drivers/iio/accel/st_accel_core.c+16−0
@@ -67,6 +67,8 @@ · 66 unmodified lines
6767 #define ST_ACCEL_1_DRDY_IRQ_ADDR 0x22
6868 #define ST_ACCEL_1_DRDY_IRQ_INT1_MASK 0x10
6969 #define ST_ACCEL_1_DRDY_IRQ_INT2_MASK 0x08
70+#define ST_ACCEL_1_IHL_IRQ_ADDR 0x25
71+#define ST_ACCEL_1_IHL_IRQ_MASK 0x02
7072 #define ST_ACCEL_1_MULTIREAD_BIT true
7173
7274 /* CUSTOM VALUES FOR SENSOR 2 */
@@ -92,6 +94,8 @@ · 19 unmodified lines
9294 #define ST_ACCEL_2_DRDY_IRQ_ADDR 0x22
9395 #define ST_ACCEL_2_DRDY_IRQ_INT1_MASK 0x02
9496 #define ST_ACCEL_2_DRDY_IRQ_INT2_MASK 0x10
97+#define ST_ACCEL_2_IHL_IRQ_ADDR 0x22
98+#define ST_ACCEL_2_IHL_IRQ_MASK 0x80
9599 #define ST_ACCEL_2_MULTIREAD_BIT true
96100
97101 /* CUSTOM VALUES FOR SENSOR 3 */
@@ -125,6 +129,8 @@ · 27 unmodified lines
125129 #define ST_ACCEL_3_DRDY_IRQ_ADDR 0x23
126130 #define ST_ACCEL_3_DRDY_IRQ_INT1_MASK 0x80
127131 #define ST_ACCEL_3_DRDY_IRQ_INT2_MASK 0x00
132+#define ST_ACCEL_3_IHL_IRQ_ADDR 0x23
133+#define ST_ACCEL_3_IHL_IRQ_MASK 0x40
128134 #define ST_ACCEL_3_IG1_EN_ADDR 0x23
129135 #define ST_ACCEL_3_IG1_EN_MASK 0x08
130136 #define ST_ACCEL_3_MULTIREAD_BIT false
@@ -169,6 +175,8 @@ · 38 unmodified lines
169175 #define ST_ACCEL_5_DRDY_IRQ_ADDR 0x22
170176 #define ST_ACCEL_5_DRDY_IRQ_INT1_MASK 0x04
171177 #define ST_ACCEL_5_DRDY_IRQ_INT2_MASK 0x20
178+#define ST_ACCEL_5_IHL_IRQ_ADDR 0x22
179+#define ST_ACCEL_5_IHL_IRQ_MASK 0x80
172180 #define ST_ACCEL_5_IG1_EN_ADDR 0x21
173181 #define ST_ACCEL_5_IG1_EN_MASK 0x08
174182 #define ST_ACCEL_5_MULTIREAD_BIT false
@@ -292,6 +300,8 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { · 117 unmodified lines
292300 .addr = ST_ACCEL_1_DRDY_IRQ_ADDR,
293301 .mask_int1 = ST_ACCEL_1_DRDY_IRQ_INT1_MASK,
294302 .mask_int2 = ST_ACCEL_1_DRDY_IRQ_INT2_MASK,
303+ .addr_ihl = ST_ACCEL_1_IHL_IRQ_ADDR,
304+ .mask_ihl = ST_ACCEL_1_IHL_IRQ_MASK,
295305 },
296306 .multi_read_bit = ST_ACCEL_1_MULTIREAD_BIT,
297307 .bootime = 2,
@@ -355,6 +365,8 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { · 57 unmodified lines
355365 .addr = ST_ACCEL_2_DRDY_IRQ_ADDR,
356366 .mask_int1 = ST_ACCEL_2_DRDY_IRQ_INT1_MASK,
357367 .mask_int2 = ST_ACCEL_2_DRDY_IRQ_INT2_MASK,
368+ .addr_ihl = ST_ACCEL_2_IHL_IRQ_ADDR,
369+ .mask_ihl = ST_ACCEL_2_IHL_IRQ_MASK,
358370 },
359371 .multi_read_bit = ST_ACCEL_2_MULTIREAD_BIT,
360372 .bootime = 2,
@@ -430,6 +442,8 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { · 69 unmodified lines
430442 .addr = ST_ACCEL_3_DRDY_IRQ_ADDR,
431443 .mask_int1 = ST_ACCEL_3_DRDY_IRQ_INT1_MASK,
432444 .mask_int2 = ST_ACCEL_3_DRDY_IRQ_INT2_MASK,
445+ .addr_ihl = ST_ACCEL_3_IHL_IRQ_ADDR,
446+ .mask_ihl = ST_ACCEL_3_IHL_IRQ_MASK,
433447 .ig1 = {
434448 .en_addr = ST_ACCEL_3_IG1_EN_ADDR,
435449 .en_mask = ST_ACCEL_3_IG1_EN_MASK,
@@ -537,6 +551,8 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { · 101 unmodified lines
537551 .addr = ST_ACCEL_5_DRDY_IRQ_ADDR,
538552 .mask_int1 = ST_ACCEL_5_DRDY_IRQ_INT1_MASK,
539553 .mask_int2 = ST_ACCEL_5_DRDY_IRQ_INT2_MASK,
554+ .addr_ihl = ST_ACCEL_5_IHL_IRQ_ADDR,
555+ .mask_ihl = ST_ACCEL_5_IHL_IRQ_MASK,
540556 },
541557 .multi_read_bit = ST_ACCEL_5_MULTIREAD_BIT,
542558 .bootime = 2, /* guess */
drivers/iio/adc/Kconfig+13−3
@@ -131,6 +131,16 @@ config AT91_ADC · 130 unmodified lines
131131 To compile this driver as a module, choose M here: the module will be
132132 called at91_adc.
133133
134+config AT91_SAMA5D2_ADC
135+ tristate "Atmel AT91 SAMA5D2 ADC"
136+ depends on ARCH_AT91 || COMPILE_TEST
137+ help
138+ Say yes here to build support for Atmel SAMA5D2 ADC which is
139+ available on SAMA5D2 SoC family.
140+
141+ To compile this driver as a module, choose M here: the module will be
142+ called at91-sama5d2_adc.
143+
134144 config AXP288_ADC
135145 tristate "X-Powers AXP288 ADC driver"
136146 depends on MFD_AXP20X
@@ -265,11 +275,11 @@ config MCP320X · 128 unmodified lines
265275 called mcp320x.
266276
267277 config MCP3422
268− tristate "Microchip Technology MCP3422/3/4/6/7/8 driver"
278+ tristate "Microchip Technology MCP3421/2/3/4/5/6/7/8 driver"
269279 depends on I2C
270280 help
271− Say yes here to build support for Microchip Technology's
272− MCP3422, MCP3423, MCP3424, MCP3426, MCP3427 or MCP3428
281+ Say yes here to build support for Microchip Technology's MCP3421
282+ MCP3422, MCP3423, MCP3424, MCP3425, MCP3426, MCP3427 or MCP3428
273283 analog to digital converters.
274284
275285 This driver can also be built as a module. If so, the module will be
drivers/iio/adc/Makefile+1−0
@@ -14,6 +14,7 @@ obj-$(CONFIG_AD7793) += ad7793.o · 13 unmodified lines
1414 obj-$(CONFIG_AD7887) += ad7887.o
1515 obj-$(CONFIG_AD799X) += ad799x.o
1616 obj-$(CONFIG_AT91_ADC) += at91_adc.o
17+obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
1718 obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
1819 obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
1920 obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
drivers/iio/adc/at91-sama5d2_adc.c+508−0
@@ -0,0 +1,508 @@
1+/*
2+ * Atmel ADC driver for SAMA5D2 devices and compatible.
3+ *
4+ * Copyright (C) 2015 Atmel,
5+ * 2015 Ludovic Desroches <ludovic.desroches@atmel.com>
6+ *
7+ * This software is licensed under the terms of the GNU General Public
8+ * License version 2, as published by the Free Software Foundation, and
9+ * may be copied, distributed, and modified under those terms.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ */
16+
17+#include <linux/bitops.h>
18+#include <linux/clk.h>
19+#include <linux/interrupt.h>
20+#include <linux/io.h>
21+#include <linux/module.h>
22+#include <linux/of_device.h>
23+#include <linux/platform_device.h>
24+#include <linux/sched.h>
25+#include <linux/wait.h>
26+#include <linux/iio/iio.h>
27+#include <linux/iio/sysfs.h>
28+#include <linux/regulator/consumer.h>
29+
30+/* Control Register */
31+#define AT91_SAMA5D2_CR 0x00
32+/* Software Reset */
33+#define AT91_SAMA5D2_CR_SWRST BIT(0)
34+/* Start Conversion */
35+#define AT91_SAMA5D2_CR_START BIT(1)
36+/* Touchscreen Calibration */
37+#define AT91_SAMA5D2_CR_TSCALIB BIT(2)
38+/* Comparison Restart */
39+#define AT91_SAMA5D2_CR_CMPRST BIT(4)
40+
41+/* Mode Register */
42+#define AT91_SAMA5D2_MR 0x04
43+/* Trigger Selection */
44+#define AT91_SAMA5D2_MR_TRGSEL(v) ((v) << 1)
45+/* ADTRG */
46+#define AT91_SAMA5D2_MR_TRGSEL_TRIG0 0
47+/* TIOA0 */
48+#define AT91_SAMA5D2_MR_TRGSEL_TRIG1 1
49+/* TIOA1 */
50+#define AT91_SAMA5D2_MR_TRGSEL_TRIG2 2
51+/* TIOA2 */
52+#define AT91_SAMA5D2_MR_TRGSEL_TRIG3 3
53+/* PWM event line 0 */
54+#define AT91_SAMA5D2_MR_TRGSEL_TRIG4 4
55+/* PWM event line 1 */
56+#define AT91_SAMA5D2_MR_TRGSEL_TRIG5 5
57+/* TIOA3 */
58+#define AT91_SAMA5D2_MR_TRGSEL_TRIG6 6
59+/* RTCOUT0 */
60+#define AT91_SAMA5D2_MR_TRGSEL_TRIG7 7
61+/* Sleep Mode */
62+#define AT91_SAMA5D2_MR_SLEEP BIT(5)
63+/* Fast Wake Up */
64+#define AT91_SAMA5D2_MR_FWUP BIT(6)
65+/* Prescaler Rate Selection */
66+#define AT91_SAMA5D2_MR_PRESCAL(v) ((v) << AT91_SAMA5D2_MR_PRESCAL_OFFSET)
67+#define AT91_SAMA5D2_MR_PRESCAL_OFFSET 8
68+#define AT91_SAMA5D2_MR_PRESCAL_MAX 0xff
69+/* Startup Time */
70+#define AT91_SAMA5D2_MR_STARTUP(v) ((v) << 16)
71+/* Analog Change */
72+#define AT91_SAMA5D2_MR_ANACH BIT(23)
73+/* Tracking Time */
74+#define AT91_SAMA5D2_MR_TRACKTIM(v) ((v) << 24)
75+#define AT91_SAMA5D2_MR_TRACKTIM_MAX 0xff
76+/* Transfer Time */
77+#define AT91_SAMA5D2_MR_TRANSFER(v) ((v) << 28)
78+#define AT91_SAMA5D2_MR_TRANSFER_MAX 0x3
79+/* Use Sequence Enable */
80+#define AT91_SAMA5D2_MR_USEQ BIT(31)
81+
82+/* Channel Sequence Register 1 */
83+#define AT91_SAMA5D2_SEQR1 0x08
84+/* Channel Sequence Register 2 */
85+#define AT91_SAMA5D2_SEQR2 0x0c
86+/* Channel Enable Register */
87+#define AT91_SAMA5D2_CHER 0x10
88+/* Channel Disable Register */
89+#define AT91_SAMA5D2_CHDR 0x14
90+/* Channel Status Register */
91+#define AT91_SAMA5D2_CHSR 0x18
92+/* Last Converted Data Register */
93+#define AT91_SAMA5D2_LCDR 0x20
94+/* Interrupt Enable Register */
95+#define AT91_SAMA5D2_IER 0x24
96+/* Interrupt Disable Register */
97+#define AT91_SAMA5D2_IDR 0x28
98+/* Interrupt Mask Register */
99+#define AT91_SAMA5D2_IMR 0x2c
100+/* Interrupt Status Register */
101+#define AT91_SAMA5D2_ISR 0x30
102+/* Last Channel Trigger Mode Register */
103+#define AT91_SAMA5D2_LCTMR 0x34
104+/* Last Channel Compare Window Register */
105+#define AT91_SAMA5D2_LCCWR 0x38
106+/* Overrun Status Register */
107+#define AT91_SAMA5D2_OVER 0x3c
108+/* Extended Mode Register */
109+#define AT91_SAMA5D2_EMR 0x40
110+/* Compare Window Register */
111+#define AT91_SAMA5D2_CWR 0x44
112+/* Channel Gain Register */
113+#define AT91_SAMA5D2_CGR 0x48
114+/* Channel Offset Register */
115+#define AT91_SAMA5D2_COR 0x4c
116+/* Channel Data Register 0 */
117+#define AT91_SAMA5D2_CDR0 0x50
118+/* Analog Control Register */
119+#define AT91_SAMA5D2_ACR 0x94
120+/* Touchscreen Mode Register */
121+#define AT91_SAMA5D2_TSMR 0xb0
122+/* Touchscreen X Position Register */
123+#define AT91_SAMA5D2_XPOSR 0xb4
124+/* Touchscreen Y Position Register */
125+#define AT91_SAMA5D2_YPOSR 0xb8
126+/* Touchscreen Pressure Register */
127+#define AT91_SAMA5D2_PRESSR 0xbc
128+/* Trigger Register */
129+#define AT91_SAMA5D2_TRGR 0xc0
130+/* Correction Select Register */
131+#define AT91_SAMA5D2_COSR 0xd0
132+/* Correction Value Register */
133+#define AT91_SAMA5D2_CVR 0xd4
134+/* Channel Error Correction Register */
135+#define AT91_SAMA5D2_CECR 0xd8
136+/* Write Protection Mode Register */
137+#define AT91_SAMA5D2_WPMR 0xe4
138+/* Write Protection Status Register */
139+#define AT91_SAMA5D2_WPSR 0xe8
140+/* Version Register */
141+#define AT91_SAMA5D2_VERSION 0xfc
142+
143+#define AT91_AT91_SAMA5D2_CHAN(num, addr) \
144+ { \
145+ .type = IIO_VOLTAGE, \
146+ .channel = num, \
147+ .address = addr, \
148+ .scan_type = { \
149+ .sign = 'u', \
150+ .realbits = 12, \
151+ }, \
152+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
153+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
154+ .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
155+ .datasheet_name = "CH"#num, \
156+ .indexed = 1, \
157+ }
158+
159+#define at91_adc_readl(st, reg) readl_relaxed(st->base + reg)
160+#define at91_adc_writel(st, reg, val) writel_relaxed(val, st->base + reg)
161+
162+struct at91_adc_soc_info {
163+ unsigned startup_time;
164+ unsigned min_sample_rate;
165+ unsigned max_sample_rate;
166+};
167+
168+struct at91_adc_state {
169+ void __iomem *base;
170+ int irq;
171+ struct clk *per_clk;
172+ struct regulator *reg;
173+ struct regulator *vref;
174+ int vref_uv;
175+ const struct iio_chan_spec *chan;
176+ bool conversion_done;
177+ u32 conversion_value;
178+ struct at91_adc_soc_info soc_info;
179+ wait_queue_head_t wq_data_available;
180+ /*
181+ * lock to prevent concurrent 'single conversion' requests through
182+ * sysfs.
183+ */
184+ struct mutex lock;
185+};
186+
187+static const struct iio_chan_spec at91_adc_channels[] = {
188+ AT91_AT91_SAMA5D2_CHAN(0, 0x50),
189+ AT91_AT91_SAMA5D2_CHAN(1, 0x54),
190+ AT91_AT91_SAMA5D2_CHAN(2, 0x58),
191+ AT91_AT91_SAMA5D2_CHAN(3, 0x5c),
192+ AT91_AT91_SAMA5D2_CHAN(4, 0x60),
193+ AT91_AT91_SAMA5D2_CHAN(5, 0x64),
194+ AT91_AT91_SAMA5D2_CHAN(6, 0x68),
195+ AT91_AT91_SAMA5D2_CHAN(7, 0x6c),
196+ AT91_AT91_SAMA5D2_CHAN(8, 0x70),
197+ AT91_AT91_SAMA5D2_CHAN(9, 0x74),
198+ AT91_AT91_SAMA5D2_CHAN(10, 0x78),
199+ AT91_AT91_SAMA5D2_CHAN(11, 0x7c),
200+};
201+
202+static unsigned at91_adc_startup_time(unsigned startup_time_min,
203+ unsigned adc_clk_khz)
204+{
205+ const unsigned startup_lookup[] = {
206+ 0, 8, 16, 24,
207+ 64, 80, 96, 112,
208+ 512, 576, 640, 704,
209+ 768, 832, 896, 960
210+ };
211+ unsigned ticks_min, i;
212+
213+ /*
214+ * Since the adc frequency is checked before, there is no reason
215+ * to not meet the startup time constraint.
216+ */
217+
218+ ticks_min = startup_time_min * adc_clk_khz / 1000;
219+ for (i = 0; i < ARRAY_SIZE(startup_lookup); i++)
220+ if (startup_lookup[i] > ticks_min)
221+ break;
222+
223+ return i;
224+}
225+
226+static void at91_adc_setup_samp_freq(struct at91_adc_state *st, unsigned freq)
227+{
228+ struct iio_dev *indio_dev = iio_priv_to_dev(st);
229+ unsigned f_per, prescal, startup;
230+
231+ f_per = clk_get_rate(st->per_clk);
232+ prescal = (f_per / (2 * freq)) - 1;
233+
234+ startup = at91_adc_startup_time(st->soc_info.startup_time,
235+ freq / 1000);
236+
237+ at91_adc_writel(st, AT91_SAMA5D2_MR,
238+ AT91_SAMA5D2_MR_TRANSFER(2)
239+ | AT91_SAMA5D2_MR_STARTUP(startup)
240+ | AT91_SAMA5D2_MR_PRESCAL(prescal));
241+
242+ dev_dbg(&indio_dev->dev, "freq: %u, startup: %u, prescal: %u\n",
243+ freq, startup, prescal);
244+}
245+
246+static unsigned at91_adc_get_sample_freq(struct at91_adc_state *st)
247+{
248+ unsigned f_adc, f_per = clk_get_rate(st->per_clk);
249+ unsigned mr, prescal;
250+
251+ mr = at91_adc_readl(st, AT91_SAMA5D2_MR);
252+ prescal = (mr >> AT91_SAMA5D2_MR_PRESCAL_OFFSET)
253+ & AT91_SAMA5D2_MR_PRESCAL_MAX;
254+ f_adc = f_per / (2 * (prescal + 1));
255+
256+ return f_adc;
257+}
258+
259+static irqreturn_t at91_adc_interrupt(int irq, void *private)
260+{
261+ struct iio_dev *indio = private;
262+ struct at91_adc_state *st = iio_priv(indio);
263+ u32 status = at91_adc_readl(st, AT91_SAMA5D2_ISR);
264+ u32 imr = at91_adc_readl(st, AT91_SAMA5D2_IMR);
265+
266+ if (status & imr) {
267+ st->conversion_value = at91_adc_readl(st, st->chan->address);
268+ st->conversion_done = true;
269+ wake_up_interruptible(&st->wq_data_available);
270+ return IRQ_HANDLED;
271+ }
272+
273+ return IRQ_NONE;
274+}
275+
276+static int at91_adc_read_raw(struct iio_dev *indio_dev,
277+ struct iio_chan_spec const *chan,
278+ int *val, int *val2, long mask)
279+{
280+ struct at91_adc_state *st = iio_priv(indio_dev);
281+ int ret;
282+
283+ switch (mask) {
284+ case IIO_CHAN_INFO_RAW:
285+ mutex_lock(&st->lock);
286+
287+ st->chan = chan;
288+
289+ at91_adc_writel(st, AT91_SAMA5D2_CHER, BIT(chan->channel));
290+ at91_adc_writel(st, AT91_SAMA5D2_IER, BIT(chan->channel));
291+ at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_START);
292+
293+ ret = wait_event_interruptible_timeout(st->wq_data_available,
294+ st->conversion_done,
295+ msecs_to_jiffies(1000));
296+ if (ret == 0)
297+ ret = -ETIMEDOUT;
298+
299+ if (ret > 0) {
300+ *val = st->conversion_value;
301+ ret = IIO_VAL_INT;
302+ st->conversion_done = false;
303+ }
304+
305+ at91_adc_writel(st, AT91_SAMA5D2_IDR, BIT(chan->channel));
306+ at91_adc_writel(st, AT91_SAMA5D2_CHDR, BIT(chan->channel));
307+
308+ mutex_unlock(&st->lock);
309+ return ret;
310+
311+ case IIO_CHAN_INFO_SCALE:
312+ *val = st->vref_uv / 1000;
313+ *val2 = chan->scan_type.realbits;
314+ return IIO_VAL_FRACTIONAL_LOG2;
315+
316+ case IIO_CHAN_INFO_SAMP_FREQ:
317+ *val = at91_adc_get_sample_freq(st);
318+ return IIO_VAL_INT;
319+
320+ default:
321+ return -EINVAL;
322+ }
323+}
324+
325+static int at91_adc_write_raw(struct iio_dev *indio_dev,
326+ struct iio_chan_spec const *chan,
327+ int val, int val2, long mask)
328+{
329+ struct at91_adc_state *st = iio_priv(indio_dev);
330+
331+ if (mask != IIO_CHAN_INFO_SAMP_FREQ)
332+ return -EINVAL;
333+
334+ if (val < st->soc_info.min_sample_rate ||
335+ val > st->soc_info.max_sample_rate)
336+ return -EINVAL;
337+
338+ at91_adc_setup_samp_freq(st, val);
339+
340+ return 0;
341+}
342+
343+static const struct iio_info at91_adc_info = {
344+ .read_raw = &at91_adc_read_raw,
345+ .write_raw = &at91_adc_write_raw,
346+ .driver_module = THIS_MODULE,
347+};
348+
349+static int at91_adc_probe(struct platform_device *pdev)
350+{
351+ struct iio_dev *indio_dev;
352+ struct at91_adc_state *st;
353+ struct resource *res;
354+ int ret;
355+
356+ indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*st));
357+ if (!indio_dev)
358+ return -ENOMEM;
359+
360+ indio_dev->dev.parent = &pdev->dev;
361+ indio_dev->name = dev_name(&pdev->dev);
362+ indio_dev->modes = INDIO_DIRECT_MODE;
363+ indio_dev->info = &at91_adc_info;
364+ indio_dev->channels = at91_adc_channels;
365+ indio_dev->num_channels = ARRAY_SIZE(at91_adc_channels);
366+
367+ st = iio_priv(indio_dev);
368+
369+ ret = of_property_read_u32(pdev->dev.of_node,
370+ "atmel,min-sample-rate-hz",
371+ &st->soc_info.min_sample_rate);
372+ if (ret) {
373+ dev_err(&pdev->dev,
374+ "invalid or missing value for atmel,min-sample-rate-hz\n");
375+ return ret;
376+ }
377+
378+ ret = of_property_read_u32(pdev->dev.of_node,
379+ "atmel,max-sample-rate-hz",
380+ &st->soc_info.max_sample_rate);
381+ if (ret) {
382+ dev_err(&pdev->dev,
383+ "invalid or missing value for atmel,max-sample-rate-hz\n");
384+ return ret;
385+ }
386+
387+ ret = of_property_read_u32(pdev->dev.of_node, "atmel,startup-time-ms",
388+ &st->soc_info.startup_time);
389+ if (ret) {
390+ dev_err(&pdev->dev,
391+ "invalid or missing value for atmel,startup-time-ms\n");
392+ return ret;
393+ }
394+
395+ init_waitqueue_head(&st->wq_data_available);
396+ mutex_init(&st->lock);
397+
398+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
399+ if (!res)
400+ return -EINVAL;
401+
402+ st->base = devm_ioremap_resource(&pdev->dev, res);
403+ if (IS_ERR(st->base))
404+ return PTR_ERR(st->base);
405+
406+ st->irq = platform_get_irq(pdev, 0);
407+ if (st->irq <= 0) {
408+ if (!st->irq)
409+ st->irq = -ENXIO;
410+
411+ return st->irq;
412+ }
413+
414+ st->per_clk = devm_clk_get(&pdev->dev, "adc_clk");
415+ if (IS_ERR(st->per_clk))
416+ return PTR_ERR(st->per_clk);
417+
418+ st->reg = devm_regulator_get(&pdev->dev, "vddana");
419+ if (IS_ERR(st->reg))
420+ return PTR_ERR(st->reg);
421+
422+ st->vref = devm_regulator_get(&pdev->dev, "vref");
423+ if (IS_ERR(st->vref))
424+ return PTR_ERR(st->vref);
425+
426+ ret = devm_request_irq(&pdev->dev, st->irq, at91_adc_interrupt, 0,
427+ pdev->dev.driver->name, indio_dev);
428+ if (ret)
429+ return ret;
430+
431+ ret = regulator_enable(st->reg);
432+ if (ret)
433+ return ret;
434+
435+ ret = regulator_enable(st->vref);
436+ if (ret)
437+ goto reg_disable;
438+
439+ st->vref_uv = regulator_get_voltage(st->vref);
440+ if (st->vref_uv <= 0) {
441+ ret = -EINVAL;
442+ goto vref_disable;
443+ }
444+
445+ at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
446+ at91_adc_writel(st, AT91_SAMA5D2_IDR, 0xffffffff);
447+
448+ at91_adc_setup_samp_freq(st, st->soc_info.min_sample_rate);
449+
450+ ret = clk_prepare_enable(st->per_clk);
451+ if (ret)
452+ goto vref_disable;
453+
454+ ret = iio_device_register(indio_dev);
455+ if (ret < 0)
456+ goto per_clk_disable_unprepare;
457+
458+ dev_info(&pdev->dev, "version: %x\n",
459+ readl_relaxed(st->base + AT91_SAMA5D2_VERSION));
460+
461+ return 0;
462+
463+per_clk_disable_unprepare:
464+ clk_disable_unprepare(st->per_clk);
465+vref_disable:
466+ regulator_disable(st->vref);
467+reg_disable:
468+ regulator_disable(st->reg);
469+ return ret;
470+}
471+
472+static int at91_adc_remove(struct platform_device *pdev)
473+{
474+ struct iio_dev *indio_dev = platform_get_drvdata(pdev);
475+ struct at91_adc_state *st = iio_priv(indio_dev);
476+
477+ iio_device_unregister(indio_dev);
478+
479+ clk_disable_unprepare(st->per_clk);
480+
481+ regulator_disable(st->vref);
482+ regulator_disable(st->reg);
483+
484+ return 0;
485+}
486+
487+static const struct of_device_id at91_adc_dt_match[] = {
488+ {
489+ .compatible = "atmel,sama5d2-adc",
490+ }, {
491+ /* sentinel */
492+ }
493+};
494+MODULE_DEVICE_TABLE(of, at91_adc_dt_match);
495+
496+static struct platform_driver at91_adc_driver = {
497+ .probe = at91_adc_probe,
498+ .remove = at91_adc_remove,
499+ .driver = {
500+ .name = "at91-sama5d2_adc",
501+ .of_match_table = at91_adc_dt_match,
502+ },
503+};
504+module_platform_driver(at91_adc_driver)
505+
506+MODULE_AUTHOR("Ludovic Desroches <ludovic.desroches@atmel.com>");
507+MODULE_DESCRIPTION("Atmel AT91 SAMA5D2 ADC");
508+MODULE_LICENSE("GPL v2");
drivers/iio/adc/axp288_adc.c+1−1
@@ -46,7 +46,7 @@ struct axp288_adc_info { · 45 unmodified lines
4646 struct regmap *regmap;
4747 };
4848
49−static const struct iio_chan_spec const axp288_adc_channels[] = {
49+static const struct iio_chan_spec axp288_adc_channels[] = {
5050 {
5151 .indexed = 1,
5252 .type = IIO_TEMP,
drivers/iio/adc/mcp320x.c+19−12
@@ -187,26 +187,27 @@ out: · 186 unmodified lines
187187 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \
188188 }
189189
190−#define MCP320X_VOLTAGE_CHANNEL_DIFF(num) \
190+#define MCP320X_VOLTAGE_CHANNEL_DIFF(chan1, chan2) \
191191 { \
192192 .type = IIO_VOLTAGE, \
193193 .indexed = 1, \
194− .channel = (num * 2), \
195− .channel2 = (num * 2 + 1), \
196− .address = (num * 2), \
194+ .channel = (chan1), \
195+ .channel2 = (chan2), \
196+ .address = (chan1), \
197197 .differential = 1, \
198198 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
199199 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \
200200 }
201201
202202 static const struct iio_chan_spec mcp3201_channels[] = {
203− MCP320X_VOLTAGE_CHANNEL_DIFF(0),
203+ MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
204204 };
205205
206206 static const struct iio_chan_spec mcp3202_channels[] = {
207207 MCP320X_VOLTAGE_CHANNEL(0),
208208 MCP320X_VOLTAGE_CHANNEL(1),
209− MCP320X_VOLTAGE_CHANNEL_DIFF(0),
209+ MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
210+ MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
210211 };
211212
212213 static const struct iio_chan_spec mcp3204_channels[] = {
@@ -214,8 +215,10 @@ static const struct iio_chan_spec mcp3204_channels[] = { · 1 unmodified line
214215 MCP320X_VOLTAGE_CHANNEL(1),
215216 MCP320X_VOLTAGE_CHANNEL(2),
216217 MCP320X_VOLTAGE_CHANNEL(3),
217− MCP320X_VOLTAGE_CHANNEL_DIFF(0),
218− MCP320X_VOLTAGE_CHANNEL_DIFF(1),
218+ MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
219+ MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
220+ MCP320X_VOLTAGE_CHANNEL_DIFF(2, 3),
221+ MCP320X_VOLTAGE_CHANNEL_DIFF(3, 2),
219222 };
220223
221224 static const struct iio_chan_spec mcp3208_channels[] = {
@@ -227,10 +230,14 @@ static const struct iio_chan_spec mcp3208_channels[] = { · 5 unmodified lines
227230 MCP320X_VOLTAGE_CHANNEL(5),
228231 MCP320X_VOLTAGE_CHANNEL(6),
229232 MCP320X_VOLTAGE_CHANNEL(7),
230− MCP320X_VOLTAGE_CHANNEL_DIFF(0),
231− MCP320X_VOLTAGE_CHANNEL_DIFF(1),
232− MCP320X_VOLTAGE_CHANNEL_DIFF(2),
233− MCP320X_VOLTAGE_CHANNEL_DIFF(3),
233+ MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
234+ MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
235+ MCP320X_VOLTAGE_CHANNEL_DIFF(2, 3),
236+ MCP320X_VOLTAGE_CHANNEL_DIFF(3, 2),
237+ MCP320X_VOLTAGE_CHANNEL_DIFF(4, 5),
238+ MCP320X_VOLTAGE_CHANNEL_DIFF(5, 4),
239+ MCP320X_VOLTAGE_CHANNEL_DIFF(6, 7),
240+ MCP320X_VOLTAGE_CHANNEL_DIFF(7, 6),
234241 };
235242
236243 static const struct iio_info mcp320x_info = {
drivers/iio/adc/mcp3422.c+5−2
@@ -1,11 +1,12 @@
11 /*
2− * mcp3422.c - driver for the Microchip mcp3422/3/4/6/7/8 chip family
2+ * mcp3422.c - driver for the Microchip mcp3421/2/3/4/5/6/7/8 chip family
33 *
44 * Copyright (C) 2013, Angelo Compagnucci
55 * Author: Angelo Compagnucci <angelo.compagnucci@gmail.com>
66 *
77 * Datasheet: http://ww1.microchip.com/downloads/en/devicedoc/22088b.pdf
88 * http://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf
9+ * http://ww1.microchip.com/downloads/en/DeviceDoc/22072b.pdf
910 *
1011 * This driver exports the value of analog input voltage to sysfs, the
1112 * voltage unit is nV.
@@ -357,6 +358,7 @@ static int mcp3422_probe(struct i2c_client *client, · 345 unmodified lines
357358
358359 switch (adc->id) {
359360 case 1:
361+ case 5:
360362 indio_dev->channels = mcp3421_channels;
361363 indio_dev->num_channels = ARRAY_SIZE(mcp3421_channels);
362364 break;
@@ -395,6 +397,7 @@ static const struct i2c_device_id mcp3422_id[] = { · 32 unmodified lines
395397 { "mcp3422", 2 },
396398 { "mcp3423", 3 },
397399 { "mcp3424", 4 },
400+ { "mcp3425", 5 },
398401 { "mcp3426", 6 },
399402 { "mcp3427", 7 },
400403 { "mcp3428", 8 },
@@ -421,5 +424,5 @@ static struct i2c_driver mcp3422_driver = { · 20 unmodified lines
421424 module_i2c_driver(mcp3422_driver);
422425
423426 MODULE_AUTHOR("Angelo Compagnucci <angelo.compagnucci@gmail.com>");
424−MODULE_DESCRIPTION("Microchip mcp3422/3/4/6/7/8 driver");
427+MODULE_DESCRIPTION("Microchip mcp3421/2/3/4/5/6/7/8 driver");
425428 MODULE_LICENSE("GPL v2");
drivers/iio/chemical/Kconfig+13−0
@@ -4,6 +4,19 @@ · 3 unmodified lines
44
55 menu "Chemical Sensors"
66
7+config ATLAS_PH_SENSOR
8+ tristate "Atlas Scientific OEM pH-SM sensor"
9+ depends on I2C
10+ select REGMAP_I2C
11+ select IIO_BUFFER
12+ select IIO_TRIGGERED_BUFFER
13+ help
14+ Say Y here to build I2C interface support for the Atlas
15+ Scientific OEM pH-SM sensor.
16+
17+ To compile this driver as module, choose M here: the
18+ module will be called atlas-ph-sensor.
19+
720 config IAQCORE
821 tristate "AMS iAQ-Core VOC sensors"
922 depends on I2C
drivers/iio/chemical/Makefile+1−0
@@ -3,5 +3,6 @@ · 2 unmodified lines
33 #
44
55 # When adding new entries keep the list in alphabetical order
6+obj-$(CONFIG_ATLAS_PH_SENSOR) += atlas-ph-sensor.o
67 obj-$(CONFIG_IAQCORE) += ams-iaq-core.o
78 obj-$(CONFIG_VZ89X) += vz89x.o
drivers/iio/chemical/atlas-ph-sensor.c+511−0
@@ -0,0 +1,511 @@
1+/*
2+ * atlas-ph-sensor.c - Support for Atlas Scientific OEM pH-SM sensor
3+ *
4+ * Copyright (C) 2015 Matt Ranostay <mranostay@gmail.com>
5+ *
6+ * This program is free software; you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation; either version 2 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ */
16+
17+#include <linux/module.h>
18+#include <linux/init.h>
19+#include <linux/interrupt.h>
20+#include <linux/delay.h>
21+#include <linux/mutex.h>
22+#include <linux/err.h>
23+#include <linux/irq.h>
24+#include <linux/irq_work.h>
25+#include <linux/gpio.h>
26+#include <linux/i2c.h>
27+#include <linux/regmap.h>
28+#include <linux/iio/iio.h>
29+#include <linux/iio/buffer.h>
30+#include <linux/iio/trigger.h>
31+#include <linux/iio/trigger_consumer.h>
32+#include <linux/iio/triggered_buffer.h>
33+#include <linux/pm_runtime.h>
34+
35+#define ATLAS_REGMAP_NAME "atlas_ph_regmap"
36+#define ATLAS_DRV_NAME "atlas_ph"
37+
38+#define ATLAS_REG_DEV_TYPE 0x00
39+#define ATLAS_REG_DEV_VERSION 0x01
40+
41+#define ATLAS_REG_INT_CONTROL 0x04
42+#define ATLAS_REG_INT_CONTROL_EN BIT(3)
43+
44+#define ATLAS_REG_PWR_CONTROL 0x06
45+
46+#define ATLAS_REG_CALIB_STATUS 0x0d
47+#define ATLAS_REG_CALIB_STATUS_MASK 0x07
48+#define ATLAS_REG_CALIB_STATUS_LOW BIT(0)
49+#define ATLAS_REG_CALIB_STATUS_MID BIT(1)
50+#define ATLAS_REG_CALIB_STATUS_HIGH BIT(2)
51+
52+#define ATLAS_REG_TEMP_DATA 0x0e
53+#define ATLAS_REG_PH_DATA 0x16
54+
55+#define ATLAS_PH_INT_TIME_IN_US 450000
56+
57+struct atlas_data {
58+ struct i2c_client *client;
59+ struct iio_trigger *trig;
60+ struct regmap *regmap;
61+ struct irq_work work;
62+
63+ __be32 buffer[4]; /* 32-bit pH data + 32-bit pad + 64-bit timestamp */
64+};
65+
66+static const struct regmap_range atlas_volatile_ranges[] = {
67+ regmap_reg_range(ATLAS_REG_INT_CONTROL, ATLAS_REG_INT_CONTROL),
68+ regmap_reg_range(ATLAS_REG_CALIB_STATUS, ATLAS_REG_CALIB_STATUS),
69+ regmap_reg_range(ATLAS_REG_TEMP_DATA, ATLAS_REG_TEMP_DATA + 4),
70+ regmap_reg_range(ATLAS_REG_PH_DATA, ATLAS_REG_PH_DATA + 4),
71+};
72+
73+static const struct regmap_access_table atlas_volatile_table = {
74+ .yes_ranges = atlas_volatile_ranges,
75+ .n_yes_ranges = ARRAY_SIZE(atlas_volatile_ranges),
76+};
77+
78+static const struct regmap_config atlas_regmap_config = {
79+ .name = ATLAS_REGMAP_NAME,
80+
81+ .reg_bits = 8,
82+ .val_bits = 8,
83+
84+ .volatile_table = &atlas_volatile_table,
85+ .max_register = ATLAS_REG_PH_DATA + 4,
86+ .cache_type = REGCACHE_FLAT,
87+};
88+
89+static const struct iio_chan_spec atlas_channels[] = {
90+ {
91+ .type = IIO_PH,
92+ .info_mask_separate =
93+ BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
94+ .scan_index = 0,
95+ .scan_type = {
96+ .sign = 'u',
97+ .realbits = 32,
98+ .storagebits = 32,
99+ .endianness = IIO_BE,
100+ },
101+ },
102+ IIO_CHAN_SOFT_TIMESTAMP(1),
103+ {
104+ .type = IIO_TEMP,
105+ .address = ATLAS_REG_TEMP_DATA,
106+ .info_mask_separate =
107+ BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
108+ .output = 1,
109+ .scan_index = -1
110+ },
111+};
112+
113+static int atlas_set_powermode(struct atlas_data *data, int on)
114+{
115+ return regmap_write(data->regmap, ATLAS_REG_PWR_CONTROL, on);
116+}
117+
118+static int atlas_set_interrupt(struct atlas_data *data, bool state)
119+{
120+ return regmap_update_bits(data->regmap, ATLAS_REG_INT_CONTROL,
121+ ATLAS_REG_INT_CONTROL_EN,
122+ state ? ATLAS_REG_INT_CONTROL_EN : 0);
123+}
124+
125+static int atlas_buffer_postenable(struct iio_dev *indio_dev)
126+{
127+ struct atlas_data *data = iio_priv(indio_dev);
128+ int ret;
129+
130+ ret = iio_triggered_buffer_postenable(indio_dev);
131+ if (ret)
132+ return ret;
133+
134+ ret = pm_runtime_get_sync(&data->client->dev);
135+ if (ret < 0) {
136+ pm_runtime_put_noidle(&data->client->dev);
137+ return ret;
138+ }
139+
140+ return atlas_set_interrupt(data, true);
141+}
142+
143+static int atlas_buffer_predisable(struct iio_dev *indio_dev)
144+{
145+ struct atlas_data *data = iio_priv(indio_dev);
146+ int ret;
147+
148+ ret = iio_triggered_buffer_predisable(indio_dev);
149+ if (ret)
150+ return ret;
151+
152+ ret = atlas_set_interrupt(data, false);
153+ if (ret)
154+ return ret;
155+
156+ pm_runtime_mark_last_busy(&data->client->dev);
157+ return pm_runtime_put_autosuspend(&data->client->dev);
158+}
159+
160+static const struct iio_trigger_ops atlas_interrupt_trigger_ops = {
161+ .owner = THIS_MODULE,
162+};
163+
164+static const struct iio_buffer_setup_ops atlas_buffer_setup_ops = {
165+ .postenable = atlas_buffer_postenable,
166+ .predisable = atlas_buffer_predisable,
167+};
168+
169+static void atlas_work_handler(struct irq_work *work)
170+{
171+ struct atlas_data *data = container_of(work, struct atlas_data, work);
172+
173+ iio_trigger_poll(data->trig);
174+}
175+
176+static irqreturn_t atlas_trigger_handler(int irq, void *private)
177+{
178+ struct iio_poll_func *pf = private;
179+ struct iio_dev *indio_dev = pf->indio_dev;
180+ struct atlas_data *data = iio_priv(indio_dev);
181+ int ret;
182+
183+ ret = i2c_smbus_read_i2c_block_data(data->client, ATLAS_REG_PH_DATA,
184+ sizeof(data->buffer[0]), (u8 *) &data->buffer);
185+
186+ if (ret > 0)
187+ iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
188+ iio_get_time_ns());
189+
190+ iio_trigger_notify_done(indio_dev->trig);
191+
192+ return IRQ_HANDLED;
193+}
194+
195+static irqreturn_t atlas_interrupt_handler(int irq, void *private)
196+{
197+ struct iio_dev *indio_dev = private;
198+ struct atlas_data *data = iio_priv(indio_dev);
199+
200+ irq_work_queue(&data->work);
201+
202+ return IRQ_HANDLED;
203+}
204+
205+static int atlas_read_ph_measurement(struct atlas_data *data, __be32 *val)
206+{
207+ struct device *dev = &data->client->dev;
208+ int suspended = pm_runtime_suspended(dev);
209+ int ret;
210+
211+ ret = pm_runtime_get_sync(dev);
212+ if (ret < 0) {
213+ pm_runtime_put_noidle(dev);
214+ return ret;
215+ }
216+
217+ if (suspended)
218+ usleep_range(ATLAS_PH_INT_TIME_IN_US,
219+ ATLAS_PH_INT_TIME_IN_US + 100000);
220+
221+ ret = regmap_bulk_read(data->regmap, ATLAS_REG_PH_DATA,
222+ (u8 *) val, sizeof(*val));
223+
224+ pm_runtime_mark_last_busy(dev);
225+ pm_runtime_put_autosuspend(dev);
226+
227+ return ret;
228+}
229+
230+static int atlas_read_raw(struct iio_dev *indio_dev,
231+ struct iio_chan_spec const *chan,
232+ int *val, int *val2, long mask)
233+{
234+ struct atlas_data *data = iio_priv(indio_dev);
235+
236+ switch (mask) {
237+ case IIO_CHAN_INFO_RAW: {
238+ int ret;
239+ __be32 reg;
240+
241+ switch (chan->type) {
242+ case IIO_TEMP:
243+ ret = regmap_bulk_read(data->regmap, chan->address,
244+ (u8 *) &reg, sizeof(reg));
245+ break;
246+ case IIO_PH:
247+ mutex_lock(&indio_dev->mlock);
248+
249+ if (iio_buffer_enabled(indio_dev))
250+ ret = -EBUSY;
251+ else
252+ ret = atlas_read_ph_measurement(data, &reg);
253+
254+ mutex_unlock(&indio_dev->mlock);
255+ break;
256+ default:
257+ ret = -EINVAL;
258+ }
259+
260+ if (!ret) {
261+ *val = be32_to_cpu(reg);
262+ ret = IIO_VAL_INT;
263+ }
264+ return ret;
265+ }
266+ case IIO_CHAN_INFO_SCALE:
267+ switch (chan->type) {
268+ case IIO_TEMP:
269+ *val = 1; /* 0.01 */
270+ *val2 = 100;
271+ break;
272+ case IIO_PH:
273+ *val = 1; /* 0.001 */
274+ *val2 = 1000;
275+ break;
276+ default:
277+ return -EINVAL;
278+ }
279+ return IIO_VAL_FRACTIONAL;
280+ }
281+
282+ return -EINVAL;
283+}
284+
285+static int atlas_write_raw(struct iio_dev *indio_dev,
286+ struct iio_chan_spec const *chan,
287+ int val, int val2, long mask)
288+{
289+ struct atlas_data *data = iio_priv(indio_dev);
290+ __be32 reg = cpu_to_be32(val);
291+
292+ if (val2 != 0 || val < 0 || val > 20000)
293+ return -EINVAL;
294+
295+ if (mask != IIO_CHAN_INFO_RAW || chan->type != IIO_TEMP)
296+ return -EINVAL;
297+
298+ return regmap_bulk_write(data->regmap, chan->address,
299+ &reg, sizeof(reg));
300+}
301+
302+static const struct iio_info atlas_info = {
303+ .driver_module = THIS_MODULE,
304+ .read_raw = atlas_read_raw,
305+ .write_raw = atlas_write_raw,
306+};
307+
308+static int atlas_check_calibration(struct atlas_data *data)
309+{
310+ struct device *dev = &data->client->dev;
311+ int ret;
312+ unsigned int val;
313+
314+ ret = regmap_read(data->regmap, ATLAS_REG_CALIB_STATUS, &val);
315+ if (ret)
316+ return ret;
317+
318+ if (!(val & ATLAS_REG_CALIB_STATUS_MASK)) {
319+ dev_warn(dev, "device has not been calibrated\n");
320+ return 0;
321+ }
322+
323+ if (!(val & ATLAS_REG_CALIB_STATUS_LOW))
324+ dev_warn(dev, "device missing low point calibration\n");
325+
326+ if (!(val & ATLAS_REG_CALIB_STATUS_MID))
327+ dev_warn(dev, "device missing mid point calibration\n");
328+
329+ if (!(val & ATLAS_REG_CALIB_STATUS_HIGH))
330+ dev_warn(dev, "device missing high point calibration\n");
331+
332+ return 0;
333+};
334+
335+static int atlas_probe(struct i2c_client *client,
336+ const struct i2c_device_id *id)
337+{
338+ struct atlas_data *data;
339+ struct iio_trigger *trig;
340+ struct iio_dev *indio_dev;
341+ int ret;
342+
343+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
344+ if (!indio_dev)
345+ return -ENOMEM;
346+
347+ indio_dev->info = &atlas_info;
348+ indio_dev->name = ATLAS_DRV_NAME;
349+ indio_dev->channels = atlas_channels;
350+ indio_dev->num_channels = ARRAY_SIZE(atlas_channels);
351+ indio_dev->modes = INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE;
352+ indio_dev->dev.parent = &client->dev;
353+
354+ trig = devm_iio_trigger_alloc(&client->dev, "%s-dev%d",
355+ indio_dev->name, indio_dev->id);
356+
357+ if (!trig)
358+ return -ENOMEM;
359+
360+ data = iio_priv(indio_dev);
361+ data->client = client;
362+ data->trig = trig;
363+ trig->dev.parent = indio_dev->dev.parent;
364+ trig->ops = &atlas_interrupt_trigger_ops;
365+ iio_trigger_set_drvdata(trig, indio_dev);
366+
367+ i2c_set_clientdata(client, indio_dev);
368+
369+ data->regmap = devm_regmap_init_i2c(client, &atlas_regmap_config);
370+ if (IS_ERR(data->regmap)) {
371+ dev_err(&client->dev, "regmap initialization failed\n");
372+ return PTR_ERR(data->regmap);
373+ }
374+
375+ ret = pm_runtime_set_active(&client->dev);
376+ if (ret)
377+ return ret;
378+
379+ if (client->irq <= 0) {
380+ dev_err(&client->dev, "no valid irq defined\n");
381+ return -EINVAL;
382+ }
383+
384+ ret = atlas_check_calibration(data);
385+ if (ret)
386+ return ret;
387+
388+ ret = iio_trigger_register(trig);
389+ if (ret) {
390+ dev_err(&client->dev, "failed to register trigger\n");
391+ return ret;
392+ }
393+
394+ ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
395+ &atlas_trigger_handler, &atlas_buffer_setup_ops);
396+ if (ret) {
397+ dev_err(&client->dev, "cannot setup iio trigger\n");
398+ goto unregister_trigger;
399+ }
400+
401+ init_irq_work(&data->work, atlas_work_handler);
402+
403+ /* interrupt pin toggles on new conversion */
404+ ret = devm_request_threaded_irq(&client->dev, client->irq,
405+ NULL, atlas_interrupt_handler,
406+ IRQF_TRIGGER_RISING |
407+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
408+ "atlas_irq",
409+ indio_dev);
410+ if (ret) {
411+ dev_err(&client->dev, "request irq (%d) failed\n", client->irq);
412+ goto unregister_buffer;
413+ }
414+
415+ ret = atlas_set_powermode(data, 1);
416+ if (ret) {
417+ dev_err(&client->dev, "cannot power device on");
418+ goto unregister_buffer;
419+ }
420+
421+ pm_runtime_enable(&client->dev);
422+ pm_runtime_set_autosuspend_delay(&client->dev, 2500);
423+ pm_runtime_use_autosuspend(&client->dev);
424+
425+ ret = iio_device_register(indio_dev);
426+ if (ret) {
427+ dev_err(&client->dev, "unable to register device\n");
428+ goto unregister_pm;
429+ }
430+
431+ return 0;
432+
433+unregister_pm:
434+ pm_runtime_disable(&client->dev);
435+ atlas_set_powermode(data, 0);
436+
437+unregister_buffer:
438+ iio_triggered_buffer_cleanup(indio_dev);
439+
440+unregister_trigger:
441+ iio_trigger_unregister(data->trig);
442+
443+ return ret;
444+}
445+
446+static int atlas_remove(struct i2c_client *client)
447+{
448+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
449+ struct atlas_data *data = iio_priv(indio_dev);
450+
451+ iio_device_unregister(indio_dev);
452+ iio_triggered_buffer_cleanup(indio_dev);
453+ iio_trigger_unregister(data->trig);
454+
455+ pm_runtime_disable(&client->dev);
456+ pm_runtime_set_suspended(&client->dev);
457+ pm_runtime_put_noidle(&client->dev);
458+
459+ return atlas_set_powermode(data, 0);
460+}
461+
462+#ifdef CONFIG_PM
463+static int atlas_runtime_suspend(struct device *dev)
464+{
465+ struct atlas_data *data =
466+ iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
467+
468+ return atlas_set_powermode(data, 0);
469+}
470+
471+static int atlas_runtime_resume(struct device *dev)
472+{
473+ struct atlas_data *data =
474+ iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
475+
476+ return atlas_set_powermode(data, 1);
477+}
478+#endif
479+
480+static const struct dev_pm_ops atlas_pm_ops = {
481+ SET_RUNTIME_PM_OPS(atlas_runtime_suspend,
482+ atlas_runtime_resume, NULL)
483+};
484+
485+static const struct i2c_device_id atlas_id[] = {
486+ { "atlas-ph-sm", 0 },
487+ {}
488+};
489+MODULE_DEVICE_TABLE(i2c, atlas_id);
490+
491+static const struct of_device_id atlas_dt_ids[] = {
492+ { .compatible = "atlas,ph-sm" },
493+ { }
494+};
495+MODULE_DEVICE_TABLE(of, atlas_dt_ids);
496+
497+static struct i2c_driver atlas_driver = {
498+ .driver = {
499+ .name = ATLAS_DRV_NAME,
500+ .of_match_table = of_match_ptr(atlas_dt_ids),
501+ .pm = &atlas_pm_ops,
502+ },
503+ .probe = atlas_probe,
504+ .remove = atlas_remove,
505+ .id_table = atlas_id,
506+};
507+module_i2c_driver(atlas_driver);
508+
509+MODULE_AUTHOR("Matt Ranostay <mranostay@gmail.com>");
510+MODULE_DESCRIPTION("Atlas Scientific pH-SM sensor");
511+MODULE_LICENSE("GPL");
drivers/iio/common/st_sensors/st_sensors_core.c+4−2
@@ -18,13 +18,15 @@ · 17 unmodified lines
1818 #include <asm/unaligned.h>
1919 #include <linux/iio/common/st_sensors.h>
2020
21+#include "st_sensors_core.h"
22+
2123 static inline u32 st_sensors_get_unaligned_le24(const u8 *p)
2224 {
2325 return (s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8;
2426 }
2527
26−static int st_sensors_write_data_with_mask(struct iio_dev *indio_dev,
27− u8 reg_addr, u8 mask, u8 data)
28+int st_sensors_write_data_with_mask(struct iio_dev *indio_dev,
29+ u8 reg_addr, u8 mask, u8 data)
2830 {
2931 int err;
3032 u8 new_data;
drivers/iio/common/st_sensors/st_sensors_core.h+8−0
@@ -0,0 +1,8 @@
1+/*
2+ * Local functions in the ST Sensors core
3+ */
4+#ifndef __ST_SENSORS_CORE_H
5+#define __ST_SENSORS_CORE_H
6+int st_sensors_write_data_with_mask(struct iio_dev *indio_dev,
7+ u8 reg_addr, u8 mask, u8 data);
8+#endif
drivers/iio/common/st_sensors/st_sensors_trigger.c+42−10
@@ -14,32 +14,65 @@ · 13 unmodified lines
1414 #include <linux/iio/iio.h>
1515 #include <linux/iio/trigger.h>
1616 #include <linux/interrupt.h>
17−
1817 #include <linux/iio/common/st_sensors.h>
19−
18+#include "st_sensors_core.h"
2019
2120 int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
2221 const struct iio_trigger_ops *trigger_ops)
2322 {
24− int err;
23+ int err, irq;
2524 struct st_sensor_data *sdata = iio_priv(indio_dev);
25+ unsigned long irq_trig;
2626
2727 sdata->trig = iio_trigger_alloc("%s-trigger", indio_dev->name);
2828 if (sdata->trig == NULL) {
29− err = -ENOMEM;
3029 dev_err(&indio_dev->dev, "failed to allocate iio trigger.\n");
31− goto iio_trigger_alloc_error;
30+ return -ENOMEM;
3231 }
3332
34− err = request_threaded_irq(sdata->get_irq_data_ready(indio_dev),
33+ irq = sdata->get_irq_data_ready(indio_dev);
34+ irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
35+ /*
36+ * If the IRQ is triggered on falling edge, we need to mark the
37+ * interrupt as active low, if the hardware supports this.
38+ */
39+ if (irq_trig == IRQF_TRIGGER_FALLING) {
40+ if (!sdata->sensor_settings->drdy_irq.addr_ihl) {
41+ dev_err(&indio_dev->dev,
42+ "falling edge specified for IRQ but hardware "
43+ "only support rising edge, will request "
44+ "rising edge\n");
45+ irq_trig = IRQF_TRIGGER_RISING;
46+ } else {
47+ /* Set up INT active low i.e. falling edge */
48+ err = st_sensors_write_data_with_mask(indio_dev,
49+ sdata->sensor_settings->drdy_irq.addr_ihl,
50+ sdata->sensor_settings->drdy_irq.mask_ihl, 1);
51+ if (err < 0)
52+ goto iio_trigger_free;
53+ dev_info(&indio_dev->dev,
54+ "interrupts on the falling edge\n");
55+ }
56+ } else if (irq_trig == IRQF_TRIGGER_RISING) {
57+ dev_info(&indio_dev->dev,
58+ "interrupts on the rising edge\n");
59+
60+ } else {
61+ dev_err(&indio_dev->dev,
62+ "unsupported IRQ trigger specified (%lx), only "
63+ "rising and falling edges supported, enforce "
64+ "rising edge\n", irq_trig);
65+ irq_trig = IRQF_TRIGGER_RISING;
66+ }
67+ err = request_threaded_irq(irq,
3568 iio_trigger_generic_data_rdy_poll,
3669 NULL,
37− IRQF_TRIGGER_RISING,
70+ irq_trig,
3871 sdata->trig->name,
3972 sdata->trig);
4073 if (err) {
4174 dev_err(&indio_dev->dev, "failed to request trigger IRQ.\n");
42− goto request_irq_error;
75+ goto iio_trigger_free;
4376 }
4477
4578 iio_trigger_set_drvdata(sdata->trig, indio_dev);
@@ -57,9 +90,8 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, · 11 unmodified lines
5790
5891 iio_trigger_register_error:
5992 free_irq(sdata->get_irq_data_ready(indio_dev), sdata->trig);
60−request_irq_error:
93+iio_trigger_free:
6194 iio_trigger_free(sdata->trig);
62−iio_trigger_alloc_error:
6395 return err;
6496 }
6597 EXPORT_SYMBOL(st_sensors_allocate_trigger);
drivers/iio/dac/Kconfig+12−2
@@ -111,6 +111,16 @@ config AD5755 · 110 unmodified lines
111111 To compile this driver as a module, choose M here: the
112112 module will be called ad5755.
113113
114+config AD5761
115+ tristate "Analog Devices AD5761/61R/21/21R DAC driver"
116+ depends on SPI_MASTER
117+ help
118+ Say yes here to build support for Analog Devices AD5761, AD5761R, AD5721,
119+ AD5721R Digital to Analog Converter.
120+
121+ To compile this driver as a module, choose M here: the
122+ module will be called ad5761.
123+
114124 config AD5764
115125 tristate "Analog Devices AD5764/64R/44/44R DAC driver"
116126 depends on SPI_MASTER
@@ -176,11 +186,11 @@ config MAX5821 · 59 unmodified lines
176186 10 bits DAC.
177187
178188 config MCP4725
179− tristate "MCP4725 DAC driver"
189+ tristate "MCP4725/6 DAC driver"
180190 depends on I2C
181191 ---help---
182192 Say Y here if you want to build a driver for the Microchip
183− MCP 4725 12-bit digital-to-analog converter (DAC) with I2C
193+ MCP 4725/6 12-bit digital-to-analog converter (DAC) with I2C
184194 interface.
185195
186196 To compile this driver as a module, choose M here: the module
drivers/iio/dac/Makefile+1−0
@@ -12,6 +12,7 @@ obj-$(CONFIG_AD5504) += ad5504.o · 11 unmodified lines
1212 obj-$(CONFIG_AD5446) += ad5446.o
1313 obj-$(CONFIG_AD5449) += ad5449.o
1414 obj-$(CONFIG_AD5755) += ad5755.o
15+obj-$(CONFIG_AD5761) += ad5761.o
1516 obj-$(CONFIG_AD5764) += ad5764.o
1617 obj-$(CONFIG_AD5791) += ad5791.o
1718 obj-$(CONFIG_AD5686) += ad5686.o
drivers/iio/dac/ad5761.c+430−0
@@ -0,0 +1,430 @@
1+/*
2+ * AD5721, AD5721R, AD5761, AD5761R, Voltage Output Digital to Analog Converter
3+ *
4+ * Copyright 2016 Qtechnology A/S
5+ * 2016 Ricardo Ribalda <ricardo.ribalda@gmail.com>
6+ *
7+ * Licensed under the GPL-2.
8+ */
9+#include <linux/kernel.h>
10+#include <linux/module.h>
11+#include <linux/spi/spi.h>
12+#include <linux/bitops.h>
13+#include <linux/iio/iio.h>
14+#include <linux/iio/sysfs.h>
15+#include <linux/regulator/consumer.h>
16+#include <linux/platform_data/ad5761.h>
17+
18+#define AD5761_ADDR(addr) ((addr & 0xf) << 16)
19+#define AD5761_ADDR_NOOP 0x0
20+#define AD5761_ADDR_DAC_WRITE 0x3
21+#define AD5761_ADDR_CTRL_WRITE_REG 0x4
22+#define AD5761_ADDR_SW_DATA_RESET 0x7
23+#define AD5761_ADDR_DAC_READ 0xb
24+#define AD5761_ADDR_CTRL_READ_REG 0xc
25+#define AD5761_ADDR_SW_FULL_RESET 0xf
26+
27+#define AD5761_CTRL_USE_INTVREF BIT(5)
28+#define AD5761_CTRL_ETS BIT(6)
29+
30+/**
31+ * struct ad5761_chip_info - chip specific information
32+ * @int_vref: Value of the internal reference voltage in mV - 0 if external
33+ * reference voltage is used
34+ * @channel: channel specification
35+*/
36+
37+struct ad5761_chip_info {
38+ unsigned long int_vref;
39+ const struct iio_chan_spec channel;
40+};
41+
42+struct ad5761_range_params {
43+ int m;
44+ int c;
45+};
46+
47+enum ad5761_supported_device_ids {
48+ ID_AD5721,
49+ ID_AD5721R,
50+ ID_AD5761,
51+ ID_AD5761R,
52+};
53+
54+/**
55+ * struct ad5761_state - driver instance specific data
56+ * @spi: spi_device
57+ * @vref_reg: reference voltage regulator
58+ * @use_intref: true when the internal voltage reference is used
59+ * @vref: actual voltage reference in mVolts
60+ * @range: output range mode used
61+ * @data: cache aligned spi buffer
62+ */
63+struct ad5761_state {
64+ struct spi_device *spi;
65+ struct regulator *vref_reg;
66+
67+ bool use_intref;
68+ int vref;
69+ enum ad5761_voltage_range range;
70+
71+ /*
72+ * DMA (thus cache coherency maintenance) requires the
73+ * transfer buffers to live in their own cache lines.
74+ */
75+ union {
76+ __be32 d32;
77+ u8 d8[4];
78+ } data[3] ____cacheline_aligned;
79+};
80+
81+static const struct ad5761_range_params ad5761_range_params[] = {
82+ [AD5761_VOLTAGE_RANGE_M10V_10V] = {
83+ .m = 80,
84+ .c = 40,
85+ },
86+ [AD5761_VOLTAGE_RANGE_0V_10V] = {
87+ .m = 40,
88+ .c = 0,
89+ },
90+ [AD5761_VOLTAGE_RANGE_M5V_5V] = {
91+ .m = 40,
92+ .c = 20,
93+ },
94+ [AD5761_VOLTAGE_RANGE_0V_5V] = {
95+ .m = 20,
96+ .c = 0,
97+ },
98+ [AD5761_VOLTAGE_RANGE_M2V5_7V5] = {
99+ .m = 40,
100+ .c = 10,
101+ },
102+ [AD5761_VOLTAGE_RANGE_M3V_3V] = {
103+ .m = 24,
104+ .c = 12,
105+ },
106+ [AD5761_VOLTAGE_RANGE_0V_16V] = {
107+ .m = 64,
108+ .c = 0,
109+ },
110+ [AD5761_VOLTAGE_RANGE_0V_20V] = {
111+ .m = 80,
112+ .c = 0,
113+ },
114+};
115+
116+static int _ad5761_spi_write(struct ad5761_state *st, u8 addr, u16 val)
117+{
118+ st->data[0].d32 = cpu_to_be32(AD5761_ADDR(addr) | val);
119+
120+ return spi_write(st->spi, &st->data[0].d8[1], 3);
121+}
122+
123+static int ad5761_spi_write(struct iio_dev *indio_dev, u8 addr, u16 val)
124+{
125+ struct ad5761_state *st = iio_priv(indio_dev);
126+ int ret;
127+
128+ mutex_lock(&indio_dev->mlock);
129+ ret = _ad5761_spi_write(st, addr, val);
130+ mutex_unlock(&indio_dev->mlock);
131+
132+ return ret;
133+}
134+
135+static int _ad5761_spi_read(struct ad5761_state *st, u8 addr, u16 *val)
136+{
137+ int ret;
138+ struct spi_transfer xfers[] = {
139+ {
140+ .tx_buf = &st->data[0].d8[1],
141+ .bits_per_word = 8,
142+ .len = 3,
143+ .cs_change = true,
144+ }, {
145+ .tx_buf = &st->data[1].d8[1],
146+ .rx_buf = &st->data[2].d8[1],
147+ .bits_per_word = 8,
148+ .len = 3,
149+ },
150+ };
151+
152+ st->data[0].d32 = cpu_to_be32(AD5761_ADDR(addr));
153+ st->data[1].d32 = cpu_to_be32(AD5761_ADDR(AD5761_ADDR_NOOP));
154+
155+ ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
156+
157+ *val = be32_to_cpu(st->data[2].d32);
158+
159+ return ret;
160+}
161+
162+static int ad5761_spi_read(struct iio_dev *indio_dev, u8 addr, u16 *val)
163+{
164+ struct ad5761_state *st = iio_priv(indio_dev);
165+ int ret;
166+
167+ mutex_lock(&indio_dev->mlock);
168+ ret = _ad5761_spi_read(st, addr, val);
169+ mutex_unlock(&indio_dev->mlock);
170+
171+ return ret;
172+}
173+
174+static int ad5761_spi_set_range(struct ad5761_state *st,
175+ enum ad5761_voltage_range range)
176+{
177+ u16 aux;
178+ int ret;
179+
180+ aux = (range & 0x7) | AD5761_CTRL_ETS;
181+
182+ if (st->use_intref)
183+ aux |= AD5761_CTRL_USE_INTVREF;
184+
185+ ret = _ad5761_spi_write(st, AD5761_ADDR_SW_FULL_RESET, 0);
186+ if (ret)
187+ return ret;
188+
189+ ret = _ad5761_spi_write(st, AD5761_ADDR_CTRL_WRITE_REG, aux);
190+ if (ret)
191+ return ret;
192+
193+ st->range = range;
194+
195+ return 0;
196+}
197+
198+static int ad5761_read_raw(struct iio_dev *indio_dev,
199+ struct iio_chan_spec const *chan,
200+ int *val,
201+ int *val2,
202+ long mask)
203+{
204+ struct ad5761_state *st;
205+ int ret;
206+ u16 aux;
207+
208+ switch (mask) {
209+ case IIO_CHAN_INFO_RAW:
210+ ret = ad5761_spi_read(indio_dev, AD5761_ADDR_DAC_READ, &aux);
211+ if (ret)
212+ return ret;
213+ *val = aux >> chan->scan_type.shift;
214+ return IIO_VAL_INT;
215+ case IIO_CHAN_INFO_SCALE:
216+ st = iio_priv(indio_dev);
217+ *val = st->vref * ad5761_range_params[st->range].m;
218+ *val /= 10;
219+ *val2 = chan->scan_type.realbits;
220+ return IIO_VAL_FRACTIONAL_LOG2;
221+ case IIO_CHAN_INFO_OFFSET:
222+ st = iio_priv(indio_dev);
223+ *val = -(1 << chan->scan_type.realbits);
224+ *val *= ad5761_range_params[st->range].c;
225+ *val /= ad5761_range_params[st->range].m;
226+ return IIO_VAL_INT;
227+ default:
228+ return -EINVAL;
229+ }
230+}
231+
232+static int ad5761_write_raw(struct iio_dev *indio_dev,
233+ struct iio_chan_spec const *chan,
234+ int val,
235+ int val2,
236+ long mask)
237+{
238+ u16 aux;
239+
240+ if (mask != IIO_CHAN_INFO_RAW)
241+ return -EINVAL;
242+
243+ if (val2 || (val << chan->scan_type.shift) > 0xffff || val < 0)
244+ return -EINVAL;
245+
246+ aux = val << chan->scan_type.shift;
247+
248+ return ad5761_spi_write(indio_dev, AD5761_ADDR_DAC_WRITE, aux);
249+}
250+
251+static const struct iio_info ad5761_info = {
252+ .read_raw = &ad5761_read_raw,
253+ .write_raw = &ad5761_write_raw,
254+ .driver_module = THIS_MODULE,
255+};
256+
257+#define AD5761_CHAN(_bits) { \
258+ .type = IIO_VOLTAGE, \
259+ .output = 1, \
260+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
261+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
262+ BIT(IIO_CHAN_INFO_OFFSET), \
263+ .scan_type = { \
264+ .sign = 'u', \
265+ .realbits = (_bits), \
266+ .storagebits = 16, \
267+ .shift = 16 - (_bits), \
268+ }, \
269+}
270+
271+static const struct ad5761_chip_info ad5761_chip_infos[] = {
272+ [ID_AD5721] = {
273+ .int_vref = 0,
274+ .channel = AD5761_CHAN(12),
275+ },
276+ [ID_AD5721R] = {
277+ .int_vref = 2500,
278+ .channel = AD5761_CHAN(12),
279+ },
280+ [ID_AD5761] = {
281+ .int_vref = 0,
282+ .channel = AD5761_CHAN(16),
283+ },
284+ [ID_AD5761R] = {
285+ .int_vref = 2500,
286+ .channel = AD5761_CHAN(16),
287+ },
288+};
289+
290+static int ad5761_get_vref(struct ad5761_state *st,
291+ const struct ad5761_chip_info *chip_info)
292+{
293+ int ret;
294+
295+ st->vref_reg = devm_regulator_get_optional(&st->spi->dev, "vref");
296+ if (PTR_ERR(st->vref_reg) == -ENODEV) {
297+ /* Use Internal regulator */
298+ if (!chip_info->int_vref) {
299+ dev_err(&st->spi->dev,
300+ "Voltage reference not found\n");
301+ return -EIO;
302+ }
303+
304+ st->use_intref = true;
305+ st->vref = chip_info->int_vref;
306+ return 0;
307+ }
308+
309+ if (IS_ERR(st->vref_reg)) {
310+ dev_err(&st->spi->dev,
311+ "Error getting voltage reference regulator\n");
312+ return PTR_ERR(st->vref_reg);
313+ }
314+
315+ ret = regulator_enable(st->vref_reg);
316+ if (ret) {
317+ dev_err(&st->spi->dev,
318+ "Failed to enable voltage reference\n");
319+ return ret;
320+ }
321+
322+ ret = regulator_get_voltage(st->vref_reg);
323+ if (ret < 0) {
324+ dev_err(&st->spi->dev,
325+ "Failed to get voltage reference value\n");
326+ goto disable_regulator_vref;
327+ }
328+
329+ if (ret < 2000000 || ret > 3000000) {
330+ dev_warn(&st->spi->dev,
331+ "Invalid external voltage ref. value %d uV\n", ret);
332+ ret = -EIO;
333+ goto disable_regulator_vref;
334+ }
335+
336+ st->vref = ret / 1000;
337+ st->use_intref = false;
338+
339+ return 0;
340+
341+disable_regulator_vref:
342+ regulator_disable(st->vref_reg);
343+ st->vref_reg = NULL;
344+ return ret;
345+}
346+
347+static int ad5761_probe(struct spi_device *spi)
348+{
349+ struct iio_dev *iio_dev;
350+ struct ad5761_state *st;
351+ int ret;
352+ const struct ad5761_chip_info *chip_info =
353+ &ad5761_chip_infos[spi_get_device_id(spi)->driver_data];
354+ enum ad5761_voltage_range voltage_range = AD5761_VOLTAGE_RANGE_0V_5V;
355+ struct ad5761_platform_data *pdata = dev_get_platdata(&spi->dev);
356+
357+ iio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
358+ if (!iio_dev)
359+ return -ENOMEM;
360+
361+ st = iio_priv(iio_dev);
362+
363+ st->spi = spi;
364+ spi_set_drvdata(spi, iio_dev);
365+
366+ ret = ad5761_get_vref(st, chip_info);
367+ if (ret)
368+ return ret;
369+
370+ if (pdata)
371+ voltage_range = pdata->voltage_range;
372+
373+ ret = ad5761_spi_set_range(st, voltage_range);
374+ if (ret)
375+ goto disable_regulator_err;
376+
377+ iio_dev->dev.parent = &spi->dev;
378+ iio_dev->info = &ad5761_info;
379+ iio_dev->modes = INDIO_DIRECT_MODE;
380+ iio_dev->channels = &chip_info->channel;
381+ iio_dev->num_channels = 1;
382+ iio_dev->name = spi_get_device_id(st->spi)->name;
383+ ret = iio_device_register(iio_dev);
384+ if (ret)
385+ goto disable_regulator_err;
386+
387+ return 0;
388+
389+disable_regulator_err:
390+ if (!IS_ERR_OR_NULL(st->vref_reg))
391+ regulator_disable(st->vref_reg);
392+
393+ return ret;
394+}
395+
396+static int ad5761_remove(struct spi_device *spi)
397+{
398+ struct iio_dev *iio_dev = spi_get_drvdata(spi);
399+ struct ad5761_state *st = iio_priv(iio_dev);
400+
401+ iio_device_unregister(iio_dev);
402+
403+ if (!IS_ERR_OR_NULL(st->vref_reg))
404+ regulator_disable(st->vref_reg);
405+
406+ return 0;
407+}
408+
409+static const struct spi_device_id ad5761_id[] = {
410+ {"ad5721", ID_AD5721},
411+ {"ad5721r", ID_AD5721R},
412+ {"ad5761", ID_AD5761},
413+ {"ad5761r", ID_AD5761R},
414+ {}
415+};
416+MODULE_DEVICE_TABLE(spi, ad5761_id);
417+
418+static struct spi_driver ad5761_driver = {
419+ .driver = {
420+ .name = "ad5761",
421+ },
422+ .probe = ad5761_probe,
423+ .remove = ad5761_remove,
424+ .id_table = ad5761_id,
425+};
426+module_spi_driver(ad5761_driver);
427+
428+MODULE_AUTHOR("Ricardo Ribalda <ricardo.ribalda@gmail.com>");
429+MODULE_DESCRIPTION("Analog Devices AD5721, AD5721R, AD5761, AD5761R driver");
430+MODULE_LICENSE("GPL v2");
drivers/iio/dac/mcp4725.c+67−20
@@ -1,5 +1,5 @@
11 /*
2− * mcp4725.c - Support for Microchip MCP4725
2+ * mcp4725.c - Support for Microchip MCP4725/6
33 *
44 * Copyright (C) 2012 Peter Meerwald <pmeerw@pmeerw.net>
55 *
@@ -134,6 +134,12 @@ static const char * const mcp4725_powerdown_modes[] = { · 128 unmodified lines
134134 "500kohm_to_gnd"
135135 };
136136
137+static const char * const mcp4726_powerdown_modes[] = {
138+ "1kohm_to_gnd",
139+ "125kohm_to_gnd",
140+ "640kohm_to_gnd"
141+};
142+
137143 static int mcp4725_get_powerdown_mode(struct iio_dev *indio_dev,
138144 const struct iio_chan_spec *chan)
139145 {
@@ -182,11 +188,24 @@ static ssize_t mcp4725_write_powerdown(struct iio_dev *indio_dev, · 42 unmodified lines
182188 return len;
183189 }
184190
185−static const struct iio_enum mcp4725_powerdown_mode_enum = {
186− .items = mcp4725_powerdown_modes,
187− .num_items = ARRAY_SIZE(mcp4725_powerdown_modes),
188− .get = mcp4725_get_powerdown_mode,
189− .set = mcp4725_set_powerdown_mode,
191+enum {
192+ MCP4725,
193+ MCP4726,
194+};
195+
196+static const struct iio_enum mcp472x_powerdown_mode_enum[] = {
197+ [MCP4725] = {
198+ .items = mcp4725_powerdown_modes,
199+ .num_items = ARRAY_SIZE(mcp4725_powerdown_modes),
200+ .get = mcp4725_get_powerdown_mode,
201+ .set = mcp4725_set_powerdown_mode,
202+ },
203+ [MCP4726] = {
204+ .items = mcp4726_powerdown_modes,
205+ .num_items = ARRAY_SIZE(mcp4726_powerdown_modes),
206+ .get = mcp4725_get_powerdown_mode,
207+ .set = mcp4725_set_powerdown_mode,
208+ },
190209 };
191210
192211 static const struct iio_chan_spec_ext_info mcp4725_ext_info[] = {
@@ -196,19 +215,46 @@ static const struct iio_chan_spec_ext_info mcp4725_ext_info[] = { · 3 unmodified lines
196215 .write = mcp4725_write_powerdown,
197216 .shared = IIO_SEPARATE,
198217 },
199− IIO_ENUM("powerdown_mode", IIO_SEPARATE, &mcp4725_powerdown_mode_enum),
200− IIO_ENUM_AVAILABLE("powerdown_mode", &mcp4725_powerdown_mode_enum),
218+ IIO_ENUM("powerdown_mode", IIO_SEPARATE,
219+ &mcp472x_powerdown_mode_enum[MCP4725]),
220+ IIO_ENUM_AVAILABLE("powerdown_mode",
221+ &mcp472x_powerdown_mode_enum[MCP4725]),
222+ { },
223+};
224+
225+static const struct iio_chan_spec_ext_info mcp4726_ext_info[] = {
226+ {
227+ .name = "powerdown",
228+ .read = mcp4725_read_powerdown,
229+ .write = mcp4725_write_powerdown,
230+ .shared = IIO_SEPARATE,
231+ },
232+ IIO_ENUM("powerdown_mode", IIO_SEPARATE,
233+ &mcp472x_powerdown_mode_enum[MCP4726]),
234+ IIO_ENUM_AVAILABLE("powerdown_mode",
235+ &mcp472x_powerdown_mode_enum[MCP4726]),
201236 { },
202237 };
203238
204−static const struct iio_chan_spec mcp4725_channel = {
205− .type = IIO_VOLTAGE,
206− .indexed = 1,
207− .output = 1,
208− .channel = 0,
209− .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
210− .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
211− .ext_info = mcp4725_ext_info,
239+static const struct iio_chan_spec mcp472x_channel[] = {
240+ [MCP4725] = {
241+ .type = IIO_VOLTAGE,
242+ .indexed = 1,
243+ .output = 1,
244+ .channel = 0,
245+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
246+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
247+ .ext_info = mcp4725_ext_info,
248+ },
249+ [MCP4726] = {
250+ .type = IIO_VOLTAGE,
251+ .indexed = 1,
252+ .output = 1,
253+ .channel = 0,
254+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
255+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
256+ .ext_info = mcp4726_ext_info,
257+ },
212258 };
213259
214260 static int mcp4725_set_value(struct iio_dev *indio_dev, int val)
@@ -301,7 +347,7 @@ static int mcp4725_probe(struct i2c_client *client, · 86 unmodified lines
301347
302348 indio_dev->dev.parent = &client->dev;
303349 indio_dev->info = &mcp4725_info;
304− indio_dev->channels = &mcp4725_channel;
350+ indio_dev->channels = &mcp472x_channel[id->driver_data];
305351 indio_dev->num_channels = 1;
306352 indio_dev->modes = INDIO_DIRECT_MODE;
307353
@@ -315,7 +361,7 @@ static int mcp4725_probe(struct i2c_client *client, · 7 unmodified lines
315361 }
316362 pd = (inbuf[0] >> 1) & 0x3;
317363 data->powerdown = pd > 0 ? true : false;
318− data->powerdown_mode = pd ? pd-1 : 2; /* 500kohm_to_gnd */
364+ data->powerdown_mode = pd ? pd - 1 : 2; /* largest register to gnd */
319365 data->dac_value = (inbuf[1] << 4) | (inbuf[2] >> 4);
320366
321367 return iio_device_register(indio_dev);
@@ -328,7 +374,8 @@ static int mcp4725_remove(struct i2c_client *client) · 6 unmodified lines
328374 }
329375
330376 static const struct i2c_device_id mcp4725_id[] = {
331− { "mcp4725", 0 },
377+ { "mcp4725", MCP4725 },
378+ { "mcp4726", MCP4726 },
332379 { }
333380 };
334381 MODULE_DEVICE_TABLE(i2c, mcp4725_id);
@@ -345,5 +392,5 @@ static struct i2c_driver mcp4725_driver = { · 10 unmodified lines
345392 module_i2c_driver(mcp4725_driver);
346393
347394 MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
348−MODULE_DESCRIPTION("MCP4725 12-bit DAC");
395+MODULE_DESCRIPTION("MCP4725/6 12-bit DAC");
349396 MODULE_LICENSE("GPL");
drivers/iio/gyro/st_gyro_core.c+15−0
@@ -185,6 +185,11 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = { · 184 unmodified lines
185185 .drdy_irq = {
186186 .addr = ST_GYRO_1_DRDY_IRQ_ADDR,
187187 .mask_int2 = ST_GYRO_1_DRDY_IRQ_INT2_MASK,
188+ /*
189+ * The sensor has IHL (active low) and open
190+ * drain settings, but only for INT1 and not
191+ * for the DRDY line on INT2.
192+ */
188193 },
189194 .multi_read_bit = ST_GYRO_1_MULTIREAD_BIT,
190195 .bootime = 2,
@@ -248,6 +253,11 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = { · 57 unmodified lines
248253 .drdy_irq = {
249254 .addr = ST_GYRO_2_DRDY_IRQ_ADDR,
250255 .mask_int2 = ST_GYRO_2_DRDY_IRQ_INT2_MASK,
256+ /*
257+ * The sensor has IHL (active low) and open
258+ * drain settings, but only for INT1 and not
259+ * for the DRDY line on INT2.
260+ */
251261 },
252262 .multi_read_bit = ST_GYRO_2_MULTIREAD_BIT,
253263 .bootime = 2,
@@ -307,6 +317,11 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = { · 53 unmodified lines
307317 .drdy_irq = {
308318 .addr = ST_GYRO_3_DRDY_IRQ_ADDR,
309319 .mask_int2 = ST_GYRO_3_DRDY_IRQ_INT2_MASK,
320+ /*
321+ * The sensor has IHL (active low) and open
322+ * drain settings, but only for INT1 and not
323+ * for the DRDY line on INT2.
324+ */
310325 },
311326 .multi_read_bit = ST_GYRO_3_MULTIREAD_BIT,
312327 .bootime = 2,
drivers/iio/health/max30100.c+75−6
@@ -13,7 +13,7 @@ · 12 unmodified lines
1313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414 * GNU General Public License for more details.
1515 *
16− * TODO: allow LED current and pulse length controls via device tree properties
16+ * TODO: enable pulse length controls via device tree properties
1717 */
1818
1919 #include <linux/module.h>
@@ -24,6 +24,7 @@ · 4 unmodified lines
2424 #include <linux/irq.h>
2525 #include <linux/i2c.h>
2626 #include <linux/mutex.h>
27+#include <linux/of.h>
2728 #include <linux/regmap.h>
2829 #include <linux/iio/iio.h>
2930 #include <linux/iio/buffer.h>
@@ -65,6 +66,7 @@ · 35 unmodified lines
6566 #define MAX30100_REG_SPO2_CONFIG_1600US 0x3
6667
6768 #define MAX30100_REG_LED_CONFIG 0x09
69+#define MAX30100_REG_LED_CONFIG_LED_MASK 0x0f
6870 #define MAX30100_REG_LED_CONFIG_RED_LED_SHIFT 4
6971
7072 #define MAX30100_REG_LED_CONFIG_24MA 0x07
@@ -111,6 +113,12 @@ static const struct regmap_config max30100_regmap_config = { · 40 unmodified lines
111113 .volatile_reg = max30100_is_volatile_reg,
112114 };
113115
116+static const unsigned int max30100_led_current_mapping[] = {
117+ 4400, 7600, 11000, 14200, 17400,
118+ 20800, 24000, 27100, 30600, 33800,
119+ 37000, 40200, 43600, 46800, 50000
120+};
121+
114122 static const unsigned long max30100_scan_masks[] = {0x3, 0};
115123
116124 static const struct iio_chan_spec max30100_channels[] = {
@@ -243,15 +251,76 @@ static irqreturn_t max30100_interrupt_handler(int irq, void *private) · 126 unmodified lines
243251 return IRQ_HANDLED;
244252 }
245253
254+static int max30100_get_current_idx(unsigned int val, int *reg)
255+{
256+ int idx;
257+
258+ /* LED turned off */
259+ if (val == 0) {
260+ *reg = 0;
261+ return 0;
262+ }
263+
264+ for (idx = 0; idx < ARRAY_SIZE(max30100_led_current_mapping); idx++) {
265+ if (max30100_led_current_mapping[idx] == val) {
266+ *reg = idx + 1;
267+ return 0;
268+ }
269+ }
270+
271+ return -EINVAL;
272+}
273+
274+static int max30100_led_init(struct max30100_data *data)
275+{
276+ struct device *dev = &data->client->dev;
277+ struct device_node *np = dev->of_node;
278+ unsigned int val[2];
279+ int reg, ret;
280+
281+ ret = of_property_read_u32_array(np, "maxim,led-current-microamp",
282+ (unsigned int *) &val, 2);
283+ if (ret) {
284+ /* Default to 24 mA RED LED, 50 mA IR LED */
285+ reg = (MAX30100_REG_LED_CONFIG_24MA <<
286+ MAX30100_REG_LED_CONFIG_RED_LED_SHIFT) |
287+ MAX30100_REG_LED_CONFIG_50MA;
288+ dev_warn(dev, "no led-current-microamp set");
289+
290+ return regmap_write(data->regmap, MAX30100_REG_LED_CONFIG, reg);
291+ }
292+
293+ /* RED LED current */
294+ ret = max30100_get_current_idx(val[0], &reg);
295+ if (ret) {
296+ dev_err(dev, "invalid RED current setting %d", val[0]);
297+ return ret;
298+ }
299+
300+ ret = regmap_update_bits(data->regmap, MAX30100_REG_LED_CONFIG,
301+ MAX30100_REG_LED_CONFIG_LED_MASK <<
302+ MAX30100_REG_LED_CONFIG_RED_LED_SHIFT,
303+ reg << MAX30100_REG_LED_CONFIG_RED_LED_SHIFT);
304+ if (ret)
305+ return ret;
306+
307+ /* IR LED current */
308+ ret = max30100_get_current_idx(val[1], &reg);
309+ if (ret) {
310+ dev_err(dev, "invalid IR current setting %d", val[1]);
311+ return ret;
312+ }
313+
314+ return regmap_update_bits(data->regmap, MAX30100_REG_LED_CONFIG,
315+ MAX30100_REG_LED_CONFIG_LED_MASK, reg);
316+}
317+
246318 static int max30100_chip_init(struct max30100_data *data)
247319 {
248320 int ret;
249321
250− /* RED IR LED = 24mA, IR LED = 50mA */
251− ret = regmap_write(data->regmap, MAX30100_REG_LED_CONFIG,
252− (MAX30100_REG_LED_CONFIG_24MA <<
253− MAX30100_REG_LED_CONFIG_RED_LED_SHIFT) |
254− MAX30100_REG_LED_CONFIG_50MA);
322+ /* setup LED current settings */
323+ ret = max30100_led_init(data);
255324 if (ret)
256325 return ret;
257326
drivers/iio/humidity/Kconfig+4−2
@@ -43,14 +43,16 @@ config SI7005 · 42 unmodified lines
4343 humidity and temperature sensor.
4444
4545 To compile this driver as a module, choose M here: the module
46− will be called si7005.
46+ will be called si7005. This driver also
47+ supports Hoperf TH02 Humidity and Temperature Sensor.
4748
4849 config SI7020
4950 tristate "Si7013/20/21 Relative Humidity and Temperature Sensors"
5051 depends on I2C
5152 help
5253 Say yes here to build support for the Silicon Labs Si7013/20/21
53− Relative Humidity and Temperature Sensors.
54+ Relative Humidity and Temperature Sensors. This driver also
55+ supports Hoperf TH06 Humidity and Temperature Sensor.
5456
5557 To compile this driver as a module, choose M here: the module
5658 will be called si7020.
drivers/iio/humidity/dht11.c+50−27
@@ -50,12 +50,32 @@ · 49 unmodified lines
5050 #define DHT11_EDGES_PER_READ (2 * DHT11_BITS_PER_READ + \
5151 DHT11_EDGES_PREAMBLE + 1)
5252
53−/* Data transmission timing (nano seconds) */
53+/*
54+ * Data transmission timing:
55+ * Data bits are encoded as pulse length (high time) on the data line.
56+ * 0-bit: 22-30uS -- typically 26uS (AM2302)
57+ * 1-bit: 68-75uS -- typically 70uS (AM2302)
58+ * The acutal timings also depend on the properties of the cable, with
59+ * longer cables typically making pulses shorter.
60+ *
61+ * Our decoding depends on the time resolution of the system:
62+ * timeres > 34uS ... don't know what a 1-tick pulse is
63+ * 34uS > timeres > 30uS ... no problem (30kHz and 32kHz clocks)
64+ * 30uS > timeres > 23uS ... don't know what a 2-tick pulse is
65+ * timeres < 23uS ... no problem
66+ *
67+ * Luckily clocks in the 33-44kHz range are quite uncommon, so we can
68+ * support most systems if the threshold for decoding a pulse as 1-bit
69+ * is chosen carefully. If somebody really wants to support clocks around
70+ * 40kHz, where this driver is most unreliable, there are two options.
71+ * a) select an implementation using busy loop polling on those systems
72+ * b) use the checksum to do some probabilistic decoding
73+ */
5474 #define DHT11_START_TRANSMISSION 18 /* ms */
55−#define DHT11_SENSOR_RESPONSE 80000
56−#define DHT11_START_BIT 50000
57−#define DHT11_DATA_BIT_LOW 27000
58−#define DHT11_DATA_BIT_HIGH 70000
75+#define DHT11_MIN_TIMERES 34000 /* ns */
76+#define DHT11_THRESHOLD 49000 /* ns */
77+#define DHT11_AMBIG_LOW 23000 /* ns */
78+#define DHT11_AMBIG_HIGH 30000 /* ns */
5979
6080 struct dht11 {
6181 struct device *dev;
@@ -76,43 +96,39 @@ struct dht11 { · 14 unmodified lines
7696 struct {s64 ts; int value; } edges[DHT11_EDGES_PER_READ];
7797 };
7898
79−static unsigned char dht11_decode_byte(int *timing, int threshold)
99+static unsigned char dht11_decode_byte(char *bits)
80100 {
81101 unsigned char ret = 0;
82102 int i;
83103
84104 for (i = 0; i < 8; ++i) {
85105 ret <<= 1;
86− if (timing[i] >= threshold)
106+ if (bits[i])
87107 ++ret;
88108 }
89109
90110 return ret;
91111 }
92112
93−static int dht11_decode(struct dht11 *dht11, int offset, int timeres)
113+static int dht11_decode(struct dht11 *dht11, int offset)
94114 {
95− int i, t, timing[DHT11_BITS_PER_READ], threshold;
115+ int i, t;
116+ char bits[DHT11_BITS_PER_READ];
96117 unsigned char temp_int, temp_dec, hum_int, hum_dec, checksum;
97118
98− threshold = DHT11_DATA_BIT_HIGH / timeres;
99− if (DHT11_DATA_BIT_LOW / timeres + 1 >= threshold)
100− pr_err("dht11: WARNING: decoding ambiguous\n");
101−
102− /* scale down with timeres and check validity */
103119 for (i = 0; i < DHT11_BITS_PER_READ; ++i) {
104120 t = dht11->edges[offset + 2 * i + 2].ts -
105121 dht11->edges[offset + 2 * i + 1].ts;
106122 if (!dht11->edges[offset + 2 * i + 1].value)
107123 return -EIO; /* lost synchronisation */
108− timing[i] = t / timeres;
124+ bits[i] = t > DHT11_THRESHOLD;
109125 }
110126
111− hum_int = dht11_decode_byte(timing, threshold);
112− hum_dec = dht11_decode_byte(&timing[8], threshold);
113− temp_int = dht11_decode_byte(&timing[16], threshold);
114− temp_dec = dht11_decode_byte(&timing[24], threshold);
115− checksum = dht11_decode_byte(&timing[32], threshold);
127+ hum_int = dht11_decode_byte(bits);
128+ hum_dec = dht11_decode_byte(&bits[8]);
129+ temp_int = dht11_decode_byte(&bits[16]);
130+ temp_dec = dht11_decode_byte(&bits[24]);
131+ checksum = dht11_decode_byte(&bits[32]);
116132
117133 if (((hum_int + hum_dec + temp_int + temp_dec) & 0xff) != checksum)
118134 return -EIO;
@@ -161,12 +177,12 @@ static int dht11_read_raw(struct iio_dev *iio_dev, · 42 unmodified lines
161177 int *val, int *val2, long m)
162178 {
163179 struct dht11 *dht11 = iio_priv(iio_dev);
164− int ret, timeres;
180+ int ret, timeres, offset;
165181
166182 mutex_lock(&dht11->lock);
167183 if (dht11->timestamp + DHT11_DATA_VALID_TIME < ktime_get_real_ns()) {
168184 timeres = ktime_get_resolution_ns();
169− if (DHT11_DATA_BIT_HIGH < 2 * timeres) {
185+ if (timeres > DHT11_MIN_TIMERES) {
170186 dev_err(dht11->dev, "timeresolution %dns too low\n",
171187 timeres);
172188 /* In theory a better clock could become available
@@ -176,6 +192,10 @@ static int dht11_read_raw(struct iio_dev *iio_dev, · 3 unmodified lines
176192 ret = -EAGAIN;
177193 goto err;
178194 }
195+ if (timeres > DHT11_AMBIG_LOW && timeres < DHT11_AMBIG_HIGH)
196+ dev_warn(dht11->dev,
197+ "timeresolution: %dns - decoding ambiguous\n",
198+ timeres);
179199
180200 reinit_completion(&dht11->completion);
181201
@@ -208,11 +228,14 @@ static int dht11_read_raw(struct iio_dev *iio_dev, · 26 unmodified lines
208228 if (ret < 0)
209229 goto err;
210230
211− ret = dht11_decode(dht11,
212− dht11->num_edges == DHT11_EDGES_PER_READ ?
213− DHT11_EDGES_PREAMBLE :
214− DHT11_EDGES_PREAMBLE - 2,
215− timeres);
231+ offset = DHT11_EDGES_PREAMBLE +
232+ dht11->num_edges - DHT11_EDGES_PER_READ;
233+ for (; offset >= 0; --offset) {
234+ ret = dht11_decode(dht11, offset);
235+ if (!ret)
236+ break;
237+ }
238+
216239 if (ret)
217240 goto err;
218241 }
drivers/iio/humidity/si7005.c+1−0
@@ -170,6 +170,7 @@ static int si7005_probe(struct i2c_client *client, · 169 unmodified lines
170170
171171 static const struct i2c_device_id si7005_id[] = {
172172 { "si7005", 0 },
173+ { "th02", 0 },
173174 { }
174175 };
175176 MODULE_DEVICE_TABLE(i2c, si7005_id);
drivers/iio/humidity/si7020.c+1−0
@@ -149,6 +149,7 @@ static int si7020_probe(struct i2c_client *client, · 148 unmodified lines
149149
150150 static const struct i2c_device_id si7020_id[] = {
151151 { "si7020", 0 },
152+ { "th06", 0 },
152153 { }
153154 };
154155 MODULE_DEVICE_TABLE(i2c, si7020_id);
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c+2−3
@@ -727,8 +727,7 @@ static const struct iio_info mpu_info = { · 726 unmodified lines
727727 /**
728728 * inv_check_and_setup_chip() - check and setup chip.
729729 */
730−static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
731− const struct i2c_device_id *id)
730+static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
732731 {
733732 int result;
734733
@@ -795,7 +794,7 @@ static int inv_mpu_probe(struct i2c_client *client, · 60 unmodified lines
795794 if (pdata)
796795 st->plat_data = *pdata;
797796 /* power is turned on inside check chip type*/
798− result = inv_check_and_setup_chip(st, id);
797+ result = inv_check_and_setup_chip(st);
799798 if (result)
800799 return result;
801800
drivers/iio/industrialio-core.c+1−0
@@ -77,6 +77,7 @@ static const char * const iio_chan_type_name_spec[] = { · 76 unmodified lines
7777 [IIO_VELOCITY] = "velocity",
7878 [IIO_CONCENTRATION] = "concentration",
7979 [IIO_RESISTANCE] = "resistance",
80+ [IIO_PH] = "ph",
8081 };
8182
8283 static const char * const iio_modifier_names[] = {
drivers/iio/light/opt3001.c+106−50
@@ -65,19 +65,25 @@ · 64 unmodified lines
6565 #define OPT3001_REG_EXPONENT(n) ((n) >> 12)
6666 #define OPT3001_REG_MANTISSA(n) ((n) & 0xfff)
6767
68+#define OPT3001_INT_TIME_LONG 800000
69+#define OPT3001_INT_TIME_SHORT 100000
70+
6871 /*
6972 * Time to wait for conversion result to be ready. The device datasheet
70− * worst-case max value is 880ms. Add some slack to be on the safe side.
73+ * sect. 6.5 states results are ready after total integration time plus 3ms.
74+ * This results in worst-case max values of 113ms or 883ms, respectively.
75+ * Add some slack to be on the safe side.
7176 */
72−#define OPT3001_RESULT_READY_TIMEOUT msecs_to_jiffies(1000)
77+#define OPT3001_RESULT_READY_SHORT 150
78+#define OPT3001_RESULT_READY_LONG 1000
7379
7480 struct opt3001 {
7581 struct i2c_client *client;
7682 struct device *dev;
7783
7884 struct mutex lock;
79− u16 ok_to_ignore_lock:1;
80− u16 result_ready:1;
85+ bool ok_to_ignore_lock;
86+ bool result_ready;
8187 wait_queue_head_t result_ready_queue;
8288 u16 result;
8389
@@ -89,6 +95,8 @@ struct opt3001 { · 5 unmodified lines
8995
9096 u8 high_thresh_exp;
9197 u8 low_thresh_exp;
98+
99+ bool use_irq;
92100 };
93101
94102 struct opt3001_scale {
@@ -227,26 +235,30 @@ static int opt3001_get_lux(struct opt3001 *opt, int *val, int *val2) · 132 unmodified lines
227235 u16 reg;
228236 u8 exponent;
229237 u16 value;
238+ long timeout;
230239
231− /*
232− * Enable the end-of-conversion interrupt mechanism. Note that doing
233− * so will overwrite the low-level limit value however we will restore
234− * this value later on.
235− */
236− ret = i2c_smbus_write_word_swapped(opt->client, OPT3001_LOW_LIMIT,
237− OPT3001_LOW_LIMIT_EOC_ENABLE);
238− if (ret < 0) {
239− dev_err(opt->dev, "failed to write register %02x\n",
240− OPT3001_LOW_LIMIT);
241− return ret;
240+ if (opt->use_irq) {
241+ /*
242+ * Enable the end-of-conversion interrupt mechanism. Note that
243+ * doing so will overwrite the low-level limit value however we
244+ * will restore this value later on.
245+ */
246+ ret = i2c_smbus_write_word_swapped(opt->client,
247+ OPT3001_LOW_LIMIT,
248+ OPT3001_LOW_LIMIT_EOC_ENABLE);
249+ if (ret < 0) {
250+ dev_err(opt->dev, "failed to write register %02x\n",
251+ OPT3001_LOW_LIMIT);
252+ return ret;
253+ }
254+
255+ /* Allow IRQ to access the device despite lock being set */
256+ opt->ok_to_ignore_lock = true;
242257 }
243258
244− /* Reset data-ready indicator flag (will be set in the IRQ routine) */
259+ /* Reset data-ready indicator flag */
245260 opt->result_ready = false;
246261
247− /* Allow IRQ to access the device despite lock being set */
248− opt->ok_to_ignore_lock = true;
249−
250262 /* Configure for single-conversion mode and start a new conversion */
251263 ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_CONFIGURATION);
252264 if (ret < 0) {
@@ -266,32 +278,69 @@ static int opt3001_get_lux(struct opt3001 *opt, int *val, int *val2) · 13 unmodified lines
266278 goto err;
267279 }
268280
269− /* Wait for the IRQ to indicate the conversion is complete */
270− ret = wait_event_timeout(opt->result_ready_queue, opt->result_ready,
271− OPT3001_RESULT_READY_TIMEOUT);
281+ if (opt->use_irq) {
282+ /* Wait for the IRQ to indicate the conversion is complete */
283+ ret = wait_event_timeout(opt->result_ready_queue,
284+ opt->result_ready,
285+ msecs_to_jiffies(OPT3001_RESULT_READY_LONG));
286+ } else {
287+ /* Sleep for result ready time */
288+ timeout = (opt->int_time == OPT3001_INT_TIME_SHORT) ?
289+ OPT3001_RESULT_READY_SHORT : OPT3001_RESULT_READY_LONG;
290+ msleep(timeout);
291+
292+ /* Check result ready flag */
293+ ret = i2c_smbus_read_word_swapped(opt->client,
294+ OPT3001_CONFIGURATION);
295+ if (ret < 0) {
296+ dev_err(opt->dev, "failed to read register %02x\n",
297+ OPT3001_CONFIGURATION);
298+ goto err;
299+ }
300+
301+ if (!(ret & OPT3001_CONFIGURATION_CRF)) {
302+ ret = -ETIMEDOUT;
303+ goto err;
304+ }
305+
306+ /* Obtain value */
307+ ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_RESULT);
308+ if (ret < 0) {
309+ dev_err(opt->dev, "failed to read register %02x\n",
310+ OPT3001_RESULT);
311+ goto err;
312+ }
313+ opt->result = ret;
314+ opt->result_ready = true;
315+ }
272316
273317 err:
274− /* Disallow IRQ to access the device while lock is active */
275− opt->ok_to_ignore_lock = false;
318+ if (opt->use_irq)
319+ /* Disallow IRQ to access the device while lock is active */
320+ opt->ok_to_ignore_lock = false;
276321
277322 if (ret == 0)
278323 return -ETIMEDOUT;
279324 else if (ret < 0)
280325 return ret;
281326
282− /*
283− * Disable the end-of-conversion interrupt mechanism by restoring the
284− * low-level limit value (clearing OPT3001_LOW_LIMIT_EOC_ENABLE). Note
285− * that selectively clearing those enable bits would affect the actual
286− * limit value due to bit-overlap and therefore can't be done.
287− */
288− value = (opt->low_thresh_exp << 12) | opt->low_thresh_mantissa;
289− ret = i2c_smbus_write_word_swapped(opt->client, OPT3001_LOW_LIMIT,
290− value);
291− if (ret < 0) {
292− dev_err(opt->dev, "failed to write register %02x\n",
293− OPT3001_LOW_LIMIT);
294− return ret;
327+ if (opt->use_irq) {
328+ /*
329+ * Disable the end-of-conversion interrupt mechanism by
330+ * restoring the low-level limit value (clearing
331+ * OPT3001_LOW_LIMIT_EOC_ENABLE). Note that selectively clearing
332+ * those enable bits would affect the actual limit value due to
333+ * bit-overlap and therefore can't be done.
334+ */
335+ value = (opt->low_thresh_exp << 12) | opt->low_thresh_mantissa;
336+ ret = i2c_smbus_write_word_swapped(opt->client,
337+ OPT3001_LOW_LIMIT,
338+ value);
339+ if (ret < 0) {
340+ dev_err(opt->dev, "failed to write register %02x\n",
341+ OPT3001_LOW_LIMIT);
342+ return ret;
343+ }
295344 }
296345
297346 exponent = OPT3001_REG_EXPONENT(opt->result);
@@ -325,13 +374,13 @@ static int opt3001_set_int_time(struct opt3001 *opt, int time) · 27 unmodified lines
325374 reg = ret;
326375
327376 switch (time) {
328− case 100000:
377+ case OPT3001_INT_TIME_SHORT:
329378 reg &= ~OPT3001_CONFIGURATION_CT;
330− opt->int_time = 100000;
379+ opt->int_time = OPT3001_INT_TIME_SHORT;
331380 break;
332− case 800000:
381+ case OPT3001_INT_TIME_LONG:
333382 reg |= OPT3001_CONFIGURATION_CT;
334− opt->int_time = 800000;
383+ opt->int_time = OPT3001_INT_TIME_LONG;
335384 break;
336385 default:
337386 return -EINVAL;
@@ -597,9 +646,9 @@ static int opt3001_configure(struct opt3001 *opt) · 259 unmodified lines
597646
598647 /* Reflect status of the device's integration time setting */
599648 if (reg & OPT3001_CONFIGURATION_CT)
600− opt->int_time = 800000;
649+ opt->int_time = OPT3001_INT_TIME_LONG;
601650 else
602− opt->int_time = 100000;
651+ opt->int_time = OPT3001_INT_TIME_SHORT;
603652
604653 /* Ensure device is in shutdown initially */
605654 opt3001_set_mode(opt, &reg, OPT3001_CONFIGURATION_M_SHUTDOWN);
@@ -733,12 +782,18 @@ static int opt3001_probe(struct i2c_client *client, · 127 unmodified lines
733782 return ret;
734783 }
735784
736− ret = request_threaded_irq(irq, NULL, opt3001_irq,
737− IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
738− "opt3001", iio);
739− if (ret) {
740− dev_err(dev, "failed to request IRQ #%d\n", irq);
741− return ret;
785+ /* Make use of INT pin only if valid IRQ no. is given */
786+ if (irq > 0) {
787+ ret = request_threaded_irq(irq, NULL, opt3001_irq,
788+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
789+ "opt3001", iio);
790+ if (ret) {
791+ dev_err(dev, "failed to request IRQ #%d\n", irq);
792+ return ret;
793+ }
794+ opt->use_irq = true;
795+ } else {
796+ dev_dbg(opt->dev, "enabling interrupt-less operation\n");
742797 }
743798
744799 return 0;
@@ -751,7 +806,8 @@ static int opt3001_remove(struct i2c_client *client) · 6 unmodified lines
751806 int ret;
752807 u16 reg;
753808
754− free_irq(client->irq, iio);
809+ if (opt->use_irq)
810+ free_irq(client->irq, iio);
755811
756812 ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_CONFIGURATION);
757813 if (ret < 0) {
drivers/iio/magnetometer/ak8975.c+2−2
@@ -252,7 +252,7 @@ struct ak_def { · 251 unmodified lines
252252 u8 data_regs[3];
253253 };
254254
255−static struct ak_def ak_def_array[AK_MAX_TYPE] = {
255+static const struct ak_def ak_def_array[AK_MAX_TYPE] = {
256256 {
257257 .type = AK8975,
258258 .raw_to_gauss = ak8975_raw_to_gauss,
@@ -360,7 +360,7 @@ static struct ak_def ak_def_array[AK_MAX_TYPE] = { · 101 unmodified lines
360360 */
361361 struct ak8975_data {
362362 struct i2c_client *client;
363− struct ak_def *def;
363+ const struct ak_def *def;
364364 struct attribute_group attrs;
365365 struct mutex lock;
366366 u8 asa[3];
drivers/iio/magnetometer/st_magn_core.c+4−0
@@ -175,6 +175,8 @@ · 174 unmodified lines
175175 #define ST_MAGN_3_BDU_MASK 0x10
176176 #define ST_MAGN_3_DRDY_IRQ_ADDR 0x62
177177 #define ST_MAGN_3_DRDY_INT_MASK 0x01
178+#define ST_MAGN_3_IHL_IRQ_ADDR 0x63
179+#define ST_MAGN_3_IHL_IRQ_MASK 0x04
178180 #define ST_MAGN_3_FS_AVL_15000_GAIN 1500
179181 #define ST_MAGN_3_MULTIREAD_BIT false
180182 #define ST_MAGN_3_OUT_X_L_ADDR 0x68
@@ -480,6 +482,8 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { · 299 unmodified lines
480482 .drdy_irq = {
481483 .addr = ST_MAGN_3_DRDY_IRQ_ADDR,
482484 .mask_int1 = ST_MAGN_3_DRDY_INT_MASK,
485+ .addr_ihl = ST_MAGN_3_IHL_IRQ_ADDR,
486+ .mask_ihl = ST_MAGN_3_IHL_IRQ_MASK,
483487 },
484488 .multi_read_bit = ST_MAGN_3_MULTIREAD_BIT,
485489 .bootime = 2,
drivers/iio/pressure/Kconfig+28−13
@@ -10,11 +10,11 @@ config BMP280 · 9 unmodified lines
1010 depends on I2C
1111 select REGMAP_I2C
1212 help
13− Say yes here to build support for Bosch Sensortec BMP280
14− pressure and temperature sensor.
13+ Say yes here to build support for Bosch Sensortec BMP280
14+ pressure and temperature sensor.
1515
16− To compile this driver as a module, choose M here: the module
17− will be called bmp280.
16+ To compile this driver as a module, choose M here: the module
17+ will be called bmp280.
1818
1919 config HID_SENSOR_PRESS
2020 depends on HID_SENSOR_HUB
@@ -27,18 +27,33 @@ config HID_SENSOR_PRESS · 6 unmodified lines
2727 Say yes here to build support for the HID SENSOR
2828 Pressure driver
2929
30− To compile this driver as a module, choose M here: the module
31− will be called hid-sensor-press.
30+ To compile this driver as a module, choose M here: the module
31+ will be called hid-sensor-press.
3232
3333 config MPL115
34+ tristate
35+
36+config MPL115_I2C
3437 tristate "Freescale MPL115A2 pressure sensor driver"
3538 depends on I2C
39+ select MPL115
3640 help
3741 Say yes here to build support for the Freescale MPL115A2
3842 pressure sensor connected via I2C.
3943
40− To compile this driver as a module, choose M here: the module
41− will be called mpl115.
44+ To compile this driver as a module, choose M here: the module
45+ will be called mpl115_i2c.
46+
47+config MPL115_SPI
48+ tristate "Freescale MPL115A1 pressure sensor driver"
49+ depends on SPI_MASTER
50+ select MPL115
51+ help
52+ Say yes here to build support for the Freescale MPL115A1
53+ pressure sensor connected via SPI.
54+
55+ To compile this driver as a module, choose M here: the module
56+ will be called mpl115_spi.
4257
4358 config MPL3115
4459 tristate "Freescale MPL3115A2 pressure sensor driver"
@@ -49,8 +64,8 @@ config MPL3115 · 4 unmodified lines
4964 Say yes here to build support for the Freescale MPL3115A2
5065 pressure sensor / altimeter.
5166
52− To compile this driver as a module, choose M here: the module
53− will be called mpl3115.
67+ To compile this driver as a module, choose M here: the module
68+ will be called mpl3115.
5469
5570 config MS5611
5671 tristate "Measurement Specialties MS5611 pressure sensor driver"
@@ -82,7 +97,7 @@ config MS5611_SPI · 25 unmodified lines
8297 config MS5637
8398 tristate "Measurement Specialties MS5637 pressure & temperature sensor"
8499 depends on I2C
85− select IIO_MS_SENSORS_I2C
100+ select IIO_MS_SENSORS_I2C
86101 help
87102 If you say yes here you get support for the Measurement Specialties
88103 MS5637 pressure and temperature sensor.
@@ -128,7 +143,7 @@ config T5403 · 39 unmodified lines
128143 Say yes here to build support for the EPCOS T5403 pressure sensor
129144 connected via I2C.
130145
131− To compile this driver as a module, choose M here: the module
132− will be called t5403.
146+ To compile this driver as a module, choose M here: the module
147+ will be called t5403.
133148
134149 endmenu
drivers/iio/pressure/Makefile+2−0
@@ -6,6 +6,8 @@ · 5 unmodified lines
66 obj-$(CONFIG_BMP280) += bmp280.o
77 obj-$(CONFIG_HID_SENSOR_PRESS) += hid-sensor-press.o
88 obj-$(CONFIG_MPL115) += mpl115.o
9+obj-$(CONFIG_MPL115_I2C) += mpl115_i2c.o
10+obj-$(CONFIG_MPL115_SPI) += mpl115_spi.o
911 obj-$(CONFIG_MPL3115) += mpl3115.o
1012 obj-$(CONFIG_MS5611) += ms5611_core.o
1113 obj-$(CONFIG_MS5611_I2C) += ms5611_i2c.o
drivers/iio/pressure/mpl115.c+27−39
@@ -1,5 +1,5 @@
11 /*
2− * mpl115.c - Support for Freescale MPL115A2 pressure/temperature sensor
2+ * mpl115.c - Support for Freescale MPL115A pressure/temperature sensor
33 *
44 * Copyright (c) 2014 Peter Meerwald <pmeerw@pmeerw.net>
55 *
@@ -7,17 +7,16 @@ · 1 unmodified line
77 * the GNU General Public License. See the file COPYING in the main
88 * directory of this archive for more details.
99 *
10− * (7-bit I2C slave address 0x60)
11− *
1210 * TODO: shutdown pin
1311 *
1412 */
1513
1614 #include <linux/module.h>
17−#include <linux/i2c.h>
1815 #include <linux/iio/iio.h>
1916 #include <linux/delay.h>
2017
18+#include "mpl115.h"
19+
2120 #define MPL115_PADC 0x00 /* pressure ADC output value, MSB first, 10 bit */
2221 #define MPL115_TADC 0x02 /* temperature ADC output value, MSB first, 10 bit */
2322 #define MPL115_A0 0x04 /* 12 bit integer, 3 bit fraction */
@@ -27,16 +26,18 @@ · 3 unmodified lines
2726 #define MPL115_CONVERT 0x12 /* convert temperature and pressure */
2827
2928 struct mpl115_data {
30− struct i2c_client *client;
29+ struct device *dev;
3130 struct mutex lock;
3231 s16 a0;
3332 s16 b1, b2;
3433 s16 c12;
34+ const struct mpl115_ops *ops;
3535 };
3636
3737 static int mpl115_request(struct mpl115_data *data)
3838 {
39− int ret = i2c_smbus_write_byte_data(data->client, MPL115_CONVERT, 0);
39+ int ret = data->ops->write(data->dev, MPL115_CONVERT, 0);
40+
4041 if (ret < 0)
4142 return ret;
4243
@@ -57,12 +58,12 @@ static int mpl115_comp_pressure(struct mpl115_data *data, int *val, int *val2) · 14 unmodified lines
5758 if (ret < 0)
5859 goto done;
5960
60− ret = i2c_smbus_read_word_swapped(data->client, MPL115_PADC);
61+ ret = data->ops->read(data->dev, MPL115_PADC);
6162 if (ret < 0)
6263 goto done;
6364 padc = ret >> 6;
6465
65− ret = i2c_smbus_read_word_swapped(data->client, MPL115_TADC);
66+ ret = data->ops->read(data->dev, MPL115_TADC);
6667 if (ret < 0)
6768 goto done;
6869 tadc = ret >> 6;
@@ -90,7 +91,7 @@ static int mpl115_read_temp(struct mpl115_data *data) · 21 unmodified lines
9091 ret = mpl115_request(data);
9192 if (ret < 0)
9293 goto done;
93− ret = i2c_smbus_read_word_swapped(data->client, MPL115_TADC);
94+ ret = data->ops->read(data->dev, MPL115_TADC);
9495 done:
9596 mutex_unlock(&data->lock);
9697 return ret;
@@ -145,66 +146,53 @@ static const struct iio_info mpl115_info = { · 48 unmodified lines
145146 .driver_module = THIS_MODULE,
146147 };
147148
148−static int mpl115_probe(struct i2c_client *client,
149− const struct i2c_device_id *id)
149+int mpl115_probe(struct device *dev, const char *name,
150+ const struct mpl115_ops *ops)
150151 {
151152 struct mpl115_data *data;
152153 struct iio_dev *indio_dev;
153154 int ret;
154155
155− if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
156− return -ENODEV;
157−
158− indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
156+ indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
159157 if (!indio_dev)
160158 return -ENOMEM;
161159
162160 data = iio_priv(indio_dev);
163− data->client = client;
161+ data->dev = dev;
162+ data->ops = ops;
164163 mutex_init(&data->lock);
165164
166− i2c_set_clientdata(client, indio_dev);
167165 indio_dev->info = &mpl115_info;
168− indio_dev->name = id->name;
169− indio_dev->dev.parent = &client->dev;
166+ indio_dev->name = name;
167+ indio_dev->dev.parent = dev;
170168 indio_dev->modes = INDIO_DIRECT_MODE;
171169 indio_dev->channels = mpl115_channels;
172170 indio_dev->num_channels = ARRAY_SIZE(mpl115_channels);
173171
174− ret = i2c_smbus_read_word_swapped(data->client, MPL115_A0);
172+ ret = data->ops->init(data->dev);
173+ if (ret)
174+ return ret;
175+
176+ ret = data->ops->read(data->dev, MPL115_A0);
175177 if (ret < 0)
176178 return ret;
177179 data->a0 = ret;
178− ret = i2c_smbus_read_word_swapped(data->client, MPL115_B1);
180+ ret = data->ops->read(data->dev, MPL115_B1);
179181 if (ret < 0)
180182 return ret;
181183 data->b1 = ret;
182− ret = i2c_smbus_read_word_swapped(data->client, MPL115_B2);
184+ ret = data->ops->read(data->dev, MPL115_B2);
183185 if (ret < 0)
184186 return ret;
185187 data->b2 = ret;
186− ret = i2c_smbus_read_word_swapped(data->client, MPL115_C12);
188+ ret = data->ops->read(data->dev, MPL115_C12);
187189 if (ret < 0)
188190 return ret;
189191 data->c12 = ret;
190192
191− return devm_iio_device_register(&client->dev, indio_dev);
193+ return devm_iio_device_register(dev, indio_dev);
192194 }
193−
194−static const struct i2c_device_id mpl115_id[] = {
195− { "mpl115", 0 },
196− { }
197−};
198−MODULE_DEVICE_TABLE(i2c, mpl115_id);
199−
200−static struct i2c_driver mpl115_driver = {
201− .driver = {
202− .name = "mpl115",
203− },
204− .probe = mpl115_probe,
205− .id_table = mpl115_id,
206−};
207−module_i2c_driver(mpl115_driver);
195+EXPORT_SYMBOL_GPL(mpl115_probe);
208196
209197 MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
210198 MODULE_DESCRIPTION("Freescale MPL115 pressure/temperature driver");
drivers/iio/pressure/mpl115.h+24−0
@@ -0,0 +1,24 @@
1+/*
2+ * Freescale MPL115A pressure/temperature sensor
3+ *
4+ * Copyright (c) 2014 Peter Meerwald <pmeerw@pmeerw.net>
5+ * Copyright (c) 2016 Akinobu Mita <akinobu.mita@gmail.com>
6+ *
7+ * This file is subject to the terms and conditions of version 2 of
8+ * the GNU General Public License. See the file COPYING in the main
9+ * directory of this archive for more details.
10+ */
11+
12+#ifndef _MPL115_H_
13+#define _MPL115_H_
14+
15+struct mpl115_ops {
16+ int (*init)(struct device *);
17+ int (*read)(struct device *, u8);
18+ int (*write)(struct device *, u8, u8);
19+};
20+
21+int mpl115_probe(struct device *dev, const char *name,
22+ const struct mpl115_ops *ops);
23+
24+#endif
drivers/iio/pressure/mpl115_i2c.c+67−0
@@ -0,0 +1,67 @@
1+/*
2+ * Freescale MPL115A2 pressure/temperature sensor
3+ *
4+ * Copyright (c) 2014 Peter Meerwald <pmeerw@pmeerw.net>
5+ *
6+ * This file is subject to the terms and conditions of version 2 of
7+ * the GNU General Public License. See the file COPYING in the main
8+ * directory of this archive for more details.
9+ *
10+ * (7-bit I2C slave address 0x60)
11+ *
12+ * Datasheet: http://www.nxp.com/files/sensors/doc/data_sheet/MPL115A2.pdf
13+ */
14+
15+#include <linux/module.h>
16+#include <linux/i2c.h>
17+
18+#include "mpl115.h"
19+
20+static int mpl115_i2c_init(struct device *dev)
21+{
22+ return 0;
23+}
24+
25+static int mpl115_i2c_read(struct device *dev, u8 address)
26+{
27+ return i2c_smbus_read_word_swapped(to_i2c_client(dev), address);
28+}
29+
30+static int mpl115_i2c_write(struct device *dev, u8 address, u8 value)
31+{
32+ return i2c_smbus_write_byte_data(to_i2c_client(dev), address, value);
33+}
34+
35+static const struct mpl115_ops mpl115_i2c_ops = {
36+ .init = mpl115_i2c_init,
37+ .read = mpl115_i2c_read,
38+ .write = mpl115_i2c_write,
39+};
40+
41+static int mpl115_i2c_probe(struct i2c_client *client,
42+ const struct i2c_device_id *id)
43+{
44+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
45+ return -ENODEV;
46+
47+ return mpl115_probe(&client->dev, id->name, &mpl115_i2c_ops);
48+}
49+
50+static const struct i2c_device_id mpl115_i2c_id[] = {
51+ { "mpl115", 0 },
52+ { }
53+};
54+MODULE_DEVICE_TABLE(i2c, mpl115_i2c_id);
55+
56+static struct i2c_driver mpl115_i2c_driver = {
57+ .driver = {
58+ .name = "mpl115",
59+ },
60+ .probe = mpl115_i2c_probe,
61+ .id_table = mpl115_i2c_id,
62+};
63+module_i2c_driver(mpl115_i2c_driver);
64+
65+MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
66+MODULE_DESCRIPTION("Freescale MPL115A2 pressure/temperature driver");
67+MODULE_LICENSE("GPL");
drivers/iio/pressure/mpl115_spi.c+106−0
@@ -0,0 +1,106 @@
1+/*
2+ * Freescale MPL115A1 pressure/temperature sensor
3+ *
4+ * Copyright (c) 2016 Akinobu Mita <akinobu.mita@gmail.com>
5+ *
6+ * This file is subject to the terms and conditions of version 2 of
7+ * the GNU General Public License. See the file COPYING in the main
8+ * directory of this archive for more details.
9+ *
10+ * Datasheet: http://www.nxp.com/files/sensors/doc/data_sheet/MPL115A1.pdf
11+ */
12+
13+#include <linux/module.h>
14+#include <linux/spi/spi.h>
15+
16+#include "mpl115.h"
17+
18+#define MPL115_SPI_WRITE(address) ((address) << 1)
19+#define MPL115_SPI_READ(address) (0x80 | (address) << 1)
20+
21+struct mpl115_spi_buf {
22+ u8 tx[4];
23+ u8 rx[4];
24+};
25+
26+static int mpl115_spi_init(struct device *dev)
27+{
28+ struct spi_device *spi = to_spi_device(dev);
29+ struct mpl115_spi_buf *buf;
30+
31+ buf = devm_kzalloc(dev, sizeof(*buf), GFP_KERNEL);
32+ if (!buf)
33+ return -ENOMEM;
34+
35+ spi_set_drvdata(spi, buf);
36+
37+ return 0;
38+}
39+
40+static int mpl115_spi_read(struct device *dev, u8 address)
41+{
42+ struct spi_device *spi = to_spi_device(dev);
43+ struct mpl115_spi_buf *buf = spi_get_drvdata(spi);
44+ struct spi_transfer xfer = {
45+ .tx_buf = buf->tx,
46+ .rx_buf = buf->rx,
47+ .len = 4,
48+ };
49+ int ret;
50+
51+ buf->tx[0] = MPL115_SPI_READ(address);
52+ buf->tx[2] = MPL115_SPI_READ(address + 1);
53+
54+ ret = spi_sync_transfer(spi, &xfer, 1);
55+ if (ret)
56+ return ret;
57+
58+ return (buf->rx[1] << 8) | buf->rx[3];
59+}
60+
61+static int mpl115_spi_write(struct device *dev, u8 address, u8 value)
62+{
63+ struct spi_device *spi = to_spi_device(dev);
64+ struct mpl115_spi_buf *buf = spi_get_drvdata(spi);
65+ struct spi_transfer xfer = {
66+ .tx_buf = buf->tx,
67+ .len = 2,
68+ };
69+
70+ buf->tx[0] = MPL115_SPI_WRITE(address);
71+ buf->tx[1] = value;
72+
73+ return spi_sync_transfer(spi, &xfer, 1);
74+}
75+
76+static const struct mpl115_ops mpl115_spi_ops = {
77+ .init = mpl115_spi_init,
78+ .read = mpl115_spi_read,
79+ .write = mpl115_spi_write,
80+};
81+
82+static int mpl115_spi_probe(struct spi_device *spi)
83+{
84+ const struct spi_device_id *id = spi_get_device_id(spi);
85+
86+ return mpl115_probe(&spi->dev, id->name, &mpl115_spi_ops);
87+}
88+
89+static const struct spi_device_id mpl115_spi_ids[] = {
90+ { "mpl115", 0 },
91+ {}
92+};
93+MODULE_DEVICE_TABLE(spi, mpl115_spi_ids);
94+
95+static struct spi_driver mpl115_spi_driver = {
96+ .driver = {
97+ .name = "mpl115",
98+ },
99+ .probe = mpl115_spi_probe,
100+ .id_table = mpl115_spi_ids,
101+};
102+module_spi_driver(mpl115_spi_driver);
103+
104+MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");
105+MODULE_DESCRIPTION("Freescale MPL115A1 pressure/temperature driver");
106+MODULE_LICENSE("GPL");
drivers/iio/pressure/st_pressure_core.c+8−0
@@ -62,6 +62,8 @@ · 61 unmodified lines
6262 #define ST_PRESS_LPS331AP_DRDY_IRQ_ADDR 0x22
6363 #define ST_PRESS_LPS331AP_DRDY_IRQ_INT1_MASK 0x04
6464 #define ST_PRESS_LPS331AP_DRDY_IRQ_INT2_MASK 0x20
65+#define ST_PRESS_LPS331AP_IHL_IRQ_ADDR 0x22
66+#define ST_PRESS_LPS331AP_IHL_IRQ_MASK 0x80
6567 #define ST_PRESS_LPS331AP_MULTIREAD_BIT true
6668 #define ST_PRESS_LPS331AP_TEMP_OFFSET 42500
6769
@@ -100,6 +102,8 @@ · 32 unmodified lines
100102 #define ST_PRESS_LPS25H_DRDY_IRQ_ADDR 0x23
101103 #define ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK 0x01
102104 #define ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK 0x10
105+#define ST_PRESS_LPS25H_IHL_IRQ_ADDR 0x22
106+#define ST_PRESS_LPS25H_IHL_IRQ_MASK 0x80
103107 #define ST_PRESS_LPS25H_MULTIREAD_BIT true
104108 #define ST_PRESS_LPS25H_TEMP_OFFSET 42500
105109 #define ST_PRESS_LPS25H_OUT_XL_ADDR 0x28
@@ -220,6 +224,8 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { · 114 unmodified lines
220224 .addr = ST_PRESS_LPS331AP_DRDY_IRQ_ADDR,
221225 .mask_int1 = ST_PRESS_LPS331AP_DRDY_IRQ_INT1_MASK,
222226 .mask_int2 = ST_PRESS_LPS331AP_DRDY_IRQ_INT2_MASK,
227+ .addr_ihl = ST_PRESS_LPS331AP_IHL_IRQ_ADDR,
228+ .mask_ihl = ST_PRESS_LPS331AP_IHL_IRQ_MASK,
223229 },
224230 .multi_read_bit = ST_PRESS_LPS331AP_MULTIREAD_BIT,
225231 .bootime = 2,
@@ -304,6 +310,8 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { · 78 unmodified lines
304310 .addr = ST_PRESS_LPS25H_DRDY_IRQ_ADDR,
305311 .mask_int1 = ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK,
306312 .mask_int2 = ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK,
313+ .addr_ihl = ST_PRESS_LPS25H_IHL_IRQ_ADDR,
314+ .mask_ihl = ST_PRESS_LPS25H_IHL_IRQ_MASK,
307315 },
308316 .multi_read_bit = ST_PRESS_LPS25H_MULTIREAD_BIT,
309317 .bootime = 2,
drivers/staging/iio/Documentation/sysfs-bus-iio-light+0−28
@@ -1,31 +1,3 @@
1−
2−What: /sys/bus/iio/devices/device[n]/range
3−KernelVersion: 2.6.37
4−Contact: linux-iio@vger.kernel.org
5−Description:
6− Hardware dependent ADC Full Scale Range used for some ambient
7− light sensors in calculating lux.
8−
9−What: /sys/bus/iio/devices/device[n]/range_available
10−KernelVersion: 2.6.37
11−Contact: linux-iio@vger.kernel.org
12−Description:
13− Hardware dependent supported vales for ADC Full Scale Range.
14−
15−What: /sys/bus/iio/devices/device[n]/adc_resolution
16−KernelVersion: 2.6.37
17−Contact: linux-iio@vger.kernel.org
18−Description:
19− Hardware dependent ADC resolution of the ambient light sensor
20− used in calculating the lux.
21−
22−What: /sys/bus/iio/devices/device[n]/adc_resolution_available
23−KernelVersion: 2.6.37
24−Contact: linux-iio@vger.kernel.org
25−Description:
26− Hardware dependent list of possible values supported for the
27− adc_resolution of the given sensor.
28−
291 What: /sys/bus/iio/devices/device[n]/in_illuminance0[_input|_raw]
302 KernelVersion: 2.6.35
313 Contact: linux-iio@vger.kernel.org
drivers/staging/iio/adc/ad7192.c+1−1
@@ -236,7 +236,7 @@ static int ad7192_setup(struct ad7192_state *st, · 235 unmodified lines
236236 st->mclk = pdata->ext_clk_hz;
237237 else
238238 st->mclk = AD7192_INT_FREQ_MHZ;
239− break;
239+ break;
240240 default:
241241 ret = -EINVAL;
242242 goto out;
drivers/staging/iio/cdc/ad7150.c+18−16
@@ -21,8 +21,8 @@ · 20 unmodified lines
2121 */
2222
2323 #define AD7150_STATUS 0
24−#define AD7150_STATUS_OUT1 (1 << 3)
25−#define AD7150_STATUS_OUT2 (1 << 5)
24+#define AD7150_STATUS_OUT1 BIT(3)
25+#define AD7150_STATUS_OUT2 BIT(5)
2626 #define AD7150_CH1_DATA_HIGH 1
2727 #define AD7150_CH2_DATA_HIGH 3
2828 #define AD7150_CH1_AVG_HIGH 5
@@ -36,7 +36,7 @@ · 7 unmodified lines
3636 #define AD7150_CH2_TIMEOUT 13
3737 #define AD7150_CH2_SETUP 14
3838 #define AD7150_CFG 15
39−#define AD7150_CFG_FIX (1 << 7)
39+#define AD7150_CFG_FIX BIT(7)
4040 #define AD7150_PD_TIMER 16
4141 #define AD7150_CH1_CAPDAC 17
4242 #define AD7150_CH2_CAPDAC 18
@@ -160,8 +160,9 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, · 117 unmodified lines
160160
161161 /* lock should be held */
162162 static int ad7150_write_event_params(struct iio_dev *indio_dev,
163− unsigned int chan, enum iio_event_type type,
164− enum iio_event_direction dir)
163+ unsigned int chan,
164+ enum iio_event_type type,
165+ enum iio_event_direction dir)
165166 {
166167 int ret;
167168 u16 value;
@@ -209,8 +210,9 @@ static int ad7150_write_event_params(struct iio_dev *indio_dev, · 41 unmodified lines
209210 }
210211
211212 static int ad7150_write_event_config(struct iio_dev *indio_dev,
212− const struct iio_chan_spec *chan, enum iio_event_type type,
213− enum iio_event_direction dir, int state)
213+ const struct iio_chan_spec *chan,
214+ enum iio_event_type type,
215+ enum iio_event_direction dir, int state)
214216 {
215217 u8 thresh_type, cfg, adaptive;
216218 int ret;
@@ -302,11 +304,11 @@ static int ad7150_read_event_value(struct iio_dev *indio_dev, · 85 unmodified lines
302304 }
303305
304306 static int ad7150_write_event_value(struct iio_dev *indio_dev,
305− const struct iio_chan_spec *chan,
306− enum iio_event_type type,
307− enum iio_event_direction dir,
308− enum iio_event_info info,
309− int val, int val2)
307+ const struct iio_chan_spec *chan,
308+ enum iio_event_type type,
309+ enum iio_event_direction dir,
310+ enum iio_event_info info,
311+ int val, int val2)
310312 {
311313 int ret;
312314 struct ad7150_chip_info *chip = iio_priv(indio_dev);
@@ -365,9 +367,9 @@ static ssize_t ad7150_show_timeout(struct device *dev, · 52 unmodified lines
365367 }
366368
367369 static ssize_t ad7150_store_timeout(struct device *dev,
368− struct device_attribute *attr,
369− const char *buf,
370− size_t len)
370+ struct device_attribute *attr,
371+ const char *buf,
372+ size_t len)
371373 {
372374 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
373375 struct ad7150_chip_info *chip = iio_priv(indio_dev);
@@ -580,7 +582,7 @@ static const struct iio_info ad7150_info = { · 206 unmodified lines
580582 */
581583
582584 static int ad7150_probe(struct i2c_client *client,
583− const struct i2c_device_id *id)
585+ const struct i2c_device_id *id)
584586 {
585587 int ret;
586588 struct ad7150_chip_info *chip;
include/linux/iio/common/st_sensors.h+4−0
@@ -119,6 +119,8 @@ struct st_sensor_bdu { · 118 unmodified lines
119119 * @addr: address of the register.
120120 * @mask_int1: mask to enable/disable IRQ on INT1 pin.
121121 * @mask_int2: mask to enable/disable IRQ on INT2 pin.
122+ * @addr_ihl: address to enable/disable active low on the INT lines.
123+ * @mask_ihl: mask to enable/disable active low on the INT lines.
122124 * struct ig1 - represents the Interrupt Generator 1 of sensors.
123125 * @en_addr: address of the enable ig1 register.
124126 * @en_mask: mask to write the on/off value for enable.
@@ -127,6 +129,8 @@ struct st_sensor_data_ready_irq { · 2 unmodified lines
127129 u8 addr;
128130 u8 mask_int1;
129131 u8 mask_int2;
132+ u8 addr_ihl;
133+ u8 mask_ihl;
130134 struct {
131135 u8 en_addr;
132136 u8 en_mask;
include/linux/platform_data/ad5761.h+44−0
@@ -0,0 +1,44 @@
1+/*
2+ * AD5721, AD5721R, AD5761, AD5761R, Voltage Output Digital to Analog Converter
3+ *
4+ * Copyright 2016 Qtechnology A/S
5+ * 2016 Ricardo Ribalda <ricardo.ribalda@gmail.com>
6+ *
7+ * Licensed under the GPL-2.
8+ */
9+#ifndef __LINUX_PLATFORM_DATA_AD5761_H__
10+#define __LINUX_PLATFORM_DATA_AD5761_H__
11+
12+/**
13+ * enum ad5761_voltage_range - Voltage range the AD5761 is configured for.
14+ * @AD5761_VOLTAGE_RANGE_M10V_10V: -10V to 10V
15+ * @AD5761_VOLTAGE_RANGE_0V_10V: 0V to 10V
16+ * @AD5761_VOLTAGE_RANGE_M5V_5V: -5V to 5V
17+ * @AD5761_VOLTAGE_RANGE_0V_5V: 0V to 5V
18+ * @AD5761_VOLTAGE_RANGE_M2V5_7V5: -2.5V to 7.5V
19+ * @AD5761_VOLTAGE_RANGE_M3V_3V: -3V to 3V
20+ * @AD5761_VOLTAGE_RANGE_0V_16V: 0V to 16V
21+ * @AD5761_VOLTAGE_RANGE_0V_20V: 0V to 20V
22+ */
23+
24+enum ad5761_voltage_range {
25+ AD5761_VOLTAGE_RANGE_M10V_10V,
26+ AD5761_VOLTAGE_RANGE_0V_10V,
27+ AD5761_VOLTAGE_RANGE_M5V_5V,
28+ AD5761_VOLTAGE_RANGE_0V_5V,
29+ AD5761_VOLTAGE_RANGE_M2V5_7V5,
30+ AD5761_VOLTAGE_RANGE_M3V_3V,
31+ AD5761_VOLTAGE_RANGE_0V_16V,
32+ AD5761_VOLTAGE_RANGE_0V_20V,
33+};
34+
35+/**
36+ * struct ad5761_platform_data - AD5761 DAC driver platform data
37+ * @voltage_range: Voltage range the AD5761 is configured for
38+ */
39+
40+struct ad5761_platform_data {
41+ enum ad5761_voltage_range voltage_range;
42+};
43+
44+#endif
include/uapi/linux/iio/types.h+1−0
@@ -37,6 +37,7 @@ enum iio_chan_type { · 36 unmodified lines
3737 IIO_VELOCITY,
3838 IIO_CONCENTRATION,
3939 IIO_RESISTANCE,
40+ IIO_PH,
4041 };
4142
4243 enum iio_modifier {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t