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

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

Jonathan writes:

1st set of IIO new device support, features and cleanup for the 6.5 cycle.

New device support
- honeywell,mprls0025pa
* New driver and dt-bindings for this series of pressure sensors.
- invensense,mpu6050
* Add support for ICM 20600 IMU (ID, bindings and device data).
- melexis,mlx90614
* Add support for mlx90615 Infra Red Thermometer after driver cleanup
and refactoring to support the differences in this device.
- renesas,x9250
* New driver and bindings for this quad potentiometer.
- rockchip,saradc
* Add support for RK3588. Also included is a bunch of refactoring and
cleanup for that driver.
- rohm,bu27008
* New driver bindings etc for this 5 photodiode color sensor.
- st,lsm9ds0/st,st-sensors
* ID added for LSM303D accelerometer and magnetometer including ACPI binding.
- ti,opt4001
* New driver and bindings for this ambient light sensor.

Features
- core
* Introduce iio_validate_own_trigger() for cases where a driver can only
consumer a trigger it registered (detected via same parent device).
Use it in the kionix,kx022a driver and new rohm,by27008 driver.
- dynaimage,al3320a
* ACPI binding CALS0001 seen on Lenovo Yoga Table 2 devices.
- kionix,kx002a
* Enable asynchronous probe.
- rohm,bu27034
* Enable asynchronous probe.
- ti,tmp006
* Explicit support for DT including binding documentation.

Cleanups, minor fixes and misc improvements.
- treewide
* Switch I2C drivers from probe_new() back to probe() - part of the
long process of getting rid of a parameter from probe()
* Various whitespace and typo fixes not otherwise called out.
- core
* industrialio-buffer,Style cleanup.
* Add documentation to extend_name field of struct iio_chan_spec to
direct people using it towards the label infrastructure instead.
extend_name was a design mistake a long time back so directly people
away from it may be useful.
- adi,ad7606
* Add HAS_IOPORT dependency to prepare for some Kconfig changes.
- bosch,bma400
* Drop pointless print of ret in a dev_err_probe() message.
- invensense,icm42600
* Rework timestamp handling to reduce jitter.
- mediatek,mt7986-auxdac
* Add DT binding for this part.
- qcom,spmi-vadc
* Allow for 1/16th prescaling used on a few devices.
* Various changes to channel labeling and naming, including dropping
use of fwnode_name which generates odd channel names. Small ABI
change as a result, but not thought to be a problem for users of this
platform.
- st,lsm6dsx
* dt-binding: Use common schema for mount-matrix via a reference.
- st,stm32
* Add a debug print for when legacy channel config is used.
- ti,palmas-adc
* Drop unused i2c.h include.

* tag 'iio-for-6.5a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (59 commits)
dt-bindings: iio: rockchip: Fix 'oneOf' condition failed warning
dt-bindings: iio: afe: voltage-divider: Spelling s/curcuit/circuit/
dt-bindings: iio: adc: Add rockchip,rk3588-saradc string
iio: adc: rockchip_saradc: Use dev_err_probe
iio: adc: rockchip_saradc: Match alignment with open parenthesis
iio: adc: rockchip_saradc: Use of_device_get_match_data
iio: adc: rockchip_saradc: Make use of devm_clk_get_enabled
iio: adc: rockchip_saradc: Add support for RK3588
iio: adc: rockchip_saradc: Add callback functions
iio: temperature: tmp006: Add OF device matching support
dt-bindings: iio: temperature: Add support for tmp006
staging: iio: Switch i2c drivers back to use .probe()
iio: amplifiers: ad8366 Fix whitespace issue
iio: imu: inv_icm42600: avoid frequent timestamp jitter
MAINTAINERS: Add ROHM BU27008
iio: light: ROHM BU27008 color sensor
iio: kx022a: Use new iio_validate_own_trigger()
iio: trigger: Add simple trigger_validation helper
dt-bindings: iio: light: ROHM BU27008
iio: mlx90614: Add MLX90615 support
...

