Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Jonathan writes:

First set of new device support, features and cleanups for IIO in the 4.13 cycle

Two entirely new drivers in here plus the usual range of cleanups and features.

New device support
* ad5064
- add ltc2631, ltc2633 and ltc2635 support.
* bma180
- trivial support for bma250e (new id)
* hid-sensor-rotation
- add relative orientation and geometric orientation support.
* isl29028
- add isl29030 support (its effectively the same part from a driver point of
view)
* maxim_thermocouple
- add max31856 id.
* meson-saradc
- add meson8b SoC adc support.
* ti-adc084s021
- new driver and bindings.
* ti-adc108s102
- new driver and bindings.

Staging graduations
* isl29028

Features
* bma180
- ACPI enumeration for BMA250E which is used in various x86 tablets.
* hi8453
- add raw access rather than only events.
* hid-sensor-hub
- Implement batch mode in which we can set a threshold on the amount of time
between data coming from the fifos. This is the first device to do this
rather than use a watershed on the number of samples.
* hts221
- power management support
* lsm6dsx
- add system power management support.
* rpr0521
- sampling frequency read / write
* stm32-trigger
- add support for TRG02 triggers.
* tsl2583
- runtime power management support.

Cleanups
* core
- inkern: fix a double unlock in iio_read_available_channel_raw when raw
value doesn't appear to be raw (error path).
- fixup accidental sizeof pointer in iio_device_add_mask_type.
* docs
- fix an accidental duplicated line in sysfs-bus-iio-meas-spec.
* tools
- use local include/uapi headers to ensure always up to date.
- increase length of allowed trigger names.
* ad9834
- symbolic to octal permissions.
* ade7753
- symbolic to octal permissions.
- fix indentation
* ade7754
- symbolic to octal permissions.
* ade7758
- symbolic to octal permissions.
- ade7854
- symbolic to octal permissions.
* as3935
- move out of storm check to given consistent results for raw and processed
values.
* bmp280
- fix bme280 naming in Kconfig help.
* hi8435
- avoid garbage on event after enable.
- add missing in_voltage_sensing_mode_available to list possible enum options.
- handle the reset gpio with the obvious polarity rather than relying on
DT to provide it correctly.
* hid-sensors
- fix a wrong error path scrubbing of return values.
* hid-sensors-accel
- drop static on a local variable
* hid-sensors-rotation
- Add missing scale and offset property parsing support.
* ina2xx
- Fix a bad use of GENMASK and some typos and whitespace issues.
* isl29018
- only declare the ACPI table when ACPI is enabled.
* isl29028
- fix proximity sleep times.
* lsm6dsx
- replace ifdef CONFIG_PM with __maybe_unused to avoid the complexity of
dealing with the various PM config variables.
* meson-saradc
- mark meson_sar_adc_data static and const.
* rcar-gyroadc
- derive the interface clock speed from the fck clock on the basis they are
the same actual clock.
- drop the now unused if clock from the bindings.
* rpr0521
- disable sensor when marked as such rather than always enabling it.
- poweroff if probe fails and we can talk to device.
- make sure device powered off when it doesn't need to be on.
- use sizeof rather than hardcoded size on value read.
- whitespace fixup.
- reorder channel numbers ready for buffered support which didn't quite
make this pull request.
* st-accel
- fix platform data initialization to allow remove and reprobe.
* st-pressure
- fix platform data initialization to allow remove and reprobe.
* tsl2x7x
- S_IRUGO, S_IWUSR to octal values
- rename driver for consistency with more recent drivers
- drop FSF mailing address
- replace DEVICE_ATTR macros with the shorter DEVICE_ATTR_RW form and
relevant function renames.
* zpa2326
- report an error for consistency with other error paths.