+3314 -474
+1
Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml
··· 26 26 - mediatek,mt2712-auxadc 27 27 - mediatek,mt6765-auxadc 28 28 - mediatek,mt7622-auxadc 29 + - mediatek,mt7986-auxadc 29 30 - mediatek,mt8173-auxadc 30 31 - items: 31 32 - enum:
+15 -13
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
··· 54 54 - '#io-channel-cells' 55 55 56 56 patternProperties: 57 - "^.*@[0-9a-f]+$": 57 + "^channel@[0-9a-f]+$": 58 58 type: object 59 59 additionalProperties: false 60 60 description: | ··· 101 101 oneOf: 102 102 - items: 103 103 - const: 1 104 - - enum: [ 1, 3, 4, 6, 20, 8, 10 ] 104 + - enum: [ 1, 3, 4, 6, 20, 8, 10, 16 ] 105 105 - items: 106 106 - const: 10 107 107 - const: 81 ··· 148 148 149 149 then: 150 150 patternProperties: 151 - "^.*@[0-9a-f]+$": 151 + "^channel@[0-9a-f]+$": 152 152 properties: 153 153 qcom,decimation: 154 154 enum: [ 512, 1024, 2048, 4096 ] ··· 171 171 172 172 then: 173 173 patternProperties: 174 - "^.*@[0-9a-f]+$": 174 + "^channel@[0-9a-f]+$": 175 175 properties: 176 176 qcom,decimation: 177 177 enum: [ 256, 512, 1024 ] ··· 194 194 195 195 then: 196 196 patternProperties: 197 - "^.*@[0-9a-f]+$": 197 + "^channel@[0-9a-f]+$": 198 198 properties: 199 199 qcom,decimation: 200 200 enum: [ 250, 420, 840 ] ··· 217 217 218 218 then: 219 219 patternProperties: 220 - "^.*@[0-9a-f]+$": 220 + "^channel@[0-9a-f]+$": 221 221 properties: 222 222 qcom,decimation: 223 223 enum: [ 85, 340, 1360 ] ··· 249 249 #io-channel-cells = <1>; 250 250 251 251 /* Channel node */ 252 - adc-chan@39 { 252 + channel@39 { 253 253 reg = <0x39>; 254 254 qcom,decimation = <512>; 255 255 qcom,ratiometric; ··· 258 258 qcom,pre-scaling = <1 3>; 259 259 }; 260 260 261 - adc-chan@9 { 261 + channel@9 { 262 262 reg = <0x9>; 263 263 }; 264 264 265 - adc-chan@a { 265 + channel@a { 266 266 reg = <0xa>; 267 267 }; 268 268 269 - adc-chan@e { 269 + channel@e { 270 270 reg = <0xe>; 271 271 }; 272 272 273 - adc-chan@f { 273 + channel@f { 274 274 reg = <0xf>; 275 275 }; 276 276 }; ··· 292 292 #io-channel-cells = <1>; 293 293 294 294 /* Other properties are omitted */ 295 - xo-therm@44 { 295 + channel@44 { 296 296 reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>; 297 297 qcom,ratiometric; 298 298 qcom,hw-settle-time = <200>; 299 + label = "xo_therm"; 299 300 }; 300 301 301 - conn-therm@47 { 302 + channel@47 { 302 303 reg = <PM8350_ADC7_AMUX_THM4_100K_PU(1)>; 303 304 qcom,ratiometric; 304 305 qcom,hw-settle-time = <200>; 306 + label = "conn_therm"; 305 307 }; 306 308 }; 307 309 };
+1
Documentation/devicetree/bindings/iio/adc/rockchip-saradc.yaml
··· 15 15 - const: rockchip,saradc 16 16 - const: rockchip,rk3066-tsadc 17 17 - const: rockchip,rk3399-saradc 18 + - const: rockchip,rk3588-saradc 18 19 - items: 19 20 - enum: 20 21 - rockchip,px30-saradc
+1 -1
Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml
··· 13 13 When an io-channel measures the midpoint of a voltage divider, the 14 14 interesting voltage is often the voltage over the full resistance 15 15 of the divider. This binding describes the voltage divider in such 16 - a curcuit. 16 + a circuit. 17 17 18 18 Vin ----. 19 19 |
+3
Documentation/devicetree/bindings/iio/imu/invensense,mpu6050.yaml
··· 31 31 - invensense,mpu9250 32 32 - invensense,mpu9255 33 33 - items: 34 + - const: invensense,icm20600 35 + - const: invensense,icm20602 36 + - items: 34 37 - const: invensense,icm20608d 35 38 - const: invensense,icm20608 36 39
+1
Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml
··· 98 98 - reg 99 99 100 100 allOf: 101 + - $ref: /schemas/iio/iio.yaml# 101 102 - $ref: /schemas/spi/spi-peripheral-props.yaml# 102 103 103 104 unevaluatedProperties: false
+49
Documentation/devicetree/bindings/iio/light/rohm,bu27008.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/iio/light/rohm,bu27008.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: ROHM BU27008 color sensor 8 + 9 + maintainers: 10 + - Matti Vaittinen <mazziesaccount@gmail.com> 11 + 12 + description: 13 + The ROHM BU27008 is a sensor with 5 photodiodes (red, green, blue, clear 14 + and IR) with four configurable channels. Red and green being always 15 + available and two out of the rest three (blue, clear, IR) can be 16 + selected to be simultaneously measured. Typical application is adjusting 17 + LCD backlight of TVs, mobile phones and tablet PCs. 18 + 19 + properties: 20 + compatible: 21 + const: rohm,bu27008 22 + 23 + reg: 24 + maxItems: 1 25 + 26 + interrupts: 27 + maxItems: 1 28 + 29 + vdd-supply: true 30 + 31 + required: 32 + - compatible 33 + - reg 34 + 35 + additionalProperties: false 36 + 37 + examples: 38 + - | 39 + i2c { 40 + #address-cells = <1>; 41 + #size-cells = <0>; 42 + 43 + light-sensor@38 { 44 + compatible = "rohm,bu27008"; 45 + reg = <0x38>; 46 + }; 47 + }; 48 + 49 + ...
+68
Documentation/devicetree/bindings/iio/light/ti,opt4001.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/iio/light/ti,opt4001.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Texas Instruments OPT4001 Ambient Light Sensor 8 + 9 + maintainers: 10 + - Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com> 11 + 12 + description: 13 + Ambient light sensor with an i2c interface. 14 + Last part of compatible is for the packaging used. 15 + Picostar is a 4 pinned SMT and sot-5x3 is a 8 pinned SOT. 16 + https://www.ti.com/lit/gpn/opt4001 17 + 18 + properties: 19 + compatible: 20 + enum: 21 + - ti,opt4001-picostar 22 + - ti,opt4001-sot-5x3 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + interrupts: 28 + maxItems: 1 29 + 30 + vdd-supply: 31 + description: Regulator that provides power to the sensor 32 + 33 + required: 34 + - compatible 35 + - reg 36 + 37 + allOf: 38 + - if: 39 + properties: 40 + compatible: 41 + contains: 42 + const: ti,opt4001-sot-5x3 43 + then: 44 + properties: 45 + interrupts: 46 + maxItems: 1 47 + else: 48 + properties: 49 + interrupts: false 50 + 51 + additionalProperties: false 52 + 53 + examples: 54 + - | 55 + #include <dt-bindings/interrupt-controller/irq.h> 56 + i2c { 57 + #address-cells = <1>; 58 + #size-cells = <0>; 59 + 60 + light-sensor@44 { 61 + compatible = "ti,opt4001-sot-5x3"; 62 + reg = <0x44>; 63 + vdd-supply = <&vdd_reg>; 64 + interrupt-parent = <&gpio1>; 65 + interrupts = <28 IRQ_TYPE_EDGE_FALLING>; 66 + }; 67 + }; 68 + ...
+78
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/iio/potentiometer/renesas,x9250.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Renesas X9250 quad potentiometers 8 + 9 + maintainers: 10 + - Herve Codina <herve.codina@bootlin.com> 11 + 12 + description: 13 + The Renesas X9250 integrates four digitally controlled potentiometers. 14 + On each potentiometer, the X9250T has a 100 kOhms total resistance and the 15 + X9250U has a 50 kOhms total resistance. 16 + 17 + allOf: 18 + - $ref: /schemas/spi/spi-peripheral-props.yaml 19 + 20 + properties: 21 + compatible: 22 + enum: 23 + - renesas,x9250t 24 + - renesas,x9250u 25 + 26 + reg: 27 + maxItems: 1 28 + 29 + vcc-supply: 30 + description: 31 + Regulator for the VCC power supply. 32 + 33 + avp-supply: 34 + description: 35 + Regulator for the analog V+ power supply. 36 + 37 + avn-supply: 38 + description: 39 + Regulator for the analog V- power supply. 40 + 41 + '#io-channel-cells': 42 + const: 1 43 + 44 + spi-max-frequency: 45 + maximum: 2000000 46 + 47 + wp-gpios: 48 + maxItems: 1 49 + description: 50 + GPIO connected to the write-protect pin. 51 + 52 + required: 53 + - compatible 54 + - reg 55 + - vcc-supply 56 + - avp-supply 57 + - avn-supply 58 + - '#io-channel-cells' 59 + 60 + unevaluatedProperties: false 61 + 62 + examples: 63 + - | 64 + #include <dt-bindings/gpio/gpio.h> 65 + spi { 66 + #address-cells = <1>; 67 + #size-cells = <0>; 68 + potentiometer@0 { 69 + compatible = "renesas,x9250t"; 70 + reg = <0>; 71 + vcc-supply = <&vcc_regulator>; 72 + avp-supply = <&avp_regulator>; 73 + avn-supply = <&avp_regulator>; 74 + wp-gpios = <&gpio 1 GPIO_ACTIVE_LOW>; 75 + spi-max-frequency = <2000000>; 76 + #io-channel-cells = <1>; 77 + }; 78 + };
+104
Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/iio/pressure/honeywell,mprls0025pa.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Honeywell mprls0025pa pressure sensor 8 + 9 + maintainers: 10 + - Andreas Klinger <ak@it-klinger.de> 11 + 12 + description: | 13 + Honeywell pressure sensor of model mprls0025pa. 14 + 15 + This sensor has an I2C and SPI interface. Only the I2C interface is 16 + implemented. 17 + 18 + There are many models with different pressure ranges available. The vendor 19 + calls them "mpr series". All of them have the identical programming model and 20 + differ in the pressure range, unit and transfer function. 21 + 22 + To support different models one need to specify the pressure range as well as 23 + the transfer function. Pressure range needs to be converted from its unit to 24 + pascal. 25 + 26 + The transfer function defines the ranges of numerical values delivered by the 27 + sensor. The minimal range value stands for the minimum pressure and the 28 + maximum value also for the maximum pressure with linear relation inside the 29 + range. 30 + 31 + Specifications about the devices can be found at: 32 + https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/ 33 + products/sensors/pressure-sensors/board-mount-pressure-sensors/ 34 + micropressure-mpr-series/documents/ 35 + sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf 36 + 37 + properties: 38 + compatible: 39 + const: honeywell,mprls0025pa 40 + 41 + reg: 42 + maxItems: 1 43 + 44 + interrupts: 45 + maxItems: 1 46 + 47 + reset-gpios: 48 + description: 49 + Optional GPIO for resetting the device. 50 + If not present the device is not resetted during the probe. 51 + maxItems: 1 52 + 53 + honeywell,pmin-pascal: 54 + description: 55 + Minimum pressure value the sensor can measure in pascal. 56 + $ref: /schemas/types.yaml#/definitions/uint32 57 + 58 + honeywell,pmax-pascal: 59 + description: 60 + Maximum pressure value the sensor can measure in pascal. 61 + $ref: /schemas/types.yaml#/definitions/uint32 62 + 63 + honeywell,transfer-function: 64 + description: | 65 + Transfer function which defines the range of valid values delivered by the 66 + sensor. 67 + 1 - A, 10% to 90% of 2^24 (1677722 .. 15099494) 68 + 2 - B, 2.5% to 22.5% of 2^24 (419430 .. 3774874) 69 + 3 - C, 20% to 80% of 2^24 (3355443 .. 13421773) 70 + $ref: /schemas/types.yaml#/definitions/uint32 71 + 72 + vdd-supply: 73 + description: provide VDD power to the sensor. 74 + 75 + required: 76 + - compatible 77 + - reg 78 + - honeywell,pmin-pascal 79 + - honeywell,pmax-pascal 80 + - honeywell,transfer-function 81 + - vdd-supply 82 + 83 + additionalProperties: false 84 + 85 + examples: 86 + - | 87 + #include <dt-bindings/gpio/gpio.h> 88 + #include <dt-bindings/interrupt-controller/irq.h> 89 + i2c { 90 + #address-cells = <1>; 91 + #size-cells = <0>; 92 + 93 + pressure@18 { 94 + compatible = "honeywell,mprls0025pa"; 95 + reg = <0x18>; 96 + reset-gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>; 97 + interrupt-parent = <&gpio3>; 98 + interrupts = <21 IRQ_TYPE_EDGE_FALLING>; 99 + honeywell,pmin-pascal = <0>; 100 + honeywell,pmax-pascal = <172369>; 101 + honeywell,transfer-function = <1>; 102 + vdd-supply = <&vcc_3v3>; 103 + }; 104 + };
+1
Documentation/devicetree/bindings/iio/st,st-sensors.yaml
··· 84 84 - st,lps35hw 85 85 - description: IMUs 86 86 enum: 87 + - st,lsm303d-imu 87 88 - st,lsm9ds0-imu 88 89 - description: Deprecated bindings 89 90 enum:
+4 -2
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90614.yaml
··· 4 4 $id: http://devicetree.org/schemas/iio/temperature/melexis,mlx90614.yaml# 5 5 $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 - title: Melexis MLX90614 contactless IR temperature sensor 7 + title: Melexis MLX90614/MLX90615 contactless IR temperature sensor 8 8 9 9 maintainers: 10 10 - Peter Meerwald <pmeerw@pmeerw.net> ··· 15 15 16 16 properties: 17 17 compatible: 18 - const: melexis,mlx90614 18 + enum: 19 + - melexis,mlx90614 20 + - melexis,mlx90615 19 21 20 22 reg: 21 23 maxItems: 1
+42
Documentation/devicetree/bindings/iio/temperature/ti,tmp006.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/iio/temperature/ti,tmp006.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: TI TMP006 IR thermopile sensor 8 + 9 + maintainers: 10 + - Peter Meerwald <pmeerw@pmeerw.net> 11 + 12 + description: | 13 + TI TMP006 - Infrared Thermopile Sensor in Chip-Scale Package. 14 + https://cdn.sparkfun.com/datasheets/Sensors/Temp/tmp006.pdf 15 + 16 + properties: 17 + compatible: 18 + const: ti,tmp006 19 + 20 + reg: 21 + maxItems: 1 22 + 23 + vdd-supply: 24 + description: provide VDD power to the sensor. 25 + 26 + required: 27 + - compatible 28 + - reg 29 + 30 + additionalProperties: false 31 + 32 + examples: 33 + - | 34 + i2c { 35 + #address-cells = <1>; 36 + #size-cells = <0>; 37 + temperature-sensor@40 { 38 + compatible = "ti,tmp006"; 39 + reg = <0x40>; 40 + vdd-supply = <&ldo4_reg>; 41 + }; 42 + };
+16 -1
MAINTAINERS
··· 9418 9418 F: mm/hmm* 9419 9419 F: tools/testing/selftests/mm/*hmm* 9420 9420 9421 + HONEYWELL MPRLS0025PA PRESSURE SENSOR SERIES IIO DRIVER 9422 + M: Andreas Klinger <ak@it-klinger.de> 9423 + L: linux-iio@vger.kernel.org 9424 + S: Maintained 9425 + F: Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml 9426 + F: drivers/iio/pressure/mprls0025pa.c 9427 + 9421 9428 HOST AP DRIVER 9422 9429 M: Jouni Malinen <j@w1.fi> 9423 9430 L: linux-wireless@vger.kernel.org ··· 18057 18050 F: Documentation/devicetree/bindings/clock/renesas,versaclock7.yaml 18058 18051 F: drivers/clk/clk-versaclock7.c 18059 18052 18053 + RENESAS X9250 DIGITAL POTENTIOMETERS DRIVER 18054 + M: Herve Codina <herve.codina@bootlin.com> 18055 + L: linux-iio@vger.kernel.org 18056 + S: Maintained 18057 + F: Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml 18058 + F: drivers/iio/potentiometer/x9250.c 18059 + 18060 18060 RESET CONTROLLER FRAMEWORK 18061 18061 M: Philipp Zabel <p.zabel@pengutronix.de> 18062 18062 S: Maintained ··· 18266 18252 F: Documentation/devicetree/bindings/iio/light/bh1750.yaml 18267 18253 F: drivers/iio/light/bh1750.c 18268 18254 18269 - ROHM BU27034 AMBIENT LIGHT SENSOR DRIVER 18255 + ROHM BU270xx LIGHT SENSOR DRIVERs 18270 18256 M: Matti Vaittinen <mazziesaccount@gmail.com> 18271 18257 L: linux-iio@vger.kernel.org 18272 18258 S: Supported 18259 + F: drivers/iio/light/rohm-bu27008.c 18273 18260 F: drivers/iio/light/rohm-bu27034.c 18274 18261 18275 18262 ROHM MULTIFUNCTION BD9571MWV-M PMIC DEVICE DRIVERS
+1 -1
drivers/iio/accel/adxl313_i2c.c
··· 85 85 .name = "adxl313_i2c", 86 86 .of_match_table = adxl313_of_match, 87 87 }, 88 - .probe_new = adxl313_i2c_probe, 88 + .probe = adxl313_i2c_probe, 89 89 .id_table = adxl313_i2c_id, 90 90 }; 91 91
+1 -1
drivers/iio/accel/adxl345_i2c.c
··· 56 56 .of_match_table = adxl345_of_match, 57 57 .acpi_match_table = adxl345_acpi_match, 58 58 }, 59 - .probe_new = adxl345_i2c_probe, 59 + .probe = adxl345_i2c_probe, 60 60 .id_table = adxl345_i2c_id, 61 61 }; 62 62 module_i2c_driver(adxl345_i2c_driver);
+1 -1
drivers/iio/accel/adxl355_i2c.c
··· 68 68 .name = "adxl355_i2c", 69 69 .of_match_table = adxl355_of_match, 70 70 }, 71 - .probe_new = adxl355_i2c_probe, 71 + .probe = adxl355_i2c_probe, 72 72 .id_table = adxl355_i2c_id, 73 73 }; 74 74 module_i2c_driver(adxl355_i2c_driver);
+1 -1
drivers/iio/accel/adxl367_i2c.c
··· 77 77 .name = "adxl367_i2c", 78 78 .of_match_table = adxl367_of_match, 79 79 }, 80 - .probe_new = adxl367_i2c_probe, 80 + .probe = adxl367_i2c_probe, 81 81 .id_table = adxl367_i2c_id, 82 82 }; 83 83
+1 -1
drivers/iio/accel/adxl372_i2c.c
··· 58 58 .name = "adxl372_i2c", 59 59 .of_match_table = adxl372_of_match, 60 60 }, 61 - .probe_new = adxl372_i2c_probe, 61 + .probe = adxl372_i2c_probe, 62 62 .id_table = adxl372_i2c_id, 63 63 }; 64 64
+1 -1
drivers/iio/accel/bma180.c
··· 1134 1134 .pm = pm_sleep_ptr(&bma180_pm_ops), 1135 1135 .of_match_table = bma180_of_match, 1136 1136 }, 1137 - .probe_new = bma180_probe, 1137 + .probe = bma180_probe, 1138 1138 .remove = bma180_remove, 1139 1139 .id_table = bma180_ids, 1140 1140 };
+1 -2
drivers/iio/accel/bma400_core.c
··· 868 868 ARRAY_SIZE(regulator_names), 869 869 regulator_names); 870 870 if (ret) 871 - return dev_err_probe(data->dev, ret, "Failed to get regulators: %d\n", 872 - ret); 871 + return dev_err_probe(data->dev, ret, "Failed to get regulators\n"); 873 872 874 873 /* Try to read chip_id register. It must return 0x90. */ 875 874 ret = regmap_read(data->regmap, BMA400_CHIP_ID_REG, &val);
+1 -1
drivers/iio/accel/bma400_i2c.c
··· 44 44 .name = "bma400", 45 45 .of_match_table = bma400_of_i2c_match, 46 46 }, 47 - .probe_new = bma400_i2c_probe, 47 + .probe = bma400_i2c_probe, 48 48 .id_table = bma400_i2c_ids, 49 49 }; 50 50
+1 -1
drivers/iio/accel/bmc150-accel-i2c.c
··· 269 269 .acpi_match_table = ACPI_PTR(bmc150_accel_acpi_match), 270 270 .pm = &bmc150_accel_pm_ops, 271 271 }, 272 - .probe_new = bmc150_accel_probe, 272 + .probe = bmc150_accel_probe, 273 273 .remove = bmc150_accel_remove, 274 274 .id_table = bmc150_accel_id, 275 275 };
+1 -1
drivers/iio/accel/da280.c
··· 184 184 .acpi_match_table = ACPI_PTR(da280_acpi_match), 185 185 .pm = pm_sleep_ptr(&da280_pm_ops), 186 186 }, 187 - .probe_new = da280_probe, 187 + .probe = da280_probe, 188 188 .id_table = da280_i2c_id, 189 189 }; 190 190
+1 -1
drivers/iio/accel/da311.c
··· 278 278 .name = "da311", 279 279 .pm = pm_sleep_ptr(&da311_pm_ops), 280 280 }, 281 - .probe_new = da311_probe, 281 + .probe = da311_probe, 282 282 .id_table = da311_i2c_id, 283 283 }; 284 284
+1 -1
drivers/iio/accel/dmard06.c
··· 217 217 MODULE_DEVICE_TABLE(of, dmard06_of_match); 218 218 219 219 static struct i2c_driver dmard06_driver = { 220 - .probe_new = dmard06_probe, 220 + .probe = dmard06_probe, 221 221 .id_table = dmard06_id, 222 222 .driver = { 223 223 .name = DMARD06_DRV_NAME,
+1 -1
drivers/iio/accel/dmard09.c
··· 135 135 .driver = { 136 136 .name = DMARD09_DRV_NAME 137 137 }, 138 - .probe_new = dmard09_probe, 138 + .probe = dmard09_probe, 139 139 .id_table = dmard09_id, 140 140 }; 141 141
+1 -1
drivers/iio/accel/dmard10.c
··· 241 241 .name = "dmard10", 242 242 .pm = pm_sleep_ptr(&dmard10_pm_ops), 243 243 }, 244 - .probe_new = dmard10_probe, 244 + .probe = dmard10_probe, 245 245 .id_table = dmard10_i2c_id, 246 246 }; 247 247
+1 -1
drivers/iio/accel/fxls8962af-i2c.c
··· 47 47 .of_match_table = fxls8962af_of_match, 48 48 .pm = pm_ptr(&fxls8962af_pm_ops), 49 49 }, 50 - .probe_new = fxls8962af_probe, 50 + .probe = fxls8962af_probe, 51 51 .id_table = fxls8962af_id, 52 52 }; 53 53 module_i2c_driver(fxls8962af_driver);
+2 -1
drivers/iio/accel/kionix-kx022a-i2c.c
··· 40 40 .driver = { 41 41 .name = "kx022a-i2c", 42 42 .of_match_table = kx022a_of_match, 43 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 43 44 }, 44 - .probe_new = kx022a_i2c_probe, 45 + .probe = kx022a_i2c_probe, 45 46 }; 46 47 module_i2c_driver(kx022a_i2c_driver); 47 48
+1
drivers/iio/accel/kionix-kx022a-spi.c
··· 46 46 .driver = { 47 47 .name = "kx022a-spi", 48 48 .of_match_table = kx022a_of_match, 49 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 49 50 }, 50 51 .probe = kx022a_spi_probe, 51 52 .id_table = kx022a_id,
+1 -12
drivers/iio/accel/kionix-kx022a.c
··· 516 516 return -EINVAL; 517 517 }; 518 518 519 - static int kx022a_validate_trigger(struct iio_dev *idev, 520 - struct iio_trigger *trig) 521 - { 522 - struct kx022a_data *data = iio_priv(idev); 523 - 524 - if (data->trig != trig) 525 - return -EINVAL; 526 - 527 - return 0; 528 - } 529 - 530 519 static int kx022a_set_watermark(struct iio_dev *idev, unsigned int val) 531 520 { 532 521 struct kx022a_data *data = iio_priv(idev); ··· 714 725 .write_raw = &kx022a_write_raw, 715 726 .read_avail = &kx022a_read_avail, 716 727 717 - .validate_trigger = kx022a_validate_trigger, 728 + .validate_trigger = iio_validate_own_trigger, 718 729 .hwfifo_set_watermark = kx022a_set_watermark, 719 730 .hwfifo_flush_to_buffer = kx022a_fifo_flush, 720 731 };
+1 -1
drivers/iio/accel/kxcjk-1013.c
··· 1732 1732 .of_match_table = kxcjk1013_of_match, 1733 1733 .pm = &kxcjk1013_pm_ops, 1734 1734 }, 1735 - .probe_new = kxcjk1013_probe, 1735 + .probe = kxcjk1013_probe, 1736 1736 .remove = kxcjk1013_remove, 1737 1737 .id_table = kxcjk1013_id, 1738 1738 };
+1 -1
drivers/iio/accel/kxsd9-i2c.c
··· 54 54 .of_match_table = kxsd9_of_match, 55 55 .pm = pm_ptr(&kxsd9_dev_pm_ops), 56 56 }, 57 - .probe_new = kxsd9_i2c_probe, 57 + .probe = kxsd9_i2c_probe, 58 58 .remove = kxsd9_i2c_remove, 59 59 .id_table = kxsd9_i2c_id, 60 60 };
+1 -1
drivers/iio/accel/mc3230.c
··· 190 190 .name = "mc3230", 191 191 .pm = pm_sleep_ptr(&mc3230_pm_ops), 192 192 }, 193 - .probe_new = mc3230_probe, 193 + .probe = mc3230_probe, 194 194 .remove = mc3230_remove, 195 195 .id_table = mc3230_i2c_id, 196 196 };
+1 -1
drivers/iio/accel/mma7455_i2c.c
··· 46 46 MODULE_DEVICE_TABLE(of, mma7455_of_match); 47 47 48 48 static struct i2c_driver mma7455_i2c_driver = { 49 - .probe_new = mma7455_i2c_probe, 49 + .probe = mma7455_i2c_probe, 50 50 .remove = mma7455_i2c_remove, 51 51 .id_table = mma7455_i2c_ids, 52 52 .driver = {
+1 -1
drivers/iio/accel/mma7660.c
··· 266 266 .of_match_table = mma7660_of_match, 267 267 .acpi_match_table = mma7660_acpi_id, 268 268 }, 269 - .probe_new = mma7660_probe, 269 + .probe = mma7660_probe, 270 270 .remove = mma7660_remove, 271 271 .id_table = mma7660_i2c_id, 272 272 };
+1 -1
drivers/iio/accel/mma8452.c
··· 1846 1846 .of_match_table = mma8452_dt_ids, 1847 1847 .pm = &mma8452_pm_ops, 1848 1848 }, 1849 - .probe_new = mma8452_probe, 1849 + .probe = mma8452_probe, 1850 1850 .remove = mma8452_remove, 1851 1851 .id_table = mma8452_id, 1852 1852 };
+1 -1
drivers/iio/accel/mma9551.c
··· 607 607 .acpi_match_table = ACPI_PTR(mma9551_acpi_match), 608 608 .pm = pm_ptr(&mma9551_pm_ops), 609 609 }, 610 - .probe_new = mma9551_probe, 610 + .probe = mma9551_probe, 611 611 .remove = mma9551_remove, 612 612 .id_table = mma9551_id, 613 613 };
+1 -1
drivers/iio/accel/mma9553.c
··· 1246 1246 .acpi_match_table = ACPI_PTR(mma9553_acpi_match), 1247 1247 .pm = pm_ptr(&mma9553_pm_ops), 1248 1248 }, 1249 - .probe_new = mma9553_probe, 1249 + .probe = mma9553_probe, 1250 1250 .remove = mma9553_remove, 1251 1251 .id_table = mma9553_id, 1252 1252 };
+1 -1
drivers/iio/accel/msa311.c
··· 1294 1294 .of_match_table = msa311_of_match, 1295 1295 .pm = pm_ptr(&msa311_pm_ops), 1296 1296 }, 1297 - .probe_new = msa311_probe, 1297 + .probe = msa311_probe, 1298 1298 .id_table = msa311_i2c_id, 1299 1299 }; 1300 1300 module_i2c_driver(msa311_driver);
+1 -1
drivers/iio/accel/mxc4005.c
··· 488 488 .name = MXC4005_DRV_NAME, 489 489 .acpi_match_table = ACPI_PTR(mxc4005_acpi_match), 490 490 }, 491 - .probe_new = mxc4005_probe, 491 + .probe = mxc4005_probe, 492 492 .id_table = mxc4005_id, 493 493 }; 494 494
+1 -1
drivers/iio/accel/mxc6255.c
··· 183 183 .name = MXC6255_DRV_NAME, 184 184 .acpi_match_table = ACPI_PTR(mxc6255_acpi_match), 185 185 }, 186 - .probe_new = mxc6255_probe, 186 + .probe = mxc6255_probe, 187 187 .id_table = mxc6255_id, 188 188 }; 189 189
+1
drivers/iio/accel/st_accel_core.c
··· 1007 1007 .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, 1008 1008 .sensors_supported = { 1009 1009 [0] = LSM9DS0_IMU_DEV_NAME, 1010 + [1] = LSM303D_IMU_DEV_NAME, 1010 1011 }, 1011 1012 .ch = (struct iio_chan_spec *)st_accel_16bit_channels, 1012 1013 .odr = {
+1 -1
drivers/iio/accel/st_accel_i2c.c
··· 206 206 .of_match_table = st_accel_of_match, 207 207 .acpi_match_table = ACPI_PTR(st_accel_acpi_match), 208 208 }, 209 - .probe_new = st_accel_i2c_probe, 209 + .probe = st_accel_i2c_probe, 210 210 .id_table = st_accel_id_table, 211 211 }; 212 212 module_i2c_driver(st_accel_driver);
+1 -1
drivers/iio/accel/stk8312.c
··· 644 644 .name = STK8312_DRIVER_NAME, 645 645 .pm = pm_sleep_ptr(&stk8312_pm_ops), 646 646 }, 647 - .probe_new = stk8312_probe, 647 + .probe = stk8312_probe, 648 648 .remove = stk8312_remove, 649 649 .id_table = stk8312_i2c_id, 650 650 };
+1 -1
drivers/iio/accel/stk8ba50.c
··· 543 543 .pm = pm_sleep_ptr(&stk8ba50_pm_ops), 544 544 .acpi_match_table = ACPI_PTR(stk8ba50_acpi_id), 545 545 }, 546 - .probe_new = stk8ba50_probe, 546 + .probe = stk8ba50_probe, 547 547 .remove = stk8ba50_remove, 548 548 .id_table = stk8ba50_i2c_id, 549 549 };
+1 -1
drivers/iio/adc/Kconfig
··· 145 145 146 146 config AD7606_IFACE_PARALLEL 147 147 tristate "Analog Devices AD7606 ADC driver with parallel interface support" 148 - depends on HAS_IOMEM 148 + depends on HAS_IOPORT 149 149 select AD7606 150 150 help 151 151 Say yes here to build parallel interface support for Analog Devices:
+1 -1
drivers/iio/adc/ad7091r5.c
··· 103 103 .name = "ad7091r5", 104 104 .of_match_table = ad7091r5_dt_ids, 105 105 }, 106 - .probe_new = ad7091r5_i2c_probe, 106 + .probe = ad7091r5_i2c_probe, 107 107 .id_table = ad7091r5_i2c_ids, 108 108 }; 109 109 module_i2c_driver(ad7091r5_driver);
+1 -1
drivers/iio/adc/ad7291.c
··· 553 553 .name = KBUILD_MODNAME, 554 554 .of_match_table = ad7291_of_match, 555 555 }, 556 - .probe_new = ad7291_probe, 556 + .probe = ad7291_probe, 557 557 .id_table = ad7291_id, 558 558 }; 559 559 module_i2c_driver(ad7291_driver);
+1 -1
drivers/iio/adc/ad799x.c
··· 968 968 .name = "ad799x", 969 969 .pm = pm_sleep_ptr(&ad799x_pm_ops), 970 970 }, 971 - .probe_new = ad799x_probe, 971 + .probe = ad799x_probe, 972 972 .remove = ad799x_remove, 973 973 .id_table = ad799x_id, 974 974 };
+1 -1
drivers/iio/adc/ina2xx-adc.c
··· 1090 1090 .name = KBUILD_MODNAME, 1091 1091 .of_match_table = ina2xx_of_match, 1092 1092 }, 1093 - .probe_new = ina2xx_probe, 1093 + .probe = ina2xx_probe, 1094 1094 .remove = ina2xx_remove, 1095 1095 .id_table = ina2xx_id, 1096 1096 };
+1 -1
drivers/iio/adc/ltc2471.c
··· 146 146 .driver = { 147 147 .name = "ltc2471", 148 148 }, 149 - .probe_new = ltc2471_i2c_probe, 149 + .probe = ltc2471_i2c_probe, 150 150 .id_table = ltc2471_i2c_id, 151 151 }; 152 152
+1 -1
drivers/iio/adc/ltc2485.c
··· 133 133 .driver = { 134 134 .name = "ltc2485", 135 135 }, 136 - .probe_new = ltc2485_probe, 136 + .probe = ltc2485_probe, 137 137 .id_table = ltc2485_id, 138 138 }; 139 139 module_i2c_driver(ltc2485_driver);
+1 -1
drivers/iio/adc/ltc2497.c
··· 163 163 .name = "ltc2497", 164 164 .of_match_table = ltc2497_of_match, 165 165 }, 166 - .probe_new = ltc2497_probe, 166 + .probe = ltc2497_probe, 167 167 .remove = ltc2497_remove, 168 168 .id_table = ltc2497_id, 169 169 };
+1 -1
drivers/iio/adc/max1363.c
··· 1718 1718 .name = "max1363", 1719 1719 .of_match_table = max1363_of_match, 1720 1720 }, 1721 - .probe_new = max1363_probe, 1721 + .probe = max1363_probe, 1722 1722 .id_table = max1363_id, 1723 1723 }; 1724 1724 module_i2c_driver(max1363_driver);
+1 -1
drivers/iio/adc/max9611.c
··· 556 556 .name = DRIVER_NAME, 557 557 .of_match_table = max9611_of_table, 558 558 }, 559 - .probe_new = max9611_probe, 559 + .probe = max9611_probe, 560 560 }; 561 561 module_i2c_driver(max9611_driver); 562 562
+1 -1
drivers/iio/adc/mcp3422.c
··· 417 417 .name = "mcp3422", 418 418 .of_match_table = mcp3422_of_match, 419 419 }, 420 - .probe_new = mcp3422_probe, 420 + .probe = mcp3422_probe, 421 421 .id_table = mcp3422_id, 422 422 }; 423 423 module_i2c_driver(mcp3422_driver);
+1 -1
drivers/iio/adc/nau7802.c
··· 544 544 MODULE_DEVICE_TABLE(of, nau7802_dt_ids); 545 545 546 546 static struct i2c_driver nau7802_driver = { 547 - .probe_new = nau7802_probe, 547 + .probe = nau7802_probe, 548 548 .id_table = nau7802_i2c_id, 549 549 .driver = { 550 550 .name = "nau7802",
-1
drivers/iio/adc/palmas_gpadc.c
··· 14 14 #include <linux/platform_device.h> 15 15 #include <linux/slab.h> 16 16 #include <linux/delay.h> 17 - #include <linux/i2c.h> 18 17 #include <linux/pm.h> 19 18 #include <linux/mfd/palmas.h> 20 19 #include <linux/completion.h>
+7 -8
drivers/iio/adc/qcom-spmi-adc5.c
··· 114 114 * that is an average of multiple measurements. 115 115 * @scale_fn_type: Represents the scaling function to convert voltage 116 116 * physical units desired by the client for the channel. 117 - * @datasheet_name: Channel name used in device tree. 117 + * @channel_name: Channel name used in device tree. 118 118 */ 119 119 struct adc5_channel_prop { 120 120 unsigned int channel; ··· 126 126 unsigned int hw_settle_time; 127 127 unsigned int avg_samples; 128 128 enum vadc_scale_fn_type scale_fn_type; 129 - const char *datasheet_name; 129 + const char *channel_name; 130 130 }; 131 131 132 132 /** ··· 657 657 chan = chan & ADC_CHANNEL_MASK; 658 658 } 659 659 660 - if (chan > ADC5_PARALLEL_ISENSE_VBAT_IDATA || 661 - !data->adc_chans[chan].datasheet_name) { 660 + if (chan > ADC5_PARALLEL_ISENSE_VBAT_IDATA) { 662 661 dev_err(dev, "%s invalid channel number %d\n", name, chan); 663 662 return -EINVAL; 664 663 } ··· 668 669 669 670 ret = fwnode_property_read_string(fwnode, "label", &channel_name); 670 671 if (ret) 671 - channel_name = name; 672 + channel_name = data->adc_chans[chan].datasheet_name; 672 673 673 - prop->datasheet_name = channel_name; 674 + prop->channel_name = channel_name; 674 675 675 676 ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &value); 676 677 if (!ret) { ··· 860 861 adc_chan = &adc->data->adc_chans[prop.channel]; 861 862 862 863 iio_chan->channel = prop.channel; 863 - iio_chan->datasheet_name = prop.datasheet_name; 864 - iio_chan->extend_name = prop.datasheet_name; 864 + iio_chan->datasheet_name = adc_chan->datasheet_name; 865 + iio_chan->extend_name = prop.channel_name; 865 866 iio_chan->info_mask_separate = adc_chan->info_mask; 866 867 iio_chan->type = adc_chan->type; 867 868 iio_chan->address = index;
+18 -1
drivers/iio/adc/qcom-spmi-vadc.c
··· 84 84 * that is an average of multiple measurements. 85 85 * @scale_fn_type: Represents the scaling function to convert voltage 86 86 * physical units desired by the client for the channel. 87 + * @channel_name: Channel name used in device tree. 87 88 */ 88 89 struct vadc_channel_prop { 89 90 unsigned int channel; ··· 94 93 unsigned int hw_settle_time; 95 94 unsigned int avg_samples; 96 95 enum vadc_scale_fn_type scale_fn_type; 96 + const char *channel_name; 97 97 }; 98 98 99 99 /** ··· 497 495 return -EINVAL; 498 496 } 499 497 498 + static int vadc_read_label(struct iio_dev *indio_dev, 499 + struct iio_chan_spec const *chan, char *label) 500 + { 501 + struct vadc_priv *vadc = iio_priv(indio_dev); 502 + const char *name = vadc->chan_props[chan->address].channel_name; 503 + 504 + return sysfs_emit(label, "%s\n", name); 505 + } 506 + 500 507 static const struct iio_info vadc_info = { 501 508 .read_raw = vadc_read_raw, 509 + .read_label = vadc_read_label, 502 510 .fwnode_xlate = vadc_fwnode_xlate, 503 511 }; 504 512 ··· 664 652 struct vadc_channel_prop *prop, 665 653 struct fwnode_handle *fwnode) 666 654 { 667 - const char *name = fwnode_get_name(fwnode); 655 + const char *name = fwnode_get_name(fwnode), *label; 668 656 u32 chan, value, varr[2]; 669 657 int ret; 670 658 ··· 678 666 dev_err(dev, "%s invalid channel number %d\n", name, chan); 679 667 return -EINVAL; 680 668 } 669 + 670 + ret = fwnode_property_read_string(fwnode, "label", &label); 671 + if (ret) 672 + label = vadc_chans[chan].datasheet_name; 673 + prop->channel_name = label; 681 674 682 675 /* the channel has DT description */ 683 676 prop->channel = chan;
+155 -91
drivers/iio/adc/rockchip_saradc.c
··· 4 4 * Copyright (C) 2014 ROCKCHIP, Inc. 5 5 */ 6 6 7 + #include <linux/bitfield.h> 7 8 #include <linux/module.h> 8 9 #include <linux/mutex.h> 9 10 #include <linux/platform_device.h> ··· 39 38 #define SARADC_TIMEOUT msecs_to_jiffies(100) 40 39 #define SARADC_MAX_CHANNELS 8 41 40 41 + /* v2 registers */ 42 + #define SARADC2_CONV_CON 0x000 43 + #define SARADC_T_PD_SOC 0x004 44 + #define SARADC_T_DAS_SOC 0x00c 45 + #define SARADC2_END_INT_EN 0x104 46 + #define SARADC2_ST_CON 0x108 47 + #define SARADC2_STATUS 0x10c 48 + #define SARADC2_END_INT_ST 0x110 49 + #define SARADC2_DATA_BASE 0x120 50 + 51 + #define SARADC2_EN_END_INT BIT(0) 52 + #define SARADC2_START BIT(4) 53 + #define SARADC2_SINGLE_MODE BIT(5) 54 + 55 + #define SARADC2_CONV_CHANNELS GENMASK(15, 0) 56 + 57 + struct rockchip_saradc; 58 + 42 59 struct rockchip_saradc_data { 43 60 const struct iio_chan_spec *channels; 44 61 int num_channels; 45 62 unsigned long clk_rate; 63 + void (*start)(struct rockchip_saradc *info, int chn); 64 + int (*read)(struct rockchip_saradc *info); 65 + void (*power_down)(struct rockchip_saradc *info); 46 66 }; 47 67 48 68 struct rockchip_saradc { ··· 82 60 struct notifier_block nb; 83 61 }; 84 62 85 - static void rockchip_saradc_power_down(struct rockchip_saradc *info) 63 + static void rockchip_saradc_reset_controller(struct reset_control *reset); 64 + 65 + static void rockchip_saradc_start_v1(struct rockchip_saradc *info, int chn) 86 66 { 87 - /* Clear irq & power down adc */ 67 + /* 8 clock periods as delay between power up and start cmd */ 68 + writel_relaxed(8, info->regs + SARADC_DLY_PU_SOC); 69 + /* Select the channel to be used and trigger conversion */ 70 + writel(SARADC_CTRL_POWER_CTRL | (chn & SARADC_CTRL_CHN_MASK) | 71 + SARADC_CTRL_IRQ_ENABLE, info->regs + SARADC_CTRL); 72 + } 73 + 74 + static void rockchip_saradc_start_v2(struct rockchip_saradc *info, int chn) 75 + { 76 + int val; 77 + 78 + if (info->reset) 79 + rockchip_saradc_reset_controller(info->reset); 80 + 81 + writel_relaxed(0xc, info->regs + SARADC_T_DAS_SOC); 82 + writel_relaxed(0x20, info->regs + SARADC_T_PD_SOC); 83 + val = FIELD_PREP(SARADC2_EN_END_INT, 1); 84 + val |= val << 16; 85 + writel_relaxed(val, info->regs + SARADC2_END_INT_EN); 86 + val = FIELD_PREP(SARADC2_START, 1) | 87 + FIELD_PREP(SARADC2_SINGLE_MODE, 1) | 88 + FIELD_PREP(SARADC2_CONV_CHANNELS, chn); 89 + val |= val << 16; 90 + writel(val, info->regs + SARADC2_CONV_CON); 91 + } 92 + 93 + static void rockchip_saradc_start(struct rockchip_saradc *info, int chn) 94 + { 95 + info->data->start(info, chn); 96 + } 97 + 98 + static int rockchip_saradc_read_v1(struct rockchip_saradc *info) 99 + { 100 + return readl_relaxed(info->regs + SARADC_DATA); 101 + } 102 + 103 + static int rockchip_saradc_read_v2(struct rockchip_saradc *info) 104 + { 105 + int offset; 106 + 107 + /* Clear irq */ 108 + writel_relaxed(0x1, info->regs + SARADC2_END_INT_ST); 109 + 110 + offset = SARADC2_DATA_BASE + info->last_chan->channel * 0x4; 111 + 112 + return readl_relaxed(info->regs + offset); 113 + } 114 + 115 + static int rockchip_saradc_read(struct rockchip_saradc *info) 116 + { 117 + return info->data->read(info); 118 + } 119 + 120 + static void rockchip_saradc_power_down_v1(struct rockchip_saradc *info) 121 + { 88 122 writel_relaxed(0, info->regs + SARADC_CTRL); 89 123 } 90 124 125 + static void rockchip_saradc_power_down(struct rockchip_saradc *info) 126 + { 127 + if (info->data->power_down) 128 + info->data->power_down(info); 129 + } 130 + 91 131 static int rockchip_saradc_conversion(struct rockchip_saradc *info, 92 - struct iio_chan_spec const *chan) 132 + struct iio_chan_spec const *chan) 93 133 { 94 134 reinit_completion(&info->completion); 95 135 96 - /* 8 clock periods as delay between power up and start cmd */ 97 - writel_relaxed(8, info->regs + SARADC_DLY_PU_SOC); 98 - 99 136 info->last_chan = chan; 100 - 101 - /* Select the channel to be used and trigger conversion */ 102 - writel(SARADC_CTRL_POWER_CTRL 103 - | (chan->channel & SARADC_CTRL_CHN_MASK) 104 - | SARADC_CTRL_IRQ_ENABLE, 105 - info->regs + SARADC_CTRL); 137 + rockchip_saradc_start(info, chan->channel); 106 138 107 139 if (!wait_for_completion_timeout(&info->completion, SARADC_TIMEOUT)) 108 140 return -ETIMEDOUT; ··· 199 123 struct rockchip_saradc *info = dev_id; 200 124 201 125 /* Read value */ 202 - info->last_val = readl_relaxed(info->regs + SARADC_DATA); 126 + info->last_val = rockchip_saradc_read(info); 203 127 info->last_val &= GENMASK(info->last_chan->scan_type.realbits - 1, 0); 204 128 205 129 rockchip_saradc_power_down(info); ··· 239 163 .channels = rockchip_saradc_iio_channels, 240 164 .num_channels = ARRAY_SIZE(rockchip_saradc_iio_channels), 241 165 .clk_rate = 1000000, 166 + .start = rockchip_saradc_start_v1, 167 + .read = rockchip_saradc_read_v1, 168 + .power_down = rockchip_saradc_power_down_v1, 242 169 }; 243 170 244 171 static const struct iio_chan_spec rockchip_rk3066_tsadc_iio_channels[] = { ··· 253 174 .channels = rockchip_rk3066_tsadc_iio_channels, 254 175 .num_channels = ARRAY_SIZE(rockchip_rk3066_tsadc_iio_channels), 255 176 .clk_rate = 50000, 177 + .start = rockchip_saradc_start_v1, 178 + .read = rockchip_saradc_read_v1, 179 + .power_down = rockchip_saradc_power_down_v1, 256 180 }; 257 181 258 182 static const struct iio_chan_spec rockchip_rk3399_saradc_iio_channels[] = { ··· 271 189 .channels = rockchip_rk3399_saradc_iio_channels, 272 190 .num_channels = ARRAY_SIZE(rockchip_rk3399_saradc_iio_channels), 273 191 .clk_rate = 1000000, 192 + .start = rockchip_saradc_start_v1, 193 + .read = rockchip_saradc_read_v1, 194 + .power_down = rockchip_saradc_power_down_v1, 274 195 }; 275 196 276 197 static const struct iio_chan_spec rockchip_rk3568_saradc_iio_channels[] = { ··· 291 206 .channels = rockchip_rk3568_saradc_iio_channels, 292 207 .num_channels = ARRAY_SIZE(rockchip_rk3568_saradc_iio_channels), 293 208 .clk_rate = 1000000, 209 + .start = rockchip_saradc_start_v1, 210 + .read = rockchip_saradc_read_v1, 211 + .power_down = rockchip_saradc_power_down_v1, 212 + }; 213 + 214 + static const struct iio_chan_spec rockchip_rk3588_saradc_iio_channels[] = { 215 + SARADC_CHANNEL(0, "adc0", 12), 216 + SARADC_CHANNEL(1, "adc1", 12), 217 + SARADC_CHANNEL(2, "adc2", 12), 218 + SARADC_CHANNEL(3, "adc3", 12), 219 + SARADC_CHANNEL(4, "adc4", 12), 220 + SARADC_CHANNEL(5, "adc5", 12), 221 + SARADC_CHANNEL(6, "adc6", 12), 222 + SARADC_CHANNEL(7, "adc7", 12), 223 + }; 224 + 225 + static const struct rockchip_saradc_data rk3588_saradc_data = { 226 + .channels = rockchip_rk3588_saradc_iio_channels, 227 + .num_channels = ARRAY_SIZE(rockchip_rk3588_saradc_iio_channels), 228 + .clk_rate = 1000000, 229 + .start = rockchip_saradc_start_v2, 230 + .read = rockchip_saradc_read_v2, 294 231 }; 295 232 296 233 static const struct of_device_id rockchip_saradc_match[] = { ··· 328 221 }, { 329 222 .compatible = "rockchip,rk3568-saradc", 330 223 .data = &rk3568_saradc_data, 224 + }, { 225 + .compatible = "rockchip,rk3588-saradc", 226 + .data = &rk3588_saradc_data, 331 227 }, 332 228 {}, 333 229 }; ··· 344 234 reset_control_assert(reset); 345 235 usleep_range(10, 20); 346 236 reset_control_deassert(reset); 347 - } 348 - 349 - static void rockchip_saradc_clk_disable(void *data) 350 - { 351 - struct rockchip_saradc *info = data; 352 - 353 - clk_disable_unprepare(info->clk); 354 - } 355 - 356 - static void rockchip_saradc_pclk_disable(void *data) 357 - { 358 - struct rockchip_saradc *info = data; 359 - 360 - clk_disable_unprepare(info->pclk); 361 237 } 362 238 363 239 static void rockchip_saradc_regulator_disable(void *data) ··· 394 298 } 395 299 396 300 static int rockchip_saradc_volt_notify(struct notifier_block *nb, 397 - unsigned long event, 398 - void *data) 301 + unsigned long event, void *data) 399 302 { 400 303 struct rockchip_saradc *info = 401 304 container_of(nb, struct rockchip_saradc, nb); ··· 414 319 415 320 static int rockchip_saradc_probe(struct platform_device *pdev) 416 321 { 322 + const struct rockchip_saradc_data *match_data; 417 323 struct rockchip_saradc *info = NULL; 418 324 struct device_node *np = pdev->dev.of_node; 419 325 struct iio_dev *indio_dev = NULL; 420 - const struct of_device_id *match; 421 326 int ret; 422 327 int irq; 423 328 ··· 425 330 return -ENODEV; 426 331 427 332 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info)); 428 - if (!indio_dev) { 429 - dev_err(&pdev->dev, "failed allocating iio device\n"); 430 - return -ENOMEM; 431 - } 333 + if (!indio_dev) 334 + return dev_err_probe(&pdev->dev, -ENOMEM, 335 + "failed allocating iio device\n"); 336 + 432 337 info = iio_priv(indio_dev); 433 338 434 - match = of_match_device(rockchip_saradc_match, &pdev->dev); 435 - if (!match) { 436 - dev_err(&pdev->dev, "failed to match device\n"); 437 - return -ENODEV; 438 - } 339 + match_data = of_device_get_match_data(&pdev->dev); 340 + if (!match_data) 341 + return dev_err_probe(&pdev->dev, -ENODEV, 342 + "failed to match device\n"); 439 343 440 - info->data = match->data; 344 + info->data = match_data; 441 345 442 346 /* Sanity check for possible later IP variants with more channels */ 443 - if (info->data->num_channels > SARADC_MAX_CHANNELS) { 444 - dev_err(&pdev->dev, "max channels exceeded"); 445 - return -EINVAL; 446 - } 347 + if (info->data->num_channels > SARADC_MAX_CHANNELS) 348 + return dev_err_probe(&pdev->dev, -EINVAL, 349 + "max channels exceeded"); 447 350 448 351 info->regs = devm_platform_ioremap_resource(pdev, 0); 449 352 if (IS_ERR(info->regs)) ··· 476 383 return ret; 477 384 } 478 385 479 - info->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); 480 - if (IS_ERR(info->pclk)) 481 - return dev_err_probe(&pdev->dev, PTR_ERR(info->pclk), 482 - "failed to get pclk\n"); 483 - 484 - info->clk = devm_clk_get(&pdev->dev, "saradc"); 485 - if (IS_ERR(info->clk)) 486 - return dev_err_probe(&pdev->dev, PTR_ERR(info->clk), 487 - "failed to get adc clock\n"); 488 - 489 386 info->vref = devm_regulator_get(&pdev->dev, "vref"); 490 387 if (IS_ERR(info->vref)) 491 388 return dev_err_probe(&pdev->dev, PTR_ERR(info->vref), ··· 489 406 * This may become user-configurable in the future. 490 407 */ 491 408 ret = clk_set_rate(info->clk, info->data->clk_rate); 492 - if (ret < 0) { 493 - dev_err(&pdev->dev, "failed to set adc clk rate, %d\n", ret); 494 - return ret; 495 - } 409 + if (ret < 0) 410 + return dev_err_probe(&pdev->dev, ret, 411 + "failed to set adc clk rate\n"); 496 412 497 413 ret = regulator_enable(info->vref); 498 - if (ret < 0) { 499 - dev_err(&pdev->dev, "failed to enable vref regulator\n"); 500 - return ret; 501 - } 414 + if (ret < 0) 415 + return dev_err_probe(&pdev->dev, ret, 416 + "failed to enable vref regulator\n"); 417 + 502 418 ret = devm_add_action_or_reset(&pdev->dev, 503 419 rockchip_saradc_regulator_disable, info); 504 - if (ret) { 505 - dev_err(&pdev->dev, "failed to register devm action, %d\n", 506 - ret); 507 - return ret; 508 - } 420 + if (ret) 421 + return dev_err_probe(&pdev->dev, ret, 422 + "failed to register devm action\n"); 509 423 510 424 ret = regulator_get_voltage(info->vref); 511 425 if (ret < 0) ··· 510 430 511 431 info->uv_vref = ret; 512 432 513 - ret = clk_prepare_enable(info->pclk); 514 - if (ret < 0) { 515 - dev_err(&pdev->dev, "failed to enable pclk\n"); 516 - return ret; 517 - } 518 - ret = devm_add_action_or_reset(&pdev->dev, 519 - rockchip_saradc_pclk_disable, info); 520 - if (ret) { 521 - dev_err(&pdev->dev, "failed to register devm action, %d\n", 522 - ret); 523 - return ret; 524 - } 433 + info->pclk = devm_clk_get_enabled(&pdev->dev, "apb_pclk"); 434 + if (IS_ERR(info->pclk)) 435 + return dev_err_probe(&pdev->dev, PTR_ERR(info->pclk), 436 + "failed to get pclk\n"); 525 437 526 - ret = clk_prepare_enable(info->clk); 527 - if (ret < 0) { 528 - dev_err(&pdev->dev, "failed to enable converter clock\n"); 529 - return ret; 530 - } 531 - ret = devm_add_action_or_reset(&pdev->dev, 532 - rockchip_saradc_clk_disable, info); 533 - if (ret) { 534 - dev_err(&pdev->dev, "failed to register devm action, %d\n", 535 - ret); 536 - return ret; 537 - } 438 + info->clk = devm_clk_get_enabled(&pdev->dev, "saradc"); 439 + if (IS_ERR(info->clk)) 440 + return dev_err_probe(&pdev->dev, PTR_ERR(info->clk), 441 + "failed to get adc clock\n"); 538 442 539 443 platform_set_drvdata(pdev, indio_dev); 540 444
+1 -1
drivers/iio/adc/rtq6056.c
··· 652 652 .of_match_table = rtq6056_device_match, 653 653 .pm = pm_ptr(&rtq6056_pm_ops), 654 654 }, 655 - .probe_new = rtq6056_probe, 655 + .probe = rtq6056_probe, 656 656 }; 657 657 module_i2c_driver(rtq6056_driver); 658 658
+2
drivers/iio/adc/stm32-adc.c
··· 1993 1993 const struct stm32_adc_info *adc_info = adc->cfg->adc_info; 1994 1994 int num_channels = 0, ret; 1995 1995 1996 + dev_dbg(&indio_dev->dev, "using legacy channel config\n"); 1997 + 1996 1998 ret = device_property_count_u32(dev, "st,adc-channels"); 1997 1999 if (ret > adc_info->max_channels) { 1998 2000 dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
+1 -1
drivers/iio/adc/ti-adc081c.c
··· 235 235 .of_match_table = adc081c_of_match, 236 236 .acpi_match_table = adc081c_acpi_match, 237 237 }, 238 - .probe_new = adc081c_probe, 238 + .probe = adc081c_probe, 239 239 .id_table = adc081c_id, 240 240 }; 241 241 module_i2c_driver(adc081c_driver);
+1 -1
drivers/iio/adc/ti-ads1015.c
··· 1195 1195 .of_match_table = ads1015_of_match, 1196 1196 .pm = &ads1015_pm_ops, 1197 1197 }, 1198 - .probe_new = ads1015_probe, 1198 + .probe = ads1015_probe, 1199 1199 .remove = ads1015_remove, 1200 1200 .id_table = ads1015_id, 1201 1201 };
+1 -1
drivers/iio/adc/ti-ads1100.c
··· 434 434 .of_match_table = ads1100_of_match, 435 435 .pm = pm_ptr(&ads1100_pm_ops), 436 436 }, 437 - .probe_new = ads1100_probe, 437 + .probe = ads1100_probe, 438 438 .id_table = ads1100_id, 439 439 }; 440 440
+1 -1
drivers/iio/adc/ti-ads7924.c
··· 463 463 .name = "ads7924", 464 464 .of_match_table = ads7924_of_match, 465 465 }, 466 - .probe_new = ads7924_probe, 466 + .probe = ads7924_probe, 467 467 .id_table = ads7924_id, 468 468 }; 469 469
+1 -1
drivers/iio/amplifiers/ad8366.c
··· 281 281 indio_dev->info = &ad8366_info; 282 282 indio_dev->modes = INDIO_DIRECT_MODE; 283 283 284 - ret = ad8366_write(indio_dev, 0 , 0); 284 + ret = ad8366_write(indio_dev, 0, 0); 285 285 if (ret < 0) 286 286 goto error_disable_reg; 287 287
+1 -1
drivers/iio/cdc/ad7150.c
··· 647 647 .name = "ad7150", 648 648 .of_match_table = ad7150_of_match, 649 649 }, 650 - .probe_new = ad7150_probe, 650 + .probe = ad7150_probe, 651 651 .id_table = ad7150_id, 652 652 }; 653 653 module_i2c_driver(ad7150_driver);
+1 -1
drivers/iio/cdc/ad7746.c
··· 809 809 .name = KBUILD_MODNAME, 810 810 .of_match_table = ad7746_of_match, 811 811 }, 812 - .probe_new = ad7746_probe, 812 + .probe = ad7746_probe, 813 813 .id_table = ad7746_id, 814 814 }; 815 815 module_i2c_driver(ad7746_driver);
+1 -1
drivers/iio/chemical/ams-iaq-core.c
··· 179 179 .name = "ams-iaq-core", 180 180 .of_match_table = ams_iaqcore_dt_ids, 181 181 }, 182 - .probe_new = ams_iaqcore_probe, 182 + .probe = ams_iaqcore_probe, 183 183 .id_table = ams_iaqcore_id, 184 184 }; 185 185 module_i2c_driver(ams_iaqcore_driver);
+1 -1
drivers/iio/chemical/atlas-ezo-sensor.c
··· 238 238 .name = ATLAS_EZO_DRV_NAME, 239 239 .of_match_table = atlas_ezo_dt_ids, 240 240 }, 241 - .probe_new = atlas_ezo_probe, 241 + .probe = atlas_ezo_probe, 242 242 .id_table = atlas_ezo_id, 243 243 }; 244 244 module_i2c_driver(atlas_ezo_driver);
+1 -1
drivers/iio/chemical/atlas-sensor.c
··· 767 767 .of_match_table = atlas_dt_ids, 768 768 .pm = pm_ptr(&atlas_pm_ops), 769 769 }, 770 - .probe_new = atlas_probe, 770 + .probe = atlas_probe, 771 771 .remove = atlas_remove, 772 772 .id_table = atlas_id, 773 773 };
+1 -1
drivers/iio/chemical/bme680_i2c.c
··· 52 52 .name = "bme680_i2c", 53 53 .of_match_table = bme680_of_i2c_match, 54 54 }, 55 - .probe_new = bme680_i2c_probe, 55 + .probe = bme680_i2c_probe, 56 56 .id_table = bme680_i2c_id, 57 57 }; 58 58 module_i2c_driver(bme680_i2c_driver);
+1 -1
drivers/iio/chemical/ccs811.c
··· 567 567 .name = "ccs811", 568 568 .of_match_table = ccs811_dt_ids, 569 569 }, 570 - .probe_new = ccs811_probe, 570 + .probe = ccs811_probe, 571 571 .remove = ccs811_remove, 572 572 .id_table = ccs811_id, 573 573 };
+1 -1
drivers/iio/chemical/scd30_i2c.c
··· 130 130 .of_match_table = scd30_i2c_of_match, 131 131 .pm = pm_sleep_ptr(&scd30_pm_ops), 132 132 }, 133 - .probe_new = scd30_i2c_probe, 133 + .probe = scd30_i2c_probe, 134 134 }; 135 135 module_i2c_driver(scd30_i2c_driver); 136 136
+1 -1
drivers/iio/chemical/scd4x.c
··· 690 690 .of_match_table = scd4x_dt_ids, 691 691 .pm = pm_sleep_ptr(&scd4x_pm_ops), 692 692 }, 693 - .probe_new = scd4x_probe, 693 + .probe = scd4x_probe, 694 694 }; 695 695 module_i2c_driver(scd4x_i2c_driver); 696 696
+1 -1
drivers/iio/chemical/sgp30.c
··· 575 575 .name = "sgp30", 576 576 .of_match_table = sgp_dt_ids, 577 577 }, 578 - .probe_new = sgp_probe, 578 + .probe = sgp_probe, 579 579 .remove = sgp_remove, 580 580 .id_table = sgp_id, 581 581 };
+1 -1
drivers/iio/chemical/sgp40.c
··· 368 368 .name = "sgp40", 369 369 .of_match_table = sgp40_dt_ids, 370 370 }, 371 - .probe_new = sgp40_probe, 371 + .probe = sgp40_probe, 372 372 .id_table = sgp40_id, 373 373 }; 374 374 module_i2c_driver(sgp40_driver);
+1 -1
drivers/iio/chemical/sps30_i2c.c
··· 249 249 .of_match_table = sps30_i2c_of_match, 250 250 }, 251 251 .id_table = sps30_i2c_id, 252 - .probe_new = sps30_i2c_probe, 252 + .probe = sps30_i2c_probe, 253 253 }; 254 254 module_i2c_driver(sps30_i2c_driver); 255 255
+1 -1
drivers/iio/chemical/sunrise_co2.c
··· 528 528 .name = DRIVER_NAME, 529 529 .of_match_table = sunrise_of_match, 530 530 }, 531 - .probe_new = sunrise_probe, 531 + .probe = sunrise_probe, 532 532 }; 533 533 module_i2c_driver(sunrise_driver); 534 534
+1 -1
drivers/iio/chemical/vz89x.c
··· 402 402 .name = "vz89x", 403 403 .of_match_table = vz89x_dt_ids, 404 404 }, 405 - .probe_new = vz89x_probe, 405 + .probe = vz89x_probe, 406 406 .id_table = vz89x_id, 407 407 }; 408 408 module_i2c_driver(vz89x_driver);
+1 -1
drivers/iio/dac/ad5064.c
··· 1056 1056 .driver = { 1057 1057 .name = "ad5064", 1058 1058 }, 1059 - .probe_new = ad5064_i2c_probe, 1059 + .probe = ad5064_i2c_probe, 1060 1060 .id_table = ad5064_i2c_ids, 1061 1061 }; 1062 1062
+1 -1
drivers/iio/dac/ad5380.c
··· 589 589 .driver = { 590 590 .name = "ad5380", 591 591 }, 592 - .probe_new = ad5380_i2c_probe, 592 + .probe = ad5380_i2c_probe, 593 593 .remove = ad5380_i2c_remove, 594 594 .id_table = ad5380_i2c_ids, 595 595 };
+1 -1
drivers/iio/dac/ad5446.c
··· 595 595 .driver = { 596 596 .name = "ad5446", 597 597 }, 598 - .probe_new = ad5446_i2c_probe, 598 + .probe = ad5446_i2c_probe, 599 599 .remove = ad5446_i2c_remove, 600 600 .id_table = ad5446_i2c_ids, 601 601 };
+1 -1
drivers/iio/dac/ad5593r.c
··· 138 138 .of_match_table = ad5593r_of_match, 139 139 .acpi_match_table = ad5593r_acpi_match, 140 140 }, 141 - .probe_new = ad5593r_i2c_probe, 141 + .probe = ad5593r_i2c_probe, 142 142 .remove = ad5593r_i2c_remove, 143 143 .id_table = ad5593r_i2c_ids, 144 144 };
+1 -1
drivers/iio/dac/ad5696-i2c.c
··· 115 115 .name = "ad5696", 116 116 .of_match_table = ad5686_of_match, 117 117 }, 118 - .probe_new = ad5686_i2c_probe, 118 + .probe = ad5686_i2c_probe, 119 119 .remove = ad5686_i2c_remove, 120 120 .id_table = ad5686_i2c_id, 121 121 };
+1 -1
drivers/iio/dac/ds4424.c
··· 312 312 .of_match_table = ds4424_of_match, 313 313 .pm = pm_sleep_ptr(&ds4424_pm_ops), 314 314 }, 315 - .probe_new = ds4424_probe, 315 + .probe = ds4424_probe, 316 316 .remove = ds4424_remove, 317 317 .id_table = ds4424_id, 318 318 };
+1 -1
drivers/iio/dac/m62332.c
··· 238 238 .name = "m62332", 239 239 .pm = pm_sleep_ptr(&m62332_pm_ops), 240 240 }, 241 - .probe_new = m62332_probe, 241 + .probe = m62332_probe, 242 242 .remove = m62332_remove, 243 243 .id_table = m62332_id, 244 244 };
+1 -1
drivers/iio/dac/max517.c
··· 203 203 .name = MAX517_DRV_NAME, 204 204 .pm = pm_sleep_ptr(&max517_pm_ops), 205 205 }, 206 - .probe_new = max517_probe, 206 + .probe = max517_probe, 207 207 .id_table = max517_id, 208 208 }; 209 209 module_i2c_driver(max517_driver);
+1 -1
drivers/iio/dac/max5821.c
··· 377 377 .of_match_table = max5821_of_match, 378 378 .pm = pm_sleep_ptr(&max5821_pm_ops), 379 379 }, 380 - .probe_new = max5821_probe, 380 + .probe = max5821_probe, 381 381 .id_table = max5821_id, 382 382 }; 383 383 module_i2c_driver(max5821_driver);
+1 -1
drivers/iio/dac/mcp4725.c
··· 536 536 .of_match_table = mcp4725_of_match, 537 537 .pm = pm_sleep_ptr(&mcp4725_pm_ops), 538 538 }, 539 - .probe_new = mcp4725_probe, 539 + .probe = mcp4725_probe, 540 540 .remove = mcp4725_remove, 541 541 .id_table = mcp4725_id, 542 542 };
+1 -1
drivers/iio/dac/ti-dac5571.c
··· 426 426 .name = "ti-dac5571", 427 427 .of_match_table = dac5571_of_id, 428 428 }, 429 - .probe_new = dac5571_probe, 429 + .probe = dac5571_probe, 430 430 .remove = dac5571_remove, 431 431 .id_table = dac5571_id, 432 432 };
+1 -1
drivers/iio/gyro/bmg160_i2c.c
··· 70 70 .of_match_table = bmg160_of_match, 71 71 .pm = &bmg160_pm_ops, 72 72 }, 73 - .probe_new = bmg160_i2c_probe, 73 + .probe = bmg160_i2c_probe, 74 74 .remove = bmg160_i2c_remove, 75 75 .id_table = bmg160_i2c_id, 76 76 };
+1 -1
drivers/iio/gyro/fxas21002c_i2c.c
··· 56 56 .pm = pm_ptr(&fxas21002c_pm_ops), 57 57 .of_match_table = fxas21002c_i2c_of_match, 58 58 }, 59 - .probe_new = fxas21002c_i2c_probe, 59 + .probe = fxas21002c_i2c_probe, 60 60 .remove = fxas21002c_i2c_remove, 61 61 .id_table = fxas21002c_i2c_id, 62 62 };
+1 -1
drivers/iio/gyro/itg3200_core.c
··· 405 405 .pm = pm_sleep_ptr(&itg3200_pm_ops), 406 406 }, 407 407 .id_table = itg3200_id, 408 - .probe_new = itg3200_probe, 408 + .probe = itg3200_probe, 409 409 .remove = itg3200_remove, 410 410 }; 411 411
+1 -1
drivers/iio/gyro/mpu3050-i2c.c
··· 108 108 MODULE_DEVICE_TABLE(of, mpu3050_i2c_of_match); 109 109 110 110 static struct i2c_driver mpu3050_i2c_driver = { 111 - .probe_new = mpu3050_i2c_probe, 111 + .probe = mpu3050_i2c_probe, 112 112 .remove = mpu3050_i2c_remove, 113 113 .id_table = mpu3050_i2c_id, 114 114 .driver = {
+1 -1
drivers/iio/gyro/st_gyro_i2c.c
··· 111 111 .name = "st-gyro-i2c", 112 112 .of_match_table = st_gyro_of_match, 113 113 }, 114 - .probe_new = st_gyro_i2c_probe, 114 + .probe = st_gyro_i2c_probe, 115 115 .id_table = st_gyro_id_table, 116 116 }; 117 117 module_i2c_driver(st_gyro_driver);
+1 -1
drivers/iio/health/afe4404.c
··· 609 609 .of_match_table = afe4404_of_match, 610 610 .pm = pm_sleep_ptr(&afe4404_pm_ops), 611 611 }, 612 - .probe_new = afe4404_probe, 612 + .probe = afe4404_probe, 613 613 .remove = afe4404_remove, 614 614 .id_table = afe4404_ids, 615 615 };
+1 -1
drivers/iio/health/max30100.c
··· 499 499 .name = MAX30100_DRV_NAME, 500 500 .of_match_table = max30100_dt_ids, 501 501 }, 502 - .probe_new = max30100_probe, 502 + .probe = max30100_probe, 503 503 .remove = max30100_remove, 504 504 .id_table = max30100_id, 505 505 };
+1 -1
drivers/iio/health/max30102.c
··· 631 631 .name = MAX30102_DRV_NAME, 632 632 .of_match_table = max30102_dt_ids, 633 633 }, 634 - .probe_new = max30102_probe, 634 + .probe = max30102_probe, 635 635 .remove = max30102_remove, 636 636 .id_table = max30102_id, 637 637 };
+1 -1
drivers/iio/humidity/am2315.c
··· 262 262 .driver = { 263 263 .name = "am2315", 264 264 }, 265 - .probe_new = am2315_probe, 265 + .probe = am2315_probe, 266 266 .id_table = am2315_i2c_id, 267 267 }; 268 268
+1 -1
drivers/iio/humidity/hdc100x.c
··· 428 428 .of_match_table = hdc100x_dt_ids, 429 429 .acpi_match_table = hdc100x_acpi_match, 430 430 }, 431 - .probe_new = hdc100x_probe, 431 + .probe = hdc100x_probe, 432 432 .id_table = hdc100x_id, 433 433 }; 434 434 module_i2c_driver(hdc100x_driver);
+1 -1
drivers/iio/humidity/hdc2010.c
··· 338 338 .name = "hdc2010", 339 339 .of_match_table = hdc2010_dt_ids, 340 340 }, 341 - .probe_new = hdc2010_probe, 341 + .probe = hdc2010_probe, 342 342 .remove = hdc2010_remove, 343 343 .id_table = hdc2010_id, 344 344 };
+1 -1
drivers/iio/humidity/hts221_i2c.c
··· 65 65 .of_match_table = hts221_i2c_of_match, 66 66 .acpi_match_table = ACPI_PTR(hts221_acpi_match), 67 67 }, 68 - .probe_new = hts221_i2c_probe, 68 + .probe = hts221_i2c_probe, 69 69 .id_table = hts221_i2c_id_table, 70 70 }; 71 71 module_i2c_driver(hts221_driver);
+1 -1
drivers/iio/humidity/htu21.c
··· 244 244 MODULE_DEVICE_TABLE(of, htu21_of_match); 245 245 246 246 static struct i2c_driver htu21_driver = { 247 - .probe_new = htu21_probe, 247 + .probe = htu21_probe, 248 248 .id_table = htu21_id, 249 249 .driver = { 250 250 .name = "htu21",
+1 -1
drivers/iio/humidity/si7005.c
··· 173 173 .driver = { 174 174 .name = "si7005", 175 175 }, 176 - .probe_new = si7005_probe, 176 + .probe = si7005_probe, 177 177 .id_table = si7005_id, 178 178 }; 179 179 module_i2c_driver(si7005_driver);
+1 -1
drivers/iio/humidity/si7020.c
··· 155 155 .name = "si7020", 156 156 .of_match_table = si7020_dt_ids, 157 157 }, 158 - .probe_new = si7020_probe, 158 + .probe = si7020_probe, 159 159 .id_table = si7020_id, 160 160 }; 161 161
+1 -1
drivers/iio/imu/bmi160/bmi160_i2c.c
··· 60 60 .acpi_match_table = bmi160_acpi_match, 61 61 .of_match_table = bmi160_of_match, 62 62 }, 63 - .probe_new = bmi160_i2c_probe, 63 + .probe = bmi160_i2c_probe, 64 64 .id_table = bmi160_i2c_id, 65 65 }; 66 66 module_i2c_driver(bmi160_i2c_driver);
+1 -1
drivers/iio/imu/bno055/bno055_i2c.c
··· 46 46 .name = "bno055-i2c", 47 47 .of_match_table = bno055_i2c_of_match, 48 48 }, 49 - .probe_new = bno055_i2c_probe, 49 + .probe = bno055_i2c_probe, 50 50 .id_table = bno055_i2c_id, 51 51 }; 52 52 module_i2c_driver(bno055_driver);
+1 -1
drivers/iio/imu/fxos8700_i2c.c
··· 60 60 .acpi_match_table = ACPI_PTR(fxos8700_acpi_match), 61 61 .of_match_table = fxos8700_of_match, 62 62 }, 63 - .probe_new = fxos8700_i2c_probe, 63 + .probe = fxos8700_i2c_probe, 64 64 .id_table = fxos8700_i2c_id, 65 65 }; 66 66 module_i2c_driver(fxos8700_i2c_driver);
+1 -1
drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
··· 98 98 .of_match_table = inv_icm42600_of_matches, 99 99 .pm = pm_ptr(&inv_icm42600_pm_ops), 100 100 }, 101 - .probe_new = inv_icm42600_probe, 101 + .probe = inv_icm42600_probe, 102 102 }; 103 103 module_i2c_driver(inv_icm42600_driver); 104 104
+26 -23
drivers/iio/imu/inv_icm42600/inv_icm42600_timestamp.c
··· 93 93 return false; 94 94 } 95 95 96 - static bool inv_compute_chip_period(struct inv_icm42600_timestamp *ts, 97 - uint32_t mult, uint32_t period) 96 + static bool inv_update_chip_period(struct inv_icm42600_timestamp *ts, 97 + uint32_t mult, uint32_t period) 98 98 { 99 99 uint32_t new_chip_period; 100 100 ··· 104 104 /* update chip internal period estimation */ 105 105 new_chip_period = period / mult; 106 106 inv_update_acc(&ts->chip_period, new_chip_period); 107 + ts->period = ts->mult * ts->chip_period.val; 107 108 108 109 return true; 110 + } 111 + 112 + static void inv_align_timestamp_it(struct inv_icm42600_timestamp *ts) 113 + { 114 + int64_t delta, jitter; 115 + int64_t adjust; 116 + 117 + /* delta time between last sample and last interrupt */ 118 + delta = ts->it.lo - ts->timestamp; 119 + 120 + /* adjust timestamp while respecting jitter */ 121 + jitter = div_s64((int64_t)ts->period * INV_ICM42600_TIMESTAMP_JITTER, 100); 122 + if (delta > jitter) 123 + adjust = jitter; 124 + else if (delta < -jitter) 125 + adjust = -jitter; 126 + else 127 + adjust = 0; 128 + 129 + ts->timestamp += adjust; 109 130 } 110 131 111 132 void inv_icm42600_timestamp_interrupt(struct inv_icm42600_timestamp *ts, ··· 137 116 int64_t delta, interval; 138 117 const uint32_t fifo_mult = fifo_period / INV_ICM42600_TIMESTAMP_PERIOD; 139 118 uint32_t period = ts->period; 140 - int32_t m; 141 119 bool valid = false; 142 120 143 121 if (fifo_nb == 0) ··· 150 130 if (it->lo != 0) { 151 131 /* compute period: delta time divided by number of samples */ 152 132 period = div_s64(delta, fifo_nb); 153 - valid = inv_compute_chip_period(ts, fifo_mult, period); 154 - /* update sensor period if chip internal period is updated */ 155 - if (valid) 156 - ts->period = ts->mult * ts->chip_period.val; 133 + valid = inv_update_chip_period(ts, fifo_mult, period); 157 134 } 158 135 159 136 /* no previous data, compute theoritical value from interrupt */ ··· 162 145 } 163 146 164 147 /* if interrupt interval is valid, sync with interrupt timestamp */ 165 - if (valid) { 166 - /* compute measured fifo_period */ 167 - fifo_period = fifo_mult * ts->chip_period.val; 168 - /* delta time between last sample and last interrupt */ 169 - delta = it->lo - ts->timestamp; 170 - /* if there are multiple samples, go back to first one */ 171 - while (delta >= (fifo_period * 3 / 2)) 172 - delta -= fifo_period; 173 - /* compute maximal adjustment value */ 174 - m = INV_ICM42600_TIMESTAMP_MAX_PERIOD(ts->period) - ts->period; 175 - if (delta > m) 176 - delta = m; 177 - else if (delta < -m) 178 - delta = -m; 179 - ts->timestamp += delta; 180 - } 148 + if (valid) 149 + inv_align_timestamp_it(ts); 181 150 } 182 151 183 152 void inv_icm42600_timestamp_apply_odr(struct inv_icm42600_timestamp *ts,
+2 -2
drivers/iio/imu/inv_mpu6050/Kconfig
··· 16 16 select REGMAP_I2C 17 17 help 18 18 This driver supports the Invensense MPU6050/9150, 19 - MPU6500/6515/6880/9250/9255, ICM20608(D)/20609/20689, ICM20602/ICM20690 19 + MPU6500/6515/6880/9250/9255, ICM20608(D)/20609/20689, ICM20600/20602/20690 20 20 and IAM20680 motion tracking devices over I2C. 21 21 This driver can be built as a module. The module will be called 22 22 inv-mpu6050-i2c. ··· 28 28 select REGMAP_SPI 29 29 help 30 30 This driver supports the Invensense MPU6000, 31 - MPU6500/6515/6880/9250/9255, ICM20608(D)/20609/20689, ICM20602/ICM20690 31 + MPU6500/6515/6880/9250/9255, ICM20608(D)/20609/20689, ICM20600/20602/20690 32 32 and IAM20680 motion tracking devices over SPI. 33 33 This driver can be built as a module. The module will be called 34 34 inv-mpu6050-spi.
+10
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
··· 245 245 .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME}, 246 246 }, 247 247 { 248 + .whoami = INV_ICM20600_WHOAMI_VALUE, 249 + .name = "ICM20600", 250 + .reg = &reg_set_icm20602, 251 + .config = &chip_config_6500, 252 + .fifo_size = 1008, 253 + .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE}, 254 + .startup_time = {INV_ICM20602_GYRO_STARTUP_TIME, INV_ICM20602_ACCEL_STARTUP_TIME}, 255 + }, 256 + { 248 257 .whoami = INV_ICM20602_WHOAMI_VALUE, 249 258 .name = "ICM20602", 250 259 .reg = &reg_set_icm20602, ··· 1606 1597 indio_dev->num_channels = ARRAY_SIZE(inv_mpu9250_channels); 1607 1598 indio_dev->available_scan_masks = inv_mpu9x50_scan_masks; 1608 1599 break; 1600 + case INV_ICM20600: 1609 1601 case INV_ICM20602: 1610 1602 indio_dev->channels = inv_mpu_channels; 1611 1603 indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels);
+7 -1
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
··· 32 32 case INV_ICM20608D: 33 33 case INV_ICM20609: 34 34 case INV_ICM20689: 35 + case INV_ICM20600: 35 36 case INV_ICM20602: 36 37 case INV_IAM20680: 37 38 /* no i2c auxiliary bus on the chip */ ··· 184 183 {"icm20608d", INV_ICM20608D}, 185 184 {"icm20609", INV_ICM20609}, 186 185 {"icm20689", INV_ICM20689}, 186 + {"icm20600", INV_ICM20600}, 187 187 {"icm20602", INV_ICM20602}, 188 188 {"icm20690", INV_ICM20690}, 189 189 {"iam20680", INV_IAM20680}, ··· 239 237 .data = (void *)INV_ICM20689 240 238 }, 241 239 { 240 + .compatible = "invensense,icm20600", 241 + .data = (void *)INV_ICM20600 242 + }, 243 + { 242 244 .compatible = "invensense,icm20602", 243 245 .data = (void *)INV_ICM20602 244 246 }, ··· 265 259 MODULE_DEVICE_TABLE(acpi, inv_acpi_match); 266 260 267 261 static struct i2c_driver inv_mpu_driver = { 268 - .probe_new = inv_mpu_probe, 262 + .probe = inv_mpu_probe, 269 263 .remove = inv_mpu_remove, 270 264 .id_table = inv_mpu_id, 271 265 .driver = {
+2
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
··· 79 79 INV_ICM20608D, 80 80 INV_ICM20609, 81 81 INV_ICM20689, 82 + INV_ICM20600, 82 83 INV_ICM20602, 83 84 INV_ICM20690, 84 85 INV_IAM20680, ··· 399 398 #define INV_ICM20608D_WHOAMI_VALUE 0xAE 400 399 #define INV_ICM20609_WHOAMI_VALUE 0xA6 401 400 #define INV_ICM20689_WHOAMI_VALUE 0x98 401 + #define INV_ICM20600_WHOAMI_VALUE 0x11 402 402 #define INV_ICM20602_WHOAMI_VALUE 0x12 403 403 #define INV_ICM20690_WHOAMI_VALUE 0x20 404 404 #define INV_IAM20680_WHOAMI_VALUE 0xA9
+5
drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
··· 76 76 {"icm20608d", INV_ICM20608D}, 77 77 {"icm20609", INV_ICM20609}, 78 78 {"icm20689", INV_ICM20689}, 79 + {"icm20600", INV_ICM20600}, 79 80 {"icm20602", INV_ICM20602}, 80 81 {"icm20690", INV_ICM20690}, 81 82 {"iam20680", INV_IAM20680}, ··· 125 124 { 126 125 .compatible = "invensense,icm20689", 127 126 .data = (void *)INV_ICM20689 127 + }, 128 + { 129 + .compatible = "invensense,icm20600", 130 + .data = (void *)INV_ICM20600 128 131 }, 129 132 { 130 133 .compatible = "invensense,icm20602",
+1 -1
drivers/iio/imu/kmx61.c
··· 1517 1517 .acpi_match_table = ACPI_PTR(kmx61_acpi_match), 1518 1518 .pm = pm_ptr(&kmx61_pm_ops), 1519 1519 }, 1520 - .probe_new = kmx61_probe, 1520 + .probe = kmx61_probe, 1521 1521 .remove = kmx61_remove, 1522 1522 .id_table = kmx61_id, 1523 1523 };
+1 -1
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
··· 179 179 .of_match_table = st_lsm6dsx_i2c_of_match, 180 180 .acpi_match_table = st_lsm6dsx_i2c_acpi_match, 181 181 }, 182 - .probe_new = st_lsm6dsx_i2c_probe, 182 + .probe = st_lsm6dsx_i2c_probe, 183 183 .id_table = st_lsm6dsx_i2c_id_table, 184 184 }; 185 185 module_i2c_driver(st_lsm6dsx_driver);
+2 -1
drivers/iio/imu/st_lsm9ds0/Kconfig
··· 10 10 11 11 help 12 12 Say yes here to build support for STMicroelectronics LSM9DS0 IMU 13 - sensor. Supported devices: accelerometer/magnetometer of lsm9ds0. 13 + sensor. Supported devices: accelerometer/magnetometer of lsm9ds0 14 + and lsm303d. 14 15 15 16 To compile this driver as a module, choose M here: the module 16 17 will be called st_lsm9ds0.
+13 -1
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
··· 19 19 20 20 static const struct of_device_id st_lsm9ds0_of_match[] = { 21 21 { 22 + .compatible = "st,lsm303d-imu", 23 + .data = LSM303D_IMU_DEV_NAME, 24 + }, 25 + { 22 26 .compatible = "st,lsm9ds0-imu", 23 27 .data = LSM9DS0_IMU_DEV_NAME, 24 28 }, ··· 31 27 MODULE_DEVICE_TABLE(of, st_lsm9ds0_of_match); 32 28 33 29 static const struct i2c_device_id st_lsm9ds0_id_table[] = { 30 + { LSM303D_IMU_DEV_NAME }, 34 31 { LSM9DS0_IMU_DEV_NAME }, 35 32 {} 36 33 }; 37 34 MODULE_DEVICE_TABLE(i2c, st_lsm9ds0_id_table); 35 + 36 + static const struct acpi_device_id st_lsm9ds0_acpi_match[] = { 37 + {"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME}, 38 + { }, 39 + }; 40 + MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match); 38 41 39 42 static const struct regmap_config st_lsm9ds0_regmap_config = { 40 43 .reg_bits = 8, ··· 79 68 .driver = { 80 69 .name = "st-lsm9ds0-i2c", 81 70 .of_match_table = st_lsm9ds0_of_match, 71 + .acpi_match_table = st_lsm9ds0_acpi_match, 82 72 }, 83 - .probe_new = st_lsm9ds0_i2c_probe, 73 + .probe = st_lsm9ds0_i2c_probe, 84 74 .id_table = st_lsm9ds0_id_table, 85 75 }; 86 76 module_i2c_driver(st_lsm9ds0_driver);
+5
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
··· 19 19 20 20 static const struct of_device_id st_lsm9ds0_of_match[] = { 21 21 { 22 + .compatible = "st,lsm303d-imu", 23 + .data = LSM303D_IMU_DEV_NAME, 24 + }, 25 + { 22 26 .compatible = "st,lsm9ds0-imu", 23 27 .data = LSM9DS0_IMU_DEV_NAME, 24 28 }, ··· 31 27 MODULE_DEVICE_TABLE(of, st_lsm9ds0_of_match); 32 28 33 29 static const struct spi_device_id st_lsm9ds0_id_table[] = { 30 + { LSM303D_IMU_DEV_NAME }, 34 31 { LSM9DS0_IMU_DEV_NAME }, 35 32 {} 36 33 };
+49 -49
drivers/iio/industrialio-buffer.c
··· 194 194 written = 0; 195 195 add_wait_queue(&rb->pollq, &wait); 196 196 do { 197 - if (indio_dev->info == NULL) 197 + if (!indio_dev->info) 198 198 return -ENODEV; 199 199 200 200 if (!iio_buffer_space_available(rb)) { ··· 210 210 } 211 211 212 212 wait_woken(&wait, TASK_INTERRUPTIBLE, 213 - MAX_SCHEDULE_TIMEOUT); 213 + MAX_SCHEDULE_TIMEOUT); 214 214 continue; 215 215 } 216 216 ··· 242 242 struct iio_buffer *rb = ib->buffer; 243 243 struct iio_dev *indio_dev = ib->indio_dev; 244 244 245 - if (!indio_dev->info || rb == NULL) 245 + if (!indio_dev->info || !rb) 246 246 return 0; 247 247 248 248 poll_wait(filp, &rb->pollq, wait); ··· 407 407 408 408 /* Note NULL used as error indicator as it doesn't make sense. */ 409 409 static const unsigned long *iio_scan_mask_match(const unsigned long *av_masks, 410 - unsigned int masklength, 411 - const unsigned long *mask, 412 - bool strict) 410 + unsigned int masklength, 411 + const unsigned long *mask, 412 + bool strict) 413 413 { 414 414 if (bitmap_empty(mask, masklength)) 415 415 return NULL; ··· 427 427 } 428 428 429 429 static bool iio_validate_scan_mask(struct iio_dev *indio_dev, 430 - const unsigned long *mask) 430 + const unsigned long *mask) 431 431 { 432 432 if (!indio_dev->setup_ops->validate_scan_mask) 433 433 return true; ··· 446 446 * individual buffers request is plausible. 447 447 */ 448 448 static int iio_scan_mask_set(struct iio_dev *indio_dev, 449 - struct iio_buffer *buffer, int bit) 449 + struct iio_buffer *buffer, int bit) 450 450 { 451 451 const unsigned long *mask; 452 452 unsigned long *trialmask; ··· 539 539 mutex_unlock(&iio_dev_opaque->mlock); 540 540 541 541 return ret < 0 ? ret : len; 542 - 543 542 } 544 543 545 544 static ssize_t iio_scan_el_ts_show(struct device *dev, ··· 705 706 } 706 707 707 708 static int iio_compute_scan_bytes(struct iio_dev *indio_dev, 708 - const unsigned long *mask, bool timestamp) 709 + const unsigned long *mask, bool timestamp) 709 710 { 710 711 unsigned int bytes = 0; 711 712 int length, i, largest = 0; ··· 731 732 } 732 733 733 734 static void iio_buffer_activate(struct iio_dev *indio_dev, 734 - struct iio_buffer *buffer) 735 + struct iio_buffer *buffer) 735 736 { 736 737 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); 737 738 ··· 752 753 struct iio_buffer *buffer, *_buffer; 753 754 754 755 list_for_each_entry_safe(buffer, _buffer, 755 - &iio_dev_opaque->buffer_list, buffer_list) 756 + &iio_dev_opaque->buffer_list, buffer_list) 756 757 iio_buffer_deactivate(buffer); 757 758 } 758 759 759 760 static int iio_buffer_enable(struct iio_buffer *buffer, 760 - struct iio_dev *indio_dev) 761 + struct iio_dev *indio_dev) 761 762 { 762 763 if (!buffer->access->enable) 763 764 return 0; ··· 765 766 } 766 767 767 768 static int iio_buffer_disable(struct iio_buffer *buffer, 768 - struct iio_dev *indio_dev) 769 + struct iio_dev *indio_dev) 769 770 { 770 771 if (!buffer->access->disable) 771 772 return 0; ··· 773 774 } 774 775 775 776 static void iio_buffer_update_bytes_per_datum(struct iio_dev *indio_dev, 776 - struct iio_buffer *buffer) 777 + struct iio_buffer *buffer) 777 778 { 778 779 unsigned int bytes; 779 780 ··· 781 782 return; 782 783 783 784 bytes = iio_compute_scan_bytes(indio_dev, buffer->scan_mask, 784 - buffer->scan_timestamp); 785 + buffer->scan_timestamp); 785 786 786 787 buffer->access->set_bytes_per_datum(buffer, bytes); 787 788 } 788 789 789 790 static int iio_buffer_request_update(struct iio_dev *indio_dev, 790 - struct iio_buffer *buffer) 791 + struct iio_buffer *buffer) 791 792 { 792 793 int ret; 793 794 ··· 796 797 ret = buffer->access->request_update(buffer); 797 798 if (ret) { 798 799 dev_dbg(&indio_dev->dev, 799 - "Buffer not started: buffer parameter update failed (%d)\n", 800 + "Buffer not started: buffer parameter update failed (%d)\n", 800 801 ret); 801 802 return ret; 802 803 } ··· 806 807 } 807 808 808 809 static void iio_free_scan_mask(struct iio_dev *indio_dev, 809 - const unsigned long *mask) 810 + const unsigned long *mask) 810 811 { 811 812 /* If the mask is dynamically allocated free it, otherwise do nothing */ 812 813 if (!indio_dev->available_scan_masks) ··· 822 823 }; 823 824 824 825 static int iio_verify_update(struct iio_dev *indio_dev, 825 - struct iio_buffer *insert_buffer, struct iio_buffer *remove_buffer, 826 - struct iio_device_config *config) 826 + struct iio_buffer *insert_buffer, 827 + struct iio_buffer *remove_buffer, 828 + struct iio_device_config *config) 827 829 { 828 830 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); 829 831 unsigned long *compound_mask; ··· 864 864 if (insert_buffer) { 865 865 modes &= insert_buffer->access->modes; 866 866 config->watermark = min(config->watermark, 867 - insert_buffer->watermark); 867 + insert_buffer->watermark); 868 868 } 869 869 870 870 /* Definitely possible for devices to support both of these. */ ··· 890 890 891 891 /* What scan mask do we actually have? */ 892 892 compound_mask = bitmap_zalloc(indio_dev->masklength, GFP_KERNEL); 893 - if (compound_mask == NULL) 893 + if (!compound_mask) 894 894 return -ENOMEM; 895 895 896 896 scan_timestamp = false; ··· 911 911 912 912 if (indio_dev->available_scan_masks) { 913 913 scan_mask = iio_scan_mask_match(indio_dev->available_scan_masks, 914 - indio_dev->masklength, 915 - compound_mask, 916 - strict_scanmask); 914 + indio_dev->masklength, 915 + compound_mask, 916 + strict_scanmask); 917 917 bitmap_free(compound_mask); 918 - if (scan_mask == NULL) 918 + if (!scan_mask) 919 919 return -EINVAL; 920 920 } else { 921 921 scan_mask = compound_mask; 922 922 } 923 923 924 924 config->scan_bytes = iio_compute_scan_bytes(indio_dev, 925 - scan_mask, scan_timestamp); 925 + scan_mask, scan_timestamp); 926 926 config->scan_mask = scan_mask; 927 927 config->scan_timestamp = scan_timestamp; 928 928 ··· 954 954 } 955 955 956 956 static int iio_buffer_add_demux(struct iio_buffer *buffer, 957 - struct iio_demux_table **p, unsigned int in_loc, unsigned int out_loc, 958 - unsigned int length) 957 + struct iio_demux_table **p, unsigned int in_loc, 958 + unsigned int out_loc, 959 + unsigned int length) 959 960 { 960 - 961 961 if (*p && (*p)->from + (*p)->length == in_loc && 962 - (*p)->to + (*p)->length == out_loc) { 962 + (*p)->to + (*p)->length == out_loc) { 963 963 (*p)->length += length; 964 964 } else { 965 965 *p = kmalloc(sizeof(**p), GFP_KERNEL); 966 - if (*p == NULL) 966 + if (!(*p)) 967 967 return -ENOMEM; 968 968 (*p)->from = in_loc; 969 969 (*p)->to = out_loc; ··· 1027 1027 out_loc += length; 1028 1028 } 1029 1029 buffer->demux_bounce = kzalloc(out_loc, GFP_KERNEL); 1030 - if (buffer->demux_bounce == NULL) { 1030 + if (!buffer->demux_bounce) { 1031 1031 ret = -ENOMEM; 1032 1032 goto error_clear_mux_table; 1033 1033 } ··· 1060 1060 } 1061 1061 1062 1062 static int iio_enable_buffers(struct iio_dev *indio_dev, 1063 - struct iio_device_config *config) 1063 + struct iio_device_config *config) 1064 1064 { 1065 1065 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); 1066 1066 struct iio_buffer *buffer, *tmp = NULL; ··· 1078 1078 ret = indio_dev->setup_ops->preenable(indio_dev); 1079 1079 if (ret) { 1080 1080 dev_dbg(&indio_dev->dev, 1081 - "Buffer not started: buffer preenable failed (%d)\n", ret); 1081 + "Buffer not started: buffer preenable failed (%d)\n", ret); 1082 1082 goto err_undo_config; 1083 1083 } 1084 1084 } ··· 1118 1118 ret = indio_dev->setup_ops->postenable(indio_dev); 1119 1119 if (ret) { 1120 1120 dev_dbg(&indio_dev->dev, 1121 - "Buffer not started: postenable failed (%d)\n", ret); 1121 + "Buffer not started: postenable failed (%d)\n", ret); 1122 1122 goto err_detach_pollfunc; 1123 1123 } 1124 1124 } ··· 1194 1194 } 1195 1195 1196 1196 static int __iio_update_buffers(struct iio_dev *indio_dev, 1197 - struct iio_buffer *insert_buffer, 1198 - struct iio_buffer *remove_buffer) 1197 + struct iio_buffer *insert_buffer, 1198 + struct iio_buffer *remove_buffer) 1199 1199 { 1200 1200 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); 1201 1201 struct iio_device_config new_config; 1202 1202 int ret; 1203 1203 1204 1204 ret = iio_verify_update(indio_dev, insert_buffer, remove_buffer, 1205 - &new_config); 1205 + &new_config); 1206 1206 if (ret) 1207 1207 return ret; 1208 1208 ··· 1258 1258 return 0; 1259 1259 1260 1260 if (insert_buffer && 1261 - (insert_buffer->direction == IIO_BUFFER_DIRECTION_OUT)) 1261 + insert_buffer->direction == IIO_BUFFER_DIRECTION_OUT) 1262 1262 return -EINVAL; 1263 1263 1264 1264 mutex_lock(&iio_dev_opaque->info_exist_lock); ··· 1275 1275 goto out_unlock; 1276 1276 } 1277 1277 1278 - if (indio_dev->info == NULL) { 1278 + if (!indio_dev->info) { 1279 1279 ret = -ENODEV; 1280 1280 goto out_unlock; 1281 1281 } ··· 1615 1615 1616 1616 buffer_attrcount = 0; 1617 1617 if (buffer->attrs) { 1618 - while (buffer->attrs[buffer_attrcount] != NULL) 1618 + while (buffer->attrs[buffer_attrcount]) 1619 1619 buffer_attrcount++; 1620 1620 } 1621 1621 buffer_attrcount += ARRAY_SIZE(iio_buffer_attrs); ··· 1643 1643 } 1644 1644 1645 1645 ret = iio_buffer_add_channel_sysfs(indio_dev, buffer, 1646 - &channels[i]); 1646 + &channels[i]); 1647 1647 if (ret < 0) 1648 1648 goto error_cleanup_dynamic; 1649 1649 scan_el_attrcount += ret; ··· 1651 1651 iio_dev_opaque->scan_index_timestamp = 1652 1652 channels[i].scan_index; 1653 1653 } 1654 - if (indio_dev->masklength && buffer->scan_mask == NULL) { 1654 + if (indio_dev->masklength && !buffer->scan_mask) { 1655 1655 buffer->scan_mask = bitmap_zalloc(indio_dev->masklength, 1656 1656 GFP_KERNEL); 1657 - if (buffer->scan_mask == NULL) { 1657 + if (!buffer->scan_mask) { 1658 1658 ret = -ENOMEM; 1659 1659 goto error_cleanup_dynamic; 1660 1660 } ··· 1771 1771 goto error_unwind_sysfs_and_mask; 1772 1772 } 1773 1773 1774 - sz = sizeof(*(iio_dev_opaque->buffer_ioctl_handler)); 1774 + sz = sizeof(*iio_dev_opaque->buffer_ioctl_handler); 1775 1775 iio_dev_opaque->buffer_ioctl_handler = kzalloc(sz, GFP_KERNEL); 1776 1776 if (!iio_dev_opaque->buffer_ioctl_handler) { 1777 1777 ret = -ENOMEM; ··· 1820 1820 * a time. 1821 1821 */ 1822 1822 bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev, 1823 - const unsigned long *mask) 1823 + const unsigned long *mask) 1824 1824 { 1825 1825 return bitmap_weight(mask, indio_dev->masklength) == 1; 1826 1826 } 1827 1827 EXPORT_SYMBOL_GPL(iio_validate_scan_mask_onehot); 1828 1828 1829 1829 static const void *iio_demux(struct iio_buffer *buffer, 1830 - const void *datain) 1830 + const void *datain) 1831 1831 { 1832 1832 struct iio_demux_table *t; 1833 1833
+21 -1
drivers/iio/industrialio-trigger.c
··· 322 322 * this is the case if the IIO device and the trigger device share the 323 323 * same parent device. 324 324 */ 325 - if (pf->indio_dev->dev.parent == trig->dev.parent) 325 + if (iio_validate_own_trigger(pf->indio_dev, trig)) 326 326 trig->attached_own_device = true; 327 327 328 328 return ret; ··· 727 727 return indio_dev->trig->attached_own_device; 728 728 } 729 729 EXPORT_SYMBOL(iio_trigger_using_own); 730 + 731 + /** 732 + * iio_validate_own_trigger - Check if a trigger and IIO device belong to 733 + * the same device 734 + * @idev: the IIO device to check 735 + * @trig: the IIO trigger to check 736 + * 737 + * This function can be used as the validate_trigger callback for triggers that 738 + * can only be attached to their own device. 739 + * 740 + * Return: 0 if both the trigger and the IIO device belong to the same 741 + * device, -EINVAL otherwise. 742 + */ 743 + int iio_validate_own_trigger(struct iio_dev *idev, struct iio_trigger *trig) 744 + { 745 + if (idev->dev.parent != trig->dev.parent) 746 + return -EINVAL; 747 + return 0; 748 + } 749 + EXPORT_SYMBOL_GPL(iio_validate_own_trigger); 730 750 731 751 /** 732 752 * iio_trigger_validate_own_device - Check if a trigger and IIO device belong to
+25
drivers/iio/light/Kconfig
··· 289 289 To compile this driver as a module, choose M here: 290 290 the module will be called jsa1212. 291 291 292 + config ROHM_BU27008 293 + tristate "ROHM BU27008 color (RGB+C/IR) sensor" 294 + depends on I2C 295 + select REGMAP_I2C 296 + select IIO_GTS_HELPER 297 + help 298 + Enable support for the ROHM BU27008 color sensor. 299 + The ROHM BU27008 is a sensor with 5 photodiodes (red, green, 300 + blue, clear and IR) with four configurable channels. Red and 301 + green being always available and two out of the rest three 302 + (blue, clear, IR) can be selected to be simultaneously measured. 303 + Typical application is adjusting LCD backlight of TVs, 304 + mobile phones and tablet PCs. 305 + 292 306 config ROHM_BU27034 293 307 tristate "ROHM BU27034 ambient light sensor" 294 308 depends on I2C ··· 426 412 427 413 If built as a dynamically linked module, it will be called 428 414 opt3001. 415 + 416 + config OPT4001 417 + tristate "Texas Instruments OPT4001 Light Sensor" 418 + depends on I2C 419 + select REGMAP_I2C 420 + help 421 + If you say Y or M here, you get support for Texas Instruments 422 + OPT4001 Ambient Light Sensor. 423 + 424 + If built as a dynamically linked module, it will be called 425 + opt4001. 429 426 430 427 config PA12203001 431 428 tristate "TXC PA12203001 light and proximity sensor"
+2
drivers/iio/light/Makefile
··· 37 37 obj-$(CONFIG_MAX44009) += max44009.o 38 38 obj-$(CONFIG_NOA1305) += noa1305.o 39 39 obj-$(CONFIG_OPT3001) += opt3001.o 40 + obj-$(CONFIG_OPT4001) += opt4001.o 40 41 obj-$(CONFIG_PA12203001) += pa12203001.o 42 + obj-$(CONFIG_ROHM_BU27008) += rohm-bu27008.o 41 43 obj-$(CONFIG_ROHM_BU27034) += rohm-bu27034.o 42 44 obj-$(CONFIG_RPR0521) += rpr0521.o 43 45 obj-$(CONFIG_SI1133) += si1133.o
+1 -1
drivers/iio/light/adjd_s311.c
··· 270 270 .driver = { 271 271 .name = ADJD_S311_DRV_NAME, 272 272 }, 273 - .probe_new = adjd_s311_probe, 273 + .probe = adjd_s311_probe, 274 274 .id_table = adjd_s311_id, 275 275 }; 276 276 module_i2c_driver(adjd_s311_driver);
+1 -1
drivers/iio/light/adux1020.c
··· 837 837 .name = ADUX1020_DRV_NAME, 838 838 .of_match_table = adux1020_of_match, 839 839 }, 840 - .probe_new = adux1020_probe, 840 + .probe = adux1020_probe, 841 841 .id_table = adux1020_id, 842 842 }; 843 843 module_i2c_driver(adux1020_driver);
+1 -1
drivers/iio/light/al3010.c
··· 229 229 .of_match_table = al3010_of_match, 230 230 .pm = pm_sleep_ptr(&al3010_pm_ops), 231 231 }, 232 - .probe_new = al3010_probe, 232 + .probe = al3010_probe, 233 233 .id_table = al3010_id, 234 234 }; 235 235 module_i2c_driver(al3010_driver);
+9 -1
drivers/iio/light/al3320a.c
··· 16 16 #include <linux/i2c.h> 17 17 #include <linux/module.h> 18 18 #include <linux/of.h> 19 + #include <linux/mod_devicetable.h> 19 20 20 21 #include <linux/iio/iio.h> 21 22 #include <linux/iio/sysfs.h> ··· 248 247 }; 249 248 MODULE_DEVICE_TABLE(of, al3320a_of_match); 250 249 250 + static const struct acpi_device_id al3320a_acpi_match[] = { 251 + {"CALS0001"}, 252 + { }, 253 + }; 254 + MODULE_DEVICE_TABLE(acpi, al3320a_acpi_match); 255 + 251 256 static struct i2c_driver al3320a_driver = { 252 257 .driver = { 253 258 .name = AL3320A_DRV_NAME, 254 259 .of_match_table = al3320a_of_match, 255 260 .pm = pm_sleep_ptr(&al3320a_pm_ops), 261 + .acpi_match_table = al3320a_acpi_match, 256 262 }, 257 - .probe_new = al3320a_probe, 263 + .probe = al3320a_probe, 258 264 .id_table = al3320a_id, 259 265 }; 260 266
+1 -1
drivers/iio/light/apds9300.c
··· 504 504 .name = APDS9300_DRV_NAME, 505 505 .pm = pm_sleep_ptr(&apds9300_pm_ops), 506 506 }, 507 - .probe_new = apds9300_probe, 507 + .probe = apds9300_probe, 508 508 .remove = apds9300_remove, 509 509 .id_table = apds9300_id, 510 510 };
+1 -1
drivers/iio/light/apds9960.c
··· 1131 1131 .pm = &apds9960_pm_ops, 1132 1132 .acpi_match_table = apds9960_acpi_match, 1133 1133 }, 1134 - .probe_new = apds9960_probe, 1134 + .probe = apds9960_probe, 1135 1135 .remove = apds9960_remove, 1136 1136 .id_table = apds9960_id, 1137 1137 };
+1 -1
drivers/iio/light/as73211.c
··· 790 790 .of_match_table = as73211_of_match, 791 791 .pm = pm_sleep_ptr(&as73211_pm_ops), 792 792 }, 793 - .probe_new = as73211_probe, 793 + .probe = as73211_probe, 794 794 .id_table = as73211_id, 795 795 }; 796 796 module_i2c_driver(as73211_driver);
+1 -1
drivers/iio/light/bh1750.c
··· 320 320 .of_match_table = bh1750_of_match, 321 321 .pm = pm_sleep_ptr(&bh1750_pm_ops), 322 322 }, 323 - .probe_new = bh1750_probe, 323 + .probe = bh1750_probe, 324 324 .remove = bh1750_remove, 325 325 .id_table = bh1750_id, 326 326
+1 -1
drivers/iio/light/bh1780.c
··· 269 269 MODULE_DEVICE_TABLE(of, of_bh1780_match); 270 270 271 271 static struct i2c_driver bh1780_driver = { 272 - .probe_new = bh1780_probe, 272 + .probe = bh1780_probe, 273 273 .remove = bh1780_remove, 274 274 .id_table = bh1780_id, 275 275 .driver = {
+1 -1
drivers/iio/light/cm32181.c
··· 542 542 .of_match_table = cm32181_of_match, 543 543 .pm = pm_sleep_ptr(&cm32181_pm_ops), 544 544 }, 545 - .probe_new = cm32181_probe, 545 + .probe = cm32181_probe, 546 546 }; 547 547 548 548 module_i2c_driver(cm32181_driver);
+1 -1
drivers/iio/light/cm3232.c
··· 417 417 .pm = pm_sleep_ptr(&cm3232_pm_ops), 418 418 }, 419 419 .id_table = cm3232_id, 420 - .probe_new = cm3232_probe, 420 + .probe = cm3232_probe, 421 421 .remove = cm3232_remove, 422 422 }; 423 423
+1 -1
drivers/iio/light/cm3323.c
··· 266 266 .name = CM3323_DRV_NAME, 267 267 .of_match_table = cm3323_of_match, 268 268 }, 269 - .probe_new = cm3323_probe, 269 + .probe = cm3323_probe, 270 270 .id_table = cm3323_id, 271 271 }; 272 272
+1 -1
drivers/iio/light/cm36651.c
··· 730 730 .name = "cm36651", 731 731 .of_match_table = cm36651_of_match, 732 732 }, 733 - .probe_new = cm36651_probe, 733 + .probe = cm36651_probe, 734 734 .remove = cm36651_remove, 735 735 .id_table = cm36651_id, 736 736 };
+1 -1
drivers/iio/light/gp2ap002.c
··· 710 710 .of_match_table = gp2ap002_of_match, 711 711 .pm = pm_ptr(&gp2ap002_dev_pm_ops), 712 712 }, 713 - .probe_new = gp2ap002_probe, 713 + .probe = gp2ap002_probe, 714 714 .remove = gp2ap002_remove, 715 715 .id_table = gp2ap002_id_table, 716 716 };
+1 -1
drivers/iio/light/gp2ap020a00f.c
··· 1609 1609 .name = GP2A_I2C_NAME, 1610 1610 .of_match_table = gp2ap020a00f_of_match, 1611 1611 }, 1612 - .probe_new = gp2ap020a00f_probe, 1612 + .probe = gp2ap020a00f_probe, 1613 1613 .remove = gp2ap020a00f_remove, 1614 1614 .id_table = gp2ap020a00f_id, 1615 1615 };
+1 -1
drivers/iio/light/isl29018.c
··· 865 865 .pm = pm_sleep_ptr(&isl29018_pm_ops), 866 866 .of_match_table = isl29018_of_match, 867 867 }, 868 - .probe_new = isl29018_probe, 868 + .probe = isl29018_probe, 869 869 .id_table = isl29018_id, 870 870 }; 871 871 module_i2c_driver(isl29018_driver);
+1 -1
drivers/iio/light/isl29028.c
··· 698 698 .pm = pm_ptr(&isl29028_pm_ops), 699 699 .of_match_table = isl29028_of_match, 700 700 }, 701 - .probe_new = isl29028_probe, 701 + .probe = isl29028_probe, 702 702 .remove = isl29028_remove, 703 703 .id_table = isl29028_id, 704 704 };
+1 -1
drivers/iio/light/isl29125.c
··· 337 337 .name = ISL29125_DRV_NAME, 338 338 .pm = pm_sleep_ptr(&isl29125_pm_ops), 339 339 }, 340 - .probe_new = isl29125_probe, 340 + .probe = isl29125_probe, 341 341 .remove = isl29125_remove, 342 342 .id_table = isl29125_id, 343 343 };
+1 -1
drivers/iio/light/jsa1212.c
··· 440 440 .pm = pm_sleep_ptr(&jsa1212_pm_ops), 441 441 .acpi_match_table = ACPI_PTR(jsa1212_acpi_match), 442 442 }, 443 - .probe_new = jsa1212_probe, 443 + .probe = jsa1212_probe, 444 444 .remove = jsa1212_remove, 445 445 .id_table = jsa1212_id, 446 446 };
+1 -1
drivers/iio/light/ltr501.c
··· 1641 1641 .pm = pm_sleep_ptr(&ltr501_pm_ops), 1642 1642 .acpi_match_table = ACPI_PTR(ltr_acpi_match), 1643 1643 }, 1644 - .probe_new = ltr501_probe, 1644 + .probe = ltr501_probe, 1645 1645 .remove = ltr501_remove, 1646 1646 .id_table = ltr501_id, 1647 1647 };
+1 -1
drivers/iio/light/ltrf216a.c
··· 539 539 .pm = pm_ptr(&ltrf216a_pm_ops), 540 540 .of_match_table = ltrf216a_of_match, 541 541 }, 542 - .probe_new = ltrf216a_probe, 542 + .probe = ltrf216a_probe, 543 543 .id_table = ltrf216a_id, 544 544 }; 545 545 module_i2c_driver(ltrf216a_driver);
+1 -1
drivers/iio/light/lv0104cs.c
··· 520 520 .name = "lv0104cs", 521 521 }, 522 522 .id_table = lv0104cs_id, 523 - .probe_new = lv0104cs_probe, 523 + .probe = lv0104cs_probe, 524 524 }; 525 525 module_i2c_driver(lv0104cs_i2c_driver); 526 526
+1 -1
drivers/iio/light/max44000.c
··· 616 616 .name = MAX44000_DRV_NAME, 617 617 .acpi_match_table = ACPI_PTR(max44000_acpi_match), 618 618 }, 619 - .probe_new = max44000_probe, 619 + .probe = max44000_probe, 620 620 .id_table = max44000_id, 621 621 }; 622 622
+1 -1
drivers/iio/light/max44009.c
··· 544 544 .name = MAX44009_DRV_NAME, 545 545 .of_match_table = max44009_of_match, 546 546 }, 547 - .probe_new = max44009_probe, 547 + .probe = max44009_probe, 548 548 .id_table = max44009_id, 549 549 }; 550 550 module_i2c_driver(max44009_driver);
+1 -1
drivers/iio/light/noa1305.c
··· 278 278 .name = NOA1305_DRIVER_NAME, 279 279 .of_match_table = noa1305_of_match, 280 280 }, 281 - .probe_new = noa1305_probe, 281 + .probe = noa1305_probe, 282 282 .id_table = noa1305_ids, 283 283 }; 284 284
+1 -1
drivers/iio/light/opt3001.c
··· 834 834 MODULE_DEVICE_TABLE(of, opt3001_of_match); 835 835 836 836 static struct i2c_driver opt3001_driver = { 837 - .probe_new = opt3001_probe, 837 + .probe = opt3001_probe, 838 838 .remove = opt3001_remove, 839 839 .id_table = opt3001_id, 840 840
+467
drivers/iio/light/opt4001.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2023 Axis Communications AB 4 + * 5 + * Datasheet: https://www.ti.com/lit/gpn/opt4001 6 + * 7 + * Device driver for the Texas Instruments OPT4001. 8 + */ 9 + 10 + #include <linux/bitfield.h> 11 + #include <linux/i2c.h> 12 + #include <linux/iio/iio.h> 13 + #include <linux/math64.h> 14 + #include <linux/module.h> 15 + #include <linux/property.h> 16 + #include <linux/regmap.h> 17 + #include <linux/regulator/consumer.h> 18 + 19 + /* OPT4001 register set */ 20 + #define OPT4001_LIGHT1_MSB 0x00 21 + #define OPT4001_LIGHT1_LSB 0x01 22 + #define OPT4001_CTRL 0x0A 23 + #define OPT4001_DEVICE_ID 0x11 24 + 25 + /* OPT4001 register mask */ 26 + #define OPT4001_EXPONENT_MASK GENMASK(15, 12) 27 + #define OPT4001_MSB_MASK GENMASK(11, 0) 28 + #define OPT4001_LSB_MASK GENMASK(15, 8) 29 + #define OPT4001_COUNTER_MASK GENMASK(7, 4) 30 + #define OPT4001_CRC_MASK GENMASK(3, 0) 31 + 32 + /* OPT4001 device id mask */ 33 + #define OPT4001_DEVICE_ID_MASK GENMASK(11, 0) 34 + 35 + /* OPT4001 control registers mask */ 36 + #define OPT4001_CTRL_QWAKE_MASK GENMASK(15, 15) 37 + #define OPT4001_CTRL_RANGE_MASK GENMASK(13, 10) 38 + #define OPT4001_CTRL_CONV_TIME_MASK GENMASK(9, 6) 39 + #define OPT4001_CTRL_OPER_MODE_MASK GENMASK(5, 4) 40 + #define OPT4001_CTRL_LATCH_MASK GENMASK(3, 3) 41 + #define OPT4001_CTRL_INT_POL_MASK GENMASK(2, 2) 42 + #define OPT4001_CTRL_FAULT_COUNT GENMASK(0, 1) 43 + 44 + /* OPT4001 constants */ 45 + #define OPT4001_DEVICE_ID_VAL 0x121 46 + 47 + /* OPT4001 operating modes */ 48 + #define OPT4001_CTRL_OPER_MODE_OFF 0x0 49 + #define OPT4001_CTRL_OPER_MODE_FORCED 0x1 50 + #define OPT4001_CTRL_OPER_MODE_ONE_SHOT 0x2 51 + #define OPT4001_CTRL_OPER_MODE_CONTINUOUS 0x3 52 + 53 + /* OPT4001 conversion control register definitions */ 54 + #define OPT4001_CTRL_CONVERSION_0_6MS 0x0 55 + #define OPT4001_CTRL_CONVERSION_1MS 0x1 56 + #define OPT4001_CTRL_CONVERSION_1_8MS 0x2 57 + #define OPT4001_CTRL_CONVERSION_3_4MS 0x3 58 + #define OPT4001_CTRL_CONVERSION_6_5MS 0x4 59 + #define OPT4001_CTRL_CONVERSION_12_7MS 0x5 60 + #define OPT4001_CTRL_CONVERSION_25MS 0x6 61 + #define OPT4001_CTRL_CONVERSION_50MS 0x7 62 + #define OPT4001_CTRL_CONVERSION_100MS 0x8 63 + #define OPT4001_CTRL_CONVERSION_200MS 0x9 64 + #define OPT4001_CTRL_CONVERSION_400MS 0xa 65 + #define OPT4001_CTRL_CONVERSION_800MS 0xb 66 + 67 + /* OPT4001 scale light level range definitions */ 68 + #define OPT4001_CTRL_LIGHT_SCALE_AUTO 12 69 + 70 + /* OPT4001 default values */ 71 + #define OPT4001_DEFAULT_CONVERSION_TIME OPT4001_CTRL_CONVERSION_800MS 72 + 73 + /* 74 + * The different packaging of OPT4001 has different constants used when calculating 75 + * lux values. 76 + */ 77 + struct opt4001_chip_info { 78 + int mul; 79 + int div; 80 + const char *name; 81 + }; 82 + 83 + struct opt4001_chip { 84 + struct regmap *regmap; 85 + struct i2c_client *client; 86 + u8 int_time; 87 + const struct opt4001_chip_info *chip_info; 88 + }; 89 + 90 + static const struct opt4001_chip_info opt4001_sot_5x3_info = { 91 + .mul = 4375, 92 + .div = 10000000, 93 + .name = "opt4001-sot-5x3" 94 + }; 95 + 96 + static const struct opt4001_chip_info opt4001_picostar_info = { 97 + .mul = 3125, 98 + .div = 10000000, 99 + .name = "opt4001-picostar" 100 + }; 101 + 102 + static const int opt4001_int_time_available[][2] = { 103 + { 0, 600 }, 104 + { 0, 1000 }, 105 + { 0, 1800 }, 106 + { 0, 3400 }, 107 + { 0, 6500 }, 108 + { 0, 12700 }, 109 + { 0, 25000 }, 110 + { 0, 50000 }, 111 + { 0, 100000 }, 112 + { 0, 200000 }, 113 + { 0, 400000 }, 114 + { 0, 800000 }, 115 + }; 116 + 117 + /* 118 + * Conversion time is integration time + time to set register 119 + * this is used as integration time. 120 + */ 121 + static const int opt4001_int_time_reg[][2] = { 122 + { 600, OPT4001_CTRL_CONVERSION_0_6MS }, 123 + { 1000, OPT4001_CTRL_CONVERSION_1MS }, 124 + { 1800, OPT4001_CTRL_CONVERSION_1_8MS }, 125 + { 3400, OPT4001_CTRL_CONVERSION_3_4MS }, 126 + { 6500, OPT4001_CTRL_CONVERSION_6_5MS }, 127 + { 12700, OPT4001_CTRL_CONVERSION_12_7MS }, 128 + { 25000, OPT4001_CTRL_CONVERSION_25MS }, 129 + { 50000, OPT4001_CTRL_CONVERSION_50MS }, 130 + { 100000, OPT4001_CTRL_CONVERSION_100MS }, 131 + { 200000, OPT4001_CTRL_CONVERSION_200MS }, 132 + { 400000, OPT4001_CTRL_CONVERSION_400MS }, 133 + { 800000, OPT4001_CTRL_CONVERSION_800MS }, 134 + }; 135 + 136 + static int opt4001_als_time_to_index(const u32 als_integration_time) 137 + { 138 + int i; 139 + 140 + for (i = 0; i < ARRAY_SIZE(opt4001_int_time_available); i++) { 141 + if (als_integration_time == opt4001_int_time_available[i][1]) 142 + return i; 143 + } 144 + 145 + return -EINVAL; 146 + } 147 + 148 + static u8 opt4001_calculate_crc(u8 exp, u32 mantissa, u8 count) 149 + { 150 + u8 crc; 151 + 152 + crc = (hweight32(mantissa) + hweight32(exp) + hweight32(count)) % 2; 153 + crc |= ((hweight32(mantissa & 0xAAAAA) + hweight32(exp & 0xA) 154 + + hweight32(count & 0xA)) % 2) << 1; 155 + crc |= ((hweight32(mantissa & 0x88888) + hweight32(exp & 0x8) 156 + + hweight32(count & 0x8)) % 2) << 2; 157 + crc |= (hweight32(mantissa & 0x80808) % 2) << 3; 158 + 159 + return crc; 160 + } 161 + 162 + static int opt4001_read_lux_value(struct iio_dev *indio_dev, 163 + int *val, int *val2) 164 + { 165 + struct opt4001_chip *chip = iio_priv(indio_dev); 166 + struct device *dev = &chip->client->dev; 167 + unsigned int light1; 168 + unsigned int light2; 169 + u16 msb; 170 + u16 lsb; 171 + u8 exp; 172 + u8 count; 173 + u8 crc; 174 + u8 calc_crc; 175 + u64 lux_raw; 176 + int ret; 177 + 178 + ret = regmap_read(chip->regmap, OPT4001_LIGHT1_MSB, &light1); 179 + if (ret < 0) { 180 + dev_err(dev, "Failed to read data bytes"); 181 + return ret; 182 + } 183 + 184 + ret = regmap_read(chip->regmap, OPT4001_LIGHT1_LSB, &light2); 185 + if (ret < 0) { 186 + dev_err(dev, "Failed to read data bytes"); 187 + return ret; 188 + } 189 + 190 + count = FIELD_GET(OPT4001_COUNTER_MASK, light2); 191 + exp = FIELD_GET(OPT4001_EXPONENT_MASK, light1); 192 + crc = FIELD_GET(OPT4001_CRC_MASK, light2); 193 + msb = FIELD_GET(OPT4001_MSB_MASK, light1); 194 + lsb = FIELD_GET(OPT4001_LSB_MASK, light2); 195 + lux_raw = (msb << 8) + lsb; 196 + calc_crc = opt4001_calculate_crc(exp, lux_raw, count); 197 + if (calc_crc != crc) 198 + return -EIO; 199 + 200 + lux_raw = lux_raw << exp; 201 + lux_raw = lux_raw * chip->chip_info->mul; 202 + *val = div_u64_rem(lux_raw, chip->chip_info->div, val2); 203 + *val2 = *val2 * 100; 204 + 205 + return IIO_VAL_INT_PLUS_NANO; 206 + } 207 + 208 + static int opt4001_set_conf(struct opt4001_chip *chip) 209 + { 210 + struct device *dev = &chip->client->dev; 211 + u16 reg; 212 + int ret; 213 + 214 + reg = FIELD_PREP(OPT4001_CTRL_RANGE_MASK, OPT4001_CTRL_LIGHT_SCALE_AUTO); 215 + reg |= FIELD_PREP(OPT4001_CTRL_CONV_TIME_MASK, chip->int_time); 216 + reg |= FIELD_PREP(OPT4001_CTRL_OPER_MODE_MASK, OPT4001_CTRL_OPER_MODE_CONTINUOUS); 217 + 218 + ret = regmap_write(chip->regmap, OPT4001_CTRL, reg); 219 + if (ret) 220 + dev_err(dev, "Failed to set configuration\n"); 221 + 222 + return ret; 223 + } 224 + 225 + static int opt4001_power_down(struct opt4001_chip *chip) 226 + { 227 + struct device *dev = &chip->client->dev; 228 + int ret; 229 + unsigned int reg; 230 + 231 + ret = regmap_read(chip->regmap, OPT4001_DEVICE_ID, &reg); 232 + if (ret) { 233 + dev_err(dev, "Failed to read configuration\n"); 234 + return ret; 235 + } 236 + 237 + /* MODE_OFF is 0x0 so just set bits to 0 */ 238 + reg &= ~OPT4001_CTRL_OPER_MODE_MASK; 239 + 240 + ret = regmap_write(chip->regmap, OPT4001_CTRL, reg); 241 + if (ret) 242 + dev_err(dev, "Failed to set configuration to power down\n"); 243 + 244 + return ret; 245 + } 246 + 247 + static void opt4001_chip_off_action(void *data) 248 + { 249 + struct opt4001_chip *chip = data; 250 + 251 + opt4001_power_down(chip); 252 + } 253 + 254 + static const struct iio_chan_spec opt4001_channels[] = { 255 + { 256 + .type = IIO_LIGHT, 257 + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), 258 + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME), 259 + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME) 260 + }, 261 + }; 262 + 263 + static int opt4001_read_raw(struct iio_dev *indio_dev, 264 + struct iio_chan_spec const *chan, 265 + int *val, int *val2, long mask) 266 + { 267 + struct opt4001_chip *chip = iio_priv(indio_dev); 268 + 269 + switch (mask) { 270 + case IIO_CHAN_INFO_PROCESSED: 271 + return opt4001_read_lux_value(indio_dev, val, val2); 272 + case IIO_CHAN_INFO_INT_TIME: 273 + *val = 0; 274 + *val2 = opt4001_int_time_reg[chip->int_time][0]; 275 + return IIO_VAL_INT_PLUS_MICRO; 276 + default: 277 + return -EINVAL; 278 + } 279 + } 280 + 281 + static int opt4001_write_raw(struct iio_dev *indio_dev, 282 + struct iio_chan_spec const *chan, 283 + int val, int val2, long mask) 284 + { 285 + struct opt4001_chip *chip = iio_priv(indio_dev); 286 + int int_time; 287 + 288 + switch (mask) { 289 + case IIO_CHAN_INFO_INT_TIME: 290 + int_time = opt4001_als_time_to_index(val2); 291 + if (int_time < 0) 292 + return int_time; 293 + chip->int_time = int_time; 294 + return opt4001_set_conf(chip); 295 + default: 296 + return -EINVAL; 297 + } 298 + } 299 + 300 + static int opt4001_read_available(struct iio_dev *indio_dev, 301 + struct iio_chan_spec const *chan, 302 + const int **vals, int *type, int *length, 303 + long mask) 304 + { 305 + switch (mask) { 306 + case IIO_CHAN_INFO_INT_TIME: 307 + *length = ARRAY_SIZE(opt4001_int_time_available) * 2; 308 + *vals = (const int *)opt4001_int_time_available; 309 + *type = IIO_VAL_INT_PLUS_MICRO; 310 + return IIO_AVAIL_LIST; 311 + 312 + default: 313 + return -EINVAL; 314 + } 315 + } 316 + 317 + static const struct iio_info opt4001_info_no_irq = { 318 + .read_raw = opt4001_read_raw, 319 + .write_raw = opt4001_write_raw, 320 + .read_avail = opt4001_read_available, 321 + }; 322 + 323 + static int opt4001_load_defaults(struct opt4001_chip *chip) 324 + { 325 + chip->int_time = OPT4001_DEFAULT_CONVERSION_TIME; 326 + 327 + return opt4001_set_conf(chip); 328 + } 329 + 330 + static bool opt4001_readable_reg(struct device *dev, unsigned int reg) 331 + { 332 + switch (reg) { 333 + case OPT4001_LIGHT1_MSB: 334 + case OPT4001_LIGHT1_LSB: 335 + case OPT4001_CTRL: 336 + case OPT4001_DEVICE_ID: 337 + return true; 338 + default: 339 + return false; 340 + } 341 + } 342 + 343 + static bool opt4001_writable_reg(struct device *dev, unsigned int reg) 344 + { 345 + switch (reg) { 346 + case OPT4001_CTRL: 347 + return true; 348 + default: 349 + return false; 350 + } 351 + } 352 + 353 + static bool opt4001_volatile_reg(struct device *dev, unsigned int reg) 354 + { 355 + switch (reg) { 356 + case OPT4001_LIGHT1_MSB: 357 + case OPT4001_LIGHT1_LSB: 358 + return true; 359 + default: 360 + return false; 361 + } 362 + } 363 + 364 + static const struct regmap_config opt4001_regmap_config = { 365 + .name = "opt4001", 366 + .reg_bits = 8, 367 + .val_bits = 16, 368 + .cache_type = REGCACHE_RBTREE, 369 + .max_register = OPT4001_DEVICE_ID, 370 + .readable_reg = opt4001_readable_reg, 371 + .writeable_reg = opt4001_writable_reg, 372 + .volatile_reg = opt4001_volatile_reg, 373 + .val_format_endian = REGMAP_ENDIAN_BIG, 374 + }; 375 + 376 + static int opt4001_probe(struct i2c_client *client) 377 + { 378 + struct opt4001_chip *chip; 379 + struct iio_dev *indio_dev; 380 + int ret; 381 + uint dev_id; 382 + 383 + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); 384 + if (!indio_dev) 385 + return -ENOMEM; 386 + 387 + chip = iio_priv(indio_dev); 388 + 389 + ret = devm_regulator_get_enable(&client->dev, "vdd"); 390 + if (ret) 391 + return dev_err_probe(&client->dev, ret, "Failed to enable vdd supply\n"); 392 + 393 + chip->regmap = devm_regmap_init_i2c(client, &opt4001_regmap_config); 394 + if (IS_ERR(chip->regmap)) 395 + return dev_err_probe(&client->dev, PTR_ERR(chip->regmap), 396 + "regmap initialization failed\n"); 397 + chip->client = client; 398 + 399 + indio_dev->info = &opt4001_info_no_irq; 400 + 401 + ret = regmap_reinit_cache(chip->regmap, &opt4001_regmap_config); 402 + if (ret) 403 + return dev_err_probe(&client->dev, ret, 404 + "failed to reinit regmap cache\n"); 405 + 406 + ret = regmap_read(chip->regmap, OPT4001_DEVICE_ID, &dev_id); 407 + if (ret < 0) 408 + return dev_err_probe(&client->dev, ret, 409 + "Failed to read the device ID register\n"); 410 + 411 + dev_id = FIELD_GET(OPT4001_DEVICE_ID_MASK, dev_id); 412 + if (dev_id != OPT4001_DEVICE_ID_VAL) 413 + dev_warn(&client->dev, "Device ID: %#04x unknown\n", dev_id); 414 + 415 + chip->chip_info = device_get_match_data(&client->dev); 416 + 417 + indio_dev->channels = opt4001_channels; 418 + indio_dev->num_channels = ARRAY_SIZE(opt4001_channels); 419 + indio_dev->modes = INDIO_DIRECT_MODE; 420 + indio_dev->name = chip->chip_info->name; 421 + 422 + ret = opt4001_load_defaults(chip); 423 + if (ret < 0) 424 + return dev_err_probe(&client->dev, ret, 425 + "Failed to set sensor defaults\n"); 426 + 427 + ret = devm_add_action_or_reset(&client->dev, 428 + opt4001_chip_off_action, 429 + chip); 430 + if (ret < 0) 431 + return dev_err_probe(&client->dev, ret, 432 + "Failed to setup power off action\n"); 433 + 434 + return devm_iio_device_register(&client->dev, indio_dev); 435 + } 436 + 437 + /* 438 + * The compatible string determines which constants to use depending on 439 + * opt4001 packaging 440 + */ 441 + static const struct i2c_device_id opt4001_id[] = { 442 + { "opt4001-sot-5x3", (kernel_ulong_t)&opt4001_sot_5x3_info }, 443 + { "opt4001-picostar", (kernel_ulong_t)&opt4001_picostar_info }, 444 + { } 445 + }; 446 + MODULE_DEVICE_TABLE(i2c, opt4001_id); 447 + 448 + static const struct of_device_id opt4001_of_match[] = { 449 + { .compatible = "ti,opt4001-sot-5x3", .data = &opt4001_sot_5x3_info}, 450 + { .compatible = "ti,opt4001-picostar", .data = &opt4001_picostar_info}, 451 + {} 452 + }; 453 + MODULE_DEVICE_TABLE(of, opt4001_of_match); 454 + 455 + static struct i2c_driver opt4001_driver = { 456 + .driver = { 457 + .name = "opt4001", 458 + .of_match_table = opt4001_of_match, 459 + }, 460 + .probe = opt4001_probe, 461 + .id_table = opt4001_id, 462 + }; 463 + module_i2c_driver(opt4001_driver); 464 + 465 + MODULE_AUTHOR("Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com>"); 466 + MODULE_DESCRIPTION("Texas Instruments opt4001 ambient light sensor driver"); 467 + MODULE_LICENSE("GPL");
+1 -1
drivers/iio/light/pa12203001.c
··· 474 474 .pm = &pa12203001_pm_ops, 475 475 .acpi_match_table = ACPI_PTR(pa12203001_acpi_match), 476 476 }, 477 - .probe_new = pa12203001_probe, 477 + .probe = pa12203001_probe, 478 478 .remove = pa12203001_remove, 479 479 .id_table = pa12203001_id, 480 480
+1026
drivers/iio/light/rohm-bu27008.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * BU27008 ROHM Colour Sensor 4 + * 5 + * Copyright (c) 2023, ROHM Semiconductor. 6 + */ 7 + 8 + #include <linux/bitfield.h> 9 + #include <linux/bitops.h> 10 + #include <linux/device.h> 11 + #include <linux/i2c.h> 12 + #include <linux/interrupt.h> 13 + #include <linux/module.h> 14 + #include <linux/property.h> 15 + #include <linux/regmap.h> 16 + #include <linux/regulator/consumer.h> 17 + #include <linux/units.h> 18 + 19 + #include <linux/iio/iio.h> 20 + #include <linux/iio/iio-gts-helper.h> 21 + #include <linux/iio/trigger.h> 22 + #include <linux/iio/trigger_consumer.h> 23 + #include <linux/iio/triggered_buffer.h> 24 + 25 + #define BU27008_REG_SYSTEM_CONTROL 0x40 26 + #define BU27008_MASK_SW_RESET BIT(7) 27 + #define BU27008_MASK_PART_ID GENMASK(5, 0) 28 + #define BU27008_ID 0x1a 29 + #define BU27008_REG_MODE_CONTROL1 0x41 30 + #define BU27008_MASK_MEAS_MODE GENMASK(2, 0) 31 + #define BU27008_MASK_CHAN_SEL GENMASK(3, 2) 32 + 33 + #define BU27008_REG_MODE_CONTROL2 0x42 34 + #define BU27008_MASK_RGBC_GAIN GENMASK(7, 3) 35 + #define BU27008_MASK_IR_GAIN_LO GENMASK(2, 0) 36 + #define BU27008_SHIFT_IR_GAIN 3 37 + 38 + #define BU27008_REG_MODE_CONTROL3 0x43 39 + #define BU27008_MASK_VALID BIT(7) 40 + #define BU27008_MASK_INT_EN BIT(1) 41 + #define BU27008_INT_EN BU27008_MASK_INT_EN 42 + #define BU27008_INT_DIS 0 43 + #define BU27008_MASK_MEAS_EN BIT(0) 44 + #define BU27008_MEAS_EN BIT(0) 45 + #define BU27008_MEAS_DIS 0 46 + 47 + #define BU27008_REG_DATA0_LO 0x50 48 + #define BU27008_REG_DATA1_LO 0x52 49 + #define BU27008_REG_DATA2_LO 0x54 50 + #define BU27008_REG_DATA3_LO 0x56 51 + #define BU27008_REG_DATA3_HI 0x57 52 + #define BU27008_REG_MANUFACTURER_ID 0x92 53 + #define BU27008_REG_MAX BU27008_REG_MANUFACTURER_ID 54 + 55 + /** 56 + * enum bu27008_chan_type - BU27008 channel types 57 + * @BU27008_RED: Red channel. Always via data0. 58 + * @BU27008_GREEN: Green channel. Always via data1. 59 + * @BU27008_BLUE: Blue channel. Via data2 (when used). 60 + * @BU27008_CLEAR: Clear channel. Via data2 or data3 (when used). 61 + * @BU27008_IR: IR channel. Via data3 (when used). 62 + * @BU27008_NUM_CHANS: Number of channel types. 63 + */ 64 + enum bu27008_chan_type { 65 + BU27008_RED, 66 + BU27008_GREEN, 67 + BU27008_BLUE, 68 + BU27008_CLEAR, 69 + BU27008_IR, 70 + BU27008_NUM_CHANS 71 + }; 72 + 73 + /** 74 + * enum bu27008_chan - BU27008 physical data channel 75 + * @BU27008_DATA0: Always red. 76 + * @BU27008_DATA1: Always green. 77 + * @BU27008_DATA2: Blue or clear. 78 + * @BU27008_DATA3: IR or clear. 79 + * @BU27008_NUM_HW_CHANS: Number of physical channels 80 + */ 81 + enum bu27008_chan { 82 + BU27008_DATA0, 83 + BU27008_DATA1, 84 + BU27008_DATA2, 85 + BU27008_DATA3, 86 + BU27008_NUM_HW_CHANS 87 + }; 88 + 89 + /* We can always measure red and green at same time */ 90 + #define ALWAYS_SCANNABLE (BIT(BU27008_RED) | BIT(BU27008_GREEN)) 91 + 92 + /* We use these data channel configs. Ensure scan_masks below follow them too */ 93 + #define BU27008_BLUE2_CLEAR3 0x0 /* buffer is R, G, B, C */ 94 + #define BU27008_CLEAR2_IR3 0x1 /* buffer is R, G, C, IR */ 95 + #define BU27008_BLUE2_IR3 0x2 /* buffer is R, G, B, IR */ 96 + 97 + static const unsigned long bu27008_scan_masks[] = { 98 + /* buffer is R, G, B, C */ 99 + ALWAYS_SCANNABLE | BIT(BU27008_BLUE) | BIT(BU27008_CLEAR), 100 + /* buffer is R, G, C, IR */ 101 + ALWAYS_SCANNABLE | BIT(BU27008_CLEAR) | BIT(BU27008_IR), 102 + /* buffer is R, G, B, IR */ 103 + ALWAYS_SCANNABLE | BIT(BU27008_BLUE) | BIT(BU27008_IR), 104 + 0 105 + }; 106 + 107 + /* 108 + * Available scales with gain 1x - 1024x, timings 55, 100, 200, 400 mS 109 + * Time impacts to gain: 1x, 2x, 4x, 8x. 110 + * 111 + * => Max total gain is HWGAIN * gain by integration time (8 * 1024) = 8192 112 + * 113 + * Max amplification is (HWGAIN * MAX integration-time multiplier) 1024 * 8 114 + * = 8192. With NANO scale we get rid of accuracy loss when we start with the 115 + * scale 16.0 for HWGAIN1, INT-TIME 55 mS. This way the nano scale for MAX 116 + * total gain 8192 will be 1953125 117 + */ 118 + #define BU27008_SCALE_1X 16 119 + 120 + /* See the data sheet for the "Gain Setting" table */ 121 + #define BU27008_GSEL_1X 0x00 122 + #define BU27008_GSEL_4X 0x08 123 + #define BU27008_GSEL_8X 0x09 124 + #define BU27008_GSEL_16X 0x0a 125 + #define BU27008_GSEL_32X 0x0b 126 + #define BU27008_GSEL_64X 0x0c 127 + #define BU27008_GSEL_256X 0x18 128 + #define BU27008_GSEL_512X 0x19 129 + #define BU27008_GSEL_1024X 0x1a 130 + 131 + static const struct iio_gain_sel_pair bu27008_gains[] = { 132 + GAIN_SCALE_GAIN(1, BU27008_GSEL_1X), 133 + GAIN_SCALE_GAIN(4, BU27008_GSEL_4X), 134 + GAIN_SCALE_GAIN(8, BU27008_GSEL_8X), 135 + GAIN_SCALE_GAIN(16, BU27008_GSEL_16X), 136 + GAIN_SCALE_GAIN(32, BU27008_GSEL_32X), 137 + GAIN_SCALE_GAIN(64, BU27008_GSEL_64X), 138 + GAIN_SCALE_GAIN(256, BU27008_GSEL_256X), 139 + GAIN_SCALE_GAIN(512, BU27008_GSEL_512X), 140 + GAIN_SCALE_GAIN(1024, BU27008_GSEL_1024X), 141 + }; 142 + 143 + static const struct iio_gain_sel_pair bu27008_gains_ir[] = { 144 + GAIN_SCALE_GAIN(2, BU27008_GSEL_1X), 145 + GAIN_SCALE_GAIN(4, BU27008_GSEL_4X), 146 + GAIN_SCALE_GAIN(8, BU27008_GSEL_8X), 147 + GAIN_SCALE_GAIN(16, BU27008_GSEL_16X), 148 + GAIN_SCALE_GAIN(32, BU27008_GSEL_32X), 149 + GAIN_SCALE_GAIN(64, BU27008_GSEL_64X), 150 + GAIN_SCALE_GAIN(256, BU27008_GSEL_256X), 151 + GAIN_SCALE_GAIN(512, BU27008_GSEL_512X), 152 + GAIN_SCALE_GAIN(1024, BU27008_GSEL_1024X), 153 + }; 154 + 155 + #define BU27008_MEAS_MODE_100MS 0x00 156 + #define BU27008_MEAS_MODE_55MS 0x01 157 + #define BU27008_MEAS_MODE_200MS 0x02 158 + #define BU27008_MEAS_MODE_400MS 0x04 159 + #define BU27008_MEAS_TIME_MAX_MS 400 160 + 161 + static const struct iio_itime_sel_mul bu27008_itimes[] = { 162 + GAIN_SCALE_ITIME_US(400000, BU27008_MEAS_MODE_400MS, 8), 163 + GAIN_SCALE_ITIME_US(200000, BU27008_MEAS_MODE_200MS, 4), 164 + GAIN_SCALE_ITIME_US(100000, BU27008_MEAS_MODE_100MS, 2), 165 + GAIN_SCALE_ITIME_US(55000, BU27008_MEAS_MODE_55MS, 1), 166 + }; 167 + 168 + /* 169 + * All the RGBC channels share the same gain. 170 + * IR gain can be fine-tuned from the gain set for the RGBC by 2 bit, but this 171 + * would yield quite complex gain setting. Especially since not all bit 172 + * compinations are supported. And in any case setting GAIN for RGBC will 173 + * always also change the IR-gain. 174 + * 175 + * On top of this, the selector '0' which corresponds to hw-gain 1X on RGBC, 176 + * corresponds to gain 2X on IR. Rest of the selctors correspond to same gains 177 + * though. This, however, makes it not possible to use shared gain for all 178 + * RGBC and IR settings even though they are all changed at the one go. 179 + */ 180 + #define BU27008_CHAN(color, data, separate_avail) \ 181 + { \ 182 + .type = IIO_INTENSITY, \ 183 + .modified = 1, \ 184 + .channel2 = IIO_MOD_LIGHT_##color, \ 185 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 186 + BIT(IIO_CHAN_INFO_SCALE), \ 187 + .info_mask_separate_available = (separate_avail), \ 188 + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), \ 189 + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME), \ 190 + .address = BU27008_REG_##data##_LO, \ 191 + .scan_index = BU27008_##color, \ 192 + .scan_type = { \ 193 + .sign = 's', \ 194 + .realbits = 16, \ 195 + .storagebits = 16, \ 196 + .endianness = IIO_LE, \ 197 + }, \ 198 + } 199 + 200 + /* For raw reads we always configure DATA3 for CLEAR */ 201 + static const struct iio_chan_spec bu27008_channels[] = { 202 + BU27008_CHAN(RED, DATA0, BIT(IIO_CHAN_INFO_SCALE)), 203 + BU27008_CHAN(GREEN, DATA1, BIT(IIO_CHAN_INFO_SCALE)), 204 + BU27008_CHAN(BLUE, DATA2, BIT(IIO_CHAN_INFO_SCALE)), 205 + BU27008_CHAN(CLEAR, DATA2, BIT(IIO_CHAN_INFO_SCALE)), 206 + /* 207 + * We don't allow setting scale for IR (because of shared gain bits). 208 + * Hence we don't advertise available ones either. 209 + */ 210 + BU27008_CHAN(IR, DATA3, 0), 211 + IIO_CHAN_SOFT_TIMESTAMP(BU27008_NUM_CHANS), 212 + }; 213 + 214 + struct bu27008_data { 215 + struct regmap *regmap; 216 + struct iio_trigger *trig; 217 + struct device *dev; 218 + struct iio_gts gts; 219 + struct iio_gts gts_ir; 220 + int irq; 221 + 222 + /* 223 + * Prevent changing gain/time config when scale is read/written. 224 + * Similarly, protect the integration_time read/change sequence. 225 + * Prevent changing gain/time when data is read. 226 + */ 227 + struct mutex mutex; 228 + }; 229 + 230 + static const struct regmap_range bu27008_volatile_ranges[] = { 231 + { 232 + .range_min = BU27008_REG_SYSTEM_CONTROL, /* SWRESET */ 233 + .range_max = BU27008_REG_SYSTEM_CONTROL, 234 + }, { 235 + .range_min = BU27008_REG_MODE_CONTROL3, /* VALID */ 236 + .range_max = BU27008_REG_MODE_CONTROL3, 237 + }, { 238 + .range_min = BU27008_REG_DATA0_LO, /* DATA */ 239 + .range_max = BU27008_REG_DATA3_HI, 240 + }, 241 + }; 242 + 243 + static const struct regmap_access_table bu27008_volatile_regs = { 244 + .yes_ranges = &bu27008_volatile_ranges[0], 245 + .n_yes_ranges = ARRAY_SIZE(bu27008_volatile_ranges), 246 + }; 247 + 248 + static const struct regmap_range bu27008_read_only_ranges[] = { 249 + { 250 + .range_min = BU27008_REG_DATA0_LO, 251 + .range_max = BU27008_REG_DATA3_HI, 252 + }, { 253 + .range_min = BU27008_REG_MANUFACTURER_ID, 254 + .range_max = BU27008_REG_MANUFACTURER_ID, 255 + }, 256 + }; 257 + 258 + static const struct regmap_access_table bu27008_ro_regs = { 259 + .no_ranges = &bu27008_read_only_ranges[0], 260 + .n_no_ranges = ARRAY_SIZE(bu27008_read_only_ranges), 261 + }; 262 + 263 + static const struct regmap_config bu27008_regmap = { 264 + .reg_bits = 8, 265 + .val_bits = 8, 266 + .max_register = BU27008_REG_MAX, 267 + .cache_type = REGCACHE_RBTREE, 268 + .volatile_table = &bu27008_volatile_regs, 269 + .wr_table = &bu27008_ro_regs, 270 + /* 271 + * All register writes are serialized by the mutex which protects the 272 + * scale setting/getting. This is needed because scale is combined by 273 + * gain and integration time settings and we need to ensure those are 274 + * not read / written when scale is being computed. 275 + * 276 + * As a result of this serializing, we don't need regmap locking. Note, 277 + * this is not true if we add any configurations which are not 278 + * serialized by the mutex and which may need for example a protected 279 + * read-modify-write cycle (eg. regmap_update_bits()). Please, revise 280 + * this when adding features to the driver. 281 + */ 282 + .disable_locking = true, 283 + }; 284 + 285 + #define BU27008_MAX_VALID_RESULT_WAIT_US 50000 286 + #define BU27008_VALID_RESULT_WAIT_QUANTA_US 1000 287 + 288 + static int bu27008_chan_read_data(struct bu27008_data *data, int reg, int *val) 289 + { 290 + int ret, valid; 291 + __le16 tmp; 292 + 293 + ret = regmap_read_poll_timeout(data->regmap, BU27008_REG_MODE_CONTROL3, 294 + valid, (valid & BU27008_MASK_VALID), 295 + BU27008_VALID_RESULT_WAIT_QUANTA_US, 296 + BU27008_MAX_VALID_RESULT_WAIT_US); 297 + if (ret) 298 + return ret; 299 + 300 + ret = regmap_bulk_read(data->regmap, reg, &tmp, sizeof(tmp)); 301 + if (ret) 302 + dev_err(data->dev, "Reading channel data failed\n"); 303 + 304 + *val = le16_to_cpu(tmp); 305 + 306 + return ret; 307 + } 308 + 309 + static int bu27008_get_gain(struct bu27008_data *data, struct iio_gts *gts, int *gain) 310 + { 311 + int ret, sel; 312 + 313 + ret = regmap_read(data->regmap, BU27008_REG_MODE_CONTROL2, &sel); 314 + if (ret) 315 + return ret; 316 + 317 + sel = FIELD_GET(BU27008_MASK_RGBC_GAIN, sel); 318 + 319 + ret = iio_gts_find_gain_by_sel(gts, sel); 320 + if (ret < 0) { 321 + dev_err(data->dev, "unknown gain value 0x%x\n", sel); 322 + return ret; 323 + } 324 + 325 + *gain = ret; 326 + 327 + return 0; 328 + } 329 + 330 + static int bu27008_write_gain_sel(struct bu27008_data *data, int sel) 331 + { 332 + int regval; 333 + 334 + regval = FIELD_PREP(BU27008_MASK_RGBC_GAIN, sel); 335 + 336 + /* 337 + * We do always set also the LOW bits of IR-gain because othervice we 338 + * would risk resulting an invalid GAIN register value. 339 + * 340 + * We could allow setting separate gains for RGBC and IR when the 341 + * values were such that HW could support both gain settings. 342 + * Eg, when the shared bits were same for both gain values. 343 + * 344 + * This, however, has a negligible benefit compared to the increased 345 + * software complexity when we would need to go through the gains 346 + * for both channels separately when the integration time changes. 347 + * This would end up with nasty logic for computing gain values for 348 + * both channels - and rejecting them if shared bits changed. 349 + * 350 + * We should then build the logic by guessing what a user prefers. 351 + * RGBC or IR gains correctly set while other jumps to odd value? 352 + * Maybe look-up a value where both gains are somehow optimized 353 + * <what this somehow is, is ATM unknown to us>. Or maybe user would 354 + * expect us to reject changes when optimal gains can't be set to both 355 + * channels w/given integration time. At best that would result 356 + * solution that works well for a very specific subset of 357 + * configurations but causes unexpected corner-cases. 358 + * 359 + * So, we keep it simple. Always set same selector to IR and RGBC. 360 + * We disallow setting IR (as I expect that most of the users are 361 + * interested in RGBC). This way we can show the user that the scales 362 + * for RGBC and IR channels are different (1X Vs 2X with sel 0) while 363 + * still keeping the operation deterministic. 364 + */ 365 + regval |= FIELD_PREP(BU27008_MASK_IR_GAIN_LO, sel); 366 + 367 + return regmap_update_bits(data->regmap, BU27008_REG_MODE_CONTROL2, 368 + BU27008_MASK_RGBC_GAIN, regval); 369 + } 370 + 371 + static int bu27008_set_gain(struct bu27008_data *data, int gain) 372 + { 373 + int ret; 374 + 375 + ret = iio_gts_find_sel_by_gain(&data->gts, gain); 376 + if (ret < 0) 377 + return ret; 378 + 379 + return bu27008_write_gain_sel(data, ret); 380 + } 381 + 382 + static int bu27008_get_int_time_sel(struct bu27008_data *data, int *sel) 383 + { 384 + int ret, val; 385 + 386 + ret = regmap_read(data->regmap, BU27008_REG_MODE_CONTROL1, &val); 387 + *sel = FIELD_GET(BU27008_MASK_MEAS_MODE, val); 388 + 389 + return ret; 390 + } 391 + 392 + static int bu27008_set_int_time_sel(struct bu27008_data *data, int sel) 393 + { 394 + return regmap_update_bits(data->regmap, BU27008_REG_MODE_CONTROL1, 395 + BU27008_MASK_MEAS_MODE, sel); 396 + } 397 + 398 + static int bu27008_get_int_time_us(struct bu27008_data *data) 399 + { 400 + int ret, sel; 401 + 402 + ret = bu27008_get_int_time_sel(data, &sel); 403 + if (ret) 404 + return ret; 405 + 406 + return iio_gts_find_int_time_by_sel(&data->gts, sel); 407 + } 408 + 409 + static int _bu27008_get_scale(struct bu27008_data *data, bool ir, int *val, 410 + int *val2) 411 + { 412 + struct iio_gts *gts; 413 + int gain, ret; 414 + 415 + if (ir) 416 + gts = &data->gts_ir; 417 + else 418 + gts = &data->gts; 419 + 420 + ret = bu27008_get_gain(data, gts, &gain); 421 + if (ret) 422 + return ret; 423 + 424 + ret = bu27008_get_int_time_us(data); 425 + if (ret < 0) 426 + return ret; 427 + 428 + return iio_gts_get_scale(gts, gain, ret, val, val2); 429 + } 430 + 431 + static int bu27008_get_scale(struct bu27008_data *data, bool ir, int *val, 432 + int *val2) 433 + { 434 + int ret; 435 + 436 + mutex_lock(&data->mutex); 437 + ret = _bu27008_get_scale(data, ir, val, val2); 438 + mutex_unlock(&data->mutex); 439 + 440 + return ret; 441 + } 442 + 443 + static int bu27008_set_int_time(struct bu27008_data *data, int time) 444 + { 445 + int ret; 446 + 447 + ret = iio_gts_find_sel_by_int_time(&data->gts, time); 448 + if (ret < 0) 449 + return ret; 450 + 451 + return regmap_update_bits(data->regmap, BU27008_REG_MODE_CONTROL1, 452 + BU27008_MASK_MEAS_MODE, ret); 453 + } 454 + 455 + /* Try to change the time so that the scale is maintained */ 456 + static int bu27008_try_set_int_time(struct bu27008_data *data, int int_time_new) 457 + { 458 + int ret, old_time_sel, new_time_sel, old_gain, new_gain; 459 + 460 + mutex_lock(&data->mutex); 461 + 462 + ret = bu27008_get_int_time_sel(data, &old_time_sel); 463 + if (ret < 0) 464 + goto unlock_out; 465 + 466 + if (!iio_gts_valid_time(&data->gts, int_time_new)) { 467 + dev_dbg(data->dev, "Unsupported integration time %u\n", 468 + int_time_new); 469 + 470 + ret = -EINVAL; 471 + goto unlock_out; 472 + } 473 + 474 + /* If we already use requested time, then we're done */ 475 + new_time_sel = iio_gts_find_sel_by_int_time(&data->gts, int_time_new); 476 + if (new_time_sel == old_time_sel) 477 + goto unlock_out; 478 + 479 + ret = bu27008_get_gain(data, &data->gts, &old_gain); 480 + if (ret) 481 + goto unlock_out; 482 + 483 + ret = iio_gts_find_new_gain_sel_by_old_gain_time(&data->gts, old_gain, 484 + old_time_sel, new_time_sel, &new_gain); 485 + if (ret) { 486 + int scale1, scale2; 487 + bool ok; 488 + 489 + _bu27008_get_scale(data, false, &scale1, &scale2); 490 + dev_dbg(data->dev, 491 + "Can't support time %u with current scale %u %u\n", 492 + int_time_new, scale1, scale2); 493 + 494 + if (new_gain < 0) 495 + goto unlock_out; 496 + 497 + /* 498 + * If caller requests for integration time change and we 499 + * can't support the scale - then the caller should be 500 + * prepared to 'pick up the pieces and deal with the 501 + * fact that the scale changed'. 502 + */ 503 + ret = iio_find_closest_gain_low(&data->gts, new_gain, &ok); 504 + if (!ok) 505 + dev_dbg(data->dev, "optimal gain out of range\n"); 506 + 507 + if (ret < 0) { 508 + dev_dbg(data->dev, 509 + "Total gain increase. Risk of saturation"); 510 + ret = iio_gts_get_min_gain(&data->gts); 511 + if (ret < 0) 512 + goto unlock_out; 513 + } 514 + new_gain = ret; 515 + dev_dbg(data->dev, "scale changed, new gain %u\n", new_gain); 516 + } 517 + 518 + ret = bu27008_set_gain(data, new_gain); 519 + if (ret) 520 + goto unlock_out; 521 + 522 + ret = bu27008_set_int_time(data, int_time_new); 523 + 524 + unlock_out: 525 + mutex_unlock(&data->mutex); 526 + 527 + return ret; 528 + } 529 + 530 + static int bu27008_meas_set(struct bu27008_data *data, int state) 531 + { 532 + return regmap_update_bits(data->regmap, BU27008_REG_MODE_CONTROL3, 533 + BU27008_MASK_MEAS_EN, state); 534 + } 535 + 536 + static int bu27008_chan_cfg(struct bu27008_data *data, 537 + struct iio_chan_spec const *chan) 538 + { 539 + int chan_sel; 540 + 541 + if (chan->scan_index == BU27008_BLUE) 542 + chan_sel = BU27008_BLUE2_CLEAR3; 543 + else 544 + chan_sel = BU27008_CLEAR2_IR3; 545 + 546 + chan_sel = FIELD_PREP(BU27008_MASK_CHAN_SEL, chan_sel); 547 + 548 + return regmap_update_bits(data->regmap, BU27008_REG_MODE_CONTROL3, 549 + BU27008_MASK_CHAN_SEL, chan_sel); 550 + } 551 + 552 + static int bu27008_read_one(struct bu27008_data *data, struct iio_dev *idev, 553 + struct iio_chan_spec const *chan, int *val, int *val2) 554 + { 555 + int ret, int_time; 556 + 557 + ret = bu27008_chan_cfg(data, chan); 558 + if (ret) 559 + return ret; 560 + 561 + ret = bu27008_meas_set(data, BU27008_MEAS_EN); 562 + if (ret) 563 + return ret; 564 + 565 + ret = bu27008_get_int_time_us(data); 566 + if (ret < 0) 567 + int_time = BU27008_MEAS_TIME_MAX_MS; 568 + else 569 + int_time = ret / USEC_PER_MSEC; 570 + 571 + msleep(int_time); 572 + 573 + ret = bu27008_chan_read_data(data, chan->address, val); 574 + if (!ret) 575 + ret = IIO_VAL_INT; 576 + 577 + if (bu27008_meas_set(data, BU27008_MEAS_DIS)) 578 + dev_warn(data->dev, "measurement disabling failed\n"); 579 + 580 + return ret; 581 + } 582 + 583 + static int bu27008_read_raw(struct iio_dev *idev, 584 + struct iio_chan_spec const *chan, 585 + int *val, int *val2, long mask) 586 + { 587 + struct bu27008_data *data = iio_priv(idev); 588 + int busy, ret; 589 + 590 + switch (mask) { 591 + case IIO_CHAN_INFO_RAW: 592 + busy = iio_device_claim_direct_mode(idev); 593 + if (busy) 594 + return -EBUSY; 595 + 596 + mutex_lock(&data->mutex); 597 + ret = bu27008_read_one(data, idev, chan, val, val2); 598 + mutex_unlock(&data->mutex); 599 + 600 + iio_device_release_direct_mode(idev); 601 + 602 + return ret; 603 + 604 + case IIO_CHAN_INFO_SCALE: 605 + ret = bu27008_get_scale(data, chan->scan_index == BU27008_IR, 606 + val, val2); 607 + if (ret) 608 + return ret; 609 + 610 + return IIO_VAL_INT_PLUS_NANO; 611 + 612 + case IIO_CHAN_INFO_INT_TIME: 613 + ret = bu27008_get_int_time_us(data); 614 + if (ret < 0) 615 + return ret; 616 + 617 + *val = 0; 618 + *val2 = ret; 619 + 620 + return IIO_VAL_INT_PLUS_MICRO; 621 + 622 + default: 623 + return -EINVAL; 624 + } 625 + } 626 + 627 + /* Called if the new scale could not be supported with existing int-time */ 628 + static int bu27008_try_find_new_time_gain(struct bu27008_data *data, int val, 629 + int val2, int *gain_sel) 630 + { 631 + int i, ret, new_time_sel; 632 + 633 + for (i = 0; i < data->gts.num_itime; i++) { 634 + new_time_sel = data->gts.itime_table[i].sel; 635 + ret = iio_gts_find_gain_sel_for_scale_using_time(&data->gts, 636 + new_time_sel, val, val2 * 1000, gain_sel); 637 + if (!ret) 638 + break; 639 + } 640 + if (i == data->gts.num_itime) { 641 + dev_err(data->dev, "Can't support scale %u %u\n", val, val2); 642 + 643 + return -EINVAL; 644 + } 645 + 646 + return bu27008_set_int_time_sel(data, new_time_sel); 647 + } 648 + 649 + static int bu27008_set_scale(struct bu27008_data *data, 650 + struct iio_chan_spec const *chan, 651 + int val, int val2) 652 + { 653 + int ret, gain_sel, time_sel; 654 + 655 + if (chan->scan_index == BU27008_IR) 656 + return -EINVAL; 657 + 658 + mutex_lock(&data->mutex); 659 + 660 + ret = bu27008_get_int_time_sel(data, &time_sel); 661 + if (ret < 0) 662 + goto unlock_out; 663 + 664 + ret = iio_gts_find_gain_sel_for_scale_using_time(&data->gts, time_sel, 665 + val, val2 * 1000, &gain_sel); 666 + if (ret) { 667 + ret = bu27008_try_find_new_time_gain(data, val, val2, &gain_sel); 668 + if (ret) 669 + goto unlock_out; 670 + 671 + } 672 + ret = bu27008_write_gain_sel(data, gain_sel); 673 + 674 + unlock_out: 675 + mutex_unlock(&data->mutex); 676 + 677 + return ret; 678 + } 679 + 680 + static int bu27008_write_raw(struct iio_dev *idev, 681 + struct iio_chan_spec const *chan, 682 + int val, int val2, long mask) 683 + { 684 + struct bu27008_data *data = iio_priv(idev); 685 + int ret; 686 + 687 + /* 688 + * Do not allow changing scale when measurement is ongoing as doing so 689 + * could make values in the buffer inconsistent. 690 + */ 691 + ret = iio_device_claim_direct_mode(idev); 692 + if (ret) 693 + return ret; 694 + 695 + switch (mask) { 696 + case IIO_CHAN_INFO_SCALE: 697 + ret = bu27008_set_scale(data, chan, val, val2); 698 + break; 699 + case IIO_CHAN_INFO_INT_TIME: 700 + if (val) { 701 + ret = -EINVAL; 702 + break; 703 + } 704 + ret = bu27008_try_set_int_time(data, val2); 705 + break; 706 + default: 707 + ret = -EINVAL; 708 + break; 709 + } 710 + iio_device_release_direct_mode(idev); 711 + 712 + return ret; 713 + } 714 + 715 + static int bu27008_read_avail(struct iio_dev *idev, 716 + struct iio_chan_spec const *chan, const int **vals, 717 + int *type, int *length, long mask) 718 + { 719 + struct bu27008_data *data = iio_priv(idev); 720 + 721 + switch (mask) { 722 + case IIO_CHAN_INFO_INT_TIME: 723 + return iio_gts_avail_times(&data->gts, vals, type, length); 724 + case IIO_CHAN_INFO_SCALE: 725 + if (chan->channel2 == IIO_MOD_LIGHT_IR) 726 + return iio_gts_all_avail_scales(&data->gts_ir, vals, 727 + type, length); 728 + return iio_gts_all_avail_scales(&data->gts, vals, type, length); 729 + default: 730 + return -EINVAL; 731 + } 732 + } 733 + 734 + static int bu27008_update_scan_mode(struct iio_dev *idev, 735 + const unsigned long *scan_mask) 736 + { 737 + struct bu27008_data *data = iio_priv(idev); 738 + int chan_sel; 739 + 740 + /* Configure channel selection */ 741 + if (test_bit(BU27008_BLUE, idev->active_scan_mask)) { 742 + if (test_bit(BU27008_CLEAR, idev->active_scan_mask)) 743 + chan_sel = BU27008_BLUE2_CLEAR3; 744 + else 745 + chan_sel = BU27008_BLUE2_IR3; 746 + } else { 747 + chan_sel = BU27008_CLEAR2_IR3; 748 + } 749 + 750 + chan_sel = FIELD_PREP(BU27008_MASK_CHAN_SEL, chan_sel); 751 + 752 + return regmap_update_bits(data->regmap, BU27008_REG_MODE_CONTROL3, 753 + BU27008_MASK_CHAN_SEL, chan_sel); 754 + } 755 + 756 + static const struct iio_info bu27008_info = { 757 + .read_raw = &bu27008_read_raw, 758 + .write_raw = &bu27008_write_raw, 759 + .read_avail = &bu27008_read_avail, 760 + .update_scan_mode = bu27008_update_scan_mode, 761 + .validate_trigger = iio_validate_own_trigger, 762 + }; 763 + 764 + static int bu27008_chip_init(struct bu27008_data *data) 765 + { 766 + int ret; 767 + 768 + ret = regmap_write_bits(data->regmap, BU27008_REG_SYSTEM_CONTROL, 769 + BU27008_MASK_SW_RESET, BU27008_MASK_SW_RESET); 770 + if (ret) 771 + return dev_err_probe(data->dev, ret, "Sensor reset failed\n"); 772 + 773 + /* 774 + * The data-sheet does not tell how long performing the IC reset takes. 775 + * However, the data-sheet says the minimum time it takes the IC to be 776 + * able to take inputs after power is applied, is 100 uS. I'd assume 777 + * > 1 mS is enough. 778 + */ 779 + msleep(1); 780 + 781 + ret = regmap_reinit_cache(data->regmap, &bu27008_regmap); 782 + if (ret) 783 + dev_err(data->dev, "Failed to reinit reg cache\n"); 784 + 785 + return ret; 786 + } 787 + 788 + static int bu27008_set_drdy_irq(struct bu27008_data *data, int state) 789 + { 790 + return regmap_update_bits(data->regmap, BU27008_REG_MODE_CONTROL3, 791 + BU27008_MASK_INT_EN, state); 792 + } 793 + 794 + static int bu27008_trigger_set_state(struct iio_trigger *trig, 795 + bool state) 796 + { 797 + struct bu27008_data *data = iio_trigger_get_drvdata(trig); 798 + int ret; 799 + 800 + if (state) 801 + ret = bu27008_set_drdy_irq(data, BU27008_INT_EN); 802 + else 803 + ret = bu27008_set_drdy_irq(data, BU27008_INT_DIS); 804 + if (ret) 805 + dev_err(data->dev, "Failed to set trigger state\n"); 806 + 807 + return ret; 808 + } 809 + 810 + static void bu27008_trigger_reenable(struct iio_trigger *trig) 811 + { 812 + struct bu27008_data *data = iio_trigger_get_drvdata(trig); 813 + 814 + enable_irq(data->irq); 815 + } 816 + 817 + static const struct iio_trigger_ops bu27008_trigger_ops = { 818 + .set_trigger_state = bu27008_trigger_set_state, 819 + .reenable = bu27008_trigger_reenable, 820 + }; 821 + 822 + static irqreturn_t bu27008_trigger_handler(int irq, void *p) 823 + { 824 + struct iio_poll_func *pf = p; 825 + struct iio_dev *idev = pf->indio_dev; 826 + struct bu27008_data *data = iio_priv(idev); 827 + struct { 828 + __le16 chan[BU27008_NUM_HW_CHANS]; 829 + s64 ts __aligned(8); 830 + } raw; 831 + int ret, dummy; 832 + 833 + memset(&raw, 0, sizeof(raw)); 834 + 835 + /* 836 + * After some measurements, it seems reading the 837 + * BU27008_REG_MODE_CONTROL3 debounces the IRQ line 838 + */ 839 + ret = regmap_read(data->regmap, BU27008_REG_MODE_CONTROL3, &dummy); 840 + if (ret < 0) 841 + goto err_read; 842 + 843 + ret = regmap_bulk_read(data->regmap, BU27008_REG_DATA0_LO, &raw.chan, 844 + sizeof(raw.chan)); 845 + if (ret < 0) 846 + goto err_read; 847 + 848 + iio_push_to_buffers_with_timestamp(idev, &raw, pf->timestamp); 849 + err_read: 850 + iio_trigger_notify_done(idev->trig); 851 + 852 + return IRQ_HANDLED; 853 + } 854 + 855 + static int bu27008_buffer_preenable(struct iio_dev *idev) 856 + { 857 + struct bu27008_data *data = iio_priv(idev); 858 + 859 + return bu27008_meas_set(data, BU27008_MEAS_EN); 860 + } 861 + 862 + static int bu27008_buffer_postdisable(struct iio_dev *idev) 863 + { 864 + struct bu27008_data *data = iio_priv(idev); 865 + 866 + return bu27008_meas_set(data, BU27008_MEAS_DIS); 867 + } 868 + 869 + static const struct iio_buffer_setup_ops bu27008_buffer_ops = { 870 + .preenable = bu27008_buffer_preenable, 871 + .postdisable = bu27008_buffer_postdisable, 872 + }; 873 + 874 + static irqreturn_t bu27008_data_rdy_poll(int irq, void *private) 875 + { 876 + /* 877 + * The BU27008 keeps IRQ asserted until we read the VALID bit from 878 + * a register. We need to keep the IRQ disabled until then. 879 + */ 880 + disable_irq_nosync(irq); 881 + iio_trigger_poll(private); 882 + 883 + return IRQ_HANDLED; 884 + } 885 + 886 + static int bu27008_setup_trigger(struct bu27008_data *data, struct iio_dev *idev) 887 + { 888 + struct iio_trigger *itrig; 889 + char *name; 890 + int ret; 891 + 892 + ret = devm_iio_triggered_buffer_setup(data->dev, idev, 893 + &iio_pollfunc_store_time, 894 + bu27008_trigger_handler, 895 + &bu27008_buffer_ops); 896 + if (ret) 897 + return dev_err_probe(data->dev, ret, 898 + "iio_triggered_buffer_setup_ext FAIL\n"); 899 + 900 + itrig = devm_iio_trigger_alloc(data->dev, "%sdata-rdy-dev%d", 901 + idev->name, iio_device_id(idev)); 902 + if (!itrig) 903 + return -ENOMEM; 904 + 905 + data->trig = itrig; 906 + 907 + itrig->ops = &bu27008_trigger_ops; 908 + iio_trigger_set_drvdata(itrig, data); 909 + 910 + name = devm_kasprintf(data->dev, GFP_KERNEL, "%s-bu27008", 911 + dev_name(data->dev)); 912 + 913 + ret = devm_request_irq(data->dev, data->irq, 914 + &bu27008_data_rdy_poll, 915 + 0, name, itrig); 916 + if (ret) 917 + return dev_err_probe(data->dev, ret, "Could not request IRQ\n"); 918 + 919 + ret = devm_iio_trigger_register(data->dev, itrig); 920 + if (ret) 921 + return dev_err_probe(data->dev, ret, 922 + "Trigger registration failed\n"); 923 + 924 + /* set default trigger */ 925 + idev->trig = iio_trigger_get(itrig); 926 + 927 + return 0; 928 + } 929 + 930 + static int bu27008_probe(struct i2c_client *i2c) 931 + { 932 + struct device *dev = &i2c->dev; 933 + struct bu27008_data *data; 934 + struct regmap *regmap; 935 + unsigned int part_id, reg; 936 + struct iio_dev *idev; 937 + int ret; 938 + 939 + regmap = devm_regmap_init_i2c(i2c, &bu27008_regmap); 940 + if (IS_ERR(regmap)) 941 + return dev_err_probe(dev, PTR_ERR(regmap), 942 + "Failed to initialize Regmap\n"); 943 + 944 + idev = devm_iio_device_alloc(dev, sizeof(*data)); 945 + if (!idev) 946 + return -ENOMEM; 947 + 948 + ret = devm_regulator_get_enable(dev, "vdd"); 949 + if (ret) 950 + return dev_err_probe(dev, ret, "Failed to get regulator\n"); 951 + 952 + data = iio_priv(idev); 953 + 954 + ret = regmap_read(regmap, BU27008_REG_SYSTEM_CONTROL, &reg); 955 + if (ret) 956 + return dev_err_probe(dev, ret, "Failed to access sensor\n"); 957 + 958 + part_id = FIELD_GET(BU27008_MASK_PART_ID, reg); 959 + 960 + if (part_id != BU27008_ID) 961 + dev_warn(dev, "unknown device 0x%x\n", part_id); 962 + 963 + ret = devm_iio_init_iio_gts(dev, BU27008_SCALE_1X, 0, bu27008_gains, 964 + ARRAY_SIZE(bu27008_gains), bu27008_itimes, 965 + ARRAY_SIZE(bu27008_itimes), &data->gts); 966 + if (ret) 967 + return ret; 968 + 969 + ret = devm_iio_init_iio_gts(dev, BU27008_SCALE_1X, 0, bu27008_gains_ir, 970 + ARRAY_SIZE(bu27008_gains_ir), bu27008_itimes, 971 + ARRAY_SIZE(bu27008_itimes), &data->gts_ir); 972 + if (ret) 973 + return ret; 974 + 975 + mutex_init(&data->mutex); 976 + data->regmap = regmap; 977 + data->dev = dev; 978 + data->irq = i2c->irq; 979 + 980 + idev->channels = bu27008_channels; 981 + idev->num_channels = ARRAY_SIZE(bu27008_channels); 982 + idev->name = "bu27008"; 983 + idev->info = &bu27008_info; 984 + idev->modes = INDIO_DIRECT_MODE; 985 + idev->available_scan_masks = bu27008_scan_masks; 986 + 987 + ret = bu27008_chip_init(data); 988 + if (ret) 989 + return ret; 990 + 991 + if (i2c->irq) { 992 + ret = bu27008_setup_trigger(data, idev); 993 + if (ret) 994 + return ret; 995 + } else { 996 + dev_info(dev, "No IRQ, buffered mode disabled\n"); 997 + } 998 + 999 + ret = devm_iio_device_register(dev, idev); 1000 + if (ret) 1001 + return dev_err_probe(dev, ret, 1002 + "Unable to register iio device\n"); 1003 + 1004 + return 0; 1005 + } 1006 + 1007 + static const struct of_device_id bu27008_of_match[] = { 1008 + { .compatible = "rohm,bu27008" }, 1009 + { } 1010 + }; 1011 + MODULE_DEVICE_TABLE(of, bu27008_of_match); 1012 + 1013 + static struct i2c_driver bu27008_i2c_driver = { 1014 + .driver = { 1015 + .name = "bu27008", 1016 + .of_match_table = bu27008_of_match, 1017 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1018 + }, 1019 + .probe = bu27008_probe, 1020 + }; 1021 + module_i2c_driver(bu27008_i2c_driver); 1022 + 1023 + MODULE_DESCRIPTION("ROHM BU27008 colour sensor driver"); 1024 + MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); 1025 + MODULE_LICENSE("GPL"); 1026 + MODULE_IMPORT_NS(IIO_GTS_HELPER);
+2 -1
drivers/iio/light/rohm-bu27034.c
··· 1500 1500 .driver = { 1501 1501 .name = "bu27034-als", 1502 1502 .of_match_table = bu27034_of_match, 1503 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1503 1504 }, 1504 - .probe_new = bu27034_probe, 1505 + .probe = bu27034_probe, 1505 1506 }; 1506 1507 module_i2c_driver(bu27034_i2c_driver); 1507 1508
+1 -1
drivers/iio/light/rpr0521.c
··· 1121 1121 .pm = pm_ptr(&rpr0521_pm_ops), 1122 1122 .acpi_match_table = ACPI_PTR(rpr0521_acpi_match), 1123 1123 }, 1124 - .probe_new = rpr0521_probe, 1124 + .probe = rpr0521_probe, 1125 1125 .remove = rpr0521_remove, 1126 1126 .id_table = rpr0521_id, 1127 1127 };
+1 -1
drivers/iio/light/si1133.c
··· 1064 1064 .driver = { 1065 1065 .name = "si1133", 1066 1066 }, 1067 - .probe_new = si1133_probe, 1067 + .probe = si1133_probe, 1068 1068 .id_table = si1133_ids, 1069 1069 }; 1070 1070
+1 -1
drivers/iio/light/si1145.c
··· 1352 1352 .driver = { 1353 1353 .name = "si1145", 1354 1354 }, 1355 - .probe_new = si1145_probe, 1355 + .probe = si1145_probe, 1356 1356 .id_table = si1145_ids, 1357 1357 }; 1358 1358
+1 -1
drivers/iio/light/st_uvis25_i2c.c
··· 57 57 .pm = pm_sleep_ptr(&st_uvis25_pm_ops), 58 58 .of_match_table = st_uvis25_i2c_of_match, 59 59 }, 60 - .probe_new = st_uvis25_i2c_probe, 60 + .probe = st_uvis25_i2c_probe, 61 61 .id_table = st_uvis25_i2c_id_table, 62 62 }; 63 63 module_i2c_driver(st_uvis25_driver);
+1 -1
drivers/iio/light/stk3310.c
··· 714 714 .pm = pm_sleep_ptr(&stk3310_pm_ops), 715 715 .acpi_match_table = ACPI_PTR(stk3310_acpi_id), 716 716 }, 717 - .probe_new = stk3310_probe, 717 + .probe = stk3310_probe, 718 718 .remove = stk3310_remove, 719 719 .id_table = stk3310_i2c_id, 720 720 };
+1 -1
drivers/iio/light/tcs3414.c
··· 373 373 .name = TCS3414_DRV_NAME, 374 374 .pm = pm_sleep_ptr(&tcs3414_pm_ops), 375 375 }, 376 - .probe_new = tcs3414_probe, 376 + .probe = tcs3414_probe, 377 377 .id_table = tcs3414_id, 378 378 }; 379 379 module_i2c_driver(tcs3414_driver);
+1 -1
drivers/iio/light/tcs3472.c
··· 609 609 .name = TCS3472_DRV_NAME, 610 610 .pm = pm_sleep_ptr(&tcs3472_pm_ops), 611 611 }, 612 - .probe_new = tcs3472_probe, 612 + .probe = tcs3472_probe, 613 613 .remove = tcs3472_remove, 614 614 .id_table = tcs3472_id, 615 615 };
+1 -1
drivers/iio/light/tsl2563.c
··· 862 862 .of_match_table = tsl2563_of_match, 863 863 .pm = pm_sleep_ptr(&tsl2563_pm_ops), 864 864 }, 865 - .probe_new = tsl2563_probe, 865 + .probe = tsl2563_probe, 866 866 .remove = tsl2563_remove, 867 867 .id_table = tsl2563_id, 868 868 };
+1 -1
drivers/iio/light/tsl2583.c
··· 942 942 .of_match_table = tsl2583_of_match, 943 943 }, 944 944 .id_table = tsl2583_idtable, 945 - .probe_new = tsl2583_probe, 945 + .probe = tsl2583_probe, 946 946 .remove = tsl2583_remove, 947 947 }; 948 948 module_i2c_driver(tsl2583_driver);
+1 -1
drivers/iio/light/tsl2591.c
··· 1214 1214 .pm = pm_ptr(&tsl2591_pm_ops), 1215 1215 .of_match_table = tsl2591_of_match, 1216 1216 }, 1217 - .probe_new = tsl2591_probe 1217 + .probe = tsl2591_probe 1218 1218 }; 1219 1219 module_i2c_driver(tsl2591_driver); 1220 1220
+1 -1
drivers/iio/light/tsl2772.c
··· 1932 1932 .pm = &tsl2772_pm_ops, 1933 1933 }, 1934 1934 .id_table = tsl2772_idtable, 1935 - .probe_new = tsl2772_probe, 1935 + .probe = tsl2772_probe, 1936 1936 }; 1937 1937 1938 1938 module_i2c_driver(tsl2772_driver);
+1 -1
drivers/iio/light/tsl4531.c
··· 237 237 .name = TSL4531_DRV_NAME, 238 238 .pm = pm_sleep_ptr(&tsl4531_pm_ops), 239 239 }, 240 - .probe_new = tsl4531_probe, 240 + .probe = tsl4531_probe, 241 241 .remove = tsl4531_remove, 242 242 .id_table = tsl4531_id, 243 243 };
+1 -1
drivers/iio/light/us5182d.c
··· 974 974 .of_match_table = us5182d_of_match, 975 975 .acpi_match_table = ACPI_PTR(us5182d_acpi_match), 976 976 }, 977 - .probe_new = us5182d_probe, 977 + .probe = us5182d_probe, 978 978 .remove = us5182d_remove, 979 979 .id_table = us5182d_id, 980 980
+1 -1
drivers/iio/light/vcnl4000.c
··· 1500 1500 .pm = pm_ptr(&vcnl4000_pm_ops), 1501 1501 .of_match_table = vcnl_4000_of_match, 1502 1502 }, 1503 - .probe_new = vcnl4000_probe, 1503 + .probe = vcnl4000_probe, 1504 1504 .id_table = vcnl4000_id, 1505 1505 .remove = vcnl4000_remove, 1506 1506 };
+1 -1
drivers/iio/light/vcnl4035.c
··· 670 670 .pm = pm_ptr(&vcnl4035_pm_ops), 671 671 .of_match_table = vcnl4035_of_match, 672 672 }, 673 - .probe_new = vcnl4035_probe, 673 + .probe = vcnl4035_probe, 674 674 .remove = vcnl4035_remove, 675 675 .id_table = vcnl4035_id, 676 676 };
+1 -1
drivers/iio/light/veml6030.c
··· 892 892 .of_match_table = veml6030_of_match, 893 893 .pm = pm_ptr(&veml6030_pm_ops), 894 894 }, 895 - .probe_new = veml6030_probe, 895 + .probe = veml6030_probe, 896 896 .id_table = veml6030_id, 897 897 }; 898 898 module_i2c_driver(veml6030_driver);
+1 -1
drivers/iio/light/veml6070.c
··· 198 198 .driver = { 199 199 .name = VEML6070_DRV_NAME, 200 200 }, 201 - .probe_new = veml6070_probe, 201 + .probe = veml6070_probe, 202 202 .remove = veml6070_remove, 203 203 .id_table = veml6070_id, 204 204 };
+1 -1
drivers/iio/light/vl6180.c
··· 538 538 .name = VL6180_DRV_NAME, 539 539 .of_match_table = vl6180_of_match, 540 540 }, 541 - .probe_new = vl6180_probe, 541 + .probe = vl6180_probe, 542 542 .id_table = vl6180_id, 543 543 }; 544 544
+1 -1
drivers/iio/light/zopt2201.c
··· 554 554 .driver = { 555 555 .name = ZOPT2201_DRV_NAME, 556 556 }, 557 - .probe_new = zopt2201_probe, 557 + .probe = zopt2201_probe, 558 558 .id_table = zopt2201_id, 559 559 }; 560 560
+1 -1
drivers/iio/magnetometer/ak8974.c
··· 1046 1046 .pm = pm_ptr(&ak8974_dev_pm_ops), 1047 1047 .of_match_table = ak8974_of_match, 1048 1048 }, 1049 - .probe_new = ak8974_probe, 1049 + .probe = ak8974_probe, 1050 1050 .remove = ak8974_remove, 1051 1051 .id_table = ak8974_id, 1052 1052 };
+1 -1
drivers/iio/magnetometer/ak8975.c
··· 1110 1110 .of_match_table = ak8975_of_match, 1111 1111 .acpi_match_table = ak_acpi_match, 1112 1112 }, 1113 - .probe_new = ak8975_probe, 1113 + .probe = ak8975_probe, 1114 1114 .remove = ak8975_remove, 1115 1115 .id_table = ak8975_id, 1116 1116 };
+1 -1
drivers/iio/magnetometer/bmc150_magn_i2c.c
··· 71 71 .acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match), 72 72 .pm = &bmc150_magn_pm_ops, 73 73 }, 74 - .probe_new = bmc150_magn_i2c_probe, 74 + .probe = bmc150_magn_i2c_probe, 75 75 .remove = bmc150_magn_i2c_remove, 76 76 .id_table = bmc150_magn_i2c_id, 77 77 };
+1 -1
drivers/iio/magnetometer/hmc5843_i2c.c
··· 95 95 .of_match_table = hmc5843_of_match, 96 96 }, 97 97 .id_table = hmc5843_id, 98 - .probe_new = hmc5843_i2c_probe, 98 + .probe = hmc5843_i2c_probe, 99 99 .remove = hmc5843_i2c_remove, 100 100 }; 101 101 module_i2c_driver(hmc5843_driver);
+1 -1
drivers/iio/magnetometer/mag3110.c
··· 641 641 .of_match_table = mag3110_of_match, 642 642 .pm = pm_sleep_ptr(&mag3110_pm_ops), 643 643 }, 644 - .probe_new = mag3110_probe, 644 + .probe = mag3110_probe, 645 645 .remove = mag3110_remove, 646 646 .id_table = mag3110_id, 647 647 };
+1 -1
drivers/iio/magnetometer/mmc35240.c
··· 575 575 .pm = pm_sleep_ptr(&mmc35240_pm_ops), 576 576 .acpi_match_table = ACPI_PTR(mmc35240_acpi_match), 577 577 }, 578 - .probe_new = mmc35240_probe, 578 + .probe = mmc35240_probe, 579 579 .id_table = mmc35240_id, 580 580 }; 581 581
+1 -1
drivers/iio/magnetometer/rm3100-i2c.c
··· 45 45 .name = "rm3100-i2c", 46 46 .of_match_table = rm3100_dt_match, 47 47 }, 48 - .probe_new = rm3100_probe, 48 + .probe = rm3100_probe, 49 49 }; 50 50 module_i2c_driver(rm3100_driver); 51 51
+1
drivers/iio/magnetometer/st_magn_core.c
··· 427 427 .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, 428 428 .sensors_supported = { 429 429 [0] = LSM9DS0_IMU_DEV_NAME, 430 + [1] = LSM303D_IMU_DEV_NAME, 430 431 }, 431 432 .ch = (struct iio_chan_spec *)st_magn_4_16bit_channels, 432 433 .odr = {
+1 -1
drivers/iio/magnetometer/st_magn_i2c.c
··· 111 111 .name = "st-magn-i2c", 112 112 .of_match_table = st_magn_of_match, 113 113 }, 114 - .probe_new = st_magn_i2c_probe, 114 + .probe = st_magn_i2c_probe, 115 115 .id_table = st_magn_id_table, 116 116 }; 117 117 module_i2c_driver(st_magn_driver);
+1 -1
drivers/iio/magnetometer/tmag5273.c
··· 734 734 .of_match_table = tmag5273_of_match, 735 735 .pm = pm_ptr(&tmag5273_pm_ops), 736 736 }, 737 - .probe_new = tmag5273_probe, 737 + .probe = tmag5273_probe, 738 738 .id_table = tmag5273_id, 739 739 }; 740 740 module_i2c_driver(tmag5273_driver);
+1 -1
drivers/iio/magnetometer/yamaha-yas530.c
··· 1605 1605 .of_match_table = yas5xx_of_match, 1606 1606 .pm = pm_ptr(&yas5xx_dev_pm_ops), 1607 1607 }, 1608 - .probe_new = yas5xx_probe, 1608 + .probe = yas5xx_probe, 1609 1609 .remove = yas5xx_remove, 1610 1610 .id_table = yas5xx_id, 1611 1611 };
+10
drivers/iio/potentiometer/Kconfig
··· 136 136 To compile this driver as a module, choose M here: the 137 137 module will be called tpl0102. 138 138 139 + config X9250 140 + tristate "Renesas X9250 quad controlled potentiometers" 141 + depends on SPI 142 + help 143 + Enable support for the Renesas X9250 quad controlled 144 + potentiometers. 145 + 146 + To compile this driver as a module, choose M here: the module 147 + will be called x9250. 148 + 139 149 endmenu
+1
drivers/iio/potentiometer/Makefile
··· 15 15 obj-$(CONFIG_MCP4531) += mcp4531.o 16 16 obj-$(CONFIG_MCP41010) += mcp41010.o 17 17 obj-$(CONFIG_TPL0102) += tpl0102.o 18 + obj-$(CONFIG_X9250) += x9250.o
+1 -1
drivers/iio/potentiometer/ad5110.c
··· 334 334 .name = "ad5110", 335 335 .of_match_table = ad5110_of_match, 336 336 }, 337 - .probe_new = ad5110_probe, 337 + .probe = ad5110_probe, 338 338 .id_table = ad5110_id, 339 339 }; 340 340 module_i2c_driver(ad5110_driver);
+1 -1
drivers/iio/potentiometer/ad5272.c
··· 218 218 .name = "ad5272", 219 219 .of_match_table = ad5272_dt_ids, 220 220 }, 221 - .probe_new = ad5272_probe, 221 + .probe = ad5272_probe, 222 222 .id_table = ad5272_id, 223 223 }; 224 224
+1 -1
drivers/iio/potentiometer/ds1803.c
··· 252 252 .name = "ds1803", 253 253 .of_match_table = ds1803_dt_ids, 254 254 }, 255 - .probe_new = ds1803_probe, 255 + .probe = ds1803_probe, 256 256 .id_table = ds1803_id, 257 257 }; 258 258
+1 -1
drivers/iio/potentiometer/max5432.c
··· 123 123 .name = "max5432", 124 124 .of_match_table = max5432_dt_ids, 125 125 }, 126 - .probe_new = max5432_probe, 126 + .probe = max5432_probe, 127 127 }; 128 128 129 129 module_i2c_driver(max5432_driver);
+1 -1
drivers/iio/potentiometer/mcp4018.c
··· 174 174 .name = "mcp4018", 175 175 .of_match_table = mcp4018_of_match, 176 176 }, 177 - .probe_new = mcp4018_probe, 177 + .probe = mcp4018_probe, 178 178 .id_table = mcp4018_id, 179 179 }; 180 180
+1 -1
drivers/iio/potentiometer/mcp4531.c
··· 385 385 .name = "mcp4531", 386 386 .of_match_table = mcp4531_of_match, 387 387 }, 388 - .probe_new = mcp4531_probe, 388 + .probe = mcp4531_probe, 389 389 .id_table = mcp4531_id, 390 390 }; 391 391
+1 -1
drivers/iio/potentiometer/tpl0102.c
··· 161 161 .driver = { 162 162 .name = "tpl0102", 163 163 }, 164 - .probe_new = tpl0102_probe, 164 + .probe = tpl0102_probe, 165 165 .id_table = tpl0102_id, 166 166 }; 167 167
+220
drivers/iio/potentiometer/x9250.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * 4 + * x9250.c -- Renesas X9250 potentiometers IIO driver 5 + * 6 + * Copyright 2023 CS GROUP France 7 + * 8 + * Author: Herve Codina <herve.codina@bootlin.com> 9 + */ 10 + 11 + #include <linux/delay.h> 12 + #include <linux/gpio/consumer.h> 13 + #include <linux/iio/iio.h> 14 + #include <linux/limits.h> 15 + #include <linux/module.h> 16 + #include <linux/regulator/consumer.h> 17 + #include <linux/slab.h> 18 + #include <linux/spi/spi.h> 19 + 20 + struct x9250_cfg { 21 + const char *name; 22 + int kohms; 23 + }; 24 + 25 + struct x9250 { 26 + struct spi_device *spi; 27 + const struct x9250_cfg *cfg; 28 + struct gpio_desc *wp_gpio; 29 + }; 30 + 31 + #define X9250_ID 0x50 32 + #define X9250_CMD_RD_WCR(_p) (0x90 | (_p)) 33 + #define X9250_CMD_WR_WCR(_p) (0xa0 | (_p)) 34 + 35 + static int x9250_write8(struct x9250 *x9250, u8 cmd, u8 val) 36 + { 37 + u8 txbuf[3]; 38 + 39 + txbuf[0] = X9250_ID; 40 + txbuf[1] = cmd; 41 + txbuf[2] = val; 42 + 43 + return spi_write_then_read(x9250->spi, txbuf, ARRAY_SIZE(txbuf), NULL, 0); 44 + } 45 + 46 + static int x9250_read8(struct x9250 *x9250, u8 cmd, u8 *val) 47 + { 48 + u8 txbuf[2]; 49 + 50 + txbuf[0] = X9250_ID; 51 + txbuf[1] = cmd; 52 + 53 + return spi_write_then_read(x9250->spi, txbuf, ARRAY_SIZE(txbuf), val, 1); 54 + } 55 + 56 + #define X9250_CHANNEL(ch) { \ 57 + .type = IIO_RESISTANCE, \ 58 + .indexed = 1, \ 59 + .output = 1, \ 60 + .channel = (ch), \ 61 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 62 + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 63 + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_RAW), \ 64 + } 65 + 66 + static const struct iio_chan_spec x9250_channels[] = { 67 + X9250_CHANNEL(0), 68 + X9250_CHANNEL(1), 69 + X9250_CHANNEL(2), 70 + X9250_CHANNEL(3), 71 + }; 72 + 73 + static int x9250_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, 74 + int *val, int *val2, long mask) 75 + { 76 + struct x9250 *x9250 = iio_priv(indio_dev); 77 + int ch = chan->channel; 78 + int ret; 79 + u8 v; 80 + 81 + switch (mask) { 82 + case IIO_CHAN_INFO_RAW: 83 + ret = x9250_read8(x9250, X9250_CMD_RD_WCR(ch), &v); 84 + if (ret) 85 + return ret; 86 + *val = v; 87 + return IIO_VAL_INT; 88 + 89 + case IIO_CHAN_INFO_SCALE: 90 + *val = 1000 * x9250->cfg->kohms; 91 + *val2 = U8_MAX; 92 + return IIO_VAL_FRACTIONAL; 93 + } 94 + 95 + return -EINVAL; 96 + } 97 + 98 + static int x9250_read_avail(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, 99 + const int **vals, int *type, int *length, long mask) 100 + { 101 + static const int range[] = {0, 1, 255}; /* min, step, max */ 102 + 103 + switch (mask) { 104 + case IIO_CHAN_INFO_RAW: 105 + *length = ARRAY_SIZE(range); 106 + *vals = range; 107 + *type = IIO_VAL_INT; 108 + return IIO_AVAIL_RANGE; 109 + } 110 + 111 + return -EINVAL; 112 + } 113 + 114 + static int x9250_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, 115 + int val, int val2, long mask) 116 + { 117 + struct x9250 *x9250 = iio_priv(indio_dev); 118 + int ch = chan->channel; 119 + int ret; 120 + 121 + if (mask != IIO_CHAN_INFO_RAW) 122 + return -EINVAL; 123 + 124 + if (val > U8_MAX || val < 0) 125 + return -EINVAL; 126 + 127 + gpiod_set_value_cansleep(x9250->wp_gpio, 0); 128 + ret = x9250_write8(x9250, X9250_CMD_WR_WCR(ch), val); 129 + gpiod_set_value_cansleep(x9250->wp_gpio, 1); 130 + 131 + return ret; 132 + } 133 + 134 + static const struct iio_info x9250_info = { 135 + .read_raw = x9250_read_raw, 136 + .read_avail = x9250_read_avail, 137 + .write_raw = x9250_write_raw, 138 + }; 139 + 140 + enum x9250_type { 141 + X9250T, 142 + X9250U, 143 + }; 144 + 145 + static const struct x9250_cfg x9250_cfg[] = { 146 + [X9250T] = { .name = "x9250t", .kohms = 100, }, 147 + [X9250U] = { .name = "x9250u", .kohms = 50, }, 148 + }; 149 + 150 + static const char *const x9250_regulator_names[] = { 151 + "vcc", 152 + "avp", 153 + "avn", 154 + }; 155 + 156 + static int x9250_probe(struct spi_device *spi) 157 + { 158 + struct iio_dev *indio_dev; 159 + struct x9250 *x9250; 160 + int ret; 161 + 162 + ret = devm_regulator_bulk_get_enable(&spi->dev, ARRAY_SIZE(x9250_regulator_names), 163 + x9250_regulator_names); 164 + if (ret) 165 + return dev_err_probe(&spi->dev, ret, "Failed to get regulators\n"); 166 + 167 + /* 168 + * The x9250 needs a 5ms maximum delay after the power-supplies are set 169 + * before performing the first write (1ms for the first read). 170 + */ 171 + usleep_range(5000, 6000); 172 + 173 + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*x9250)); 174 + if (!indio_dev) 175 + return -ENOMEM; 176 + 177 + x9250 = iio_priv(indio_dev); 178 + x9250->spi = spi; 179 + x9250->cfg = spi_get_device_match_data(spi); 180 + x9250->wp_gpio = devm_gpiod_get_optional(&spi->dev, "wp", GPIOD_OUT_LOW); 181 + if (IS_ERR(x9250->wp_gpio)) 182 + return dev_err_probe(&spi->dev, PTR_ERR(x9250->wp_gpio), 183 + "failed to get wp gpio\n"); 184 + 185 + indio_dev->info = &x9250_info; 186 + indio_dev->channels = x9250_channels; 187 + indio_dev->num_channels = ARRAY_SIZE(x9250_channels); 188 + indio_dev->name = x9250->cfg->name; 189 + 190 + return devm_iio_device_register(&spi->dev, indio_dev); 191 + } 192 + 193 + static const struct of_device_id x9250_of_match[] = { 194 + { .compatible = "renesas,x9250t", .data = &x9250_cfg[X9250T]}, 195 + { .compatible = "renesas,x9250u", .data = &x9250_cfg[X9250U]}, 196 + { } 197 + }; 198 + MODULE_DEVICE_TABLE(of, x9250_of_match); 199 + 200 + static const struct spi_device_id x9250_id_table[] = { 201 + { "x9250t", (kernel_ulong_t)&x9250_cfg[X9250T] }, 202 + { "x9250u", (kernel_ulong_t)&x9250_cfg[X9250U] }, 203 + { } 204 + }; 205 + MODULE_DEVICE_TABLE(spi, x9250_id_table); 206 + 207 + static struct spi_driver x9250_spi_driver = { 208 + .driver = { 209 + .name = "x9250", 210 + .of_match_table = x9250_of_match, 211 + }, 212 + .id_table = x9250_id_table, 213 + .probe = x9250_probe, 214 + }; 215 + 216 + module_spi_driver(x9250_spi_driver); 217 + 218 + MODULE_AUTHOR("Herve Codina <herve.codina@bootlin.com>"); 219 + MODULE_DESCRIPTION("X9250 ALSA SoC driver"); 220 + MODULE_LICENSE("GPL");
+1 -1
drivers/iio/potentiostat/lmp91000.c
··· 416 416 .name = LMP91000_DRV_NAME, 417 417 .of_match_table = lmp91000_of_match, 418 418 }, 419 - .probe_new = lmp91000_probe, 419 + .probe = lmp91000_probe, 420 420 .remove = lmp91000_remove, 421 421 .id_table = lmp91000_id, 422 422 };
+13
drivers/iio/pressure/Kconfig
··· 148 148 To compile this driver as a module, choose M here: the module 149 149 will be called mpl3115. 150 150 151 + config MPRLS0025PA 152 + tristate "Honeywell MPRLS0025PA (MicroPressure sensors series)" 153 + depends on I2C 154 + select IIO_BUFFER 155 + select IIO_TRIGGERED_BUFFER 156 + help 157 + Say Y here to build support for the Honeywell MicroPressure pressure 158 + sensor series. There are many different types with different pressure 159 + range. These ranges can be set up in the device tree. 160 + 161 + To compile this driver as a module, choose M here: the module will be 162 + called mprls0025pa. 163 + 151 164 config MS5611 152 165 tristate "Measurement Specialties MS5611 pressure sensor driver" 153 166 select IIO_BUFFER
+1
drivers/iio/pressure/Makefile
··· 19 19 obj-$(CONFIG_MPL115_I2C) += mpl115_i2c.o 20 20 obj-$(CONFIG_MPL115_SPI) += mpl115_spi.o 21 21 obj-$(CONFIG_MPL3115) += mpl3115.o 22 + obj-$(CONFIG_MPRLS0025PA) += mprls0025pa.o 22 23 obj-$(CONFIG_MS5611) += ms5611_core.o 23 24 obj-$(CONFIG_MS5611_I2C) += ms5611_i2c.o 24 25 obj-$(CONFIG_MS5611_SPI) += ms5611_spi.o
+1 -1
drivers/iio/pressure/abp060mg.c
··· 255 255 .driver = { 256 256 .name = "abp060mg", 257 257 }, 258 - .probe_new = abp060mg_probe, 258 + .probe = abp060mg_probe, 259 259 .id_table = abp060mg_id_table, 260 260 }; 261 261 module_i2c_driver(abp060mg_driver);
+1 -1
drivers/iio/pressure/bmp280-i2c.c
··· 56 56 .of_match_table = bmp280_of_i2c_match, 57 57 .pm = pm_ptr(&bmp280_dev_pm_ops), 58 58 }, 59 - .probe_new = bmp280_i2c_probe, 59 + .probe = bmp280_i2c_probe, 60 60 .id_table = bmp280_i2c_id, 61 61 }; 62 62 module_i2c_driver(bmp280_i2c_driver);
+1 -1
drivers/iio/pressure/dlhl60d.c
··· 362 362 .name = "dlhl60d", 363 363 .of_match_table = dlh_of_match, 364 364 }, 365 - .probe_new = dlh_probe, 365 + .probe = dlh_probe, 366 366 .id_table = dlh_id, 367 367 }; 368 368 module_i2c_driver(dlh_driver);
+1 -1
drivers/iio/pressure/dps310.c
··· 887 887 .name = DPS310_DEV_NAME, 888 888 .acpi_match_table = dps310_acpi_match, 889 889 }, 890 - .probe_new = dps310_probe, 890 + .probe = dps310_probe, 891 891 .id_table = dps310_id, 892 892 }; 893 893 module_i2c_driver(dps310_driver);
+1 -1
drivers/iio/pressure/hp03.c
··· 282 282 .name = "hp03", 283 283 .of_match_table = hp03_of_match, 284 284 }, 285 - .probe_new = hp03_probe, 285 + .probe = hp03_probe, 286 286 .id_table = hp03_id, 287 287 }; 288 288 module_i2c_driver(hp03_driver);
+1 -1
drivers/iio/pressure/hp206c.c
··· 409 409 #endif 410 410 411 411 static struct i2c_driver hp206c_driver = { 412 - .probe_new = hp206c_probe, 412 + .probe = hp206c_probe, 413 413 .id_table = hp206c_id, 414 414 .driver = { 415 415 .name = "hp206c",
+1 -1
drivers/iio/pressure/icp10100.c
··· 648 648 .pm = pm_ptr(&icp10100_pm), 649 649 .of_match_table = icp10100_of_match, 650 650 }, 651 - .probe_new = icp10100_probe, 651 + .probe = icp10100_probe, 652 652 .id_table = icp10100_id, 653 653 }; 654 654 module_i2c_driver(icp10100_driver);
+1 -1
drivers/iio/pressure/mpl115_i2c.c
··· 55 55 .name = "mpl115", 56 56 .pm = pm_ptr(&mpl115_dev_pm_ops), 57 57 }, 58 - .probe_new = mpl115_i2c_probe, 58 + .probe = mpl115_i2c_probe, 59 59 .id_table = mpl115_i2c_id, 60 60 }; 61 61 module_i2c_driver(mpl115_i2c_driver);
+1 -1
drivers/iio/pressure/mpl3115.c
··· 335 335 .of_match_table = mpl3115_of_match, 336 336 .pm = pm_sleep_ptr(&mpl3115_pm_ops), 337 337 }, 338 - .probe_new = mpl3115_probe, 338 + .probe = mpl3115_probe, 339 339 .remove = mpl3115_remove, 340 340 .id_table = mpl3115_id, 341 341 };
+450
drivers/iio/pressure/mprls0025pa.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * MPRLS0025PA - Honeywell MicroPressure pressure sensor series driver 4 + * 5 + * Copyright (c) Andreas Klinger <ak@it-klinger.de> 6 + * 7 + * Data sheet: 8 + * https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/ 9 + * products/sensors/pressure-sensors/board-mount-pressure-sensors/ 10 + * micropressure-mpr-series/documents/ 11 + * sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf 12 + * 13 + * 7-bit I2C default slave address: 0x18 14 + */ 15 + 16 + #include <linux/delay.h> 17 + #include <linux/device.h> 18 + #include <linux/i2c.h> 19 + #include <linux/math64.h> 20 + #include <linux/mod_devicetable.h> 21 + #include <linux/module.h> 22 + #include <linux/property.h> 23 + #include <linux/units.h> 24 + 25 + #include <linux/gpio/consumer.h> 26 + 27 + #include <linux/iio/buffer.h> 28 + #include <linux/iio/iio.h> 29 + #include <linux/iio/trigger_consumer.h> 30 + #include <linux/iio/triggered_buffer.h> 31 + 32 + #include <linux/regulator/consumer.h> 33 + 34 + #include <asm/unaligned.h> 35 + 36 + /* bits in i2c status byte */ 37 + #define MPR_I2C_POWER BIT(6) /* device is powered */ 38 + #define MPR_I2C_BUSY BIT(5) /* device is busy */ 39 + #define MPR_I2C_MEMORY BIT(2) /* integrity test passed */ 40 + #define MPR_I2C_MATH BIT(0) /* internal math saturation */ 41 + 42 + /* 43 + * support _RAW sysfs interface: 44 + * 45 + * Calculation formula from the datasheet: 46 + * pressure = (press_cnt - outputmin) * scale + pmin 47 + * with: 48 + * * pressure - measured pressure in Pascal 49 + * * press_cnt - raw value read from sensor 50 + * * pmin - minimum pressure range value of sensor (data->pmin) 51 + * * pmax - maximum pressure range value of sensor (data->pmax) 52 + * * outputmin - minimum numerical range raw value delivered by sensor 53 + * (mpr_func_spec.output_min) 54 + * * outputmax - maximum numerical range raw value delivered by sensor 55 + * (mpr_func_spec.output_max) 56 + * * scale - (pmax - pmin) / (outputmax - outputmin) 57 + * 58 + * formula of the userspace: 59 + * pressure = (raw + offset) * scale 60 + * 61 + * Values given to the userspace in sysfs interface: 62 + * * raw - press_cnt 63 + * * offset - (-1 * outputmin) - pmin / scale 64 + * note: With all sensors from the datasheet pmin = 0 65 + * which reduces the offset to (-1 * outputmin) 66 + */ 67 + 68 + /* 69 + * transfer function A: 10% to 90% of 2^24 70 + * transfer function B: 2.5% to 22.5% of 2^24 71 + * transfer function C: 20% to 80% of 2^24 72 + */ 73 + enum mpr_func_id { 74 + MPR_FUNCTION_A, 75 + MPR_FUNCTION_B, 76 + MPR_FUNCTION_C, 77 + }; 78 + 79 + struct mpr_func_spec { 80 + u32 output_min; 81 + u32 output_max; 82 + }; 83 + 84 + static const struct mpr_func_spec mpr_func_spec[] = { 85 + [MPR_FUNCTION_A] = {.output_min = 1677722, .output_max = 15099494}, 86 + [MPR_FUNCTION_B] = {.output_min = 419430, .output_max = 3774874}, 87 + [MPR_FUNCTION_C] = {.output_min = 3355443, .output_max = 13421773}, 88 + }; 89 + 90 + struct mpr_chan { 91 + s32 pres; /* pressure value */ 92 + s64 ts; /* timestamp */ 93 + }; 94 + 95 + struct mpr_data { 96 + struct i2c_client *client; 97 + struct mutex lock; /* 98 + * access to device during read 99 + */ 100 + u32 pmin; /* minimal pressure in pascal */ 101 + u32 pmax; /* maximal pressure in pascal */ 102 + enum mpr_func_id function; /* transfer function */ 103 + u32 outmin; /* 104 + * minimal numerical range raw 105 + * value from sensor 106 + */ 107 + u32 outmax; /* 108 + * maximal numerical range raw 109 + * value from sensor 110 + */ 111 + int scale; /* int part of scale */ 112 + int scale2; /* nano part of scale */ 113 + int offset; /* int part of offset */ 114 + int offset2; /* nano part of offset */ 115 + struct gpio_desc *gpiod_reset; /* reset */ 116 + int irq; /* 117 + * end of conversion irq; 118 + * used to distinguish between 119 + * irq mode and reading in a 120 + * loop until data is ready 121 + */ 122 + struct completion completion; /* handshake from irq to read */ 123 + struct mpr_chan chan; /* 124 + * channel values for buffered 125 + * mode 126 + */ 127 + }; 128 + 129 + static const struct iio_chan_spec mpr_channels[] = { 130 + { 131 + .type = IIO_PRESSURE, 132 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | 133 + BIT(IIO_CHAN_INFO_SCALE) | 134 + BIT(IIO_CHAN_INFO_OFFSET), 135 + .scan_index = 0, 136 + .scan_type = { 137 + .sign = 's', 138 + .realbits = 32, 139 + .storagebits = 32, 140 + .endianness = IIO_CPU, 141 + }, 142 + }, 143 + IIO_CHAN_SOFT_TIMESTAMP(1), 144 + }; 145 + 146 + static void mpr_reset(struct mpr_data *data) 147 + { 148 + if (data->gpiod_reset) { 149 + gpiod_set_value(data->gpiod_reset, 0); 150 + udelay(10); 151 + gpiod_set_value(data->gpiod_reset, 1); 152 + } 153 + } 154 + 155 + /** 156 + * mpr_read_pressure() - Read pressure value from sensor via I2C 157 + * @data: Pointer to private data struct. 158 + * @press: Output value read from sensor. 159 + * 160 + * Reading from the sensor by sending and receiving I2C telegrams. 161 + * 162 + * If there is an end of conversion (EOC) interrupt registered the function 163 + * waits for a maximum of one second for the interrupt. 164 + * 165 + * Context: The function can sleep and data->lock should be held when calling it 166 + * Return: 167 + * * 0 - OK, the pressure value could be read 168 + * * -ETIMEDOUT - Timeout while waiting for the EOC interrupt or busy flag is 169 + * still set after nloops attempts of reading 170 + */ 171 + static int mpr_read_pressure(struct mpr_data *data, s32 *press) 172 + { 173 + struct device *dev = &data->client->dev; 174 + int ret, i; 175 + u8 wdata[] = {0xAA, 0x00, 0x00}; 176 + s32 status; 177 + int nloops = 10; 178 + u8 buf[4]; 179 + 180 + reinit_completion(&data->completion); 181 + 182 + ret = i2c_master_send(data->client, wdata, sizeof(wdata)); 183 + if (ret < 0) { 184 + dev_err(dev, "error while writing ret: %d\n", ret); 185 + return ret; 186 + } 187 + if (ret != sizeof(wdata)) { 188 + dev_err(dev, "received size doesn't fit - ret: %d / %u\n", ret, 189 + (u32)sizeof(wdata)); 190 + return -EIO; 191 + } 192 + 193 + if (data->irq > 0) { 194 + ret = wait_for_completion_timeout(&data->completion, HZ); 195 + if (!ret) { 196 + dev_err(dev, "timeout while waiting for eoc irq\n"); 197 + return -ETIMEDOUT; 198 + } 199 + } else { 200 + /* wait until status indicates data is ready */ 201 + for (i = 0; i < nloops; i++) { 202 + /* 203 + * datasheet only says to wait at least 5 ms for the 204 + * data but leave the maximum response time open 205 + * --> let's try it nloops (10) times which seems to be 206 + * quite long 207 + */ 208 + usleep_range(5000, 10000); 209 + status = i2c_smbus_read_byte(data->client); 210 + if (status < 0) { 211 + dev_err(dev, 212 + "error while reading, status: %d\n", 213 + status); 214 + return status; 215 + } 216 + if (!(status & MPR_I2C_BUSY)) 217 + break; 218 + } 219 + if (i == nloops) { 220 + dev_err(dev, "timeout while reading\n"); 221 + return -ETIMEDOUT; 222 + } 223 + } 224 + 225 + ret = i2c_master_recv(data->client, buf, sizeof(buf)); 226 + if (ret < 0) { 227 + dev_err(dev, "error in i2c_master_recv ret: %d\n", ret); 228 + return ret; 229 + } 230 + if (ret != sizeof(buf)) { 231 + dev_err(dev, "received size doesn't fit - ret: %d / %u\n", ret, 232 + (u32)sizeof(buf)); 233 + return -EIO; 234 + } 235 + 236 + if (buf[0] & MPR_I2C_BUSY) { 237 + /* 238 + * it should never be the case that status still indicates 239 + * business 240 + */ 241 + dev_err(dev, "data still not ready: %08x\n", buf[0]); 242 + return -ETIMEDOUT; 243 + } 244 + 245 + *press = get_unaligned_be24(&buf[1]); 246 + 247 + dev_dbg(dev, "received: %*ph cnt: %d\n", ret, buf, *press); 248 + 249 + return 0; 250 + } 251 + 252 + static irqreturn_t mpr_eoc_handler(int irq, void *p) 253 + { 254 + struct mpr_data *data = p; 255 + 256 + complete(&data->completion); 257 + 258 + return IRQ_HANDLED; 259 + } 260 + 261 + static irqreturn_t mpr_trigger_handler(int irq, void *p) 262 + { 263 + int ret; 264 + struct iio_poll_func *pf = p; 265 + struct iio_dev *indio_dev = pf->indio_dev; 266 + struct mpr_data *data = iio_priv(indio_dev); 267 + 268 + mutex_lock(&data->lock); 269 + ret = mpr_read_pressure(data, &data->chan.pres); 270 + if (ret < 0) 271 + goto err; 272 + 273 + iio_push_to_buffers_with_timestamp(indio_dev, &data->chan, 274 + iio_get_time_ns(indio_dev)); 275 + 276 + err: 277 + mutex_unlock(&data->lock); 278 + iio_trigger_notify_done(indio_dev->trig); 279 + 280 + return IRQ_HANDLED; 281 + } 282 + 283 + static int mpr_read_raw(struct iio_dev *indio_dev, 284 + struct iio_chan_spec const *chan, int *val, int *val2, long mask) 285 + { 286 + int ret; 287 + s32 pressure; 288 + struct mpr_data *data = iio_priv(indio_dev); 289 + 290 + if (chan->type != IIO_PRESSURE) 291 + return -EINVAL; 292 + 293 + switch (mask) { 294 + case IIO_CHAN_INFO_RAW: 295 + mutex_lock(&data->lock); 296 + ret = mpr_read_pressure(data, &pressure); 297 + mutex_unlock(&data->lock); 298 + if (ret < 0) 299 + return ret; 300 + *val = pressure; 301 + return IIO_VAL_INT; 302 + case IIO_CHAN_INFO_SCALE: 303 + *val = data->scale; 304 + *val2 = data->scale2; 305 + return IIO_VAL_INT_PLUS_NANO; 306 + case IIO_CHAN_INFO_OFFSET: 307 + *val = data->offset; 308 + *val2 = data->offset2; 309 + return IIO_VAL_INT_PLUS_NANO; 310 + default: 311 + return -EINVAL; 312 + } 313 + } 314 + 315 + static const struct iio_info mpr_info = { 316 + .read_raw = &mpr_read_raw, 317 + }; 318 + 319 + static int mpr_probe(struct i2c_client *client) 320 + { 321 + int ret; 322 + struct mpr_data *data; 323 + struct iio_dev *indio_dev; 324 + struct device *dev = &client->dev; 325 + s64 scale, offset; 326 + 327 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) 328 + return dev_err_probe(dev, -EOPNOTSUPP, 329 + "I2C functionality not supported\n"); 330 + 331 + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); 332 + if (!indio_dev) 333 + return dev_err_probe(dev, -ENOMEM, "couldn't get iio_dev\n"); 334 + 335 + data = iio_priv(indio_dev); 336 + data->client = client; 337 + data->irq = client->irq; 338 + 339 + mutex_init(&data->lock); 340 + init_completion(&data->completion); 341 + 342 + indio_dev->name = "mprls0025pa"; 343 + indio_dev->info = &mpr_info; 344 + indio_dev->channels = mpr_channels; 345 + indio_dev->num_channels = ARRAY_SIZE(mpr_channels); 346 + indio_dev->modes = INDIO_DIRECT_MODE; 347 + 348 + ret = devm_regulator_get_enable(dev, "vdd"); 349 + if (ret) 350 + return dev_err_probe(dev, ret, 351 + "can't get and enable vdd supply\n"); 352 + 353 + if (dev_fwnode(dev)) { 354 + ret = device_property_read_u32(dev, "honeywell,pmin-pascal", 355 + &data->pmin); 356 + if (ret) 357 + return dev_err_probe(dev, ret, 358 + "honeywell,pmin-pascal could not be read\n"); 359 + ret = device_property_read_u32(dev, "honeywell,pmax-pascal", 360 + &data->pmax); 361 + if (ret) 362 + return dev_err_probe(dev, ret, 363 + "honeywell,pmax-pascal could not be read\n"); 364 + ret = device_property_read_u32(dev, 365 + "honeywell,transfer-function", &data->function); 366 + if (ret) 367 + return dev_err_probe(dev, ret, 368 + "honeywell,transfer-function could not be read\n"); 369 + if (data->function > MPR_FUNCTION_C) 370 + return dev_err_probe(dev, -EINVAL, 371 + "honeywell,transfer-function %d invalid\n", 372 + data->function); 373 + } else { 374 + /* when loaded as i2c device we need to use default values */ 375 + dev_notice(dev, "firmware node not found; using defaults\n"); 376 + data->pmin = 0; 377 + data->pmax = 172369; /* 25 psi */ 378 + data->function = MPR_FUNCTION_A; 379 + } 380 + 381 + data->outmin = mpr_func_spec[data->function].output_min; 382 + data->outmax = mpr_func_spec[data->function].output_max; 383 + 384 + /* use 64 bit calculation for preserving a reasonable precision */ 385 + scale = div_s64(((s64)(data->pmax - data->pmin)) * NANO, 386 + data->outmax - data->outmin); 387 + data->scale = div_s64_rem(scale, NANO, &data->scale2); 388 + /* 389 + * multiply with NANO before dividing by scale and later divide by NANO 390 + * again. 391 + */ 392 + offset = ((-1LL) * (s64)data->outmin) * NANO - 393 + div_s64(div_s64((s64)data->pmin * NANO, scale), NANO); 394 + data->offset = div_s64_rem(offset, NANO, &data->offset2); 395 + 396 + if (data->irq > 0) { 397 + ret = devm_request_irq(dev, data->irq, mpr_eoc_handler, 398 + IRQF_TRIGGER_RISING, client->name, data); 399 + if (ret) 400 + return dev_err_probe(dev, ret, 401 + "request irq %d failed\n", data->irq); 402 + } 403 + 404 + data->gpiod_reset = devm_gpiod_get_optional(dev, "reset", 405 + GPIOD_OUT_HIGH); 406 + if (IS_ERR(data->gpiod_reset)) 407 + return dev_err_probe(dev, PTR_ERR(data->gpiod_reset), 408 + "request reset-gpio failed\n"); 409 + 410 + mpr_reset(data); 411 + 412 + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, 413 + mpr_trigger_handler, NULL); 414 + if (ret) 415 + return dev_err_probe(dev, ret, 416 + "iio triggered buffer setup failed\n"); 417 + 418 + ret = devm_iio_device_register(dev, indio_dev); 419 + if (ret) 420 + return dev_err_probe(dev, ret, 421 + "unable to register iio device\n"); 422 + 423 + return 0; 424 + } 425 + 426 + static const struct of_device_id mpr_matches[] = { 427 + { .compatible = "honeywell,mprls0025pa" }, 428 + { } 429 + }; 430 + MODULE_DEVICE_TABLE(of, mpr_matches); 431 + 432 + static const struct i2c_device_id mpr_id[] = { 433 + { "mprls0025pa" }, 434 + { } 435 + }; 436 + MODULE_DEVICE_TABLE(i2c, mpr_id); 437 + 438 + static struct i2c_driver mpr_driver = { 439 + .probe = mpr_probe, 440 + .id_table = mpr_id, 441 + .driver = { 442 + .name = "mprls0025pa", 443 + .of_match_table = mpr_matches, 444 + }, 445 + }; 446 + module_i2c_driver(mpr_driver); 447 + 448 + MODULE_AUTHOR("Andreas Klinger <ak@it-klinger.de>"); 449 + MODULE_DESCRIPTION("Honeywell MPRLS0025PA I2C driver"); 450 + MODULE_LICENSE("GPL");
+1 -1
drivers/iio/pressure/ms5611_i2c.c
··· 125 125 .of_match_table = ms5611_i2c_matches, 126 126 }, 127 127 .id_table = ms5611_id, 128 - .probe_new = ms5611_i2c_probe, 128 + .probe = ms5611_i2c_probe, 129 129 }; 130 130 module_i2c_driver(ms5611_driver); 131 131
+1 -1
drivers/iio/pressure/ms5637.c
··· 238 238 MODULE_DEVICE_TABLE(of, ms5637_of_match); 239 239 240 240 static struct i2c_driver ms5637_driver = { 241 - .probe_new = ms5637_probe, 241 + .probe = ms5637_probe, 242 242 .id_table = ms5637_id, 243 243 .driver = { 244 244 .name = "ms5637",
+1 -1
drivers/iio/pressure/st_pressure_i2c.c
··· 116 116 .of_match_table = st_press_of_match, 117 117 .acpi_match_table = ACPI_PTR(st_press_acpi_match), 118 118 }, 119 - .probe_new = st_press_i2c_probe, 119 + .probe = st_press_i2c_probe, 120 120 .id_table = st_press_id_table, 121 121 }; 122 122 module_i2c_driver(st_press_driver);
+1 -1
drivers/iio/pressure/t5403.c
··· 260 260 .driver = { 261 261 .name = "t5403", 262 262 }, 263 - .probe_new = t5403_probe, 263 + .probe = t5403_probe, 264 264 .id_table = t5403_id, 265 265 }; 266 266 module_i2c_driver(t5403_driver);
+1 -1
drivers/iio/pressure/zpa2326_i2c.c
··· 76 76 .of_match_table = zpa2326_i2c_matches, 77 77 .pm = ZPA2326_PM_OPS, 78 78 }, 79 - .probe_new = zpa2326_probe_i2c, 79 + .probe = zpa2326_probe_i2c, 80 80 .remove = zpa2326_remove_i2c, 81 81 .id_table = zpa2326_i2c_ids, 82 82 };
+1 -1
drivers/iio/proximity/isl29501.c
··· 1008 1008 .name = "isl29501", 1009 1009 }, 1010 1010 .id_table = isl29501_id, 1011 - .probe_new = isl29501_probe, 1011 + .probe = isl29501_probe, 1012 1012 }; 1013 1013 module_i2c_driver(isl29501_driver); 1014 1014
+1 -1
drivers/iio/proximity/mb1232.c
··· 264 264 .name = "maxbotix-mb1232", 265 265 .of_match_table = of_mb1232_match, 266 266 }, 267 - .probe_new = mb1232_probe, 267 + .probe = mb1232_probe, 268 268 .id_table = mb1232_id, 269 269 }; 270 270 module_i2c_driver(mb1232_driver);
+1 -1
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
··· 365 365 .of_match_table = lidar_dt_ids, 366 366 .pm = pm_ptr(&lidar_pm_ops), 367 367 }, 368 - .probe_new = lidar_probe, 368 + .probe = lidar_probe, 369 369 .remove = lidar_remove, 370 370 .id_table = lidar_id, 371 371 };
+1 -1
drivers/iio/proximity/rfd77402.c
··· 318 318 .name = RFD77402_DRV_NAME, 319 319 .pm = pm_sleep_ptr(&rfd77402_pm_ops), 320 320 }, 321 - .probe_new = rfd77402_probe, 321 + .probe = rfd77402_probe, 322 322 .id_table = rfd77402_id, 323 323 }; 324 324
+1 -1
drivers/iio/proximity/srf08.c
··· 549 549 .name = "srf08", 550 550 .of_match_table = of_srf08_match, 551 551 }, 552 - .probe_new = srf08_probe, 552 + .probe = srf08_probe, 553 553 .id_table = srf08_id, 554 554 }; 555 555 module_i2c_driver(srf08_driver);
+1 -1
drivers/iio/proximity/sx9310.c
··· 1050 1050 */ 1051 1051 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1052 1052 }, 1053 - .probe_new = sx9310_probe, 1053 + .probe = sx9310_probe, 1054 1054 .id_table = sx9310_id, 1055 1055 }; 1056 1056 module_i2c_driver(sx9310_driver);
+1 -1
drivers/iio/proximity/sx9324.c
··· 1152 1152 */ 1153 1153 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1154 1154 }, 1155 - .probe_new = sx9324_probe, 1155 + .probe = sx9324_probe, 1156 1156 .id_table = sx9324_id, 1157 1157 }; 1158 1158 module_i2c_driver(sx9324_driver);
+1 -1
drivers/iio/proximity/sx9360.c
··· 896 896 */ 897 897 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 898 898 }, 899 - .probe_new = sx9360_probe, 899 + .probe = sx9360_probe, 900 900 .id_table = sx9360_id, 901 901 }; 902 902 module_i2c_driver(sx9360_driver);
+1 -1
drivers/iio/proximity/sx9500.c
··· 1055 1055 .of_match_table = sx9500_of_match, 1056 1056 .pm = pm_sleep_ptr(&sx9500_pm_ops), 1057 1057 }, 1058 - .probe_new = sx9500_probe, 1058 + .probe = sx9500_probe, 1059 1059 .remove = sx9500_remove, 1060 1060 .id_table = sx9500_id, 1061 1061 };
+1 -1
drivers/iio/proximity/vcnl3020.c
··· 662 662 .name = "vcnl3020", 663 663 .of_match_table = vcnl3020_of_match, 664 664 }, 665 - .probe_new = vcnl3020_probe, 665 + .probe = vcnl3020_probe, 666 666 }; 667 667 module_i2c_driver(vcnl3020_driver); 668 668
+1 -1
drivers/iio/proximity/vl53l0x-i2c.c
··· 294 294 .name = "vl53l0x-i2c", 295 295 .of_match_table = st_vl53l0x_dt_match, 296 296 }, 297 - .probe_new = vl53l0x_probe, 297 + .probe = vl53l0x_probe, 298 298 .id_table = vl53l0x_id, 299 299 }; 300 300 module_i2c_driver(vl53l0x_driver);
+1 -1
drivers/iio/temperature/max30208.c
··· 242 242 .of_match_table = max30208_of_match, 243 243 .acpi_match_table = max30208_acpi_match, 244 244 }, 245 - .probe_new = max30208_probe, 245 + .probe = max30208_probe, 246 246 .id_table = max30208_id_table, 247 247 }; 248 248 module_i2c_driver(max30208_driver);
+170 -71
drivers/iio/temperature/mlx90614.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * mlx90614.c - Support for Melexis MLX90614 contactless IR temperature sensor 3 + * mlx90614.c - Support for Melexis MLX90614/MLX90615 contactless IR temperature sensor 4 4 * 5 5 * Copyright (c) 2014 Peter Meerwald <pmeerw@pmeerw.net> 6 6 * Copyright (c) 2015 Essensium NV 7 7 * Copyright (c) 2015 Melexis 8 8 * 9 - * Driver for the Melexis MLX90614 I2C 16-bit IR thermopile sensor 9 + * Driver for the Melexis MLX90614/MLX90615 I2C 16-bit IR thermopile sensor 10 + * 11 + * MLX90614 - 17-bit ADC + MLX90302 DSP 12 + * MLX90615 - 16-bit ADC + MLX90325 DSP 10 13 * 11 14 * (7-bit I2C slave address 0x5a, 100KHz bus speed only!) 12 15 * ··· 22 19 * the "wakeup" GPIO is not given, power management will be disabled. 23 20 */ 24 21 25 - #include <linux/err.h> 26 - #include <linux/i2c.h> 27 - #include <linux/module.h> 28 22 #include <linux/delay.h> 29 - #include <linux/jiffies.h> 23 + #include <linux/err.h> 30 24 #include <linux/gpio/consumer.h> 25 + #include <linux/i2c.h> 26 + #include <linux/jiffies.h> 27 + #include <linux/module.h> 28 + #include <linux/of_device.h> 31 29 #include <linux/pm_runtime.h> 32 30 33 31 #include <linux/iio/iio.h> ··· 38 34 #define MLX90614_OP_EEPROM 0x20 39 35 #define MLX90614_OP_SLEEP 0xff 40 36 41 - /* RAM offsets with 16-bit data, MSB first */ 42 - #define MLX90614_RAW1 (MLX90614_OP_RAM | 0x04) /* raw data IR channel 1 */ 43 - #define MLX90614_RAW2 (MLX90614_OP_RAM | 0x05) /* raw data IR channel 2 */ 44 - #define MLX90614_TA (MLX90614_OP_RAM | 0x06) /* ambient temperature */ 45 - #define MLX90614_TOBJ1 (MLX90614_OP_RAM | 0x07) /* object 1 temperature */ 46 - #define MLX90614_TOBJ2 (MLX90614_OP_RAM | 0x08) /* object 2 temperature */ 47 - 48 - /* EEPROM offsets with 16-bit data, MSB first */ 49 - #define MLX90614_EMISSIVITY (MLX90614_OP_EEPROM | 0x04) /* emissivity correction coefficient */ 50 - #define MLX90614_CONFIG (MLX90614_OP_EEPROM | 0x05) /* configuration register */ 37 + #define MLX90615_OP_EEPROM 0x10 38 + #define MLX90615_OP_RAM 0x20 39 + #define MLX90615_OP_SLEEP 0xc6 51 40 52 41 /* Control bits in configuration register */ 53 42 #define MLX90614_CONFIG_IIR_SHIFT 0 /* IIR coefficient */ ··· 49 52 #define MLX90614_CONFIG_DUAL_MASK (1 << MLX90614_CONFIG_DUAL_SHIFT) 50 53 #define MLX90614_CONFIG_FIR_SHIFT 8 /* FIR coefficient */ 51 54 #define MLX90614_CONFIG_FIR_MASK (0x7 << MLX90614_CONFIG_FIR_SHIFT) 52 - #define MLX90614_CONFIG_GAIN_SHIFT 11 /* gain */ 53 - #define MLX90614_CONFIG_GAIN_MASK (0x7 << MLX90614_CONFIG_GAIN_SHIFT) 55 + 56 + #define MLX90615_CONFIG_IIR_SHIFT 12 /* IIR coefficient */ 57 + #define MLX90615_CONFIG_IIR_MASK (0x7 << MLX90615_CONFIG_IIR_SHIFT) 54 58 55 59 /* Timings (in ms) */ 56 60 #define MLX90614_TIMING_EEPROM 20 /* time for EEPROM write/erase to complete */ 57 61 #define MLX90614_TIMING_WAKEUP 34 /* time to hold SDA low for wake-up */ 58 62 #define MLX90614_TIMING_STARTUP 250 /* time before first data after wake-up */ 63 + 64 + #define MLX90615_TIMING_WAKEUP 22 /* time to hold SCL low for wake-up */ 59 65 60 66 #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */ 61 67 ··· 66 66 #define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the Kelvin offset */ 67 67 #define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */ 68 68 #define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */ 69 - #define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */ 70 - #define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */ 71 69 #define MLX90614_CONST_FIR 0x7 /* Fixed value for FIR part of low pass filter */ 70 + 71 + /* Non-constant mask variant of FIELD_GET() and FIELD_PREP() */ 72 + #define field_get(_mask, _reg) (((_reg) & (_mask)) >> (ffs(_mask) - 1)) 73 + #define field_prep(_mask, _val) (((_val) << (ffs(_mask) - 1)) & (_mask)) 74 + 75 + struct mlx_chip_info { 76 + /* EEPROM offsets with 16-bit data, MSB first */ 77 + /* emissivity correction coefficient */ 78 + u8 op_eeprom_emissivity; 79 + u8 op_eeprom_config1; 80 + /* RAM offsets with 16-bit data, MSB first */ 81 + /* ambient temperature */ 82 + u8 op_ram_ta; 83 + /* object 1 temperature */ 84 + u8 op_ram_tobj1; 85 + /* object 2 temperature */ 86 + u8 op_ram_tobj2; 87 + u8 op_sleep; 88 + /* support for two input channels (MLX90614 only) */ 89 + u8 dual_channel; 90 + u8 wakeup_delay_ms; 91 + u16 emissivity_max; 92 + u16 fir_config_mask; 93 + u16 iir_config_mask; 94 + int iir_valid_offset; 95 + u16 iir_values[8]; 96 + int iir_freqs[8][2]; 97 + }; 72 98 73 99 struct mlx90614_data { 74 100 struct i2c_client *client; 75 101 struct mutex lock; /* for EEPROM access only */ 76 102 struct gpio_desc *wakeup_gpio; /* NULL to disable sleep/wake-up */ 103 + const struct mlx_chip_info *chip_info; /* Chip hardware details */ 77 104 unsigned long ready_timestamp; /* in jiffies */ 78 - }; 79 - 80 - /* Bandwidth values for IIR filtering */ 81 - static const int mlx90614_iir_values[] = {77, 31, 20, 15, 723, 153, 110, 86}; 82 - static const int mlx90614_freqs[][2] = { 83 - {0, 150000}, 84 - {0, 200000}, 85 - {0, 310000}, 86 - {0, 770000}, 87 - {0, 860000}, 88 - {1, 100000}, 89 - {1, 530000}, 90 - {7, 230000} 91 105 }; 92 106 93 107 /* ··· 143 129 } 144 130 145 131 /* 146 - * Find the IIR value inside mlx90614_iir_values array and return its position 132 + * Find the IIR value inside iir_values array and return its position 147 133 * which is equivalent to the bit value in sensor register 148 134 */ 149 135 static inline s32 mlx90614_iir_search(const struct i2c_client *client, 150 136 int value) 151 137 { 138 + struct iio_dev *indio_dev = i2c_get_clientdata(client); 139 + struct mlx90614_data *data = iio_priv(indio_dev); 140 + const struct mlx_chip_info *chip_info = data->chip_info; 152 141 int i; 153 142 s32 ret; 154 143 155 - for (i = 0; i < ARRAY_SIZE(mlx90614_iir_values); ++i) { 156 - if (value == mlx90614_iir_values[i]) 144 + for (i = chip_info->iir_valid_offset; 145 + i < ARRAY_SIZE(chip_info->iir_values); 146 + i++) { 147 + if (value == chip_info->iir_values[i]) 157 148 break; 158 149 } 159 150 160 - if (i == ARRAY_SIZE(mlx90614_iir_values)) 151 + if (i == ARRAY_SIZE(chip_info->iir_values)) 161 152 return -EINVAL; 162 153 163 154 /* ··· 170 151 * we must read them before we actually write 171 152 * changes 172 153 */ 173 - ret = i2c_smbus_read_word_data(client, MLX90614_CONFIG); 154 + ret = i2c_smbus_read_word_data(client, chip_info->op_eeprom_config1); 174 155 if (ret < 0) 175 156 return ret; 176 157 177 - ret &= ~MLX90614_CONFIG_FIR_MASK; 178 - ret |= MLX90614_CONST_FIR << MLX90614_CONFIG_FIR_SHIFT; 179 - ret &= ~MLX90614_CONFIG_IIR_MASK; 180 - ret |= i << MLX90614_CONFIG_IIR_SHIFT; 158 + /* Modify FIR on parts which have configurable FIR filter */ 159 + if (chip_info->fir_config_mask) { 160 + ret &= ~chip_info->fir_config_mask; 161 + ret |= field_prep(chip_info->fir_config_mask, MLX90614_CONST_FIR); 162 + } 163 + 164 + ret &= ~chip_info->iir_config_mask; 165 + ret |= field_prep(chip_info->iir_config_mask, i); 181 166 182 167 /* Write changed values */ 183 - ret = mlx90614_write_word(client, MLX90614_CONFIG, ret); 168 + ret = mlx90614_write_word(client, chip_info->op_eeprom_config1, ret); 184 169 return ret; 185 170 } 186 171 ··· 244 221 int *val2, long mask) 245 222 { 246 223 struct mlx90614_data *data = iio_priv(indio_dev); 247 - u8 cmd; 224 + const struct mlx_chip_info *chip_info = data->chip_info; 225 + u8 cmd, idx; 248 226 s32 ret; 249 227 250 228 switch (mask) { 251 229 case IIO_CHAN_INFO_RAW: /* 0.02K / LSB */ 252 230 switch (channel->channel2) { 253 231 case IIO_MOD_TEMP_AMBIENT: 254 - cmd = MLX90614_TA; 232 + cmd = chip_info->op_ram_ta; 255 233 break; 256 234 case IIO_MOD_TEMP_OBJECT: 235 + if (chip_info->dual_channel && channel->channel) 236 + return -EINVAL; 237 + 257 238 switch (channel->channel) { 258 239 case 0: 259 - cmd = MLX90614_TOBJ1; 240 + cmd = chip_info->op_ram_tobj1; 260 241 break; 261 242 case 1: 262 - cmd = MLX90614_TOBJ2; 243 + cmd = chip_info->op_ram_tobj2; 263 244 break; 264 245 default: 265 246 return -EINVAL; ··· 295 268 case IIO_CHAN_INFO_SCALE: 296 269 *val = MLX90614_CONST_SCALE; 297 270 return IIO_VAL_INT; 298 - case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */ 271 + case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/emissivity_max / LSB */ 299 272 ret = mlx90614_power_get(data, false); 300 273 if (ret < 0) 301 274 return ret; 302 275 303 276 mutex_lock(&data->lock); 304 277 ret = i2c_smbus_read_word_data(data->client, 305 - MLX90614_EMISSIVITY); 278 + chip_info->op_eeprom_emissivity); 306 279 mutex_unlock(&data->lock); 307 280 mlx90614_power_put(data); 308 281 309 282 if (ret < 0) 310 283 return ret; 311 284 312 - if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) { 285 + if (ret == chip_info->emissivity_max) { 313 286 *val = 1; 314 287 *val2 = 0; 315 288 } else { 316 289 *val = 0; 317 - *val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION; 290 + *val2 = ret * NSEC_PER_SEC / chip_info->emissivity_max; 318 291 } 319 292 return IIO_VAL_INT_PLUS_NANO; 320 - case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: /* IIR setting with 321 - FIR = 1024 */ 293 + /* IIR setting with FIR=1024 (MLX90614) or FIR=65536 (MLX90615) */ 294 + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: 322 295 ret = mlx90614_power_get(data, false); 323 296 if (ret < 0) 324 297 return ret; 325 298 326 299 mutex_lock(&data->lock); 327 - ret = i2c_smbus_read_word_data(data->client, MLX90614_CONFIG); 300 + ret = i2c_smbus_read_word_data(data->client, 301 + chip_info->op_eeprom_config1); 328 302 mutex_unlock(&data->lock); 329 303 mlx90614_power_put(data); 330 304 331 305 if (ret < 0) 332 306 return ret; 333 307 334 - *val = mlx90614_iir_values[ret & MLX90614_CONFIG_IIR_MASK] / 100; 335 - *val2 = (mlx90614_iir_values[ret & MLX90614_CONFIG_IIR_MASK] % 100) * 336 - 10000; 308 + idx = field_get(chip_info->iir_config_mask, ret) - 309 + chip_info->iir_valid_offset; 310 + 311 + *val = chip_info->iir_values[idx] / 100; 312 + *val2 = (chip_info->iir_values[idx] % 100) * 10000; 337 313 return IIO_VAL_INT_PLUS_MICRO; 338 314 default: 339 315 return -EINVAL; ··· 348 318 int val2, long mask) 349 319 { 350 320 struct mlx90614_data *data = iio_priv(indio_dev); 321 + const struct mlx_chip_info *chip_info = data->chip_info; 351 322 s32 ret; 352 323 353 324 switch (mask) { 354 - case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */ 325 + case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/emissivity_max / LSB */ 355 326 if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0)) 356 327 return -EINVAL; 357 - val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX + 358 - val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION; 328 + val = val * chip_info->emissivity_max + 329 + val2 * chip_info->emissivity_max / NSEC_PER_SEC; 359 330 360 331 ret = mlx90614_power_get(data, false); 361 332 if (ret < 0) 362 333 return ret; 363 334 364 335 mutex_lock(&data->lock); 365 - ret = mlx90614_write_word(data->client, MLX90614_EMISSIVITY, 366 - val); 336 + ret = mlx90614_write_word(data->client, 337 + chip_info->op_eeprom_emissivity, val); 367 338 mutex_unlock(&data->lock); 368 339 mlx90614_power_put(data); 369 340 ··· 408 377 const int **vals, int *type, int *length, 409 378 long mask) 410 379 { 380 + struct mlx90614_data *data = iio_priv(indio_dev); 381 + const struct mlx_chip_info *chip_info = data->chip_info; 382 + 411 383 switch (mask) { 412 384 case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: 413 - *vals = (int *)mlx90614_freqs; 385 + *vals = (int *)chip_info->iir_freqs; 414 386 *type = IIO_VAL_INT_PLUS_MICRO; 415 - *length = 2 * ARRAY_SIZE(mlx90614_freqs); 387 + *length = 2 * (ARRAY_SIZE(chip_info->iir_freqs) - 388 + chip_info->iir_valid_offset); 416 389 return IIO_AVAIL_LIST; 417 390 default: 418 391 return -EINVAL; ··· 470 435 #ifdef CONFIG_PM 471 436 static int mlx90614_sleep(struct mlx90614_data *data) 472 437 { 438 + const struct mlx_chip_info *chip_info = data->chip_info; 473 439 s32 ret; 474 440 475 441 if (!data->wakeup_gpio) { ··· 483 447 mutex_lock(&data->lock); 484 448 ret = i2c_smbus_xfer(data->client->adapter, data->client->addr, 485 449 data->client->flags | I2C_CLIENT_PEC, 486 - I2C_SMBUS_WRITE, MLX90614_OP_SLEEP, 450 + I2C_SMBUS_WRITE, chip_info->op_sleep, 487 451 I2C_SMBUS_BYTE, NULL); 488 452 mutex_unlock(&data->lock); 489 453 ··· 492 456 493 457 static int mlx90614_wakeup(struct mlx90614_data *data) 494 458 { 459 + const struct mlx_chip_info *chip_info = data->chip_info; 460 + 495 461 if (!data->wakeup_gpio) { 496 462 dev_dbg(&data->client->dev, "Wake-up disabled"); 497 463 return -ENOSYS; ··· 503 465 504 466 i2c_lock_bus(data->client->adapter, I2C_LOCK_ROOT_ADAPTER); 505 467 gpiod_direction_output(data->wakeup_gpio, 0); 506 - msleep(MLX90614_TIMING_WAKEUP); 468 + msleep(chip_info->wakeup_delay_ms); 507 469 gpiod_direction_input(data->wakeup_gpio); 508 470 i2c_unlock_bus(data->client->adapter, I2C_LOCK_ROOT_ADAPTER); 509 471 ··· 516 478 * If the read fails, the controller will probably be reset so that 517 479 * further reads will work. 518 480 */ 519 - i2c_smbus_read_word_data(data->client, MLX90614_CONFIG); 481 + i2c_smbus_read_word_data(data->client, chip_info->op_eeprom_config1); 520 482 521 483 return 0; 522 484 } ··· 565 527 /* Return 0 for single sensor, 1 for dual sensor, <0 on error. */ 566 528 static int mlx90614_probe_num_ir_sensors(struct i2c_client *client) 567 529 { 530 + struct iio_dev *indio_dev = i2c_get_clientdata(client); 531 + struct mlx90614_data *data = iio_priv(indio_dev); 532 + const struct mlx_chip_info *chip_info = data->chip_info; 568 533 s32 ret; 569 534 570 - ret = i2c_smbus_read_word_data(client, MLX90614_CONFIG); 535 + if (chip_info->dual_channel) 536 + return 0; 537 + 538 + ret = i2c_smbus_read_word_data(client, chip_info->op_eeprom_config1); 571 539 572 540 if (ret < 0) 573 541 return ret; ··· 600 556 data->client = client; 601 557 mutex_init(&data->lock); 602 558 data->wakeup_gpio = mlx90614_probe_wakeup(client); 559 + data->chip_info = device_get_match_data(&client->dev); 603 560 604 561 mlx90614_wakeup(data); 605 562 ··· 650 605 } 651 606 } 652 607 608 + static const struct mlx_chip_info mlx90614_chip_info = { 609 + .op_eeprom_emissivity = MLX90614_OP_EEPROM | 0x04, 610 + .op_eeprom_config1 = MLX90614_OP_EEPROM | 0x05, 611 + .op_ram_ta = MLX90614_OP_RAM | 0x06, 612 + .op_ram_tobj1 = MLX90614_OP_RAM | 0x07, 613 + .op_ram_tobj2 = MLX90614_OP_RAM | 0x08, 614 + .op_sleep = MLX90614_OP_SLEEP, 615 + .dual_channel = true, 616 + .wakeup_delay_ms = MLX90614_TIMING_WAKEUP, 617 + .emissivity_max = 65535, 618 + .fir_config_mask = MLX90614_CONFIG_FIR_MASK, 619 + .iir_config_mask = MLX90614_CONFIG_IIR_MASK, 620 + .iir_valid_offset = 0, 621 + .iir_values = { 77, 31, 20, 15, 723, 153, 110, 86 }, 622 + .iir_freqs = { 623 + { 0, 150000 }, /* 13% ~= 0.15 Hz */ 624 + { 0, 200000 }, /* 17% ~= 0.20 Hz */ 625 + { 0, 310000 }, /* 25% ~= 0.31 Hz */ 626 + { 0, 770000 }, /* 50% ~= 0.77 Hz */ 627 + { 0, 860000 }, /* 57% ~= 0.86 Hz */ 628 + { 1, 100000 }, /* 67% ~= 1.10 Hz */ 629 + { 1, 530000 }, /* 80% ~= 1.53 Hz */ 630 + { 7, 230000 } /* 100% ~= 7.23 Hz */ 631 + }, 632 + }; 633 + 634 + static const struct mlx_chip_info mlx90615_chip_info = { 635 + .op_eeprom_emissivity = MLX90615_OP_EEPROM | 0x03, 636 + .op_eeprom_config1 = MLX90615_OP_EEPROM | 0x02, 637 + .op_ram_ta = MLX90615_OP_RAM | 0x06, 638 + .op_ram_tobj1 = MLX90615_OP_RAM | 0x07, 639 + .op_ram_tobj2 = MLX90615_OP_RAM | 0x08, 640 + .op_sleep = MLX90615_OP_SLEEP, 641 + .dual_channel = false, 642 + .wakeup_delay_ms = MLX90615_TIMING_WAKEUP, 643 + .emissivity_max = 16383, 644 + .fir_config_mask = 0, /* MLX90615 FIR is fixed */ 645 + .iir_config_mask = MLX90615_CONFIG_IIR_MASK, 646 + /* IIR value 0 is FORBIDDEN COMBINATION on MLX90615 */ 647 + .iir_valid_offset = 1, 648 + .iir_values = { 500, 50, 30, 20, 15, 13, 10 }, 649 + .iir_freqs = { 650 + { 0, 100000 }, /* 14% ~= 0.10 Hz */ 651 + { 0, 130000 }, /* 17% ~= 0.13 Hz */ 652 + { 0, 150000 }, /* 20% ~= 0.15 Hz */ 653 + { 0, 200000 }, /* 25% ~= 0.20 Hz */ 654 + { 0, 300000 }, /* 33% ~= 0.30 Hz */ 655 + { 0, 500000 }, /* 50% ~= 0.50 Hz */ 656 + { 5, 000000 }, /* 100% ~= 5.00 Hz */ 657 + }, 658 + }; 659 + 653 660 static const struct i2c_device_id mlx90614_id[] = { 654 - { "mlx90614", 0 }, 661 + { "mlx90614", .driver_data = (kernel_ulong_t)&mlx90614_chip_info }, 662 + { "mlx90615", .driver_data = (kernel_ulong_t)&mlx90615_chip_info }, 655 663 { } 656 664 }; 657 665 MODULE_DEVICE_TABLE(i2c, mlx90614_id); 658 666 659 667 static const struct of_device_id mlx90614_of_match[] = { 660 - { .compatible = "melexis,mlx90614" }, 668 + { .compatible = "melexis,mlx90614", .data = &mlx90614_chip_info }, 669 + { .compatible = "melexis,mlx90615", .data = &mlx90615_chip_info }, 661 670 { } 662 671 }; 663 672 MODULE_DEVICE_TABLE(of, mlx90614_of_match); ··· 774 675 .of_match_table = mlx90614_of_match, 775 676 .pm = pm_ptr(&mlx90614_pm_ops), 776 677 }, 777 - .probe_new = mlx90614_probe, 678 + .probe = mlx90614_probe, 778 679 .remove = mlx90614_remove, 779 680 .id_table = mlx90614_id, 780 681 };
+1 -1
drivers/iio/temperature/mlx90632.c
··· 1337 1337 .of_match_table = mlx90632_of_match, 1338 1338 .pm = pm_ptr(&mlx90632_pm_ops), 1339 1339 }, 1340 - .probe_new = mlx90632_probe, 1340 + .probe = mlx90632_probe, 1341 1341 .id_table = mlx90632_id, 1342 1342 }; 1343 1343 module_i2c_driver(mlx90632_driver);
+9 -1
drivers/iio/temperature/tmp006.c
··· 15 15 #include <linux/i2c.h> 16 16 #include <linux/delay.h> 17 17 #include <linux/module.h> 18 + #include <linux/mod_devicetable.h> 18 19 #include <linux/pm.h> 19 20 #include <linux/bitops.h> 20 21 ··· 273 272 274 273 static DEFINE_SIMPLE_DEV_PM_OPS(tmp006_pm_ops, tmp006_suspend, tmp006_resume); 275 274 275 + static const struct of_device_id tmp006_of_match[] = { 276 + { .compatible = "ti,tmp006" }, 277 + { } 278 + }; 279 + MODULE_DEVICE_TABLE(of, tmp006_of_match); 280 + 276 281 static const struct i2c_device_id tmp006_id[] = { 277 282 { "tmp006", 0 }, 278 283 { } ··· 288 281 static struct i2c_driver tmp006_driver = { 289 282 .driver = { 290 283 .name = "tmp006", 284 + .of_match_table = tmp006_of_match, 291 285 .pm = pm_sleep_ptr(&tmp006_pm_ops), 292 286 }, 293 - .probe_new = tmp006_probe, 287 + .probe = tmp006_probe, 294 288 .id_table = tmp006_id, 295 289 }; 296 290 module_i2c_driver(tmp006_driver);
+1 -1
drivers/iio/temperature/tmp007.c
··· 574 574 .of_match_table = tmp007_of_match, 575 575 .pm = pm_sleep_ptr(&tmp007_pm_ops), 576 576 }, 577 - .probe_new = tmp007_probe, 577 + .probe = tmp007_probe, 578 578 .id_table = tmp007_id, 579 579 }; 580 580 module_i2c_driver(tmp007_driver);
+1 -1
drivers/iio/temperature/tmp117.c
··· 217 217 .name = "tmp117", 218 218 .of_match_table = tmp117_of_match, 219 219 }, 220 - .probe_new = tmp117_probe, 220 + .probe = tmp117_probe, 221 221 .id_table = tmp117_id, 222 222 }; 223 223 module_i2c_driver(tmp117_driver);
+1 -1
drivers/iio/temperature/tsys01.c
··· 218 218 MODULE_DEVICE_TABLE(of, tsys01_of_match); 219 219 220 220 static struct i2c_driver tsys01_driver = { 221 - .probe_new = tsys01_i2c_probe, 221 + .probe = tsys01_i2c_probe, 222 222 .id_table = tsys01_id, 223 223 .driver = { 224 224 .name = "tsys01",
+1 -1
drivers/iio/temperature/tsys02d.c
··· 174 174 MODULE_DEVICE_TABLE(i2c, tsys02d_id); 175 175 176 176 static struct i2c_driver tsys02d_driver = { 177 - .probe_new = tsys02d_probe, 177 + .probe = tsys02d_probe, 178 178 .id_table = tsys02d_id, 179 179 .driver = { 180 180 .name = "tsys02d",
+1 -1
drivers/staging/iio/addac/adt7316-i2c.c
··· 138 138 .of_match_table = adt7316_of_match, 139 139 .pm = ADT7316_PM_OPS, 140 140 }, 141 - .probe_new = adt7316_i2c_probe, 141 + .probe = adt7316_i2c_probe, 142 142 .id_table = adt7316_i2c_id, 143 143 }; 144 144 module_i2c_driver(adt7316_driver);
+1 -1
drivers/staging/iio/impedance-analyzer/ad5933.c
··· 781 781 .name = "ad5933", 782 782 .of_match_table = ad5933_of_match, 783 783 }, 784 - .probe_new = ad5933_probe, 784 + .probe = ad5933_probe, 785 785 .id_table = ad5933_id, 786 786 }; 787 787 module_i2c_driver(ad5933_driver);
+1
include/linux/iio/common/st_sensors.h
··· 22 22 #include <linux/platform_data/st_sensors_pdata.h> 23 23 24 24 #define LSM9DS0_IMU_DEV_NAME "lsm9ds0" 25 + #define LSM303D_IMU_DEV_NAME "lsm303d" 25 26 26 27 /* 27 28 * Buffer size max case: 2bytes per channel, 3 channels in total +
+3
include/linux/iio/iio.h
··· 221 221 * @extend_name: Allows labeling of channel attributes with an 222 222 * informative name. Note this has no effect codes etc, 223 223 * unlike modifiers. 224 + * This field is deprecated in favour of providing 225 + * iio_info->read_label() to override the label, which 226 + * unlike @extend_name does not affect sysfs filenames. 224 227 * @datasheet_name: A name used in in-kernel mapping of channels. It should 225 228 * correspond to the first name that the channel is referred 226 229 * to by in the datasheet (e.g. IND), or the nearest
+1
include/linux/iio/trigger.h
··· 171 171 */ 172 172 bool iio_trigger_using_own(struct iio_dev *indio_dev); 173 173 174 + int iio_validate_own_trigger(struct iio_dev *idev, struct iio_trigger *trig); 174 175 int iio_trigger_validate_own_device(struct iio_trigger *trig, 175 176 struct iio_dev *indio_dev); 176 177
+1 -1
include/linux/platform_data/st_sensors_pdata.h
··· 15 15 * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2). 16 16 * Available only for accelerometer, magnetometer and pressure sensors. 17 17 * Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet). 18 - * Magnetometer DRDY is supported only on LSM9DS0. 18 + * Magnetometer DRDY is supported only on LSM9DS0 and LSM303D. 19 19 * @open_drain: set the interrupt line to be open drain if possible. 20 20 * @spi_3wire: enable spi-3wire mode. 21 21 * @pullups: enable/disable i2c controller pullup resistors.