+2008 -423
+11
Documentation/ABI/testing/sysfs-bus-iio
··· 1425 1425 guarantees that the hardware fifo is flushed to the device 1426 1426 buffer. 1427 1427 1428 + What: /sys/bus/iio/devices/iio:device*/buffer/hwfifo_timeout 1429 + KernelVersion: 4.12 1430 + Contact: linux-iio@vger.kernel.org 1431 + Description: 1432 + A read/write property to provide capability to delay reporting of 1433 + samples till a timeout is reached. This allows host processors to 1434 + sleep, while the sensor is storing samples in its internal fifo. 1435 + The maximum timeout in seconds can be specified by setting 1436 + hwfifo_timeout.The current delay can be read by reading 1437 + hwfifo_timeout. A value of 0 means that there is no timeout. 1438 + 1428 1439 What: /sys/bus/iio/devices/iio:deviceX/buffer/hwfifo_watermark 1429 1440 KernelVersion: 4.2 1430 1441 Contact: linux-iio@vger.kernel.org
-1
Documentation/ABI/testing/sysfs-bus-iio-meas-spec
··· 5 5 Reading returns either '1' or '0'. '1' means that the 6 6 battery level supplied to sensor is below 2.25V. 7 7 This ABI is available for tsys02d, htu21, ms8607 8 - This ABI is available for htu21, ms8607
+48
Documentation/ABI/testing/sysfs-bus-iio-timer-stm32
··· 16 16 - "OC2REF" : OC2REF signal is used as trigger output. 17 17 - "OC3REF" : OC3REF signal is used as trigger output. 18 18 - "OC4REF" : OC4REF signal is used as trigger output. 19 + Additional modes (on TRGO2 only): 20 + - "OC5REF" : OC5REF signal is used as trigger output. 21 + - "OC6REF" : OC6REF signal is used as trigger output. 22 + - "compare_pulse_OC4REF": 23 + OC4REF rising or falling edges generate pulses. 24 + - "compare_pulse_OC6REF": 25 + OC6REF rising or falling edges generate pulses. 26 + - "compare_pulse_OC4REF_r_or_OC6REF_r": 27 + OC4REF or OC6REF rising edges generate pulses. 28 + - "compare_pulse_OC4REF_r_or_OC6REF_f": 29 + OC4REF rising or OC6REF falling edges generate pulses. 30 + - "compare_pulse_OC5REF_r_or_OC6REF_r": 31 + OC5REF or OC6REF rising edges generate pulses. 32 + - "compare_pulse_OC5REF_r_or_OC6REF_f": 33 + OC5REF rising or OC6REF falling edges generate pulses. 34 + 35 + +-----------+ +-------------+ +---------+ 36 + | Prescaler +-> | Counter | +-> | Master | TRGO(2) 37 + +-----------+ +--+--------+-+ |-> | Control +--> 38 + | | || +---------+ 39 + +--v--------+-+ OCxREF || +---------+ 40 + | Chx compare +----------> | Output | ChX 41 + +-----------+-+ | | Control +--> 42 + . | | +---------+ 43 + . | | . 44 + +-----------v-+ OC6REF | . 45 + | Ch6 compare +---------+> 46 + +-------------+ 47 + 48 + Example with: "compare_pulse_OC4REF_r_or_OC6REF_r": 49 + 50 + X 51 + X X 52 + X . . X 53 + X . . X 54 + X . . X 55 + count X . . . . X 56 + . . . . 57 + . . . . 58 + +---------------+ 59 + OC4REF | . . | 60 + +-+ . . +-+ 61 + . +---+ . 62 + OC6REF . | | . 63 + +-------+ +-------+ 64 + +-+ +-+ 65 + TRGO2 | | | | 66 + +-+ +---+ +---------+ 19 67 20 68 What: /sys/bus/iio/devices/triggerX/master_mode 21 69 KernelVersion: 4.11
+2
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt
··· 2 2 3 3 Required properties: 4 4 - compatible: depending on the SoC this should be one of: 5 + - "amlogic,meson8-saradc" for Meson8 6 + - "amlogic,meson8b-saradc" for Meson8b 5 7 - "amlogic,meson-gxbb-saradc" for GXBB 6 8 - "amlogic,meson-gxl-saradc" for GXL 7 9 - "amlogic,meson-gxm-saradc" for GXM
+3 -4
Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt
··· 16 16 - clocks: References to all the clocks specified in the clock-names 17 17 property as specified in 18 18 Documentation/devicetree/bindings/clock/clock-bindings.txt. 19 - - clock-names: Shall contain "fck" and "if". The "fck" is the GyroADC block 20 - clock, the "if" is the interface clock. 19 + - clock-names: Shall contain "fck". The "fck" is the GyroADC block clock. 21 20 - power-domains: Must contain a reference to the PM domain, if available. 22 21 - #address-cells: Should be <1> (setting for the subnodes) for all ADCs 23 22 except for "fujitsu,mb88101a". Should be <0> (setting for ··· 74 75 adc@e6e54000 { 75 76 compatible = "renesas,r8a7791-gyroadc", "renesas,rcar-gyroadc"; 76 77 reg = <0 0xe6e54000 0 64>; 77 - clocks = <&mstp9_clks R8A7791_CLK_GYROADC>, <&clk_65m>; 78 - clock-names = "fck", "if"; 78 + clocks = <&mstp9_clks R8A7791_CLK_GYROADC>; 79 + clock-names = "fck"; 79 80 power-domains = <&sysc R8A7791_PD_ALWAYS_ON>; 80 81 81 82 pinctrl-0 = <&adc_pins>;
+19
Documentation/devicetree/bindings/iio/adc/ti-adc084s021.txt
··· 1 + * Texas Instruments' ADC084S021 2 + 3 + Required properties: 4 + - compatible : Must be "ti,adc084s021" 5 + - reg : SPI chip select number for the device 6 + - vref-supply : The regulator supply for ADC reference voltage 7 + - spi-cpol : Per spi-bus bindings 8 + - spi-cpha : Per spi-bus bindings 9 + - spi-max-frequency : Per spi-bus bindings 10 + 11 + Example: 12 + adc@0 { 13 + compatible = "ti,adc084s021"; 14 + reg = <0>; 15 + vref-supply = <&adc_vref>; 16 + spi-cpol; 17 + spi-cpha; 18 + spi-max-frequency = <16000000>; 19 + };
+18
Documentation/devicetree/bindings/iio/adc/ti-adc108s102.txt
··· 1 + * Texas Instruments' ADC108S102 and ADC128S102 ADC chip 2 + 3 + Required properties: 4 + - compatible: Should be "ti,adc108s102" 5 + - reg: spi chip select number for the device 6 + - vref-supply: The regulator supply for ADC reference voltage 7 + 8 + Recommended properties: 9 + - spi-max-frequency: Definition as per 10 + Documentation/devicetree/bindings/spi/spi-bus.txt 11 + 12 + Example: 13 + adc@0 { 14 + compatible = "ti,adc108s102"; 15 + reg = <0>; 16 + vref-supply = <&vdd_supply>; 17 + spi-max-frequency = <1000000>; 18 + };
+1
Documentation/devicetree/bindings/trivial-devices.txt
··· 55 55 infineon,slb9635tt Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz) 56 56 infineon,slb9645tt Infineon SLB9645 I2C TPM (new protocol, max 400khz) 57 57 isil,isl29028 Intersil ISL29028 Ambient Light and Proximity Sensor 58 + isil,isl29030 Intersil ISL29030 Ambient Light and Proximity Sensor 58 59 maxim,ds1050 5 Bit Programmable, Pulse-Width Modulator 59 60 maxim,max1237 Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs 60 61 maxim,max6625 9-Bit/12-Bit Temperature Sensors with I²C-Compatible Serial Interface
+42 -3
drivers/iio/accel/bma180.c
··· 14 14 * BMA250: 7-bit I2C slave address 0x18 or 0x19 15 15 */ 16 16 17 + #include <linux/acpi.h> 17 18 #include <linux/module.h> 18 19 #include <linux/i2c.h> 19 20 #include <linux/interrupt.h> ··· 37 36 enum chip_ids { 38 37 BMA180, 39 38 BMA250, 39 + BMA250E, 40 40 }; 41 41 42 42 struct bma180_data; ··· 57 55 u8 power_reg, power_mask, lowpower_val; 58 56 u8 int_enable_reg, int_enable_mask; 59 57 u8 softreset_reg; 58 + u8 chip_id; 60 59 61 60 int (*chip_config)(struct bma180_data *data); 62 61 void (*chip_disable)(struct bma180_data *data); ··· 114 111 #define BMA250_DATA_INTEN_MASK BIT(4) 115 112 #define BMA250_INT1_DATA_MASK BIT(0) 116 113 #define BMA250_INT_RESET_MASK BIT(7) /* Reset pending interrupts */ 114 + 115 + #define BMA250E_CHIP_ID 0xf9 117 116 118 117 struct bma180_data { 119 118 struct i2c_client *client; ··· 314 309 315 310 if (ret < 0) 316 311 return ret; 317 - if (ret != BMA180_ID_REG_VAL) 312 + if (ret != data->part_info->chip_id) 318 313 return -ENODEV; 319 314 320 315 ret = bma180_soft_reset(data); ··· 637 632 BMA180_TCO_Z, BMA180_MODE_CONFIG, BMA180_LOW_POWER, 638 633 BMA180_CTRL_REG3, BMA180_NEW_DATA_INT, 639 634 BMA180_RESET, 635 + BMA180_CHIP_ID, 640 636 bma180_chip_config, 641 637 bma180_chip_disable, 642 638 }, ··· 652 646 BMA250_POWER_REG, BMA250_LOWPOWER_MASK, 1, 653 647 BMA250_INT_ENABLE_REG, BMA250_DATA_INTEN_MASK, 654 648 BMA250_RESET_REG, 649 + BMA180_CHIP_ID, 650 + bma250_chip_config, 651 + bma250_chip_disable, 652 + }, 653 + [BMA250E] = { 654 + bma250_channels, ARRAY_SIZE(bma250_channels), 655 + bma250_scale_table, ARRAY_SIZE(bma250_scale_table), 656 + bma250_bw_table, ARRAY_SIZE(bma250_bw_table), 657 + BMA250_INT_RESET_REG, BMA250_INT_RESET_MASK, 658 + BMA250_POWER_REG, BMA250_SUSPEND_MASK, 659 + BMA250_BW_REG, BMA250_BW_MASK, 660 + BMA250_RANGE_REG, BMA250_RANGE_MASK, 661 + BMA250_POWER_REG, BMA250_LOWPOWER_MASK, 1, 662 + BMA250_INT_ENABLE_REG, BMA250_DATA_INTEN_MASK, 663 + BMA250_RESET_REG, 664 + BMA250E_CHIP_ID, 655 665 bma250_chip_config, 656 666 bma250_chip_disable, 657 667 }, ··· 728 706 static int bma180_probe(struct i2c_client *client, 729 707 const struct i2c_device_id *id) 730 708 { 709 + struct device *dev = &client->dev; 710 + const struct acpi_device_id *acpi_id; 731 711 struct bma180_data *data; 732 712 struct iio_dev *indio_dev; 733 713 enum chip_ids chip; ··· 742 718 data = iio_priv(indio_dev); 743 719 i2c_set_clientdata(client, indio_dev); 744 720 data->client = client; 745 - if (client->dev.of_node) 721 + if (dev->of_node) { 746 722 chip = (enum chip_ids)of_device_get_match_data(&client->dev); 747 - else 723 + } else if (id) { 748 724 chip = id->driver_data; 725 + } else { 726 + acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); 727 + if (!acpi_id) 728 + return -ENODEV; 729 + 730 + chip = acpi_id->driver_data; 731 + } 749 732 data->part_info = &bma180_part_info[chip]; 750 733 751 734 ret = data->part_info->chip_config(data); ··· 873 842 #define BMA180_PM_OPS NULL 874 843 #endif 875 844 845 + static const struct acpi_device_id bma180_acpi_match[] = { 846 + { "BMA250E", BMA250E }, 847 + { } 848 + }; 849 + MODULE_DEVICE_TABLE(acpi, bma180_acpi_match); 850 + 876 851 static struct i2c_device_id bma180_ids[] = { 877 852 { "bma180", BMA180 }, 878 853 { "bma250", BMA250 }, 854 + { "bma250e", BMA250E }, 879 855 { } 880 856 }; 881 857 ··· 904 866 static struct i2c_driver bma180_driver = { 905 867 .driver = { 906 868 .name = "bma180", 869 + .acpi_match_table = ACPI_PTR(bma180_acpi_match), 907 870 .pm = BMA180_PM_OPS, 908 871 .of_match_table = bma180_of_match, 909 872 },
+1 -1
drivers/iio/accel/hid-sensor-accel-3d.c
··· 347 347 static int hid_accel_3d_probe(struct platform_device *pdev) 348 348 { 349 349 int ret = 0; 350 - static const char *name; 350 + const char *name; 351 351 struct iio_dev *indio_dev; 352 352 struct accel_3d_state *accel_state; 353 353 const struct iio_chan_spec *channel_spec;
+4 -3
drivers/iio/accel/st_accel_core.c
··· 710 710 int st_accel_common_probe(struct iio_dev *indio_dev) 711 711 { 712 712 struct st_sensor_data *adata = iio_priv(indio_dev); 713 + struct st_sensors_platform_data *pdata = 714 + (struct st_sensors_platform_data *)adata->dev->platform_data; 713 715 int irq = adata->get_irq_data_ready(indio_dev); 714 716 int err; 715 717 ··· 738 736 &adata->sensor_settings->fs.fs_avl[0]; 739 737 adata->odr = adata->sensor_settings->odr.odr_avl[0].hz; 740 738 741 - if (!adata->dev->platform_data) 742 - adata->dev->platform_data = 743 - (struct st_sensors_platform_data *)&default_accel_pdata; 739 + if (!pdata) 740 + pdata = (struct st_sensors_platform_data *)&default_accel_pdata; 744 741 745 742 err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data); 746 743 if (err < 0)
+24
drivers/iio/adc/Kconfig
··· 679 679 This driver can also be built as a module. If so, the module will be 680 680 called ti-adc0832. 681 681 682 + config TI_ADC084S021 683 + tristate "Texas Instruments ADC084S021" 684 + depends on SPI 685 + select IIO_BUFFER 686 + select IIO_TRIGGERED_BUFFER 687 + help 688 + If you say yes here you get support for Texas Instruments ADC084S021 689 + chips. 690 + 691 + This driver can also be built as a module. If so, the module will be 692 + called ti-adc084s021. 693 + 682 694 config TI_ADC12138 683 695 tristate "Texas Instruments ADC12130/ADC12132/ADC12138" 684 696 depends on SPI ··· 702 690 703 691 This driver can also be built as a module. If so, the module will be 704 692 called ti-adc12138. 693 + 694 + config TI_ADC108S102 695 + tristate "Texas Instruments ADC108S102 and ADC128S102 driver" 696 + depends on SPI 697 + select IIO_BUFFER 698 + select IIO_TRIGGERED_BUFFER 699 + help 700 + Say yes here to build support for Texas Instruments ADC108S102 and 701 + ADC128S102 ADC. 702 + 703 + To compile this driver as a module, choose M here: the module will 704 + be called ti-adc108s102. 705 705 706 706 config TI_ADC128S052 707 707 tristate "Texas Instruments ADC128S052/ADC122S021/ADC124S021"
+2
drivers/iio/adc/Makefile
··· 62 62 obj-$(CONFIG_STM32_ADC) += stm32-adc.o 63 63 obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o 64 64 obj-$(CONFIG_TI_ADC0832) += ti-adc0832.o 65 + obj-$(CONFIG_TI_ADC084S021) += ti-adc084s021.o 65 66 obj-$(CONFIG_TI_ADC12138) += ti-adc12138.o 67 + obj-$(CONFIG_TI_ADC108S102) += ti-adc108s102.o 66 68 obj-$(CONFIG_TI_ADC128S052) += ti-adc128s052.o 67 69 obj-$(CONFIG_TI_ADC161S626) += ti-adc161s626.o 68 70 obj-$(CONFIG_TI_ADS1015) += ti-ads1015.o
+43 -7
drivers/iio/adc/hi8435.c
··· 105 105 return spi_write(priv->spi, priv->reg_buffer, 3); 106 106 } 107 107 108 + static int hi8435_read_raw(struct iio_dev *idev, 109 + const struct iio_chan_spec *chan, 110 + int *val, int *val2, long mask) 111 + { 112 + struct hi8435_priv *priv = iio_priv(idev); 113 + u32 tmp; 114 + int ret; 115 + 116 + switch (mask) { 117 + case IIO_CHAN_INFO_RAW: 118 + ret = hi8435_readl(priv, HI8435_SO31_0_REG, &tmp); 119 + if (ret < 0) 120 + return ret; 121 + *val = !!(tmp & BIT(chan->channel)); 122 + return IIO_VAL_INT; 123 + default: 124 + return -EINVAL; 125 + } 126 + } 127 + 108 128 static int hi8435_read_event_config(struct iio_dev *idev, 109 129 const struct iio_chan_spec *chan, 110 130 enum iio_event_type type, ··· 141 121 enum iio_event_direction dir, int state) 142 122 { 143 123 struct hi8435_priv *priv = iio_priv(idev); 124 + int ret; 125 + u32 tmp; 144 126 145 - priv->event_scan_mask &= ~BIT(chan->channel); 146 - if (state) 127 + if (state) { 128 + ret = hi8435_readl(priv, HI8435_SO31_0_REG, &tmp); 129 + if (ret < 0) 130 + return ret; 131 + if (tmp & BIT(chan->channel)) 132 + priv->event_prev_val |= BIT(chan->channel); 133 + else 134 + priv->event_prev_val &= ~BIT(chan->channel); 135 + 147 136 priv->event_scan_mask |= BIT(chan->channel); 137 + } else 138 + priv->event_scan_mask &= ~BIT(chan->channel); 148 139 149 140 return 0; 150 141 } ··· 356 325 357 326 static const struct iio_chan_spec_ext_info hi8435_ext_info[] = { 358 327 IIO_ENUM("sensing_mode", IIO_SEPARATE, &hi8435_sensing_mode), 328 + IIO_ENUM_AVAILABLE("sensing_mode", &hi8435_sensing_mode), 359 329 {}, 360 330 }; 361 331 ··· 365 333 .type = IIO_VOLTAGE, \ 366 334 .indexed = 1, \ 367 335 .channel = num, \ 336 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 368 337 .event_spec = hi8435_events, \ 369 338 .num_event_specs = ARRAY_SIZE(hi8435_events), \ 370 339 .ext_info = hi8435_ext_info, \ ··· 409 376 410 377 static const struct iio_info hi8435_info = { 411 378 .driver_module = THIS_MODULE, 379 + .read_raw = hi8435_read_raw, 412 380 .read_event_config = &hi8435_read_event_config, 413 381 .write_event_config = hi8435_write_event_config, 414 382 .read_event_value = &hi8435_read_event_value, ··· 476 442 priv->spi = spi; 477 443 478 444 reset_gpio = devm_gpiod_get(&spi->dev, NULL, GPIOD_OUT_LOW); 479 - if (IS_ERR(reset_gpio)) { 480 - /* chip s/w reset if h/w reset failed */ 445 + if (!IS_ERR(reset_gpio)) { 446 + /* need >=100ns low pulse to reset chip */ 447 + gpiod_set_raw_value_cansleep(reset_gpio, 0); 448 + udelay(1); 449 + gpiod_set_raw_value_cansleep(reset_gpio, 1); 450 + } else { 451 + /* s/w reset chip if h/w reset is not available */ 481 452 hi8435_writeb(priv, HI8435_CTRL_REG, HI8435_CTRL_SRST); 482 453 hi8435_writeb(priv, HI8435_CTRL_REG, 0); 483 - } else { 484 - udelay(5); 485 - gpiod_set_value(reset_gpio, 1); 486 454 } 487 455 488 456 spi_set_drvdata(spi, idev);
+6 -6
drivers/iio/adc/ina2xx-adc.c
··· 42 42 #define INA2XX_CURRENT 0x04 /* readonly */ 43 43 #define INA2XX_CALIBRATION 0x05 44 44 45 - #define INA226_ALERT_MASK GENMASK(2, 1) 46 - #define INA266_CVRF BIT(3) 45 + #define INA226_MASK_ENABLE 0x06 46 + #define INA226_CVRF BIT(3) 47 47 48 48 #define INA2XX_MAX_REGISTERS 8 49 49 ··· 417 417 .address = (_address), \ 418 418 .indexed = 1, \ 419 419 .channel = (_index), \ 420 - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) \ 421 - | BIT(IIO_CHAN_INFO_SCALE), \ 420 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 421 + BIT(IIO_CHAN_INFO_SCALE), \ 422 422 .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ 423 423 BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ 424 424 .scan_index = (_index), \ ··· 481 481 */ 482 482 if (!chip->allow_async_readout) 483 483 do { 484 - ret = regmap_read(chip->regmap, INA226_ALERT_MASK, 484 + ret = regmap_read(chip->regmap, INA226_MASK_ENABLE, 485 485 &alert); 486 486 if (ret < 0) 487 487 return ret; 488 488 489 - alert &= INA266_CVRF; 489 + alert &= INA226_CVRF; 490 490 } while (!alert); 491 491 492 492 /*
+57 -25
drivers/iio/adc/meson_saradc.c
··· 220 220 }; 221 221 222 222 struct meson_sar_adc_data { 223 + bool has_bl30_integration; 223 224 unsigned int resolution; 224 225 const char *name; 225 226 }; ··· 438 437 439 438 mutex_lock(&indio_dev->mlock); 440 439 441 - /* prevent BL30 from using the SAR ADC while we are using it */ 442 - regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY, 443 - MESON_SAR_ADC_DELAY_KERNEL_BUSY, 444 - MESON_SAR_ADC_DELAY_KERNEL_BUSY); 440 + if (priv->data->has_bl30_integration) { 441 + /* prevent BL30 from using the SAR ADC while we are using it */ 442 + regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY, 443 + MESON_SAR_ADC_DELAY_KERNEL_BUSY, 444 + MESON_SAR_ADC_DELAY_KERNEL_BUSY); 445 445 446 - /* wait until BL30 releases it's lock (so we can use the SAR ADC) */ 447 - do { 448 - udelay(1); 449 - regmap_read(priv->regmap, MESON_SAR_ADC_DELAY, &val); 450 - } while (val & MESON_SAR_ADC_DELAY_BL30_BUSY && timeout--); 446 + /* 447 + * wait until BL30 releases it's lock (so we can use the SAR 448 + * ADC) 449 + */ 450 + do { 451 + udelay(1); 452 + regmap_read(priv->regmap, MESON_SAR_ADC_DELAY, &val); 453 + } while (val & MESON_SAR_ADC_DELAY_BL30_BUSY && timeout--); 451 454 452 - if (timeout < 0) 453 - return -ETIMEDOUT; 455 + if (timeout < 0) 456 + return -ETIMEDOUT; 457 + } 454 458 455 459 return 0; 456 460 } ··· 464 458 { 465 459 struct meson_sar_adc_priv *priv = iio_priv(indio_dev); 466 460 467 - /* allow BL30 to use the SAR ADC again */ 468 - regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY, 469 - MESON_SAR_ADC_DELAY_KERNEL_BUSY, 0); 461 + if (priv->data->has_bl30_integration) 462 + /* allow BL30 to use the SAR ADC again */ 463 + regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY, 464 + MESON_SAR_ADC_DELAY_KERNEL_BUSY, 0); 470 465 471 466 mutex_unlock(&indio_dev->mlock); 472 467 } ··· 621 614 */ 622 615 meson_sar_adc_set_chan7_mux(indio_dev, CHAN7_MUX_CH7_INPUT); 623 616 624 - /* 625 - * leave sampling delay and the input clocks as configured by BL30 to 626 - * make sure BL30 gets the values it expects when reading the 627 - * temperature sensor. 628 - */ 629 - regmap_read(priv->regmap, MESON_SAR_ADC_REG3, &regval); 630 - if (regval & MESON_SAR_ADC_REG3_BL30_INITIALIZED) 631 - return 0; 617 + if (priv->data->has_bl30_integration) { 618 + /* 619 + * leave sampling delay and the input clocks as configured by 620 + * BL30 to make sure BL30 gets the values it expects when 621 + * reading the temperature sensor. 622 + */ 623 + regmap_read(priv->regmap, MESON_SAR_ADC_REG3, &regval); 624 + if (regval & MESON_SAR_ADC_REG3_BL30_INITIALIZED) 625 + return 0; 626 + } 632 627 633 628 meson_sar_adc_stop_sample_engine(indio_dev); 634 629 ··· 843 834 .driver_module = THIS_MODULE, 844 835 }; 845 836 846 - struct meson_sar_adc_data meson_sar_adc_gxbb_data = { 837 + static const struct meson_sar_adc_data meson_sar_adc_meson8_data = { 838 + .has_bl30_integration = false, 839 + .resolution = 10, 840 + .name = "meson-meson8-saradc", 841 + }; 842 + 843 + static const struct meson_sar_adc_data meson_sar_adc_meson8b_data = { 844 + .has_bl30_integration = false, 845 + .resolution = 10, 846 + .name = "meson-meson8b-saradc", 847 + }; 848 + 849 + static const struct meson_sar_adc_data meson_sar_adc_gxbb_data = { 850 + .has_bl30_integration = true, 847 851 .resolution = 10, 848 852 .name = "meson-gxbb-saradc", 849 853 }; 850 854 851 - struct meson_sar_adc_data meson_sar_adc_gxl_data = { 855 + static const struct meson_sar_adc_data meson_sar_adc_gxl_data = { 856 + .has_bl30_integration = true, 852 857 .resolution = 12, 853 858 .name = "meson-gxl-saradc", 854 859 }; 855 860 856 - struct meson_sar_adc_data meson_sar_adc_gxm_data = { 861 + static const struct meson_sar_adc_data meson_sar_adc_gxm_data = { 862 + .has_bl30_integration = true, 857 863 .resolution = 12, 858 864 .name = "meson-gxm-saradc", 859 865 }; 860 866 861 867 static const struct of_device_id meson_sar_adc_of_match[] = { 868 + { 869 + .compatible = "amlogic,meson8-saradc", 870 + .data = &meson_sar_adc_meson8_data, 871 + }, 872 + { 873 + .compatible = "amlogic,meson8b-saradc", 874 + .data = &meson_sar_adc_meson8b_data, 875 + }, 862 876 { 863 877 .compatible = "amlogic,meson-gxbb-saradc", 864 878 .data = &meson_sar_adc_gxbb_data,
+8 -8
drivers/iio/adc/rcar-gyroadc.c
··· 73 73 struct rcar_gyroadc { 74 74 struct device *dev; 75 75 void __iomem *regs; 76 - struct clk *iclk; 76 + struct clk *clk; 77 77 struct regulator *vref[8]; 78 78 unsigned int num_channels; 79 79 enum rcar_gyroadc_model model; ··· 83 83 84 84 static void rcar_gyroadc_hw_init(struct rcar_gyroadc *priv) 85 85 { 86 - const unsigned long clk_mhz = clk_get_rate(priv->iclk) / 1000000; 86 + const unsigned long clk_mhz = clk_get_rate(priv->clk) / 1000000; 87 87 const unsigned long clk_mul = 88 88 (priv->mode == RCAR_GYROADC_MODE_SELECT_1_MB88101A) ? 10 : 5; 89 89 unsigned long clk_len = clk_mhz * clk_mul; ··· 510 510 if (IS_ERR(priv->regs)) 511 511 return PTR_ERR(priv->regs); 512 512 513 - priv->iclk = devm_clk_get(dev, "if"); 514 - if (IS_ERR(priv->iclk)) { 515 - ret = PTR_ERR(priv->iclk); 513 + priv->clk = devm_clk_get(dev, "fck"); 514 + if (IS_ERR(priv->clk)) { 515 + ret = PTR_ERR(priv->clk); 516 516 if (ret != -EPROBE_DEFER) 517 517 dev_err(dev, "Failed to get IF clock (ret=%i)\n", ret); 518 518 return ret; ··· 536 536 indio_dev->info = &rcar_gyroadc_iio_info; 537 537 indio_dev->modes = INDIO_DIRECT_MODE; 538 538 539 - ret = clk_prepare_enable(priv->iclk); 539 + ret = clk_prepare_enable(priv->clk); 540 540 if (ret) { 541 541 dev_err(dev, "Could not prepare or enable the IF clock.\n"); 542 542 goto err_clk_if_enable; ··· 565 565 pm_runtime_put_sync(dev); 566 566 pm_runtime_disable(dev); 567 567 pm_runtime_set_suspended(dev); 568 - clk_disable_unprepare(priv->iclk); 568 + clk_disable_unprepare(priv->clk); 569 569 err_clk_if_enable: 570 570 rcar_gyroadc_deinit_supplies(indio_dev); 571 571 ··· 584 584 pm_runtime_put_sync(dev); 585 585 pm_runtime_disable(dev); 586 586 pm_runtime_set_suspended(dev); 587 - clk_disable_unprepare(priv->iclk); 587 + clk_disable_unprepare(priv->clk); 588 588 rcar_gyroadc_deinit_supplies(indio_dev); 589 589 590 590 return 0;
+275
drivers/iio/adc/ti-adc084s021.c
··· 1 + /** 2 + * Copyright (C) 2017 Axis Communications AB 3 + * 4 + * Driver for Texas Instruments' ADC084S021 ADC chip. 5 + * Datasheets can be found here: 6 + * http://www.ti.com/lit/ds/symlink/adc084s021.pdf 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + */ 12 + 13 + #include <linux/err.h> 14 + #include <linux/spi/spi.h> 15 + #include <linux/module.h> 16 + #include <linux/interrupt.h> 17 + #include <linux/iio/iio.h> 18 + #include <linux/iio/buffer.h> 19 + #include <linux/iio/triggered_buffer.h> 20 + #include <linux/iio/trigger_consumer.h> 21 + #include <linux/regulator/consumer.h> 22 + 23 + #define ADC084S021_DRIVER_NAME "adc084s021" 24 + 25 + struct adc084s021 { 26 + struct spi_device *spi; 27 + struct spi_message message; 28 + struct spi_transfer spi_trans; 29 + struct regulator *reg; 30 + struct mutex lock; 31 + /* 32 + * DMA (thus cache coherency maintenance) requires the 33 + * transfer buffers to live in their own cache line. 34 + */ 35 + u16 tx_buf[4] ____cacheline_aligned; 36 + __be16 rx_buf[5]; /* First 16-bits are trash */ 37 + }; 38 + 39 + #define ADC084S021_VOLTAGE_CHANNEL(num) \ 40 + { \ 41 + .type = IIO_VOLTAGE, \ 42 + .channel = (num), \ 43 + .indexed = 1, \ 44 + .scan_index = (num), \ 45 + .scan_type = { \ 46 + .sign = 'u', \ 47 + .realbits = 8, \ 48 + .storagebits = 16, \ 49 + .shift = 4, \ 50 + .endianness = IIO_BE, \ 51 + }, \ 52 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 53 + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),\ 54 + } 55 + 56 + static const struct iio_chan_spec adc084s021_channels[] = { 57 + ADC084S021_VOLTAGE_CHANNEL(0), 58 + ADC084S021_VOLTAGE_CHANNEL(1), 59 + ADC084S021_VOLTAGE_CHANNEL(2), 60 + ADC084S021_VOLTAGE_CHANNEL(3), 61 + IIO_CHAN_SOFT_TIMESTAMP(4), 62 + }; 63 + 64 + /** 65 + * Read an ADC channel and return its value. 66 + * 67 + * @adc: The ADC SPI data. 68 + * @data: Buffer for converted data. 69 + */ 70 + static int adc084s021_adc_conversion(struct adc084s021 *adc, void *data) 71 + { 72 + int n_words = (adc->spi_trans.len >> 1) - 1; /* Discard first word */ 73 + int ret, i = 0; 74 + u16 *p = data; 75 + 76 + /* Do the transfer */ 77 + ret = spi_sync(adc->spi, &adc->message); 78 + if (ret < 0) 79 + return ret; 80 + 81 + for (; i < n_words; i++) 82 + *(p + i) = adc->rx_buf[i + 1]; 83 + 84 + return ret; 85 + } 86 + 87 + static int adc084s021_read_raw(struct iio_dev *indio_dev, 88 + struct iio_chan_spec const *channel, int *val, 89 + int *val2, long mask) 90 + { 91 + struct adc084s021 *adc = iio_priv(indio_dev); 92 + int ret; 93 + 94 + switch (mask) { 95 + case IIO_CHAN_INFO_RAW: 96 + ret = iio_device_claim_direct_mode(indio_dev); 97 + if (ret < 0) 98 + return ret; 99 + 100 + ret = regulator_enable(adc->reg); 101 + if (ret) { 102 + iio_device_release_direct_mode(indio_dev); 103 + return ret; 104 + } 105 + 106 + adc->tx_buf[0] = channel->channel << 3; 107 + ret = adc084s021_adc_conversion(adc, val); 108 + iio_device_release_direct_mode(indio_dev); 109 + regulator_disable(adc->reg); 110 + if (ret < 0) 111 + return ret; 112 + 113 + *val = be16_to_cpu(*val); 114 + *val = (*val >> channel->scan_type.shift) & 0xff; 115 + 116 + return IIO_VAL_INT; 117 + case IIO_CHAN_INFO_SCALE: 118 + ret = regulator_enable(adc->reg); 119 + if (ret) 120 + return ret; 121 + 122 + ret = regulator_get_voltage(adc->reg); 123 + regulator_disable(adc->reg); 124 + if (ret < 0) 125 + return ret; 126 + 127 + *val = ret / 1000; 128 + 129 + return IIO_VAL_INT; 130 + default: 131 + return -EINVAL; 132 + } 133 + } 134 + 135 + /** 136 + * Read enabled ADC channels and push data to the buffer. 137 + * 138 + * @irq: The interrupt number (not used). 139 + * @pollfunc: Pointer to the poll func. 140 + */ 141 + static irqreturn_t adc084s021_buffer_trigger_handler(int irq, void *pollfunc) 142 + { 143 + struct iio_poll_func *pf = pollfunc; 144 + struct iio_dev *indio_dev = pf->indio_dev; 145 + struct adc084s021 *adc = iio_priv(indio_dev); 146 + __be16 data[8] = {0}; /* 4 * 16-bit words of data + 8 bytes timestamp */ 147 + 148 + mutex_lock(&adc->lock); 149 + 150 + if (adc084s021_adc_conversion(adc, &data) < 0) 151 + dev_err(&adc->spi->dev, "Failed to read data\n"); 152 + 153 + iio_push_to_buffers_with_timestamp(indio_dev, data, 154 + iio_get_time_ns(indio_dev)); 155 + mutex_unlock(&adc->lock); 156 + iio_trigger_notify_done(indio_dev->trig); 157 + 158 + return IRQ_HANDLED; 159 + } 160 + 161 + static int adc084s021_buffer_preenable(struct iio_dev *indio_dev) 162 + { 163 + struct adc084s021 *adc = iio_priv(indio_dev); 164 + int scan_index; 165 + int i = 0; 166 + 167 + for_each_set_bit(scan_index, indio_dev->active_scan_mask, 168 + indio_dev->masklength) { 169 + const struct iio_chan_spec *channel = 170 + &indio_dev->channels[scan_index]; 171 + adc->tx_buf[i++] = channel->channel << 3; 172 + } 173 + adc->spi_trans.len = 2 + (i * sizeof(__be16)); /* Trash + channels */ 174 + 175 + return regulator_enable(adc->reg); 176 + } 177 + 178 + static int adc084s021_buffer_postdisable(struct iio_dev *indio_dev) 179 + { 180 + struct adc084s021 *adc = iio_priv(indio_dev); 181 + 182 + adc->spi_trans.len = 4; /* Trash + single channel */ 183 + 184 + return regulator_disable(adc->reg); 185 + } 186 + 187 + static const struct iio_info adc084s021_info = { 188 + .read_raw = adc084s021_read_raw, 189 + .driver_module = THIS_MODULE, 190 + }; 191 + 192 + static const struct iio_buffer_setup_ops adc084s021_buffer_setup_ops = { 193 + .preenable = adc084s021_buffer_preenable, 194 + .postenable = iio_triggered_buffer_postenable, 195 + .predisable = iio_triggered_buffer_predisable, 196 + .postdisable = adc084s021_buffer_postdisable, 197 + }; 198 + 199 + static int adc084s021_probe(struct spi_device *spi) 200 + { 201 + struct iio_dev *indio_dev; 202 + struct adc084s021 *adc; 203 + int ret; 204 + 205 + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); 206 + if (!indio_dev) { 207 + dev_err(&spi->dev, "Failed to allocate IIO device\n"); 208 + return -ENOMEM; 209 + } 210 + 211 + adc = iio_priv(indio_dev); 212 + adc->spi = spi; 213 + 214 + /* Connect the SPI device and the iio dev */ 215 + spi_set_drvdata(spi, indio_dev); 216 + 217 + /* Initiate the Industrial I/O device */ 218 + indio_dev->dev.parent = &spi->dev; 219 + indio_dev->dev.of_node = spi->dev.of_node; 220 + indio_dev->name = spi_get_device_id(spi)->name; 221 + indio_dev->modes = INDIO_DIRECT_MODE; 222 + indio_dev->info = &adc084s021_info; 223 + indio_dev->channels = adc084s021_channels; 224 + indio_dev->num_channels = ARRAY_SIZE(adc084s021_channels); 225 + 226 + /* Create SPI transfer for channel reads */ 227 + adc->spi_trans.tx_buf = adc->tx_buf; 228 + adc->spi_trans.rx_buf = adc->rx_buf; 229 + adc->spi_trans.len = 4; /* Trash + single channel */ 230 + spi_message_init_with_transfers(&adc->message, &adc->spi_trans, 1); 231 + 232 + adc->reg = devm_regulator_get(&spi->dev, "vref"); 233 + if (IS_ERR(adc->reg)) 234 + return PTR_ERR(adc->reg); 235 + 236 + mutex_init(&adc->lock); 237 + 238 + /* Setup triggered buffer with pollfunction */ 239 + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, 240 + adc084s021_buffer_trigger_handler, 241 + &adc084s021_buffer_setup_ops); 242 + if (ret) { 243 + dev_err(&spi->dev, "Failed to setup triggered buffer\n"); 244 + return ret; 245 + } 246 + 247 + return devm_iio_device_register(&spi->dev, indio_dev); 248 + } 249 + 250 + static const struct of_device_id adc084s021_of_match[] = { 251 + { .compatible = "ti,adc084s021", }, 252 + {}, 253 + }; 254 + MODULE_DEVICE_TABLE(of, adc084s021_of_match); 255 + 256 + static const struct spi_device_id adc084s021_id[] = { 257 + { ADC084S021_DRIVER_NAME, 0}, 258 + {} 259 + }; 260 + MODULE_DEVICE_TABLE(spi, adc084s021_id); 261 + 262 + static struct spi_driver adc084s021_driver = { 263 + .driver = { 264 + .name = ADC084S021_DRIVER_NAME, 265 + .of_match_table = of_match_ptr(adc084s021_of_match), 266 + }, 267 + .probe = adc084s021_probe, 268 + .id_table = adc084s021_id, 269 + }; 270 + module_spi_driver(adc084s021_driver); 271 + 272 + MODULE_AUTHOR("Mårten Lindahl <martenli@axis.com>"); 273 + MODULE_DESCRIPTION("Texas Instruments ADC084S021"); 274 + MODULE_LICENSE("GPL v2"); 275 + MODULE_VERSION("1.0");
+348
drivers/iio/adc/ti-adc108s102.c
··· 1 + /* 2 + * TI ADC108S102 SPI ADC driver 3 + * 4 + * Copyright (c) 2013-2015 Intel Corporation. 5 + * Copyright (c) 2017 Siemens AG 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms and conditions of the GNU General Public License, 9 + * version 2, as published by the Free Software Foundation. 10 + * 11 + * This program is distributed in the hope it will be useful, but WITHOUT 12 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 + * more details. 15 + * 16 + * This IIO device driver is designed to work with the following 17 + * analog to digital converters from Texas Instruments: 18 + * ADC108S102 19 + * ADC128S102 20 + * The communication with ADC chip is via the SPI bus (mode 3). 21 + */ 22 + 23 + #include <linux/acpi.h> 24 + #include <linux/iio/iio.h> 25 + #include <linux/iio/buffer.h> 26 + #include <linux/iio/types.h> 27 + #include <linux/iio/triggered_buffer.h> 28 + #include <linux/iio/trigger_consumer.h> 29 + #include <linux/interrupt.h> 30 + #include <linux/module.h> 31 + #include <linux/property.h> 32 + #include <linux/regulator/consumer.h> 33 + #include <linux/spi/spi.h> 34 + 35 + /* 36 + * In case of ACPI, we use the hard-wired 5000 mV of the Galileo and IOT2000 37 + * boards as default for the reference pin VA. Device tree users encode that 38 + * via the vref-supply regulator. 39 + */ 40 + #define ADC108S102_VA_MV_ACPI_DEFAULT 5000 41 + 42 + /* 43 + * Defining the ADC resolution being 12 bits, we can use the same driver for 44 + * both ADC108S102 (10 bits resolution) and ADC128S102 (12 bits resolution) 45 + * chips. The ADC108S102 effectively returns a 12-bit result with the 2 46 + * least-significant bits unset. 47 + */ 48 + #define ADC108S102_BITS 12 49 + #define ADC108S102_MAX_CHANNELS 8 50 + 51 + /* 52 + * 16-bit SPI command format: 53 + * [15:14] Ignored 54 + * [13:11] 3-bit channel address 55 + * [10:0] Ignored 56 + */ 57 + #define ADC108S102_CMD(ch) ((u16)(ch) << 11) 58 + 59 + /* 60 + * 16-bit SPI response format: 61 + * [15:12] Zeros 62 + * [11:0] 12-bit ADC sample (for ADC108S102, [1:0] will always be 0). 63 + */ 64 + #define ADC108S102_RES_DATA(res) ((u16)res & GENMASK(11, 0)) 65 + 66 + struct adc108s102_state { 67 + struct spi_device *spi; 68 + struct regulator *reg; 69 + u32 va_millivolt; 70 + /* SPI transfer used by triggered buffer handler*/ 71 + struct spi_transfer ring_xfer; 72 + /* SPI transfer used by direct scan */ 73 + struct spi_transfer scan_single_xfer; 74 + /* SPI message used by ring_xfer SPI transfer */ 75 + struct spi_message ring_msg; 76 + /* SPI message used by scan_single_xfer SPI transfer */ 77 + struct spi_message scan_single_msg; 78 + 79 + /* 80 + * SPI message buffers: 81 + * tx_buf: |C0|C1|C2|C3|C4|C5|C6|C7|XX| 82 + * rx_buf: |XX|R0|R1|R2|R3|R4|R5|R6|R7|tt|tt|tt|tt| 83 + * 84 + * tx_buf: 8 channel read commands, plus 1 dummy command 85 + * rx_buf: 1 dummy response, 8 channel responses, plus 64-bit timestamp 86 + */ 87 + __be16 rx_buf[13] ____cacheline_aligned; 88 + __be16 tx_buf[9] ____cacheline_aligned; 89 + }; 90 + 91 + #define ADC108S102_V_CHAN(index) \ 92 + { \ 93 + .type = IIO_VOLTAGE, \ 94 + .indexed = 1, \ 95 + .channel = index, \ 96 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 97 + BIT(IIO_CHAN_INFO_SCALE), \ 98 + .address = index, \ 99 + .scan_index = index, \ 100 + .scan_type = { \ 101 + .sign = 'u', \ 102 + .realbits = ADC108S102_BITS, \ 103 + .storagebits = 16, \ 104 + .endianness = IIO_BE, \ 105 + }, \ 106 + } 107 + 108 + static const struct iio_chan_spec adc108s102_channels[] = { 109 + ADC108S102_V_CHAN(0), 110 + ADC108S102_V_CHAN(1), 111 + ADC108S102_V_CHAN(2), 112 + ADC108S102_V_CHAN(3), 113 + ADC108S102_V_CHAN(4), 114 + ADC108S102_V_CHAN(5), 115 + ADC108S102_V_CHAN(6), 116 + ADC108S102_V_CHAN(7), 117 + IIO_CHAN_SOFT_TIMESTAMP(8), 118 + }; 119 + 120 + static int adc108s102_update_scan_mode(struct iio_dev *indio_dev, 121 + unsigned long const *active_scan_mask) 122 + { 123 + struct adc108s102_state *st = iio_priv(indio_dev); 124 + unsigned int bit, cmds; 125 + 126 + /* 127 + * Fill in the first x shorts of tx_buf with the number of channels 128 + * enabled for sampling by the triggered buffer. 129 + */ 130 + cmds = 0; 131 + for_each_set_bit(bit, active_scan_mask, ADC108S102_MAX_CHANNELS) 132 + st->tx_buf[cmds++] = cpu_to_be16(ADC108S102_CMD(bit)); 133 + 134 + /* One dummy command added, to clock in the last response */ 135 + st->tx_buf[cmds++] = 0x00; 136 + 137 + /* build SPI ring message */ 138 + st->ring_xfer.tx_buf = &st->tx_buf[0]; 139 + st->ring_xfer.rx_buf = &st->rx_buf[0]; 140 + st->ring_xfer.len = cmds * sizeof(st->tx_buf[0]); 141 + 142 + spi_message_init_with_transfers(&st->ring_msg, &st->ring_xfer, 1); 143 + 144 + return 0; 145 + } 146 + 147 + static irqreturn_t adc108s102_trigger_handler(int irq, void *p) 148 + { 149 + struct iio_poll_func *pf = p; 150 + struct iio_dev *indio_dev = pf->indio_dev; 151 + struct adc108s102_state *st = iio_priv(indio_dev); 152 + int ret; 153 + 154 + ret = spi_sync(st->spi, &st->ring_msg); 155 + if (ret < 0) 156 + goto out_notify; 157 + 158 + /* Skip the dummy response in the first slot */ 159 + iio_push_to_buffers_with_timestamp(indio_dev, 160 + (u8 *)&st->rx_buf[1], 161 + iio_get_time_ns(indio_dev)); 162 + 163 + out_notify: 164 + iio_trigger_notify_done(indio_dev->trig); 165 + 166 + return IRQ_HANDLED; 167 + } 168 + 169 + static int adc108s102_scan_direct(struct adc108s102_state *st, unsigned int ch) 170 + { 171 + int ret; 172 + 173 + st->tx_buf[0] = cpu_to_be16(ADC108S102_CMD(ch)); 174 + ret = spi_sync(st->spi, &st->scan_single_msg); 175 + if (ret) 176 + return ret; 177 + 178 + /* Skip the dummy response in the first slot */ 179 + return be16_to_cpu(st->rx_buf[1]); 180 + } 181 + 182 + static int adc108s102_read_raw(struct iio_dev *indio_dev, 183 + struct iio_chan_spec const *chan, 184 + int *val, int *val2, long m) 185 + { 186 + struct adc108s102_state *st = iio_priv(indio_dev); 187 + int ret; 188 + 189 + switch (m) { 190 + case IIO_CHAN_INFO_RAW: 191 + ret = iio_device_claim_direct_mode(indio_dev); 192 + if (ret) 193 + return ret; 194 + 195 + ret = adc108s102_scan_direct(st, chan->address); 196 + 197 + iio_device_release_direct_mode(indio_dev); 198 + 199 + if (ret < 0) 200 + return ret; 201 + 202 + *val = ADC108S102_RES_DATA(ret); 203 + 204 + return IIO_VAL_INT; 205 + case IIO_CHAN_INFO_SCALE: 206 + if (chan->type != IIO_VOLTAGE) 207 + break; 208 + 209 + *val = st->va_millivolt; 210 + *val2 = chan->scan_type.realbits; 211 + 212 + return IIO_VAL_FRACTIONAL_LOG2; 213 + default: 214 + break; 215 + } 216 + 217 + return -EINVAL; 218 + } 219 + 220 + static const struct iio_info adc108s102_info = { 221 + .read_raw = &adc108s102_read_raw, 222 + .update_scan_mode = &adc108s102_update_scan_mode, 223 + .driver_module = THIS_MODULE, 224 + }; 225 + 226 + static int adc108s102_probe(struct spi_device *spi) 227 + { 228 + struct adc108s102_state *st; 229 + struct iio_dev *indio_dev; 230 + int ret; 231 + 232 + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 233 + if (!indio_dev) 234 + return -ENOMEM; 235 + 236 + st = iio_priv(indio_dev); 237 + 238 + if (ACPI_COMPANION(&spi->dev)) { 239 + st->va_millivolt = ADC108S102_VA_MV_ACPI_DEFAULT; 240 + } else { 241 + st->reg = devm_regulator_get(&spi->dev, "vref"); 242 + if (IS_ERR(st->reg)) 243 + return PTR_ERR(st->reg); 244 + 245 + ret = regulator_enable(st->reg); 246 + if (ret < 0) { 247 + dev_err(&spi->dev, "Cannot enable vref regulator\n"); 248 + return ret; 249 + } 250 + 251 + ret = regulator_get_voltage(st->reg); 252 + if (ret < 0) { 253 + dev_err(&spi->dev, "vref get voltage failed\n"); 254 + return ret; 255 + } 256 + 257 + st->va_millivolt = ret / 1000; 258 + } 259 + 260 + spi_set_drvdata(spi, indio_dev); 261 + st->spi = spi; 262 + 263 + indio_dev->name = spi->modalias; 264 + indio_dev->dev.parent = &spi->dev; 265 + indio_dev->modes = INDIO_DIRECT_MODE; 266 + indio_dev->channels = adc108s102_channels; 267 + indio_dev->num_channels = ARRAY_SIZE(adc108s102_channels); 268 + indio_dev->info = &adc108s102_info; 269 + 270 + /* Setup default message */ 271 + st->scan_single_xfer.tx_buf = st->tx_buf; 272 + st->scan_single_xfer.rx_buf = st->rx_buf; 273 + st->scan_single_xfer.len = 2 * sizeof(st->tx_buf[0]); 274 + 275 + spi_message_init_with_transfers(&st->scan_single_msg, 276 + &st->scan_single_xfer, 1); 277 + 278 + ret = iio_triggered_buffer_setup(indio_dev, NULL, 279 + &adc108s102_trigger_handler, NULL); 280 + if (ret) 281 + goto error_disable_reg; 282 + 283 + ret = iio_device_register(indio_dev); 284 + if (ret) { 285 + dev_err(&spi->dev, "Failed to register IIO device\n"); 286 + goto error_cleanup_triggered_buffer; 287 + } 288 + return 0; 289 + 290 + error_cleanup_triggered_buffer: 291 + iio_triggered_buffer_cleanup(indio_dev); 292 + 293 + error_disable_reg: 294 + regulator_disable(st->reg); 295 + 296 + return ret; 297 + } 298 + 299 + static int adc108s102_remove(struct spi_device *spi) 300 + { 301 + struct iio_dev *indio_dev = spi_get_drvdata(spi); 302 + struct adc108s102_state *st = iio_priv(indio_dev); 303 + 304 + iio_device_unregister(indio_dev); 305 + iio_triggered_buffer_cleanup(indio_dev); 306 + 307 + regulator_disable(st->reg); 308 + 309 + return 0; 310 + } 311 + 312 + #ifdef CONFIG_OF 313 + static const struct of_device_id adc108s102_of_match[] = { 314 + { .compatible = "ti,adc108s102" }, 315 + { } 316 + }; 317 + MODULE_DEVICE_TABLE(of, adc108s102_of_match); 318 + #endif 319 + 320 + #ifdef CONFIG_ACPI 321 + static const struct acpi_device_id adc108s102_acpi_ids[] = { 322 + { "INT3495", 0 }, 323 + { } 324 + }; 325 + MODULE_DEVICE_TABLE(acpi, adc108s102_acpi_ids); 326 + #endif 327 + 328 + static const struct spi_device_id adc108s102_id[] = { 329 + { "adc108s102", 0 }, 330 + { } 331 + }; 332 + MODULE_DEVICE_TABLE(spi, adc108s102_id); 333 + 334 + static struct spi_driver adc108s102_driver = { 335 + .driver = { 336 + .name = "adc108s102", 337 + .of_match_table = of_match_ptr(adc108s102_of_match), 338 + .acpi_match_table = ACPI_PTR(adc108s102_acpi_ids), 339 + }, 340 + .probe = adc108s102_probe, 341 + .remove = adc108s102_remove, 342 + .id_table = adc108s102_id, 343 + }; 344 + module_spi_driver(adc108s102_driver); 345 + 346 + MODULE_AUTHOR("Bogdan Pricop <bogdan.pricop@emutex.com>"); 347 + MODULE_DESCRIPTION("Texas Instruments ADC108S102 and ADC128S102 driver"); 348 + MODULE_LICENSE("GPL v2");
+52 -2
drivers/iio/common/hid-sensors/hid-sensor-attributes.c
··· 69 69 {HID_USAGE_SENSOR_TIME_TIMESTAMP, HID_USAGE_SENSOR_UNITS_MILLISECOND, 70 70 1000000, 0}, 71 71 72 + {HID_USAGE_SENSOR_DEVICE_ORIENTATION, 0, 1, 0}, 73 + 74 + {HID_USAGE_SENSOR_RELATIVE_ORIENTATION, 0, 1, 0}, 75 + 76 + {HID_USAGE_SENSOR_GEOMAGNETIC_ORIENTATION, 0, 1, 0}, 77 + 72 78 {HID_USAGE_SENSOR_TEMPERATURE, 0, 1000, 0}, 73 79 {HID_USAGE_SENSOR_TEMPERATURE, HID_USAGE_SENSOR_UNITS_DEGREES, 1000, 0}, 74 80 ··· 236 230 ret = sensor_hub_set_feature(st->hsdev, st->poll.report_id, 237 231 st->poll.index, sizeof(value), &value); 238 232 if (ret < 0 || value < 0) 239 - ret = -EINVAL; 233 + return -EINVAL; 240 234 241 235 ret = sensor_hub_get_feature(st->hsdev, 242 236 st->poll.report_id, ··· 289 283 st->sensitivity.index, sizeof(value), 290 284 &value); 291 285 if (ret < 0 || value < 0) 292 - ret = -EINVAL; 286 + return -EINVAL; 293 287 294 288 ret = sensor_hub_get_feature(st->hsdev, 295 289 st->sensitivity.report_id, ··· 410 404 411 405 } 412 406 407 + static void hid_sensor_get_report_latency_info(struct hid_sensor_hub_device *hsdev, 408 + u32 usage_id, 409 + struct hid_sensor_common *st) 410 + { 411 + sensor_hub_input_get_attribute_info(hsdev, HID_FEATURE_REPORT, 412 + usage_id, 413 + HID_USAGE_SENSOR_PROP_REPORT_LATENCY, 414 + &st->report_latency); 415 + 416 + hid_dbg(hsdev->hdev, "Report latency attributes: %x:%x\n", 417 + st->report_latency.index, st->report_latency.report_id); 418 + } 419 + 420 + int hid_sensor_get_report_latency(struct hid_sensor_common *st) 421 + { 422 + int ret; 423 + int value; 424 + 425 + ret = sensor_hub_get_feature(st->hsdev, st->report_latency.report_id, 426 + st->report_latency.index, sizeof(value), 427 + &value); 428 + if (ret < 0) 429 + return ret; 430 + 431 + return value; 432 + } 433 + EXPORT_SYMBOL(hid_sensor_get_report_latency); 434 + 435 + int hid_sensor_set_report_latency(struct hid_sensor_common *st, int latency_ms) 436 + { 437 + return sensor_hub_set_feature(st->hsdev, st->report_latency.report_id, 438 + st->report_latency.index, 439 + sizeof(latency_ms), &latency_ms); 440 + } 441 + EXPORT_SYMBOL(hid_sensor_set_report_latency); 442 + 443 + bool hid_sensor_batch_mode_supported(struct hid_sensor_common *st) 444 + { 445 + return st->report_latency.index > 0 && st->report_latency.report_id > 0; 446 + } 447 + EXPORT_SYMBOL(hid_sensor_batch_mode_supported); 448 + 413 449 int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, 414 450 u32 usage_id, 415 451 struct hid_sensor_common *st) ··· 492 444 st->timestamp_ns_scale = val0; 493 445 } else 494 446 st->timestamp_ns_scale = 1000000000; 447 + 448 + hid_sensor_get_report_latency_info(hsdev, usage_id, st); 495 449 496 450 hid_dbg(hsdev->hdev, "common attributes: %x:%x, %x:%x, %x:%x %x:%x %x:%x\n", 497 451 st->poll.index, st->poll.report_id,
+80
drivers/iio/common/hid-sensors/hid-sensor-trigger.c
··· 26 26 #include <linux/hid-sensor-hub.h> 27 27 #include <linux/iio/iio.h> 28 28 #include <linux/iio/trigger.h> 29 + #include <linux/iio/buffer.h> 29 30 #include <linux/iio/sysfs.h> 30 31 #include "hid-sensor-trigger.h" 32 + 33 + static ssize_t _hid_sensor_set_report_latency(struct device *dev, 34 + struct device_attribute *attr, 35 + const char *buf, size_t len) 36 + { 37 + struct iio_dev *indio_dev = dev_to_iio_dev(dev); 38 + struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev); 39 + int integer, fract, ret; 40 + int latency; 41 + 42 + ret = iio_str_to_fixpoint(buf, 100000, &integer, &fract); 43 + if (ret) 44 + return ret; 45 + 46 + latency = integer * 1000 + fract / 1000; 47 + ret = hid_sensor_set_report_latency(attrb, latency); 48 + if (ret < 0) 49 + return len; 50 + 51 + attrb->latency_ms = hid_sensor_get_report_latency(attrb); 52 + 53 + return len; 54 + } 55 + 56 + static ssize_t _hid_sensor_get_report_latency(struct device *dev, 57 + struct device_attribute *attr, 58 + char *buf) 59 + { 60 + struct iio_dev *indio_dev = dev_to_iio_dev(dev); 61 + struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev); 62 + int latency; 63 + 64 + latency = hid_sensor_get_report_latency(attrb); 65 + if (latency < 0) 66 + return latency; 67 + 68 + return sprintf(buf, "%d.%06u\n", latency / 1000, (latency % 1000) * 1000); 69 + } 70 + 71 + static ssize_t _hid_sensor_get_fifo_state(struct device *dev, 72 + struct device_attribute *attr, 73 + char *buf) 74 + { 75 + struct iio_dev *indio_dev = dev_to_iio_dev(dev); 76 + struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev); 77 + int latency; 78 + 79 + latency = hid_sensor_get_report_latency(attrb); 80 + if (latency < 0) 81 + return latency; 82 + 83 + return sprintf(buf, "%d\n", !!latency); 84 + } 85 + 86 + static IIO_DEVICE_ATTR(hwfifo_timeout, 0644, 87 + _hid_sensor_get_report_latency, 88 + _hid_sensor_set_report_latency, 0); 89 + static IIO_DEVICE_ATTR(hwfifo_enabled, 0444, 90 + _hid_sensor_get_fifo_state, NULL, 0); 91 + 92 + static const struct attribute *hid_sensor_fifo_attributes[] = { 93 + &iio_dev_attr_hwfifo_timeout.dev_attr.attr, 94 + &iio_dev_attr_hwfifo_enabled.dev_attr.attr, 95 + NULL, 96 + }; 97 + 98 + static void hid_sensor_setup_batch_mode(struct iio_dev *indio_dev, 99 + struct hid_sensor_common *st) 100 + { 101 + if (!hid_sensor_batch_mode_supported(st)) 102 + return; 103 + 104 + iio_buffer_set_attrs(indio_dev->buffer, hid_sensor_fifo_attributes); 105 + } 31 106 32 107 static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state) 33 108 { ··· 216 141 sizeof(attrb->raw_hystersis), 217 142 &attrb->raw_hystersis); 218 143 144 + if (attrb->latency_ms > 0) 145 + hid_sensor_set_report_latency(attrb, attrb->latency_ms); 146 + 219 147 _hid_sensor_power_state(attrb, true); 220 148 } 221 149 ··· 269 191 } 270 192 attrb->trigger = trig; 271 193 indio_dev->trig = iio_trigger_get(trig); 194 + 195 + hid_sensor_setup_batch_mode(indio_dev, attrb); 272 196 273 197 ret = pm_runtime_set_active(&indio_dev->dev); 274 198 if (ret)
+2 -1
drivers/iio/dac/Kconfig
··· 13 13 AD5045, AD5064, AD5064-1, AD5065, AD5625, AD5625R, AD5627, AD5627R, 14 14 AD5628, AD5629R, AD5645R, AD5647R, AD5648, AD5665, AD5665R, AD5666, 15 15 AD5667, AD5667R, AD5668, AD5669R, LTC2606, LTC2607, LTC2609, LTC2616, 16 - LTC2617, LTC2619, LTC2626, LTC2627, LTC2629 Digital to Analog Converter. 16 + LTC2617, LTC2619, LTC2626, LTC2627, LTC2629, LTC2631, LTC2633, LTC2635 17 + Digital to Analog Converter. 17 18 18 19 To compile this driver as a module, choose M here: the 19 20 module will be called ad5064.
+69 -2
drivers/iio/dac/ad5064.c
··· 2 2 * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5625, AD5625R, 3 3 * AD5627, AD5627R, AD5628, AD5629R, AD5645R, AD5647R, AD5648, AD5665, AD5665R, 4 4 * AD5666, AD5667, AD5667R, AD5668, AD5669R, LTC2606, LTC2607, LTC2609, LTC2616, 5 - * LTC2617, LTC2619, LTC2626, LTC2627, LTC2629 Digital to analog converters 6 - * driver 5 + * LTC2617, LTC2619, LTC2626, LTC2627, LTC2629, LTC2631, LTC2633, LTC2635 6 + * Digital to analog converters driver 7 7 * 8 8 * Copyright 2011 Analog Devices Inc. 9 9 * ··· 168 168 ID_LTC2626, 169 169 ID_LTC2627, 170 170 ID_LTC2629, 171 + ID_LTC2631_L12, 172 + ID_LTC2631_H12, 173 + ID_LTC2631_L10, 174 + ID_LTC2631_H10, 175 + ID_LTC2631_L8, 176 + ID_LTC2631_H8, 177 + ID_LTC2633_L12, 178 + ID_LTC2633_H12, 179 + ID_LTC2633_L10, 180 + ID_LTC2633_H10, 181 + ID_LTC2633_L8, 182 + ID_LTC2633_H8, 183 + ID_LTC2635_L12, 184 + ID_LTC2635_H12, 185 + ID_LTC2635_L10, 186 + ID_LTC2635_H10, 187 + ID_LTC2635_L8, 188 + ID_LTC2635_H8, 171 189 }; 172 190 173 191 static int ad5064_write(struct ad5064_state *st, unsigned int cmd, ··· 443 425 static DECLARE_AD5064_CHANNELS(ltc2607_channels, 16, 0, ltc2617_ext_info); 444 426 static DECLARE_AD5064_CHANNELS(ltc2617_channels, 14, 2, ltc2617_ext_info); 445 427 static DECLARE_AD5064_CHANNELS(ltc2627_channels, 12, 4, ltc2617_ext_info); 428 + #define ltc2631_12_channels ltc2627_channels 429 + static DECLARE_AD5064_CHANNELS(ltc2631_10_channels, 10, 6, ltc2617_ext_info); 430 + static DECLARE_AD5064_CHANNELS(ltc2631_8_channels, 8, 8, ltc2617_ext_info); 431 + 432 + #define LTC2631_INFO(vref, pchannels, nchannels) \ 433 + { \ 434 + .shared_vref = true, \ 435 + .internal_vref = vref, \ 436 + .channels = pchannels, \ 437 + .num_channels = nchannels, \ 438 + .regmap_type = AD5064_REGMAP_LTC, \ 439 + } 440 + 446 441 447 442 static const struct ad5064_chip_info ad5064_chip_info_tbl[] = { 448 443 [ID_AD5024] = { ··· 755 724 .num_channels = 4, 756 725 .regmap_type = AD5064_REGMAP_LTC, 757 726 }, 727 + [ID_LTC2631_L12] = LTC2631_INFO(2500000, ltc2631_12_channels, 1), 728 + [ID_LTC2631_H12] = LTC2631_INFO(4096000, ltc2631_12_channels, 1), 729 + [ID_LTC2631_L10] = LTC2631_INFO(2500000, ltc2631_10_channels, 1), 730 + [ID_LTC2631_H10] = LTC2631_INFO(4096000, ltc2631_10_channels, 1), 731 + [ID_LTC2631_L8] = LTC2631_INFO(2500000, ltc2631_8_channels, 1), 732 + [ID_LTC2631_H8] = LTC2631_INFO(4096000, ltc2631_8_channels, 1), 733 + [ID_LTC2633_L12] = LTC2631_INFO(2500000, ltc2631_12_channels, 2), 734 + [ID_LTC2633_H12] = LTC2631_INFO(4096000, ltc2631_12_channels, 2), 735 + [ID_LTC2633_L10] = LTC2631_INFO(2500000, ltc2631_10_channels, 2), 736 + [ID_LTC2633_H10] = LTC2631_INFO(4096000, ltc2631_10_channels, 2), 737 + [ID_LTC2633_L8] = LTC2631_INFO(2500000, ltc2631_8_channels, 2), 738 + [ID_LTC2633_H8] = LTC2631_INFO(4096000, ltc2631_8_channels, 2), 739 + [ID_LTC2635_L12] = LTC2631_INFO(2500000, ltc2631_12_channels, 4), 740 + [ID_LTC2635_H12] = LTC2631_INFO(4096000, ltc2631_12_channels, 4), 741 + [ID_LTC2635_L10] = LTC2631_INFO(2500000, ltc2631_10_channels, 4), 742 + [ID_LTC2635_H10] = LTC2631_INFO(4096000, ltc2631_10_channels, 4), 743 + [ID_LTC2635_L8] = LTC2631_INFO(2500000, ltc2631_8_channels, 4), 744 + [ID_LTC2635_H8] = LTC2631_INFO(4096000, ltc2631_8_channels, 4), 758 745 }; 759 746 760 747 static inline unsigned int ad5064_num_vref(struct ad5064_state *st) ··· 1031 982 {"ltc2626", ID_LTC2626}, 1032 983 {"ltc2627", ID_LTC2627}, 1033 984 {"ltc2629", ID_LTC2629}, 985 + {"ltc2631-l12", ID_LTC2631_L12}, 986 + {"ltc2631-h12", ID_LTC2631_H12}, 987 + {"ltc2631-l10", ID_LTC2631_L10}, 988 + {"ltc2631-h10", ID_LTC2631_H10}, 989 + {"ltc2631-l8", ID_LTC2631_L8}, 990 + {"ltc2631-h8", ID_LTC2631_H8}, 991 + {"ltc2633-l12", ID_LTC2633_L12}, 992 + {"ltc2633-h12", ID_LTC2633_H12}, 993 + {"ltc2633-l10", ID_LTC2633_L10}, 994 + {"ltc2633-h10", ID_LTC2633_H10}, 995 + {"ltc2633-l8", ID_LTC2633_L8}, 996 + {"ltc2633-h8", ID_LTC2633_H8}, 997 + {"ltc2635-l12", ID_LTC2635_L12}, 998 + {"ltc2635-h12", ID_LTC2635_H12}, 999 + {"ltc2635-l10", ID_LTC2635_L10}, 1000 + {"ltc2635-h10", ID_LTC2635_H10}, 1001 + {"ltc2635-l8", ID_LTC2635_L8}, 1002 + {"ltc2635-h8", ID_LTC2635_H8}, 1034 1003 {} 1035 1004 }; 1036 1005 MODULE_DEVICE_TABLE(i2c, ad5064_i2c_ids);
+3
drivers/iio/humidity/hts221.h
··· 57 57 58 58 struct hts221_sensor sensors[HTS221_SENSOR_MAX]; 59 59 60 + bool enabled; 60 61 u8 odr; 61 62 62 63 const struct hts221_transfer_function *tf; 63 64 struct hts221_transfer_buffer tb; 64 65 }; 66 + 67 + extern const struct dev_pm_ops hts221_pm_ops; 65 68 66 69 int hts221_config_drdy(struct hts221_hw *hw, bool enable); 67 70 int hts221_probe(struct iio_dev *iio_dev);
+50 -4
drivers/iio/humidity/hts221_core.c
··· 13 13 #include <linux/device.h> 14 14 #include <linux/iio/sysfs.h> 15 15 #include <linux/delay.h> 16 + #include <linux/pm.h> 16 17 #include <asm/unaligned.h> 17 18 18 19 #include "hts221.h" ··· 308 307 309 308 int hts221_power_on(struct hts221_hw *hw) 310 309 { 311 - return hts221_update_odr(hw, hw->odr); 310 + int err; 311 + 312 + err = hts221_update_odr(hw, hw->odr); 313 + if (err < 0) 314 + return err; 315 + 316 + hw->enabled = true; 317 + 318 + return 0; 312 319 } 313 320 314 321 int hts221_power_off(struct hts221_hw *hw) 315 322 { 316 - u8 data[] = {0x00, 0x00}; 323 + __le16 data = 0; 324 + int err; 317 325 318 - return hw->tf->write(hw->dev, HTS221_REG_CNTRL1_ADDR, sizeof(data), 319 - data); 326 + err = hw->tf->write(hw->dev, HTS221_REG_CNTRL1_ADDR, sizeof(data), 327 + (u8 *)&data); 328 + if (err < 0) 329 + return err; 330 + 331 + hw->enabled = false; 332 + 333 + return 0; 320 334 } 321 335 322 336 static int hts221_parse_temp_caldata(struct hts221_hw *hw) ··· 697 681 return devm_iio_device_register(hw->dev, iio_dev); 698 682 } 699 683 EXPORT_SYMBOL(hts221_probe); 684 + 685 + static int __maybe_unused hts221_suspend(struct device *dev) 686 + { 687 + struct iio_dev *iio_dev = dev_get_drvdata(dev); 688 + struct hts221_hw *hw = iio_priv(iio_dev); 689 + __le16 data = 0; 690 + int err; 691 + 692 + err = hw->tf->write(hw->dev, HTS221_REG_CNTRL1_ADDR, sizeof(data), 693 + (u8 *)&data); 694 + 695 + return err < 0 ? err : 0; 696 + } 697 + 698 + static int __maybe_unused hts221_resume(struct device *dev) 699 + { 700 + struct iio_dev *iio_dev = dev_get_drvdata(dev); 701 + struct hts221_hw *hw = iio_priv(iio_dev); 702 + int err = 0; 703 + 704 + if (hw->enabled) 705 + err = hts221_update_odr(hw, hw->odr); 706 + 707 + return err; 708 + } 709 + 710 + const struct dev_pm_ops hts221_pm_ops = { 711 + SET_SYSTEM_SLEEP_PM_OPS(hts221_suspend, hts221_resume) 712 + }; 713 + EXPORT_SYMBOL(hts221_pm_ops); 700 714 701 715 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>"); 702 716 MODULE_DESCRIPTION("STMicroelectronics hts221 sensor driver");
+1
drivers/iio/humidity/hts221_i2c.c
··· 105 105 static struct i2c_driver hts221_driver = { 106 106 .driver = { 107 107 .name = "hts221_i2c", 108 + .pm = &hts221_pm_ops, 108 109 .of_match_table = of_match_ptr(hts221_i2c_of_match), 109 110 .acpi_match_table = ACPI_PTR(hts221_acpi_match), 110 111 },
+1
drivers/iio/humidity/hts221_spi.c
··· 113 113 static struct spi_driver hts221_driver = { 114 114 .driver = { 115 115 .name = "hts221_spi", 116 + .pm = &hts221_pm_ops, 116 117 .of_match_table = of_match_ptr(hts221_spi_of_match), 117 118 }, 118 119 .probe = hts221_spi_probe,
+5
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
··· 135 135 #endif /* CONFIG_SPI_MASTER */ 136 136 }; 137 137 138 + extern const struct dev_pm_ops st_lsm6dsx_pm_ops; 139 + 138 140 int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, 139 141 const struct st_lsm6dsx_transfer_function *tf_ops); 140 142 int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor); ··· 146 144 u8 val); 147 145 int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, 148 146 u16 watermark); 147 + int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw); 148 + int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, 149 + enum st_lsm6dsx_fifo_mode fifo_mode); 149 150 150 151 #endif /* ST_LSM6DSX_H */
+3 -3
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
··· 130 130 return 0; 131 131 } 132 132 133 - static int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, 134 - enum st_lsm6dsx_fifo_mode fifo_mode) 133 + int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, 134 + enum st_lsm6dsx_fifo_mode fifo_mode) 135 135 { 136 136 u8 data; 137 137 int err; ··· 303 303 return read_len; 304 304 } 305 305 306 - static int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw) 306 + int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw) 307 307 { 308 308 int err; 309 309
+52
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
··· 36 36 #include <linux/delay.h> 37 37 #include <linux/iio/iio.h> 38 38 #include <linux/iio/sysfs.h> 39 + #include <linux/pm.h> 39 40 40 41 #include <linux/platform_data/st_sensors_pdata.h> 41 42 ··· 731 730 return 0; 732 731 } 733 732 EXPORT_SYMBOL(st_lsm6dsx_probe); 733 + 734 + static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) 735 + { 736 + struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); 737 + struct st_lsm6dsx_sensor *sensor; 738 + int i, err = 0; 739 + 740 + for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { 741 + sensor = iio_priv(hw->iio_devs[i]); 742 + if (!(hw->enable_mask & BIT(sensor->id))) 743 + continue; 744 + 745 + err = st_lsm6dsx_write_with_mask(hw, 746 + st_lsm6dsx_odr_table[sensor->id].reg.addr, 747 + st_lsm6dsx_odr_table[sensor->id].reg.mask, 0); 748 + if (err < 0) 749 + return err; 750 + } 751 + 752 + if (hw->fifo_mode != ST_LSM6DSX_FIFO_BYPASS) 753 + err = st_lsm6dsx_flush_fifo(hw); 754 + 755 + return err; 756 + } 757 + 758 + static int __maybe_unused st_lsm6dsx_resume(struct device *dev) 759 + { 760 + struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); 761 + struct st_lsm6dsx_sensor *sensor; 762 + int i, err = 0; 763 + 764 + for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { 765 + sensor = iio_priv(hw->iio_devs[i]); 766 + if (!(hw->enable_mask & BIT(sensor->id))) 767 + continue; 768 + 769 + err = st_lsm6dsx_set_odr(sensor, sensor->odr); 770 + if (err < 0) 771 + return err; 772 + } 773 + 774 + if (hw->enable_mask) 775 + err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT); 776 + 777 + return err; 778 + } 779 + 780 + const struct dev_pm_ops st_lsm6dsx_pm_ops = { 781 + SET_SYSTEM_SLEEP_PM_OPS(st_lsm6dsx_suspend, st_lsm6dsx_resume) 782 + }; 783 + EXPORT_SYMBOL(st_lsm6dsx_pm_ops); 734 784 735 785 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>"); 736 786 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
+1
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
··· 98 98 static struct i2c_driver st_lsm6dsx_driver = { 99 99 .driver = { 100 100 .name = "st_lsm6dsx_i2c", 101 + .pm = &st_lsm6dsx_pm_ops, 101 102 .of_match_table = of_match_ptr(st_lsm6dsx_i2c_of_match), 102 103 }, 103 104 .probe = st_lsm6dsx_i2c_probe,
+1
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
··· 115 115 static struct spi_driver st_lsm6dsx_driver = { 116 116 .driver = { 117 117 .name = "st_lsm6dsx_spi", 118 + .pm = &st_lsm6dsx_pm_ops, 118 119 .of_match_table = of_match_ptr(st_lsm6dsx_spi_of_match), 119 120 }, 120 121 .probe = st_lsm6dsx_spi_probe,
+2 -2
drivers/iio/industrialio-core.c
··· 1089 1089 { 1090 1090 int i, ret, attrcount = 0; 1091 1091 1092 - for_each_set_bit(i, infomask, sizeof(infomask)*8) { 1092 + for_each_set_bit(i, infomask, sizeof(*infomask)*8) { 1093 1093 if (i >= ARRAY_SIZE(iio_chan_info_postfix)) 1094 1094 return -EINVAL; 1095 1095 ret = __iio_add_chan_devattr(iio_chan_info_postfix[i], ··· 1118 1118 int i, ret, attrcount = 0; 1119 1119 char *avail_postfix; 1120 1120 1121 - for_each_set_bit(i, infomask, sizeof(infomask) * 8) { 1121 + for_each_set_bit(i, infomask, sizeof(*infomask) * 8) { 1122 1122 avail_postfix = kasprintf(GFP_KERNEL, 1123 1123 "%s_available", 1124 1124 iio_chan_info_postfix[i]);
+1 -3
drivers/iio/inkern.c
··· 750 750 err_unlock: 751 751 mutex_unlock(&chan->indio_dev->info_exist_lock); 752 752 753 - if (ret >= 0 && type != IIO_VAL_INT) { 753 + if (ret >= 0 && type != IIO_VAL_INT) 754 754 /* raw values are assumed to be IIO_VAL_INT */ 755 755 ret = -EINVAL; 756 - goto err_unlock; 757 - } 758 756 759 757 return ret; 760 758 }
+10
drivers/iio/light/Kconfig
··· 172 172 in lux, proximity infrared sensing and normal infrared sensing. 173 173 Data from sensor is accessible via sysfs. 174 174 175 + config SENSORS_ISL29028 176 + tristate "Intersil ISL29028 Concurrent Light and Proximity Sensor" 177 + depends on I2C 178 + select REGMAP_I2C 179 + help 180 + Provides driver for the Intersil's ISL29028 device. 181 + This driver supports the sysfs interface to get the ALS, IR intensity, 182 + Proximity value via iio. The ISL29028 provides the concurrent sensing 183 + of ambient light and proximity. 184 + 175 185 config ISL29125 176 186 tristate "Intersil ISL29125 digital color light sensor" 177 187 depends on I2C
+1
drivers/iio/light/Makefile
··· 20 20 obj-$(CONFIG_HID_SENSOR_ALS) += hid-sensor-als.o 21 21 obj-$(CONFIG_HID_SENSOR_PROX) += hid-sensor-prox.o 22 22 obj-$(CONFIG_SENSORS_ISL29018) += isl29018.o 23 + obj-$(CONFIG_SENSORS_ISL29028) += isl29028.o 23 24 obj-$(CONFIG_ISL29125) += isl29125.o 24 25 obj-$(CONFIG_JSA1212) += jsa1212.o 25 26 obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o
+2
drivers/iio/light/isl29018.c
··· 807 807 #define ISL29018_PM_OPS NULL 808 808 #endif 809 809 810 + #ifdef CONFIG_ACPI 810 811 static const struct acpi_device_id isl29018_acpi_match[] = { 811 812 {"ISL29018", isl29018}, 812 813 {"ISL29023", isl29023}, ··· 815 814 {}, 816 815 }; 817 816 MODULE_DEVICE_TABLE(acpi, isl29018_acpi_match); 817 + #endif 818 818 819 819 static const struct i2c_device_id isl29018_id[] = { 820 820 {"isl29018", isl29018},
+260 -47
drivers/iio/light/rpr0521.c
··· 9 9 * 10 10 * IIO driver for RPR-0521RS (7-bit I2C slave address 0x38). 11 11 * 12 - * TODO: illuminance channel, PM support, buffer 12 + * TODO: illuminance channel, buffer 13 13 */ 14 14 15 15 #include <linux/module.h> ··· 30 30 #define RPR0521_REG_PXS_DATA 0x44 /* 16-bit, little endian */ 31 31 #define RPR0521_REG_ALS_DATA0 0x46 /* 16-bit, little endian */ 32 32 #define RPR0521_REG_ALS_DATA1 0x48 /* 16-bit, little endian */ 33 + #define RPR0521_REG_PS_OFFSET_LSB 0x53 33 34 #define RPR0521_REG_ID 0x92 34 35 35 36 #define RPR0521_MODE_ALS_MASK BIT(7) ··· 78 77 }; 79 78 80 79 enum rpr0521_channel { 80 + RPR0521_CHAN_PXS, 81 81 RPR0521_CHAN_ALS_DATA0, 82 82 RPR0521_CHAN_ALS_DATA1, 83 - RPR0521_CHAN_PXS, 84 83 }; 85 84 86 85 struct rpr0521_reg_desc { ··· 89 88 }; 90 89 91 90 static const struct rpr0521_reg_desc rpr0521_data_reg[] = { 91 + [RPR0521_CHAN_PXS] = { 92 + .address = RPR0521_REG_PXS_DATA, 93 + .device_mask = RPR0521_MODE_PXS_MASK, 94 + }, 92 95 [RPR0521_CHAN_ALS_DATA0] = { 93 96 .address = RPR0521_REG_ALS_DATA0, 94 97 .device_mask = RPR0521_MODE_ALS_MASK, ··· 100 95 [RPR0521_CHAN_ALS_DATA1] = { 101 96 .address = RPR0521_REG_ALS_DATA1, 102 97 .device_mask = RPR0521_MODE_ALS_MASK, 103 - }, 104 - [RPR0521_CHAN_PXS] = { 105 - .address = RPR0521_REG_PXS_DATA, 106 - .device_mask = RPR0521_MODE_PXS_MASK, 107 98 }, 108 99 }; 109 100 ··· 110 109 const struct rpr0521_gain *gain; 111 110 int size; 112 111 } rpr0521_gain[] = { 112 + [RPR0521_CHAN_PXS] = { 113 + .reg = RPR0521_REG_PXS_CTRL, 114 + .mask = RPR0521_PXS_GAIN_MASK, 115 + .shift = RPR0521_PXS_GAIN_SHIFT, 116 + .gain = rpr0521_pxs_gain, 117 + .size = ARRAY_SIZE(rpr0521_pxs_gain), 118 + }, 113 119 [RPR0521_CHAN_ALS_DATA0] = { 114 120 .reg = RPR0521_REG_ALS_CTRL, 115 121 .mask = RPR0521_ALS_DATA0_GAIN_MASK, ··· 131 123 .gain = rpr0521_als_gain, 132 124 .size = ARRAY_SIZE(rpr0521_als_gain), 133 125 }, 134 - [RPR0521_CHAN_PXS] = { 135 - .reg = RPR0521_REG_PXS_CTRL, 136 - .mask = RPR0521_PXS_GAIN_MASK, 137 - .shift = RPR0521_PXS_GAIN_SHIFT, 138 - .gain = rpr0521_pxs_gain, 139 - .size = ARRAY_SIZE(rpr0521_pxs_gain), 140 - }, 126 + }; 127 + 128 + struct rpr0521_samp_freq { 129 + int als_hz; 130 + int als_uhz; 131 + int pxs_hz; 132 + int pxs_uhz; 133 + }; 134 + 135 + static const struct rpr0521_samp_freq rpr0521_samp_freq_i[13] = { 136 + /* {ALS, PXS}, W==currently writable option */ 137 + {0, 0, 0, 0}, /* W0000, 0=standby */ 138 + {0, 0, 100, 0}, /* 0001 */ 139 + {0, 0, 25, 0}, /* 0010 */ 140 + {0, 0, 10, 0}, /* 0011 */ 141 + {0, 0, 2, 500000}, /* 0100 */ 142 + {10, 0, 20, 0}, /* 0101 */ 143 + {10, 0, 10, 0}, /* W0110 */ 144 + {10, 0, 2, 500000}, /* 0111 */ 145 + {2, 500000, 20, 0}, /* 1000, measurement 100ms, sleep 300ms */ 146 + {2, 500000, 10, 0}, /* 1001, measurement 100ms, sleep 300ms */ 147 + {2, 500000, 0, 0}, /* 1010, high sensitivity mode */ 148 + {2, 500000, 2, 500000}, /* W1011, high sensitivity mode */ 149 + {20, 0, 20, 0} /* 1100, ALS_data x 0.5, see specification P.18 */ 141 150 }; 142 151 143 152 struct rpr0521_data { ··· 167 142 bool als_dev_en; 168 143 bool pxs_dev_en; 169 144 170 - /* optimize runtime pm ops - enable device only if needed */ 145 + /* optimize runtime pm ops - enable/disable device only if needed */ 171 146 bool als_ps_need_en; 172 147 bool pxs_ps_need_en; 148 + bool als_need_dis; 149 + bool pxs_need_dis; 173 150 174 151 struct regmap *regmap; 175 152 }; ··· 179 152 static IIO_CONST_ATTR(in_intensity_scale_available, RPR0521_ALS_SCALE_AVAIL); 180 153 static IIO_CONST_ATTR(in_proximity_scale_available, RPR0521_PXS_SCALE_AVAIL); 181 154 155 + /* 156 + * Start with easy freq first, whole table of freq combinations is more 157 + * complicated. 158 + */ 159 + static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("2.5 10"); 160 + 182 161 static struct attribute *rpr0521_attributes[] = { 183 162 &iio_const_attr_in_intensity_scale_available.dev_attr.attr, 184 163 &iio_const_attr_in_proximity_scale_available.dev_attr.attr, 164 + &iio_const_attr_sampling_frequency_available.dev_attr.attr, 185 165 NULL, 186 166 }; 187 167 ··· 198 164 199 165 static const struct iio_chan_spec rpr0521_channels[] = { 200 166 { 167 + .type = IIO_PROXIMITY, 168 + .address = RPR0521_CHAN_PXS, 169 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | 170 + BIT(IIO_CHAN_INFO_OFFSET) | 171 + BIT(IIO_CHAN_INFO_SCALE), 172 + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), 173 + }, 174 + { 201 175 .type = IIO_INTENSITY, 202 176 .modified = 1, 203 177 .address = RPR0521_CHAN_ALS_DATA0, 204 178 .channel2 = IIO_MOD_LIGHT_BOTH, 205 179 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | 206 180 BIT(IIO_CHAN_INFO_SCALE), 181 + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), 207 182 }, 208 183 { 209 184 .type = IIO_INTENSITY, ··· 221 178 .channel2 = IIO_MOD_LIGHT_IR, 222 179 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | 223 180 BIT(IIO_CHAN_INFO_SCALE), 181 + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), 224 182 }, 225 - { 226 - .type = IIO_PROXIMITY, 227 - .address = RPR0521_CHAN_PXS, 228 - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | 229 - BIT(IIO_CHAN_INFO_SCALE), 230 - } 231 183 }; 232 184 233 185 static int rpr0521_als_enable(struct rpr0521_data *data, u8 status) ··· 235 197 if (ret < 0) 236 198 return ret; 237 199 238 - data->als_dev_en = true; 200 + if (status & RPR0521_MODE_ALS_MASK) 201 + data->als_dev_en = true; 202 + else 203 + data->als_dev_en = false; 239 204 240 205 return 0; 241 206 } ··· 253 212 if (ret < 0) 254 213 return ret; 255 214 256 - data->pxs_dev_en = true; 215 + if (status & RPR0521_MODE_PXS_MASK) 216 + data->pxs_dev_en = true; 217 + else 218 + data->pxs_dev_en = false; 257 219 258 220 return 0; 259 221 } ··· 268 224 * @on: state to be set for devices in @device_mask 269 225 * @device_mask: bitmask specifying for which device we need to update @on state 270 226 * 271 - * We rely on rpr0521_runtime_resume to enable our @device_mask devices, but 272 - * if (for example) PXS was enabled (pxs_dev_en = true) by a previous call to 273 - * rpr0521_runtime_resume and we want to enable ALS we MUST set ALS enable 274 - * bit of RPR0521_REG_MODE_CTRL here because rpr0521_runtime_resume will not 275 - * be called twice. 227 + * Calls for this function must be balanced so that each ON should have matching 228 + * OFF. Otherwise pm usage_count gets out of sync. 276 229 */ 277 230 static int rpr0521_set_power_state(struct rpr0521_data *data, bool on, 278 231 u8 device_mask) 279 232 { 280 233 #ifdef CONFIG_PM 281 234 int ret; 282 - u8 update_mask = 0; 283 235 284 236 if (device_mask & RPR0521_MODE_ALS_MASK) { 285 - if (on && !data->als_ps_need_en && data->pxs_dev_en) 286 - update_mask |= RPR0521_MODE_ALS_MASK; 287 - else 288 - data->als_ps_need_en = on; 237 + data->als_ps_need_en = on; 238 + data->als_need_dis = !on; 289 239 } 290 240 291 241 if (device_mask & RPR0521_MODE_PXS_MASK) { 292 - if (on && !data->pxs_ps_need_en && data->als_dev_en) 293 - update_mask |= RPR0521_MODE_PXS_MASK; 294 - else 295 - data->pxs_ps_need_en = on; 242 + data->pxs_ps_need_en = on; 243 + data->pxs_need_dis = !on; 296 244 } 297 245 298 - if (update_mask) { 299 - ret = regmap_update_bits(data->regmap, RPR0521_REG_MODE_CTRL, 300 - update_mask, update_mask); 301 - if (ret < 0) 302 - return ret; 303 - } 304 - 246 + /* 247 + * On: _resume() is called only when we are suspended 248 + * Off: _suspend() is called after delay if _resume() is not 249 + * called before that. 250 + * Note: If either measurement is re-enabled before _suspend(), 251 + * both stay enabled until _suspend(). 252 + */ 305 253 if (on) { 306 254 ret = pm_runtime_get_sync(&data->client->dev); 307 255 } else { ··· 308 272 pm_runtime_put_noidle(&data->client->dev); 309 273 310 274 return ret; 275 + } 276 + 277 + if (on) { 278 + /* If _resume() was not called, enable measurement now. */ 279 + if (data->als_ps_need_en) { 280 + ret = rpr0521_als_enable(data, RPR0521_MODE_ALS_ENABLE); 281 + if (ret) 282 + return ret; 283 + data->als_ps_need_en = false; 284 + } 285 + 286 + if (data->pxs_ps_need_en) { 287 + ret = rpr0521_pxs_enable(data, RPR0521_MODE_PXS_ENABLE); 288 + if (ret) 289 + return ret; 290 + data->pxs_ps_need_en = false; 291 + } 311 292 } 312 293 #endif 313 294 return 0; ··· 367 314 idx << rpr0521_gain[chan].shift); 368 315 } 369 316 317 + static int rpr0521_read_samp_freq(struct rpr0521_data *data, 318 + enum iio_chan_type chan_type, 319 + int *val, int *val2) 320 + { 321 + int reg, ret; 322 + 323 + ret = regmap_read(data->regmap, RPR0521_REG_MODE_CTRL, &reg); 324 + if (ret < 0) 325 + return ret; 326 + 327 + reg &= RPR0521_MODE_MEAS_TIME_MASK; 328 + if (reg >= ARRAY_SIZE(rpr0521_samp_freq_i)) 329 + return -EINVAL; 330 + 331 + switch (chan_type) { 332 + case IIO_INTENSITY: 333 + *val = rpr0521_samp_freq_i[reg].als_hz; 334 + *val2 = rpr0521_samp_freq_i[reg].als_uhz; 335 + return 0; 336 + 337 + case IIO_PROXIMITY: 338 + *val = rpr0521_samp_freq_i[reg].pxs_hz; 339 + *val2 = rpr0521_samp_freq_i[reg].pxs_uhz; 340 + return 0; 341 + 342 + default: 343 + return -EINVAL; 344 + } 345 + } 346 + 347 + static int rpr0521_write_samp_freq_common(struct rpr0521_data *data, 348 + enum iio_chan_type chan_type, 349 + int val, int val2) 350 + { 351 + int i; 352 + 353 + /* 354 + * Ignore channel 355 + * both pxs and als are setup only to same freq because of simplicity 356 + */ 357 + switch (val) { 358 + case 0: 359 + i = 0; 360 + break; 361 + 362 + case 2: 363 + if (val2 != 500000) 364 + return -EINVAL; 365 + 366 + i = 11; 367 + break; 368 + 369 + case 10: 370 + i = 6; 371 + break; 372 + 373 + default: 374 + return -EINVAL; 375 + } 376 + 377 + return regmap_update_bits(data->regmap, 378 + RPR0521_REG_MODE_CTRL, 379 + RPR0521_MODE_MEAS_TIME_MASK, 380 + i); 381 + } 382 + 383 + static int rpr0521_read_ps_offset(struct rpr0521_data *data, int *offset) 384 + { 385 + int ret; 386 + __le16 buffer; 387 + 388 + ret = regmap_bulk_read(data->regmap, 389 + RPR0521_REG_PS_OFFSET_LSB, &buffer, sizeof(buffer)); 390 + 391 + if (ret < 0) { 392 + dev_err(&data->client->dev, "Failed to read PS OFFSET register\n"); 393 + return ret; 394 + } 395 + *offset = le16_to_cpu(buffer); 396 + 397 + return ret; 398 + } 399 + 400 + static int rpr0521_write_ps_offset(struct rpr0521_data *data, int offset) 401 + { 402 + int ret; 403 + __le16 buffer; 404 + 405 + buffer = cpu_to_le16(offset & 0x3ff); 406 + ret = regmap_raw_write(data->regmap, 407 + RPR0521_REG_PS_OFFSET_LSB, &buffer, sizeof(buffer)); 408 + 409 + if (ret < 0) { 410 + dev_err(&data->client->dev, "Failed to write PS OFFSET register\n"); 411 + return ret; 412 + } 413 + 414 + return ret; 415 + } 416 + 370 417 static int rpr0521_read_raw(struct iio_dev *indio_dev, 371 418 struct iio_chan_spec const *chan, int *val, 372 419 int *val2, long mask) ··· 492 339 493 340 ret = regmap_bulk_read(data->regmap, 494 341 rpr0521_data_reg[chan->address].address, 495 - &raw_data, 2); 342 + &raw_data, sizeof(raw_data)); 496 343 if (ret < 0) { 497 344 rpr0521_set_power_state(data, false, device_mask); 498 345 mutex_unlock(&data->lock); ··· 507 354 *val = le16_to_cpu(raw_data); 508 355 509 356 return IIO_VAL_INT; 357 + 510 358 case IIO_CHAN_INFO_SCALE: 511 359 mutex_lock(&data->lock); 512 360 ret = rpr0521_get_gain(data, chan->address, val, val2); ··· 516 362 return ret; 517 363 518 364 return IIO_VAL_INT_PLUS_MICRO; 365 + 366 + case IIO_CHAN_INFO_SAMP_FREQ: 367 + mutex_lock(&data->lock); 368 + ret = rpr0521_read_samp_freq(data, chan->type, val, val2); 369 + mutex_unlock(&data->lock); 370 + if (ret < 0) 371 + return ret; 372 + 373 + return IIO_VAL_INT_PLUS_MICRO; 374 + 375 + case IIO_CHAN_INFO_OFFSET: 376 + mutex_lock(&data->lock); 377 + ret = rpr0521_read_ps_offset(data, val); 378 + mutex_unlock(&data->lock); 379 + if (ret < 0) 380 + return ret; 381 + 382 + return IIO_VAL_INT; 383 + 519 384 default: 520 385 return -EINVAL; 521 386 } ··· 554 381 mutex_unlock(&data->lock); 555 382 556 383 return ret; 384 + 385 + case IIO_CHAN_INFO_SAMP_FREQ: 386 + mutex_lock(&data->lock); 387 + ret = rpr0521_write_samp_freq_common(data, chan->type, 388 + val, val2); 389 + mutex_unlock(&data->lock); 390 + 391 + return ret; 392 + 393 + case IIO_CHAN_INFO_OFFSET: 394 + mutex_lock(&data->lock); 395 + ret = rpr0521_write_ps_offset(data, val); 396 + mutex_unlock(&data->lock); 397 + 398 + return ret; 399 + 557 400 default: 558 401 return -EINVAL; 559 402 } ··· 608 419 return ret; 609 420 } 610 421 422 + #ifndef CONFIG_PM 611 423 ret = rpr0521_als_enable(data, RPR0521_MODE_ALS_ENABLE); 612 424 if (ret < 0) 613 425 return ret; 614 426 ret = rpr0521_pxs_enable(data, RPR0521_MODE_PXS_ENABLE); 615 427 if (ret < 0) 616 428 return ret; 429 + #endif 617 430 618 431 return 0; 619 432 } ··· 701 510 702 511 ret = pm_runtime_set_active(&client->dev); 703 512 if (ret < 0) 704 - return ret; 513 + goto err_poweroff; 705 514 706 515 pm_runtime_enable(&client->dev); 707 516 pm_runtime_set_autosuspend_delay(&client->dev, RPR0521_SLEEP_DELAY_MS); 708 517 pm_runtime_use_autosuspend(&client->dev); 709 518 710 - return iio_device_register(indio_dev); 519 + ret = iio_device_register(indio_dev); 520 + if (ret) 521 + goto err_pm_disable; 522 + 523 + return 0; 524 + 525 + err_pm_disable: 526 + pm_runtime_disable(&client->dev); 527 + pm_runtime_set_suspended(&client->dev); 528 + pm_runtime_put_noidle(&client->dev); 529 + err_poweroff: 530 + rpr0521_poweroff(data); 531 + 532 + return ret; 711 533 } 712 534 713 535 static int rpr0521_remove(struct i2c_client *client) ··· 745 541 struct rpr0521_data *data = iio_priv(indio_dev); 746 542 int ret; 747 543 748 - /* disable channels and sets {als,pxs}_dev_en to false */ 749 544 mutex_lock(&data->lock); 545 + /* If measurements are enabled, enable them on resume */ 546 + if (!data->als_need_dis) 547 + data->als_ps_need_en = data->als_dev_en; 548 + if (!data->pxs_need_dis) 549 + data->pxs_ps_need_en = data->pxs_dev_en; 550 + 551 + /* disable channels and sets {als,pxs}_dev_en to false */ 750 552 ret = rpr0521_poweroff(data); 553 + regcache_mark_dirty(data->regmap); 751 554 mutex_unlock(&data->lock); 752 555 753 556 return ret; ··· 766 555 struct rpr0521_data *data = iio_priv(indio_dev); 767 556 int ret; 768 557 558 + regcache_sync(data->regmap); 769 559 if (data->als_ps_need_en) { 770 560 ret = rpr0521_als_enable(data, RPR0521_MODE_ALS_ENABLE); 771 561 if (ret < 0) ··· 780 568 return ret; 781 569 data->pxs_ps_need_en = false; 782 570 } 571 + msleep(100); //wait for first measurement result 783 572 784 573 return 0; 785 574 }
+76 -30
drivers/iio/light/tsl2583.c
··· 3 3 * within the TAOS tsl258x family of devices (tsl2580, tsl2581, tsl2583). 4 4 * 5 5 * Copyright (c) 2011, TAOS Corporation. 6 - * Copyright (c) 2016 Brian Masney <masneyb@onstation.org> 6 + * Copyright (c) 2016-2017 Brian Masney <masneyb@onstation.org> 7 7 * 8 8 * This program is free software; you can redistribute it and/or modify 9 9 * it under the terms of the GNU General Public License as published by ··· 27 27 #include <linux/module.h> 28 28 #include <linux/iio/iio.h> 29 29 #include <linux/iio/sysfs.h> 30 + #include <linux/pm_runtime.h> 30 31 31 32 /* Device Registers and Masks */ 32 33 #define TSL2583_CNTRL 0x00 ··· 64 63 65 64 #define TSL2583_CHIP_ID 0x90 66 65 #define TSL2583_CHIP_ID_MASK 0xf0 66 + 67 + #define TSL2583_POWER_OFF_DELAY_MS 2000 67 68 68 69 /* Per-device data */ 69 70 struct tsl2583_als_info { ··· 111 108 struct tsl2583_settings als_settings; 112 109 int als_time_scale; 113 110 int als_saturation; 114 - bool suspended; 115 111 }; 116 112 117 113 struct gainadj { ··· 462 460 if (ret < 0) 463 461 return ret; 464 462 465 - chip->suspended = false; 466 - 467 463 return ret; 468 464 } 469 465 ··· 512 512 return -EINVAL; 513 513 514 514 mutex_lock(&chip->als_mutex); 515 - 516 - if (chip->suspended) { 517 - ret = -EBUSY; 518 - goto done; 519 - } 520 515 521 516 ret = tsl2583_als_calibrate(indio_dev); 522 517 if (ret < 0) ··· 640 645 }, 641 646 }; 642 647 648 + static int tsl2583_set_pm_runtime_busy(struct tsl2583_chip *chip, bool on) 649 + { 650 + int ret; 651 + 652 + if (on) { 653 + ret = pm_runtime_get_sync(&chip->client->dev); 654 + if (ret < 0) 655 + pm_runtime_put_noidle(&chip->client->dev); 656 + } else { 657 + pm_runtime_mark_last_busy(&chip->client->dev); 658 + ret = pm_runtime_put_autosuspend(&chip->client->dev); 659 + } 660 + 661 + return ret; 662 + } 663 + 643 664 static int tsl2583_read_raw(struct iio_dev *indio_dev, 644 665 struct iio_chan_spec const *chan, 645 666 int *val, int *val2, long mask) 646 667 { 647 668 struct tsl2583_chip *chip = iio_priv(indio_dev); 648 - int ret = -EINVAL; 669 + int ret, pm_ret; 670 + 671 + ret = tsl2583_set_pm_runtime_busy(chip, true); 672 + if (ret < 0) 673 + return ret; 649 674 650 675 mutex_lock(&chip->als_mutex); 651 676 652 - if (chip->suspended) { 653 - ret = -EBUSY; 654 - goto read_done; 655 - } 656 - 677 + ret = -EINVAL; 657 678 switch (mask) { 658 679 case IIO_CHAN_INFO_RAW: 659 680 if (chan->type == IIO_LIGHT) { ··· 730 719 read_done: 731 720 mutex_unlock(&chip->als_mutex); 732 721 722 + if (ret < 0) 723 + return ret; 724 + 725 + /* 726 + * Preserve the ret variable if the call to 727 + * tsl2583_set_pm_runtime_busy() is successful so the reading 728 + * (if applicable) is returned to user space. 729 + */ 730 + pm_ret = tsl2583_set_pm_runtime_busy(chip, false); 731 + if (pm_ret < 0) 732 + return pm_ret; 733 + 733 734 return ret; 734 735 } 735 736 ··· 750 727 int val, int val2, long mask) 751 728 { 752 729 struct tsl2583_chip *chip = iio_priv(indio_dev); 753 - int ret = -EINVAL; 730 + int ret; 731 + 732 + ret = tsl2583_set_pm_runtime_busy(chip, true); 733 + if (ret < 0) 734 + return ret; 754 735 755 736 mutex_lock(&chip->als_mutex); 756 737 757 - if (chip->suspended) { 758 - ret = -EBUSY; 759 - goto write_done; 760 - } 761 - 738 + ret = -EINVAL; 762 739 switch (mask) { 763 740 case IIO_CHAN_INFO_CALIBBIAS: 764 741 if (chan->type == IIO_LIGHT) { ··· 790 767 break; 791 768 } 792 769 793 - write_done: 794 770 mutex_unlock(&chip->als_mutex); 771 + 772 + if (ret < 0) 773 + return ret; 774 + 775 + ret = tsl2583_set_pm_runtime_busy(chip, false); 776 + if (ret < 0) 777 + return ret; 795 778 796 779 return ret; 797 780 } ··· 832 803 i2c_set_clientdata(clientp, indio_dev); 833 804 834 805 mutex_init(&chip->als_mutex); 835 - chip->suspended = true; 836 806 837 807 ret = i2c_smbus_read_byte_data(clientp, 838 808 TSL2583_CMD_REG | TSL2583_CHIPID); ··· 854 826 indio_dev->modes = INDIO_DIRECT_MODE; 855 827 indio_dev->name = chip->client->name; 856 828 829 + pm_runtime_enable(&clientp->dev); 830 + pm_runtime_set_autosuspend_delay(&clientp->dev, 831 + TSL2583_POWER_OFF_DELAY_MS); 832 + pm_runtime_use_autosuspend(&clientp->dev); 833 + 857 834 ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); 858 835 if (ret) { 859 836 dev_err(&clientp->dev, "%s: iio registration failed\n", ··· 869 836 /* Load up the V2 defaults (these are hard coded defaults for now) */ 870 837 tsl2583_defaults(chip); 871 838 872 - /* Make sure the chip is on */ 873 - ret = tsl2583_chip_init_and_power_on(indio_dev); 874 - if (ret < 0) 875 - return ret; 876 - 877 839 dev_info(&clientp->dev, "Light sensor found.\n"); 878 840 879 841 return 0; 842 + } 843 + 844 + static int tsl2583_remove(struct i2c_client *client) 845 + { 846 + struct iio_dev *indio_dev = i2c_get_clientdata(client); 847 + struct tsl2583_chip *chip = iio_priv(indio_dev); 848 + 849 + iio_device_unregister(indio_dev); 850 + 851 + pm_runtime_disable(&client->dev); 852 + pm_runtime_set_suspended(&client->dev); 853 + pm_runtime_put_noidle(&client->dev); 854 + 855 + return tsl2583_set_power_state(chip, TSL2583_CNTL_PWR_OFF); 880 856 } 881 857 882 858 static int __maybe_unused tsl2583_suspend(struct device *dev) ··· 897 855 mutex_lock(&chip->als_mutex); 898 856 899 857 ret = tsl2583_set_power_state(chip, TSL2583_CNTL_PWR_OFF); 900 - chip->suspended = true; 901 858 902 859 mutex_unlock(&chip->als_mutex); 903 860 ··· 918 877 return ret; 919 878 } 920 879 921 - static SIMPLE_DEV_PM_OPS(tsl2583_pm_ops, tsl2583_suspend, tsl2583_resume); 880 + static const struct dev_pm_ops tsl2583_pm_ops = { 881 + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 882 + pm_runtime_force_resume) 883 + SET_RUNTIME_PM_OPS(tsl2583_suspend, tsl2583_resume, NULL) 884 + }; 922 885 923 886 static struct i2c_device_id tsl2583_idtable[] = { 924 887 { "tsl2580", 0 }, ··· 949 904 }, 950 905 .id_table = tsl2583_idtable, 951 906 .probe = tsl2583_probe, 907 + .remove = tsl2583_remove, 952 908 }; 953 909 module_i2c_driver(tsl2583_driver); 954 910
+47 -8
drivers/iio/orientation/hid-sensor-rotation.c
··· 31 31 struct hid_sensor_common common_attributes; 32 32 struct hid_sensor_hub_attribute_info quaternion; 33 33 u32 sampled_vals[4]; 34 + int scale_pre_decml; 35 + int scale_post_decml; 36 + int scale_precision; 37 + int value_offset; 34 38 }; 35 39 36 40 /* Channel definitions */ ··· 45 41 .channel2 = IIO_MOD_QUATERNION, 46 42 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 47 43 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | 44 + BIT(IIO_CHAN_INFO_OFFSET) | 45 + BIT(IIO_CHAN_INFO_SCALE) | 48 46 BIT(IIO_CHAN_INFO_HYSTERESIS) 49 47 } 50 48 }; ··· 86 80 } else 87 81 ret_type = -EINVAL; 88 82 break; 83 + case IIO_CHAN_INFO_SCALE: 84 + vals[0] = rot_state->scale_pre_decml; 85 + vals[1] = rot_state->scale_post_decml; 86 + return rot_state->scale_precision; 87 + 88 + case IIO_CHAN_INFO_OFFSET: 89 + *vals = rot_state->value_offset; 90 + return IIO_VAL_INT; 91 + 89 92 case IIO_CHAN_INFO_SAMP_FREQ: 90 93 ret_type = hid_sensor_read_samp_freq_value( 91 94 &rot_state->common_attributes, &vals[0], &vals[1]); ··· 214 199 dev_dbg(&pdev->dev, "dev_rot: attrib size %d\n", 215 200 st->quaternion.size); 216 201 202 + st->scale_precision = hid_sensor_format_scale( 203 + hsdev->usage, 204 + &st->quaternion, 205 + &st->scale_pre_decml, &st->scale_post_decml); 206 + 217 207 /* Set Sensitivity field ids, when there is no individual modifier */ 218 208 if (st->common_attributes.sensitivity.index < 0) { 219 209 sensor_hub_input_get_attribute_info(hsdev, ··· 238 218 static int hid_dev_rot_probe(struct platform_device *pdev) 239 219 { 240 220 int ret; 241 - static char *name = "dev_rotation"; 221 + static char *name; 242 222 struct iio_dev *indio_dev; 243 223 struct dev_rot_state *rot_state; 244 224 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; ··· 254 234 rot_state->common_attributes.hsdev = hsdev; 255 235 rot_state->common_attributes.pdev = pdev; 256 236 257 - ret = hid_sensor_parse_common_attributes(hsdev, 258 - HID_USAGE_SENSOR_DEVICE_ORIENTATION, 237 + switch (hsdev->usage) { 238 + case HID_USAGE_SENSOR_DEVICE_ORIENTATION: 239 + name = "dev_rotation"; 240 + break; 241 + case HID_USAGE_SENSOR_RELATIVE_ORIENTATION: 242 + name = "relative_orientation"; 243 + break; 244 + case HID_USAGE_SENSOR_GEOMAGNETIC_ORIENTATION: 245 + name = "geomagnetic_orientation"; 246 + break; 247 + default: 248 + return -EINVAL; 249 + } 250 + 251 + ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage, 259 252 &rot_state->common_attributes); 260 253 if (ret) { 261 254 dev_err(&pdev->dev, "failed to setup common attributes\n"); ··· 285 252 286 253 ret = dev_rot_parse_report(pdev, hsdev, 287 254 (struct iio_chan_spec *)indio_dev->channels, 288 - HID_USAGE_SENSOR_DEVICE_ORIENTATION, 289 - rot_state); 255 + hsdev->usage, rot_state); 290 256 if (ret) { 291 257 dev_err(&pdev->dev, "failed to setup attributes\n"); 292 258 return ret; ··· 320 288 rot_state->callbacks.send_event = dev_rot_proc_event; 321 289 rot_state->callbacks.capture_sample = dev_rot_capture_sample; 322 290 rot_state->callbacks.pdev = pdev; 323 - ret = sensor_hub_register_callback(hsdev, 324 - HID_USAGE_SENSOR_DEVICE_ORIENTATION, 291 + ret = sensor_hub_register_callback(hsdev, hsdev->usage, 325 292 &rot_state->callbacks); 326 293 if (ret) { 327 294 dev_err(&pdev->dev, "callback reg failed\n"); ··· 345 314 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 346 315 struct dev_rot_state *rot_state = iio_priv(indio_dev); 347 316 348 - sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_DEVICE_ORIENTATION); 317 + sensor_hub_remove_callback(hsdev, hsdev->usage); 349 318 iio_device_unregister(indio_dev); 350 319 hid_sensor_remove_trigger(&rot_state->common_attributes); 351 320 iio_triggered_buffer_cleanup(indio_dev); ··· 357 326 { 358 327 /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ 359 328 .name = "HID-SENSOR-20008a", 329 + }, 330 + { 331 + /* Relative orientation(AG) sensor */ 332 + .name = "HID-SENSOR-20008e", 333 + }, 334 + { 335 + /* Geomagnetic orientation(AM) sensor */ 336 + .name = "HID-SENSOR-2000c1", 360 337 }, 361 338 { /* sentinel */ } 362 339 };
+1 -1
drivers/iio/pressure/Kconfig
··· 23 23 select BMP280_SPI if (SPI_MASTER) 24 24 help 25 25 Say yes here to build support for Bosch Sensortec BMP180 and BMP280 26 - pressure and temperature sensors. Also supports the BE280 with 26 + pressure and temperature sensors. Also supports the BME280 with 27 27 an additional humidity sensor channel. 28 28 29 29 To compile this driver as a module, choose M here: the core module
+4 -4
drivers/iio/pressure/st_pressure_core.c
··· 568 568 int st_press_common_probe(struct iio_dev *indio_dev) 569 569 { 570 570 struct st_sensor_data *press_data = iio_priv(indio_dev); 571 + struct st_sensors_platform_data *pdata = 572 + (struct st_sensors_platform_data *)press_data->dev->platform_data; 571 573 int irq = press_data->get_irq_data_ready(indio_dev); 572 574 int err; 573 575 ··· 605 603 press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz; 606 604 607 605 /* Some devices don't support a data ready pin. */ 608 - if (!press_data->dev->platform_data && 609 - press_data->sensor_settings->drdy_irq.addr) 610 - press_data->dev->platform_data = 611 - (struct st_sensors_platform_data *)&default_press_pdata; 606 + if (!pdata && press_data->sensor_settings->drdy_irq.addr) 607 + pdata = (struct st_sensors_platform_data *)&default_press_pdata; 612 608 613 609 err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data); 614 610 if (err < 0)
+11 -7
drivers/iio/pressure/zpa2326.c
··· 867 867 { 868 868 int ret; 869 869 unsigned int val; 870 + long timeout; 870 871 871 872 zpa2326_dbg(indio_dev, "waiting for one shot completion interrupt"); 872 873 873 - ret = wait_for_completion_interruptible_timeout( 874 + timeout = wait_for_completion_interruptible_timeout( 874 875 &private->data_ready, ZPA2326_CONVERSION_JIFFIES); 875 - if (ret > 0) 876 + if (timeout > 0) 876 877 /* 877 878 * Interrupt handler completed before timeout: return operation 878 879 * status. ··· 883 882 /* Clear all interrupts just to be sure. */ 884 883 regmap_read(private->regmap, ZPA2326_INT_SOURCE_REG, &val); 885 884 886 - if (!ret) 885 + if (!timeout) { 887 886 /* Timed out. */ 887 + zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)", 888 + timeout); 888 889 ret = -ETIME; 889 - 890 - if (ret != -ERESTARTSYS) 891 - zpa2326_warn(indio_dev, "no one shot interrupt occurred (%d)", 892 - ret); 890 + } else if (timeout < 0) { 891 + zpa2326_warn(indio_dev, 892 + "wait for one shot interrupt cancelled"); 893 + ret = -ERESTARTSYS; 894 + } 893 895 894 896 return ret; 895 897 }
+3 -3
drivers/iio/proximity/as3935.c
··· 176 176 if (ret) 177 177 return ret; 178 178 179 - if (m == IIO_CHAN_INFO_RAW) 180 - return IIO_VAL_INT; 181 - 182 179 /* storm out of range */ 183 180 if (*val == AS3935_DATA_MASK) 184 181 return -EINVAL; 182 + 183 + if (m == IIO_CHAN_INFO_RAW) 184 + return IIO_VAL_INT; 185 185 186 186 if (m == IIO_CHAN_INFO_PROCESSED) 187 187 *val *= 1000;
+1
drivers/iio/temperature/maxim_thermocouple.c
··· 267 267 static const struct spi_device_id maxim_thermocouple_id[] = { 268 268 {"max6675", MAX6675}, 269 269 {"max31855", MAX31855}, 270 + {"max31856", MAX31855}, 270 271 {}, 271 272 }; 272 273 MODULE_DEVICE_TABLE(spi, maxim_thermocouple_id);
+99 -14
drivers/iio/trigger/stm32-timer-trigger.c
··· 14 14 #include <linux/module.h> 15 15 #include <linux/platform_device.h> 16 16 17 - #define MAX_TRIGGERS 6 17 + #define MAX_TRIGGERS 7 18 18 #define MAX_VALIDS 5 19 19 20 20 /* List the triggers created by each timer */ 21 21 static const void *triggers_table[][MAX_TRIGGERS] = { 22 - { TIM1_TRGO, TIM1_CH1, TIM1_CH2, TIM1_CH3, TIM1_CH4,}, 22 + { TIM1_TRGO, TIM1_TRGO2, TIM1_CH1, TIM1_CH2, TIM1_CH3, TIM1_CH4,}, 23 23 { TIM2_TRGO, TIM2_CH1, TIM2_CH2, TIM2_CH3, TIM2_CH4,}, 24 24 { TIM3_TRGO, TIM3_CH1, TIM3_CH2, TIM3_CH3, TIM3_CH4,}, 25 25 { TIM4_TRGO, TIM4_CH1, TIM4_CH2, TIM4_CH3, TIM4_CH4,}, 26 26 { TIM5_TRGO, TIM5_CH1, TIM5_CH2, TIM5_CH3, TIM5_CH4,}, 27 27 { TIM6_TRGO,}, 28 28 { TIM7_TRGO,}, 29 - { TIM8_TRGO, TIM8_CH1, TIM8_CH2, TIM8_CH3, TIM8_CH4,}, 29 + { TIM8_TRGO, TIM8_TRGO2, TIM8_CH1, TIM8_CH2, TIM8_CH3, TIM8_CH4,}, 30 30 { TIM9_TRGO, TIM9_CH1, TIM9_CH2,}, 31 31 { }, /* timer 10 */ 32 32 { }, /* timer 11 */ ··· 56 56 u32 max_arr; 57 57 const void *triggers; 58 58 const void *valids; 59 + bool has_trgo2; 59 60 }; 60 61 62 + static bool stm32_timer_is_trgo2_name(const char *name) 63 + { 64 + return !!strstr(name, "trgo2"); 65 + } 66 + 61 67 static int stm32_timer_start(struct stm32_timer_trigger *priv, 68 + struct iio_trigger *trig, 62 69 unsigned int frequency) 63 70 { 64 71 unsigned long long prd, div; ··· 109 102 regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, TIM_CR1_ARPE); 110 103 111 104 /* Force master mode to update mode */ 112 - regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS, 0x20); 105 + if (stm32_timer_is_trgo2_name(trig->name)) 106 + regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2, 107 + 0x2 << TIM_CR2_MMS2_SHIFT); 108 + else 109 + regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS, 110 + 0x2 << TIM_CR2_MMS_SHIFT); 113 111 114 112 /* Make sure that registers are updated */ 115 113 regmap_update_bits(priv->regmap, TIM_EGR, TIM_EGR_UG, TIM_EGR_UG); ··· 162 150 if (freq == 0) { 163 151 stm32_timer_stop(priv); 164 152 } else { 165 - ret = stm32_timer_start(priv, freq); 153 + ret = stm32_timer_start(priv, trig, freq); 166 154 if (ret) 167 155 return ret; 168 156 } ··· 195 183 stm32_tt_read_frequency, 196 184 stm32_tt_store_frequency); 197 185 186 + #define MASTER_MODE_MAX 7 187 + #define MASTER_MODE2_MAX 15 188 + 198 189 static char *master_mode_table[] = { 199 190 "reset", 200 191 "enable", ··· 206 191 "OC1REF", 207 192 "OC2REF", 208 193 "OC3REF", 209 - "OC4REF" 194 + "OC4REF", 195 + /* Master mode selection 2 only */ 196 + "OC5REF", 197 + "OC6REF", 198 + "compare_pulse_OC4REF", 199 + "compare_pulse_OC6REF", 200 + "compare_pulse_OC4REF_r_or_OC6REF_r", 201 + "compare_pulse_OC4REF_r_or_OC6REF_f", 202 + "compare_pulse_OC5REF_r_or_OC6REF_r", 203 + "compare_pulse_OC5REF_r_or_OC6REF_f", 210 204 }; 211 205 212 206 static ssize_t stm32_tt_show_master_mode(struct device *dev, ··· 223 199 char *buf) 224 200 { 225 201 struct stm32_timer_trigger *priv = dev_get_drvdata(dev); 202 + struct iio_trigger *trig = to_iio_trigger(dev); 226 203 u32 cr2; 227 204 228 205 regmap_read(priv->regmap, TIM_CR2, &cr2); 229 - cr2 = (cr2 & TIM_CR2_MMS) >> TIM_CR2_MMS_SHIFT; 206 + 207 + if (stm32_timer_is_trgo2_name(trig->name)) 208 + cr2 = (cr2 & TIM_CR2_MMS2) >> TIM_CR2_MMS2_SHIFT; 209 + else 210 + cr2 = (cr2 & TIM_CR2_MMS) >> TIM_CR2_MMS_SHIFT; 230 211 231 212 return snprintf(buf, PAGE_SIZE, "%s\n", master_mode_table[cr2]); 232 213 } ··· 241 212 const char *buf, size_t len) 242 213 { 243 214 struct stm32_timer_trigger *priv = dev_get_drvdata(dev); 215 + struct iio_trigger *trig = to_iio_trigger(dev); 216 + u32 mask, shift, master_mode_max; 244 217 int i; 245 218 246 - for (i = 0; i < ARRAY_SIZE(master_mode_table); i++) { 219 + if (stm32_timer_is_trgo2_name(trig->name)) { 220 + mask = TIM_CR2_MMS2; 221 + shift = TIM_CR2_MMS2_SHIFT; 222 + master_mode_max = MASTER_MODE2_MAX; 223 + } else { 224 + mask = TIM_CR2_MMS; 225 + shift = TIM_CR2_MMS_SHIFT; 226 + master_mode_max = MASTER_MODE_MAX; 227 + } 228 + 229 + for (i = 0; i <= master_mode_max; i++) { 247 230 if (!strncmp(master_mode_table[i], buf, 248 231 strlen(master_mode_table[i]))) { 249 - regmap_update_bits(priv->regmap, TIM_CR2, 250 - TIM_CR2_MMS, i << TIM_CR2_MMS_SHIFT); 232 + regmap_update_bits(priv->regmap, TIM_CR2, mask, 233 + i << shift); 251 234 /* Make sure that registers are updated */ 252 235 regmap_update_bits(priv->regmap, TIM_EGR, 253 236 TIM_EGR_UG, TIM_EGR_UG); ··· 270 229 return -EINVAL; 271 230 } 272 231 273 - static IIO_CONST_ATTR(master_mode_available, 274 - "reset enable update compare_pulse OC1REF OC2REF OC3REF OC4REF"); 232 + static ssize_t stm32_tt_show_master_mode_avail(struct device *dev, 233 + struct device_attribute *attr, 234 + char *buf) 235 + { 236 + struct iio_trigger *trig = to_iio_trigger(dev); 237 + unsigned int i, master_mode_max; 238 + size_t len = 0; 239 + 240 + if (stm32_timer_is_trgo2_name(trig->name)) 241 + master_mode_max = MASTER_MODE2_MAX; 242 + else 243 + master_mode_max = MASTER_MODE_MAX; 244 + 245 + for (i = 0; i <= master_mode_max; i++) 246 + len += scnprintf(buf + len, PAGE_SIZE - len, 247 + "%s ", master_mode_table[i]); 248 + 249 + /* replace trailing space by newline */ 250 + buf[len - 1] = '\n'; 251 + 252 + return len; 253 + } 254 + 255 + static IIO_DEVICE_ATTR(master_mode_available, 0444, 256 + stm32_tt_show_master_mode_avail, NULL, 0); 275 257 276 258 static IIO_DEVICE_ATTR(master_mode, 0660, 277 259 stm32_tt_show_master_mode, ··· 304 240 static struct attribute *stm32_trigger_attrs[] = { 305 241 &iio_dev_attr_sampling_frequency.dev_attr.attr, 306 242 &iio_dev_attr_master_mode.dev_attr.attr, 307 - &iio_const_attr_master_mode_available.dev_attr.attr, 243 + &iio_dev_attr_master_mode_available.dev_attr.attr, 308 244 NULL, 309 245 }; 310 246 ··· 328 264 329 265 while (cur && *cur) { 330 266 struct iio_trigger *trig; 267 + bool cur_is_trgo2 = stm32_timer_is_trgo2_name(*cur); 268 + 269 + if (cur_is_trgo2 && !priv->has_trgo2) { 270 + cur++; 271 + continue; 272 + } 331 273 332 274 trig = devm_iio_trigger_alloc(priv->dev, "%s", *cur); 333 275 if (!trig) ··· 347 277 * should only be available on trgo trigger which 348 278 * is always the first in the list. 349 279 */ 350 - if (cur == priv->triggers) 280 + if (cur == priv->triggers || cur_is_trgo2) 351 281 trig->dev.groups = stm32_trigger_attr_groups; 352 282 353 283 iio_trigger_set_drvdata(trig, priv); ··· 654 584 } 655 585 EXPORT_SYMBOL(is_stm32_timer_trigger); 656 586 587 + static void stm32_timer_detect_trgo2(struct stm32_timer_trigger *priv) 588 + { 589 + u32 val; 590 + 591 + /* 592 + * Master mode selection 2 bits can only be written and read back when 593 + * timer supports it. 594 + */ 595 + regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2, TIM_CR2_MMS2); 596 + regmap_read(priv->regmap, TIM_CR2, &val); 597 + regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2, 0); 598 + priv->has_trgo2 = !!val; 599 + } 600 + 657 601 static int stm32_timer_trigger_probe(struct platform_device *pdev) 658 602 { 659 603 struct device *dev = &pdev->dev; ··· 698 614 priv->max_arr = ddata->max_arr; 699 615 priv->triggers = triggers_table[index]; 700 616 priv->valids = valids_table[index]; 617 + stm32_timer_detect_trgo2(priv); 701 618 702 619 ret = stm32_setup_iio_triggers(priv); 703 620 if (ret)
+11 -11
drivers/staging/iio/frequency/ad9834.c
··· 292 292 return sprintf(buf, "%s\n", str); 293 293 } 294 294 295 - static IIO_DEVICE_ATTR(out_altvoltage0_out0_wavetype_available, S_IRUGO, 295 + static IIO_DEVICE_ATTR(out_altvoltage0_out0_wavetype_available, 0444, 296 296 ad9834_show_out0_wavetype_available, NULL, 0); 297 297 298 298 static ··· 312 312 return sprintf(buf, "%s\n", str); 313 313 } 314 314 315 - static IIO_DEVICE_ATTR(out_altvoltage0_out1_wavetype_available, S_IRUGO, 315 + static IIO_DEVICE_ATTR(out_altvoltage0_out1_wavetype_available, 0444, 316 316 ad9834_show_out1_wavetype_available, NULL, 0); 317 317 318 318 /** 319 319 * see dds.h for further information 320 320 */ 321 321 322 - static IIO_DEV_ATTR_FREQ(0, 0, S_IWUSR, NULL, ad9834_write, AD9834_REG_FREQ0); 323 - static IIO_DEV_ATTR_FREQ(0, 1, S_IWUSR, NULL, ad9834_write, AD9834_REG_FREQ1); 324 - static IIO_DEV_ATTR_FREQSYMBOL(0, S_IWUSR, NULL, ad9834_write, AD9834_FSEL); 322 + static IIO_DEV_ATTR_FREQ(0, 0, 0200, NULL, ad9834_write, AD9834_REG_FREQ0); 323 + static IIO_DEV_ATTR_FREQ(0, 1, 0200, NULL, ad9834_write, AD9834_REG_FREQ1); 324 + static IIO_DEV_ATTR_FREQSYMBOL(0, 0200, NULL, ad9834_write, AD9834_FSEL); 325 325 static IIO_CONST_ATTR_FREQ_SCALE(0, "1"); /* 1Hz */ 326 326 327 - static IIO_DEV_ATTR_PHASE(0, 0, S_IWUSR, NULL, ad9834_write, AD9834_REG_PHASE0); 328 - static IIO_DEV_ATTR_PHASE(0, 1, S_IWUSR, NULL, ad9834_write, AD9834_REG_PHASE1); 329 - static IIO_DEV_ATTR_PHASESYMBOL(0, S_IWUSR, NULL, ad9834_write, AD9834_PSEL); 327 + static IIO_DEV_ATTR_PHASE(0, 0, 0200, NULL, ad9834_write, AD9834_REG_PHASE0); 328 + static IIO_DEV_ATTR_PHASE(0, 1, 0200, NULL, ad9834_write, AD9834_REG_PHASE1); 329 + static IIO_DEV_ATTR_PHASESYMBOL(0, 0200, NULL, ad9834_write, AD9834_PSEL); 330 330 static IIO_CONST_ATTR_PHASE_SCALE(0, "0.0015339808"); /* 2PI/2^12 rad*/ 331 331 332 - static IIO_DEV_ATTR_PINCONTROL_EN(0, S_IWUSR, NULL, 332 + static IIO_DEV_ATTR_PINCONTROL_EN(0, 0200, NULL, 333 333 ad9834_write, AD9834_PIN_SW); 334 - static IIO_DEV_ATTR_OUT_ENABLE(0, S_IWUSR, NULL, ad9834_write, AD9834_RESET); 335 - static IIO_DEV_ATTR_OUTY_ENABLE(0, 1, S_IWUSR, NULL, 334 + static IIO_DEV_ATTR_OUT_ENABLE(0, 0200, NULL, ad9834_write, AD9834_RESET); 335 + static IIO_DEV_ATTR_OUTY_ENABLE(0, 1, 0200, NULL, 336 336 ad9834_write, AD9834_OPBITEN); 337 337 static IIO_DEV_ATTR_OUT_WAVETYPE(0, 0, ad9834_store_wavetype, 0); 338 338 static IIO_DEV_ATTR_OUT_WAVETYPE(0, 1, ad9834_store_wavetype, 1);
+1 -1
drivers/staging/iio/frequency/dds.h
··· 101 101 102 102 #define IIO_DEV_ATTR_OUT_WAVETYPE(_channel, _output, _store, _addr) \ 103 103 IIO_DEVICE_ATTR(out_altvoltage##_channel##_out##_output##_wavetype,\ 104 - S_IWUSR, NULL, _store, _addr) 104 + 0200, NULL, _store, _addr) 105 105 106 106 /** 107 107 * /sys/bus/iio/devices/.../out_altvoltageX_outY_wavetype_available
-10
drivers/staging/iio/light/Kconfig
··· 3 3 # 4 4 menu "Light sensors" 5 5 6 - config SENSORS_ISL29028 7 - tristate "Intersil ISL29028 Concurrent Light and Proximity Sensor" 8 - depends on I2C 9 - select REGMAP_I2C 10 - help 11 - Provides driver for the Intersil's ISL29028 device. 12 - This driver supports the sysfs interface to get the ALS, IR intensity, 13 - Proximity value via iio. The ISL29028 provides the concurrent sensing 14 - of ambient light and proximity. 15 - 16 6 config TSL2x7x 17 7 tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and proximity sensors" 18 8 depends on I2C
+1 -2
drivers/staging/iio/light/Makefile
··· 2 2 # Makefile for industrial I/O Light sensors 3 3 # 4 4 5 - obj-$(CONFIG_SENSORS_ISL29028) += isl29028.o 6 - obj-$(CONFIG_TSL2x7x) += tsl2x7x_core.o 5 + obj-$(CONFIG_TSL2x7x) += tsl2x7x.o
+56 -20
drivers/staging/iio/light/isl29028.c drivers/iio/light/isl29028.c
··· 16 16 * 17 17 * You should have received a copy of the GNU General Public License 18 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 + * 20 + * Datasheets: 21 + * - http://www.intersil.com/content/dam/Intersil/documents/isl2/isl29028.pdf 22 + * - http://www.intersil.com/content/dam/Intersil/documents/isl2/isl29030.pdf 19 23 */ 20 24 21 25 #include <linux/module.h> ··· 68 64 69 65 #define ISL29028_POWER_OFF_DELAY_MS 2000 70 66 71 - static const unsigned int isl29028_prox_sleep_time[] = {800, 400, 200, 100, 75, 72 - 50, 12, 0}; 67 + struct isl29028_prox_data { 68 + int sampling_int; 69 + int sampling_fract; 70 + int sleep_time; 71 + }; 72 + 73 + static const struct isl29028_prox_data isl29028_prox_data[] = { 74 + { 1, 250000, 800 }, 75 + { 2, 500000, 400 }, 76 + { 5, 0, 200 }, 77 + { 10, 0, 100 }, 78 + { 13, 300000, 75 }, 79 + { 20, 0, 50 }, 80 + { 80, 0, 13 }, /* 81 + * Note: Data sheet lists 12.5 ms sleep time. 82 + * Round up a half millisecond for msleep(). 83 + */ 84 + { 100, 0, 0 } 85 + }; 73 86 74 87 enum isl29028_als_ir_mode { 75 88 ISL29028_MODE_NONE = 0, ··· 97 76 struct isl29028_chip { 98 77 struct mutex lock; 99 78 struct regmap *regmap; 100 - unsigned int prox_sampling; 79 + int prox_sampling_int; 80 + int prox_sampling_frac; 101 81 bool enable_prox; 102 82 int lux_scale; 103 83 enum isl29028_als_ir_mode als_ir_mode; 104 84 }; 105 85 106 - static int isl29028_find_prox_sleep_time_index(int sampling) 86 + static int isl29028_find_prox_sleep_index(int sampling_int, int sampling_fract) 107 87 { 108 - unsigned int period = DIV_ROUND_UP(1000, sampling); 109 88 int i; 110 89 111 - for (i = 0; i < ARRAY_SIZE(isl29028_prox_sleep_time); ++i) { 112 - if (period >= isl29028_prox_sleep_time[i]) 113 - break; 90 + for (i = 0; i < ARRAY_SIZE(isl29028_prox_data); ++i) { 91 + if (isl29028_prox_data[i].sampling_int == sampling_int && 92 + isl29028_prox_data[i].sampling_fract == sampling_fract) 93 + return i; 114 94 } 115 95 116 - return i; 96 + return -EINVAL; 117 97 } 118 98 119 99 static int isl29028_set_proxim_sampling(struct isl29028_chip *chip, 120 - unsigned int sampling) 100 + int sampling_int, int sampling_fract) 121 101 { 122 102 struct device *dev = regmap_get_device(chip->regmap); 123 103 int sleep_index, ret; 124 104 125 - sleep_index = isl29028_find_prox_sleep_time_index(sampling); 105 + sleep_index = isl29028_find_prox_sleep_index(sampling_int, 106 + sampling_fract); 107 + if (sleep_index < 0) 108 + return sleep_index; 109 + 126 110 ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, 127 111 ISL29028_CONF_PROX_SLP_MASK, 128 112 sleep_index << ISL29028_CONF_PROX_SLP_SH); ··· 138 112 return ret; 139 113 } 140 114 141 - chip->prox_sampling = sampling; 115 + chip->prox_sampling_int = sampling_int; 116 + chip->prox_sampling_frac = sampling_fract; 142 117 143 118 return ret; 144 119 } 145 120 146 121 static int isl29028_enable_proximity(struct isl29028_chip *chip) 147 122 { 148 - int sleep_index, ret; 123 + int prox_index, ret; 149 124 150 - ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling); 125 + ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling_int, 126 + chip->prox_sampling_frac); 151 127 if (ret < 0) 152 128 return ret; 153 129 ··· 160 132 return ret; 161 133 162 134 /* Wait for conversion to be complete for first sample */ 163 - sleep_index = isl29028_find_prox_sleep_time_index(chip->prox_sampling); 164 - msleep(isl29028_prox_sleep_time[sleep_index]); 135 + prox_index = isl29028_find_prox_sleep_index(chip->prox_sampling_int, 136 + chip->prox_sampling_frac); 137 + if (prox_index < 0) 138 + return prox_index; 139 + 140 + msleep(isl29028_prox_data[prox_index].sleep_time); 165 141 166 142 return 0; 167 143 } ··· 393 361 break; 394 362 } 395 363 396 - ret = isl29028_set_proxim_sampling(chip, val); 364 + ret = isl29028_set_proxim_sampling(chip, val, val2); 397 365 break; 398 366 case IIO_LIGHT: 399 367 if (mask != IIO_CHAN_INFO_SCALE) { ··· 471 439 if (chan->type != IIO_PROXIMITY) 472 440 break; 473 441 474 - *val = chip->prox_sampling; 442 + *val = chip->prox_sampling_int; 443 + *val2 = chip->prox_sampling_frac; 475 444 ret = IIO_VAL_INT; 476 445 break; 477 446 case IIO_CHAN_INFO_SCALE: ··· 505 472 } 506 473 507 474 static IIO_CONST_ATTR(in_proximity_sampling_frequency_available, 508 - "1 3 5 10 13 20 83 100"); 475 + "1.25 2.5 5 10 13.3 20 80 100"); 509 476 static IIO_CONST_ATTR(in_illuminance_scale_available, "125 2000"); 510 477 511 478 #define ISL29028_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr) ··· 604 571 } 605 572 606 573 chip->enable_prox = false; 607 - chip->prox_sampling = 20; 574 + chip->prox_sampling_int = 20; 575 + chip->prox_sampling_frac = 0; 608 576 chip->lux_scale = 2000; 609 577 610 578 ret = regmap_write(chip->regmap, ISL29028_REG_TEST1_MODE, 0x0); ··· 698 664 699 665 static const struct i2c_device_id isl29028_id[] = { 700 666 {"isl29028", 0}, 667 + {"isl29030", 0}, 701 668 {} 702 669 }; 703 670 MODULE_DEVICE_TABLE(i2c, isl29028_id); ··· 706 671 static const struct of_device_id isl29028_of_match[] = { 707 672 { .compatible = "isl,isl29028", }, /* for backward compat., don't use */ 708 673 { .compatible = "isil,isl29028", }, 674 + { .compatible = "isil,isl29030", }, 709 675 { }, 710 676 }; 711 677 MODULE_DEVICE_TABLE(of, isl29028_of_match);
+26 -40
drivers/staging/iio/light/tsl2x7x_core.c drivers/staging/iio/light/tsl2x7x.c
··· 13 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 15 * more details. 16 - * 17 - * You should have received a copy of the GNU General Public License along 18 - * with this program; if not, write to the Free Software Foundation, Inc., 19 - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 16 */ 21 17 22 18 #include <linux/kernel.h> ··· 915 919 tsl2x7x_chip_on(indio_dev); 916 920 } 917 921 918 - static ssize_t tsl2x7x_power_state_show(struct device *dev, 922 + static ssize_t power_state_show(struct device *dev, 919 923 struct device_attribute *attr, 920 924 char *buf) 921 925 { ··· 924 928 return snprintf(buf, PAGE_SIZE, "%d\n", chip->tsl2x7x_chip_status); 925 929 } 926 930 927 - static ssize_t tsl2x7x_power_state_store(struct device *dev, 931 + static ssize_t power_state_store(struct device *dev, 928 932 struct device_attribute *attr, 929 933 const char *buf, size_t len) 930 934 { ··· 942 946 return len; 943 947 } 944 948 945 - static ssize_t tsl2x7x_gain_available_show(struct device *dev, 949 + static ssize_t in_illuminance0_calibscale_available_show(struct device *dev, 946 950 struct device_attribute *attr, 947 951 char *buf) 948 952 { ··· 960 964 return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120"); 961 965 } 962 966 963 - static ssize_t tsl2x7x_prox_gain_available_show(struct device *dev, 967 + static ssize_t in_proximity0_calibscale_available_show(struct device *dev, 964 968 struct device_attribute *attr, 965 969 char *buf) 966 970 { 967 971 return snprintf(buf, PAGE_SIZE, "%s\n", "1 2 4 8"); 968 972 } 969 973 970 - static ssize_t tsl2x7x_als_time_show(struct device *dev, 974 + static ssize_t in_illuminance0_integration_time_show(struct device *dev, 971 975 struct device_attribute *attr, 972 976 char *buf) 973 977 { ··· 982 986 return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z); 983 987 } 984 988 985 - static ssize_t tsl2x7x_als_time_store(struct device *dev, 989 + static ssize_t in_illuminance0_integration_time_store(struct device *dev, 986 990 struct device_attribute *attr, 987 991 const char *buf, size_t len) 988 992 { ··· 1010 1014 static IIO_CONST_ATTR(in_illuminance0_integration_time_available, 1011 1015 ".00272 - .696"); 1012 1016 1013 - static ssize_t tsl2x7x_als_cal_target_show(struct device *dev, 1017 + static ssize_t in_illuminance0_target_input_show(struct device *dev, 1014 1018 struct device_attribute *attr, 1015 1019 char *buf) 1016 1020 { ··· 1020 1024 chip->tsl2x7x_settings.als_cal_target); 1021 1025 } 1022 1026 1023 - static ssize_t tsl2x7x_als_cal_target_store(struct device *dev, 1027 + static ssize_t in_illuminance0_target_input_store(struct device *dev, 1024 1028 struct device_attribute *attr, 1025 1029 const char *buf, size_t len) 1026 1030 { ··· 1040 1044 } 1041 1045 1042 1046 /* persistence settings */ 1043 - static ssize_t tsl2x7x_als_persistence_show(struct device *dev, 1047 + static ssize_t in_intensity0_thresh_period_show(struct device *dev, 1044 1048 struct device_attribute *attr, 1045 1049 char *buf) 1046 1050 { ··· 1057 1061 return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z); 1058 1062 } 1059 1063 1060 - static ssize_t tsl2x7x_als_persistence_store(struct device *dev, 1064 + static ssize_t in_intensity0_thresh_period_store(struct device *dev, 1061 1065 struct device_attribute *attr, 1062 1066 const char *buf, size_t len) 1063 1067 { ··· 1088 1092 return IIO_VAL_INT_PLUS_MICRO; 1089 1093 } 1090 1094 1091 - static ssize_t tsl2x7x_prox_persistence_show(struct device *dev, 1095 + static ssize_t in_proximity0_thresh_period_show(struct device *dev, 1092 1096 struct device_attribute *attr, 1093 1097 char *buf) 1094 1098 { ··· 1105 1109 return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z); 1106 1110 } 1107 1111 1108 - static ssize_t tsl2x7x_prox_persistence_store(struct device *dev, 1112 + static ssize_t in_proximity0_thresh_period_store(struct device *dev, 1109 1113 struct device_attribute *attr, 1110 1114 const char *buf, size_t len) 1111 1115 { ··· 1136 1140 return IIO_VAL_INT_PLUS_MICRO; 1137 1141 } 1138 1142 1139 - static ssize_t tsl2x7x_do_calibrate(struct device *dev, 1143 + static ssize_t in_illuminance0_calibrate_store(struct device *dev, 1140 1144 struct device_attribute *attr, 1141 1145 const char *buf, size_t len) 1142 1146 { ··· 1154 1158 return len; 1155 1159 } 1156 1160 1157 - static ssize_t tsl2x7x_luxtable_show(struct device *dev, 1161 + static ssize_t in_illuminance0_lux_table_show(struct device *dev, 1158 1162 struct device_attribute *attr, 1159 1163 char *buf) 1160 1164 { ··· 1182 1186 return offset; 1183 1187 } 1184 1188 1185 - static ssize_t tsl2x7x_luxtable_store(struct device *dev, 1189 + static ssize_t in_illuminance0_lux_table_store(struct device *dev, 1186 1190 struct device_attribute *attr, 1187 1191 const char *buf, size_t len) 1188 1192 { ··· 1222 1226 return len; 1223 1227 } 1224 1228 1225 - static ssize_t tsl2x7x_do_prox_calibrate(struct device *dev, 1229 + static ssize_t in_proximity0_calibrate_store(struct device *dev, 1226 1230 struct device_attribute *attr, 1227 1231 const char *buf, size_t len) 1228 1232 { ··· 1494 1498 return 0; 1495 1499 } 1496 1500 1497 - static DEVICE_ATTR(power_state, S_IRUGO | S_IWUSR, 1498 - tsl2x7x_power_state_show, tsl2x7x_power_state_store); 1501 + static DEVICE_ATTR_RW(power_state); 1499 1502 1500 - static DEVICE_ATTR(in_proximity0_calibscale_available, S_IRUGO, 1501 - tsl2x7x_prox_gain_available_show, NULL); 1503 + static DEVICE_ATTR_RO(in_proximity0_calibscale_available); 1502 1504 1503 - static DEVICE_ATTR(in_illuminance0_calibscale_available, S_IRUGO, 1504 - tsl2x7x_gain_available_show, NULL); 1505 + static DEVICE_ATTR_RO(in_illuminance0_calibscale_available); 1505 1506 1506 - static DEVICE_ATTR(in_illuminance0_integration_time, S_IRUGO | S_IWUSR, 1507 - tsl2x7x_als_time_show, tsl2x7x_als_time_store); 1507 + static DEVICE_ATTR_RW(in_illuminance0_integration_time); 1508 1508 1509 - static DEVICE_ATTR(in_illuminance0_target_input, S_IRUGO | S_IWUSR, 1510 - tsl2x7x_als_cal_target_show, tsl2x7x_als_cal_target_store); 1509 + static DEVICE_ATTR_RW(in_illuminance0_target_input); 1511 1510 1512 - static DEVICE_ATTR(in_illuminance0_calibrate, S_IWUSR, NULL, 1513 - tsl2x7x_do_calibrate); 1511 + static DEVICE_ATTR_WO(in_illuminance0_calibrate); 1514 1512 1515 - static DEVICE_ATTR(in_proximity0_calibrate, S_IWUSR, NULL, 1516 - tsl2x7x_do_prox_calibrate); 1513 + static DEVICE_ATTR_WO(in_proximity0_calibrate); 1517 1514 1518 - static DEVICE_ATTR(in_illuminance0_lux_table, S_IRUGO | S_IWUSR, 1519 - tsl2x7x_luxtable_show, tsl2x7x_luxtable_store); 1515 + static DEVICE_ATTR_RW(in_illuminance0_lux_table); 1520 1516 1521 - static DEVICE_ATTR(in_intensity0_thresh_period, S_IRUGO | S_IWUSR, 1522 - tsl2x7x_als_persistence_show, tsl2x7x_als_persistence_store); 1517 + static DEVICE_ATTR_RW(in_intensity0_thresh_period); 1523 1518 1524 - static DEVICE_ATTR(in_proximity0_thresh_period, S_IRUGO | S_IWUSR, 1525 - tsl2x7x_prox_persistence_show, tsl2x7x_prox_persistence_store); 1519 + static DEVICE_ATTR_RW(in_proximity0_thresh_period); 1526 1520 1527 1521 /* Use the default register values to identify the Taos device */ 1528 1522 static int tsl2x7x_device_id(unsigned char *id, int target)
+50 -51
drivers/staging/iio/meter/ade7753.c
··· 107 107 return ret; 108 108 } 109 109 110 - static int ade7753_spi_write_reg_16(struct device *dev, 111 - u8 reg_address, 112 - u16 value) 110 + static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address, 111 + u16 value) 113 112 { 114 113 int ret; 115 114 struct iio_dev *indio_dev = dev_to_iio_dev(dev); ··· 125 126 } 126 127 127 128 static int ade7753_spi_read_reg_8(struct device *dev, 128 - u8 reg_address, 129 - u8 *val) 129 + u8 reg_address, 130 + u8 *val) 130 131 { 131 132 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 132 133 struct ade7753_state *st = iio_priv(indio_dev); ··· 135 136 ret = spi_w8r8(st->us, ADE7753_READ_REG(reg_address)); 136 137 if (ret < 0) { 137 138 dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X", 138 - reg_address); 139 + reg_address); 139 140 return ret; 140 141 } 141 142 *val = ret; ··· 144 145 } 145 146 146 147 static int ade7753_spi_read_reg_16(struct device *dev, 147 - u8 reg_address, 148 - u16 *val) 148 + u8 reg_address, 149 + u16 *val) 149 150 { 150 151 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 151 152 struct ade7753_state *st = iio_priv(indio_dev); ··· 164 165 } 165 166 166 167 static int ade7753_spi_read_reg_24(struct device *dev, 167 - u8 reg_address, 168 - u32 *val) 168 + u8 reg_address, 169 + u32 *val) 169 170 { 170 171 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 171 172 struct ade7753_state *st = iio_priv(indio_dev); ··· 188 189 ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); 189 190 if (ret) { 190 191 dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X", 191 - reg_address); 192 + reg_address); 192 193 goto error_ret; 193 194 } 194 195 *val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2]; ··· 199 200 } 200 201 201 202 static ssize_t ade7753_read_8bit(struct device *dev, 202 - struct device_attribute *attr, 203 - char *buf) 203 + struct device_attribute *attr, 204 + char *buf) 204 205 { 205 206 int ret; 206 207 u8 val; ··· 214 215 } 215 216 216 217 static ssize_t ade7753_read_16bit(struct device *dev, 217 - struct device_attribute *attr, 218 - char *buf) 218 + struct device_attribute *attr, 219 + char *buf) 219 220 { 220 221 int ret; 221 222 u16 val; ··· 229 230 } 230 231 231 232 static ssize_t ade7753_read_24bit(struct device *dev, 232 - struct device_attribute *attr, 233 - char *buf) 233 + struct device_attribute *attr, 234 + char *buf) 234 235 { 235 236 int ret; 236 237 u32 val; ··· 244 245 } 245 246 246 247 static ssize_t ade7753_write_8bit(struct device *dev, 247 - struct device_attribute *attr, 248 - const char *buf, 249 - size_t len) 248 + struct device_attribute *attr, 249 + const char *buf, 250 + size_t len) 250 251 { 251 252 struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); 252 253 int ret; ··· 262 263 } 263 264 264 265 static ssize_t ade7753_write_16bit(struct device *dev, 265 - struct device_attribute *attr, 266 - const char *buf, 267 - size_t len) 266 + struct device_attribute *attr, 267 + const char *buf, 268 + size_t len) 268 269 { 269 270 struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); 270 271 int ret; ··· 297 298 static IIO_DEV_ATTR_LAENERGY(ade7753_read_24bit, ADE7753_LAENERGY); 298 299 static IIO_DEV_ATTR_VAENERGY(ade7753_read_24bit, ADE7753_VAENERGY); 299 300 static IIO_DEV_ATTR_LVAENERGY(ade7753_read_24bit, ADE7753_LVAENERGY); 300 - static IIO_DEV_ATTR_CFDEN(S_IWUSR | S_IRUGO, 301 + static IIO_DEV_ATTR_CFDEN(0644, 301 302 ade7753_read_16bit, 302 303 ade7753_write_16bit, 303 304 ADE7753_CFDEN); 304 - static IIO_DEV_ATTR_CFNUM(S_IWUSR | S_IRUGO, 305 + static IIO_DEV_ATTR_CFNUM(0644, 305 306 ade7753_read_8bit, 306 307 ade7753_write_8bit, 307 308 ADE7753_CFNUM); 308 309 static IIO_DEV_ATTR_CHKSUM(ade7753_read_8bit, ADE7753_CHKSUM); 309 - static IIO_DEV_ATTR_PHCAL(S_IWUSR | S_IRUGO, 310 + static IIO_DEV_ATTR_PHCAL(0644, 310 311 ade7753_read_16bit, 311 312 ade7753_write_16bit, 312 313 ADE7753_PHCAL); 313 - static IIO_DEV_ATTR_APOS(S_IWUSR | S_IRUGO, 314 + static IIO_DEV_ATTR_APOS(0644, 314 315 ade7753_read_16bit, 315 316 ade7753_write_16bit, 316 317 ADE7753_APOS); 317 - static IIO_DEV_ATTR_SAGCYC(S_IWUSR | S_IRUGO, 318 + static IIO_DEV_ATTR_SAGCYC(0644, 318 319 ade7753_read_8bit, 319 320 ade7753_write_8bit, 320 321 ADE7753_SAGCYC); 321 - static IIO_DEV_ATTR_SAGLVL(S_IWUSR | S_IRUGO, 322 + static IIO_DEV_ATTR_SAGLVL(0644, 322 323 ade7753_read_8bit, 323 324 ade7753_write_8bit, 324 325 ADE7753_SAGLVL); 325 - static IIO_DEV_ATTR_LINECYC(S_IWUSR | S_IRUGO, 326 + static IIO_DEV_ATTR_LINECYC(0644, 326 327 ade7753_read_8bit, 327 328 ade7753_write_8bit, 328 329 ADE7753_LINECYC); 329 - static IIO_DEV_ATTR_WDIV(S_IWUSR | S_IRUGO, 330 + static IIO_DEV_ATTR_WDIV(0644, 330 331 ade7753_read_8bit, 331 332 ade7753_write_8bit, 332 333 ADE7753_WDIV); 333 - static IIO_DEV_ATTR_IRMS(S_IWUSR | S_IRUGO, 334 + static IIO_DEV_ATTR_IRMS(0644, 334 335 ade7753_read_24bit, 335 336 NULL, 336 337 ADE7753_IRMS); 337 - static IIO_DEV_ATTR_VRMS(S_IRUGO, 338 + static IIO_DEV_ATTR_VRMS(0444, 338 339 ade7753_read_24bit, 339 340 NULL, 340 341 ADE7753_VRMS); 341 - static IIO_DEV_ATTR_IRMSOS(S_IWUSR | S_IRUGO, 342 + static IIO_DEV_ATTR_IRMSOS(0644, 342 343 ade7753_read_16bit, 343 344 ade7753_write_16bit, 344 345 ADE7753_IRMSOS); 345 - static IIO_DEV_ATTR_VRMSOS(S_IWUSR | S_IRUGO, 346 + static IIO_DEV_ATTR_VRMSOS(0644, 346 347 ade7753_read_16bit, 347 348 ade7753_write_16bit, 348 349 ADE7753_VRMSOS); 349 - static IIO_DEV_ATTR_WGAIN(S_IWUSR | S_IRUGO, 350 + static IIO_DEV_ATTR_WGAIN(0644, 350 351 ade7753_read_16bit, 351 352 ade7753_write_16bit, 352 353 ADE7753_WGAIN); 353 - static IIO_DEV_ATTR_VAGAIN(S_IWUSR | S_IRUGO, 354 + static IIO_DEV_ATTR_VAGAIN(0644, 354 355 ade7753_read_16bit, 355 356 ade7753_write_16bit, 356 357 ADE7753_VAGAIN); 357 - static IIO_DEV_ATTR_PGA_GAIN(S_IWUSR | S_IRUGO, 358 + static IIO_DEV_ATTR_PGA_GAIN(0644, 358 359 ade7753_read_16bit, 359 360 ade7753_write_16bit, 360 361 ADE7753_GAIN); 361 - static IIO_DEV_ATTR_IPKLVL(S_IWUSR | S_IRUGO, 362 + static IIO_DEV_ATTR_IPKLVL(0644, 362 363 ade7753_read_8bit, 363 364 ade7753_write_8bit, 364 365 ADE7753_IPKLVL); 365 - static IIO_DEV_ATTR_VPKLVL(S_IWUSR | S_IRUGO, 366 + static IIO_DEV_ATTR_VPKLVL(0644, 366 367 ade7753_read_8bit, 367 368 ade7753_write_8bit, 368 369 ADE7753_VPKLVL); 369 - static IIO_DEV_ATTR_IPEAK(S_IRUGO, 370 + static IIO_DEV_ATTR_IPEAK(0444, 370 371 ade7753_read_24bit, 371 372 NULL, 372 373 ADE7753_IPEAK); 373 - static IIO_DEV_ATTR_VPEAK(S_IRUGO, 374 + static IIO_DEV_ATTR_VPEAK(0444, 374 375 ade7753_read_24bit, 375 376 NULL, 376 377 ADE7753_VPEAK); 377 - static IIO_DEV_ATTR_VPERIOD(S_IRUGO, 378 + static IIO_DEV_ATTR_VPERIOD(0444, 378 379 ade7753_read_16bit, 379 380 NULL, 380 381 ADE7753_PERIOD); 381 - static IIO_DEV_ATTR_CH_OFF(1, S_IWUSR | S_IRUGO, 382 + static IIO_DEV_ATTR_CH_OFF(1, 0644, 382 383 ade7753_read_8bit, 383 384 ade7753_write_8bit, 384 385 ADE7753_CH1OS); 385 - static IIO_DEV_ATTR_CH_OFF(2, S_IWUSR | S_IRUGO, 386 + static IIO_DEV_ATTR_CH_OFF(2, 0644, 386 387 ade7753_read_8bit, 387 388 ade7753_write_8bit, 388 389 ADE7753_CH2OS); ··· 449 450 } 450 451 451 452 static ssize_t ade7753_read_frequency(struct device *dev, 452 - struct device_attribute *attr, 453 - char *buf) 453 + struct device_attribute *attr, 454 + char *buf) 454 455 { 455 456 int ret; 456 457 u16 t; ··· 467 468 } 468 469 469 470 static ssize_t ade7753_write_frequency(struct device *dev, 470 - struct device_attribute *attr, 471 - const char *buf, 472 - size_t len) 471 + struct device_attribute *attr, 472 + const char *buf, 473 + size_t len) 473 474 { 474 475 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 475 476 struct ade7753_state *st = iio_priv(indio_dev); ··· 513 514 static IIO_CONST_ATTR(in_temp_offset, "-25 C"); 514 515 static IIO_CONST_ATTR(in_temp_scale, "0.67 C"); 515 516 516 - static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, 517 + static IIO_DEV_ATTR_SAMP_FREQ(0644, 517 518 ade7753_read_frequency, 518 519 ade7753_write_frequency); 519 520
+28 -28
drivers/staging/iio/meter/ade7754.c
··· 316 316 static IIO_DEV_ATTR_LAENERGY(ade7754_read_24bit, ADE7754_LAENERGY); 317 317 static IIO_DEV_ATTR_VAENERGY(ade7754_read_24bit, ADE7754_VAENERGY); 318 318 static IIO_DEV_ATTR_LVAENERGY(ade7754_read_24bit, ADE7754_LVAENERGY); 319 - static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO, 319 + static IIO_DEV_ATTR_VPEAK(0644, 320 320 ade7754_read_8bit, 321 321 ade7754_write_8bit, 322 322 ADE7754_VPEAK); 323 - static IIO_DEV_ATTR_IPEAK(S_IWUSR | S_IRUGO, 323 + static IIO_DEV_ATTR_IPEAK(0644, 324 324 ade7754_read_8bit, 325 325 ade7754_write_8bit, 326 326 ADE7754_VPEAK); 327 - static IIO_DEV_ATTR_APHCAL(S_IWUSR | S_IRUGO, 327 + static IIO_DEV_ATTR_APHCAL(0644, 328 328 ade7754_read_8bit, 329 329 ade7754_write_8bit, 330 330 ADE7754_APHCAL); 331 - static IIO_DEV_ATTR_BPHCAL(S_IWUSR | S_IRUGO, 331 + static IIO_DEV_ATTR_BPHCAL(0644, 332 332 ade7754_read_8bit, 333 333 ade7754_write_8bit, 334 334 ADE7754_BPHCAL); 335 - static IIO_DEV_ATTR_CPHCAL(S_IWUSR | S_IRUGO, 335 + static IIO_DEV_ATTR_CPHCAL(0644, 336 336 ade7754_read_8bit, 337 337 ade7754_write_8bit, 338 338 ADE7754_CPHCAL); 339 - static IIO_DEV_ATTR_AAPOS(S_IWUSR | S_IRUGO, 339 + static IIO_DEV_ATTR_AAPOS(0644, 340 340 ade7754_read_16bit, 341 341 ade7754_write_16bit, 342 342 ADE7754_AAPOS); 343 - static IIO_DEV_ATTR_BAPOS(S_IWUSR | S_IRUGO, 343 + static IIO_DEV_ATTR_BAPOS(0644, 344 344 ade7754_read_16bit, 345 345 ade7754_write_16bit, 346 346 ADE7754_BAPOS); 347 - static IIO_DEV_ATTR_CAPOS(S_IWUSR | S_IRUGO, 347 + static IIO_DEV_ATTR_CAPOS(0644, 348 348 ade7754_read_16bit, 349 349 ade7754_write_16bit, 350 350 ADE7754_CAPOS); 351 - static IIO_DEV_ATTR_WDIV(S_IWUSR | S_IRUGO, 351 + static IIO_DEV_ATTR_WDIV(0644, 352 352 ade7754_read_8bit, 353 353 ade7754_write_8bit, 354 354 ADE7754_WDIV); 355 - static IIO_DEV_ATTR_VADIV(S_IWUSR | S_IRUGO, 355 + static IIO_DEV_ATTR_VADIV(0644, 356 356 ade7754_read_8bit, 357 357 ade7754_write_8bit, 358 358 ADE7754_VADIV); 359 - static IIO_DEV_ATTR_CFNUM(S_IWUSR | S_IRUGO, 359 + static IIO_DEV_ATTR_CFNUM(0644, 360 360 ade7754_read_16bit, 361 361 ade7754_write_16bit, 362 362 ADE7754_CFNUM); 363 - static IIO_DEV_ATTR_CFDEN(S_IWUSR | S_IRUGO, 363 + static IIO_DEV_ATTR_CFDEN(0644, 364 364 ade7754_read_16bit, 365 365 ade7754_write_16bit, 366 366 ADE7754_CFDEN); 367 - static IIO_DEV_ATTR_ACTIVE_POWER_A_GAIN(S_IWUSR | S_IRUGO, 367 + static IIO_DEV_ATTR_ACTIVE_POWER_A_GAIN(0644, 368 368 ade7754_read_16bit, 369 369 ade7754_write_16bit, 370 370 ADE7754_AAPGAIN); 371 - static IIO_DEV_ATTR_ACTIVE_POWER_B_GAIN(S_IWUSR | S_IRUGO, 371 + static IIO_DEV_ATTR_ACTIVE_POWER_B_GAIN(0644, 372 372 ade7754_read_16bit, 373 373 ade7754_write_16bit, 374 374 ADE7754_BAPGAIN); 375 - static IIO_DEV_ATTR_ACTIVE_POWER_C_GAIN(S_IWUSR | S_IRUGO, 375 + static IIO_DEV_ATTR_ACTIVE_POWER_C_GAIN(0644, 376 376 ade7754_read_16bit, 377 377 ade7754_write_16bit, 378 378 ADE7754_CAPGAIN); 379 - static IIO_DEV_ATTR_AIRMS(S_IRUGO, 379 + static IIO_DEV_ATTR_AIRMS(0444, 380 380 ade7754_read_24bit, 381 381 NULL, 382 382 ADE7754_AIRMS); 383 - static IIO_DEV_ATTR_BIRMS(S_IRUGO, 383 + static IIO_DEV_ATTR_BIRMS(0444, 384 384 ade7754_read_24bit, 385 385 NULL, 386 386 ADE7754_BIRMS); 387 - static IIO_DEV_ATTR_CIRMS(S_IRUGO, 387 + static IIO_DEV_ATTR_CIRMS(0444, 388 388 ade7754_read_24bit, 389 389 NULL, 390 390 ADE7754_CIRMS); 391 - static IIO_DEV_ATTR_AVRMS(S_IRUGO, 391 + static IIO_DEV_ATTR_AVRMS(0444, 392 392 ade7754_read_24bit, 393 393 NULL, 394 394 ADE7754_AVRMS); 395 - static IIO_DEV_ATTR_BVRMS(S_IRUGO, 395 + static IIO_DEV_ATTR_BVRMS(0444, 396 396 ade7754_read_24bit, 397 397 NULL, 398 398 ADE7754_BVRMS); 399 - static IIO_DEV_ATTR_CVRMS(S_IRUGO, 399 + static IIO_DEV_ATTR_CVRMS(0444, 400 400 ade7754_read_24bit, 401 401 NULL, 402 402 ADE7754_CVRMS); 403 - static IIO_DEV_ATTR_AIRMSOS(S_IRUGO, 403 + static IIO_DEV_ATTR_AIRMSOS(0444, 404 404 ade7754_read_16bit, 405 405 ade7754_write_16bit, 406 406 ADE7754_AIRMSOS); 407 - static IIO_DEV_ATTR_BIRMSOS(S_IRUGO, 407 + static IIO_DEV_ATTR_BIRMSOS(0444, 408 408 ade7754_read_16bit, 409 409 ade7754_write_16bit, 410 410 ADE7754_BIRMSOS); 411 - static IIO_DEV_ATTR_CIRMSOS(S_IRUGO, 411 + static IIO_DEV_ATTR_CIRMSOS(0444, 412 412 ade7754_read_16bit, 413 413 ade7754_write_16bit, 414 414 ADE7754_CIRMSOS); 415 - static IIO_DEV_ATTR_AVRMSOS(S_IRUGO, 415 + static IIO_DEV_ATTR_AVRMSOS(0444, 416 416 ade7754_read_16bit, 417 417 ade7754_write_16bit, 418 418 ADE7754_AVRMSOS); 419 - static IIO_DEV_ATTR_BVRMSOS(S_IRUGO, 419 + static IIO_DEV_ATTR_BVRMSOS(0444, 420 420 ade7754_read_16bit, 421 421 ade7754_write_16bit, 422 422 ADE7754_BVRMSOS); 423 - static IIO_DEV_ATTR_CVRMSOS(S_IRUGO, 423 + static IIO_DEV_ATTR_CVRMSOS(0444, 424 424 ade7754_read_16bit, 425 425 ade7754_write_16bit, 426 426 ADE7754_CVRMSOS); ··· 549 549 static IIO_CONST_ATTR(in_temp_offset, "129 C"); 550 550 static IIO_CONST_ATTR(in_temp_scale, "4 C"); 551 551 552 - static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, 552 + static IIO_DEV_ATTR_SAMP_FREQ(0644, 553 553 ade7754_read_frequency, 554 554 ade7754_write_frequency); 555 555
+25 -25
drivers/staging/iio/meter/ade7758_core.c
··· 301 301 return ret; 302 302 } 303 303 304 - static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO, 304 + static IIO_DEV_ATTR_VPEAK(0644, 305 305 ade7758_read_8bit, 306 306 ade7758_write_8bit, 307 307 ADE7758_VPEAK); 308 - static IIO_DEV_ATTR_IPEAK(S_IWUSR | S_IRUGO, 308 + static IIO_DEV_ATTR_IPEAK(0644, 309 309 ade7758_read_8bit, 310 310 ade7758_write_8bit, 311 311 ADE7758_VPEAK); 312 - static IIO_DEV_ATTR_APHCAL(S_IWUSR | S_IRUGO, 312 + static IIO_DEV_ATTR_APHCAL(0644, 313 313 ade7758_read_8bit, 314 314 ade7758_write_8bit, 315 315 ADE7758_APHCAL); 316 - static IIO_DEV_ATTR_BPHCAL(S_IWUSR | S_IRUGO, 316 + static IIO_DEV_ATTR_BPHCAL(0644, 317 317 ade7758_read_8bit, 318 318 ade7758_write_8bit, 319 319 ADE7758_BPHCAL); 320 - static IIO_DEV_ATTR_CPHCAL(S_IWUSR | S_IRUGO, 320 + static IIO_DEV_ATTR_CPHCAL(0644, 321 321 ade7758_read_8bit, 322 322 ade7758_write_8bit, 323 323 ADE7758_CPHCAL); 324 - static IIO_DEV_ATTR_WDIV(S_IWUSR | S_IRUGO, 324 + static IIO_DEV_ATTR_WDIV(0644, 325 325 ade7758_read_8bit, 326 326 ade7758_write_8bit, 327 327 ADE7758_WDIV); 328 - static IIO_DEV_ATTR_VADIV(S_IWUSR | S_IRUGO, 328 + static IIO_DEV_ATTR_VADIV(0644, 329 329 ade7758_read_8bit, 330 330 ade7758_write_8bit, 331 331 ADE7758_VADIV); 332 - static IIO_DEV_ATTR_AIRMS(S_IRUGO, 332 + static IIO_DEV_ATTR_AIRMS(0444, 333 333 ade7758_read_24bit, 334 334 NULL, 335 335 ADE7758_AIRMS); 336 - static IIO_DEV_ATTR_BIRMS(S_IRUGO, 336 + static IIO_DEV_ATTR_BIRMS(0444, 337 337 ade7758_read_24bit, 338 338 NULL, 339 339 ADE7758_BIRMS); 340 - static IIO_DEV_ATTR_CIRMS(S_IRUGO, 340 + static IIO_DEV_ATTR_CIRMS(0444, 341 341 ade7758_read_24bit, 342 342 NULL, 343 343 ADE7758_CIRMS); 344 - static IIO_DEV_ATTR_AVRMS(S_IRUGO, 344 + static IIO_DEV_ATTR_AVRMS(0444, 345 345 ade7758_read_24bit, 346 346 NULL, 347 347 ADE7758_AVRMS); 348 - static IIO_DEV_ATTR_BVRMS(S_IRUGO, 348 + static IIO_DEV_ATTR_BVRMS(0444, 349 349 ade7758_read_24bit, 350 350 NULL, 351 351 ADE7758_BVRMS); 352 - static IIO_DEV_ATTR_CVRMS(S_IRUGO, 352 + static IIO_DEV_ATTR_CVRMS(0444, 353 353 ade7758_read_24bit, 354 354 NULL, 355 355 ADE7758_CVRMS); 356 - static IIO_DEV_ATTR_AIRMSOS(S_IWUSR | S_IRUGO, 356 + static IIO_DEV_ATTR_AIRMSOS(0644, 357 357 ade7758_read_16bit, 358 358 ade7758_write_16bit, 359 359 ADE7758_AIRMSOS); 360 - static IIO_DEV_ATTR_BIRMSOS(S_IWUSR | S_IRUGO, 360 + static IIO_DEV_ATTR_BIRMSOS(0644, 361 361 ade7758_read_16bit, 362 362 ade7758_write_16bit, 363 363 ADE7758_BIRMSOS); 364 - static IIO_DEV_ATTR_CIRMSOS(S_IWUSR | S_IRUGO, 364 + static IIO_DEV_ATTR_CIRMSOS(0644, 365 365 ade7758_read_16bit, 366 366 ade7758_write_16bit, 367 367 ADE7758_CIRMSOS); 368 - static IIO_DEV_ATTR_AVRMSOS(S_IWUSR | S_IRUGO, 368 + static IIO_DEV_ATTR_AVRMSOS(0644, 369 369 ade7758_read_16bit, 370 370 ade7758_write_16bit, 371 371 ADE7758_AVRMSOS); 372 - static IIO_DEV_ATTR_BVRMSOS(S_IWUSR | S_IRUGO, 372 + static IIO_DEV_ATTR_BVRMSOS(0644, 373 373 ade7758_read_16bit, 374 374 ade7758_write_16bit, 375 375 ADE7758_BVRMSOS); 376 - static IIO_DEV_ATTR_CVRMSOS(S_IWUSR | S_IRUGO, 376 + static IIO_DEV_ATTR_CVRMSOS(0644, 377 377 ade7758_read_16bit, 378 378 ade7758_write_16bit, 379 379 ADE7758_CVRMSOS); 380 - static IIO_DEV_ATTR_AIGAIN(S_IWUSR | S_IRUGO, 380 + static IIO_DEV_ATTR_AIGAIN(0644, 381 381 ade7758_read_16bit, 382 382 ade7758_write_16bit, 383 383 ADE7758_AIGAIN); 384 - static IIO_DEV_ATTR_BIGAIN(S_IWUSR | S_IRUGO, 384 + static IIO_DEV_ATTR_BIGAIN(0644, 385 385 ade7758_read_16bit, 386 386 ade7758_write_16bit, 387 387 ADE7758_BIGAIN); 388 - static IIO_DEV_ATTR_CIGAIN(S_IWUSR | S_IRUGO, 388 + static IIO_DEV_ATTR_CIGAIN(0644, 389 389 ade7758_read_16bit, 390 390 ade7758_write_16bit, 391 391 ADE7758_CIGAIN); 392 - static IIO_DEV_ATTR_AVRMSGAIN(S_IWUSR | S_IRUGO, 392 + static IIO_DEV_ATTR_AVRMSGAIN(0644, 393 393 ade7758_read_16bit, 394 394 ade7758_write_16bit, 395 395 ADE7758_AVRMSGAIN); 396 - static IIO_DEV_ATTR_BVRMSGAIN(S_IWUSR | S_IRUGO, 396 + static IIO_DEV_ATTR_BVRMSGAIN(0644, 397 397 ade7758_read_16bit, 398 398 ade7758_write_16bit, 399 399 ADE7758_BVRMSGAIN); 400 - static IIO_DEV_ATTR_CVRMSGAIN(S_IWUSR | S_IRUGO, 400 + static IIO_DEV_ATTR_CVRMSGAIN(0644, 401 401 ade7758_read_16bit, 402 402 ade7758_write_16bit, 403 403 ADE7758_CVRMSGAIN);
+44 -44
drivers/staging/iio/meter/ade7854.c
··· 186 186 return st->write_reg_16(dev, ADE7854_CONFIG, val); 187 187 } 188 188 189 - static IIO_DEV_ATTR_AIGAIN(S_IWUSR | S_IRUGO, 189 + static IIO_DEV_ATTR_AIGAIN(0644, 190 190 ade7854_read_24bit, 191 191 ade7854_write_24bit, 192 192 ADE7854_AIGAIN); 193 - static IIO_DEV_ATTR_BIGAIN(S_IWUSR | S_IRUGO, 193 + static IIO_DEV_ATTR_BIGAIN(0644, 194 194 ade7854_read_24bit, 195 195 ade7854_write_24bit, 196 196 ADE7854_BIGAIN); 197 - static IIO_DEV_ATTR_CIGAIN(S_IWUSR | S_IRUGO, 197 + static IIO_DEV_ATTR_CIGAIN(0644, 198 198 ade7854_read_24bit, 199 199 ade7854_write_24bit, 200 200 ADE7854_CIGAIN); 201 - static IIO_DEV_ATTR_NIGAIN(S_IWUSR | S_IRUGO, 201 + static IIO_DEV_ATTR_NIGAIN(0644, 202 202 ade7854_read_24bit, 203 203 ade7854_write_24bit, 204 204 ADE7854_NIGAIN); 205 - static IIO_DEV_ATTR_AVGAIN(S_IWUSR | S_IRUGO, 205 + static IIO_DEV_ATTR_AVGAIN(0644, 206 206 ade7854_read_24bit, 207 207 ade7854_write_24bit, 208 208 ADE7854_AVGAIN); 209 - static IIO_DEV_ATTR_BVGAIN(S_IWUSR | S_IRUGO, 209 + static IIO_DEV_ATTR_BVGAIN(0644, 210 210 ade7854_read_24bit, 211 211 ade7854_write_24bit, 212 212 ADE7854_BVGAIN); 213 - static IIO_DEV_ATTR_CVGAIN(S_IWUSR | S_IRUGO, 213 + static IIO_DEV_ATTR_CVGAIN(0644, 214 214 ade7854_read_24bit, 215 215 ade7854_write_24bit, 216 216 ADE7854_CVGAIN); 217 - static IIO_DEV_ATTR_APPARENT_POWER_A_GAIN(S_IWUSR | S_IRUGO, 217 + static IIO_DEV_ATTR_APPARENT_POWER_A_GAIN(0644, 218 218 ade7854_read_24bit, 219 219 ade7854_write_24bit, 220 220 ADE7854_AVAGAIN); 221 - static IIO_DEV_ATTR_APPARENT_POWER_B_GAIN(S_IWUSR | S_IRUGO, 221 + static IIO_DEV_ATTR_APPARENT_POWER_B_GAIN(0644, 222 222 ade7854_read_24bit, 223 223 ade7854_write_24bit, 224 224 ADE7854_BVAGAIN); 225 - static IIO_DEV_ATTR_APPARENT_POWER_C_GAIN(S_IWUSR | S_IRUGO, 225 + static IIO_DEV_ATTR_APPARENT_POWER_C_GAIN(0644, 226 226 ade7854_read_24bit, 227 227 ade7854_write_24bit, 228 228 ADE7854_CVAGAIN); 229 - static IIO_DEV_ATTR_ACTIVE_POWER_A_OFFSET(S_IWUSR | S_IRUGO, 229 + static IIO_DEV_ATTR_ACTIVE_POWER_A_OFFSET(0644, 230 230 ade7854_read_24bit, 231 231 ade7854_write_24bit, 232 232 ADE7854_AWATTOS); 233 - static IIO_DEV_ATTR_ACTIVE_POWER_B_OFFSET(S_IWUSR | S_IRUGO, 233 + static IIO_DEV_ATTR_ACTIVE_POWER_B_OFFSET(0644, 234 234 ade7854_read_24bit, 235 235 ade7854_write_24bit, 236 236 ADE7854_BWATTOS); 237 - static IIO_DEV_ATTR_ACTIVE_POWER_C_OFFSET(S_IWUSR | S_IRUGO, 237 + static IIO_DEV_ATTR_ACTIVE_POWER_C_OFFSET(0644, 238 238 ade7854_read_24bit, 239 239 ade7854_write_24bit, 240 240 ADE7854_CWATTOS); 241 - static IIO_DEV_ATTR_REACTIVE_POWER_A_GAIN(S_IWUSR | S_IRUGO, 241 + static IIO_DEV_ATTR_REACTIVE_POWER_A_GAIN(0644, 242 242 ade7854_read_24bit, 243 243 ade7854_write_24bit, 244 244 ADE7854_AVARGAIN); 245 - static IIO_DEV_ATTR_REACTIVE_POWER_B_GAIN(S_IWUSR | S_IRUGO, 245 + static IIO_DEV_ATTR_REACTIVE_POWER_B_GAIN(0644, 246 246 ade7854_read_24bit, 247 247 ade7854_write_24bit, 248 248 ADE7854_BVARGAIN); 249 - static IIO_DEV_ATTR_REACTIVE_POWER_C_GAIN(S_IWUSR | S_IRUGO, 249 + static IIO_DEV_ATTR_REACTIVE_POWER_C_GAIN(0644, 250 250 ade7854_read_24bit, 251 251 ade7854_write_24bit, 252 252 ADE7854_CVARGAIN); 253 - static IIO_DEV_ATTR_REACTIVE_POWER_A_OFFSET(S_IWUSR | S_IRUGO, 253 + static IIO_DEV_ATTR_REACTIVE_POWER_A_OFFSET(0644, 254 254 ade7854_read_24bit, 255 255 ade7854_write_24bit, 256 256 ADE7854_AVAROS); 257 - static IIO_DEV_ATTR_REACTIVE_POWER_B_OFFSET(S_IWUSR | S_IRUGO, 257 + static IIO_DEV_ATTR_REACTIVE_POWER_B_OFFSET(0644, 258 258 ade7854_read_24bit, 259 259 ade7854_write_24bit, 260 260 ADE7854_BVAROS); 261 - static IIO_DEV_ATTR_REACTIVE_POWER_C_OFFSET(S_IWUSR | S_IRUGO, 261 + static IIO_DEV_ATTR_REACTIVE_POWER_C_OFFSET(0644, 262 262 ade7854_read_24bit, 263 263 ade7854_write_24bit, 264 264 ADE7854_CVAROS); 265 - static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO, 265 + static IIO_DEV_ATTR_VPEAK(0644, 266 266 ade7854_read_32bit, 267 267 ade7854_write_32bit, 268 268 ADE7854_VPEAK); 269 - static IIO_DEV_ATTR_IPEAK(S_IWUSR | S_IRUGO, 269 + static IIO_DEV_ATTR_IPEAK(0644, 270 270 ade7854_read_32bit, 271 271 ade7854_write_32bit, 272 272 ADE7854_VPEAK); 273 - static IIO_DEV_ATTR_APHCAL(S_IWUSR | S_IRUGO, 273 + static IIO_DEV_ATTR_APHCAL(0644, 274 274 ade7854_read_16bit, 275 275 ade7854_write_16bit, 276 276 ADE7854_APHCAL); 277 - static IIO_DEV_ATTR_BPHCAL(S_IWUSR | S_IRUGO, 277 + static IIO_DEV_ATTR_BPHCAL(0644, 278 278 ade7854_read_16bit, 279 279 ade7854_write_16bit, 280 280 ADE7854_BPHCAL); 281 - static IIO_DEV_ATTR_CPHCAL(S_IWUSR | S_IRUGO, 281 + static IIO_DEV_ATTR_CPHCAL(0644, 282 282 ade7854_read_16bit, 283 283 ade7854_write_16bit, 284 284 ADE7854_CPHCAL); 285 - static IIO_DEV_ATTR_CF1DEN(S_IWUSR | S_IRUGO, 285 + static IIO_DEV_ATTR_CF1DEN(0644, 286 286 ade7854_read_16bit, 287 287 ade7854_write_16bit, 288 288 ADE7854_CF1DEN); 289 - static IIO_DEV_ATTR_CF2DEN(S_IWUSR | S_IRUGO, 289 + static IIO_DEV_ATTR_CF2DEN(0644, 290 290 ade7854_read_16bit, 291 291 ade7854_write_16bit, 292 292 ADE7854_CF2DEN); 293 - static IIO_DEV_ATTR_CF3DEN(S_IWUSR | S_IRUGO, 293 + static IIO_DEV_ATTR_CF3DEN(0644, 294 294 ade7854_read_16bit, 295 295 ade7854_write_16bit, 296 296 ADE7854_CF3DEN); 297 - static IIO_DEV_ATTR_LINECYC(S_IWUSR | S_IRUGO, 297 + static IIO_DEV_ATTR_LINECYC(0644, 298 298 ade7854_read_16bit, 299 299 ade7854_write_16bit, 300 300 ADE7854_LINECYC); 301 - static IIO_DEV_ATTR_SAGCYC(S_IWUSR | S_IRUGO, 301 + static IIO_DEV_ATTR_SAGCYC(0644, 302 302 ade7854_read_8bit, 303 303 ade7854_write_8bit, 304 304 ADE7854_SAGCYC); 305 - static IIO_DEV_ATTR_CFCYC(S_IWUSR | S_IRUGO, 305 + static IIO_DEV_ATTR_CFCYC(0644, 306 306 ade7854_read_8bit, 307 307 ade7854_write_8bit, 308 308 ADE7854_CFCYC); 309 - static IIO_DEV_ATTR_PEAKCYC(S_IWUSR | S_IRUGO, 309 + static IIO_DEV_ATTR_PEAKCYC(0644, 310 310 ade7854_read_8bit, 311 311 ade7854_write_8bit, 312 312 ADE7854_PEAKCYC); ··· 318 318 ADE7854_ANGLE1); 319 319 static IIO_DEV_ATTR_ANGLE2(ade7854_read_24bit, 320 320 ADE7854_ANGLE2); 321 - static IIO_DEV_ATTR_AIRMS(S_IRUGO, 321 + static IIO_DEV_ATTR_AIRMS(0444, 322 322 ade7854_read_24bit, 323 323 NULL, 324 324 ADE7854_AIRMS); 325 - static IIO_DEV_ATTR_BIRMS(S_IRUGO, 325 + static IIO_DEV_ATTR_BIRMS(0444, 326 326 ade7854_read_24bit, 327 327 NULL, 328 328 ADE7854_BIRMS); 329 - static IIO_DEV_ATTR_CIRMS(S_IRUGO, 329 + static IIO_DEV_ATTR_CIRMS(0444, 330 330 ade7854_read_24bit, 331 331 NULL, 332 332 ADE7854_CIRMS); 333 - static IIO_DEV_ATTR_NIRMS(S_IRUGO, 333 + static IIO_DEV_ATTR_NIRMS(0444, 334 334 ade7854_read_24bit, 335 335 NULL, 336 336 ADE7854_NIRMS); 337 - static IIO_DEV_ATTR_AVRMS(S_IRUGO, 337 + static IIO_DEV_ATTR_AVRMS(0444, 338 338 ade7854_read_24bit, 339 339 NULL, 340 340 ADE7854_AVRMS); 341 - static IIO_DEV_ATTR_BVRMS(S_IRUGO, 341 + static IIO_DEV_ATTR_BVRMS(0444, 342 342 ade7854_read_24bit, 343 343 NULL, 344 344 ADE7854_BVRMS); 345 - static IIO_DEV_ATTR_CVRMS(S_IRUGO, 345 + static IIO_DEV_ATTR_CVRMS(0444, 346 346 ade7854_read_24bit, 347 347 NULL, 348 348 ADE7854_CVRMS); 349 - static IIO_DEV_ATTR_AIRMSOS(S_IRUGO, 349 + static IIO_DEV_ATTR_AIRMSOS(0444, 350 350 ade7854_read_16bit, 351 351 ade7854_write_16bit, 352 352 ADE7854_AIRMSOS); 353 - static IIO_DEV_ATTR_BIRMSOS(S_IRUGO, 353 + static IIO_DEV_ATTR_BIRMSOS(0444, 354 354 ade7854_read_16bit, 355 355 ade7854_write_16bit, 356 356 ADE7854_BIRMSOS); 357 - static IIO_DEV_ATTR_CIRMSOS(S_IRUGO, 357 + static IIO_DEV_ATTR_CIRMSOS(0444, 358 358 ade7854_read_16bit, 359 359 ade7854_write_16bit, 360 360 ADE7854_CIRMSOS); 361 - static IIO_DEV_ATTR_AVRMSOS(S_IRUGO, 361 + static IIO_DEV_ATTR_AVRMSOS(0444, 362 362 ade7854_read_16bit, 363 363 ade7854_write_16bit, 364 364 ADE7854_AVRMSOS); 365 - static IIO_DEV_ATTR_BVRMSOS(S_IRUGO, 365 + static IIO_DEV_ATTR_BVRMSOS(0444, 366 366 ade7854_read_16bit, 367 367 ade7854_write_16bit, 368 368 ADE7854_BVRMSOS); 369 - static IIO_DEV_ATTR_CVRMSOS(S_IRUGO, 369 + static IIO_DEV_ATTR_CVRMSOS(0444, 370 370 ade7854_read_16bit, 371 371 ade7854_write_16bit, 372 372 ADE7854_CVRMSOS);
+5
include/linux/hid-sensor-hub.h
··· 233 233 atomic_t user_requested_state; 234 234 int poll_interval; 235 235 int raw_hystersis; 236 + int latency_ms; 236 237 struct iio_trigger *trigger; 237 238 int timestamp_ns_scale; 238 239 struct hid_sensor_hub_attribute_info poll; 239 240 struct hid_sensor_hub_attribute_info report_state; 240 241 struct hid_sensor_hub_attribute_info power_state; 241 242 struct hid_sensor_hub_attribute_info sensitivity; 243 + struct hid_sensor_hub_attribute_info report_latency; 242 244 struct work_struct work; 243 245 }; 244 246 ··· 278 276 279 277 int64_t hid_sensor_convert_timestamp(struct hid_sensor_common *st, 280 278 int64_t raw_value); 279 + bool hid_sensor_batch_mode_supported(struct hid_sensor_common *st); 280 + int hid_sensor_set_report_latency(struct hid_sensor_common *st, int latency); 281 + int hid_sensor_get_report_latency(struct hid_sensor_common *st); 281 282 282 283 #endif
+5
include/linux/hid-sensor-ids.h
··· 90 90 #define HID_USAGE_SENSOR_ORIENT_TILT_Z 0x200481 91 91 92 92 #define HID_USAGE_SENSOR_DEVICE_ORIENTATION 0x20008A 93 + #define HID_USAGE_SENSOR_RELATIVE_ORIENTATION 0x20008E 94 + #define HID_USAGE_SENSOR_GEOMAGNETIC_ORIENTATION 0x2000C1 93 95 #define HID_USAGE_SENSOR_ORIENT_ROTATION_MATRIX 0x200482 94 96 #define HID_USAGE_SENSOR_ORIENT_QUATERNION 0x200483 95 97 #define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX 0x200484 ··· 151 149 #define HID_USAGE_SENSOR_PROP_RANGE_MINIMUM 0x200315 152 150 #define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316 153 151 #define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319 152 + 153 + /* Batch mode selectors */ 154 + #define HID_USAGE_SENSOR_PROP_REPORT_LATENCY 0x20031B 154 155 155 156 /* Per data field properties */ 156 157 #define HID_USAGE_SENSOR_DATA_MOD_NONE 0x00
+2
include/linux/iio/timer/stm32-timer-trigger.h
··· 10 10 #define _STM32_TIMER_TRIGGER_H_ 11 11 12 12 #define TIM1_TRGO "tim1_trgo" 13 + #define TIM1_TRGO2 "tim1_trgo2" 13 14 #define TIM1_CH1 "tim1_ch1" 14 15 #define TIM1_CH2 "tim1_ch2" 15 16 #define TIM1_CH3 "tim1_ch3" ··· 45 44 #define TIM7_TRGO "tim7_trgo" 46 45 47 46 #define TIM8_TRGO "tim8_trgo" 47 + #define TIM8_TRGO2 "tim8_trgo2" 48 48 #define TIM8_CH1 "tim8_ch1" 49 49 #define TIM8_CH2 "tim8_ch2" 50 50 #define TIM8_CH3 "tim8_ch3"
+2
include/linux/mfd/stm32-timers.h
··· 34 34 #define TIM_CR1_DIR BIT(4) /* Counter Direction */ 35 35 #define TIM_CR1_ARPE BIT(7) /* Auto-reload Preload Ena */ 36 36 #define TIM_CR2_MMS (BIT(4) | BIT(5) | BIT(6)) /* Master mode selection */ 37 + #define TIM_CR2_MMS2 GENMASK(23, 20) /* Master mode selection 2 */ 37 38 #define TIM_SMCR_SMS (BIT(0) | BIT(1) | BIT(2)) /* Slave mode selection */ 38 39 #define TIM_SMCR_TS (BIT(4) | BIT(5) | BIT(6)) /* Trigger selection */ 39 40 #define TIM_DIER_UIE BIT(0) /* Update interrupt */ ··· 61 60 62 61 #define MAX_TIM_PSC 0xFFFF 63 62 #define TIM_CR2_MMS_SHIFT 4 63 + #define TIM_CR2_MMS2_SHIFT 20 64 64 #define TIM_SMCR_TS_SHIFT 4 65 65 #define TIM_BDTR_BKF_MASK 0xF 66 66 #define TIM_BDTR_BKF_SHIFT 16
+1 -1
tools/iio/Makefile
··· 1 1 CC = $(CROSS_COMPILE)gcc 2 - CFLAGS += -Wall -g -D_GNU_SOURCE 2 + CFLAGS += -Wall -g -D_GNU_SOURCE -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include 3 3 4 4 BINDIR=usr/bin 5 5 INSTALL_PROGRAM=install -m 755 -p
+1 -1
tools/iio/iio_utils.h
··· 13 13 #include <stdint.h> 14 14 15 15 /* Made up value to limit allocation sizes */ 16 - #define IIO_MAX_NAME_LENGTH 30 16 + #define IIO_MAX_NAME_LENGTH 64 17 17 18 18 #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements" 19 19 #define FORMAT_TYPE_FILE "%s_type"