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

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

Jonathan writes:

2nd set of IIO new device support, cleanups etc for 6.2

Includes a few late breaking fixes for old issues.

Contains a large set of conversions from i2c probe() to probe_new()
as part of an attempt to finally get rid of the old style probe().

New devices support
* adi,ad74115
- New driver for this complex input/output device with 16 bit ADCs,
14 bit DACs amongst other features.
- A few tidy ups / removal of unused data patches followed.
* adi,adf4377
- New driver for this dual output integer-N phased locked loop and VCO
chip.
* maxim,max30208
- New driver for this high accuracy digital temperature sensor.
* st,lsm6dsx
- Support for LSM6DS016IS (chip specific data)
- Support for ISM330IS (id entry only)

Minor cleanups etc
* adi,adis
- Fix a deadlock on device instance specific mutex.
- Tidy up by calling unlocked form of __adis_initial_startup() in all
cases and dropping the locked version.
* adi,ad4130
- Reference spi-peripehral-props.yaml in the dt-binding.
* adi,ad74413r
- Fix a bug brought on by integer promotion of signed value to unsigned type.
- Add an spi_device_id table to allow module autoloading to work.
- Add support for reset pin.
* adi,ad7606_par
- devm_platform_get_and_ioremap_resource() instead of opencoding.
* adi,ad7923
- Add dt-bindings docs for ad7927 via a fallback to ad7928 and do similar
for ad7924.
* adi,ltc2983
- Drop a now unneeded $ref for -nanoamp property as dt-schema no covers this
unit.
* maxim,max11410
- Fix mask due to repeated use of VREFN instead of one of them being VREFP.
* qcom,spmi-iadc
- Add fallback compatibles to dt-binding.
* renesas,rzg2l
- Document use for RZ/Five SoC.
* st,stm32-adc
- Improved calibration support with error logging and a debugfs
interface to read back the result.
* ti,adc128s052
- Fix an issue with missing data members in the adc128_of_match table that
meant all device were being handled as adc128s052 ADCs.

* tag 'iio-for-6.2b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (178 commits)
iio: addac: ad74413r: fix blank line after declaration warning
iio: addac: ad74115: remove unused ad74115_dac_slew_rate_hz_tbl
dt-bindings: iio: imu: st_lsm6dsx: add ism330is
iio: imu: st_lsm6dsx: add support to ISM330IS
iio: frequency: adf4377: add support for ADF4377
dt-bindings: iio: frequency: add adf4377 doc
dt-bindings: iio: adc: ad4130: use spi-peripheral-props.yaml
dt-bindings: iio: temperature: ltc2983: drop $ref for -nanoamp properties
dt-bindings: iio: adc: renesas,rzg2l-adc: Document RZ/Five SoC
iio: adc128s052: add proper .data members in adc128_of_match table
iio: adc: stm32-adc: add debugfs to read raw calibration result
iio: adc: stm32-adc: improve calibration error log
iio: adc: stm32-adc: smart calibration support
iio: addac: ad74413r: add support for reset-gpio
dt-bindings: iio: ad74413r: add optional reset-gpios
iio: addac: ad74413r: add spi_device_id table
dt-bindings: iio/adc: qcom,spmi-iadc: use double compatibles
dt-bindings: iio: imu: st_lsm6dsx: add lsm6dso16is
iio: imu: st_lsm6dsx: add support to LSM6DSO16IS
iio: addac: add AD74115 driver
...

+4425 -552
+4 -1
Documentation/devicetree/bindings/iio/adc/adi,ad4130.yaml
··· 190 190 - reg 191 191 - diff-channels 192 192 193 - additionalProperties: false 193 + allOf: 194 + - $ref: /schemas/spi/spi-peripheral-props.yaml# 195 + 196 + unevaluatedProperties: false 194 197 195 198 examples: 196 199 - |
+17 -9
Documentation/devicetree/bindings/iio/adc/adi,ad7923.yaml
··· 11 11 12 12 description: | 13 13 Analog Devices AD7904, AD7914, AD7923, AD7924 4 Channel ADCs, and AD7908, 14 - AD7918, AD7928 8 Channels ADCs. 14 + AD7918, AD7927, AD7928 8 Channels ADCs. 15 15 16 16 Specifications about the part can be found at: 17 17 https://www.analog.com/media/en/technical-documentation/data-sheets/AD7923.pdf ··· 20 20 21 21 properties: 22 22 compatible: 23 - enum: 24 - - adi,ad7904 25 - - adi,ad7914 26 - - adi,ad7923 27 - - adi,ad7924 28 - - adi,ad7908 29 - - adi,ad7918 30 - - adi,ad7928 23 + oneOf: 24 + - enum: 25 + - adi,ad7904 26 + - adi,ad7908 27 + - adi,ad7914 28 + - adi,ad7918 29 + - adi,ad7923 30 + - adi,ad7928 31 + - const: adi,ad7924 32 + deprecated: true 33 + - items: 34 + - const: adi,ad7924 35 + - const: adi,ad7923 36 + - items: 37 + - const: adi,ad7927 38 + - const: adi,ad7928 31 39 32 40 reg: 33 41 maxItems: 1
+5 -2
Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.yaml
··· 18 18 19 19 properties: 20 20 compatible: 21 - const: qcom,spmi-iadc 21 + items: 22 + - enum: 23 + - qcom,pm8941-iadc 24 + - const: qcom,spmi-iadc 22 25 23 26 reg: 24 27 description: IADC base address and length in the SPMI PMIC register map ··· 53 50 #address-cells = <1>; 54 51 #size-cells = <0>; 55 52 pmic_iadc: adc@3600 { 56 - compatible = "qcom,spmi-iadc"; 53 + compatible = "qcom,pm8941-iadc", "qcom,spmi-iadc"; 57 54 reg = <0x3600>; 58 55 interrupts = <0x0 0x36 0x0 IRQ_TYPE_EDGE_RISING>; 59 56 qcom,external-resistor-micro-ohms = <10000>;
+1 -1
Documentation/devicetree/bindings/iio/adc/renesas,rzg2l-adc.yaml
··· 19 19 compatible: 20 20 items: 21 21 - enum: 22 - - renesas,r9a07g043-adc # RZ/G2UL 22 + - renesas,r9a07g043-adc # RZ/G2UL and RZ/Five 23 23 - renesas,r9a07g044-adc # RZ/G2L 24 24 - renesas,r9a07g054-adc # RZ/V2L 25 25 - const: renesas,rzg2l-adc
+373
Documentation/devicetree/bindings/iio/addac/adi,ad74115.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/addac/adi,ad74115.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Analog Devices AD74115H device 8 + 9 + maintainers: 10 + - Cosmin Tanislav <cosmin.tanislav@analog.com> 11 + 12 + description: | 13 + The AD74115H is a single-channel software configurable input/output 14 + device for industrial control applications. It contains functionality for 15 + analog output, analog input, digital output, digital input, resistance 16 + temperature detector, and thermocouple measurements integrated into a single 17 + chip solution with an SPI interface. The device features a 16-bit ADC and a 18 + 14-bit DAC. 19 + 20 + https://www.analog.com/en/products/ad74115h.html 21 + 22 + properties: 23 + compatible: 24 + enum: 25 + - adi,ad74115h 26 + 27 + reg: 28 + maxItems: 1 29 + 30 + spi-max-frequency: 31 + maximum: 24000000 32 + 33 + spi-cpol: true 34 + 35 + reset-gpios: true 36 + 37 + interrupts: 38 + minItems: 1 39 + maxItems: 2 40 + 41 + interrupt-names: 42 + minItems: 1 43 + maxItems: 2 44 + items: 45 + enum: 46 + - adc_rdy 47 + - alert 48 + 49 + avdd-supply: true 50 + avcc-supply: true 51 + dvcc-supply: true 52 + dovdd-supply: true 53 + refin-supply: true 54 + 55 + adi,ch-func: 56 + $ref: /schemas/types.yaml#/definitions/uint32 57 + description: | 58 + Channel function. 59 + 0 - High impedance 60 + 1 - Voltage output 61 + 2 - Current output 62 + 3 - Voltage input 63 + 4 - Current input, externally-powered 64 + 5 - Current input, loop-powered 65 + 6 - Resistance input 66 + 7 - RTD measure 67 + 8 - Digital input logic 68 + 9 - Digital input, loop-powered 69 + 10 - Current output with HART 70 + 11 - Current input, externally-powered, with HART 71 + 12 - Current input, loop-powered, with HART 72 + minimum: 0 73 + maximum: 12 74 + default: 0 75 + 76 + adi,conv2-mux: 77 + $ref: /schemas/types.yaml#/definitions/uint32 78 + description: | 79 + Input node for ADC conversion 2. 80 + 0 - SENSE_EXT1 to AGND_SENSE 81 + 1 - SENSE_EXT2 to AGND_SENSE 82 + 2 - SENSE_EXT2 to SENSE_EXT1 83 + 3 - AGND to AGND 84 + minimum: 0 85 + maximum: 3 86 + default: 0 87 + 88 + adi,conv2-range-microvolt: 89 + description: Conversion range for ADC conversion 2. 90 + oneOf: 91 + - items: 92 + - enum: [-2500000, 0] 93 + - const: 2500000 94 + - items: 95 + - enum: [-12000000, 0] 96 + - const: 12000000 97 + - items: 98 + - const: -2500000 99 + - const: 0 100 + - items: 101 + - const: -104000 102 + - const: 104000 103 + - items: 104 + - const: 0 105 + - const: 625000 106 + 107 + adi,sense-agnd-buffer-low-power: 108 + type: boolean 109 + description: 110 + Whether to enable low-power buffered mode for the AGND sense pin. 111 + 112 + adi,lf-buffer-low-power: 113 + type: boolean 114 + description: 115 + Whether to enable low-power buffered mode for the low-side filtered 116 + sense pin. 117 + 118 + adi,hf-buffer-low-power: 119 + type: boolean 120 + description: 121 + Whether to enable low-power buffered mode for the high-side filtered 122 + sense pin. 123 + 124 + adi,ext2-buffer-low-power: 125 + type: boolean 126 + description: Whether to enable low-power buffered mode for the EXT2 pin. 127 + 128 + adi,ext1-buffer-low-power: 129 + type: boolean 130 + description: Whether to enable low-power buffered mode for the EXT1 pin. 131 + 132 + adi,comparator-invert: 133 + type: boolean 134 + description: Whether to invert the comparator output. 135 + 136 + adi,digital-input-sink-range-high: 137 + $ref: /schemas/types.yaml#/definitions/uint32 138 + description: | 139 + When not present, the digital input range is from 0 to 3700uA in steps 140 + of 120uA, with a ~2k series resistance. 141 + When present, the digital input range is from 0 to 7400uA in steps 142 + of 240uA, with a ~1k series resistance. 143 + 144 + adi,digital-input-sink-microamp: 145 + description: Sink current in digital input mode. 146 + minimum: 0 147 + maximum: 3700 148 + default: 0 149 + 150 + adi,digital-input-debounce-mode-counter-reset: 151 + type: boolean 152 + description: | 153 + When not present, a counter increments when the signal is asserted 154 + and decrements when the signal is de-asserted. 155 + When present, a counter increments while the signal is asserted and 156 + resets when the signal de-asserts 157 + 158 + adi,digital-input-unbuffered: 159 + type: boolean 160 + description: Whether to buffer digital input signals. 161 + 162 + adi,digital-input-short-circuit-detection: 163 + type: boolean 164 + description: Whether to detect digital input short circuits. 165 + 166 + adi,digital-input-open-circuit-detection: 167 + type: boolean 168 + description: Whether to detect digital input open circuits. 169 + 170 + adi,digital-input-threshold-mode-fixed: 171 + type: boolean 172 + description: | 173 + When not present, the digital input threshold range is -0.96 * AVDD 174 + to AVDD. 175 + When present, the threshold range is fixed from -19V to 30V. 176 + 177 + adi,dac-bipolar: 178 + type: boolean 179 + description: | 180 + When not present, the DAC operates in the 0V to 12V range. 181 + When present, the DAC operates in the -12V to 12V range. 182 + 183 + adi,charge-pump: 184 + type: boolean 185 + description: Whether to enable the internal charge pump. 186 + 187 + adi,dac-hart-slew: 188 + type: boolean 189 + description: Whether to use a HART-compatible slew rate. 190 + 191 + adi,dac-current-limit-low: 192 + type: boolean 193 + description: | 194 + When not present, the DAC short-circuit current limit is 32mA in 195 + either source or sink for VOUT and 4mA sink for IOUT. 196 + When present, the limit is 16mA in either source or sink for VOUT, 197 + 1mA sink for IOUT. 198 + 199 + adi,4-wire-rtd: 200 + type: boolean 201 + description: | 202 + When not present, the ADC should be used for measuring 3-wire RTDs. 203 + When present, the ADC should be used for measuring 4-wire RTDs. 204 + 205 + adi,3-wire-rtd-excitation-swap: 206 + type: boolean 207 + description: Whether to swap the excitation for 3-wire RTD. 208 + 209 + adi,rtd-excitation-current-microamp: 210 + description: Excitation current to apply to RTD. 211 + enum: [250, 500, 750, 1000] 212 + default: 250 213 + 214 + adi,ext1-burnout: 215 + type: boolean 216 + description: Whether to enable burnout current for EXT1. 217 + 218 + adi,ext1-burnout-current-nanoamp: 219 + $ref: /schemas/types.yaml#/definitions/uint32 220 + description: 221 + Burnout current in nanoamps to be applied to EXT1. 222 + enum: [0, 50, 500, 1000, 10000] 223 + default: 0 224 + 225 + adi,ext1-burnout-current-polarity-sourcing: 226 + type: boolean 227 + description: | 228 + When not present, the burnout current polarity for EXT1 is sinking. 229 + When present, the burnout current polarity for EXT1 is sourcing. 230 + 231 + adi,ext2-burnout: 232 + type: boolean 233 + description: Whether to enable burnout current for EXT2. 234 + 235 + adi,ext2-burnout-current-nanoamp: 236 + $ref: /schemas/types.yaml#/definitions/uint32 237 + description: Burnout current in nanoamps to be applied to EXT2. 238 + enum: [0, 50, 500, 1000, 10000] 239 + default: 0 240 + 241 + adi,ext2-burnout-current-polarity-sourcing: 242 + type: boolean 243 + description: | 244 + When not present, the burnout current polarity for EXT2 is sinking. 245 + When present, the burnout current polarity for EXT2 is sourcing. 246 + 247 + adi,viout-burnout: 248 + type: boolean 249 + description: Whether to enable burnout current for VIOUT. 250 + 251 + adi,viout-burnout-current-nanoamp: 252 + $ref: /schemas/types.yaml#/definitions/uint32 253 + description: Burnout current in nanoamps to be applied to VIOUT. 254 + enum: [0, 1000, 10000] 255 + default: 0 256 + 257 + adi,viout-burnout-current-polarity-sourcing: 258 + type: boolean 259 + description: | 260 + When not present, the burnout current polarity for VIOUT is sinking. 261 + When present, the burnout current polarity for VIOUT is sourcing. 262 + 263 + adi,gpio0-mode: 264 + $ref: /schemas/types.yaml#/definitions/uint32 265 + description: | 266 + GPIO functions. 267 + 0 - Disabled 268 + 1 - Logic I/O 269 + 2 - Comparator output 270 + 3 - Control HART CD 271 + 4 - Monitor HART CD 272 + 5 - Monitor HART EOM status 273 + minimum: 0 274 + maximum: 5 275 + default: 0 276 + 277 + adi,gpio1-mode: 278 + $ref: /schemas/types.yaml#/definitions/uint32 279 + description: | 280 + GPIO functions. 281 + 0 - Disabled 282 + 1 - Logic I/O 283 + 2 - Drive external digital output FET 284 + 3 - Control HART RXD 285 + 4 - Monitor HART RXD 286 + 5 - Monitor HART SOM status 287 + minimum: 0 288 + maximum: 5 289 + default: 0 290 + 291 + adi,gpio2-mode: 292 + $ref: /schemas/types.yaml#/definitions/uint32 293 + description: | 294 + GPIO functions. 295 + 0 - Disabled 296 + 1 - Logic I/O 297 + 2 - Drive internal digital output FET 298 + 3 - Control HART TXD 299 + 4 - Monitor HART TXD 300 + 5 - Monitor HART TX complete status 301 + minimum: 0 302 + maximum: 5 303 + default: 0 304 + 305 + adi,gpio3-mode: 306 + $ref: /schemas/types.yaml#/definitions/uint32 307 + description: | 308 + GPIO functions. 309 + 0 - Disabled 310 + 1 - Logic I/O 311 + 2 - High impedance 312 + 3 - Control HART RTS 313 + 4 - Monitor HART RTS 314 + 5 - Monitor HART CD complete status 315 + minimum: 0 316 + maximum: 5 317 + default: 0 318 + 319 + required: 320 + - compatible 321 + - reg 322 + - spi-cpol 323 + - avdd-supply 324 + 325 + allOf: 326 + - $ref: /schemas/spi/spi-peripheral-props.yaml# 327 + - if: 328 + required: 329 + - adi,digital-input-sink-range-high 330 + then: 331 + properties: 332 + adi,digital-input-sink-microamp: 333 + maximum: 7400 334 + 335 + unevaluatedProperties: false 336 + 337 + examples: 338 + - | 339 + #include <dt-bindings/gpio/gpio.h> 340 + #include <dt-bindings/interrupt-controller/irq.h> 341 + 342 + spi { 343 + #address-cells = <1>; 344 + #size-cells = <0>; 345 + 346 + addac@0 { 347 + compatible = "adi,ad74115h"; 348 + reg = <0>; 349 + 350 + spi-max-frequency = <12000000>; 351 + spi-cpol; 352 + 353 + reset-gpios = <&gpio 27 GPIO_ACTIVE_LOW>; 354 + 355 + interrupt-parent = <&gpio>; 356 + interrupts = <26 IRQ_TYPE_EDGE_FALLING>; 357 + interrupt-names = "adc_rdy"; 358 + 359 + avdd-supply = <&ad74115_avdd>; 360 + 361 + adi,ch-func = <1>; 362 + adi,conv2-mux = <2>; 363 + adi,conv2-range-microvolt = <(-12000000) 12000000>; 364 + 365 + adi,gpio0-mode = <1>; 366 + adi,gpio1-mode = <1>; 367 + adi,gpio2-mode = <1>; 368 + adi,gpio3-mode = <1>; 369 + 370 + adi,dac-bipolar; 371 + }; 372 + }; 373 + ...
+4
Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml
··· 51 51 Shunt (sense) resistor value in micro-Ohms. 52 52 default: 100000000 53 53 54 + reset-gpios: 55 + maxItems: 1 56 + 54 57 required: 55 58 - compatible 56 59 - reg ··· 132 129 interrupts = <26 IRQ_TYPE_EDGE_FALLING>; 133 130 134 131 refin-supply = <&ad74413r_refin>; 132 + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; 135 133 136 134 channel@0 { 137 135 reg = <0>;
+92
Documentation/devicetree/bindings/iio/frequency/adi,adf4377.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/frequency/adi,adf4377.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: ADF4377 Microwave Wideband Synthesizer with Integrated VCO 8 + 9 + maintainers: 10 + - Antoniu Miclaus <antoniu.miclaus@analog.com> 11 + - Dragos Bogdan <dragos.bogdan@analog.com> 12 + 13 + description: | 14 + The ADF4377 is a high performance, ultralow jitter, dual output integer-N 15 + phased locked loop (PLL) with integrated voltage controlled oscillator (VCO) 16 + ideally suited for data converter and mixed signal front end (MxFE) clock 17 + applications. 18 + 19 + https://www.analog.com/en/products/adf4377.html 20 + 21 + properties: 22 + compatible: 23 + enum: 24 + - adi,adf4377 25 + - adi,adf4378 26 + 27 + reg: 28 + maxItems: 1 29 + 30 + spi-max-frequency: 31 + maximum: 10000000 32 + 33 + clocks: 34 + maxItems: 1 35 + 36 + clock-names: 37 + description: 38 + External clock that provides reference input frequency. 39 + items: 40 + - const: ref_in 41 + 42 + chip-enable-gpios: 43 + description: 44 + GPIO that controls the Chip Enable Pin. 45 + maxItems: 1 46 + 47 + clk1-enable-gpios: 48 + description: 49 + GPIO that controls the Enable Clock 1 Output Buffer Pin. 50 + maxItems: 1 51 + 52 + clk2-enable-gpios: 53 + description: 54 + GPIO that controls the Enable Clock 2 Output Buffer Pin. 55 + maxItems: 1 56 + 57 + adi,muxout-select: 58 + description: 59 + On chip multiplexer output selection. 60 + high_z - MUXOUT Pin set to high-Z. 61 + lock_detect - MUXOUT Pin set to lock detector output. 62 + muxout_low - MUXOUT Pin set to low. 63 + f_div_rclk_2 - MUXOUT Pin set to fDIV_RCLK/2. 64 + f_div_nclk_2 - MUXOUT Pin set to fDIV_NCLK/2. 65 + muxout_high - MUXOUT Pin set to high. 66 + enum: [high_z, lock_detect, muxout_low, f_div_rclk_2, f_div_nclk_2, muxout_high] 67 + 68 + required: 69 + - compatible 70 + - reg 71 + - clocks 72 + - clock-names 73 + 74 + allOf: 75 + - $ref: /schemas/spi/spi-peripheral-props.yaml# 76 + 77 + unevaluatedProperties: false 78 + 79 + examples: 80 + - | 81 + spi { 82 + #address-cells = <1>; 83 + #size-cells = <0>; 84 + frequency@0 { 85 + compatible = "adi,adf4377"; 86 + reg = <0>; 87 + spi-max-frequency = <10000000>; 88 + clocks = <&adf4377_ref_in>; 89 + clock-names = "ref_in"; 90 + }; 91 + }; 92 + ...
+4
Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml
··· 33 33 - st,lsm6dst 34 34 - st,lsm6dsop 35 35 - st,lsm6dsv 36 + - st,lsm6dso16is 36 37 - items: 37 38 - const: st,asm330lhhx 38 39 - const: st,lsm6dsr ··· 43 42 - items: 44 43 - const: st,lsm6dsv16x 45 44 - const: st,lsm6dsv 45 + - items: 46 + - const: st,ism330is 47 + - const: st,lsm6dso16is 46 48 47 49 reg: 48 50 maxItems: 1
-1
Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
··· 325 325 description: 326 326 Excitation current applied to the thermistor. 327 327 0 sets the sensor in auto-range mode. 328 - $ref: /schemas/types.yaml#/definitions/uint32 329 328 enum: [0, 250, 500, 1000, 5000, 10000, 25000, 50000, 100000, 250000, 330 329 500000, 1000000] 331 330 default: 0
+22
MAINTAINERS
··· 1175 1175 F: Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml 1176 1176 F: drivers/iio/adc/ad7780.c 1177 1177 1178 + ANALOG DEVICES INC AD74115 DRIVER 1179 + M: Cosmin Tanislav <cosmin.tanislav@analog.com> 1180 + L: linux-iio@vger.kernel.org 1181 + S: Supported 1182 + W: http://ez.analog.com/community/linux-device-drivers 1183 + F: Documentation/devicetree/bindings/iio/addac/adi,ad74115.yaml 1184 + F: drivers/iio/addac/ad74115.c 1185 + 1178 1186 ANALOG DEVICES INC AD74413R DRIVER 1179 1187 M: Cosmin Tanislav <cosmin.tanislav@analog.com> 1180 1188 L: linux-iio@vger.kernel.org ··· 1205 1197 W: https://ez.analog.com/linux-software-drivers 1206 1198 F: Documentation/devicetree/bindings/iio/amplifiers/adi,ada4250.yaml 1207 1199 F: drivers/iio/amplifiers/ada4250.c 1200 + 1201 + ANALOG DEVICES INC ADF4377 DRIVER 1202 + M: Antoniu Miclaus <antoniu.miclaus@analog.com> 1203 + L: linux-iio@vger.kernel.org 1204 + S: Supported 1205 + W: https://ez.analog.com/linux-software-drivers 1206 + F: Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml 1207 + F: drivers/iio/frequency/adf4377.c 1208 1208 1209 1209 ANALOG DEVICES INC ADGS1408 DRIVER 1210 1210 M: Mircea Caprioru <mircea.caprioru@analog.com> ··· 12537 12521 S: Maintained 12538 12522 F: Documentation/devicetree/bindings/regulator/maxim,max20086.yaml 12539 12523 F: drivers/regulator/max20086-regulator.c 12524 + 12525 + MAXIM MAX30208 TEMPERATURE SENSOR DRIVER 12526 + M: Rajat Khandelwal <rajat.khandelwal@linux.intel.com> 12527 + L: linux-iio@vger.kernel.org 12528 + S: Maintained 12529 + F: drivers/iio/temperature/max30208.c 12540 12530 12541 12531 MAXIM MAX77650 PMIC MFD DRIVER 12542 12532 M: Bartosz Golaszewski <brgl@bgdev.pl>
+1 -1
drivers/iio/accel/adis16201.c
··· 281 281 if (ret) 282 282 return ret; 283 283 284 - ret = adis_initial_startup(st); 284 + ret = __adis_initial_startup(st); 285 285 if (ret) 286 286 return ret; 287 287
+1 -1
drivers/iio/accel/adis16209.c
··· 291 291 if (ret) 292 292 return ret; 293 293 294 - ret = adis_initial_startup(st); 294 + ret = __adis_initial_startup(st); 295 295 if (ret) 296 296 return ret; 297 297
+3 -3
drivers/iio/accel/adxl372_i2c.c
··· 18 18 .readable_noinc_reg = adxl372_readable_noinc_reg, 19 19 }; 20 20 21 - static int adxl372_i2c_probe(struct i2c_client *client, 22 - const struct i2c_device_id *id) 21 + static int adxl372_i2c_probe(struct i2c_client *client) 23 22 { 23 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 24 24 struct regmap *regmap; 25 25 unsigned int regval; 26 26 int ret; ··· 58 58 .name = "adxl372_i2c", 59 59 .of_match_table = adxl372_of_match, 60 60 }, 61 - .probe = adxl372_i2c_probe, 61 + .probe_new = adxl372_i2c_probe, 62 62 .id_table = adxl372_i2c_id, 63 63 }; 64 64
+3 -3
drivers/iio/accel/bma180.c
··· 921 921 .reenable = bma180_trig_reen, 922 922 }; 923 923 924 - static int bma180_probe(struct i2c_client *client, 925 - const struct i2c_device_id *id) 924 + static int bma180_probe(struct i2c_client *client) 926 925 { 926 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 927 927 struct device *dev = &client->dev; 928 928 struct bma180_data *data; 929 929 struct iio_dev *indio_dev; ··· 1134 1134 .pm = pm_sleep_ptr(&bma180_pm_ops), 1135 1135 .of_match_table = bma180_of_match, 1136 1136 }, 1137 - .probe = bma180_probe, 1137 + .probe_new = bma180_probe, 1138 1138 .remove = bma180_remove, 1139 1139 .id_table = bma180_ids, 1140 1140 };
+3 -3
drivers/iio/accel/bma400_i2c.c
··· 13 13 14 14 #include "bma400.h" 15 15 16 - static int bma400_i2c_probe(struct i2c_client *client, 17 - const struct i2c_device_id *id) 16 + static int bma400_i2c_probe(struct i2c_client *client) 18 17 { 18 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 19 19 struct regmap *regmap; 20 20 21 21 regmap = devm_regmap_init_i2c(client, &bma400_regmap_config); ··· 44 44 .name = "bma400", 45 45 .of_match_table = bma400_of_i2c_match, 46 46 }, 47 - .probe = bma400_i2c_probe, 47 + .probe_new = bma400_i2c_probe, 48 48 .id_table = bma400_i2c_ids, 49 49 }; 50 50
+3 -3
drivers/iio/accel/bmc150-accel-i2c.c
··· 171 171 static void bmc150_acpi_dual_accel_remove(struct i2c_client *client) {} 172 172 #endif 173 173 174 - static int bmc150_accel_probe(struct i2c_client *client, 175 - const struct i2c_device_id *id) 174 + static int bmc150_accel_probe(struct i2c_client *client) 176 175 { 176 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 177 177 struct regmap *regmap; 178 178 const char *name = NULL; 179 179 enum bmc150_type type = BOSCH_UNKNOWN; ··· 269 269 .acpi_match_table = ACPI_PTR(bmc150_accel_acpi_match), 270 270 .pm = &bmc150_accel_pm_ops, 271 271 }, 272 - .probe = bmc150_accel_probe, 272 + .probe_new = bmc150_accel_probe, 273 273 .remove = bmc150_accel_remove, 274 274 .id_table = bmc150_accel_id, 275 275 };
+3 -3
drivers/iio/accel/da280.c
··· 105 105 da280_enable(client, false); 106 106 } 107 107 108 - static int da280_probe(struct i2c_client *client, 109 - const struct i2c_device_id *id) 108 + static int da280_probe(struct i2c_client *client) 110 109 { 110 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 111 111 int ret; 112 112 struct iio_dev *indio_dev; 113 113 struct da280_data *data; ··· 184 184 .acpi_match_table = ACPI_PTR(da280_acpi_match), 185 185 .pm = pm_sleep_ptr(&da280_pm_ops), 186 186 }, 187 - .probe = da280_probe, 187 + .probe_new = da280_probe, 188 188 .id_table = da280_i2c_id, 189 189 }; 190 190
+3 -3
drivers/iio/accel/kxcjk-1013.c
··· 1424 1424 return dev_name(dev); 1425 1425 } 1426 1426 1427 - static int kxcjk1013_probe(struct i2c_client *client, 1428 - const struct i2c_device_id *id) 1427 + static int kxcjk1013_probe(struct i2c_client *client) 1429 1428 { 1429 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1430 1430 static const char * const regulator_names[] = { "vdd", "vddio" }; 1431 1431 struct kxcjk1013_data *data; 1432 1432 struct iio_dev *indio_dev; ··· 1732 1732 .of_match_table = kxcjk1013_of_match, 1733 1733 .pm = &kxcjk1013_pm_ops, 1734 1734 }, 1735 - .probe = kxcjk1013_probe, 1735 + .probe_new = kxcjk1013_probe, 1736 1736 .remove = kxcjk1013_remove, 1737 1737 .id_table = kxcjk1013_id, 1738 1738 };
+3 -3
drivers/iio/accel/mma7455_i2c.c
··· 10 10 11 11 #include "mma7455.h" 12 12 13 - static int mma7455_i2c_probe(struct i2c_client *i2c, 14 - const struct i2c_device_id *id) 13 + static int mma7455_i2c_probe(struct i2c_client *i2c) 15 14 { 15 + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 16 16 struct regmap *regmap; 17 17 const char *name = NULL; 18 18 ··· 46 46 MODULE_DEVICE_TABLE(of, mma7455_of_match); 47 47 48 48 static struct i2c_driver mma7455_i2c_driver = { 49 - .probe = mma7455_i2c_probe, 49 + .probe_new = mma7455_i2c_probe, 50 50 .remove = mma7455_i2c_remove, 51 51 .id_table = mma7455_i2c_ids, 52 52 .driver = {
+3 -3
drivers/iio/accel/mma8452.c
··· 1545 1545 }; 1546 1546 MODULE_DEVICE_TABLE(of, mma8452_dt_ids); 1547 1547 1548 - static int mma8452_probe(struct i2c_client *client, 1549 - const struct i2c_device_id *id) 1548 + static int mma8452_probe(struct i2c_client *client) 1550 1549 { 1550 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1551 1551 struct mma8452_data *data; 1552 1552 struct iio_dev *indio_dev; 1553 1553 int ret; ··· 1846 1846 .of_match_table = mma8452_dt_ids, 1847 1847 .pm = &mma8452_pm_ops, 1848 1848 }, 1849 - .probe = mma8452_probe, 1849 + .probe_new = mma8452_probe, 1850 1850 .remove = mma8452_remove, 1851 1851 .id_table = mma8452_id, 1852 1852 };
+3 -3
drivers/iio/accel/mma9551.c
··· 446 446 return dev_name(dev); 447 447 } 448 448 449 - static int mma9551_probe(struct i2c_client *client, 450 - const struct i2c_device_id *id) 449 + static int mma9551_probe(struct i2c_client *client) 451 450 { 451 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 452 452 struct mma9551_data *data; 453 453 struct iio_dev *indio_dev; 454 454 const char *name = NULL; ··· 607 607 .acpi_match_table = ACPI_PTR(mma9551_acpi_match), 608 608 .pm = pm_ptr(&mma9551_pm_ops), 609 609 }, 610 - .probe = mma9551_probe, 610 + .probe_new = mma9551_probe, 611 611 .remove = mma9551_remove, 612 612 .id_table = mma9551_id, 613 613 };
+3 -3
drivers/iio/accel/mma9553.c
··· 1073 1073 return dev_name(dev); 1074 1074 } 1075 1075 1076 - static int mma9553_probe(struct i2c_client *client, 1077 - const struct i2c_device_id *id) 1076 + static int mma9553_probe(struct i2c_client *client) 1078 1077 { 1078 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1079 1079 struct mma9553_data *data; 1080 1080 struct iio_dev *indio_dev; 1081 1081 const char *name = NULL; ··· 1246 1246 .acpi_match_table = ACPI_PTR(mma9553_acpi_match), 1247 1247 .pm = pm_ptr(&mma9553_pm_ops), 1248 1248 }, 1249 - .probe = mma9553_probe, 1249 + .probe_new = mma9553_probe, 1250 1250 .remove = mma9553_remove, 1251 1251 .id_table = mma9553_id, 1252 1252 };
+3 -3
drivers/iio/adc/ad7091r5.c
··· 69 69 .vref_mV = 2500, 70 70 }; 71 71 72 - static int ad7091r5_i2c_probe(struct i2c_client *i2c, 73 - const struct i2c_device_id *id) 72 + static int ad7091r5_i2c_probe(struct i2c_client *i2c) 74 73 { 74 + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 75 75 const struct ad7091r_chip_info *chip_info; 76 76 struct regmap *map = devm_regmap_init_i2c(i2c, &ad7091r_regmap_config); 77 77 ··· 103 103 .name = "ad7091r5", 104 104 .of_match_table = ad7091r5_dt_ids, 105 105 }, 106 - .probe = ad7091r5_i2c_probe, 106 + .probe_new = ad7091r5_i2c_probe, 107 107 .id_table = ad7091r5_i2c_ids, 108 108 }; 109 109 module_i2c_driver(ad7091r5_driver);
+3 -3
drivers/iio/adc/ad7291.c
··· 465 465 regulator_disable(reg); 466 466 } 467 467 468 - static int ad7291_probe(struct i2c_client *client, 469 - const struct i2c_device_id *id) 468 + static int ad7291_probe(struct i2c_client *client) 470 469 { 470 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 471 471 struct ad7291_chip_info *chip; 472 472 struct iio_dev *indio_dev; 473 473 int ret; ··· 553 553 .name = KBUILD_MODNAME, 554 554 .of_match_table = ad7291_of_match, 555 555 }, 556 - .probe = ad7291_probe, 556 + .probe_new = ad7291_probe, 557 557 .id_table = ad7291_id, 558 558 }; 559 559 module_i2c_driver(ad7291_driver);
+1 -2
drivers/iio/adc/ad7606_par.c
··· 57 57 if (irq < 0) 58 58 return irq; 59 59 60 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 61 - addr = devm_ioremap_resource(&pdev->dev, res); 60 + addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 62 61 if (IS_ERR(addr)) 63 62 return PTR_ERR(addr); 64 63
+3 -3
drivers/iio/adc/ad799x.c
··· 775 775 }, 776 776 }; 777 777 778 - static int ad799x_probe(struct i2c_client *client, 779 - const struct i2c_device_id *id) 778 + static int ad799x_probe(struct i2c_client *client) 780 779 { 780 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 781 781 int ret; 782 782 int extra_config = 0; 783 783 struct ad799x_state *st; ··· 968 968 .name = "ad799x", 969 969 .pm = pm_sleep_ptr(&ad799x_pm_ops), 970 970 }, 971 - .probe = ad799x_probe, 971 + .probe_new = ad799x_probe, 972 972 .remove = ad799x_remove, 973 973 .id_table = ad799x_id, 974 974 };
+3 -3
drivers/iio/adc/ina2xx-adc.c
··· 946 946 return ina2xx_set_calibration(chip); 947 947 } 948 948 949 - static int ina2xx_probe(struct i2c_client *client, 950 - const struct i2c_device_id *id) 949 + static int ina2xx_probe(struct i2c_client *client) 951 950 { 951 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 952 952 struct ina2xx_chip_info *chip; 953 953 struct iio_dev *indio_dev; 954 954 unsigned int val; ··· 1090 1090 .name = KBUILD_MODNAME, 1091 1091 .of_match_table = ina2xx_of_match, 1092 1092 }, 1093 - .probe = ina2xx_probe, 1093 + .probe_new = ina2xx_probe, 1094 1094 .remove = ina2xx_remove, 1095 1095 .id_table = ina2xx_id, 1096 1096 };
+3 -3
drivers/iio/adc/ltc2471.c
··· 99 99 .read_raw = ltc2471_read_raw, 100 100 }; 101 101 102 - static int ltc2471_i2c_probe(struct i2c_client *client, 103 - const struct i2c_device_id *id) 102 + static int ltc2471_i2c_probe(struct i2c_client *client) 104 103 { 104 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 105 105 struct iio_dev *indio_dev; 106 106 struct ltc2471_data *data; 107 107 int ret; ··· 146 146 .driver = { 147 147 .name = "ltc2471", 148 148 }, 149 - .probe = ltc2471_i2c_probe, 149 + .probe_new = ltc2471_i2c_probe, 150 150 .id_table = ltc2471_i2c_id, 151 151 }; 152 152
+3 -3
drivers/iio/adc/ltc2485.c
··· 89 89 .read_raw = ltc2485_read_raw, 90 90 }; 91 91 92 - static int ltc2485_probe(struct i2c_client *client, 93 - const struct i2c_device_id *id) 92 + static int ltc2485_probe(struct i2c_client *client) 94 93 { 94 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 95 95 struct iio_dev *indio_dev; 96 96 struct ltc2485_data *data; 97 97 int ret; ··· 133 133 .driver = { 134 134 .name = "ltc2485", 135 135 }, 136 - .probe = ltc2485_probe, 136 + .probe_new = ltc2485_probe, 137 137 .id_table = ltc2485_id, 138 138 }; 139 139 module_i2c_driver(ltc2485_driver);
+3 -3
drivers/iio/adc/ltc2497.c
··· 94 94 return ret; 95 95 } 96 96 97 - static int ltc2497_probe(struct i2c_client *client, 98 - const struct i2c_device_id *id) 97 + static int ltc2497_probe(struct i2c_client *client) 99 98 { 99 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 100 100 const struct ltc2497_chip_info *chip_info; 101 101 struct iio_dev *indio_dev; 102 102 struct ltc2497_driverdata *st; ··· 165 165 .name = "ltc2497", 166 166 .of_match_table = ltc2497_of_match, 167 167 }, 168 - .probe = ltc2497_probe, 168 + .probe_new = ltc2497_probe, 169 169 .remove = ltc2497_remove, 170 170 .id_table = ltc2497_id, 171 171 };
+1 -1
drivers/iio/adc/max11410.c
··· 370 370 FIELD_PREP(MAX11410_CTRL_UNIPOLAR_BIT, cfg.bipolar ? 0 : 1); 371 371 ret = regmap_update_bits(st->regmap, MAX11410_REG_CTRL, 372 372 MAX11410_CTRL_REFSEL_MASK | 373 - MAX11410_CTRL_VREFN_BUF_BIT | 373 + MAX11410_CTRL_VREFP_BUF_BIT | 374 374 MAX11410_CTRL_VREFN_BUF_BIT | 375 375 MAX11410_CTRL_UNIPOLAR_BIT, regval); 376 376 if (ret)
+3 -3
drivers/iio/adc/max1363.c
··· 1579 1579 regulator_disable(reg); 1580 1580 } 1581 1581 1582 - static int max1363_probe(struct i2c_client *client, 1583 - const struct i2c_device_id *id) 1582 + static int max1363_probe(struct i2c_client *client) 1584 1583 { 1584 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1585 1585 int ret; 1586 1586 struct max1363_state *st; 1587 1587 struct iio_dev *indio_dev; ··· 1718 1718 .name = "max1363", 1719 1719 .of_match_table = max1363_of_match, 1720 1720 }, 1721 - .probe = max1363_probe, 1721 + .probe_new = max1363_probe, 1722 1722 .id_table = max1363_id, 1723 1723 }; 1724 1724 module_i2c_driver(max1363_driver);
+2 -3
drivers/iio/adc/max9611.c
··· 510 510 }; 511 511 512 512 MODULE_DEVICE_TABLE(of, max9611_of_table); 513 - static int max9611_probe(struct i2c_client *client, 514 - const struct i2c_device_id *id) 513 + static int max9611_probe(struct i2c_client *client) 515 514 { 516 515 const char * const shunt_res_prop = "shunt-resistor-micro-ohms"; 517 516 struct max9611_dev *max9611; ··· 556 557 .name = DRIVER_NAME, 557 558 .of_match_table = max9611_of_table, 558 559 }, 559 - .probe = max9611_probe, 560 + .probe_new = max9611_probe, 560 561 }; 561 562 module_i2c_driver(max9611_driver); 562 563
+3 -3
drivers/iio/adc/mcp3422.c
··· 330 330 .attrs = &mcp3422_attribute_group, 331 331 }; 332 332 333 - static int mcp3422_probe(struct i2c_client *client, 334 - const struct i2c_device_id *id) 333 + static int mcp3422_probe(struct i2c_client *client) 335 334 { 335 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 336 336 struct iio_dev *indio_dev; 337 337 struct mcp3422 *adc; 338 338 int err; ··· 417 417 .name = "mcp3422", 418 418 .of_match_table = mcp3422_of_match, 419 419 }, 420 - .probe = mcp3422_probe, 420 + .probe_new = mcp3422_probe, 421 421 .id_table = mcp3422_id, 422 422 }; 423 423 module_i2c_driver(mcp3422_driver);
+1
drivers/iio/adc/stm32-adc-core.h
··· 142 142 #define STM32H7_LINCALRDYW3 BIT(24) 143 143 #define STM32H7_LINCALRDYW2 BIT(23) 144 144 #define STM32H7_LINCALRDYW1 BIT(22) 145 + #define STM32H7_LINCALRDYW_MASK GENMASK(27, 22) 145 146 #define STM32H7_ADCALLIN BIT(16) 146 147 #define STM32H7_BOOST BIT(8) 147 148 #define STM32H7_ADSTP BIT(4)
+77 -58
drivers/iio/adc/stm32-adc.c
··· 7 7 */ 8 8 9 9 #include <linux/clk.h> 10 + #include <linux/debugfs.h> 10 11 #include <linux/delay.h> 11 12 #include <linux/dma-mapping.h> 12 13 #include <linux/dmaengine.h> ··· 120 119 121 120 /** 122 121 * struct stm32_adc_calib - optional adc calibration data 123 - * @calfact_s: Calibration offset for single ended channels 124 - * @calfact_d: Calibration offset in differential 125 122 * @lincalfact: Linearity calibration factor 126 - * @calibrated: Indicates calibration status 123 + * @lincal_saved: Indicates that linear calibration factors are saved 127 124 */ 128 125 struct stm32_adc_calib { 129 - u32 calfact_s; 130 - u32 calfact_d; 131 126 u32 lincalfact[STM32H7_LINCALFACT_NUM]; 132 - bool calibrated; 127 + bool lincal_saved; 133 128 }; 134 129 135 130 /** ··· 162 165 * @extsel: trigger selection register & bitfield 163 166 * @res: resolution selection register & bitfield 164 167 * @difsel: differential mode selection register & bitfield 165 - * @calfact_s: single-ended calibration factors register & bitfield 166 - * @calfact_d: differential calibration factors register & bitfield 167 168 * @smpr: smpr1 & smpr2 registers offset array 168 169 * @smp_bits: smpr1 & smpr2 index and bitfields 169 170 * @or_vddcore: option register & vddcore bitfield ··· 181 186 const struct stm32_adc_regs extsel; 182 187 const struct stm32_adc_regs res; 183 188 const struct stm32_adc_regs difsel; 184 - const struct stm32_adc_regs calfact_s; 185 - const struct stm32_adc_regs calfact_d; 186 189 const u32 smpr[2]; 187 190 const struct stm32_adc_regs *smp_bits; 188 191 const struct stm32_adc_regs or_vddcore; ··· 518 525 STM32H7_EXTSEL_SHIFT }, 519 526 .res = { STM32H7_ADC_CFGR, STM32H7_RES_MASK, STM32H7_RES_SHIFT }, 520 527 .difsel = { STM32H7_ADC_DIFSEL, STM32H7_DIFSEL_MASK}, 521 - .calfact_s = { STM32H7_ADC_CALFACT, STM32H7_CALFACT_S_MASK, 522 - STM32H7_CALFACT_S_SHIFT }, 523 - .calfact_d = { STM32H7_ADC_CALFACT, STM32H7_CALFACT_D_MASK, 524 - STM32H7_CALFACT_D_SHIFT }, 525 528 .smpr = { STM32H7_ADC_SMPR1, STM32H7_ADC_SMPR2 }, 526 529 .smp_bits = stm32h7_smp_bits, 527 530 }; ··· 539 550 STM32H7_EXTSEL_SHIFT }, 540 551 .res = { STM32H7_ADC_CFGR, STM32MP13_RES_MASK, STM32MP13_RES_SHIFT }, 541 552 .difsel = { STM32MP13_ADC_DIFSEL, STM32MP13_DIFSEL_MASK}, 542 - .calfact_s = { STM32MP13_ADC_CALFACT, STM32MP13_CALFACT_S_MASK, 543 - STM32MP13_CALFACT_S_SHIFT }, 544 - .calfact_d = { STM32MP13_ADC_CALFACT, STM32MP13_CALFACT_D_MASK, 545 - STM32MP13_CALFACT_D_SHIFT }, 546 553 .smpr = { STM32H7_ADC_SMPR1, STM32H7_ADC_SMPR2 }, 547 554 .smp_bits = stm32h7_smp_bits, 548 555 .or_vddcore = { STM32MP13_ADC2_OR, STM32MP13_OP0 }, ··· 560 575 STM32H7_EXTSEL_SHIFT }, 561 576 .res = { STM32H7_ADC_CFGR, STM32H7_RES_MASK, STM32H7_RES_SHIFT }, 562 577 .difsel = { STM32H7_ADC_DIFSEL, STM32H7_DIFSEL_MASK}, 563 - .calfact_s = { STM32H7_ADC_CALFACT, STM32H7_CALFACT_S_MASK, 564 - STM32H7_CALFACT_S_SHIFT }, 565 - .calfact_d = { STM32H7_ADC_CALFACT, STM32H7_CALFACT_D_MASK, 566 - STM32H7_CALFACT_D_SHIFT }, 567 578 .smpr = { STM32H7_ADC_SMPR1, STM32H7_ADC_SMPR2 }, 568 579 .smp_bits = stm32h7_smp_bits, 569 580 .or_vddcore = { STM32MP1_ADC2_OR, STM32MP1_VDDCOREEN }, ··· 981 1000 int i, ret; 982 1001 u32 lincalrdyw_mask, val; 983 1002 984 - if (!adc->cfg->has_linearcal) 985 - goto skip_linearcal; 986 - 987 1003 /* Read linearity calibration */ 988 1004 lincalrdyw_mask = STM32H7_LINCALRDYW6; 989 1005 for (i = STM32H7_LINCALFACT_NUM - 1; i >= 0; i--) { ··· 1002 1024 1003 1025 lincalrdyw_mask >>= 1; 1004 1026 } 1005 - 1006 - skip_linearcal: 1007 - /* Read offset calibration */ 1008 - val = stm32_adc_readl(adc, adc->cfg->regs->calfact_s.reg); 1009 - adc->cal.calfact_s = (val & adc->cfg->regs->calfact_s.mask); 1010 - adc->cal.calfact_s >>= adc->cfg->regs->calfact_s.shift; 1011 - adc->cal.calfact_d = (val & adc->cfg->regs->calfact_d.mask); 1012 - adc->cal.calfact_d >>= adc->cfg->regs->calfact_d.shift; 1013 - adc->cal.calibrated = true; 1027 + adc->cal.lincal_saved = true; 1014 1028 1015 1029 return 0; 1016 1030 } ··· 1017 1047 struct stm32_adc *adc = iio_priv(indio_dev); 1018 1048 int i, ret; 1019 1049 u32 lincalrdyw_mask, val; 1020 - 1021 - val = (adc->cal.calfact_s << adc->cfg->regs->calfact_s.shift) | 1022 - (adc->cal.calfact_d << adc->cfg->regs->calfact_d.shift); 1023 - stm32_adc_writel(adc, adc->cfg->regs->calfact_s.reg, val); 1024 - 1025 - if (!adc->cfg->has_linearcal) 1026 - return 0; 1027 1050 1028 1051 lincalrdyw_mask = STM32H7_LINCALRDYW6; 1029 1052 for (i = STM32H7_LINCALFACT_NUM - 1; i >= 0; i--) { ··· 1079 1116 /** 1080 1117 * stm32h7_adc_selfcalib() - Procedure to calibrate ADC 1081 1118 * @indio_dev: IIO device instance 1119 + * @do_lincal: linear calibration request flag 1082 1120 * Note: Must be called once ADC is out of power down. 1121 + * 1122 + * Run offset calibration unconditionally. 1123 + * Run linear calibration if requested & supported. 1083 1124 */ 1084 - static int stm32h7_adc_selfcalib(struct iio_dev *indio_dev) 1125 + static int stm32h7_adc_selfcalib(struct iio_dev *indio_dev, int do_lincal) 1085 1126 { 1086 1127 struct stm32_adc *adc = iio_priv(indio_dev); 1087 1128 int ret; 1088 1129 u32 msk = STM32H7_ADCALDIF; 1089 1130 u32 val; 1090 1131 1091 - if (adc->cal.calibrated) 1092 - return true; 1093 - 1094 - if (adc->cfg->has_linearcal) 1132 + if (adc->cfg->has_linearcal && do_lincal) 1095 1133 msk |= STM32H7_ADCALLIN; 1096 1134 /* ADC must be disabled for calibration */ 1097 1135 stm32h7_adc_disable(indio_dev); ··· 1110 1146 !(val & STM32H7_ADCAL), 100, 1111 1147 STM32H7_ADC_CALIB_TIMEOUT_US); 1112 1148 if (ret) { 1113 - dev_err(&indio_dev->dev, "calibration failed\n"); 1149 + dev_err(&indio_dev->dev, "calibration (single-ended) error %d\n", ret); 1114 1150 goto out; 1115 1151 } 1116 1152 ··· 1126 1162 !(val & STM32H7_ADCAL), 100, 1127 1163 STM32H7_ADC_CALIB_TIMEOUT_US); 1128 1164 if (ret) { 1129 - dev_err(&indio_dev->dev, "calibration failed\n"); 1165 + dev_err(&indio_dev->dev, "calibration (diff%s) error %d\n", 1166 + (msk & STM32H7_ADCALLIN) ? "+linear" : "", ret); 1130 1167 goto out; 1131 1168 } 1132 1169 ··· 1135 1170 stm32_adc_clr_bits(adc, STM32H7_ADC_CR, msk); 1136 1171 1137 1172 return ret; 1173 + } 1174 + 1175 + /** 1176 + * stm32h7_adc_check_selfcalib() - Check linear calibration status 1177 + * @indio_dev: IIO device instance 1178 + * 1179 + * Used to check if linear calibration has been done. 1180 + * Return true if linear calibration factors are already saved in private data 1181 + * or if a linear calibration has been done at boot stage. 1182 + */ 1183 + static int stm32h7_adc_check_selfcalib(struct iio_dev *indio_dev) 1184 + { 1185 + struct stm32_adc *adc = iio_priv(indio_dev); 1186 + u32 val; 1187 + 1188 + if (adc->cal.lincal_saved) 1189 + return true; 1190 + 1191 + /* 1192 + * Check if linear calibration factors are available in ADC registers, 1193 + * by checking that all LINCALRDYWx bits are set. 1194 + */ 1195 + val = stm32_adc_readl(adc, STM32H7_ADC_CR) & STM32H7_LINCALRDYW_MASK; 1196 + if (val == STM32H7_LINCALRDYW_MASK) 1197 + return true; 1198 + 1199 + return false; 1138 1200 } 1139 1201 1140 1202 /** ··· 1178 1186 static int stm32h7_adc_prepare(struct iio_dev *indio_dev) 1179 1187 { 1180 1188 struct stm32_adc *adc = iio_priv(indio_dev); 1181 - int calib, ret; 1189 + int lincal_done = false; 1190 + int ret; 1182 1191 1183 1192 ret = stm32h7_adc_exit_pwr_down(indio_dev); 1184 1193 if (ret) 1185 1194 return ret; 1186 1195 1187 - ret = stm32h7_adc_selfcalib(indio_dev); 1196 + if (adc->cfg->has_linearcal) 1197 + lincal_done = stm32h7_adc_check_selfcalib(indio_dev); 1198 + 1199 + /* Always run offset calibration. Run linear calibration only once */ 1200 + ret = stm32h7_adc_selfcalib(indio_dev, !lincal_done); 1188 1201 if (ret < 0) 1189 1202 goto pwr_dwn; 1190 - calib = ret; 1191 1203 1192 1204 stm32_adc_int_ch_enable(indio_dev); 1193 1205 ··· 1201 1205 if (ret) 1202 1206 goto ch_disable; 1203 1207 1204 - /* Either restore or read calibration result for future reference */ 1205 - if (calib) 1206 - ret = stm32h7_adc_restore_selfcalib(indio_dev); 1207 - else 1208 - ret = stm32h7_adc_read_selfcalib(indio_dev); 1209 - if (ret) 1210 - goto disable; 1208 + if (adc->cfg->has_linearcal) { 1209 + if (!adc->cal.lincal_saved) 1210 + ret = stm32h7_adc_read_selfcalib(indio_dev); 1211 + else 1212 + ret = stm32h7_adc_restore_selfcalib(indio_dev); 1213 + 1214 + if (ret) 1215 + goto disable; 1216 + } 1211 1217 1212 1218 if (adc->cfg->has_presel) 1213 1219 stm32_adc_writel(adc, STM32H7_ADC_PCSEL, adc->pcsel); ··· 1880 1882 {}, 1881 1883 }; 1882 1884 1885 + static void stm32_adc_debugfs_init(struct iio_dev *indio_dev) 1886 + { 1887 + struct stm32_adc *adc = iio_priv(indio_dev); 1888 + struct dentry *d = iio_get_debugfs_dentry(indio_dev); 1889 + struct stm32_adc_calib *cal = &adc->cal; 1890 + char buf[16]; 1891 + unsigned int i; 1892 + 1893 + if (!adc->cfg->has_linearcal) 1894 + return; 1895 + 1896 + for (i = 0; i < STM32H7_LINCALFACT_NUM; i++) { 1897 + snprintf(buf, sizeof(buf), "lincalfact%d", i + 1); 1898 + debugfs_create_u32(buf, 0444, d, &cal->lincalfact[i]); 1899 + } 1900 + } 1901 + 1883 1902 static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev) 1884 1903 { 1885 1904 struct device *dev = &indio_dev->dev; ··· 2483 2468 pm_runtime_mark_last_busy(dev); 2484 2469 pm_runtime_put_autosuspend(dev); 2485 2470 2471 + if (IS_ENABLED(CONFIG_DEBUG_FS)) 2472 + stm32_adc_debugfs_init(indio_dev); 2473 + 2486 2474 return 0; 2487 2475 2488 2476 err_hw_stop: ··· 2514 2496 struct stm32_adc *adc = iio_priv(indio_dev); 2515 2497 2516 2498 pm_runtime_get_sync(&pdev->dev); 2499 + /* iio_device_unregister() also removes debugfs entries */ 2517 2500 iio_device_unregister(indio_dev); 2518 2501 stm32_adc_hw_stop(&pdev->dev); 2519 2502 pm_runtime_disable(&pdev->dev);
+3 -3
drivers/iio/adc/ti-adc081c.c
··· 152 152 regulator_disable(reg); 153 153 } 154 154 155 - static int adc081c_probe(struct i2c_client *client, 156 - const struct i2c_device_id *id) 155 + static int adc081c_probe(struct i2c_client *client) 157 156 { 157 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 158 158 struct iio_dev *iio; 159 159 struct adc081c *adc; 160 160 const struct adcxx1c_model *model; ··· 235 235 .of_match_table = adc081c_of_match, 236 236 .acpi_match_table = adc081c_acpi_match, 237 237 }, 238 - .probe = adc081c_probe, 238 + .probe_new = adc081c_probe, 239 239 .id_table = adc081c_id, 240 240 }; 241 241 module_i2c_driver(adc081c_driver);
+7 -7
drivers/iio/adc/ti-adc128s052.c
··· 181 181 } 182 182 183 183 static const struct of_device_id adc128_of_match[] = { 184 - { .compatible = "ti,adc128s052", }, 185 - { .compatible = "ti,adc122s021", }, 186 - { .compatible = "ti,adc122s051", }, 187 - { .compatible = "ti,adc122s101", }, 188 - { .compatible = "ti,adc124s021", }, 189 - { .compatible = "ti,adc124s051", }, 190 - { .compatible = "ti,adc124s101", }, 184 + { .compatible = "ti,adc128s052", .data = (void*)0L, }, 185 + { .compatible = "ti,adc122s021", .data = (void*)1L, }, 186 + { .compatible = "ti,adc122s051", .data = (void*)1L, }, 187 + { .compatible = "ti,adc122s101", .data = (void*)1L, }, 188 + { .compatible = "ti,adc124s021", .data = (void*)2L, }, 189 + { .compatible = "ti,adc124s051", .data = (void*)2L, }, 190 + { .compatible = "ti,adc124s101", .data = (void*)2L, }, 191 191 { /* sentinel */ }, 192 192 }; 193 193 MODULE_DEVICE_TABLE(of, adc128_of_match);
+3 -3
drivers/iio/adc/ti-ads1015.c
··· 974 974 mode << ADS1015_CFG_MOD_SHIFT); 975 975 } 976 976 977 - static int ads1015_probe(struct i2c_client *client, 978 - const struct i2c_device_id *id) 977 + static int ads1015_probe(struct i2c_client *client) 979 978 { 979 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 980 980 const struct ads1015_chip_data *chip; 981 981 struct iio_dev *indio_dev; 982 982 struct ads1015_data *data; ··· 1195 1195 .of_match_table = ads1015_of_match, 1196 1196 .pm = &ads1015_pm_ops, 1197 1197 }, 1198 - .probe = ads1015_probe, 1198 + .probe_new = ads1015_probe, 1199 1199 .remove = ads1015_remove, 1200 1200 .id_table = ads1015_id, 1201 1201 };
+14
drivers/iio/addac/Kconfig
··· 5 5 6 6 menu "Analog to digital and digital to analog converters" 7 7 8 + config AD74115 9 + tristate "Analog Devices AD74115H driver" 10 + depends on GPIOLIB && SPI 11 + select CRC8 12 + select IIO_BUFFER 13 + select IIO_TRIGGERED_BUFFER 14 + select REGMAP_SPI 15 + help 16 + Say yes here to build support for Analog Devices AD74115H 17 + single-channel software configurable input/output solution. 18 + 19 + To compile this driver as a module, choose M here: the 20 + module will be called ad74115. 21 + 8 22 config AD74413R 9 23 tristate "Analog Devices AD74412R/AD74413R driver" 10 24 depends on GPIOLIB && SPI
+1
drivers/iio/addac/Makefile
··· 4 4 # 5 5 6 6 # When adding new entries keep the list in alphabetical order 7 + obj-$(CONFIG_AD74115) += ad74115.o 7 8 obj-$(CONFIG_AD74413R) += ad74413r.o 8 9 obj-$(CONFIG_STX104) += stx104.o
+1943
drivers/iio/addac/ad74115.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2022 Analog Devices, Inc. 4 + * Author: Cosmin Tanislav <cosmin.tanislav@analog.com> 5 + */ 6 + 7 + #include <linux/bitfield.h> 8 + #include <linux/bitops.h> 9 + #include <linux/crc8.h> 10 + #include <linux/device.h> 11 + #include <linux/gpio/driver.h> 12 + #include <linux/interrupt.h> 13 + #include <linux/module.h> 14 + #include <linux/regmap.h> 15 + #include <linux/regulator/consumer.h> 16 + #include <linux/spi/spi.h> 17 + #include <linux/units.h> 18 + 19 + #include <asm/unaligned.h> 20 + 21 + #include <linux/iio/buffer.h> 22 + #include <linux/iio/iio.h> 23 + #include <linux/iio/trigger.h> 24 + #include <linux/iio/trigger_consumer.h> 25 + #include <linux/iio/triggered_buffer.h> 26 + 27 + #define AD74115_NAME "ad74115" 28 + 29 + #define AD74115_CH_FUNC_SETUP_REG 0x01 30 + 31 + #define AD74115_ADC_CONFIG_REG 0x02 32 + #define AD74115_ADC_CONFIG_CONV2_RATE_MASK GENMASK(15, 13) 33 + #define AD74115_ADC_CONFIG_CONV1_RATE_MASK GENMASK(12, 10) 34 + #define AD74115_ADC_CONFIG_CONV2_RANGE_MASK GENMASK(9, 7) 35 + #define AD74115_ADC_CONFIG_CONV1_RANGE_MASK GENMASK(6, 4) 36 + 37 + #define AD74115_PWR_OPTIM_CONFIG_REG 0x03 38 + 39 + #define AD74115_DIN_CONFIG1_REG 0x04 40 + #define AD74115_DIN_COMPARATOR_EN_MASK BIT(13) 41 + #define AD74115_DIN_SINK_MASK GENMASK(11, 7) 42 + #define AD74115_DIN_DEBOUNCE_MASK GENMASK(4, 0) 43 + 44 + #define AD74115_DIN_CONFIG2_REG 0x05 45 + #define AD74115_COMP_THRESH_MASK GENMASK(6, 0) 46 + 47 + #define AD74115_OUTPUT_CONFIG_REG 0x06 48 + #define AD74115_OUTPUT_SLEW_EN_MASK GENMASK(6, 5) 49 + #define AD74115_OUTPUT_SLEW_LIN_STEP_MASK GENMASK(4, 3) 50 + #define AD74115_OUTPUT_SLEW_LIN_RATE_MASK GENMASK(2, 1) 51 + 52 + #define AD74115_RTD3W4W_CONFIG_REG 0x07 53 + 54 + #define AD74115_BURNOUT_CONFIG_REG 0x0a 55 + #define AD74115_BURNOUT_EXT2_EN_MASK BIT(10) 56 + #define AD74115_BURNOUT_EXT1_EN_MASK BIT(5) 57 + #define AD74115_BURNOUT_VIOUT_EN_MASK BIT(0) 58 + 59 + #define AD74115_DAC_CODE_REG 0x0b 60 + 61 + #define AD74115_DAC_ACTIVE_REG 0x0d 62 + 63 + #define AD74115_GPIO_CONFIG_X_REG(x) (0x35 + (x)) 64 + #define AD74115_GPIO_CONFIG_GPI_DATA BIT(5) 65 + #define AD74115_GPIO_CONFIG_GPO_DATA BIT(4) 66 + #define AD74115_GPIO_CONFIG_SELECT_MASK GENMASK(2, 0) 67 + 68 + #define AD74115_CHARGE_PUMP_REG 0x3a 69 + 70 + #define AD74115_ADC_CONV_CTRL_REG 0x3b 71 + #define AD74115_ADC_CONV_SEQ_MASK GENMASK(13, 12) 72 + 73 + #define AD74115_DIN_COMP_OUT_REG 0x40 74 + 75 + #define AD74115_LIVE_STATUS_REG 0x42 76 + #define AD74115_ADC_DATA_RDY_MASK BIT(3) 77 + 78 + #define AD74115_READ_SELECT_REG 0x64 79 + 80 + #define AD74115_CMD_KEY_REG 0x78 81 + #define AD74115_CMD_KEY_RESET1 0x15fa 82 + #define AD74115_CMD_KEY_RESET2 0xaf51 83 + 84 + #define AD74115_CRC_POLYNOMIAL 0x7 85 + DECLARE_CRC8_TABLE(ad74115_crc8_table); 86 + 87 + #define AD74115_ADC_CODE_MAX ((int)GENMASK(15, 0)) 88 + #define AD74115_ADC_CODE_HALF (AD74115_ADC_CODE_MAX / 2) 89 + 90 + #define AD74115_DAC_VOLTAGE_MAX 12000 91 + #define AD74115_DAC_CURRENT_MAX 25 92 + #define AD74115_DAC_CODE_MAX ((int)GENMASK(13, 0)) 93 + #define AD74115_DAC_CODE_HALF (AD74115_DAC_CODE_MAX / 2) 94 + 95 + #define AD74115_COMP_THRESH_MAX 98 96 + 97 + #define AD74115_SENSE_RESISTOR_OHMS 100 98 + #define AD74115_REF_RESISTOR_OHMS 2100 99 + 100 + #define AD74115_DIN_SINK_LOW_STEP 120 101 + #define AD74115_DIN_SINK_HIGH_STEP 240 102 + #define AD74115_DIN_SINK_MAX 31 103 + 104 + #define AD74115_FRAME_SIZE 4 105 + #define AD74115_GPIO_NUM 4 106 + 107 + #define AD74115_CONV_TIME_US 1000000 108 + 109 + enum ad74115_dac_ch { 110 + AD74115_DAC_CH_MAIN, 111 + AD74115_DAC_CH_COMPARATOR, 112 + }; 113 + 114 + enum ad74115_adc_ch { 115 + AD74115_ADC_CH_CONV1, 116 + AD74115_ADC_CH_CONV2, 117 + AD74115_ADC_CH_NUM 118 + }; 119 + 120 + enum ad74115_ch_func { 121 + AD74115_CH_FUNC_HIGH_IMPEDANCE, 122 + AD74115_CH_FUNC_VOLTAGE_OUTPUT, 123 + AD74115_CH_FUNC_CURRENT_OUTPUT, 124 + AD74115_CH_FUNC_VOLTAGE_INPUT, 125 + AD74115_CH_FUNC_CURRENT_INPUT_EXT_POWER, 126 + AD74115_CH_FUNC_CURRENT_INPUT_LOOP_POWER, 127 + AD74115_CH_FUNC_2_WIRE_RESISTANCE_INPUT, 128 + AD74115_CH_FUNC_3_4_WIRE_RESISTANCE_INPUT, 129 + AD74115_CH_FUNC_DIGITAL_INPUT_LOGIC, 130 + AD74115_CH_FUNC_DIGITAL_INPUT_LOOP_POWER, 131 + AD74115_CH_FUNC_CURRENT_OUTPUT_HART, 132 + AD74115_CH_FUNC_CURRENT_INPUT_EXT_POWER_HART, 133 + AD74115_CH_FUNC_CURRENT_INPUT_LOOP_POWER_HART, 134 + AD74115_CH_FUNC_MAX = AD74115_CH_FUNC_CURRENT_INPUT_LOOP_POWER_HART, 135 + AD74115_CH_FUNC_NUM 136 + }; 137 + 138 + enum ad74115_adc_range { 139 + AD74115_ADC_RANGE_12V, 140 + AD74115_ADC_RANGE_12V_BIPOLAR, 141 + AD74115_ADC_RANGE_2_5V_BIPOLAR, 142 + AD74115_ADC_RANGE_2_5V_NEG, 143 + AD74115_ADC_RANGE_2_5V, 144 + AD74115_ADC_RANGE_0_625V, 145 + AD74115_ADC_RANGE_104MV_BIPOLAR, 146 + AD74115_ADC_RANGE_12V_OTHER, 147 + AD74115_ADC_RANGE_MAX = AD74115_ADC_RANGE_12V_OTHER, 148 + AD74115_ADC_RANGE_NUM 149 + }; 150 + 151 + enum ad74115_adc_conv_seq { 152 + AD74115_ADC_CONV_SEQ_STANDBY = 0b00, 153 + AD74115_ADC_CONV_SEQ_SINGLE = 0b01, 154 + AD74115_ADC_CONV_SEQ_CONTINUOUS = 0b10, 155 + }; 156 + 157 + enum ad74115_din_threshold_mode { 158 + AD74115_DIN_THRESHOLD_MODE_AVDD, 159 + AD74115_DIN_THRESHOLD_MODE_FIXED, 160 + AD74115_DIN_THRESHOLD_MODE_MAX = AD74115_DIN_THRESHOLD_MODE_FIXED, 161 + }; 162 + 163 + enum ad74115_slew_mode { 164 + AD74115_SLEW_MODE_DISABLED, 165 + AD74115_SLEW_MODE_LINEAR, 166 + AD74115_SLEW_MODE_HART, 167 + }; 168 + 169 + enum ad74115_slew_step { 170 + AD74115_SLEW_STEP_0_8_PERCENT, 171 + AD74115_SLEW_STEP_1_5_PERCENT, 172 + AD74115_SLEW_STEP_6_1_PERCENT, 173 + AD74115_SLEW_STEP_22_2_PERCENT, 174 + }; 175 + 176 + enum ad74115_slew_rate { 177 + AD74115_SLEW_RATE_4KHZ, 178 + AD74115_SLEW_RATE_64KHZ, 179 + AD74115_SLEW_RATE_150KHZ, 180 + AD74115_SLEW_RATE_240KHZ, 181 + }; 182 + 183 + enum ad74115_gpio_config { 184 + AD74115_GPIO_CONFIG_OUTPUT_BUFFERED = 0b010, 185 + AD74115_GPIO_CONFIG_INPUT = 0b011, 186 + }; 187 + 188 + enum ad74115_gpio_mode { 189 + AD74115_GPIO_MODE_LOGIC = 1, 190 + AD74115_GPIO_MODE_SPECIAL = 2, 191 + }; 192 + 193 + struct ad74115_channels { 194 + struct iio_chan_spec *channels; 195 + unsigned int num_channels; 196 + }; 197 + 198 + struct ad74115_state { 199 + struct spi_device *spi; 200 + struct regmap *regmap; 201 + struct iio_trigger *trig; 202 + struct regulator *avdd; 203 + 204 + /* 205 + * Synchronize consecutive operations when doing a one-shot 206 + * conversion and when updating the ADC samples SPI message. 207 + */ 208 + struct mutex lock; 209 + struct gpio_chip gc; 210 + struct gpio_chip comp_gc; 211 + int irq; 212 + 213 + unsigned int avdd_mv; 214 + unsigned long gpio_valid_mask; 215 + bool dac_bipolar; 216 + bool dac_hart_slew; 217 + bool rtd_mode_4_wire; 218 + enum ad74115_ch_func ch_func; 219 + enum ad74115_din_threshold_mode din_threshold_mode; 220 + 221 + struct completion adc_data_completion; 222 + struct spi_message adc_samples_msg; 223 + struct spi_transfer adc_samples_xfer[AD74115_ADC_CH_NUM + 1]; 224 + 225 + /* 226 + * DMA (thus cache coherency maintenance) requires the 227 + * transfer buffers to live in their own cache lines. 228 + */ 229 + u8 reg_tx_buf[AD74115_FRAME_SIZE] __aligned(IIO_DMA_MINALIGN); 230 + u8 reg_rx_buf[AD74115_FRAME_SIZE]; 231 + u8 adc_samples_tx_buf[AD74115_FRAME_SIZE * AD74115_ADC_CH_NUM]; 232 + u8 adc_samples_rx_buf[AD74115_FRAME_SIZE * AD74115_ADC_CH_NUM]; 233 + }; 234 + 235 + struct ad74115_fw_prop { 236 + const char *name; 237 + bool is_boolean; 238 + bool negate; 239 + unsigned int max; 240 + unsigned int reg; 241 + unsigned int mask; 242 + const unsigned int *lookup_tbl; 243 + unsigned int lookup_tbl_len; 244 + }; 245 + 246 + #define AD74115_FW_PROP(_name, _max, _reg, _mask) \ 247 + { \ 248 + .name = (_name), \ 249 + .max = (_max), \ 250 + .reg = (_reg), \ 251 + .mask = (_mask), \ 252 + } 253 + 254 + #define AD74115_FW_PROP_TBL(_name, _tbl, _reg, _mask) \ 255 + { \ 256 + .name = (_name), \ 257 + .reg = (_reg), \ 258 + .mask = (_mask), \ 259 + .lookup_tbl = (_tbl), \ 260 + .lookup_tbl_len = ARRAY_SIZE(_tbl), \ 261 + } 262 + 263 + #define AD74115_FW_PROP_BOOL(_name, _reg, _mask) \ 264 + { \ 265 + .name = (_name), \ 266 + .is_boolean = true, \ 267 + .reg = (_reg), \ 268 + .mask = (_mask), \ 269 + } 270 + 271 + #define AD74115_FW_PROP_BOOL_NEG(_name, _reg, _mask) \ 272 + { \ 273 + .name = (_name), \ 274 + .is_boolean = true, \ 275 + .negate = true, \ 276 + .reg = (_reg), \ 277 + .mask = (_mask), \ 278 + } 279 + 280 + static const int ad74115_dac_rate_tbl[] = { 281 + 0, 282 + 4 * 8, 283 + 4 * 15, 284 + 4 * 61, 285 + 4 * 222, 286 + 64 * 8, 287 + 64 * 15, 288 + 64 * 61, 289 + 64 * 222, 290 + 150 * 8, 291 + 150 * 15, 292 + 150 * 61, 293 + 150 * 222, 294 + 240 * 8, 295 + 240 * 15, 296 + 240 * 61, 297 + 240 * 222, 298 + }; 299 + 300 + static const unsigned int ad74115_dac_rate_step_tbl[][3] = { 301 + { AD74115_SLEW_MODE_DISABLED }, 302 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_0_8_PERCENT, AD74115_SLEW_RATE_4KHZ }, 303 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_1_5_PERCENT, AD74115_SLEW_RATE_4KHZ }, 304 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_6_1_PERCENT, AD74115_SLEW_RATE_4KHZ }, 305 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_22_2_PERCENT, AD74115_SLEW_RATE_4KHZ }, 306 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_0_8_PERCENT, AD74115_SLEW_RATE_64KHZ }, 307 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_1_5_PERCENT, AD74115_SLEW_RATE_64KHZ }, 308 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_6_1_PERCENT, AD74115_SLEW_RATE_64KHZ }, 309 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_22_2_PERCENT, AD74115_SLEW_RATE_64KHZ }, 310 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_0_8_PERCENT, AD74115_SLEW_RATE_150KHZ }, 311 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_1_5_PERCENT, AD74115_SLEW_RATE_150KHZ }, 312 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_6_1_PERCENT, AD74115_SLEW_RATE_150KHZ }, 313 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_22_2_PERCENT, AD74115_SLEW_RATE_150KHZ }, 314 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_0_8_PERCENT, AD74115_SLEW_RATE_240KHZ }, 315 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_1_5_PERCENT, AD74115_SLEW_RATE_240KHZ }, 316 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_6_1_PERCENT, AD74115_SLEW_RATE_240KHZ }, 317 + { AD74115_SLEW_MODE_LINEAR, AD74115_SLEW_STEP_22_2_PERCENT, AD74115_SLEW_RATE_240KHZ }, 318 + }; 319 + 320 + static const unsigned int ad74115_rtd_excitation_current_ua_tbl[] = { 321 + 250, 500, 750, 1000 322 + }; 323 + 324 + static const unsigned int ad74115_burnout_current_na_tbl[] = { 325 + 0, 50, 0, 500, 1000, 0, 10000, 0 326 + }; 327 + 328 + static const unsigned int ad74115_viout_burnout_current_na_tbl[] = { 329 + 0, 0, 0, 0, 1000, 0, 10000, 0 330 + }; 331 + 332 + static const unsigned int ad74115_gpio_mode_tbl[] = { 333 + 0, 0, 0, 1, 2, 3, 4, 5 334 + }; 335 + 336 + static const unsigned int ad74115_adc_conv_rate_tbl[] = { 337 + 10, 20, 1200, 4800, 9600 338 + }; 339 + 340 + static const unsigned int ad74115_debounce_tbl[] = { 341 + 0, 13, 18, 24, 32, 42, 56, 75, 342 + 100, 130, 180, 240, 320, 420, 560, 750, 343 + 1000, 1300, 1800, 2400, 3200, 4200, 5600, 7500, 344 + 10000, 13000, 18000, 24000, 32000, 42000, 56000, 75000, 345 + }; 346 + 347 + static const unsigned int ad74115_adc_ch_data_regs_tbl[] = { 348 + [AD74115_ADC_CH_CONV1] = 0x44, 349 + [AD74115_ADC_CH_CONV2] = 0x46, 350 + }; 351 + 352 + static const unsigned int ad74115_adc_ch_en_bit_tbl[] = { 353 + [AD74115_ADC_CH_CONV1] = BIT(0), 354 + [AD74115_ADC_CH_CONV2] = BIT(1), 355 + }; 356 + 357 + static const bool ad74115_adc_bipolar_tbl[AD74115_ADC_RANGE_NUM] = { 358 + [AD74115_ADC_RANGE_12V_BIPOLAR] = true, 359 + [AD74115_ADC_RANGE_2_5V_BIPOLAR] = true, 360 + [AD74115_ADC_RANGE_104MV_BIPOLAR] = true, 361 + }; 362 + 363 + static const unsigned int ad74115_adc_conv_mul_tbl[AD74115_ADC_RANGE_NUM] = { 364 + [AD74115_ADC_RANGE_12V] = 12000, 365 + [AD74115_ADC_RANGE_12V_BIPOLAR] = 24000, 366 + [AD74115_ADC_RANGE_2_5V_BIPOLAR] = 5000, 367 + [AD74115_ADC_RANGE_2_5V_NEG] = 2500, 368 + [AD74115_ADC_RANGE_2_5V] = 2500, 369 + [AD74115_ADC_RANGE_0_625V] = 625, 370 + [AD74115_ADC_RANGE_104MV_BIPOLAR] = 208, 371 + [AD74115_ADC_RANGE_12V_OTHER] = 12000, 372 + }; 373 + 374 + static const unsigned int ad74115_adc_gain_tbl[AD74115_ADC_RANGE_NUM][2] = { 375 + [AD74115_ADC_RANGE_12V] = { 5, 24 }, 376 + [AD74115_ADC_RANGE_12V_BIPOLAR] = { 5, 24 }, 377 + [AD74115_ADC_RANGE_2_5V_BIPOLAR] = { 1, 1 }, 378 + [AD74115_ADC_RANGE_2_5V_NEG] = { 1, 1 }, 379 + [AD74115_ADC_RANGE_2_5V] = { 1, 1 }, 380 + [AD74115_ADC_RANGE_0_625V] = { 4, 1 }, 381 + [AD74115_ADC_RANGE_104MV_BIPOLAR] = { 24, 1 }, 382 + [AD74115_ADC_RANGE_12V_OTHER] = { 5, 24 }, 383 + }; 384 + 385 + static const int ad74115_adc_range_tbl[AD74115_ADC_RANGE_NUM][2] = { 386 + [AD74115_ADC_RANGE_12V] = { 0, 12000000 }, 387 + [AD74115_ADC_RANGE_12V_BIPOLAR] = { -12000000, 12000000 }, 388 + [AD74115_ADC_RANGE_2_5V_BIPOLAR] = { -2500000, 2500000 }, 389 + [AD74115_ADC_RANGE_2_5V_NEG] = { -2500000, 0 }, 390 + [AD74115_ADC_RANGE_2_5V] = { 0, 2500000 }, 391 + [AD74115_ADC_RANGE_0_625V] = { 0, 625000 }, 392 + [AD74115_ADC_RANGE_104MV_BIPOLAR] = { -104000, 104000 }, 393 + [AD74115_ADC_RANGE_12V_OTHER] = { 0, 12000000 }, 394 + }; 395 + 396 + static int _ad74115_find_tbl_index(const unsigned int *tbl, unsigned int tbl_len, 397 + unsigned int val, unsigned int *index) 398 + { 399 + unsigned int i; 400 + 401 + for (i = 0; i < tbl_len; i++) 402 + if (val == tbl[i]) { 403 + *index = i; 404 + return 0; 405 + } 406 + 407 + return -EINVAL; 408 + } 409 + 410 + #define ad74115_find_tbl_index(tbl, val, index) \ 411 + _ad74115_find_tbl_index(tbl, ARRAY_SIZE(tbl), val, index) 412 + 413 + static int ad74115_crc(u8 *buf) 414 + { 415 + return crc8(ad74115_crc8_table, buf, 3, 0); 416 + } 417 + 418 + static void ad74115_format_reg_write(u8 reg, u16 val, u8 *buf) 419 + { 420 + buf[0] = reg; 421 + put_unaligned_be16(val, &buf[1]); 422 + buf[3] = ad74115_crc(buf); 423 + } 424 + 425 + static int ad74115_reg_write(void *context, unsigned int reg, unsigned int val) 426 + { 427 + struct ad74115_state *st = context; 428 + 429 + ad74115_format_reg_write(reg, val, st->reg_tx_buf); 430 + 431 + return spi_write(st->spi, st->reg_tx_buf, AD74115_FRAME_SIZE); 432 + } 433 + 434 + static int ad74115_crc_check(struct ad74115_state *st, u8 *buf) 435 + { 436 + struct device *dev = &st->spi->dev; 437 + u8 expected_crc = ad74115_crc(buf); 438 + 439 + if (buf[3] != expected_crc) { 440 + dev_err(dev, "Bad CRC %02x for %02x%02x%02x, expected %02x\n", 441 + buf[3], buf[0], buf[1], buf[2], expected_crc); 442 + return -EINVAL; 443 + } 444 + 445 + return 0; 446 + } 447 + 448 + static int ad74115_reg_read(void *context, unsigned int reg, unsigned int *val) 449 + { 450 + struct ad74115_state *st = context; 451 + struct spi_transfer reg_read_xfer[] = { 452 + { 453 + .tx_buf = st->reg_tx_buf, 454 + .len = sizeof(st->reg_tx_buf), 455 + .cs_change = 1, 456 + }, 457 + { 458 + .rx_buf = st->reg_rx_buf, 459 + .len = sizeof(st->reg_rx_buf), 460 + }, 461 + }; 462 + int ret; 463 + 464 + ad74115_format_reg_write(AD74115_READ_SELECT_REG, reg, st->reg_tx_buf); 465 + 466 + ret = spi_sync_transfer(st->spi, reg_read_xfer, ARRAY_SIZE(reg_read_xfer)); 467 + if (ret) 468 + return ret; 469 + 470 + ret = ad74115_crc_check(st, st->reg_rx_buf); 471 + if (ret) 472 + return ret; 473 + 474 + *val = get_unaligned_be16(&st->reg_rx_buf[1]); 475 + 476 + return 0; 477 + } 478 + 479 + static const struct regmap_config ad74115_regmap_config = { 480 + .reg_bits = 8, 481 + .val_bits = 16, 482 + .reg_read = ad74115_reg_read, 483 + .reg_write = ad74115_reg_write, 484 + }; 485 + 486 + static int ad74115_gpio_config_set(struct ad74115_state *st, unsigned int offset, 487 + enum ad74115_gpio_config cfg) 488 + { 489 + return regmap_update_bits(st->regmap, AD74115_GPIO_CONFIG_X_REG(offset), 490 + AD74115_GPIO_CONFIG_SELECT_MASK, 491 + FIELD_PREP(AD74115_GPIO_CONFIG_SELECT_MASK, cfg)); 492 + } 493 + 494 + static int ad74115_gpio_init_valid_mask(struct gpio_chip *gc, 495 + unsigned long *valid_mask, 496 + unsigned int ngpios) 497 + { 498 + struct ad74115_state *st = gpiochip_get_data(gc); 499 + 500 + *valid_mask = st->gpio_valid_mask; 501 + 502 + return 0; 503 + } 504 + 505 + static int ad74115_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) 506 + { 507 + struct ad74115_state *st = gpiochip_get_data(gc); 508 + unsigned int val; 509 + int ret; 510 + 511 + ret = regmap_read(st->regmap, AD74115_GPIO_CONFIG_X_REG(offset), &val); 512 + if (ret) 513 + return ret; 514 + 515 + return FIELD_GET(AD74115_GPIO_CONFIG_SELECT_MASK, val) == AD74115_GPIO_CONFIG_INPUT; 516 + } 517 + 518 + static int ad74115_gpio_direction_input(struct gpio_chip *gc, unsigned int offset) 519 + { 520 + struct ad74115_state *st = gpiochip_get_data(gc); 521 + 522 + return ad74115_gpio_config_set(st, offset, AD74115_GPIO_CONFIG_INPUT); 523 + } 524 + 525 + static int ad74115_gpio_direction_output(struct gpio_chip *gc, unsigned int offset, 526 + int value) 527 + { 528 + struct ad74115_state *st = gpiochip_get_data(gc); 529 + 530 + return ad74115_gpio_config_set(st, offset, AD74115_GPIO_CONFIG_OUTPUT_BUFFERED); 531 + } 532 + 533 + static int ad74115_gpio_get(struct gpio_chip *gc, unsigned int offset) 534 + { 535 + struct ad74115_state *st = gpiochip_get_data(gc); 536 + unsigned int val; 537 + int ret; 538 + 539 + ret = regmap_read(st->regmap, AD74115_GPIO_CONFIG_X_REG(offset), &val); 540 + if (ret) 541 + return ret; 542 + 543 + return FIELD_GET(AD74115_GPIO_CONFIG_GPI_DATA, val); 544 + } 545 + 546 + static void ad74115_gpio_set(struct gpio_chip *gc, unsigned int offset, int value) 547 + { 548 + struct ad74115_state *st = gpiochip_get_data(gc); 549 + struct device *dev = &st->spi->dev; 550 + int ret; 551 + 552 + ret = regmap_update_bits(st->regmap, AD74115_GPIO_CONFIG_X_REG(offset), 553 + AD74115_GPIO_CONFIG_GPO_DATA, 554 + FIELD_PREP(AD74115_GPIO_CONFIG_GPO_DATA, value)); 555 + if (ret) 556 + dev_err(dev, "Failed to set GPIO %u output value, err: %d\n", 557 + offset, ret); 558 + } 559 + 560 + static int ad74115_set_comp_debounce(struct ad74115_state *st, unsigned int val) 561 + { 562 + unsigned int len = ARRAY_SIZE(ad74115_debounce_tbl); 563 + unsigned int i; 564 + 565 + for (i = 0; i < len; i++) 566 + if (val <= ad74115_debounce_tbl[i]) 567 + break; 568 + 569 + if (i == len) 570 + i = len - 1; 571 + 572 + return regmap_update_bits(st->regmap, AD74115_DIN_CONFIG1_REG, 573 + AD74115_DIN_DEBOUNCE_MASK, 574 + FIELD_PREP(AD74115_DIN_DEBOUNCE_MASK, val)); 575 + } 576 + 577 + static int ad74115_comp_gpio_get_direction(struct gpio_chip *chip, 578 + unsigned int offset) 579 + { 580 + return GPIO_LINE_DIRECTION_IN; 581 + } 582 + 583 + static int ad74115_comp_gpio_set_config(struct gpio_chip *chip, 584 + unsigned int offset, 585 + unsigned long config) 586 + { 587 + struct ad74115_state *st = gpiochip_get_data(chip); 588 + u32 param = pinconf_to_config_param(config); 589 + u32 arg = pinconf_to_config_argument(config); 590 + 591 + switch (param) { 592 + case PIN_CONFIG_INPUT_DEBOUNCE: 593 + return ad74115_set_comp_debounce(st, arg); 594 + default: 595 + return -ENOTSUPP; 596 + } 597 + } 598 + 599 + static int ad74115_comp_gpio_get(struct gpio_chip *chip, unsigned int offset) 600 + { 601 + struct ad74115_state *st = gpiochip_get_data(chip); 602 + unsigned int val; 603 + int ret; 604 + 605 + ret = regmap_read(st->regmap, AD74115_DIN_COMP_OUT_REG, &val); 606 + if (ret) 607 + return ret; 608 + 609 + return !!val; 610 + } 611 + 612 + static irqreturn_t ad74115_trigger_handler(int irq, void *p) 613 + { 614 + struct iio_poll_func *pf = p; 615 + struct iio_dev *indio_dev = pf->indio_dev; 616 + struct ad74115_state *st = iio_priv(indio_dev); 617 + int ret; 618 + 619 + ret = spi_sync(st->spi, &st->adc_samples_msg); 620 + if (ret) 621 + goto out; 622 + 623 + iio_push_to_buffers(indio_dev, st->adc_samples_rx_buf); 624 + 625 + out: 626 + iio_trigger_notify_done(indio_dev->trig); 627 + 628 + return IRQ_HANDLED; 629 + } 630 + 631 + static irqreturn_t ad74115_adc_data_interrupt(int irq, void *data) 632 + { 633 + struct iio_dev *indio_dev = data; 634 + struct ad74115_state *st = iio_priv(indio_dev); 635 + 636 + if (iio_buffer_enabled(indio_dev)) 637 + iio_trigger_poll(st->trig); 638 + else 639 + complete(&st->adc_data_completion); 640 + 641 + return IRQ_HANDLED; 642 + } 643 + 644 + static int ad74115_set_adc_ch_en(struct ad74115_state *st, 645 + enum ad74115_adc_ch channel, bool status) 646 + { 647 + unsigned int mask = ad74115_adc_ch_en_bit_tbl[channel]; 648 + 649 + return regmap_update_bits(st->regmap, AD74115_ADC_CONV_CTRL_REG, mask, 650 + status ? mask : 0); 651 + } 652 + 653 + static int ad74115_set_adc_conv_seq(struct ad74115_state *st, 654 + enum ad74115_adc_conv_seq conv_seq) 655 + { 656 + return regmap_update_bits(st->regmap, AD74115_ADC_CONV_CTRL_REG, 657 + AD74115_ADC_CONV_SEQ_MASK, 658 + FIELD_PREP(AD74115_ADC_CONV_SEQ_MASK, conv_seq)); 659 + } 660 + 661 + static int ad74115_update_scan_mode(struct iio_dev *indio_dev, 662 + const unsigned long *active_scan_mask) 663 + { 664 + struct ad74115_state *st = iio_priv(indio_dev); 665 + struct spi_transfer *xfer = st->adc_samples_xfer; 666 + u8 *rx_buf = st->adc_samples_rx_buf; 667 + u8 *tx_buf = st->adc_samples_tx_buf; 668 + unsigned int i; 669 + int ret = 0; 670 + 671 + mutex_lock(&st->lock); 672 + 673 + spi_message_init(&st->adc_samples_msg); 674 + 675 + for_each_clear_bit(i, active_scan_mask, AD74115_ADC_CH_NUM) { 676 + ret = ad74115_set_adc_ch_en(st, i, false); 677 + if (ret) 678 + goto out; 679 + } 680 + 681 + /* 682 + * The read select register is used to select which register's value 683 + * will be sent by the slave on the next SPI frame. 684 + * 685 + * Create an SPI message that, on each step, writes to the read select 686 + * register to select the ADC result of the next enabled channel, and 687 + * reads the ADC result of the previous enabled channel. 688 + * 689 + * Example: 690 + * W: [WCH1] [WCH2] [WCH2] [WCH3] [ ] 691 + * R: [ ] [RCH1] [RCH2] [RCH3] [RCH4] 692 + */ 693 + for_each_set_bit(i, active_scan_mask, AD74115_ADC_CH_NUM) { 694 + ret = ad74115_set_adc_ch_en(st, i, true); 695 + if (ret) 696 + goto out; 697 + 698 + if (xfer == st->adc_samples_xfer) 699 + xfer->rx_buf = NULL; 700 + else 701 + xfer->rx_buf = rx_buf; 702 + 703 + xfer->tx_buf = tx_buf; 704 + xfer->len = AD74115_FRAME_SIZE; 705 + xfer->cs_change = 1; 706 + 707 + ad74115_format_reg_write(AD74115_READ_SELECT_REG, 708 + ad74115_adc_ch_data_regs_tbl[i], tx_buf); 709 + 710 + spi_message_add_tail(xfer, &st->adc_samples_msg); 711 + 712 + tx_buf += AD74115_FRAME_SIZE; 713 + if (xfer != st->adc_samples_xfer) 714 + rx_buf += AD74115_FRAME_SIZE; 715 + xfer++; 716 + } 717 + 718 + xfer->rx_buf = rx_buf; 719 + xfer->tx_buf = NULL; 720 + xfer->len = AD74115_FRAME_SIZE; 721 + xfer->cs_change = 0; 722 + 723 + spi_message_add_tail(xfer, &st->adc_samples_msg); 724 + 725 + out: 726 + mutex_unlock(&st->lock); 727 + 728 + return ret; 729 + } 730 + 731 + static int ad74115_buffer_postenable(struct iio_dev *indio_dev) 732 + { 733 + struct ad74115_state *st = iio_priv(indio_dev); 734 + 735 + return ad74115_set_adc_conv_seq(st, AD74115_ADC_CONV_SEQ_CONTINUOUS); 736 + } 737 + 738 + static int ad74115_buffer_predisable(struct iio_dev *indio_dev) 739 + { 740 + struct ad74115_state *st = iio_priv(indio_dev); 741 + unsigned int i; 742 + int ret; 743 + 744 + mutex_lock(&st->lock); 745 + 746 + ret = ad74115_set_adc_conv_seq(st, AD74115_ADC_CONV_SEQ_STANDBY); 747 + if (ret) 748 + goto out; 749 + 750 + /* 751 + * update_scan_mode() is not called in the disable path, disable all 752 + * channels here. 753 + */ 754 + for (i = 0; i < AD74115_ADC_CH_NUM; i++) { 755 + ret = ad74115_set_adc_ch_en(st, i, false); 756 + if (ret) 757 + goto out; 758 + } 759 + 760 + out: 761 + mutex_unlock(&st->lock); 762 + 763 + return ret; 764 + } 765 + 766 + static const struct iio_buffer_setup_ops ad74115_buffer_ops = { 767 + .postenable = &ad74115_buffer_postenable, 768 + .predisable = &ad74115_buffer_predisable, 769 + }; 770 + 771 + static const struct iio_trigger_ops ad74115_trigger_ops = { 772 + .validate_device = iio_trigger_validate_own_device, 773 + }; 774 + 775 + static int ad74115_get_adc_rate(struct ad74115_state *st, 776 + enum ad74115_adc_ch channel, int *val) 777 + { 778 + unsigned int i; 779 + int ret; 780 + 781 + ret = regmap_read(st->regmap, AD74115_ADC_CONFIG_REG, &i); 782 + if (ret) 783 + return ret; 784 + 785 + if (channel == AD74115_ADC_CH_CONV1) 786 + i = FIELD_GET(AD74115_ADC_CONFIG_CONV1_RATE_MASK, i); 787 + else 788 + i = FIELD_GET(AD74115_ADC_CONFIG_CONV2_RATE_MASK, i); 789 + 790 + *val = ad74115_adc_conv_rate_tbl[i]; 791 + 792 + return IIO_VAL_INT; 793 + } 794 + 795 + static int _ad74115_get_adc_code(struct ad74115_state *st, 796 + enum ad74115_adc_ch channel, int *val) 797 + { 798 + unsigned int uval; 799 + int ret; 800 + 801 + reinit_completion(&st->adc_data_completion); 802 + 803 + ret = ad74115_set_adc_ch_en(st, channel, true); 804 + if (ret) 805 + return ret; 806 + 807 + ret = ad74115_set_adc_conv_seq(st, AD74115_ADC_CONV_SEQ_SINGLE); 808 + if (ret) 809 + return ret; 810 + 811 + if (st->irq) { 812 + ret = wait_for_completion_timeout(&st->adc_data_completion, 813 + msecs_to_jiffies(1000)); 814 + if (!ret) 815 + return -ETIMEDOUT; 816 + } else { 817 + unsigned int regval, wait_time; 818 + int rate; 819 + 820 + ret = ad74115_get_adc_rate(st, channel, &rate); 821 + if (ret < 0) 822 + return ret; 823 + 824 + wait_time = DIV_ROUND_CLOSEST(AD74115_CONV_TIME_US, rate); 825 + 826 + ret = regmap_read_poll_timeout(st->regmap, AD74115_LIVE_STATUS_REG, 827 + regval, regval & AD74115_ADC_DATA_RDY_MASK, 828 + wait_time, 5 * wait_time); 829 + if (ret) 830 + return ret; 831 + 832 + /* 833 + * The ADC_DATA_RDY bit is W1C. 834 + * See datasheet page 98, Table 62. Bit Descriptions for 835 + * LIVE_STATUS. 836 + * Although the datasheet mentions that the bit will auto-clear 837 + * when writing to the ADC_CONV_CTRL register, this does not 838 + * seem to happen. 839 + */ 840 + ret = regmap_write_bits(st->regmap, AD74115_LIVE_STATUS_REG, 841 + AD74115_ADC_DATA_RDY_MASK, 842 + FIELD_PREP(AD74115_ADC_DATA_RDY_MASK, 1)); 843 + if (ret) 844 + return ret; 845 + } 846 + 847 + ret = regmap_read(st->regmap, ad74115_adc_ch_data_regs_tbl[channel], &uval); 848 + if (ret) 849 + return ret; 850 + 851 + ret = ad74115_set_adc_conv_seq(st, AD74115_ADC_CONV_SEQ_STANDBY); 852 + if (ret) 853 + return ret; 854 + 855 + ret = ad74115_set_adc_ch_en(st, channel, false); 856 + if (ret) 857 + return ret; 858 + 859 + *val = uval; 860 + 861 + return IIO_VAL_INT; 862 + } 863 + 864 + static int ad74115_get_adc_code(struct iio_dev *indio_dev, 865 + enum ad74115_adc_ch channel, int *val) 866 + { 867 + struct ad74115_state *st = iio_priv(indio_dev); 868 + int ret; 869 + 870 + ret = iio_device_claim_direct_mode(indio_dev); 871 + if (ret) 872 + return ret; 873 + 874 + mutex_lock(&st->lock); 875 + ret = _ad74115_get_adc_code(st, channel, val); 876 + mutex_unlock(&st->lock); 877 + 878 + iio_device_release_direct_mode(indio_dev); 879 + 880 + return ret; 881 + } 882 + 883 + static int ad74115_adc_code_to_resistance(int code, int *val, int *val2) 884 + { 885 + if (code == AD74115_ADC_CODE_MAX) 886 + code--; 887 + 888 + *val = code * AD74115_REF_RESISTOR_OHMS; 889 + *val2 = AD74115_ADC_CODE_MAX - code; 890 + 891 + return IIO_VAL_FRACTIONAL; 892 + } 893 + 894 + static int ad74115_set_dac_code(struct ad74115_state *st, 895 + enum ad74115_dac_ch channel, int val) 896 + { 897 + if (val < 0) 898 + return -EINVAL; 899 + 900 + if (channel == AD74115_DAC_CH_COMPARATOR) { 901 + if (val > AD74115_COMP_THRESH_MAX) 902 + return -EINVAL; 903 + 904 + return regmap_update_bits(st->regmap, AD74115_DIN_CONFIG2_REG, 905 + AD74115_COMP_THRESH_MASK, 906 + FIELD_PREP(AD74115_COMP_THRESH_MASK, val)); 907 + } 908 + 909 + if (val > AD74115_DAC_CODE_MAX) 910 + return -EINVAL; 911 + 912 + return regmap_write(st->regmap, AD74115_DAC_CODE_REG, val); 913 + } 914 + 915 + static int ad74115_get_dac_code(struct ad74115_state *st, 916 + enum ad74115_dac_ch channel, int *val) 917 + { 918 + unsigned int uval; 919 + int ret; 920 + 921 + if (channel == AD74115_DAC_CH_COMPARATOR) 922 + return -EINVAL; 923 + 924 + ret = regmap_read(st->regmap, AD74115_DAC_ACTIVE_REG, &uval); 925 + if (ret) 926 + return ret; 927 + 928 + *val = uval; 929 + 930 + return IIO_VAL_INT; 931 + } 932 + 933 + static int ad74115_set_adc_rate(struct ad74115_state *st, 934 + enum ad74115_adc_ch channel, int val) 935 + { 936 + unsigned int i; 937 + int ret; 938 + 939 + ret = ad74115_find_tbl_index(ad74115_adc_conv_rate_tbl, val, &i); 940 + if (ret) 941 + return ret; 942 + 943 + if (channel == AD74115_ADC_CH_CONV1) 944 + return regmap_update_bits(st->regmap, AD74115_ADC_CONFIG_REG, 945 + AD74115_ADC_CONFIG_CONV1_RATE_MASK, 946 + FIELD_PREP(AD74115_ADC_CONFIG_CONV1_RATE_MASK, i)); 947 + 948 + return regmap_update_bits(st->regmap, AD74115_ADC_CONFIG_REG, 949 + AD74115_ADC_CONFIG_CONV2_RATE_MASK, 950 + FIELD_PREP(AD74115_ADC_CONFIG_CONV2_RATE_MASK, i)); 951 + } 952 + 953 + static int ad74115_get_dac_rate(struct ad74115_state *st, int *val) 954 + { 955 + unsigned int i, en_val, step_val, rate_val, tmp; 956 + int ret; 957 + 958 + ret = regmap_read(st->regmap, AD74115_OUTPUT_CONFIG_REG, &tmp); 959 + if (ret) 960 + return ret; 961 + 962 + en_val = FIELD_GET(AD74115_OUTPUT_SLEW_EN_MASK, tmp); 963 + step_val = FIELD_GET(AD74115_OUTPUT_SLEW_LIN_STEP_MASK, tmp); 964 + rate_val = FIELD_GET(AD74115_OUTPUT_SLEW_LIN_RATE_MASK, tmp); 965 + 966 + for (i = 0; i < ARRAY_SIZE(ad74115_dac_rate_step_tbl); i++) 967 + if (en_val == ad74115_dac_rate_step_tbl[i][0] && 968 + step_val == ad74115_dac_rate_step_tbl[i][1] && 969 + rate_val == ad74115_dac_rate_step_tbl[i][2]) 970 + break; 971 + 972 + if (i == ARRAY_SIZE(ad74115_dac_rate_step_tbl)) 973 + return -EINVAL; 974 + 975 + *val = ad74115_dac_rate_tbl[i]; 976 + 977 + return IIO_VAL_INT; 978 + } 979 + 980 + static int ad74115_set_dac_rate(struct ad74115_state *st, int val) 981 + { 982 + unsigned int i, en_val, step_val, rate_val, mask, tmp; 983 + int ret; 984 + 985 + ret = ad74115_find_tbl_index(ad74115_dac_rate_tbl, val, &i); 986 + if (ret) 987 + return ret; 988 + 989 + en_val = ad74115_dac_rate_step_tbl[i][0]; 990 + step_val = ad74115_dac_rate_step_tbl[i][1]; 991 + rate_val = ad74115_dac_rate_step_tbl[i][2]; 992 + 993 + mask = AD74115_OUTPUT_SLEW_EN_MASK; 994 + mask |= AD74115_OUTPUT_SLEW_LIN_STEP_MASK; 995 + mask |= AD74115_OUTPUT_SLEW_LIN_RATE_MASK; 996 + 997 + tmp = FIELD_PREP(AD74115_OUTPUT_SLEW_EN_MASK, en_val); 998 + tmp |= FIELD_PREP(AD74115_OUTPUT_SLEW_LIN_STEP_MASK, step_val); 999 + tmp |= FIELD_PREP(AD74115_OUTPUT_SLEW_LIN_RATE_MASK, rate_val); 1000 + 1001 + return regmap_update_bits(st->regmap, AD74115_OUTPUT_CONFIG_REG, mask, tmp); 1002 + } 1003 + 1004 + static int ad74115_get_dac_scale(struct ad74115_state *st, 1005 + struct iio_chan_spec const *chan, 1006 + int *val, int *val2) 1007 + { 1008 + if (chan->channel == AD74115_DAC_CH_MAIN) { 1009 + if (chan->type == IIO_VOLTAGE) { 1010 + *val = AD74115_DAC_VOLTAGE_MAX; 1011 + 1012 + if (st->dac_bipolar) 1013 + *val *= 2; 1014 + 1015 + } else { 1016 + *val = AD74115_DAC_CURRENT_MAX; 1017 + } 1018 + 1019 + *val2 = AD74115_DAC_CODE_MAX; 1020 + } else { 1021 + if (st->din_threshold_mode == AD74115_DIN_THRESHOLD_MODE_AVDD) { 1022 + *val = 196 * st->avdd_mv; 1023 + *val2 = 10 * AD74115_COMP_THRESH_MAX; 1024 + } else { 1025 + *val = 49000; 1026 + *val2 = AD74115_COMP_THRESH_MAX; 1027 + } 1028 + } 1029 + 1030 + return IIO_VAL_FRACTIONAL; 1031 + } 1032 + 1033 + static int ad74115_get_dac_offset(struct ad74115_state *st, 1034 + struct iio_chan_spec const *chan, int *val) 1035 + { 1036 + if (chan->channel == AD74115_DAC_CH_MAIN) { 1037 + if (chan->type == IIO_VOLTAGE && st->dac_bipolar) 1038 + *val = -AD74115_DAC_CODE_HALF; 1039 + else 1040 + *val = 0; 1041 + } else { 1042 + if (st->din_threshold_mode == AD74115_DIN_THRESHOLD_MODE_AVDD) 1043 + *val = -48; 1044 + else 1045 + *val = -38; 1046 + } 1047 + 1048 + return IIO_VAL_INT; 1049 + } 1050 + 1051 + static int ad74115_get_adc_range(struct ad74115_state *st, 1052 + enum ad74115_adc_ch channel, unsigned int *val) 1053 + { 1054 + int ret; 1055 + 1056 + ret = regmap_read(st->regmap, AD74115_ADC_CONFIG_REG, val); 1057 + if (ret) 1058 + return ret; 1059 + 1060 + if (channel == AD74115_ADC_CH_CONV1) 1061 + *val = FIELD_GET(AD74115_ADC_CONFIG_CONV1_RANGE_MASK, *val); 1062 + else 1063 + *val = FIELD_GET(AD74115_ADC_CONFIG_CONV2_RANGE_MASK, *val); 1064 + 1065 + return 0; 1066 + } 1067 + 1068 + static int ad74115_get_adc_resistance_scale(struct ad74115_state *st, 1069 + unsigned int range, 1070 + int *val, int *val2) 1071 + { 1072 + *val = ad74115_adc_gain_tbl[range][1] * AD74115_REF_RESISTOR_OHMS; 1073 + *val2 = ad74115_adc_gain_tbl[range][0]; 1074 + 1075 + if (ad74115_adc_bipolar_tbl[range]) 1076 + *val2 *= AD74115_ADC_CODE_HALF; 1077 + else 1078 + *val2 *= AD74115_ADC_CODE_MAX; 1079 + 1080 + return IIO_VAL_FRACTIONAL; 1081 + } 1082 + 1083 + static int ad74115_get_adc_scale(struct ad74115_state *st, 1084 + struct iio_chan_spec const *chan, 1085 + int *val, int *val2) 1086 + { 1087 + unsigned int range; 1088 + int ret; 1089 + 1090 + ret = ad74115_get_adc_range(st, chan->channel, &range); 1091 + if (ret) 1092 + return ret; 1093 + 1094 + if (chan->type == IIO_RESISTANCE) 1095 + return ad74115_get_adc_resistance_scale(st, range, val, val2); 1096 + 1097 + *val = ad74115_adc_conv_mul_tbl[range]; 1098 + *val2 = AD74115_ADC_CODE_MAX; 1099 + 1100 + if (chan->type == IIO_CURRENT) 1101 + *val2 *= AD74115_SENSE_RESISTOR_OHMS; 1102 + 1103 + return IIO_VAL_FRACTIONAL; 1104 + } 1105 + 1106 + static int ad74115_get_adc_resistance_offset(struct ad74115_state *st, 1107 + unsigned int range, 1108 + int *val, int *val2) 1109 + { 1110 + unsigned int d = 10 * AD74115_REF_RESISTOR_OHMS 1111 + * ad74115_adc_gain_tbl[range][1]; 1112 + 1113 + *val = 5; 1114 + 1115 + if (ad74115_adc_bipolar_tbl[range]) 1116 + *val -= AD74115_ADC_CODE_HALF; 1117 + 1118 + *val *= d; 1119 + 1120 + if (!st->rtd_mode_4_wire) { 1121 + /* Add 0.2 Ohm to the final result for 3-wire RTD. */ 1122 + unsigned int v = 2 * ad74115_adc_gain_tbl[range][0]; 1123 + 1124 + if (ad74115_adc_bipolar_tbl[range]) 1125 + v *= AD74115_ADC_CODE_HALF; 1126 + else 1127 + v *= AD74115_ADC_CODE_MAX; 1128 + 1129 + *val += v; 1130 + } 1131 + 1132 + *val2 = d; 1133 + 1134 + return IIO_VAL_FRACTIONAL; 1135 + } 1136 + 1137 + static int ad74115_get_adc_offset(struct ad74115_state *st, 1138 + struct iio_chan_spec const *chan, 1139 + int *val, int *val2) 1140 + { 1141 + unsigned int range; 1142 + int ret; 1143 + 1144 + ret = ad74115_get_adc_range(st, chan->channel, &range); 1145 + if (ret) 1146 + return ret; 1147 + 1148 + if (chan->type == IIO_RESISTANCE) 1149 + return ad74115_get_adc_resistance_offset(st, range, val, val2); 1150 + 1151 + if (ad74115_adc_bipolar_tbl[range]) 1152 + *val = -AD74115_ADC_CODE_HALF; 1153 + else if (range == AD74115_ADC_RANGE_2_5V_NEG) 1154 + *val = -AD74115_ADC_CODE_MAX; 1155 + else 1156 + *val = 0; 1157 + 1158 + return IIO_VAL_INT; 1159 + } 1160 + 1161 + static int ad74115_read_raw(struct iio_dev *indio_dev, 1162 + struct iio_chan_spec const *chan, 1163 + int *val, int *val2, long info) 1164 + { 1165 + struct ad74115_state *st = iio_priv(indio_dev); 1166 + int ret; 1167 + 1168 + switch (info) { 1169 + case IIO_CHAN_INFO_RAW: 1170 + if (chan->output) 1171 + return ad74115_get_dac_code(st, chan->channel, val); 1172 + 1173 + return ad74115_get_adc_code(indio_dev, chan->channel, val); 1174 + case IIO_CHAN_INFO_PROCESSED: 1175 + ret = ad74115_get_adc_code(indio_dev, chan->channel, val); 1176 + if (ret) 1177 + return ret; 1178 + 1179 + return ad74115_adc_code_to_resistance(*val, val, val2); 1180 + case IIO_CHAN_INFO_SCALE: 1181 + if (chan->output) 1182 + return ad74115_get_dac_scale(st, chan, val, val2); 1183 + 1184 + return ad74115_get_adc_scale(st, chan, val, val2); 1185 + case IIO_CHAN_INFO_OFFSET: 1186 + if (chan->output) 1187 + return ad74115_get_dac_offset(st, chan, val); 1188 + 1189 + return ad74115_get_adc_offset(st, chan, val, val2); 1190 + case IIO_CHAN_INFO_SAMP_FREQ: 1191 + if (chan->output) 1192 + return ad74115_get_dac_rate(st, val); 1193 + 1194 + return ad74115_get_adc_rate(st, chan->channel, val); 1195 + default: 1196 + return -EINVAL; 1197 + } 1198 + } 1199 + 1200 + static int ad74115_write_raw(struct iio_dev *indio_dev, 1201 + struct iio_chan_spec const *chan, int val, int val2, 1202 + long info) 1203 + { 1204 + struct ad74115_state *st = iio_priv(indio_dev); 1205 + 1206 + switch (info) { 1207 + case IIO_CHAN_INFO_RAW: 1208 + if (!chan->output) 1209 + return -EINVAL; 1210 + 1211 + return ad74115_set_dac_code(st, chan->channel, val); 1212 + case IIO_CHAN_INFO_SAMP_FREQ: 1213 + if (chan->output) 1214 + return ad74115_set_dac_rate(st, val); 1215 + 1216 + return ad74115_set_adc_rate(st, chan->channel, val); 1217 + default: 1218 + return -EINVAL; 1219 + } 1220 + } 1221 + 1222 + static int ad74115_read_avail(struct iio_dev *indio_dev, 1223 + struct iio_chan_spec const *chan, 1224 + const int **vals, int *type, int *length, long info) 1225 + { 1226 + switch (info) { 1227 + case IIO_CHAN_INFO_SAMP_FREQ: 1228 + if (chan->output) { 1229 + *vals = ad74115_dac_rate_tbl; 1230 + *length = ARRAY_SIZE(ad74115_dac_rate_tbl); 1231 + } else { 1232 + *vals = ad74115_adc_conv_rate_tbl; 1233 + *length = ARRAY_SIZE(ad74115_adc_conv_rate_tbl); 1234 + } 1235 + 1236 + *type = IIO_VAL_INT; 1237 + 1238 + return IIO_AVAIL_LIST; 1239 + default: 1240 + return -EINVAL; 1241 + } 1242 + } 1243 + 1244 + static int ad74115_reg_access(struct iio_dev *indio_dev, unsigned int reg, 1245 + unsigned int writeval, unsigned int *readval) 1246 + { 1247 + struct ad74115_state *st = iio_priv(indio_dev); 1248 + 1249 + if (readval) 1250 + return regmap_read(st->regmap, reg, readval); 1251 + 1252 + return regmap_write(st->regmap, reg, writeval); 1253 + } 1254 + 1255 + static const struct iio_info ad74115_info = { 1256 + .read_raw = ad74115_read_raw, 1257 + .write_raw = ad74115_write_raw, 1258 + .read_avail = ad74115_read_avail, 1259 + .update_scan_mode = ad74115_update_scan_mode, 1260 + .debugfs_reg_access = ad74115_reg_access, 1261 + }; 1262 + 1263 + #define AD74115_DAC_CHANNEL(_type, index) \ 1264 + { \ 1265 + .type = (_type), \ 1266 + .channel = (index), \ 1267 + .indexed = 1, \ 1268 + .output = 1, \ 1269 + .scan_index = -1, \ 1270 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) \ 1271 + | BIT(IIO_CHAN_INFO_SCALE) \ 1272 + | BIT(IIO_CHAN_INFO_OFFSET), \ 1273 + } 1274 + 1275 + #define _AD74115_ADC_CHANNEL(_type, index, extra_mask_separate) \ 1276 + { \ 1277 + .type = (_type), \ 1278 + .channel = (index), \ 1279 + .indexed = 1, \ 1280 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) \ 1281 + | BIT(IIO_CHAN_INFO_SAMP_FREQ) \ 1282 + | (extra_mask_separate), \ 1283 + .info_mask_separate_available = \ 1284 + BIT(IIO_CHAN_INFO_SAMP_FREQ), \ 1285 + .scan_index = index, \ 1286 + .scan_type = { \ 1287 + .sign = 'u', \ 1288 + .realbits = 16, \ 1289 + .storagebits = 32, \ 1290 + .shift = 8, \ 1291 + .endianness = IIO_BE, \ 1292 + }, \ 1293 + } 1294 + 1295 + #define AD74115_ADC_CHANNEL(_type, index) \ 1296 + _AD74115_ADC_CHANNEL(_type, index, BIT(IIO_CHAN_INFO_SCALE) \ 1297 + | BIT(IIO_CHAN_INFO_OFFSET)) 1298 + 1299 + static struct iio_chan_spec ad74115_voltage_input_channels[] = { 1300 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV1), 1301 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1302 + }; 1303 + 1304 + static struct iio_chan_spec ad74115_voltage_output_channels[] = { 1305 + AD74115_DAC_CHANNEL(IIO_VOLTAGE, AD74115_DAC_CH_MAIN), 1306 + AD74115_ADC_CHANNEL(IIO_CURRENT, AD74115_ADC_CH_CONV1), 1307 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1308 + }; 1309 + 1310 + static struct iio_chan_spec ad74115_current_input_channels[] = { 1311 + AD74115_ADC_CHANNEL(IIO_CURRENT, AD74115_ADC_CH_CONV1), 1312 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1313 + }; 1314 + 1315 + static struct iio_chan_spec ad74115_current_output_channels[] = { 1316 + AD74115_DAC_CHANNEL(IIO_CURRENT, AD74115_DAC_CH_MAIN), 1317 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV1), 1318 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1319 + }; 1320 + 1321 + static struct iio_chan_spec ad74115_2_wire_resistance_input_channels[] = { 1322 + _AD74115_ADC_CHANNEL(IIO_RESISTANCE, AD74115_ADC_CH_CONV1, 1323 + BIT(IIO_CHAN_INFO_PROCESSED)), 1324 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1325 + }; 1326 + 1327 + static struct iio_chan_spec ad74115_3_4_wire_resistance_input_channels[] = { 1328 + AD74115_ADC_CHANNEL(IIO_RESISTANCE, AD74115_ADC_CH_CONV1), 1329 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1330 + }; 1331 + 1332 + static struct iio_chan_spec ad74115_digital_input_logic_channels[] = { 1333 + AD74115_DAC_CHANNEL(IIO_VOLTAGE, AD74115_DAC_CH_COMPARATOR), 1334 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV1), 1335 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1336 + }; 1337 + 1338 + static struct iio_chan_spec ad74115_digital_input_loop_channels[] = { 1339 + AD74115_DAC_CHANNEL(IIO_CURRENT, AD74115_DAC_CH_MAIN), 1340 + AD74115_DAC_CHANNEL(IIO_VOLTAGE, AD74115_DAC_CH_COMPARATOR), 1341 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV1), 1342 + AD74115_ADC_CHANNEL(IIO_VOLTAGE, AD74115_ADC_CH_CONV2), 1343 + }; 1344 + 1345 + #define _AD74115_CHANNELS(_channels) \ 1346 + { \ 1347 + .channels = _channels, \ 1348 + .num_channels = ARRAY_SIZE(_channels), \ 1349 + } 1350 + 1351 + #define AD74115_CHANNELS(name) \ 1352 + _AD74115_CHANNELS(ad74115_ ## name ## _channels) 1353 + 1354 + static const struct ad74115_channels ad74115_channels_map[AD74115_CH_FUNC_NUM] = { 1355 + [AD74115_CH_FUNC_HIGH_IMPEDANCE] = AD74115_CHANNELS(voltage_input), 1356 + [AD74115_CH_FUNC_VOLTAGE_INPUT] = AD74115_CHANNELS(voltage_input), 1357 + 1358 + [AD74115_CH_FUNC_VOLTAGE_OUTPUT] = AD74115_CHANNELS(voltage_output), 1359 + 1360 + [AD74115_CH_FUNC_CURRENT_INPUT_EXT_POWER] = AD74115_CHANNELS(current_input), 1361 + [AD74115_CH_FUNC_CURRENT_INPUT_LOOP_POWER] = AD74115_CHANNELS(current_input), 1362 + [AD74115_CH_FUNC_CURRENT_INPUT_EXT_POWER_HART] = AD74115_CHANNELS(current_input), 1363 + [AD74115_CH_FUNC_CURRENT_INPUT_LOOP_POWER_HART] = AD74115_CHANNELS(current_input), 1364 + 1365 + [AD74115_CH_FUNC_CURRENT_OUTPUT] = AD74115_CHANNELS(current_output), 1366 + [AD74115_CH_FUNC_CURRENT_OUTPUT_HART] = AD74115_CHANNELS(current_output), 1367 + 1368 + [AD74115_CH_FUNC_2_WIRE_RESISTANCE_INPUT] = AD74115_CHANNELS(2_wire_resistance_input), 1369 + [AD74115_CH_FUNC_3_4_WIRE_RESISTANCE_INPUT] = AD74115_CHANNELS(3_4_wire_resistance_input), 1370 + 1371 + [AD74115_CH_FUNC_DIGITAL_INPUT_LOGIC] = AD74115_CHANNELS(digital_input_logic), 1372 + 1373 + [AD74115_CH_FUNC_DIGITAL_INPUT_LOOP_POWER] = AD74115_CHANNELS(digital_input_loop), 1374 + }; 1375 + 1376 + #define AD74115_GPIO_MODE_FW_PROP(i) \ 1377 + { \ 1378 + .name = "adi,gpio" __stringify(i) "-mode", \ 1379 + .reg = AD74115_GPIO_CONFIG_X_REG(i), \ 1380 + .mask = AD74115_GPIO_CONFIG_SELECT_MASK, \ 1381 + .lookup_tbl = ad74115_gpio_mode_tbl, \ 1382 + .lookup_tbl_len = ARRAY_SIZE(ad74115_gpio_mode_tbl), \ 1383 + } 1384 + 1385 + static const struct ad74115_fw_prop ad74115_gpio_mode_fw_props[] = { 1386 + AD74115_GPIO_MODE_FW_PROP(0), 1387 + AD74115_GPIO_MODE_FW_PROP(1), 1388 + AD74115_GPIO_MODE_FW_PROP(2), 1389 + AD74115_GPIO_MODE_FW_PROP(3), 1390 + }; 1391 + 1392 + static const struct ad74115_fw_prop ad74115_din_threshold_mode_fw_prop = 1393 + AD74115_FW_PROP_BOOL("adi,digital-input-threshold-mode-fixed", 1394 + AD74115_DIN_CONFIG2_REG, BIT(7)); 1395 + 1396 + static const struct ad74115_fw_prop ad74115_dac_bipolar_fw_prop = 1397 + AD74115_FW_PROP_BOOL("adi,dac-bipolar", AD74115_OUTPUT_CONFIG_REG, BIT(7)); 1398 + 1399 + static const struct ad74115_fw_prop ad74115_ch_func_fw_prop = 1400 + AD74115_FW_PROP("adi,ch-func", AD74115_CH_FUNC_MAX, 1401 + AD74115_CH_FUNC_SETUP_REG, GENMASK(3, 0)); 1402 + 1403 + static const struct ad74115_fw_prop ad74115_rtd_mode_fw_prop = 1404 + AD74115_FW_PROP_BOOL("adi,4-wire-rtd", AD74115_RTD3W4W_CONFIG_REG, BIT(3)); 1405 + 1406 + static const struct ad74115_fw_prop ad74115_din_range_fw_prop = 1407 + AD74115_FW_PROP_BOOL("adi,digital-input-sink-range-high", 1408 + AD74115_DIN_CONFIG1_REG, BIT(12)); 1409 + 1410 + static const struct ad74115_fw_prop ad74115_ext2_burnout_current_fw_prop = 1411 + AD74115_FW_PROP_TBL("adi,ext2-burnout-current-nanoamp", 1412 + ad74115_burnout_current_na_tbl, 1413 + AD74115_BURNOUT_CONFIG_REG, GENMASK(14, 12)); 1414 + 1415 + static const struct ad74115_fw_prop ad74115_ext1_burnout_current_fw_prop = 1416 + AD74115_FW_PROP_TBL("adi,ext1-burnout-current-nanoamp", 1417 + ad74115_burnout_current_na_tbl, 1418 + AD74115_BURNOUT_CONFIG_REG, GENMASK(9, 7)); 1419 + 1420 + static const struct ad74115_fw_prop ad74115_viout_burnout_current_fw_prop = 1421 + AD74115_FW_PROP_TBL("adi,viout-burnout-current-nanoamp", 1422 + ad74115_viout_burnout_current_na_tbl, 1423 + AD74115_BURNOUT_CONFIG_REG, GENMASK(4, 2)); 1424 + 1425 + static const struct ad74115_fw_prop ad74115_fw_props[] = { 1426 + AD74115_FW_PROP("adi,conv2-mux", 3, 1427 + AD74115_ADC_CONFIG_REG, GENMASK(3, 2)), 1428 + 1429 + AD74115_FW_PROP_BOOL_NEG("adi,sense-agnd-buffer-low-power", 1430 + AD74115_PWR_OPTIM_CONFIG_REG, BIT(4)), 1431 + AD74115_FW_PROP_BOOL_NEG("adi,lf-buffer-low-power", 1432 + AD74115_PWR_OPTIM_CONFIG_REG, BIT(3)), 1433 + AD74115_FW_PROP_BOOL_NEG("adi,hf-buffer-low-power", 1434 + AD74115_PWR_OPTIM_CONFIG_REG, BIT(2)), 1435 + AD74115_FW_PROP_BOOL_NEG("adi,ext2-buffer-low-power", 1436 + AD74115_PWR_OPTIM_CONFIG_REG, BIT(1)), 1437 + AD74115_FW_PROP_BOOL_NEG("adi,ext1-buffer-low-power", 1438 + AD74115_PWR_OPTIM_CONFIG_REG, BIT(0)), 1439 + 1440 + AD74115_FW_PROP_BOOL("adi,comparator-invert", 1441 + AD74115_DIN_CONFIG1_REG, BIT(14)), 1442 + AD74115_FW_PROP_BOOL("adi,digital-input-debounce-mode-counter-reset", 1443 + AD74115_DIN_CONFIG1_REG, BIT(6)), 1444 + 1445 + AD74115_FW_PROP_BOOL("adi,digital-input-unbuffered", 1446 + AD74115_DIN_CONFIG2_REG, BIT(10)), 1447 + AD74115_FW_PROP_BOOL("adi,digital-input-short-circuit-detection", 1448 + AD74115_DIN_CONFIG2_REG, BIT(9)), 1449 + AD74115_FW_PROP_BOOL("adi,digital-input-open-circuit-detection", 1450 + AD74115_DIN_CONFIG2_REG, BIT(8)), 1451 + 1452 + AD74115_FW_PROP_BOOL("adi,dac-current-limit-low", 1453 + AD74115_OUTPUT_CONFIG_REG, BIT(0)), 1454 + 1455 + AD74115_FW_PROP_BOOL("adi,3-wire-rtd-excitation-swap", 1456 + AD74115_RTD3W4W_CONFIG_REG, BIT(2)), 1457 + AD74115_FW_PROP_TBL("adi,rtd-excitation-current-microamp", 1458 + ad74115_rtd_excitation_current_ua_tbl, 1459 + AD74115_RTD3W4W_CONFIG_REG, GENMASK(1, 0)), 1460 + 1461 + AD74115_FW_PROP_BOOL("adi,ext2-burnout-current-polarity-sourcing", 1462 + AD74115_BURNOUT_CONFIG_REG, BIT(11)), 1463 + AD74115_FW_PROP_BOOL("adi,ext1-burnout-current-polarity-sourcing", 1464 + AD74115_BURNOUT_CONFIG_REG, BIT(6)), 1465 + AD74115_FW_PROP_BOOL("adi,viout-burnout-current-polarity-sourcing", 1466 + AD74115_BURNOUT_CONFIG_REG, BIT(1)), 1467 + 1468 + AD74115_FW_PROP_BOOL("adi,charge-pump", 1469 + AD74115_CHARGE_PUMP_REG, BIT(0)), 1470 + }; 1471 + 1472 + static int ad74115_apply_fw_prop(struct ad74115_state *st, 1473 + const struct ad74115_fw_prop *prop, u32 *retval) 1474 + { 1475 + struct device *dev = &st->spi->dev; 1476 + u32 val = 0; 1477 + int ret; 1478 + 1479 + if (prop->is_boolean) { 1480 + val = device_property_read_bool(dev, prop->name); 1481 + } else { 1482 + ret = device_property_read_u32(dev, prop->name, &val); 1483 + if (ret && prop->lookup_tbl) 1484 + val = prop->lookup_tbl[0]; 1485 + } 1486 + 1487 + *retval = val; 1488 + 1489 + if (prop->negate) 1490 + val = !val; 1491 + 1492 + if (prop->lookup_tbl) 1493 + ret = _ad74115_find_tbl_index(prop->lookup_tbl, 1494 + prop->lookup_tbl_len, val, &val); 1495 + else if (prop->max && val > prop->max) 1496 + ret = -EINVAL; 1497 + else 1498 + ret = 0; 1499 + 1500 + if (ret) 1501 + return dev_err_probe(dev, -EINVAL, 1502 + "Invalid value %u for prop %s\n", 1503 + val, prop->name); 1504 + 1505 + WARN(!prop->mask, "Prop %s mask is empty\n", prop->name); 1506 + 1507 + val = (val << __ffs(prop->mask)) & prop->mask; 1508 + 1509 + return regmap_update_bits(st->regmap, prop->reg, prop->mask, val); 1510 + } 1511 + 1512 + static int ad74115_setup_adc_conv2_range(struct ad74115_state *st) 1513 + { 1514 + unsigned int tbl_len = ARRAY_SIZE(ad74115_adc_range_tbl); 1515 + const char *prop_name = "adi,conv2-range-microvolt"; 1516 + s32 vals[2] = { 1517 + ad74115_adc_range_tbl[0][0], 1518 + ad74115_adc_range_tbl[0][1], 1519 + }; 1520 + struct device *dev = &st->spi->dev; 1521 + unsigned int i; 1522 + 1523 + device_property_read_u32_array(dev, prop_name, vals, 2); 1524 + 1525 + for (i = 0; i < tbl_len; i++) 1526 + if (vals[0] == ad74115_adc_range_tbl[i][0] && 1527 + vals[1] == ad74115_adc_range_tbl[i][1]) 1528 + break; 1529 + 1530 + if (i == tbl_len) 1531 + return dev_err_probe(dev, -EINVAL, 1532 + "Invalid value %d, %d for prop %s\n", 1533 + vals[0], vals[1], prop_name); 1534 + 1535 + return regmap_update_bits(st->regmap, AD74115_ADC_CONFIG_REG, 1536 + AD74115_ADC_CONFIG_CONV2_RANGE_MASK, 1537 + FIELD_PREP(AD74115_ADC_CONFIG_CONV2_RANGE_MASK, i)); 1538 + } 1539 + 1540 + static int ad74115_setup_iio_channels(struct iio_dev *indio_dev) 1541 + { 1542 + struct ad74115_state *st = iio_priv(indio_dev); 1543 + struct device *dev = &st->spi->dev; 1544 + struct iio_chan_spec *channels; 1545 + 1546 + channels = devm_kcalloc(dev, sizeof(*channels), 1547 + indio_dev->num_channels, GFP_KERNEL); 1548 + if (!channels) 1549 + return -ENOMEM; 1550 + 1551 + indio_dev->channels = channels; 1552 + 1553 + memcpy(channels, ad74115_channels_map[st->ch_func].channels, 1554 + sizeof(*channels) * ad74115_channels_map[st->ch_func].num_channels); 1555 + 1556 + if (channels[0].output && channels[0].channel == AD74115_DAC_CH_MAIN && 1557 + channels[0].type == IIO_VOLTAGE && !st->dac_hart_slew) { 1558 + channels[0].info_mask_separate |= BIT(IIO_CHAN_INFO_SAMP_FREQ); 1559 + channels[0].info_mask_separate_available |= BIT(IIO_CHAN_INFO_SAMP_FREQ); 1560 + } 1561 + 1562 + return 0; 1563 + } 1564 + 1565 + static int ad74115_setup_gpio_chip(struct ad74115_state *st) 1566 + { 1567 + struct device *dev = &st->spi->dev; 1568 + 1569 + if (!st->gpio_valid_mask) 1570 + return 0; 1571 + 1572 + st->gc = (struct gpio_chip) { 1573 + .owner = THIS_MODULE, 1574 + .label = AD74115_NAME, 1575 + .base = -1, 1576 + .ngpio = AD74115_GPIO_NUM, 1577 + .parent = dev, 1578 + .can_sleep = true, 1579 + .init_valid_mask = ad74115_gpio_init_valid_mask, 1580 + .get_direction = ad74115_gpio_get_direction, 1581 + .direction_input = ad74115_gpio_direction_input, 1582 + .direction_output = ad74115_gpio_direction_output, 1583 + .get = ad74115_gpio_get, 1584 + .set = ad74115_gpio_set, 1585 + }; 1586 + 1587 + return devm_gpiochip_add_data(dev, &st->gc, st); 1588 + } 1589 + 1590 + static int ad74115_setup_comp_gpio_chip(struct ad74115_state *st) 1591 + { 1592 + struct device *dev = &st->spi->dev; 1593 + u32 val; 1594 + int ret; 1595 + 1596 + ret = regmap_read(st->regmap, AD74115_DIN_CONFIG1_REG, &val); 1597 + if (ret) 1598 + return ret; 1599 + 1600 + if (!(val & AD74115_DIN_COMPARATOR_EN_MASK)) 1601 + return 0; 1602 + 1603 + st->comp_gc = (struct gpio_chip) { 1604 + .owner = THIS_MODULE, 1605 + .label = AD74115_NAME, 1606 + .base = -1, 1607 + .ngpio = 1, 1608 + .parent = dev, 1609 + .can_sleep = true, 1610 + .get_direction = ad74115_comp_gpio_get_direction, 1611 + .get = ad74115_comp_gpio_get, 1612 + .set_config = ad74115_comp_gpio_set_config, 1613 + }; 1614 + 1615 + return devm_gpiochip_add_data(dev, &st->comp_gc, st); 1616 + } 1617 + 1618 + static int ad74115_setup(struct iio_dev *indio_dev) 1619 + { 1620 + struct ad74115_state *st = iio_priv(indio_dev); 1621 + struct device *dev = &st->spi->dev; 1622 + u32 val, din_range_high; 1623 + unsigned int i; 1624 + int ret; 1625 + 1626 + ret = ad74115_apply_fw_prop(st, &ad74115_ch_func_fw_prop, &val); 1627 + if (ret) 1628 + return ret; 1629 + 1630 + indio_dev->num_channels += ad74115_channels_map[val].num_channels; 1631 + st->ch_func = val; 1632 + 1633 + ret = ad74115_setup_adc_conv2_range(st); 1634 + if (ret) 1635 + return ret; 1636 + 1637 + val = device_property_read_bool(dev, "adi,dac-hart-slew"); 1638 + if (val) { 1639 + st->dac_hart_slew = val; 1640 + 1641 + ret = regmap_update_bits(st->regmap, AD74115_OUTPUT_CONFIG_REG, 1642 + AD74115_OUTPUT_SLEW_EN_MASK, 1643 + FIELD_PREP(AD74115_OUTPUT_SLEW_EN_MASK, 1644 + AD74115_SLEW_MODE_HART)); 1645 + if (ret) 1646 + return ret; 1647 + } 1648 + 1649 + ret = ad74115_apply_fw_prop(st, &ad74115_din_range_fw_prop, 1650 + &din_range_high); 1651 + if (ret) 1652 + return ret; 1653 + 1654 + ret = device_property_read_u32(dev, "adi,digital-input-sink-microamp", &val); 1655 + if (!ret) { 1656 + if (din_range_high) 1657 + val = DIV_ROUND_CLOSEST(val, AD74115_DIN_SINK_LOW_STEP); 1658 + else 1659 + val = DIV_ROUND_CLOSEST(val, AD74115_DIN_SINK_HIGH_STEP); 1660 + 1661 + if (val > AD74115_DIN_SINK_MAX) 1662 + val = AD74115_DIN_SINK_MAX; 1663 + 1664 + ret = regmap_update_bits(st->regmap, AD74115_DIN_CONFIG1_REG, 1665 + AD74115_DIN_SINK_MASK, 1666 + FIELD_PREP(AD74115_DIN_SINK_MASK, val)); 1667 + if (ret) 1668 + return ret; 1669 + } 1670 + 1671 + ret = ad74115_apply_fw_prop(st, &ad74115_din_threshold_mode_fw_prop, &val); 1672 + if (ret) 1673 + return ret; 1674 + 1675 + if (val == AD74115_DIN_THRESHOLD_MODE_AVDD) { 1676 + ret = regulator_get_voltage(st->avdd); 1677 + if (ret < 0) 1678 + return ret; 1679 + 1680 + st->avdd_mv = ret / 1000; 1681 + } 1682 + 1683 + st->din_threshold_mode = val; 1684 + 1685 + ret = ad74115_apply_fw_prop(st, &ad74115_dac_bipolar_fw_prop, &val); 1686 + if (ret) 1687 + return ret; 1688 + 1689 + st->dac_bipolar = val; 1690 + 1691 + ret = ad74115_apply_fw_prop(st, &ad74115_rtd_mode_fw_prop, &val); 1692 + if (ret) 1693 + return ret; 1694 + 1695 + st->rtd_mode_4_wire = val; 1696 + 1697 + ret = ad74115_apply_fw_prop(st, &ad74115_ext2_burnout_current_fw_prop, &val); 1698 + if (ret) 1699 + return ret; 1700 + 1701 + if (val) { 1702 + ret = regmap_update_bits(st->regmap, AD74115_BURNOUT_CONFIG_REG, 1703 + AD74115_BURNOUT_EXT2_EN_MASK, 1704 + FIELD_PREP(AD74115_BURNOUT_EXT2_EN_MASK, 1)); 1705 + if (ret) 1706 + return ret; 1707 + } 1708 + 1709 + ret = ad74115_apply_fw_prop(st, &ad74115_ext1_burnout_current_fw_prop, &val); 1710 + if (ret) 1711 + return ret; 1712 + 1713 + if (val) { 1714 + ret = regmap_update_bits(st->regmap, AD74115_BURNOUT_CONFIG_REG, 1715 + AD74115_BURNOUT_EXT1_EN_MASK, 1716 + FIELD_PREP(AD74115_BURNOUT_EXT1_EN_MASK, 1)); 1717 + if (ret) 1718 + return ret; 1719 + } 1720 + 1721 + ret = ad74115_apply_fw_prop(st, &ad74115_viout_burnout_current_fw_prop, &val); 1722 + if (ret) 1723 + return ret; 1724 + 1725 + if (val) { 1726 + ret = regmap_update_bits(st->regmap, AD74115_BURNOUT_CONFIG_REG, 1727 + AD74115_BURNOUT_VIOUT_EN_MASK, 1728 + FIELD_PREP(AD74115_BURNOUT_VIOUT_EN_MASK, 1)); 1729 + if (ret) 1730 + return ret; 1731 + } 1732 + 1733 + for (i = 0; i < AD74115_GPIO_NUM; i++) { 1734 + ret = ad74115_apply_fw_prop(st, &ad74115_gpio_mode_fw_props[i], &val); 1735 + if (ret) 1736 + return ret; 1737 + 1738 + if (val == AD74115_GPIO_MODE_LOGIC) 1739 + st->gpio_valid_mask |= BIT(i); 1740 + } 1741 + 1742 + for (i = 0; i < ARRAY_SIZE(ad74115_fw_props); i++) { 1743 + ret = ad74115_apply_fw_prop(st, &ad74115_fw_props[i], &val); 1744 + if (ret) 1745 + return ret; 1746 + } 1747 + 1748 + ret = ad74115_setup_gpio_chip(st); 1749 + if (ret) 1750 + return ret; 1751 + 1752 + ret = ad74115_setup_comp_gpio_chip(st); 1753 + if (ret) 1754 + return ret; 1755 + 1756 + return ad74115_setup_iio_channels(indio_dev); 1757 + } 1758 + 1759 + static int ad74115_reset(struct ad74115_state *st) 1760 + { 1761 + struct device *dev = &st->spi->dev; 1762 + struct gpio_desc *reset_gpio; 1763 + int ret; 1764 + 1765 + reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 1766 + if (IS_ERR(reset_gpio)) 1767 + return dev_err_probe(dev, PTR_ERR(reset_gpio), 1768 + "Failed to find reset GPIO\n"); 1769 + 1770 + if (reset_gpio) { 1771 + fsleep(100); 1772 + 1773 + gpiod_set_value_cansleep(reset_gpio, 0); 1774 + } else { 1775 + ret = regmap_write(st->regmap, AD74115_CMD_KEY_REG, 1776 + AD74115_CMD_KEY_RESET1); 1777 + if (ret) 1778 + return ret; 1779 + 1780 + ret = regmap_write(st->regmap, AD74115_CMD_KEY_REG, 1781 + AD74115_CMD_KEY_RESET2); 1782 + if (ret) 1783 + return ret; 1784 + } 1785 + 1786 + fsleep(1000); 1787 + 1788 + return 0; 1789 + } 1790 + 1791 + static void ad74115_regulator_disable(void *data) 1792 + { 1793 + regulator_disable(data); 1794 + } 1795 + 1796 + static int ad74115_setup_trigger(struct iio_dev *indio_dev) 1797 + { 1798 + struct ad74115_state *st = iio_priv(indio_dev); 1799 + struct device *dev = &st->spi->dev; 1800 + int ret; 1801 + 1802 + st->irq = fwnode_irq_get_byname(dev_fwnode(dev), "adc_rdy"); 1803 + 1804 + if (st->irq == -EPROBE_DEFER) 1805 + return -EPROBE_DEFER; 1806 + 1807 + if (st->irq < 0) { 1808 + st->irq = 0; 1809 + return 0; 1810 + } 1811 + 1812 + ret = devm_request_irq(dev, st->irq, ad74115_adc_data_interrupt, 1813 + 0, AD74115_NAME, indio_dev); 1814 + if (ret) 1815 + return ret; 1816 + 1817 + st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", AD74115_NAME, 1818 + iio_device_id(indio_dev)); 1819 + if (!st->trig) 1820 + return -ENOMEM; 1821 + 1822 + st->trig->ops = &ad74115_trigger_ops; 1823 + iio_trigger_set_drvdata(st->trig, st); 1824 + 1825 + ret = devm_iio_trigger_register(dev, st->trig); 1826 + if (ret) 1827 + return ret; 1828 + 1829 + indio_dev->trig = iio_trigger_get(st->trig); 1830 + 1831 + return 0; 1832 + } 1833 + 1834 + static int ad74115_probe(struct spi_device *spi) 1835 + { 1836 + static const char * const regulator_names[] = { 1837 + "avcc", "dvcc", "dovdd", "refin", 1838 + }; 1839 + struct device *dev = &spi->dev; 1840 + struct ad74115_state *st; 1841 + struct iio_dev *indio_dev; 1842 + int ret; 1843 + 1844 + indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); 1845 + if (!indio_dev) 1846 + return -ENOMEM; 1847 + 1848 + st = iio_priv(indio_dev); 1849 + 1850 + st->spi = spi; 1851 + mutex_init(&st->lock); 1852 + init_completion(&st->adc_data_completion); 1853 + 1854 + indio_dev->name = AD74115_NAME; 1855 + indio_dev->modes = INDIO_DIRECT_MODE; 1856 + indio_dev->info = &ad74115_info; 1857 + 1858 + st->avdd = devm_regulator_get(dev, "avdd"); 1859 + if (IS_ERR(st->avdd)) 1860 + return PTR_ERR(st->avdd); 1861 + 1862 + ret = regulator_enable(st->avdd); 1863 + if (ret) { 1864 + dev_err(dev, "Failed to enable avdd regulator\n"); 1865 + return ret; 1866 + } 1867 + 1868 + ret = devm_add_action_or_reset(dev, ad74115_regulator_disable, st->avdd); 1869 + if (ret) 1870 + return ret; 1871 + 1872 + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names), 1873 + regulator_names); 1874 + if (ret) 1875 + return ret; 1876 + 1877 + st->regmap = devm_regmap_init(dev, NULL, st, &ad74115_regmap_config); 1878 + if (IS_ERR(st->regmap)) 1879 + return PTR_ERR(st->regmap); 1880 + 1881 + ret = ad74115_reset(st); 1882 + if (ret) 1883 + return ret; 1884 + 1885 + ret = ad74115_setup(indio_dev); 1886 + if (ret) 1887 + return ret; 1888 + 1889 + ret = ad74115_setup_trigger(indio_dev); 1890 + if (ret) 1891 + return ret; 1892 + 1893 + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, 1894 + ad74115_trigger_handler, 1895 + &ad74115_buffer_ops); 1896 + if (ret) 1897 + return ret; 1898 + 1899 + return devm_iio_device_register(dev, indio_dev); 1900 + } 1901 + 1902 + static int ad74115_unregister_driver(struct spi_driver *spi) 1903 + { 1904 + spi_unregister_driver(spi); 1905 + 1906 + return 0; 1907 + } 1908 + 1909 + static int __init ad74115_register_driver(struct spi_driver *spi) 1910 + { 1911 + crc8_populate_msb(ad74115_crc8_table, AD74115_CRC_POLYNOMIAL); 1912 + 1913 + return spi_register_driver(spi); 1914 + } 1915 + 1916 + static const struct spi_device_id ad74115_spi_id[] = { 1917 + { "ad74115h" }, 1918 + { } 1919 + }; 1920 + 1921 + MODULE_DEVICE_TABLE(spi, ad74115_spi_id); 1922 + 1923 + static const struct of_device_id ad74115_dt_id[] = { 1924 + { .compatible = "adi,ad74115h" }, 1925 + { } 1926 + }; 1927 + MODULE_DEVICE_TABLE(of, ad74115_dt_id); 1928 + 1929 + static struct spi_driver ad74115_driver = { 1930 + .driver = { 1931 + .name = "ad74115", 1932 + .of_match_table = ad74115_dt_id, 1933 + }, 1934 + .probe = ad74115_probe, 1935 + .id_table = ad74115_spi_id, 1936 + }; 1937 + 1938 + module_driver(ad74115_driver, 1939 + ad74115_register_driver, ad74115_unregister_driver); 1940 + 1941 + MODULE_AUTHOR("Cosmin Tanislav <cosmin.tanislav@analog.com>"); 1942 + MODULE_DESCRIPTION("Analog Devices AD74115 ADDAC"); 1943 + MODULE_LICENSE("GPL");
+31 -1
drivers/iio/addac/ad74413r.c
··· 71 71 struct regmap *regmap; 72 72 struct device *dev; 73 73 struct iio_trigger *trig; 74 + struct gpio_desc *reset_gpio; 74 75 75 76 size_t adc_active_channels; 76 77 struct spi_message adc_samples_msg; ··· 394 393 { 395 394 int ret; 396 395 396 + if (st->reset_gpio) { 397 + gpiod_set_value_cansleep(st->reset_gpio, 1); 398 + fsleep(50); 399 + gpiod_set_value_cansleep(st->reset_gpio, 0); 400 + return 0; 401 + } 402 + 397 403 ret = regmap_write(st->regmap, AD74413R_REG_CMD_KEY, 398 404 AD74413R_CMD_KEY_RESET1); 399 405 if (ret) ··· 699 691 if (ret) 700 692 return ret; 701 693 702 - *val = voltage_offset * AD74413R_ADC_RESULT_MAX / voltage_range; 694 + *val = voltage_offset * (int)AD74413R_ADC_RESULT_MAX / voltage_range; 703 695 704 696 return IIO_VAL_INT; 705 697 } ··· 1313 1305 st->spi = spi; 1314 1306 st->dev = &spi->dev; 1315 1307 st->chip_info = device_get_match_data(&spi->dev); 1308 + if (!st->chip_info) { 1309 + const struct spi_device_id *id = spi_get_device_id(spi); 1310 + 1311 + if (id) 1312 + st->chip_info = 1313 + (struct ad74413r_chip_info *)id->driver_data; 1314 + if (!st->chip_info) 1315 + return -EINVAL; 1316 + } 1317 + 1316 1318 mutex_init(&st->lock); 1317 1319 init_completion(&st->adc_data_completion); 1318 1320 ··· 1330 1312 &ad74413r_regmap_config); 1331 1313 if (IS_ERR(st->regmap)) 1332 1314 return PTR_ERR(st->regmap); 1315 + 1316 + st->reset_gpio = devm_gpiod_get_optional(st->dev, "reset", GPIOD_OUT_LOW); 1317 + if (IS_ERR(st->reset_gpio)) 1318 + return PTR_ERR(st->reset_gpio); 1333 1319 1334 1320 st->refin_reg = devm_regulator_get(st->dev, "refin"); 1335 1321 if (IS_ERR(st->refin_reg)) ··· 1479 1457 }; 1480 1458 MODULE_DEVICE_TABLE(of, ad74413r_dt_id); 1481 1459 1460 + static const struct spi_device_id ad74413r_spi_id[] = { 1461 + { .name = "ad74412r", .driver_data = (kernel_ulong_t)&ad74412r_chip_info_data }, 1462 + { .name = "ad74413r", .driver_data = (kernel_ulong_t)&ad74413r_chip_info_data }, 1463 + {} 1464 + }; 1465 + MODULE_DEVICE_TABLE(spi, ad74413r_spi_id); 1466 + 1482 1467 static struct spi_driver ad74413r_driver = { 1483 1468 .driver = { 1484 1469 .name = "ad74413r", 1485 1470 .of_match_table = ad74413r_dt_id, 1486 1471 }, 1487 1472 .probe = ad74413r_probe, 1473 + .id_table = ad74413r_spi_id, 1488 1474 }; 1489 1475 1490 1476 module_driver(ad74413r_driver,
+3 -3
drivers/iio/cdc/ad7150.c
··· 536 536 .read_raw = &ad7150_read_raw, 537 537 }; 538 538 539 - static int ad7150_probe(struct i2c_client *client, 540 - const struct i2c_device_id *id) 539 + static int ad7150_probe(struct i2c_client *client) 541 540 { 541 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 542 542 struct ad7150_chip_info *chip; 543 543 struct iio_dev *indio_dev; 544 544 int ret; ··· 647 647 .name = "ad7150", 648 648 .of_match_table = ad7150_of_match, 649 649 }, 650 - .probe = ad7150_probe, 650 + .probe_new = ad7150_probe, 651 651 .id_table = ad7150_id, 652 652 }; 653 653 module_i2c_driver(ad7150_driver);
+3 -3
drivers/iio/cdc/ad7746.c
··· 717 717 .write_raw = ad7746_write_raw, 718 718 }; 719 719 720 - static int ad7746_probe(struct i2c_client *client, 721 - const struct i2c_device_id *id) 720 + static int ad7746_probe(struct i2c_client *client) 722 721 { 722 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 723 723 struct device *dev = &client->dev; 724 724 struct ad7746_chip_info *chip; 725 725 struct iio_dev *indio_dev; ··· 810 810 .name = KBUILD_MODNAME, 811 811 .of_match_table = ad7746_of_match, 812 812 }, 813 - .probe = ad7746_probe, 813 + .probe_new = ad7746_probe, 814 814 .id_table = ad7746_id, 815 815 }; 816 816 module_i2c_driver(ad7746_driver);
+2 -3
drivers/iio/chemical/ams-iaq-core.c
··· 135 135 .read_raw = ams_iaqcore_read_raw, 136 136 }; 137 137 138 - static int ams_iaqcore_probe(struct i2c_client *client, 139 - const struct i2c_device_id *id) 138 + static int ams_iaqcore_probe(struct i2c_client *client) 140 139 { 141 140 struct iio_dev *indio_dev; 142 141 struct ams_iaqcore_data *data; ··· 179 180 .name = "ams-iaq-core", 180 181 .of_match_table = ams_iaqcore_dt_ids, 181 182 }, 182 - .probe = ams_iaqcore_probe, 183 + .probe_new = ams_iaqcore_probe, 183 184 .id_table = ams_iaqcore_id, 184 185 }; 185 186 module_i2c_driver(ams_iaqcore_driver);
+3 -3
drivers/iio/chemical/atlas-ezo-sensor.c
··· 201 201 }; 202 202 MODULE_DEVICE_TABLE(of, atlas_ezo_dt_ids); 203 203 204 - static int atlas_ezo_probe(struct i2c_client *client, 205 - const struct i2c_device_id *id) 204 + static int atlas_ezo_probe(struct i2c_client *client) 206 205 { 206 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 207 207 const struct atlas_ezo_device *chip; 208 208 struct atlas_ezo_data *data; 209 209 struct iio_dev *indio_dev; ··· 238 238 .name = ATLAS_EZO_DRV_NAME, 239 239 .of_match_table = atlas_ezo_dt_ids, 240 240 }, 241 - .probe = atlas_ezo_probe, 241 + .probe_new = atlas_ezo_probe, 242 242 .id_table = atlas_ezo_id, 243 243 }; 244 244 module_i2c_driver(atlas_ezo_driver);
+3 -3
drivers/iio/chemical/atlas-sensor.c
··· 608 608 }; 609 609 MODULE_DEVICE_TABLE(of, atlas_dt_ids); 610 610 611 - static int atlas_probe(struct i2c_client *client, 612 - const struct i2c_device_id *id) 611 + static int atlas_probe(struct i2c_client *client) 613 612 { 613 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 614 614 struct atlas_data *data; 615 615 struct atlas_device *chip; 616 616 struct iio_trigger *trig; ··· 767 767 .of_match_table = atlas_dt_ids, 768 768 .pm = pm_ptr(&atlas_pm_ops), 769 769 }, 770 - .probe = atlas_probe, 770 + .probe_new = atlas_probe, 771 771 .remove = atlas_remove, 772 772 .id_table = atlas_id, 773 773 };
+3 -3
drivers/iio/chemical/bme680_i2c.c
··· 17 17 18 18 #include "bme680.h" 19 19 20 - static int bme680_i2c_probe(struct i2c_client *client, 21 - const struct i2c_device_id *id) 20 + static int bme680_i2c_probe(struct i2c_client *client) 22 21 { 22 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 23 23 struct regmap *regmap; 24 24 const char *name = NULL; 25 25 ··· 52 52 .name = "bme680_i2c", 53 53 .of_match_table = bme680_of_i2c_match, 54 54 }, 55 - .probe = bme680_i2c_probe, 55 + .probe_new = bme680_i2c_probe, 56 56 .id_table = bme680_i2c_id, 57 57 }; 58 58 module_i2c_driver(bme680_i2c_driver);
+3 -3
drivers/iio/chemical/ccs811.c
··· 401 401 return 0; 402 402 } 403 403 404 - static int ccs811_probe(struct i2c_client *client, 405 - const struct i2c_device_id *id) 404 + static int ccs811_probe(struct i2c_client *client) 406 405 { 406 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 407 407 struct iio_dev *indio_dev; 408 408 struct ccs811_data *data; 409 409 int ret; ··· 567 567 .name = "ccs811", 568 568 .of_match_table = ccs811_dt_ids, 569 569 }, 570 - .probe = ccs811_probe, 570 + .probe_new = ccs811_probe, 571 571 .remove = ccs811_remove, 572 572 .id_table = ccs811_id, 573 573 };
+2 -2
drivers/iio/chemical/scd4x.c
··· 615 615 return IRQ_HANDLED; 616 616 } 617 617 618 - static int scd4x_probe(struct i2c_client *client, const struct i2c_device_id *id) 618 + static int scd4x_probe(struct i2c_client *client) 619 619 { 620 620 static const unsigned long scd4x_scan_masks[] = { 0x07, 0x00 }; 621 621 struct device *dev = &client->dev; ··· 690 690 .of_match_table = scd4x_dt_ids, 691 691 .pm = pm_sleep_ptr(&scd4x_pm_ops), 692 692 }, 693 - .probe = scd4x_probe, 693 + .probe_new = scd4x_probe, 694 694 }; 695 695 module_i2c_driver(scd4x_i2c_driver); 696 696
+3 -3
drivers/iio/chemical/sgp30.c
··· 496 496 { } 497 497 }; 498 498 499 - static int sgp_probe(struct i2c_client *client, 500 - const struct i2c_device_id *id) 499 + static int sgp_probe(struct i2c_client *client) 501 500 { 501 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 502 502 struct device *dev = &client->dev; 503 503 struct iio_dev *indio_dev; 504 504 struct sgp_data *data; ··· 575 575 .name = "sgp30", 576 576 .of_match_table = sgp_dt_ids, 577 577 }, 578 - .probe = sgp_probe, 578 + .probe_new = sgp_probe, 579 579 .remove = sgp_remove, 580 580 .id_table = sgp_id, 581 581 };
+3 -3
drivers/iio/chemical/sgp40.c
··· 311 311 .write_raw = sgp40_write_raw, 312 312 }; 313 313 314 - static int sgp40_probe(struct i2c_client *client, 315 - const struct i2c_device_id *id) 314 + static int sgp40_probe(struct i2c_client *client) 316 315 { 316 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 317 317 struct device *dev = &client->dev; 318 318 struct iio_dev *indio_dev; 319 319 struct sgp40_data *data; ··· 368 368 .name = "sgp40", 369 369 .of_match_table = sgp40_dt_ids, 370 370 }, 371 - .probe = sgp40_probe, 371 + .probe_new = sgp40_probe, 372 372 .id_table = sgp40_id, 373 373 }; 374 374 module_i2c_driver(sgp40_driver);
+3 -3
drivers/iio/chemical/vz89x.c
··· 348 348 }; 349 349 MODULE_DEVICE_TABLE(of, vz89x_dt_ids); 350 350 351 - static int vz89x_probe(struct i2c_client *client, 352 - const struct i2c_device_id *id) 351 + static int vz89x_probe(struct i2c_client *client) 353 352 { 353 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 354 354 struct device *dev = &client->dev; 355 355 struct iio_dev *indio_dev; 356 356 struct vz89x_data *data; ··· 402 402 .name = "vz89x", 403 403 .of_match_table = vz89x_dt_ids, 404 404 }, 405 - .probe = vz89x_probe, 405 + .probe_new = vz89x_probe, 406 406 .id_table = vz89x_id, 407 407 }; 408 408 module_i2c_driver(vz89x_driver);
+3 -3
drivers/iio/dac/ad5064.c
··· 993 993 return 0; 994 994 } 995 995 996 - static int ad5064_i2c_probe(struct i2c_client *i2c, 997 - const struct i2c_device_id *id) 996 + static int ad5064_i2c_probe(struct i2c_client *i2c) 998 997 { 998 + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 999 999 return ad5064_probe(&i2c->dev, id->driver_data, id->name, 1000 1000 ad5064_i2c_write); 1001 1001 } ··· 1056 1056 .driver = { 1057 1057 .name = "ad5064", 1058 1058 }, 1059 - .probe = ad5064_i2c_probe, 1059 + .probe_new = ad5064_i2c_probe, 1060 1060 .id_table = ad5064_i2c_ids, 1061 1061 }; 1062 1062
+3 -3
drivers/iio/dac/ad5380.c
··· 546 546 547 547 #if IS_ENABLED(CONFIG_I2C) 548 548 549 - static int ad5380_i2c_probe(struct i2c_client *i2c, 550 - const struct i2c_device_id *id) 549 + static int ad5380_i2c_probe(struct i2c_client *i2c) 551 550 { 551 + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 552 552 struct regmap *regmap; 553 553 554 554 regmap = devm_regmap_init_i2c(i2c, &ad5380_regmap_config); ··· 589 589 .driver = { 590 590 .name = "ad5380", 591 591 }, 592 - .probe = ad5380_i2c_probe, 592 + .probe_new = ad5380_i2c_probe, 593 593 .remove = ad5380_i2c_remove, 594 594 .id_table = ad5380_i2c_ids, 595 595 };
+3 -3
drivers/iio/dac/ad5446.c
··· 568 568 }, 569 569 }; 570 570 571 - static int ad5446_i2c_probe(struct i2c_client *i2c, 572 - const struct i2c_device_id *id) 571 + static int ad5446_i2c_probe(struct i2c_client *i2c) 573 572 { 573 + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 574 574 return ad5446_probe(&i2c->dev, id->name, 575 575 &ad5446_i2c_chip_info[id->driver_data]); 576 576 } ··· 595 595 .driver = { 596 596 .name = "ad5446", 597 597 }, 598 - .probe = ad5446_i2c_probe, 598 + .probe_new = ad5446_i2c_probe, 599 599 .remove = ad5446_i2c_remove, 600 600 .id_table = ad5446_i2c_ids, 601 601 };
+3 -3
drivers/iio/dac/ad5593r.c
··· 99 99 .gpio_read = ad5593r_gpio_read, 100 100 }; 101 101 102 - static int ad5593r_i2c_probe(struct i2c_client *i2c, 103 - const struct i2c_device_id *id) 102 + static int ad5593r_i2c_probe(struct i2c_client *i2c) 104 103 { 104 + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 105 105 if (!i2c_check_functionality(i2c->adapter, 106 106 I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C)) 107 107 return -EOPNOTSUPP; ··· 138 138 .of_match_table = ad5593r_of_match, 139 139 .acpi_match_table = ad5593r_acpi_match, 140 140 }, 141 - .probe = ad5593r_i2c_probe, 141 + .probe_new = ad5593r_i2c_probe, 142 142 .remove = ad5593r_i2c_remove, 143 143 .id_table = ad5593r_i2c_ids, 144 144 };
+3 -3
drivers/iio/dac/ad5696-i2c.c
··· 58 58 return (ret != 3) ? -EIO : 0; 59 59 } 60 60 61 - static int ad5686_i2c_probe(struct i2c_client *i2c, 62 - const struct i2c_device_id *id) 61 + static int ad5686_i2c_probe(struct i2c_client *i2c) 63 62 { 63 + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 64 64 return ad5686_probe(&i2c->dev, id->driver_data, id->name, 65 65 ad5686_i2c_write, ad5686_i2c_read); 66 66 } ··· 113 113 .name = "ad5696", 114 114 .of_match_table = ad5686_of_match, 115 115 }, 116 - .probe = ad5686_i2c_probe, 116 + .probe_new = ad5686_i2c_probe, 117 117 .remove = ad5686_i2c_remove, 118 118 .id_table = ad5686_i2c_id, 119 119 };
+3 -3
drivers/iio/dac/ds4424.c
··· 213 213 .write_raw = ds4424_write_raw, 214 214 }; 215 215 216 - static int ds4424_probe(struct i2c_client *client, 217 - const struct i2c_device_id *id) 216 + static int ds4424_probe(struct i2c_client *client) 218 217 { 218 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 219 219 struct ds4424_data *data; 220 220 struct iio_dev *indio_dev; 221 221 int ret; ··· 312 312 .of_match_table = ds4424_of_match, 313 313 .pm = pm_sleep_ptr(&ds4424_pm_ops), 314 314 }, 315 - .probe = ds4424_probe, 315 + .probe_new = ds4424_probe, 316 316 .remove = ds4424_remove, 317 317 .id_table = ds4424_id, 318 318 };
+2 -3
drivers/iio/dac/m62332.c
··· 176 176 M62332_CHANNEL(1) 177 177 }; 178 178 179 - static int m62332_probe(struct i2c_client *client, 180 - const struct i2c_device_id *id) 179 + static int m62332_probe(struct i2c_client *client) 181 180 { 182 181 struct m62332_data *data; 183 182 struct iio_dev *indio_dev; ··· 238 239 .name = "m62332", 239 240 .pm = pm_sleep_ptr(&m62332_pm_ops), 240 241 }, 241 - .probe = m62332_probe, 242 + .probe_new = m62332_probe, 242 243 .remove = m62332_remove, 243 244 .id_table = m62332_id, 244 245 };
+3 -3
drivers/iio/dac/max517.c
··· 141 141 MAX517_CHANNEL(7), 142 142 }; 143 143 144 - static int max517_probe(struct i2c_client *client, 145 - const struct i2c_device_id *id) 144 + static int max517_probe(struct i2c_client *client) 146 145 { 146 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 147 147 struct max517_data *data; 148 148 struct iio_dev *indio_dev; 149 149 struct max517_platform_data *platform_data = client->dev.platform_data; ··· 203 203 .name = MAX517_DRV_NAME, 204 204 .pm = pm_sleep_ptr(&max517_pm_ops), 205 205 }, 206 - .probe = max517_probe, 206 + .probe_new = max517_probe, 207 207 .id_table = max517_id, 208 208 }; 209 209 module_i2c_driver(max517_driver);
+3 -3
drivers/iio/dac/max5821.c
··· 300 300 regulator_disable(reg); 301 301 } 302 302 303 - static int max5821_probe(struct i2c_client *client, 304 - const struct i2c_device_id *id) 303 + static int max5821_probe(struct i2c_client *client) 305 304 { 305 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 306 306 struct max5821_data *data; 307 307 struct iio_dev *indio_dev; 308 308 u32 tmp; ··· 377 377 .of_match_table = max5821_of_match, 378 378 .pm = pm_sleep_ptr(&max5821_pm_ops), 379 379 }, 380 - .probe = max5821_probe, 380 + .probe_new = max5821_probe, 381 381 .id_table = max5821_id, 382 382 }; 383 383 module_i2c_driver(max5821_driver);
+3 -3
drivers/iio/dac/mcp4725.c
··· 369 369 return 0; 370 370 } 371 371 372 - static int mcp4725_probe(struct i2c_client *client, 373 - const struct i2c_device_id *id) 372 + static int mcp4725_probe(struct i2c_client *client) 374 373 { 374 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 375 375 struct mcp4725_data *data; 376 376 struct iio_dev *indio_dev; 377 377 struct mcp4725_platform_data *pdata, pdata_dt; ··· 524 524 .of_match_table = mcp4725_of_match, 525 525 .pm = pm_sleep_ptr(&mcp4725_pm_ops), 526 526 }, 527 - .probe = mcp4725_probe, 527 + .probe_new = mcp4725_probe, 528 528 .remove = mcp4725_remove, 529 529 .id_table = mcp4725_id, 530 530 };
+3 -3
drivers/iio/dac/ti-dac5571.c
··· 306 306 .write_raw_get_fmt = dac5571_write_raw_get_fmt, 307 307 }; 308 308 309 - static int dac5571_probe(struct i2c_client *client, 310 - const struct i2c_device_id *id) 309 + static int dac5571_probe(struct i2c_client *client) 311 310 { 311 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 312 312 struct device *dev = &client->dev; 313 313 const struct dac5571_spec *spec; 314 314 struct dac5571_data *data; ··· 426 426 .name = "ti-dac5571", 427 427 .of_match_table = dac5571_of_id, 428 428 }, 429 - .probe = dac5571_probe, 429 + .probe_new = dac5571_probe, 430 430 .remove = dac5571_remove, 431 431 .id_table = dac5571_id, 432 432 };
+10
drivers/iio/frequency/Kconfig
··· 50 50 To compile this driver as a module, choose M here: the 51 51 module will be called adf4371. 52 52 53 + config ADF4377 54 + tristate "Analog Devices ADF4377 Microwave Wideband Synthesizer" 55 + depends on SPI && COMMON_CLK 56 + help 57 + Say yes here to build support for Analog Devices ADF4377 Microwave 58 + Wideband Synthesizer. 59 + 60 + To compile this driver as a module, choose M here: the 61 + module will be called adf4377. 62 + 53 63 config ADMV1013 54 64 tristate "Analog Devices ADMV1013 Microwave Upconverter" 55 65 depends on SPI && COMMON_CLK
+1
drivers/iio/frequency/Makefile
··· 7 7 obj-$(CONFIG_AD9523) += ad9523.o 8 8 obj-$(CONFIG_ADF4350) += adf4350.o 9 9 obj-$(CONFIG_ADF4371) += adf4371.o 10 + obj-$(CONFIG_ADF4377) += adf4377.o 10 11 obj-$(CONFIG_ADMV1013) += admv1013.o 11 12 obj-$(CONFIG_ADMV1014) += admv1014.o 12 13 obj-$(CONFIG_ADMV4420) += admv4420.o
+994
drivers/iio/frequency/adf4377.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * ADF4377 driver 4 + * 5 + * Copyright 2022 Analog Devices Inc. 6 + */ 7 + 8 + #include <linux/bitfield.h> 9 + #include <linux/bits.h> 10 + #include <linux/clk.h> 11 + #include <linux/clkdev.h> 12 + #include <linux/delay.h> 13 + #include <linux/device.h> 14 + #include <linux/gpio/consumer.h> 15 + #include <linux/module.h> 16 + #include <linux/notifier.h> 17 + #include <linux/property.h> 18 + #include <linux/spi/spi.h> 19 + #include <linux/iio/iio.h> 20 + #include <linux/regmap.h> 21 + #include <linux/units.h> 22 + 23 + #include <asm/unaligned.h> 24 + 25 + /* ADF4377 REG0000 Map */ 26 + #define ADF4377_0000_SOFT_RESET_R_MSK BIT(7) 27 + #define ADF4377_0000_LSB_FIRST_R_MSK BIT(6) 28 + #define ADF4377_0000_ADDRESS_ASC_R_MSK BIT(5) 29 + #define ADF4377_0000_SDO_ACTIVE_R_MSK BIT(4) 30 + #define ADF4377_0000_SDO_ACTIVE_MSK BIT(3) 31 + #define ADF4377_0000_ADDRESS_ASC_MSK BIT(2) 32 + #define ADF4377_0000_LSB_FIRST_MSK BIT(1) 33 + #define ADF4377_0000_SOFT_RESET_MSK BIT(0) 34 + 35 + /* ADF4377 REG0000 Bit Definition */ 36 + #define ADF4377_0000_SDO_ACTIVE_SPI_3W 0x0 37 + #define ADF4377_0000_SDO_ACTIVE_SPI_4W 0x1 38 + 39 + #define ADF4377_0000_ADDR_ASC_AUTO_DECR 0x0 40 + #define ADF4377_0000_ADDR_ASC_AUTO_INCR 0x1 41 + 42 + #define ADF4377_0000_LSB_FIRST_MSB 0x0 43 + #define ADF4377_0000_LSB_FIRST_LSB 0x1 44 + 45 + #define ADF4377_0000_SOFT_RESET_N_OP 0x0 46 + #define ADF4377_0000_SOFT_RESET_EN 0x1 47 + 48 + /* ADF4377 REG0001 Map */ 49 + #define ADF4377_0001_SINGLE_INSTR_MSK BIT(7) 50 + #define ADF4377_0001_MASTER_RB_CTRL_MSK BIT(5) 51 + 52 + /* ADF4377 REG0003 Bit Definition */ 53 + #define ADF4377_0003_CHIP_TYPE 0x06 54 + 55 + /* ADF4377 REG0004 Bit Definition */ 56 + #define ADF4377_0004_PRODUCT_ID_LSB 0x0005 57 + 58 + /* ADF4377 REG0005 Bit Definition */ 59 + #define ADF4377_0005_PRODUCT_ID_MSB 0x0005 60 + 61 + /* ADF4377 REG000A Map */ 62 + #define ADF4377_000A_SCRATCHPAD_MSK GENMASK(7, 0) 63 + 64 + /* ADF4377 REG000C Bit Definition */ 65 + #define ADF4377_000C_VENDOR_ID_LSB 0x56 66 + 67 + /* ADF4377 REG000D Bit Definition */ 68 + #define ADF4377_000D_VENDOR_ID_MSB 0x04 69 + 70 + /* ADF4377 REG000F Bit Definition */ 71 + #define ADF4377_000F_R00F_RSV1_MSK GENMASK(7, 0) 72 + 73 + /* ADF4377 REG0010 Map*/ 74 + #define ADF4377_0010_N_INT_LSB_MSK GENMASK(7, 0) 75 + 76 + /* ADF4377 REG0011 Map*/ 77 + #define ADF4377_0011_EN_AUTOCAL_MSK BIT(7) 78 + #define ADF4377_0011_EN_RDBLR_MSK BIT(6) 79 + #define ADF4377_0011_DCLK_DIV2_MSK GENMASK(5, 4) 80 + #define ADF4377_0011_N_INT_MSB_MSK GENMASK(3, 0) 81 + 82 + /* ADF4377 REG0011 Bit Definition */ 83 + #define ADF4377_0011_DCLK_DIV2_1 0x0 84 + #define ADF4377_0011_DCLK_DIV2_2 0x1 85 + #define ADF4377_0011_DCLK_DIV2_4 0x2 86 + #define ADF4377_0011_DCLK_DIV2_8 0x3 87 + 88 + /* ADF4377 REG0012 Map*/ 89 + #define ADF4377_0012_CLKOUT_DIV_MSK GENMASK(7, 6) 90 + #define ADF4377_0012_R_DIV_MSK GENMASK(5, 0) 91 + 92 + /* ADF4377 REG0012 Bit Definition */ 93 + #define ADF4377_0012_CLKOUT_DIV_1 0x0 94 + #define ADF4377_0012_CLKOUT_DIV_2 0x1 95 + #define ADF4377_0012_CLKOUT_DIV_4 0x2 96 + #define ADF4377_0012_CLKOUT_DIV_8 0x3 97 + 98 + /* ADF4377 REG0013 Map */ 99 + #define ADF4377_0013_M_VCO_CORE_MSK GENMASK(5, 4) 100 + #define ADF4377_0013_VCO_BIAS_MSK GENMASK(3, 0) 101 + 102 + /* ADF4377 REG0013 Bit Definition */ 103 + #define ADF4377_0013_M_VCO_0 0x0 104 + #define ADF4377_0013_M_VCO_1 0x1 105 + #define ADF4377_0013_M_VCO_2 0x2 106 + #define ADF4377_0013_M_VCO_3 0x3 107 + 108 + /* ADF4377 REG0014 Map */ 109 + #define ADF4377_0014_M_VCO_BAND_MSK GENMASK(7, 0) 110 + 111 + /* ADF4377 REG0015 Map */ 112 + #define ADF4377_0015_BLEED_I_LSB_MSK GENMASK(7, 6) 113 + #define ADF4377_0015_BLEED_POL_MSK BIT(5) 114 + #define ADF4377_0015_EN_BLEED_MSK BIT(4) 115 + #define ADF4377_0015_CP_I_MSK GENMASK(3, 0) 116 + 117 + /* ADF4377 REG0015 Bit Definition */ 118 + #define ADF4377_CURRENT_SINK 0x0 119 + #define ADF4377_CURRENT_SOURCE 0x1 120 + 121 + #define ADF4377_0015_CP_0MA7 0x0 122 + #define ADF4377_0015_CP_0MA9 0x1 123 + #define ADF4377_0015_CP_1MA1 0x2 124 + #define ADF4377_0015_CP_1MA3 0x3 125 + #define ADF4377_0015_CP_1MA4 0x4 126 + #define ADF4377_0015_CP_1MA8 0x5 127 + #define ADF4377_0015_CP_2MA2 0x6 128 + #define ADF4377_0015_CP_2MA5 0x7 129 + #define ADF4377_0015_CP_2MA9 0x8 130 + #define ADF4377_0015_CP_3MA6 0x9 131 + #define ADF4377_0015_CP_4MA3 0xA 132 + #define ADF4377_0015_CP_5MA0 0xB 133 + #define ADF4377_0015_CP_5MA7 0xC 134 + #define ADF4377_0015_CP_7MA2 0xD 135 + #define ADF4377_0015_CP_8MA6 0xE 136 + #define ADF4377_0015_CP_10MA1 0xF 137 + 138 + /* ADF4377 REG0016 Map */ 139 + #define ADF4377_0016_BLEED_I_MSB_MSK GENMASK(7, 0) 140 + 141 + /* ADF4377 REG0017 Map */ 142 + #define ADF4377_0016_INV_CLKOUT_MSK BIT(7) 143 + #define ADF4377_0016_N_DEL_MSK GENMASK(6, 0) 144 + 145 + /* ADF4377 REG0018 Map */ 146 + #define ADF4377_0018_CMOS_OV_MSK BIT(7) 147 + #define ADF4377_0018_R_DEL_MSK GENMASK(6, 0) 148 + 149 + /* ADF4377 REG0018 Bit Definition */ 150 + #define ADF4377_0018_1V8_LOGIC 0x0 151 + #define ADF4377_0018_3V3_LOGIC 0x1 152 + 153 + /* ADF4377 REG0019 Map */ 154 + #define ADF4377_0019_CLKOUT2_OP_MSK GENMASK(7, 6) 155 + #define ADF4377_0019_CLKOUT1_OP_MSK GENMASK(5, 4) 156 + #define ADF4377_0019_PD_CLK_MSK BIT(3) 157 + #define ADF4377_0019_PD_RDET_MSK BIT(2) 158 + #define ADF4377_0019_PD_ADC_MSK BIT(1) 159 + #define ADF4377_0019_PD_CALADC_MSK BIT(0) 160 + 161 + /* ADF4377 REG0019 Bit Definition */ 162 + #define ADF4377_0019_CLKOUT_320MV 0x0 163 + #define ADF4377_0019_CLKOUT_420MV 0x1 164 + #define ADF4377_0019_CLKOUT_530MV 0x2 165 + #define ADF4377_0019_CLKOUT_640MV 0x3 166 + 167 + /* ADF4377 REG001A Map */ 168 + #define ADF4377_001A_PD_ALL_MSK BIT(7) 169 + #define ADF4377_001A_PD_RDIV_MSK BIT(6) 170 + #define ADF4377_001A_PD_NDIV_MSK BIT(5) 171 + #define ADF4377_001A_PD_VCO_MSK BIT(4) 172 + #define ADF4377_001A_PD_LD_MSK BIT(3) 173 + #define ADF4377_001A_PD_PFDCP_MSK BIT(2) 174 + #define ADF4377_001A_PD_CLKOUT1_MSK BIT(1) 175 + #define ADF4377_001A_PD_CLKOUT2_MSK BIT(0) 176 + 177 + /* ADF4377 REG001B Map */ 178 + #define ADF4377_001B_EN_LOL_MSK BIT(7) 179 + #define ADF4377_001B_LDWIN_PW_MSK BIT(6) 180 + #define ADF4377_001B_EN_LDWIN_MSK BIT(5) 181 + #define ADF4377_001B_LD_COUNT_MSK GENMASK(4, 0) 182 + 183 + /* ADF4377 REG001B Bit Definition */ 184 + #define ADF4377_001B_LDWIN_PW_NARROW 0x0 185 + #define ADF4377_001B_LDWIN_PW_WIDE 0x1 186 + 187 + /* ADF4377 REG001C Map */ 188 + #define ADF4377_001C_EN_DNCLK_MSK BIT(7) 189 + #define ADF4377_001C_EN_DRCLK_MSK BIT(6) 190 + #define ADF4377_001C_RST_LD_MSK BIT(2) 191 + #define ADF4377_001C_R01C_RSV1_MSK BIT(0) 192 + 193 + /* ADF4377 REG001C Bit Definition */ 194 + #define ADF4377_001C_RST_LD_INACTIVE 0x0 195 + #define ADF4377_001C_RST_LD_ACTIVE 0x1 196 + 197 + #define ADF4377_001C_R01C_RSV1 0x1 198 + 199 + /* ADF4377 REG001D Map */ 200 + #define ADF4377_001D_MUXOUT_MSK GENMASK(7, 4) 201 + #define ADF4377_001D_EN_CPTEST_MSK BIT(2) 202 + #define ADF4377_001D_CP_DOWN_MSK BIT(1) 203 + #define ADF4377_001D_CP_UP_MSK BIT(0) 204 + 205 + #define ADF4377_001D_EN_CPTEST_OFF 0x0 206 + #define ADF4377_001D_EN_CPTEST_ON 0x1 207 + 208 + #define ADF4377_001D_CP_DOWN_OFF 0x0 209 + #define ADF4377_001D_CP_DOWN_ON 0x1 210 + 211 + #define ADF4377_001D_CP_UP_OFF 0x0 212 + #define ADF4377_001D_CP_UP_ON 0x1 213 + 214 + /* ADF4377 REG001F Map */ 215 + #define ADF4377_001F_BST_REF_MSK BIT(7) 216 + #define ADF4377_001F_FILT_REF_MSK BIT(6) 217 + #define ADF4377_001F_REF_SEL_MSK BIT(5) 218 + #define ADF4377_001F_R01F_RSV1_MSK GENMASK(4, 0) 219 + 220 + /* ADF4377 REG001F Bit Definition */ 221 + #define ADF4377_001F_BST_LARGE_REF_IN 0x0 222 + #define ADF4377_001F_BST_SMALL_REF_IN 0x1 223 + 224 + #define ADF4377_001F_FILT_REF_OFF 0x0 225 + #define ADF4377_001F_FILT_REF_ON 0x1 226 + 227 + #define ADF4377_001F_REF_SEL_DMA 0x0 228 + #define ADF4377_001F_REF_SEL_LNA 0x1 229 + 230 + #define ADF4377_001F_R01F_RSV1 0x7 231 + 232 + /* ADF4377 REG0020 Map */ 233 + #define ADF4377_0020_RST_SYS_MSK BIT(4) 234 + #define ADF4377_0020_EN_ADC_CLK_MSK BIT(3) 235 + #define ADF4377_0020_R020_RSV1_MSK BIT(0) 236 + 237 + /* ADF4377 REG0021 Bit Definition */ 238 + #define ADF4377_0021_R021_RSV1 0xD3 239 + 240 + /* ADF4377 REG0022 Bit Definition */ 241 + #define ADF4377_0022_R022_RSV1 0x32 242 + 243 + /* ADF4377 REG0023 Map */ 244 + #define ADF4377_0023_CAT_CT_SEL BIT(7) 245 + #define ADF4377_0023_R023_RSV1_MSK GENMASK(6, 0) 246 + 247 + /* ADF4377 REG0023 Bit Definition */ 248 + #define ADF4377_0023_R023_RSV1 0x18 249 + 250 + /* ADF4377 REG0024 Map */ 251 + #define ADF4377_0024_DCLK_MODE_MSK BIT(2) 252 + 253 + /* ADF4377 REG0025 Map */ 254 + #define ADF4377_0025_CLKODIV_DB_MSK BIT(7) 255 + #define ADF4377_0025_DCLK_DB_MSK BIT(6) 256 + #define ADF4377_0025_R025_RSV1_MSK GENMASK(5, 0) 257 + 258 + /* ADF4377 REG0025 Bit Definition */ 259 + #define ADF4377_0025_R025_RSV1 0x16 260 + 261 + /* ADF4377 REG0026 Map */ 262 + #define ADF4377_0026_VCO_BAND_DIV_MSK GENMASK(7, 0) 263 + 264 + /* ADF4377 REG0027 Map */ 265 + #define ADF4377_0027_SYNTH_LOCK_TO_LSB_MSK GENMASK(7, 0) 266 + 267 + /* ADF4377 REG0028 Map */ 268 + #define ADF4377_0028_O_VCO_DB_MSK BIT(7) 269 + #define ADF4377_0028_SYNTH_LOCK_TO_MSB_MSK GENMASK(6, 0) 270 + 271 + /* ADF4377 REG0029 Map */ 272 + #define ADF4377_0029_VCO_ALC_TO_LSB_MSK GENMASK(7, 0) 273 + 274 + /* ADF4377 REG002A Map */ 275 + #define ADF4377_002A_DEL_CTRL_DB_MSK BIT(7) 276 + #define ADF4377_002A_VCO_ALC_TO_MSB_MSK GENMASK(6, 0) 277 + 278 + /* ADF4377 REG002C Map */ 279 + #define ADF4377_002C_R02C_RSV1 0xC0 280 + 281 + /* ADF4377 REG002D Map */ 282 + #define ADF4377_002D_ADC_CLK_DIV_MSK GENMASK(7, 0) 283 + 284 + /* ADF4377 REG002E Map */ 285 + #define ADF4377_002E_EN_ADC_CNV_MSK BIT(7) 286 + #define ADF4377_002E_EN_ADC_MSK BIT(1) 287 + #define ADF4377_002E_ADC_A_CONV_MSK BIT(0) 288 + 289 + /* ADF4377 REG002E Bit Definition */ 290 + #define ADF4377_002E_ADC_A_CONV_ADC_ST_CNV 0x0 291 + #define ADF4377_002E_ADC_A_CONV_VCO_CALIB 0x1 292 + 293 + /* ADF4377 REG002F Map */ 294 + #define ADF4377_002F_DCLK_DIV1_MSK GENMASK(1, 0) 295 + 296 + /* ADF4377 REG002F Bit Definition */ 297 + #define ADF4377_002F_DCLK_DIV1_1 0x0 298 + #define ADF4377_002F_DCLK_DIV1_2 0x1 299 + #define ADF4377_002F_DCLK_DIV1_8 0x2 300 + #define ADF4377_002F_DCLK_DIV1_32 0x3 301 + 302 + /* ADF4377 REG0031 Bit Definition */ 303 + #define ADF4377_0031_R031_RSV1 0x09 304 + 305 + /* ADF4377 REG0032 Map */ 306 + #define ADF4377_0032_ADC_CLK_SEL_MSK BIT(6) 307 + #define ADF4377_0032_R032_RSV1_MSK GENMASK(5, 0) 308 + 309 + /* ADF4377 REG0032 Bit Definition */ 310 + #define ADF4377_0032_ADC_CLK_SEL_N_OP 0x0 311 + #define ADF4377_0032_ADC_CLK_SEL_SPI_CLK 0x1 312 + 313 + #define ADF4377_0032_R032_RSV1 0x9 314 + 315 + /* ADF4377 REG0033 Bit Definition */ 316 + #define ADF4377_0033_R033_RSV1 0x18 317 + 318 + /* ADF4377 REG0034 Bit Definition */ 319 + #define ADF4377_0034_R034_RSV1 0x08 320 + 321 + /* ADF4377 REG003A Bit Definition */ 322 + #define ADF4377_003A_R03A_RSV1 0x5D 323 + 324 + /* ADF4377 REG003B Bit Definition */ 325 + #define ADF4377_003B_R03B_RSV1 0x2B 326 + 327 + /* ADF4377 REG003D Map */ 328 + #define ADF4377_003D_O_VCO_BAND_MSK BIT(3) 329 + #define ADF4377_003D_O_VCO_CORE_MSK BIT(2) 330 + #define ADF4377_003D_O_VCO_BIAS_MSK BIT(1) 331 + 332 + /* ADF4377 REG003D Bit Definition */ 333 + #define ADF4377_003D_O_VCO_BAND_VCO_CALIB 0x0 334 + #define ADF4377_003D_O_VCO_BAND_M_VCO 0x1 335 + 336 + #define ADF4377_003D_O_VCO_CORE_VCO_CALIB 0x0 337 + #define ADF4377_003D_O_VCO_CORE_M_VCO 0x1 338 + 339 + #define ADF4377_003D_O_VCO_BIAS_VCO_CALIB 0x0 340 + #define ADF4377_003D_O_VCO_BIAS_M_VCO 0x1 341 + 342 + /* ADF4377 REG0042 Map */ 343 + #define ADF4377_0042_R042_RSV1 0x05 344 + 345 + /* ADF4377 REG0045 Map */ 346 + #define ADF4377_0045_ADC_ST_CNV_MSK BIT(0) 347 + 348 + /* ADF4377 REG0049 Map */ 349 + #define ADF4377_0049_EN_CLK2_MSK BIT(7) 350 + #define ADF4377_0049_EN_CLK1_MSK BIT(6) 351 + #define ADF4377_0049_REF_OK_MSK BIT(3) 352 + #define ADF4377_0049_ADC_BUSY_MSK BIT(2) 353 + #define ADF4377_0049_FSM_BUSY_MSK BIT(1) 354 + #define ADF4377_0049_LOCKED_MSK BIT(0) 355 + 356 + /* ADF4377 REG004B Map */ 357 + #define ADF4377_004B_VCO_CORE_MSK GENMASK(1, 0) 358 + 359 + /* ADF4377 REG004C Map */ 360 + #define ADF4377_004C_CHIP_TEMP_LSB_MSK GENMASK(7, 0) 361 + 362 + /* ADF4377 REG004D Map */ 363 + #define ADF4377_004D_CHIP_TEMP_MSB_MSK BIT(0) 364 + 365 + /* ADF4377 REG004F Map */ 366 + #define ADF4377_004F_VCO_BAND_MSK GENMASK(7, 0) 367 + 368 + /* ADF4377 REG0051 Map */ 369 + #define ADF4377_0051_VCO_BIAS_MSK GENMASK(3, 0) 370 + 371 + /* ADF4377 REG0054 Map */ 372 + #define ADF4377_0054_CHIP_VERSION_MSK GENMASK(7, 0) 373 + 374 + /* Specifications */ 375 + #define ADF4377_SPI_READ_CMD BIT(7) 376 + #define ADF4377_MAX_VCO_FREQ (12800ULL * HZ_PER_MHZ) 377 + #define ADF4377_MIN_VCO_FREQ (6400ULL * HZ_PER_MHZ) 378 + #define ADF4377_MAX_REFIN_FREQ (1000 * HZ_PER_MHZ) 379 + #define ADF4377_MIN_REFIN_FREQ (10 * HZ_PER_MHZ) 380 + #define ADF4377_MAX_FREQ_PFD (500 * HZ_PER_MHZ) 381 + #define ADF4377_MIN_FREQ_PFD (3 * HZ_PER_MHZ) 382 + #define ADF4377_MAX_CLKPN_FREQ ADF4377_MAX_VCO_FREQ 383 + #define ADF4377_MIN_CLKPN_FREQ (ADF4377_MIN_VCO_FREQ / 8) 384 + #define ADF4377_FREQ_PFD_80MHZ (80 * HZ_PER_MHZ) 385 + #define ADF4377_FREQ_PFD_125MHZ (125 * HZ_PER_MHZ) 386 + #define ADF4377_FREQ_PFD_160MHZ (160 * HZ_PER_MHZ) 387 + #define ADF4377_FREQ_PFD_250MHZ (250 * HZ_PER_MHZ) 388 + #define ADF4377_FREQ_PFD_320MHZ (320 * HZ_PER_MHZ) 389 + 390 + enum { 391 + ADF4377_FREQ, 392 + }; 393 + 394 + enum muxout_select_mode { 395 + ADF4377_MUXOUT_HIGH_Z = 0x0, 396 + ADF4377_MUXOUT_LKDET = 0x1, 397 + ADF4377_MUXOUT_LOW = 0x2, 398 + ADF4377_MUXOUT_DIV_RCLK_2 = 0x4, 399 + ADF4377_MUXOUT_DIV_NCLK_2 = 0x5, 400 + ADF4377_MUXOUT_HIGH = 0x8, 401 + }; 402 + 403 + struct adf4377_state { 404 + struct spi_device *spi; 405 + struct regmap *regmap; 406 + struct clk *clkin; 407 + /* Protect against concurrent accesses to the device and data content */ 408 + struct mutex lock; 409 + struct notifier_block nb; 410 + /* Reference Divider */ 411 + unsigned int ref_div_factor; 412 + /* PFD Frequency */ 413 + unsigned int f_pfd; 414 + /* Input Reference Clock */ 415 + unsigned int clkin_freq; 416 + /* CLKOUT Divider */ 417 + u8 clkout_div_sel; 418 + /* Feedback Divider (N) */ 419 + u16 n_int; 420 + u16 synth_lock_timeout; 421 + u16 vco_alc_timeout; 422 + u16 adc_clk_div; 423 + u16 vco_band_div; 424 + u8 dclk_div1; 425 + u8 dclk_div2; 426 + u8 dclk_mode; 427 + unsigned int f_div_rclk; 428 + enum muxout_select_mode muxout_select; 429 + struct gpio_desc *gpio_ce; 430 + struct gpio_desc *gpio_enclk1; 431 + struct gpio_desc *gpio_enclk2; 432 + u8 buf[2] __aligned(IIO_DMA_MINALIGN); 433 + }; 434 + 435 + static const char * const adf4377_muxout_modes[] = { 436 + [ADF4377_MUXOUT_HIGH_Z] = "high_z", 437 + [ADF4377_MUXOUT_LKDET] = "lock_detect", 438 + [ADF4377_MUXOUT_LOW] = "muxout_low", 439 + [ADF4377_MUXOUT_DIV_RCLK_2] = "f_div_rclk_2", 440 + [ADF4377_MUXOUT_DIV_NCLK_2] = "f_div_nclk_2", 441 + [ADF4377_MUXOUT_HIGH] = "muxout_high", 442 + }; 443 + 444 + static const struct reg_sequence adf4377_reg_defaults[] = { 445 + { 0x42, ADF4377_0042_R042_RSV1 }, 446 + { 0x3B, ADF4377_003B_R03B_RSV1 }, 447 + { 0x3A, ADF4377_003A_R03A_RSV1 }, 448 + { 0x34, ADF4377_0034_R034_RSV1 }, 449 + { 0x33, ADF4377_0033_R033_RSV1 }, 450 + { 0x32, ADF4377_0032_R032_RSV1 }, 451 + { 0x31, ADF4377_0031_R031_RSV1 }, 452 + { 0x2C, ADF4377_002C_R02C_RSV1 }, 453 + { 0x25, ADF4377_0025_R025_RSV1 }, 454 + { 0x23, ADF4377_0023_R023_RSV1 }, 455 + { 0x22, ADF4377_0022_R022_RSV1 }, 456 + { 0x21, ADF4377_0021_R021_RSV1 }, 457 + { 0x1f, ADF4377_001F_R01F_RSV1 }, 458 + { 0x1c, ADF4377_001C_R01C_RSV1 }, 459 + }; 460 + 461 + static const struct regmap_config adf4377_regmap_config = { 462 + .reg_bits = 16, 463 + .val_bits = 8, 464 + .read_flag_mask = BIT(7), 465 + .max_register = 0x54, 466 + }; 467 + 468 + static int adf4377_reg_access(struct iio_dev *indio_dev, 469 + unsigned int reg, 470 + unsigned int write_val, 471 + unsigned int *read_val) 472 + { 473 + struct adf4377_state *st = iio_priv(indio_dev); 474 + 475 + if (read_val) 476 + return regmap_read(st->regmap, reg, read_val); 477 + 478 + return regmap_write(st->regmap, reg, write_val); 479 + } 480 + 481 + static const struct iio_info adf4377_info = { 482 + .debugfs_reg_access = &adf4377_reg_access, 483 + }; 484 + 485 + static int adf4377_soft_reset(struct adf4377_state *st) 486 + { 487 + unsigned int read_val; 488 + int ret; 489 + 490 + ret = regmap_update_bits(st->regmap, 0x0, ADF4377_0000_SOFT_RESET_MSK | 491 + ADF4377_0000_SOFT_RESET_R_MSK, 492 + FIELD_PREP(ADF4377_0000_SOFT_RESET_MSK, 1) | 493 + FIELD_PREP(ADF4377_0000_SOFT_RESET_R_MSK, 1)); 494 + if (ret) 495 + return ret; 496 + 497 + return regmap_read_poll_timeout(st->regmap, 0x0, read_val, 498 + !(read_val & (ADF4377_0000_SOFT_RESET_R_MSK | 499 + ADF4377_0000_SOFT_RESET_R_MSK)), 200, 200 * 100); 500 + } 501 + 502 + static int adf4377_get_freq(struct adf4377_state *st, u64 *freq) 503 + { 504 + unsigned int ref_div_factor, n_int; 505 + u64 clkin_freq; 506 + int ret; 507 + 508 + mutex_lock(&st->lock); 509 + ret = regmap_read(st->regmap, 0x12, &ref_div_factor); 510 + if (ret) 511 + goto exit; 512 + 513 + ret = regmap_bulk_read(st->regmap, 0x10, st->buf, sizeof(st->buf)); 514 + if (ret) 515 + goto exit; 516 + 517 + clkin_freq = clk_get_rate(st->clkin); 518 + ref_div_factor = FIELD_GET(ADF4377_0012_R_DIV_MSK, ref_div_factor); 519 + n_int = FIELD_GET(ADF4377_0010_N_INT_LSB_MSK | ADF4377_0011_N_INT_MSB_MSK, 520 + get_unaligned_le16(&st->buf)); 521 + 522 + *freq = div_u64(clkin_freq, ref_div_factor) * n_int; 523 + exit: 524 + mutex_unlock(&st->lock); 525 + 526 + return ret; 527 + } 528 + 529 + static int adf4377_set_freq(struct adf4377_state *st, u64 freq) 530 + { 531 + unsigned int read_val; 532 + u64 f_vco; 533 + int ret; 534 + 535 + mutex_lock(&st->lock); 536 + 537 + if (freq > ADF4377_MAX_CLKPN_FREQ || freq < ADF4377_MIN_CLKPN_FREQ) { 538 + ret = -EINVAL; 539 + goto exit; 540 + } 541 + 542 + ret = regmap_update_bits(st->regmap, 0x1C, ADF4377_001C_EN_DNCLK_MSK | 543 + ADF4377_001C_EN_DRCLK_MSK, 544 + FIELD_PREP(ADF4377_001C_EN_DNCLK_MSK, 1) | 545 + FIELD_PREP(ADF4377_001C_EN_DRCLK_MSK, 1)); 546 + if (ret) 547 + goto exit; 548 + 549 + ret = regmap_update_bits(st->regmap, 0x11, ADF4377_0011_EN_AUTOCAL_MSK | 550 + ADF4377_0011_DCLK_DIV2_MSK, 551 + FIELD_PREP(ADF4377_0011_EN_AUTOCAL_MSK, 1) | 552 + FIELD_PREP(ADF4377_0011_DCLK_DIV2_MSK, st->dclk_div2)); 553 + if (ret) 554 + goto exit; 555 + 556 + ret = regmap_update_bits(st->regmap, 0x2E, ADF4377_002E_EN_ADC_CNV_MSK | 557 + ADF4377_002E_EN_ADC_MSK | 558 + ADF4377_002E_ADC_A_CONV_MSK, 559 + FIELD_PREP(ADF4377_002E_EN_ADC_CNV_MSK, 1) | 560 + FIELD_PREP(ADF4377_002E_EN_ADC_MSK, 1) | 561 + FIELD_PREP(ADF4377_002E_ADC_A_CONV_MSK, 562 + ADF4377_002E_ADC_A_CONV_VCO_CALIB)); 563 + if (ret) 564 + goto exit; 565 + 566 + ret = regmap_update_bits(st->regmap, 0x20, ADF4377_0020_EN_ADC_CLK_MSK, 567 + FIELD_PREP(ADF4377_0020_EN_ADC_CLK_MSK, 1)); 568 + if (ret) 569 + goto exit; 570 + 571 + ret = regmap_update_bits(st->regmap, 0x2F, ADF4377_002F_DCLK_DIV1_MSK, 572 + FIELD_PREP(ADF4377_002F_DCLK_DIV1_MSK, st->dclk_div1)); 573 + if (ret) 574 + goto exit; 575 + 576 + ret = regmap_update_bits(st->regmap, 0x24, ADF4377_0024_DCLK_MODE_MSK, 577 + FIELD_PREP(ADF4377_0024_DCLK_MODE_MSK, st->dclk_mode)); 578 + if (ret) 579 + goto exit; 580 + 581 + ret = regmap_write(st->regmap, 0x27, 582 + FIELD_PREP(ADF4377_0027_SYNTH_LOCK_TO_LSB_MSK, 583 + st->synth_lock_timeout)); 584 + if (ret) 585 + goto exit; 586 + 587 + ret = regmap_update_bits(st->regmap, 0x28, ADF4377_0028_SYNTH_LOCK_TO_MSB_MSK, 588 + FIELD_PREP(ADF4377_0028_SYNTH_LOCK_TO_MSB_MSK, 589 + st->synth_lock_timeout >> 8)); 590 + if (ret) 591 + goto exit; 592 + 593 + ret = regmap_write(st->regmap, 0x29, 594 + FIELD_PREP(ADF4377_0029_VCO_ALC_TO_LSB_MSK, 595 + st->vco_alc_timeout)); 596 + if (ret) 597 + goto exit; 598 + 599 + ret = regmap_update_bits(st->regmap, 0x2A, ADF4377_002A_VCO_ALC_TO_MSB_MSK, 600 + FIELD_PREP(ADF4377_002A_VCO_ALC_TO_MSB_MSK, 601 + st->vco_alc_timeout >> 8)); 602 + if (ret) 603 + goto exit; 604 + 605 + ret = regmap_write(st->regmap, 0x26, 606 + FIELD_PREP(ADF4377_0026_VCO_BAND_DIV_MSK, st->vco_band_div)); 607 + if (ret) 608 + goto exit; 609 + 610 + ret = regmap_write(st->regmap, 0x2D, 611 + FIELD_PREP(ADF4377_002D_ADC_CLK_DIV_MSK, st->adc_clk_div)); 612 + if (ret) 613 + goto exit; 614 + 615 + st->clkout_div_sel = 0; 616 + 617 + f_vco = freq; 618 + 619 + while (f_vco < ADF4377_MIN_VCO_FREQ) { 620 + f_vco <<= 1; 621 + st->clkout_div_sel++; 622 + } 623 + 624 + st->n_int = div_u64(freq, st->f_pfd); 625 + 626 + ret = regmap_update_bits(st->regmap, 0x11, ADF4377_0011_EN_RDBLR_MSK | 627 + ADF4377_0011_N_INT_MSB_MSK, 628 + FIELD_PREP(ADF4377_0011_EN_RDBLR_MSK, 0) | 629 + FIELD_PREP(ADF4377_0011_N_INT_MSB_MSK, st->n_int >> 8)); 630 + if (ret) 631 + goto exit; 632 + 633 + ret = regmap_update_bits(st->regmap, 0x12, ADF4377_0012_R_DIV_MSK | 634 + ADF4377_0012_CLKOUT_DIV_MSK, 635 + FIELD_PREP(ADF4377_0012_CLKOUT_DIV_MSK, st->clkout_div_sel) | 636 + FIELD_PREP(ADF4377_0012_R_DIV_MSK, st->ref_div_factor)); 637 + if (ret) 638 + goto exit; 639 + 640 + ret = regmap_write(st->regmap, 0x10, 641 + FIELD_PREP(ADF4377_0010_N_INT_LSB_MSK, st->n_int)); 642 + if (ret) 643 + goto exit; 644 + 645 + ret = regmap_read_poll_timeout(st->regmap, 0x49, read_val, 646 + !(read_val & (ADF4377_0049_FSM_BUSY_MSK)), 200, 200 * 100); 647 + if (ret) 648 + goto exit; 649 + 650 + /* Disable EN_DNCLK, EN_DRCLK */ 651 + ret = regmap_update_bits(st->regmap, 0x1C, ADF4377_001C_EN_DNCLK_MSK | 652 + ADF4377_001C_EN_DRCLK_MSK, 653 + FIELD_PREP(ADF4377_001C_EN_DNCLK_MSK, 0) | 654 + FIELD_PREP(ADF4377_001C_EN_DRCLK_MSK, 0)); 655 + if (ret) 656 + goto exit; 657 + 658 + /* Disable EN_ADC_CLK */ 659 + ret = regmap_update_bits(st->regmap, 0x20, ADF4377_0020_EN_ADC_CLK_MSK, 660 + FIELD_PREP(ADF4377_0020_EN_ADC_CLK_MSK, 0)); 661 + if (ret) 662 + goto exit; 663 + 664 + /* Set output Amplitude */ 665 + ret = regmap_update_bits(st->regmap, 0x19, ADF4377_0019_CLKOUT2_OP_MSK | 666 + ADF4377_0019_CLKOUT1_OP_MSK, 667 + FIELD_PREP(ADF4377_0019_CLKOUT1_OP_MSK, 668 + ADF4377_0019_CLKOUT_420MV) | 669 + FIELD_PREP(ADF4377_0019_CLKOUT2_OP_MSK, 670 + ADF4377_0019_CLKOUT_420MV)); 671 + 672 + exit: 673 + mutex_unlock(&st->lock); 674 + 675 + return ret; 676 + } 677 + 678 + static void adf4377_gpio_init(struct adf4377_state *st) 679 + { 680 + if (st->gpio_ce) { 681 + gpiod_set_value(st->gpio_ce, 1); 682 + 683 + /* Delay for SPI register bits to settle to their power-on reset state */ 684 + fsleep(200); 685 + } 686 + 687 + if (st->gpio_enclk1) 688 + gpiod_set_value(st->gpio_enclk1, 1); 689 + 690 + if (st->gpio_enclk2) 691 + gpiod_set_value(st->gpio_enclk2, 1); 692 + } 693 + 694 + static int adf4377_init(struct adf4377_state *st) 695 + { 696 + struct spi_device *spi = st->spi; 697 + int ret; 698 + 699 + adf4377_gpio_init(st); 700 + 701 + ret = adf4377_soft_reset(st); 702 + if (ret) { 703 + dev_err(&spi->dev, "Failed to soft reset.\n"); 704 + return ret; 705 + } 706 + 707 + ret = regmap_multi_reg_write(st->regmap, adf4377_reg_defaults, 708 + ARRAY_SIZE(adf4377_reg_defaults)); 709 + if (ret) { 710 + dev_err(&spi->dev, "Failed to set default registers.\n"); 711 + return ret; 712 + } 713 + 714 + ret = regmap_update_bits(st->regmap, 0x00, 715 + ADF4377_0000_SDO_ACTIVE_MSK | ADF4377_0000_SDO_ACTIVE_R_MSK, 716 + FIELD_PREP(ADF4377_0000_SDO_ACTIVE_MSK, 717 + ADF4377_0000_SDO_ACTIVE_SPI_4W) | 718 + FIELD_PREP(ADF4377_0000_SDO_ACTIVE_R_MSK, 719 + ADF4377_0000_SDO_ACTIVE_SPI_4W)); 720 + if (ret) { 721 + dev_err(&spi->dev, "Failed to set 4-Wire Operation.\n"); 722 + return ret; 723 + } 724 + 725 + st->clkin_freq = clk_get_rate(st->clkin); 726 + 727 + /* Power Up */ 728 + ret = regmap_write(st->regmap, 0x1a, 729 + FIELD_PREP(ADF4377_001A_PD_ALL_MSK, 0) | 730 + FIELD_PREP(ADF4377_001A_PD_RDIV_MSK, 0) | 731 + FIELD_PREP(ADF4377_001A_PD_NDIV_MSK, 0) | 732 + FIELD_PREP(ADF4377_001A_PD_VCO_MSK, 0) | 733 + FIELD_PREP(ADF4377_001A_PD_LD_MSK, 0) | 734 + FIELD_PREP(ADF4377_001A_PD_PFDCP_MSK, 0) | 735 + FIELD_PREP(ADF4377_001A_PD_CLKOUT1_MSK, 0) | 736 + FIELD_PREP(ADF4377_001A_PD_CLKOUT2_MSK, 0)); 737 + if (ret) { 738 + dev_err(&spi->dev, "Failed to set power down registers.\n"); 739 + return ret; 740 + } 741 + 742 + /* Set Mux Output */ 743 + ret = regmap_update_bits(st->regmap, 0x1D, 744 + ADF4377_001D_MUXOUT_MSK, 745 + FIELD_PREP(ADF4377_001D_MUXOUT_MSK, st->muxout_select)); 746 + if (ret) 747 + return ret; 748 + 749 + /* Compute PFD */ 750 + st->ref_div_factor = 0; 751 + do { 752 + st->ref_div_factor++; 753 + st->f_pfd = st->clkin_freq / st->ref_div_factor; 754 + } while (st->f_pfd > ADF4377_MAX_FREQ_PFD); 755 + 756 + if (st->f_pfd > ADF4377_MAX_FREQ_PFD || st->f_pfd < ADF4377_MIN_FREQ_PFD) 757 + return -EINVAL; 758 + 759 + st->f_div_rclk = st->f_pfd; 760 + 761 + if (st->f_pfd <= ADF4377_FREQ_PFD_80MHZ) { 762 + st->dclk_div1 = ADF4377_002F_DCLK_DIV1_1; 763 + st->dclk_div2 = ADF4377_0011_DCLK_DIV2_1; 764 + st->dclk_mode = 0; 765 + } else if (st->f_pfd <= ADF4377_FREQ_PFD_125MHZ) { 766 + st->dclk_div1 = ADF4377_002F_DCLK_DIV1_1; 767 + st->dclk_div2 = ADF4377_0011_DCLK_DIV2_1; 768 + st->dclk_mode = 1; 769 + } else if (st->f_pfd <= ADF4377_FREQ_PFD_160MHZ) { 770 + st->dclk_div1 = ADF4377_002F_DCLK_DIV1_2; 771 + st->dclk_div2 = ADF4377_0011_DCLK_DIV2_1; 772 + st->dclk_mode = 0; 773 + st->f_div_rclk /= 2; 774 + } else if (st->f_pfd <= ADF4377_FREQ_PFD_250MHZ) { 775 + st->dclk_div1 = ADF4377_002F_DCLK_DIV1_2; 776 + st->dclk_div2 = ADF4377_0011_DCLK_DIV2_1; 777 + st->dclk_mode = 1; 778 + st->f_div_rclk /= 2; 779 + } else if (st->f_pfd <= ADF4377_FREQ_PFD_320MHZ) { 780 + st->dclk_div1 = ADF4377_002F_DCLK_DIV1_2; 781 + st->dclk_div2 = ADF4377_0011_DCLK_DIV2_2; 782 + st->dclk_mode = 0; 783 + st->f_div_rclk /= 4; 784 + } else { 785 + st->dclk_div1 = ADF4377_002F_DCLK_DIV1_2; 786 + st->dclk_div2 = ADF4377_0011_DCLK_DIV2_2; 787 + st->dclk_mode = 1; 788 + st->f_div_rclk /= 4; 789 + } 790 + 791 + st->synth_lock_timeout = DIV_ROUND_UP(st->f_div_rclk, 50000); 792 + st->vco_alc_timeout = DIV_ROUND_UP(st->f_div_rclk, 20000); 793 + st->vco_band_div = DIV_ROUND_UP(st->f_div_rclk, 150000 * 16 * (1 << st->dclk_mode)); 794 + st->adc_clk_div = DIV_ROUND_UP((st->f_div_rclk / 400000 - 2), 4); 795 + 796 + return 0; 797 + } 798 + 799 + static ssize_t adf4377_read(struct iio_dev *indio_dev, uintptr_t private, 800 + const struct iio_chan_spec *chan, char *buf) 801 + { 802 + struct adf4377_state *st = iio_priv(indio_dev); 803 + u64 val = 0; 804 + int ret; 805 + 806 + switch ((u32)private) { 807 + case ADF4377_FREQ: 808 + ret = adf4377_get_freq(st, &val); 809 + if (ret) 810 + return ret; 811 + 812 + return sysfs_emit(buf, "%llu\n", val); 813 + default: 814 + return -EINVAL; 815 + } 816 + } 817 + 818 + static ssize_t adf4377_write(struct iio_dev *indio_dev, uintptr_t private, 819 + const struct iio_chan_spec *chan, const char *buf, 820 + size_t len) 821 + { 822 + struct adf4377_state *st = iio_priv(indio_dev); 823 + unsigned long long freq; 824 + int ret; 825 + 826 + switch ((u32)private) { 827 + case ADF4377_FREQ: 828 + ret = kstrtoull(buf, 10, &freq); 829 + if (ret) 830 + return ret; 831 + 832 + ret = adf4377_set_freq(st, freq); 833 + if (ret) 834 + return ret; 835 + 836 + return len; 837 + default: 838 + return -EINVAL; 839 + } 840 + } 841 + 842 + #define _ADF4377_EXT_INFO(_name, _shared, _ident) { \ 843 + .name = _name, \ 844 + .read = adf4377_read, \ 845 + .write = adf4377_write, \ 846 + .private = _ident, \ 847 + .shared = _shared, \ 848 + } 849 + 850 + static const struct iio_chan_spec_ext_info adf4377_ext_info[] = { 851 + /* 852 + * Usually we use IIO_CHAN_INFO_FREQUENCY, but there are 853 + * values > 2^32 in order to support the entire frequency range 854 + * in Hz. 855 + */ 856 + _ADF4377_EXT_INFO("frequency", IIO_SEPARATE, ADF4377_FREQ), 857 + { } 858 + }; 859 + 860 + static const struct iio_chan_spec adf4377_channels[] = { 861 + { 862 + .type = IIO_ALTVOLTAGE, 863 + .indexed = 1, 864 + .output = 1, 865 + .channel = 0, 866 + .ext_info = adf4377_ext_info, 867 + }, 868 + }; 869 + 870 + static int adf4377_properties_parse(struct adf4377_state *st) 871 + { 872 + struct spi_device *spi = st->spi; 873 + const char *str; 874 + int ret; 875 + 876 + st->clkin = devm_clk_get_enabled(&spi->dev, "ref_in"); 877 + if (IS_ERR(st->clkin)) 878 + return dev_err_probe(&spi->dev, PTR_ERR(st->clkin), 879 + "failed to get the reference input clock\n"); 880 + 881 + st->gpio_ce = devm_gpiod_get_optional(&st->spi->dev, "chip-enable", 882 + GPIOD_OUT_LOW); 883 + if (IS_ERR(st->gpio_ce)) 884 + return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_ce), 885 + "failed to get the CE GPIO\n"); 886 + 887 + st->gpio_enclk1 = devm_gpiod_get_optional(&st->spi->dev, "clk1-enable", 888 + GPIOD_OUT_LOW); 889 + if (IS_ERR(st->gpio_enclk1)) 890 + return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk1), 891 + "failed to get the CE GPIO\n"); 892 + 893 + st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable", 894 + GPIOD_OUT_LOW); 895 + if (IS_ERR(st->gpio_enclk2)) 896 + return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2), 897 + "failed to get the CE GPIO\n"); 898 + 899 + ret = device_property_read_string(&spi->dev, "adi,muxout-select", &str); 900 + if (ret) { 901 + st->muxout_select = ADF4377_MUXOUT_HIGH_Z; 902 + } else { 903 + ret = match_string(adf4377_muxout_modes, ARRAY_SIZE(adf4377_muxout_modes), str); 904 + if (ret < 0) 905 + return ret; 906 + 907 + st->muxout_select = ret; 908 + } 909 + 910 + return 0; 911 + } 912 + 913 + static int adf4377_freq_change(struct notifier_block *nb, unsigned long action, void *data) 914 + { 915 + struct adf4377_state *st = container_of(nb, struct adf4377_state, nb); 916 + int ret; 917 + 918 + if (action == POST_RATE_CHANGE) { 919 + mutex_lock(&st->lock); 920 + ret = notifier_from_errno(adf4377_init(st)); 921 + mutex_unlock(&st->lock); 922 + return ret; 923 + } 924 + 925 + return NOTIFY_OK; 926 + } 927 + 928 + static int adf4377_probe(struct spi_device *spi) 929 + { 930 + struct iio_dev *indio_dev; 931 + struct regmap *regmap; 932 + struct adf4377_state *st; 933 + int ret; 934 + 935 + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 936 + if (!indio_dev) 937 + return -ENOMEM; 938 + 939 + regmap = devm_regmap_init_spi(spi, &adf4377_regmap_config); 940 + if (IS_ERR(regmap)) 941 + return PTR_ERR(regmap); 942 + 943 + st = iio_priv(indio_dev); 944 + 945 + indio_dev->info = &adf4377_info; 946 + indio_dev->name = "adf4377"; 947 + indio_dev->channels = adf4377_channels; 948 + indio_dev->num_channels = ARRAY_SIZE(adf4377_channels); 949 + 950 + st->regmap = regmap; 951 + st->spi = spi; 952 + mutex_init(&st->lock); 953 + 954 + ret = adf4377_properties_parse(st); 955 + if (ret) 956 + return ret; 957 + 958 + st->nb.notifier_call = adf4377_freq_change; 959 + ret = devm_clk_notifier_register(&spi->dev, st->clkin, &st->nb); 960 + if (ret) 961 + return ret; 962 + 963 + ret = adf4377_init(st); 964 + if (ret) 965 + return ret; 966 + 967 + return devm_iio_device_register(&spi->dev, indio_dev); 968 + } 969 + 970 + static const struct spi_device_id adf4377_id[] = { 971 + { "adf4377", 0 }, 972 + {} 973 + }; 974 + MODULE_DEVICE_TABLE(spi, adf4377_id); 975 + 976 + static const struct of_device_id adf4377_of_match[] = { 977 + { .compatible = "adi,adf4377" }, 978 + {} 979 + }; 980 + MODULE_DEVICE_TABLE(of, adf4377_of_match); 981 + 982 + static struct spi_driver adf4377_driver = { 983 + .driver = { 984 + .name = "adf4377", 985 + .of_match_table = adf4377_of_match, 986 + }, 987 + .probe = adf4377_probe, 988 + .id_table = adf4377_id, 989 + }; 990 + module_spi_driver(adf4377_driver); 991 + 992 + MODULE_AUTHOR("Antoniu Miclaus <antoniu.miclaus@analog.com>"); 993 + MODULE_DESCRIPTION("Analog Devices ADF4377"); 994 + MODULE_LICENSE("GPL");
+1 -1
drivers/iio/gyro/adis16136.c
··· 429 429 uint16_t prod_id; 430 430 int ret; 431 431 432 - ret = adis_initial_startup(&adis16136->adis); 432 + ret = __adis_initial_startup(&adis16136->adis); 433 433 if (ret) 434 434 return ret; 435 435
+1 -1
drivers/iio/gyro/adis16260.c
··· 395 395 return ret; 396 396 397 397 /* Get the device into a sane initial state */ 398 - ret = adis_initial_startup(&adis16260->adis); 398 + ret = __adis_initial_startup(&adis16260->adis); 399 399 if (ret) 400 400 return ret; 401 401
+3 -3
drivers/iio/gyro/bmg160_i2c.c
··· 13 13 .max_register = 0x3f 14 14 }; 15 15 16 - static int bmg160_i2c_probe(struct i2c_client *client, 17 - const struct i2c_device_id *id) 16 + static int bmg160_i2c_probe(struct i2c_client *client) 18 17 { 18 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 19 19 struct regmap *regmap; 20 20 const char *name = NULL; 21 21 ··· 70 70 .of_match_table = bmg160_of_match, 71 71 .pm = &bmg160_pm_ops, 72 72 }, 73 - .probe = bmg160_i2c_probe, 73 + .probe_new = bmg160_i2c_probe, 74 74 .remove = bmg160_i2c_remove, 75 75 .id_table = bmg160_i2c_id, 76 76 };
+2 -3
drivers/iio/gyro/itg3200_core.c
··· 295 295 296 296 static const unsigned long itg3200_available_scan_masks[] = { 0xffffffff, 0x0 }; 297 297 298 - static int itg3200_probe(struct i2c_client *client, 299 - const struct i2c_device_id *id) 298 + static int itg3200_probe(struct i2c_client *client) 300 299 { 301 300 int ret; 302 301 struct itg3200 *st; ··· 405 406 .pm = pm_sleep_ptr(&itg3200_pm_ops), 406 407 }, 407 408 .id_table = itg3200_id, 408 - .probe = itg3200_probe, 409 + .probe_new = itg3200_probe, 409 410 .remove = itg3200_remove, 410 411 }; 411 412
+3 -3
drivers/iio/gyro/mpu3050-i2c.c
··· 32 32 return 0; 33 33 } 34 34 35 - static int mpu3050_i2c_probe(struct i2c_client *client, 36 - const struct i2c_device_id *id) 35 + static int mpu3050_i2c_probe(struct i2c_client *client) 37 36 { 37 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 38 38 struct regmap *regmap; 39 39 const char *name; 40 40 struct mpu3050 *mpu3050; ··· 108 108 MODULE_DEVICE_TABLE(of, mpu3050_i2c_of_match); 109 109 110 110 static struct i2c_driver mpu3050_i2c_driver = { 111 - .probe = mpu3050_i2c_probe, 111 + .probe_new = mpu3050_i2c_probe, 112 112 .remove = mpu3050_i2c_remove, 113 113 .id_table = mpu3050_i2c_id, 114 114 .driver = {
+2 -3
drivers/iio/gyro/st_gyro_i2c.c
··· 58 58 }; 59 59 MODULE_DEVICE_TABLE(of, st_gyro_of_match); 60 60 61 - static int st_gyro_i2c_probe(struct i2c_client *client, 62 - const struct i2c_device_id *id) 61 + static int st_gyro_i2c_probe(struct i2c_client *client) 63 62 { 64 63 const struct st_sensor_settings *settings; 65 64 struct st_sensor_data *gdata; ··· 111 112 .name = "st-gyro-i2c", 112 113 .of_match_table = st_gyro_of_match, 113 114 }, 114 - .probe = st_gyro_i2c_probe, 115 + .probe_new = st_gyro_i2c_probe, 115 116 .id_table = st_gyro_id_table, 116 117 }; 117 118 module_i2c_driver(st_gyro_driver);
+2 -3
drivers/iio/health/afe4404.c
··· 459 459 static DEFINE_SIMPLE_DEV_PM_OPS(afe4404_pm_ops, afe4404_suspend, 460 460 afe4404_resume); 461 461 462 - static int afe4404_probe(struct i2c_client *client, 463 - const struct i2c_device_id *id) 462 + static int afe4404_probe(struct i2c_client *client) 464 463 { 465 464 struct iio_dev *indio_dev; 466 465 struct afe4404_data *afe; ··· 607 608 .of_match_table = afe4404_of_match, 608 609 .pm = pm_sleep_ptr(&afe4404_pm_ops), 609 610 }, 610 - .probe = afe4404_probe, 611 + .probe_new = afe4404_probe, 611 612 .remove = afe4404_remove, 612 613 .id_table = afe4404_ids, 613 614 };
+2 -3
drivers/iio/health/max30100.c
··· 417 417 .read_raw = max30100_read_raw, 418 418 }; 419 419 420 - static int max30100_probe(struct i2c_client *client, 421 - const struct i2c_device_id *id) 420 + static int max30100_probe(struct i2c_client *client) 422 421 { 423 422 struct max30100_data *data; 424 423 struct iio_dev *indio_dev; ··· 499 500 .name = MAX30100_DRV_NAME, 500 501 .of_match_table = max30100_dt_ids, 501 502 }, 502 - .probe = max30100_probe, 503 + .probe_new = max30100_probe, 503 504 .remove = max30100_remove, 504 505 .id_table = max30100_id, 505 506 };
+3 -3
drivers/iio/health/max30102.c
··· 513 513 .read_raw = max30102_read_raw, 514 514 }; 515 515 516 - static int max30102_probe(struct i2c_client *client, 517 - const struct i2c_device_id *id) 516 + static int max30102_probe(struct i2c_client *client) 518 517 { 518 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 519 519 struct max30102_data *data; 520 520 struct iio_dev *indio_dev; 521 521 int ret; ··· 631 631 .name = MAX30102_DRV_NAME, 632 632 .of_match_table = max30102_dt_ids, 633 633 }, 634 - .probe = max30102_probe, 634 + .probe_new = max30102_probe, 635 635 .remove = max30102_remove, 636 636 .id_table = max30102_id, 637 637 };
+2 -3
drivers/iio/humidity/am2315.c
··· 218 218 .read_raw = am2315_read_raw, 219 219 }; 220 220 221 - static int am2315_probe(struct i2c_client *client, 222 - const struct i2c_device_id *id) 221 + static int am2315_probe(struct i2c_client *client) 223 222 { 224 223 int ret; 225 224 struct iio_dev *indio_dev; ··· 262 263 .driver = { 263 264 .name = "am2315", 264 265 }, 265 - .probe = am2315_probe, 266 + .probe_new = am2315_probe, 266 267 .id_table = am2315_i2c_id, 267 268 }; 268 269
+2 -3
drivers/iio/humidity/hdc100x.c
··· 351 351 .attrs = &hdc100x_attribute_group, 352 352 }; 353 353 354 - static int hdc100x_probe(struct i2c_client *client, 355 - const struct i2c_device_id *id) 354 + static int hdc100x_probe(struct i2c_client *client) 356 355 { 357 356 struct iio_dev *indio_dev; 358 357 struct hdc100x_data *data; ··· 428 429 .of_match_table = hdc100x_dt_ids, 429 430 .acpi_match_table = hdc100x_acpi_match, 430 431 }, 431 - .probe = hdc100x_probe, 432 + .probe_new = hdc100x_probe, 432 433 .id_table = hdc100x_id, 433 434 }; 434 435 module_i2c_driver(hdc100x_driver);
+2 -3
drivers/iio/humidity/hdc2010.c
··· 251 251 .attrs = &hdc2010_attribute_group, 252 252 }; 253 253 254 - static int hdc2010_probe(struct i2c_client *client, 255 - const struct i2c_device_id *id) 254 + static int hdc2010_probe(struct i2c_client *client) 256 255 { 257 256 struct iio_dev *indio_dev; 258 257 struct hdc2010_data *data; ··· 338 339 .name = "hdc2010", 339 340 .of_match_table = hdc2010_dt_ids, 340 341 }, 341 - .probe = hdc2010_probe, 342 + .probe_new = hdc2010_probe, 342 343 .remove = hdc2010_remove, 343 344 .id_table = hdc2010_id, 344 345 };
+2 -3
drivers/iio/humidity/hts221_i2c.c
··· 25 25 .read_flag_mask = HTS221_I2C_AUTO_INCREMENT, 26 26 }; 27 27 28 - static int hts221_i2c_probe(struct i2c_client *client, 29 - const struct i2c_device_id *id) 28 + static int hts221_i2c_probe(struct i2c_client *client) 30 29 { 31 30 struct regmap *regmap; 32 31 ··· 65 66 .of_match_table = hts221_i2c_of_match, 66 67 .acpi_match_table = ACPI_PTR(hts221_acpi_match), 67 68 }, 68 - .probe = hts221_i2c_probe, 69 + .probe_new = hts221_i2c_probe, 69 70 .id_table = hts221_i2c_id_table, 70 71 }; 71 72 module_i2c_driver(hts221_driver);
+3 -3
drivers/iio/humidity/htu21.c
··· 177 177 .attrs = &htu21_attribute_group, 178 178 }; 179 179 180 - static int htu21_probe(struct i2c_client *client, 181 - const struct i2c_device_id *id) 180 + static int htu21_probe(struct i2c_client *client) 182 181 { 182 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 183 183 struct ms_ht_dev *dev_data; 184 184 struct iio_dev *indio_dev; 185 185 int ret; ··· 244 244 MODULE_DEVICE_TABLE(of, htu21_of_match); 245 245 246 246 static struct i2c_driver htu21_driver = { 247 - .probe = htu21_probe, 247 + .probe_new = htu21_probe, 248 248 .id_table = htu21_id, 249 249 .driver = { 250 250 .name = "htu21",
+2 -3
drivers/iio/humidity/si7005.c
··· 123 123 .read_raw = si7005_read_raw, 124 124 }; 125 125 126 - static int si7005_probe(struct i2c_client *client, 127 - const struct i2c_device_id *id) 126 + static int si7005_probe(struct i2c_client *client) 128 127 { 129 128 struct iio_dev *indio_dev; 130 129 struct si7005_data *data; ··· 173 174 .driver = { 174 175 .name = "si7005", 175 176 }, 176 - .probe = si7005_probe, 177 + .probe_new = si7005_probe, 177 178 .id_table = si7005_id, 178 179 }; 179 180 module_i2c_driver(si7005_driver);
+2 -3
drivers/iio/humidity/si7020.c
··· 103 103 .read_raw = si7020_read_raw, 104 104 }; 105 105 106 - static int si7020_probe(struct i2c_client *client, 107 - const struct i2c_device_id *id) 106 + static int si7020_probe(struct i2c_client *client) 108 107 { 109 108 struct iio_dev *indio_dev; 110 109 struct i2c_client **data; ··· 155 156 .name = "si7020", 156 157 .of_match_table = si7020_dt_ids, 157 158 }, 158 - .probe = si7020_probe, 159 + .probe_new = si7020_probe, 159 160 .id_table = si7020_id, 160 161 }; 161 162
+10 -18
drivers/iio/imu/adis.c
··· 270 270 #endif 271 271 272 272 /** 273 - * adis_enable_irq() - Enable or disable data ready IRQ 273 + * __adis_enable_irq() - Enable or disable data ready IRQ (unlocked) 274 274 * @adis: The adis device 275 275 * @enable: Whether to enable the IRQ 276 276 * 277 277 * Returns 0 on success, negative error code otherwise 278 278 */ 279 - int adis_enable_irq(struct adis *adis, bool enable) 279 + int __adis_enable_irq(struct adis *adis, bool enable) 280 280 { 281 - int ret = 0; 281 + int ret; 282 282 u16 msc; 283 283 284 - mutex_lock(&adis->state_lock); 285 - 286 - if (adis->data->enable_irq) { 287 - ret = adis->data->enable_irq(adis, enable); 288 - goto out_unlock; 289 - } 284 + if (adis->data->enable_irq) 285 + return adis->data->enable_irq(adis, enable); 290 286 291 287 if (adis->data->unmasked_drdy) { 292 288 if (enable) ··· 290 294 else 291 295 disable_irq(adis->spi->irq); 292 296 293 - goto out_unlock; 297 + return 0; 294 298 } 295 299 296 300 ret = __adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc); 297 301 if (ret) 298 - goto out_unlock; 302 + return ret; 299 303 300 304 msc |= ADIS_MSC_CTRL_DATA_RDY_POL_HIGH; 301 305 msc &= ~ADIS_MSC_CTRL_DATA_RDY_DIO2; ··· 304 308 else 305 309 msc &= ~ADIS_MSC_CTRL_DATA_RDY_EN; 306 310 307 - ret = __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc); 308 - 309 - out_unlock: 310 - mutex_unlock(&adis->state_lock); 311 - return ret; 311 + return __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc); 312 312 } 313 - EXPORT_SYMBOL_NS(adis_enable_irq, IIO_ADISLIB); 313 + EXPORT_SYMBOL_NS(__adis_enable_irq, IIO_ADISLIB); 314 314 315 315 /** 316 316 * __adis_check_status() - Check the device for error conditions (unlocked) ··· 437 445 * with 'IRQF_NO_AUTOEN' anyways. 438 446 */ 439 447 if (!adis->data->unmasked_drdy) 440 - adis_enable_irq(adis, false); 448 + __adis_enable_irq(adis, false); 441 449 442 450 if (!adis->data->prod_id_reg) 443 451 return 0;
+1 -1
drivers/iio/imu/adis16400.c
··· 445 445 st->adis.spi->mode = SPI_MODE_3; 446 446 spi_setup(st->adis.spi); 447 447 448 - ret = adis_initial_startup(&st->adis); 448 + ret = __adis_initial_startup(&st->adis); 449 449 if (ret) 450 450 return ret; 451 451
+3 -3
drivers/iio/imu/bmi160/bmi160_i2c.c
··· 15 15 16 16 #include "bmi160.h" 17 17 18 - static int bmi160_i2c_probe(struct i2c_client *client, 19 - const struct i2c_device_id *id) 18 + static int bmi160_i2c_probe(struct i2c_client *client) 20 19 { 20 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 21 21 struct regmap *regmap; 22 22 const char *name; 23 23 ··· 60 60 .acpi_match_table = bmi160_acpi_match, 61 61 .of_match_table = bmi160_of_match, 62 62 }, 63 - .probe = bmi160_i2c_probe, 63 + .probe_new = bmi160_i2c_probe, 64 64 .id_table = bmi160_i2c_id, 65 65 }; 66 66 module_i2c_driver(bmi160_i2c_driver);
+3 -3
drivers/iio/imu/fxos8700_i2c.c
··· 18 18 19 19 #include "fxos8700.h" 20 20 21 - static int fxos8700_i2c_probe(struct i2c_client *client, 22 - const struct i2c_device_id *id) 21 + static int fxos8700_i2c_probe(struct i2c_client *client) 23 22 { 23 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 24 24 struct regmap *regmap; 25 25 const char *name = NULL; 26 26 ··· 60 60 .acpi_match_table = ACPI_PTR(fxos8700_acpi_match), 61 61 .of_match_table = fxos8700_of_match, 62 62 }, 63 - .probe = fxos8700_i2c_probe, 63 + .probe_new = fxos8700_i2c_probe, 64 64 .id_table = fxos8700_i2c_id, 65 65 }; 66 66 module_i2c_driver(fxos8700_i2c_driver);
+3 -4
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
··· 91 91 /** 92 92 * inv_mpu_probe() - probe function. 93 93 * @client: i2c client. 94 - * @id: i2c device id. 95 94 * 96 95 * Returns 0 on success, a negative error code otherwise. 97 96 */ 98 - static int inv_mpu_probe(struct i2c_client *client, 99 - const struct i2c_device_id *id) 97 + static int inv_mpu_probe(struct i2c_client *client) 100 98 { 99 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 101 100 const void *match; 102 101 struct inv_mpu6050_state *st; 103 102 int result; ··· 259 260 MODULE_DEVICE_TABLE(acpi, inv_acpi_match); 260 261 261 262 static struct i2c_driver inv_mpu_driver = { 262 - .probe = inv_mpu_probe, 263 + .probe_new = inv_mpu_probe, 263 264 .remove = inv_mpu_remove, 264 265 .id_table = inv_mpu_id, 265 266 .driver = {
+3 -3
drivers/iio/imu/kmx61.c
··· 1276 1276 return trig; 1277 1277 } 1278 1278 1279 - static int kmx61_probe(struct i2c_client *client, 1280 - const struct i2c_device_id *id) 1279 + static int kmx61_probe(struct i2c_client *client) 1281 1280 { 1281 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1282 1282 int ret; 1283 1283 struct kmx61_data *data; 1284 1284 const char *name = NULL; ··· 1517 1517 .acpi_match_table = ACPI_PTR(kmx61_acpi_match), 1518 1518 .pm = pm_ptr(&kmx61_pm_ops), 1519 1519 }, 1520 - .probe = kmx61_probe, 1520 + .probe_new = kmx61_probe, 1521 1521 .remove = kmx61_remove, 1522 1522 .id_table = kmx61_id, 1523 1523 };
+2 -2
drivers/iio/imu/st_lsm6dsx/Kconfig
··· 13 13 sensor. Supported devices: lsm6ds3, lsm6ds3h, lsm6dsl, lsm6dsm, 14 14 ism330dlc, lsm6dso, lsm6dsox, asm330lhh, asm330lhhx, lsm6dsr, 15 15 lsm6ds3tr-c, ism330dhcx, lsm6dsrx, lsm6ds0, lsm6dsop, lsm6dstx, 16 - lsm6dsv, lsm6dsv16x, the accelerometer/gyroscope of lsm9ds1 17 - and lsm6dst. 16 + lsm6dsv, lsm6dsv16x, lsm6dso16is, ism330is, lsm6dst and the 17 + accelerometer/gyroscope of lsm9ds1. 18 18 19 19 To compile this driver as a module, choose M here: the module 20 20 will be called st_lsm6dsx.
+4
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
··· 35 35 #define ST_LSM6DSTX_DEV_NAME "lsm6dstx" 36 36 #define ST_LSM6DSV_DEV_NAME "lsm6dsv" 37 37 #define ST_LSM6DSV16X_DEV_NAME "lsm6dsv16x" 38 + #define ST_LSM6DSO16IS_DEV_NAME "lsm6dso16is" 39 + #define ST_ISM330IS_DEV_NAME "ism330is" 38 40 39 41 enum st_lsm6dsx_hw_id { 40 42 ST_LSM6DS3_ID, ··· 59 57 ST_LSM6DSTX_ID, 60 58 ST_LSM6DSV_ID, 61 59 ST_LSM6DSV16X_ID, 60 + ST_LSM6DSO16IS_ID, 61 + ST_ISM330IS_ID, 62 62 ST_LSM6DSX_MAX_ID, 63 63 }; 64 64
+131 -1
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
··· 27 27 * - FIFO size: 4KB 28 28 * 29 29 * - LSM6DSO/LSM6DSOX/ASM330LHH/ASM330LHHX/LSM6DSR/ISM330DHCX/LSM6DST/LSM6DSOP/ 30 - * LSM6DSTX: 30 + * LSM6DSTX/LSM6DSO16IS/ISM330IS: 31 31 * - Accelerometer/Gyroscope supported ODR [Hz]: 12.5, 26, 52, 104, 208, 416, 32 32 * 833 33 33 * - Accelerometer supported full-scale [g]: +-2/+-4/+-8/+-16 ··· 1373 1373 .wakeup_src_z_mask = BIT(0), 1374 1374 .wakeup_src_y_mask = BIT(1), 1375 1375 .wakeup_src_x_mask = BIT(2), 1376 + }, 1377 + }, 1378 + { 1379 + .reset = { 1380 + .addr = 0x12, 1381 + .mask = BIT(0), 1382 + }, 1383 + .boot = { 1384 + .addr = 0x12, 1385 + .mask = BIT(7), 1386 + }, 1387 + .bdu = { 1388 + .addr = 0x12, 1389 + .mask = BIT(6), 1390 + }, 1391 + .id = { 1392 + { 1393 + .hw_id = ST_LSM6DSO16IS_ID, 1394 + .name = ST_LSM6DSO16IS_DEV_NAME, 1395 + .wai = 0x22, 1396 + }, { 1397 + .hw_id = ST_ISM330IS_ID, 1398 + .name = ST_ISM330IS_DEV_NAME, 1399 + .wai = 0x22, 1400 + } 1401 + }, 1402 + .channels = { 1403 + [ST_LSM6DSX_ID_ACC] = { 1404 + .chan = st_lsm6dsx_acc_channels, 1405 + .len = ARRAY_SIZE(st_lsm6dsx_acc_channels), 1406 + }, 1407 + [ST_LSM6DSX_ID_GYRO] = { 1408 + .chan = st_lsm6dsx_gyro_channels, 1409 + .len = ARRAY_SIZE(st_lsm6dsx_gyro_channels), 1410 + }, 1411 + }, 1412 + .odr_table = { 1413 + [ST_LSM6DSX_ID_ACC] = { 1414 + .reg = { 1415 + .addr = 0x10, 1416 + .mask = GENMASK(7, 4), 1417 + }, 1418 + .odr_avl[0] = { 12500, 0x01 }, 1419 + .odr_avl[1] = { 26000, 0x02 }, 1420 + .odr_avl[2] = { 52000, 0x03 }, 1421 + .odr_avl[3] = { 104000, 0x04 }, 1422 + .odr_avl[4] = { 208000, 0x05 }, 1423 + .odr_avl[5] = { 416000, 0x06 }, 1424 + .odr_avl[6] = { 833000, 0x07 }, 1425 + .odr_len = 7, 1426 + }, 1427 + [ST_LSM6DSX_ID_GYRO] = { 1428 + .reg = { 1429 + .addr = 0x11, 1430 + .mask = GENMASK(7, 4), 1431 + }, 1432 + .odr_avl[0] = { 12500, 0x01 }, 1433 + .odr_avl[1] = { 26000, 0x02 }, 1434 + .odr_avl[2] = { 52000, 0x03 }, 1435 + .odr_avl[3] = { 104000, 0x04 }, 1436 + .odr_avl[4] = { 208000, 0x05 }, 1437 + .odr_avl[5] = { 416000, 0x06 }, 1438 + .odr_avl[6] = { 833000, 0x07 }, 1439 + .odr_len = 7, 1440 + }, 1441 + }, 1442 + .fs_table = { 1443 + [ST_LSM6DSX_ID_ACC] = { 1444 + .reg = { 1445 + .addr = 0x10, 1446 + .mask = GENMASK(3, 2), 1447 + }, 1448 + .fs_avl[0] = { IIO_G_TO_M_S_2(61000), 0x0 }, 1449 + .fs_avl[1] = { IIO_G_TO_M_S_2(122000), 0x2 }, 1450 + .fs_avl[2] = { IIO_G_TO_M_S_2(244000), 0x3 }, 1451 + .fs_avl[3] = { IIO_G_TO_M_S_2(488000), 0x1 }, 1452 + .fs_len = 4, 1453 + }, 1454 + [ST_LSM6DSX_ID_GYRO] = { 1455 + .reg = { 1456 + .addr = 0x11, 1457 + .mask = GENMASK(3, 2), 1458 + }, 1459 + .fs_avl[0] = { IIO_DEGREE_TO_RAD(8750000), 0x0 }, 1460 + .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500000), 0x1 }, 1461 + .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000000), 0x2 }, 1462 + .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000000), 0x3 }, 1463 + .fs_len = 4, 1464 + }, 1465 + }, 1466 + .irq_config = { 1467 + .hla = { 1468 + .addr = 0x12, 1469 + .mask = BIT(5), 1470 + }, 1471 + .od = { 1472 + .addr = 0x12, 1473 + .mask = BIT(4), 1474 + }, 1475 + }, 1476 + .shub_settings = { 1477 + .page_mux = { 1478 + .addr = 0x01, 1479 + .mask = BIT(6), 1480 + }, 1481 + .master_en = { 1482 + .sec_page = true, 1483 + .addr = 0x14, 1484 + .mask = BIT(2), 1485 + }, 1486 + .pullup_en = { 1487 + .sec_page = true, 1488 + .addr = 0x14, 1489 + .mask = BIT(3), 1490 + }, 1491 + .aux_sens = { 1492 + .addr = 0x14, 1493 + .mask = GENMASK(1, 0), 1494 + }, 1495 + .wr_once = { 1496 + .addr = 0x14, 1497 + .mask = BIT(6), 1498 + }, 1499 + .num_ext_dev = 3, 1500 + .shub_out = { 1501 + .sec_page = true, 1502 + .addr = 0x02, 1503 + }, 1504 + .slv0_addr = 0x15, 1505 + .dw_slv0_addr = 0x21, 1376 1506 }, 1377 1507 }, 1378 1508 };
+13 -3
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
··· 21 21 .val_bits = 8, 22 22 }; 23 23 24 - static int st_lsm6dsx_i2c_probe(struct i2c_client *client, 25 - const struct i2c_device_id *id) 24 + static int st_lsm6dsx_i2c_probe(struct i2c_client *client) 26 25 { 26 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 27 27 int hw_id = id->driver_data; 28 28 struct regmap *regmap; 29 29 ··· 117 117 .compatible = "st,lsm6dsv16x", 118 118 .data = (void *)ST_LSM6DSV16X_ID, 119 119 }, 120 + { 121 + .compatible = "st,lsm6dso16is", 122 + .data = (void *)ST_LSM6DSO16IS_ID, 123 + }, 124 + { 125 + .compatible = "st,ism330is", 126 + .data = (void *)ST_ISM330IS_ID, 127 + }, 120 128 {}, 121 129 }; 122 130 MODULE_DEVICE_TABLE(of, st_lsm6dsx_i2c_of_match); ··· 150 142 { ST_LSM6DSTX_DEV_NAME, ST_LSM6DSTX_ID }, 151 143 { ST_LSM6DSV_DEV_NAME, ST_LSM6DSV_ID }, 152 144 { ST_LSM6DSV16X_DEV_NAME, ST_LSM6DSV16X_ID }, 145 + { ST_LSM6DSO16IS_DEV_NAME, ST_LSM6DSO16IS_ID }, 146 + { ST_ISM330IS_DEV_NAME, ST_ISM330IS_ID }, 153 147 {}, 154 148 }; 155 149 MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table); ··· 162 152 .pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops), 163 153 .of_match_table = st_lsm6dsx_i2c_of_match, 164 154 }, 165 - .probe = st_lsm6dsx_i2c_probe, 155 + .probe_new = st_lsm6dsx_i2c_probe, 166 156 .id_table = st_lsm6dsx_i2c_id_table, 167 157 }; 168 158 module_i2c_driver(st_lsm6dsx_driver);
+10
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
··· 117 117 .compatible = "st,lsm6dsv16x", 118 118 .data = (void *)ST_LSM6DSV16X_ID, 119 119 }, 120 + { 121 + .compatible = "st,lsm6dso16is", 122 + .data = (void *)ST_LSM6DSO16IS_ID, 123 + }, 124 + { 125 + .compatible = "st,ism330is", 126 + .data = (void *)ST_ISM330IS_ID, 127 + }, 120 128 {}, 121 129 }; 122 130 MODULE_DEVICE_TABLE(of, st_lsm6dsx_spi_of_match); ··· 150 142 { ST_LSM6DSTX_DEV_NAME, ST_LSM6DSTX_ID }, 151 143 { ST_LSM6DSV_DEV_NAME, ST_LSM6DSV_ID }, 152 144 { ST_LSM6DSV16X_DEV_NAME, ST_LSM6DSV16X_ID }, 145 + { ST_LSM6DSO16IS_DEV_NAME, ST_LSM6DSO16IS_ID }, 146 + { ST_ISM330IS_DEV_NAME, ST_ISM330IS_ID }, 153 147 {}, 154 148 }; 155 149 MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);
+2 -3
drivers/iio/light/adjd_s311.c
··· 233 233 .write_raw = adjd_s311_write_raw, 234 234 }; 235 235 236 - static int adjd_s311_probe(struct i2c_client *client, 237 - const struct i2c_device_id *id) 236 + static int adjd_s311_probe(struct i2c_client *client) 238 237 { 239 238 struct adjd_s311_data *data; 240 239 struct iio_dev *indio_dev; ··· 270 271 .driver = { 271 272 .name = ADJD_S311_DRV_NAME, 272 273 }, 273 - .probe = adjd_s311_probe, 274 + .probe_new = adjd_s311_probe, 274 275 .id_table = adjd_s311_id, 275 276 }; 276 277 module_i2c_driver(adjd_s311_driver);
+2 -3
drivers/iio/light/adux1020.c
··· 774 774 ADUX1020_MODE_INT_MASK, ADUX1020_MODE_INT_DISABLE); 775 775 } 776 776 777 - static int adux1020_probe(struct i2c_client *client, 778 - const struct i2c_device_id *id) 777 + static int adux1020_probe(struct i2c_client *client) 779 778 { 780 779 struct adux1020_data *data; 781 780 struct iio_dev *indio_dev; ··· 837 838 .name = ADUX1020_DRV_NAME, 838 839 .of_match_table = adux1020_of_match, 839 840 }, 840 - .probe = adux1020_probe, 841 + .probe_new = adux1020_probe, 841 842 .id_table = adux1020_id, 842 843 }; 843 844 module_i2c_driver(adux1020_driver);
+2 -3
drivers/iio/light/al3010.c
··· 164 164 .attrs = &al3010_attribute_group, 165 165 }; 166 166 167 - static int al3010_probe(struct i2c_client *client, 168 - const struct i2c_device_id *id) 167 + static int al3010_probe(struct i2c_client *client) 169 168 { 170 169 struct al3010_data *data; 171 170 struct iio_dev *indio_dev; ··· 229 230 .of_match_table = al3010_of_match, 230 231 .pm = pm_sleep_ptr(&al3010_pm_ops), 231 232 }, 232 - .probe = al3010_probe, 233 + .probe_new = al3010_probe, 233 234 .id_table = al3010_id, 234 235 }; 235 236 module_i2c_driver(al3010_driver);
+2 -3
drivers/iio/light/al3320a.c
··· 187 187 .attrs = &al3320a_attribute_group, 188 188 }; 189 189 190 - static int al3320a_probe(struct i2c_client *client, 191 - const struct i2c_device_id *id) 190 + static int al3320a_probe(struct i2c_client *client) 192 191 { 193 192 struct al3320a_data *data; 194 193 struct iio_dev *indio_dev; ··· 253 254 .of_match_table = al3320a_of_match, 254 255 .pm = pm_sleep_ptr(&al3320a_pm_ops), 255 256 }, 256 - .probe = al3320a_probe, 257 + .probe_new = al3320a_probe, 257 258 .id_table = al3320a_id, 258 259 }; 259 260
+2 -3
drivers/iio/light/apds9300.c
··· 398 398 return IRQ_HANDLED; 399 399 } 400 400 401 - static int apds9300_probe(struct i2c_client *client, 402 - const struct i2c_device_id *id) 401 + static int apds9300_probe(struct i2c_client *client) 403 402 { 404 403 struct apds9300_data *data; 405 404 struct iio_dev *indio_dev; ··· 504 505 .name = APDS9300_DRV_NAME, 505 506 .pm = pm_sleep_ptr(&apds9300_pm_ops), 506 507 }, 507 - .probe = apds9300_probe, 508 + .probe_new = apds9300_probe, 508 509 .remove = apds9300_remove, 509 510 .id_table = apds9300_id, 510 511 };
+2 -3
drivers/iio/light/apds9960.c
··· 988 988 return apds9960_set_powermode(data, 1); 989 989 } 990 990 991 - static int apds9960_probe(struct i2c_client *client, 992 - const struct i2c_device_id *id) 991 + static int apds9960_probe(struct i2c_client *client) 993 992 { 994 993 struct apds9960_data *data; 995 994 struct iio_dev *indio_dev; ··· 1131 1132 .pm = &apds9960_pm_ops, 1132 1133 .acpi_match_table = apds9960_acpi_match, 1133 1134 }, 1134 - .probe = apds9960_probe, 1135 + .probe_new = apds9960_probe, 1135 1136 .remove = apds9960_remove, 1136 1137 .id_table = apds9960_id, 1137 1138 };
+3 -3
drivers/iio/light/bh1750.c
··· 228 228 } 229 229 }; 230 230 231 - static int bh1750_probe(struct i2c_client *client, 232 - const struct i2c_device_id *id) 231 + static int bh1750_probe(struct i2c_client *client) 233 232 { 233 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 234 234 int ret, usec; 235 235 struct bh1750_data *data; 236 236 struct iio_dev *indio_dev; ··· 320 320 .of_match_table = bh1750_of_match, 321 321 .pm = pm_sleep_ptr(&bh1750_pm_ops), 322 322 }, 323 - .probe = bh1750_probe, 323 + .probe_new = bh1750_probe, 324 324 .remove = bh1750_remove, 325 325 .id_table = bh1750_id, 326 326
+2 -3
drivers/iio/light/bh1780.c
··· 141 141 } 142 142 }; 143 143 144 - static int bh1780_probe(struct i2c_client *client, 145 - const struct i2c_device_id *id) 144 + static int bh1780_probe(struct i2c_client *client) 146 145 { 147 146 int ret; 148 147 struct bh1780_data *bh1780; ··· 269 270 MODULE_DEVICE_TABLE(of, of_bh1780_match); 270 271 271 272 static struct i2c_driver bh1780_driver = { 272 - .probe = bh1780_probe, 273 + .probe_new = bh1780_probe, 273 274 .remove = bh1780_remove, 274 275 .id_table = bh1780_id, 275 276 .driver = {
+3 -3
drivers/iio/light/cm3232.c
··· 325 325 .attrs = &cm3232_attribute_group, 326 326 }; 327 327 328 - static int cm3232_probe(struct i2c_client *client, 329 - const struct i2c_device_id *id) 328 + static int cm3232_probe(struct i2c_client *client) 330 329 { 330 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 331 331 struct cm3232_chip *chip; 332 332 struct iio_dev *indio_dev; 333 333 int ret; ··· 417 417 .pm = pm_sleep_ptr(&cm3232_pm_ops), 418 418 }, 419 419 .id_table = cm3232_id, 420 - .probe = cm3232_probe, 420 + .probe_new = cm3232_probe, 421 421 .remove = cm3232_remove, 422 422 }; 423 423
+2 -3
drivers/iio/light/cm3323.c
··· 214 214 .attrs = &cm3323_attribute_group, 215 215 }; 216 216 217 - static int cm3323_probe(struct i2c_client *client, 218 - const struct i2c_device_id *id) 217 + static int cm3323_probe(struct i2c_client *client) 219 218 { 220 219 struct cm3323_data *data; 221 220 struct iio_dev *indio_dev; ··· 266 267 .name = CM3323_DRV_NAME, 267 268 .of_match_table = cm3323_of_match, 268 269 }, 269 - .probe = cm3323_probe, 270 + .probe_new = cm3323_probe, 270 271 .id_table = cm3323_id, 271 272 }; 272 273
+3 -3
drivers/iio/light/cm36651.c
··· 618 618 .attrs = &cm36651_attribute_group, 619 619 }; 620 620 621 - static int cm36651_probe(struct i2c_client *client, 622 - const struct i2c_device_id *id) 621 + static int cm36651_probe(struct i2c_client *client) 623 622 { 623 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 624 624 struct cm36651_data *cm36651; 625 625 struct iio_dev *indio_dev; 626 626 int ret; ··· 730 730 .name = "cm36651", 731 731 .of_match_table = cm36651_of_match, 732 732 }, 733 - .probe = cm36651_probe, 733 + .probe_new = cm36651_probe, 734 734 .remove = cm36651_remove, 735 735 .id_table = cm36651_id, 736 736 };
+2 -3
drivers/iio/light/gp2ap002.c
··· 425 425 .reg_write = gp2ap002_regmap_i2c_write, 426 426 }; 427 427 428 - static int gp2ap002_probe(struct i2c_client *client, 429 - const struct i2c_device_id *id) 428 + static int gp2ap002_probe(struct i2c_client *client) 430 429 { 431 430 struct gp2ap002 *gp2ap002; 432 431 struct iio_dev *indio_dev; ··· 710 711 .of_match_table = gp2ap002_of_match, 711 712 .pm = pm_ptr(&gp2ap002_dev_pm_ops), 712 713 }, 713 - .probe = gp2ap002_probe, 714 + .probe_new = gp2ap002_probe, 714 715 .remove = gp2ap002_remove, 715 716 .id_table = gp2ap002_id_table, 716 717 };
+3 -3
drivers/iio/light/gp2ap020a00f.c
··· 1467 1467 .predisable = &gp2ap020a00f_buffer_predisable, 1468 1468 }; 1469 1469 1470 - static int gp2ap020a00f_probe(struct i2c_client *client, 1471 - const struct i2c_device_id *id) 1470 + static int gp2ap020a00f_probe(struct i2c_client *client) 1472 1471 { 1472 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1473 1473 struct gp2ap020a00f_data *data; 1474 1474 struct iio_dev *indio_dev; 1475 1475 struct regmap *regmap; ··· 1609 1609 .name = GP2A_I2C_NAME, 1610 1610 .of_match_table = gp2ap020a00f_of_match, 1611 1611 }, 1612 - .probe = gp2ap020a00f_probe, 1612 + .probe_new = gp2ap020a00f_probe, 1613 1613 .remove = gp2ap020a00f_remove, 1614 1614 .id_table = gp2ap020a00f_id, 1615 1615 };
+3 -3
drivers/iio/light/isl29018.c
··· 711 711 pr_err("failed to disable isl29018's VCC regulator!\n"); 712 712 } 713 713 714 - static int isl29018_probe(struct i2c_client *client, 715 - const struct i2c_device_id *id) 714 + static int isl29018_probe(struct i2c_client *client) 716 715 { 716 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 717 717 struct isl29018_chip *chip; 718 718 struct iio_dev *indio_dev; 719 719 int err; ··· 865 865 .pm = pm_sleep_ptr(&isl29018_pm_ops), 866 866 .of_match_table = isl29018_of_match, 867 867 }, 868 - .probe = isl29018_probe, 868 + .probe_new = isl29018_probe, 869 869 .id_table = isl29018_id, 870 870 }; 871 871 module_i2c_driver(isl29018_driver);
+3 -3
drivers/iio/light/isl29028.c
··· 565 565 .cache_type = REGCACHE_RBTREE, 566 566 }; 567 567 568 - static int isl29028_probe(struct i2c_client *client, 569 - const struct i2c_device_id *id) 568 + static int isl29028_probe(struct i2c_client *client) 570 569 { 570 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 571 571 struct isl29028_chip *chip; 572 572 struct iio_dev *indio_dev; 573 573 int ret; ··· 698 698 .pm = pm_ptr(&isl29028_pm_ops), 699 699 .of_match_table = isl29028_of_match, 700 700 }, 701 - .probe = isl29028_probe, 701 + .probe_new = isl29028_probe, 702 702 .remove = isl29028_remove, 703 703 .id_table = isl29028_id, 704 704 };
+2 -3
drivers/iio/light/isl29125.c
··· 241 241 .predisable = isl29125_buffer_predisable, 242 242 }; 243 243 244 - static int isl29125_probe(struct i2c_client *client, 245 - const struct i2c_device_id *id) 244 + static int isl29125_probe(struct i2c_client *client) 246 245 { 247 246 struct isl29125_data *data; 248 247 struct iio_dev *indio_dev; ··· 337 338 .name = ISL29125_DRV_NAME, 338 339 .pm = pm_sleep_ptr(&isl29125_pm_ops), 339 340 }, 340 - .probe = isl29125_probe, 341 + .probe_new = isl29125_probe, 341 342 .remove = isl29125_remove, 342 343 .id_table = isl29125_id, 343 344 };
+2 -3
drivers/iio/light/jsa1212.c
··· 308 308 .volatile_reg = jsa1212_is_volatile_reg, 309 309 }; 310 310 311 - static int jsa1212_probe(struct i2c_client *client, 312 - const struct i2c_device_id *id) 311 + static int jsa1212_probe(struct i2c_client *client) 313 312 { 314 313 struct jsa1212_data *data; 315 314 struct iio_dev *indio_dev; ··· 440 441 .pm = pm_sleep_ptr(&jsa1212_pm_ops), 441 442 .acpi_match_table = ACPI_PTR(jsa1212_acpi_match), 442 443 }, 443 - .probe = jsa1212_probe, 444 + .probe_new = jsa1212_probe, 444 445 .remove = jsa1212_remove, 445 446 .id_table = jsa1212_id, 446 447 };
+3 -3
drivers/iio/light/ltr501.c
··· 1432 1432 return dev_name(dev); 1433 1433 } 1434 1434 1435 - static int ltr501_probe(struct i2c_client *client, 1436 - const struct i2c_device_id *id) 1435 + static int ltr501_probe(struct i2c_client *client) 1437 1436 { 1437 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1438 1438 static const char * const regulator_names[] = { "vdd", "vddio" }; 1439 1439 struct ltr501_data *data; 1440 1440 struct iio_dev *indio_dev; ··· 1641 1641 .pm = pm_sleep_ptr(&ltr501_pm_ops), 1642 1642 .acpi_match_table = ACPI_PTR(ltr_acpi_match), 1643 1643 }, 1644 - .probe = ltr501_probe, 1644 + .probe_new = ltr501_probe, 1645 1645 .remove = ltr501_remove, 1646 1646 .id_table = ltr501_id, 1647 1647 };
+2 -3
drivers/iio/light/lv0104cs.c
··· 474 474 }, 475 475 }; 476 476 477 - static int lv0104cs_probe(struct i2c_client *client, 478 - const struct i2c_device_id *id) 477 + static int lv0104cs_probe(struct i2c_client *client) 479 478 { 480 479 struct iio_dev *indio_dev; 481 480 struct lv0104cs_private *lv0104cs; ··· 520 521 .name = "lv0104cs", 521 522 }, 522 523 .id_table = lv0104cs_id, 523 - .probe = lv0104cs_probe, 524 + .probe_new = lv0104cs_probe, 524 525 }; 525 526 module_i2c_driver(lv0104cs_i2c_driver); 526 527
+2 -3
drivers/iio/light/max44000.c
··· 523 523 return IRQ_HANDLED; 524 524 } 525 525 526 - static int max44000_probe(struct i2c_client *client, 527 - const struct i2c_device_id *id) 526 + static int max44000_probe(struct i2c_client *client) 528 527 { 529 528 struct max44000_data *data; 530 529 struct iio_dev *indio_dev; ··· 616 617 .name = MAX44000_DRV_NAME, 617 618 .acpi_match_table = ACPI_PTR(max44000_acpi_match), 618 619 }, 619 - .probe = max44000_probe, 620 + .probe_new = max44000_probe, 620 621 .id_table = max44000_id, 621 622 }; 622 623
+2 -3
drivers/iio/light/noa1305.c
··· 186 186 .writeable_reg = noa1305_writable_reg, 187 187 }; 188 188 189 - static int noa1305_probe(struct i2c_client *client, 190 - const struct i2c_device_id *id) 189 + static int noa1305_probe(struct i2c_client *client) 191 190 { 192 191 struct noa1305_priv *priv; 193 192 struct iio_dev *indio_dev; ··· 278 279 .name = NOA1305_DRIVER_NAME, 279 280 .of_match_table = noa1305_of_match, 280 281 }, 281 - .probe = noa1305_probe, 282 + .probe_new = noa1305_probe, 282 283 .id_table = noa1305_ids, 283 284 }; 284 285
+2 -3
drivers/iio/light/opt3001.c
··· 735 735 return IRQ_HANDLED; 736 736 } 737 737 738 - static int opt3001_probe(struct i2c_client *client, 739 - const struct i2c_device_id *id) 738 + static int opt3001_probe(struct i2c_client *client) 740 739 { 741 740 struct device *dev = &client->dev; 742 741 ··· 834 835 MODULE_DEVICE_TABLE(of, opt3001_of_match); 835 836 836 837 static struct i2c_driver opt3001_driver = { 837 - .probe = opt3001_probe, 838 + .probe_new = opt3001_probe, 838 839 .remove = opt3001_remove, 839 840 .id_table = opt3001_id, 840 841
+2 -3
drivers/iio/light/pa12203001.c
··· 338 338 return ret; 339 339 } 340 340 341 - static int pa12203001_probe(struct i2c_client *client, 342 - const struct i2c_device_id *id) 341 + static int pa12203001_probe(struct i2c_client *client) 343 342 { 344 343 struct pa12203001_data *data; 345 344 struct iio_dev *indio_dev; ··· 474 475 .pm = &pa12203001_pm_ops, 475 476 .acpi_match_table = ACPI_PTR(pa12203001_acpi_match), 476 477 }, 477 - .probe = pa12203001_probe, 478 + .probe_new = pa12203001_probe, 478 479 .remove = pa12203001_remove, 479 480 .id_table = pa12203001_id, 480 481
+2 -3
drivers/iio/light/rpr0521.c
··· 927 927 .volatile_reg = rpr0521_is_volatile_reg, 928 928 }; 929 929 930 - static int rpr0521_probe(struct i2c_client *client, 931 - const struct i2c_device_id *id) 930 + static int rpr0521_probe(struct i2c_client *client) 932 931 { 933 932 struct rpr0521_data *data; 934 933 struct iio_dev *indio_dev; ··· 1121 1122 .pm = pm_ptr(&rpr0521_pm_ops), 1122 1123 .acpi_match_table = ACPI_PTR(rpr0521_acpi_match), 1123 1124 }, 1124 - .probe = rpr0521_probe, 1125 + .probe_new = rpr0521_probe, 1125 1126 .remove = rpr0521_remove, 1126 1127 .id_table = rpr0521_id, 1127 1128 };
+3 -3
drivers/iio/light/si1133.c
··· 990 990 return 0; 991 991 } 992 992 993 - static int si1133_probe(struct i2c_client *client, 994 - const struct i2c_device_id *id) 993 + static int si1133_probe(struct i2c_client *client) 995 994 { 995 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 996 996 struct si1133_data *data; 997 997 struct iio_dev *iio_dev; 998 998 int err; ··· 1064 1064 .driver = { 1065 1065 .name = "si1133", 1066 1066 }, 1067 - .probe = si1133_probe, 1067 + .probe_new = si1133_probe, 1068 1068 .id_table = si1133_ids, 1069 1069 }; 1070 1070
+3 -3
drivers/iio/light/si1145.c
··· 1269 1269 return 0; 1270 1270 } 1271 1271 1272 - static int si1145_probe(struct i2c_client *client, 1273 - const struct i2c_device_id *id) 1272 + static int si1145_probe(struct i2c_client *client) 1274 1273 { 1274 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1275 1275 struct si1145_data *data; 1276 1276 struct iio_dev *indio_dev; 1277 1277 u8 part_id, rev_id, seq_id; ··· 1352 1352 .driver = { 1353 1353 .name = "si1145", 1354 1354 }, 1355 - .probe = si1145_probe, 1355 + .probe_new = si1145_probe, 1356 1356 .id_table = si1145_ids, 1357 1357 }; 1358 1358
+2 -3
drivers/iio/light/st_uvis25_i2c.c
··· 25 25 .read_flag_mask = UVIS25_I2C_AUTO_INCREMENT, 26 26 }; 27 27 28 - static int st_uvis25_i2c_probe(struct i2c_client *client, 29 - const struct i2c_device_id *id) 28 + static int st_uvis25_i2c_probe(struct i2c_client *client) 30 29 { 31 30 struct regmap *regmap; 32 31 ··· 57 58 .pm = pm_sleep_ptr(&st_uvis25_pm_ops), 58 59 .of_match_table = st_uvis25_i2c_of_match, 59 60 }, 60 - .probe = st_uvis25_i2c_probe, 61 + .probe_new = st_uvis25_i2c_probe, 61 62 .id_table = st_uvis25_i2c_id_table, 62 63 }; 63 64 module_i2c_driver(st_uvis25_driver);
+2 -3
drivers/iio/light/stk3310.c
··· 586 586 return IRQ_HANDLED; 587 587 } 588 588 589 - static int stk3310_probe(struct i2c_client *client, 590 - const struct i2c_device_id *id) 589 + static int stk3310_probe(struct i2c_client *client) 591 590 { 592 591 int ret; 593 592 struct iio_dev *indio_dev; ··· 714 715 .pm = pm_sleep_ptr(&stk3310_pm_ops), 715 716 .acpi_match_table = ACPI_PTR(stk3310_acpi_id), 716 717 }, 717 - .probe = stk3310_probe, 718 + .probe_new = stk3310_probe, 718 719 .remove = stk3310_remove, 719 720 .id_table = stk3310_i2c_id, 720 721 };
+2 -3
drivers/iio/light/tcs3414.c
··· 279 279 tcs3414_powerdown(data); 280 280 } 281 281 282 - static int tcs3414_probe(struct i2c_client *client, 283 - const struct i2c_device_id *id) 282 + static int tcs3414_probe(struct i2c_client *client) 284 283 { 285 284 struct tcs3414_data *data; 286 285 struct iio_dev *indio_dev; ··· 373 374 .name = TCS3414_DRV_NAME, 374 375 .pm = pm_sleep_ptr(&tcs3414_pm_ops), 375 376 }, 376 - .probe = tcs3414_probe, 377 + .probe_new = tcs3414_probe, 377 378 .id_table = tcs3414_id, 378 379 }; 379 380 module_i2c_driver(tcs3414_driver);
+2 -3
drivers/iio/light/tcs3472.c
··· 442 442 .attrs = &tcs3472_attribute_group, 443 443 }; 444 444 445 - static int tcs3472_probe(struct i2c_client *client, 446 - const struct i2c_device_id *id) 445 + static int tcs3472_probe(struct i2c_client *client) 447 446 { 448 447 struct tcs3472_data *data; 449 448 struct iio_dev *indio_dev; ··· 609 610 .name = TCS3472_DRV_NAME, 610 611 .pm = pm_sleep_ptr(&tcs3472_pm_ops), 611 612 }, 612 - .probe = tcs3472_probe, 613 + .probe_new = tcs3472_probe, 613 614 .remove = tcs3472_remove, 614 615 .id_table = tcs3472_id, 615 616 };
+2 -3
drivers/iio/light/tsl2563.c
··· 699 699 .write_event_config = &tsl2563_write_interrupt_config, 700 700 }; 701 701 702 - static int tsl2563_probe(struct i2c_client *client, 703 - const struct i2c_device_id *device_id) 702 + static int tsl2563_probe(struct i2c_client *client) 704 703 { 705 704 struct iio_dev *indio_dev; 706 705 struct tsl2563_chip *chip; ··· 879 880 .of_match_table = tsl2563_of_match, 880 881 .pm = pm_sleep_ptr(&tsl2563_pm_ops), 881 882 }, 882 - .probe = tsl2563_probe, 883 + .probe_new = tsl2563_probe, 883 884 .remove = tsl2563_remove, 884 885 .id_table = tsl2563_id, 885 886 };
+2 -3
drivers/iio/light/tsl2583.c
··· 809 809 .write_raw = tsl2583_write_raw, 810 810 }; 811 811 812 - static int tsl2583_probe(struct i2c_client *clientp, 813 - const struct i2c_device_id *idp) 812 + static int tsl2583_probe(struct i2c_client *clientp) 814 813 { 815 814 int ret; 816 815 struct tsl2583_chip *chip; ··· 942 943 .of_match_table = tsl2583_of_match, 943 944 }, 944 945 .id_table = tsl2583_idtable, 945 - .probe = tsl2583_probe, 946 + .probe_new = tsl2583_probe, 946 947 .remove = tsl2583_remove, 947 948 }; 948 949 module_i2c_driver(tsl2583_driver);
+3 -3
drivers/iio/light/tsl2772.c
··· 1750 1750 }, 1751 1751 }; 1752 1752 1753 - static int tsl2772_probe(struct i2c_client *clientp, 1754 - const struct i2c_device_id *id) 1753 + static int tsl2772_probe(struct i2c_client *clientp) 1755 1754 { 1755 + const struct i2c_device_id *id = i2c_client_get_device_id(clientp); 1756 1756 struct iio_dev *indio_dev; 1757 1757 struct tsl2772_chip *chip; 1758 1758 int ret; ··· 1931 1931 .pm = &tsl2772_pm_ops, 1932 1932 }, 1933 1933 .id_table = tsl2772_idtable, 1934 - .probe = tsl2772_probe, 1934 + .probe_new = tsl2772_probe, 1935 1935 }; 1936 1936 1937 1937 module_i2c_driver(tsl2772_driver);
+2 -3
drivers/iio/light/tsl4531.c
··· 160 160 } 161 161 } 162 162 163 - static int tsl4531_probe(struct i2c_client *client, 164 - const struct i2c_device_id *id) 163 + static int tsl4531_probe(struct i2c_client *client) 165 164 { 166 165 struct tsl4531_data *data; 167 166 struct iio_dev *indio_dev; ··· 237 238 .name = TSL4531_DRV_NAME, 238 239 .pm = pm_sleep_ptr(&tsl4531_pm_ops), 239 240 }, 240 - .probe = tsl4531_probe, 241 + .probe_new = tsl4531_probe, 241 242 .remove = tsl4531_remove, 242 243 .id_table = tsl4531_id, 243 244 };
+2 -3
drivers/iio/light/us5182d.c
··· 832 832 return IRQ_HANDLED; 833 833 } 834 834 835 - static int us5182d_probe(struct i2c_client *client, 836 - const struct i2c_device_id *id) 835 + static int us5182d_probe(struct i2c_client *client) 837 836 { 838 837 struct us5182d_data *data; 839 838 struct iio_dev *indio_dev; ··· 974 975 .of_match_table = us5182d_of_match, 975 976 .acpi_match_table = ACPI_PTR(us5182d_acpi_match), 976 977 }, 977 - .probe = us5182d_probe, 978 + .probe_new = us5182d_probe, 978 979 .remove = us5182d_remove, 979 980 .id_table = us5182d_id, 980 981
+3 -3
drivers/iio/light/vcnl4000.c
··· 1180 1180 return devm_iio_trigger_register(&client->dev, trigger); 1181 1181 } 1182 1182 1183 - static int vcnl4000_probe(struct i2c_client *client, 1184 - const struct i2c_device_id *id) 1183 + static int vcnl4000_probe(struct i2c_client *client) 1185 1184 { 1185 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1186 1186 struct vcnl4000_data *data; 1187 1187 struct iio_dev *indio_dev; 1188 1188 int ret; ··· 1326 1326 .pm = pm_ptr(&vcnl4000_pm_ops), 1327 1327 .of_match_table = vcnl_4000_of_match, 1328 1328 }, 1329 - .probe = vcnl4000_probe, 1329 + .probe_new = vcnl4000_probe, 1330 1330 .id_table = vcnl4000_id, 1331 1331 .remove = vcnl4000_remove, 1332 1332 };
+2 -3
drivers/iio/light/vcnl4035.c
··· 539 539 return ret; 540 540 } 541 541 542 - static int vcnl4035_probe(struct i2c_client *client, 543 - const struct i2c_device_id *id) 542 + static int vcnl4035_probe(struct i2c_client *client) 544 543 { 545 544 struct vcnl4035_data *data; 546 545 struct iio_dev *indio_dev; ··· 667 668 .pm = pm_ptr(&vcnl4035_pm_ops), 668 669 .of_match_table = vcnl4035_of_match, 669 670 }, 670 - .probe = vcnl4035_probe, 671 + .probe_new = vcnl4035_probe, 671 672 .remove = vcnl4035_remove, 672 673 .id_table = vcnl4035_id, 673 674 };
+2 -3
drivers/iio/light/veml6030.c
··· 786 786 return ret; 787 787 } 788 788 789 - static int veml6030_probe(struct i2c_client *client, 790 - const struct i2c_device_id *id) 789 + static int veml6030_probe(struct i2c_client *client) 791 790 { 792 791 int ret; 793 792 struct veml6030_data *data; ··· 892 893 .of_match_table = veml6030_of_match, 893 894 .pm = pm_ptr(&veml6030_pm_ops), 894 895 }, 895 - .probe = veml6030_probe, 896 + .probe_new = veml6030_probe, 896 897 .id_table = veml6030_id, 897 898 }; 898 899 module_i2c_driver(veml6030_driver);
+2 -3
drivers/iio/light/veml6070.c
··· 135 135 .read_raw = veml6070_read_raw, 136 136 }; 137 137 138 - static int veml6070_probe(struct i2c_client *client, 139 - const struct i2c_device_id *id) 138 + static int veml6070_probe(struct i2c_client *client) 140 139 { 141 140 struct veml6070_data *data; 142 141 struct iio_dev *indio_dev; ··· 198 199 .driver = { 199 200 .name = VEML6070_DRV_NAME, 200 201 }, 201 - .probe = veml6070_probe, 202 + .probe_new = veml6070_probe, 202 203 .remove = veml6070_remove, 203 204 .id_table = veml6070_id, 204 205 };
+2 -3
drivers/iio/light/zopt2201.c
··· 501 501 .attrs = &zopt2201_attribute_group, 502 502 }; 503 503 504 - static int zopt2201_probe(struct i2c_client *client, 505 - const struct i2c_device_id *id) 504 + static int zopt2201_probe(struct i2c_client *client) 506 505 { 507 506 struct zopt2201_data *data; 508 507 struct iio_dev *indio_dev; ··· 554 555 .driver = { 555 556 .name = ZOPT2201_DRV_NAME, 556 557 }, 557 - .probe = zopt2201_probe, 558 + .probe_new = zopt2201_probe, 558 559 .id_table = zopt2201_id, 559 560 }; 560 561
+2 -3
drivers/iio/magnetometer/ak8974.c
··· 814 814 .precious_reg = ak8974_precious_reg, 815 815 }; 816 816 817 - static int ak8974_probe(struct i2c_client *i2c, 818 - const struct i2c_device_id *id) 817 + static int ak8974_probe(struct i2c_client *i2c) 819 818 { 820 819 struct iio_dev *indio_dev; 821 820 struct ak8974 *ak8974; ··· 1046 1047 .pm = pm_ptr(&ak8974_dev_pm_ops), 1047 1048 .of_match_table = ak8974_of_match, 1048 1049 }, 1049 - .probe = ak8974_probe, 1050 + .probe_new = ak8974_probe, 1050 1051 .remove = ak8974_remove, 1051 1052 .id_table = ak8974_id, 1052 1053 };
+3 -3
drivers/iio/magnetometer/ak8975.c
··· 876 876 return IRQ_HANDLED; 877 877 } 878 878 879 - static int ak8975_probe(struct i2c_client *client, 880 - const struct i2c_device_id *id) 879 + static int ak8975_probe(struct i2c_client *client) 881 880 { 881 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 882 882 struct ak8975_data *data; 883 883 struct iio_dev *indio_dev; 884 884 struct gpio_desc *eoc_gpiod; ··· 1110 1110 .of_match_table = ak8975_of_match, 1111 1111 .acpi_match_table = ak_acpi_match, 1112 1112 }, 1113 - .probe = ak8975_probe, 1113 + .probe_new = ak8975_probe, 1114 1114 .remove = ak8975_remove, 1115 1115 .id_table = ak8975_id, 1116 1116 };
+3 -3
drivers/iio/magnetometer/bmc150_magn_i2c.c
··· 16 16 17 17 #include "bmc150_magn.h" 18 18 19 - static int bmc150_magn_i2c_probe(struct i2c_client *client, 20 - const struct i2c_device_id *id) 19 + static int bmc150_magn_i2c_probe(struct i2c_client *client) 21 20 { 21 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 22 22 struct regmap *regmap; 23 23 const char *name = NULL; 24 24 ··· 71 71 .acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match), 72 72 .pm = &bmc150_magn_pm_ops, 73 73 }, 74 - .probe = bmc150_magn_i2c_probe, 74 + .probe_new = bmc150_magn_i2c_probe, 75 75 .remove = bmc150_magn_i2c_remove, 76 76 .id_table = bmc150_magn_i2c_id, 77 77 };
+3 -3
drivers/iio/magnetometer/hmc5843_i2c.c
··· 52 52 .cache_type = REGCACHE_RBTREE, 53 53 }; 54 54 55 - static int hmc5843_i2c_probe(struct i2c_client *cli, 56 - const struct i2c_device_id *id) 55 + static int hmc5843_i2c_probe(struct i2c_client *cli) 57 56 { 57 + const struct i2c_device_id *id = i2c_client_get_device_id(cli); 58 58 struct regmap *regmap = devm_regmap_init_i2c(cli, 59 59 &hmc5843_i2c_regmap_config); 60 60 if (IS_ERR(regmap)) ··· 95 95 .of_match_table = hmc5843_of_match, 96 96 }, 97 97 .id_table = hmc5843_id, 98 - .probe = hmc5843_i2c_probe, 98 + .probe_new = hmc5843_i2c_probe, 99 99 .remove = hmc5843_i2c_remove, 100 100 }; 101 101 module_i2c_driver(hmc5843_driver);
+3 -3
drivers/iio/magnetometer/mag3110.c
··· 469 469 470 470 static const unsigned long mag3110_scan_masks[] = {0x7, 0xf, 0}; 471 471 472 - static int mag3110_probe(struct i2c_client *client, 473 - const struct i2c_device_id *id) 472 + static int mag3110_probe(struct i2c_client *client) 474 473 { 474 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 475 475 struct mag3110_data *data; 476 476 struct iio_dev *indio_dev; 477 477 int ret; ··· 641 641 .of_match_table = mag3110_of_match, 642 642 .pm = pm_sleep_ptr(&mag3110_pm_ops), 643 643 }, 644 - .probe = mag3110_probe, 644 + .probe_new = mag3110_probe, 645 645 .remove = mag3110_remove, 646 646 .id_table = mag3110_id, 647 647 };
+2 -3
drivers/iio/magnetometer/mmc35240.c
··· 481 481 .num_reg_defaults = ARRAY_SIZE(mmc35240_reg_defaults), 482 482 }; 483 483 484 - static int mmc35240_probe(struct i2c_client *client, 485 - const struct i2c_device_id *id) 484 + static int mmc35240_probe(struct i2c_client *client) 486 485 { 487 486 struct mmc35240_data *data; 488 487 struct iio_dev *indio_dev; ··· 575 576 .pm = pm_sleep_ptr(&mmc35240_pm_ops), 576 577 .acpi_match_table = ACPI_PTR(mmc35240_acpi_match), 577 578 }, 578 - .probe = mmc35240_probe, 579 + .probe_new = mmc35240_probe, 579 580 .id_table = mmc35240_id, 580 581 }; 581 582
+3 -3
drivers/iio/magnetometer/yamaha-yas530.c
··· 1384 1384 }, 1385 1385 }; 1386 1386 1387 - static int yas5xx_probe(struct i2c_client *i2c, 1388 - const struct i2c_device_id *id) 1387 + static int yas5xx_probe(struct i2c_client *i2c) 1389 1388 { 1389 + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 1390 1390 struct iio_dev *indio_dev; 1391 1391 struct device *dev = &i2c->dev; 1392 1392 struct yas5xx *yas5xx; ··· 1605 1605 .of_match_table = yas5xx_of_match, 1606 1606 .pm = pm_ptr(&yas5xx_dev_pm_ops), 1607 1607 }, 1608 - .probe = yas5xx_probe, 1608 + .probe_new = yas5xx_probe, 1609 1609 .remove = yas5xx_remove, 1610 1610 .id_table = yas5xx_id, 1611 1611 };
+3 -3
drivers/iio/potentiometer/ad5272.c
··· 158 158 return 0; 159 159 } 160 160 161 - static int ad5272_probe(struct i2c_client *client, 162 - const struct i2c_device_id *id) 161 + static int ad5272_probe(struct i2c_client *client) 163 162 { 163 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 164 164 struct device *dev = &client->dev; 165 165 struct iio_dev *indio_dev; 166 166 struct ad5272_data *data; ··· 218 218 .name = "ad5272", 219 219 .of_match_table = ad5272_dt_ids, 220 220 }, 221 - .probe = ad5272_probe, 221 + .probe_new = ad5272_probe, 222 222 .id_table = ad5272_id, 223 223 }; 224 224
+3 -2
drivers/iio/potentiometer/ds1803.c
··· 202 202 .read_avail = ds1803_read_avail, 203 203 }; 204 204 205 - static int ds1803_probe(struct i2c_client *client, const struct i2c_device_id *id) 205 + static int ds1803_probe(struct i2c_client *client) 206 206 { 207 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 207 208 struct device *dev = &client->dev; 208 209 struct ds1803_data *data; 209 210 struct iio_dev *indio_dev; ··· 252 251 .name = "ds1803", 253 252 .of_match_table = ds1803_dt_ids, 254 253 }, 255 - .probe = ds1803_probe, 254 + .probe_new = ds1803_probe, 256 255 .id_table = ds1803_id, 257 256 }; 258 257
+2 -3
drivers/iio/potentiometer/max5432.c
··· 85 85 .write_raw = max5432_write_raw, 86 86 }; 87 87 88 - static int max5432_probe(struct i2c_client *client, 89 - const struct i2c_device_id *id) 88 + static int max5432_probe(struct i2c_client *client) 90 89 { 91 90 struct device *dev = &client->dev; 92 91 struct iio_dev *indio_dev; ··· 123 124 .name = "max5432", 124 125 .of_match_table = max5432_dt_ids, 125 126 }, 126 - .probe = max5432_probe, 127 + .probe_new = max5432_probe, 127 128 }; 128 129 129 130 module_i2c_driver(max5432_driver);
+3 -3
drivers/iio/potentiometer/tpl0102.c
··· 120 120 .write_raw = tpl0102_write_raw, 121 121 }; 122 122 123 - static int tpl0102_probe(struct i2c_client *client, 124 - const struct i2c_device_id *id) 123 + static int tpl0102_probe(struct i2c_client *client) 125 124 { 125 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 126 126 struct device *dev = &client->dev; 127 127 struct tpl0102_data *data; 128 128 struct iio_dev *indio_dev; ··· 161 161 .driver = { 162 162 .name = "tpl0102", 163 163 }, 164 - .probe = tpl0102_probe, 164 + .probe_new = tpl0102_probe, 165 165 .id_table = tpl0102_id, 166 166 }; 167 167
+2 -3
drivers/iio/potentiostat/lmp91000.c
··· 292 292 .predisable = lmp91000_buffer_predisable, 293 293 }; 294 294 295 - static int lmp91000_probe(struct i2c_client *client, 296 - const struct i2c_device_id *id) 295 + static int lmp91000_probe(struct i2c_client *client) 297 296 { 298 297 struct device *dev = &client->dev; 299 298 struct lmp91000_data *data; ··· 416 417 .name = LMP91000_DRV_NAME, 417 418 .of_match_table = lmp91000_of_match, 418 419 }, 419 - .probe = lmp91000_probe, 420 + .probe_new = lmp91000_probe, 420 421 .remove = lmp91000_remove, 421 422 .id_table = lmp91000_id, 422 423 };
+3 -3
drivers/iio/pressure/abp060mg.c
··· 174 174 state->offset -= ABP060MG_NUM_COUNTS >> 1; 175 175 } 176 176 177 - static int abp060mg_probe(struct i2c_client *client, 178 - const struct i2c_device_id *id) 177 + static int abp060mg_probe(struct i2c_client *client) 179 178 { 179 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 180 180 struct iio_dev *indio_dev; 181 181 struct abp_state *state; 182 182 unsigned long cfg_id = id->driver_data; ··· 255 255 .driver = { 256 256 .name = "abp060mg", 257 257 }, 258 - .probe = abp060mg_probe, 258 + .probe_new = abp060mg_probe, 259 259 .id_table = abp060mg_id_table, 260 260 }; 261 261 module_i2c_driver(abp060mg_driver);
+3 -3
drivers/iio/pressure/dlhl60d.c
··· 282 282 return IRQ_HANDLED; 283 283 }; 284 284 285 - static int dlh_probe(struct i2c_client *client, 286 - const struct i2c_device_id *id) 285 + static int dlh_probe(struct i2c_client *client) 287 286 { 287 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 288 288 struct dlh_state *st; 289 289 struct iio_dev *indio_dev; 290 290 int ret; ··· 362 362 .name = "dlhl60d", 363 363 .of_match_table = dlh_of_match, 364 364 }, 365 - .probe = dlh_probe, 365 + .probe_new = dlh_probe, 366 366 .id_table = dlh_id, 367 367 }; 368 368 module_i2c_driver(dlh_driver);
+3 -3
drivers/iio/pressure/dps310.c
··· 827 827 .write_raw = dps310_write_raw, 828 828 }; 829 829 830 - static int dps310_probe(struct i2c_client *client, 831 - const struct i2c_device_id *id) 830 + static int dps310_probe(struct i2c_client *client) 832 831 { 832 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 833 833 struct dps310_data *data; 834 834 struct iio_dev *iio; 835 835 int rc; ··· 887 887 .name = DPS310_DEV_NAME, 888 888 .acpi_match_table = dps310_acpi_match, 889 889 }, 890 - .probe = dps310_probe, 890 + .probe_new = dps310_probe, 891 891 .id_table = dps310_id, 892 892 }; 893 893 module_i2c_driver(dps310_driver);
+3 -3
drivers/iio/pressure/hp03.c
··· 208 208 .read_raw = &hp03_read_raw, 209 209 }; 210 210 211 - static int hp03_probe(struct i2c_client *client, 212 - const struct i2c_device_id *id) 211 + static int hp03_probe(struct i2c_client *client) 213 212 { 213 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 214 214 struct device *dev = &client->dev; 215 215 struct iio_dev *indio_dev; 216 216 struct hp03_priv *priv; ··· 282 282 .name = "hp03", 283 283 .of_match_table = hp03_of_match, 284 284 }, 285 - .probe = hp03_probe, 285 + .probe_new = hp03_probe, 286 286 .id_table = hp03_id, 287 287 }; 288 288 module_i2c_driver(hp03_driver);
+3 -3
drivers/iio/pressure/hp206c.c
··· 352 352 .write_raw = hp206c_write_raw, 353 353 }; 354 354 355 - static int hp206c_probe(struct i2c_client *client, 356 - const struct i2c_device_id *id) 355 + static int hp206c_probe(struct i2c_client *client) 357 356 { 357 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 358 358 struct iio_dev *indio_dev; 359 359 struct hp206c_data *data; 360 360 int ret; ··· 409 409 #endif 410 410 411 411 static struct i2c_driver hp206c_driver = { 412 - .probe = hp206c_probe, 412 + .probe_new = hp206c_probe, 413 413 .id_table = hp206c_id, 414 414 .driver = { 415 415 .name = "hp206c",
+2 -3
drivers/iio/pressure/icp10100.c
··· 530 530 pm_runtime_disable(dev); 531 531 } 532 532 533 - static int icp10100_probe(struct i2c_client *client, 534 - const struct i2c_device_id *id) 533 + static int icp10100_probe(struct i2c_client *client) 535 534 { 536 535 struct iio_dev *indio_dev; 537 536 struct icp10100_state *st; ··· 648 649 .pm = pm_ptr(&icp10100_pm), 649 650 .of_match_table = icp10100_of_match, 650 651 }, 651 - .probe = icp10100_probe, 652 + .probe_new = icp10100_probe, 652 653 .id_table = icp10100_id, 653 654 }; 654 655 module_i2c_driver(icp10100_driver);
+3 -3
drivers/iio/pressure/mpl115_i2c.c
··· 35 35 .write = mpl115_i2c_write, 36 36 }; 37 37 38 - static int mpl115_i2c_probe(struct i2c_client *client, 39 - const struct i2c_device_id *id) 38 + static int mpl115_i2c_probe(struct i2c_client *client) 40 39 { 40 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 41 41 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) 42 42 return -EOPNOTSUPP; 43 43 ··· 55 55 .name = "mpl115", 56 56 .pm = pm_ptr(&mpl115_dev_pm_ops), 57 57 }, 58 - .probe = mpl115_i2c_probe, 58 + .probe_new = mpl115_i2c_probe, 59 59 .id_table = mpl115_i2c_id, 60 60 }; 61 61 module_i2c_driver(mpl115_i2c_driver);
+3 -3
drivers/iio/pressure/mpl3115.c
··· 230 230 .read_raw = &mpl3115_read_raw, 231 231 }; 232 232 233 - static int mpl3115_probe(struct i2c_client *client, 234 - const struct i2c_device_id *id) 233 + static int mpl3115_probe(struct i2c_client *client) 235 234 { 235 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 236 236 struct mpl3115_data *data; 237 237 struct iio_dev *indio_dev; 238 238 int ret; ··· 335 335 .of_match_table = mpl3115_of_match, 336 336 .pm = pm_sleep_ptr(&mpl3115_pm_ops), 337 337 }, 338 - .probe = mpl3115_probe, 338 + .probe_new = mpl3115_probe, 339 339 .remove = mpl3115_remove, 340 340 .id_table = mpl3115_id, 341 341 };
+3 -3
drivers/iio/pressure/ms5611_i2c.c
··· 79 79 return ms5611_i2c_read_adc(st, pressure); 80 80 } 81 81 82 - static int ms5611_i2c_probe(struct i2c_client *client, 83 - const struct i2c_device_id *id) 82 + static int ms5611_i2c_probe(struct i2c_client *client) 84 83 { 84 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 85 85 struct ms5611_state *st; 86 86 struct iio_dev *indio_dev; 87 87 ··· 130 130 .of_match_table = ms5611_i2c_matches, 131 131 }, 132 132 .id_table = ms5611_id, 133 - .probe = ms5611_i2c_probe, 133 + .probe_new = ms5611_i2c_probe, 134 134 .remove = ms5611_i2c_remove, 135 135 }; 136 136 module_i2c_driver(ms5611_driver);
+3 -3
drivers/iio/pressure/ms5637.c
··· 142 142 .attrs = &ms5637_attribute_group, 143 143 }; 144 144 145 - static int ms5637_probe(struct i2c_client *client, 146 - const struct i2c_device_id *id) 145 + static int ms5637_probe(struct i2c_client *client) 147 146 { 147 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 148 148 const struct ms_tp_data *data; 149 149 struct ms_tp_dev *dev_data; 150 150 struct iio_dev *indio_dev; ··· 238 238 MODULE_DEVICE_TABLE(of, ms5637_of_match); 239 239 240 240 static struct i2c_driver ms5637_driver = { 241 - .probe = ms5637_probe, 241 + .probe_new = ms5637_probe, 242 242 .id_table = ms5637_id, 243 243 .driver = { 244 244 .name = "ms5637",
+2 -3
drivers/iio/pressure/st_pressure_i2c.c
··· 76 76 }; 77 77 MODULE_DEVICE_TABLE(i2c, st_press_id_table); 78 78 79 - static int st_press_i2c_probe(struct i2c_client *client, 80 - const struct i2c_device_id *id) 79 + static int st_press_i2c_probe(struct i2c_client *client) 81 80 { 82 81 const struct st_sensor_settings *settings; 83 82 struct st_sensor_data *press_data; ··· 116 117 .of_match_table = st_press_of_match, 117 118 .acpi_match_table = ACPI_PTR(st_press_acpi_match), 118 119 }, 119 - .probe = st_press_i2c_probe, 120 + .probe_new = st_press_i2c_probe, 120 121 .id_table = st_press_id_table, 121 122 }; 122 123 module_i2c_driver(st_press_driver);
+3 -3
drivers/iio/pressure/t5403.c
··· 208 208 .attrs = &t5403_attribute_group, 209 209 }; 210 210 211 - static int t5403_probe(struct i2c_client *client, 212 - const struct i2c_device_id *id) 211 + static int t5403_probe(struct i2c_client *client) 213 212 { 213 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 214 214 struct t5403_data *data; 215 215 struct iio_dev *indio_dev; 216 216 int ret; ··· 260 260 .driver = { 261 261 .name = "t5403", 262 262 }, 263 - .probe = t5403_probe, 263 + .probe_new = t5403_probe, 264 264 .id_table = t5403_id, 265 265 }; 266 266 module_i2c_driver(t5403_driver);
+3 -3
drivers/iio/pressure/zpa2326_i2c.c
··· 38 38 (ZPA2326_SA0(client->addr) << ZPA2326_DEVICE_ID_SA0_SHIFT)); 39 39 } 40 40 41 - static int zpa2326_probe_i2c(struct i2c_client *client, 42 - const struct i2c_device_id *i2c_id) 41 + static int zpa2326_probe_i2c(struct i2c_client *client) 43 42 { 43 + const struct i2c_device_id *i2c_id = i2c_client_get_device_id(client); 44 44 struct regmap *regmap; 45 45 46 46 regmap = devm_regmap_init_i2c(client, &zpa2326_regmap_i2c_config); ··· 76 76 .of_match_table = zpa2326_i2c_matches, 77 77 .pm = ZPA2326_PM_OPS, 78 78 }, 79 - .probe = zpa2326_probe_i2c, 79 + .probe_new = zpa2326_probe_i2c, 80 80 .remove = zpa2326_remove_i2c, 81 81 .id_table = zpa2326_i2c_ids, 82 82 };
+2 -3
drivers/iio/proximity/isl29501.c
··· 949 949 return IRQ_HANDLED; 950 950 } 951 951 952 - static int isl29501_probe(struct i2c_client *client, 953 - const struct i2c_device_id *id) 952 + static int isl29501_probe(struct i2c_client *client) 954 953 { 955 954 struct iio_dev *indio_dev; 956 955 struct isl29501_private *isl29501; ··· 1008 1009 .name = "isl29501", 1009 1010 }, 1010 1011 .id_table = isl29501_id, 1011 - .probe = isl29501_probe, 1012 + .probe_new = isl29501_probe, 1012 1013 }; 1013 1014 module_i2c_driver(isl29501_driver); 1014 1015
+3 -3
drivers/iio/proximity/mb1232.c
··· 180 180 .read_raw = mb1232_read_raw, 181 181 }; 182 182 183 - static int mb1232_probe(struct i2c_client *client, 184 - const struct i2c_device_id *id) 183 + static int mb1232_probe(struct i2c_client *client) 185 184 { 185 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 186 186 struct iio_dev *indio_dev; 187 187 struct mb1232_data *data; 188 188 int ret; ··· 264 264 .name = "maxbotix-mb1232", 265 265 .of_match_table = of_mb1232_match, 266 266 }, 267 - .probe = mb1232_probe, 267 + .probe_new = mb1232_probe, 268 268 .id_table = mb1232_id, 269 269 }; 270 270 module_i2c_driver(mb1232_driver);
+2 -3
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
··· 253 253 .read_raw = lidar_read_raw, 254 254 }; 255 255 256 - static int lidar_probe(struct i2c_client *client, 257 - const struct i2c_device_id *id) 256 + static int lidar_probe(struct i2c_client *client) 258 257 { 259 258 struct lidar_data *data; 260 259 struct iio_dev *indio_dev; ··· 365 366 .of_match_table = lidar_dt_ids, 366 367 .pm = pm_ptr(&lidar_pm_ops), 367 368 }, 368 - .probe = lidar_probe, 369 + .probe_new = lidar_probe, 369 370 .remove = lidar_remove, 370 371 .id_table = lidar_id, 371 372 };
+2 -3
drivers/iio/proximity/rfd77402.c
··· 257 257 rfd77402_powerdown(client); 258 258 } 259 259 260 - static int rfd77402_probe(struct i2c_client *client, 261 - const struct i2c_device_id *id) 260 + static int rfd77402_probe(struct i2c_client *client) 262 261 { 263 262 struct rfd77402_data *data; 264 263 struct iio_dev *indio_dev; ··· 318 319 .name = RFD77402_DRV_NAME, 319 320 .pm = pm_sleep_ptr(&rfd77402_pm_ops), 320 321 }, 321 - .probe = rfd77402_probe, 322 + .probe_new = rfd77402_probe, 322 323 .id_table = rfd77402_id, 323 324 }; 324 325
+3 -3
drivers/iio/proximity/srf08.c
··· 443 443 .read_raw = srf08_read_raw, 444 444 }; 445 445 446 - static int srf08_probe(struct i2c_client *client, 447 - const struct i2c_device_id *id) 446 + static int srf08_probe(struct i2c_client *client) 448 447 { 448 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 449 449 struct iio_dev *indio_dev; 450 450 struct srf08_data *data; 451 451 int ret; ··· 549 549 .name = "srf08", 550 550 .of_match_table = of_srf08_match, 551 551 }, 552 - .probe = srf08_probe, 552 + .probe_new = srf08_probe, 553 553 .id_table = srf08_id, 554 554 }; 555 555 module_i2c_driver(srf08_driver);
+2 -3
drivers/iio/proximity/sx9500.c
··· 901 901 } 902 902 } 903 903 904 - static int sx9500_probe(struct i2c_client *client, 905 - const struct i2c_device_id *id) 904 + static int sx9500_probe(struct i2c_client *client) 906 905 { 907 906 int ret; 908 907 struct iio_dev *indio_dev; ··· 1055 1056 .of_match_table = of_match_ptr(sx9500_of_match), 1056 1057 .pm = pm_sleep_ptr(&sx9500_pm_ops), 1057 1058 }, 1058 - .probe = sx9500_probe, 1059 + .probe_new = sx9500_probe, 1059 1060 .remove = sx9500_remove, 1060 1061 .id_table = sx9500_id, 1061 1062 };
+10
drivers/iio/temperature/Kconfig
··· 128 128 This driver can also be built as a module. If so, the module will 129 129 be called tsys02d. 130 130 131 + config MAX30208 132 + tristate "Maxim MAX30208 digital temperature sensor" 133 + depends on I2C 134 + help 135 + If you say yes here you get support for Maxim MAX30208 136 + digital temperature sensor connected via I2C. 137 + 138 + This driver can also be built as a module. If so, the module 139 + will be called max30208. 140 + 131 141 config MAX31856 132 142 tristate "MAX31856 thermocouple sensor" 133 143 depends on SPI
+1
drivers/iio/temperature/Makefile
··· 7 7 obj-$(CONFIG_LTC2983) += ltc2983.o 8 8 obj-$(CONFIG_HID_SENSOR_TEMP) += hid-sensor-temperature.o 9 9 obj-$(CONFIG_MAXIM_THERMOCOUPLE) += maxim_thermocouple.o 10 + obj-$(CONFIG_MAX30208) += max30208.o 10 11 obj-$(CONFIG_MAX31856) += max31856.o 11 12 obj-$(CONFIG_MAX31865) += max31865.o 12 13 obj-$(CONFIG_MLX90614) += mlx90614.o
+252
drivers/iio/temperature/max30208.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + 3 + /* 4 + * Copyright (c) Rajat Khandelwal <rajat.khandelwal@linux.intel.com> 5 + * 6 + * Maxim MAX30208 digital temperature sensor with 0.1°C accuracy 7 + * (7-bit I2C slave address (0x50 - 0x53)) 8 + */ 9 + 10 + #include <linux/bitops.h> 11 + #include <linux/delay.h> 12 + #include <linux/iio/iio.h> 13 + #include <linux/i2c.h> 14 + #include <linux/module.h> 15 + #include <linux/types.h> 16 + 17 + #define MAX30208_STATUS 0x00 18 + #define MAX30208_STATUS_TEMP_RDY BIT(0) 19 + #define MAX30208_INT_ENABLE 0x01 20 + #define MAX30208_INT_ENABLE_TEMP_RDY BIT(0) 21 + 22 + #define MAX30208_FIFO_OVF_CNTR 0x06 23 + #define MAX30208_FIFO_DATA_CNTR 0x07 24 + #define MAX30208_FIFO_DATA 0x08 25 + 26 + #define MAX30208_FIFO_CONFIG 0x0a 27 + #define MAX30208_FIFO_CONFIG_RO BIT(1) 28 + 29 + #define MAX30208_SYSTEM_CTRL 0x0c 30 + #define MAX30208_SYSTEM_CTRL_RESET 0x01 31 + 32 + #define MAX30208_TEMP_SENSOR_SETUP 0x14 33 + #define MAX30208_TEMP_SENSOR_SETUP_CONV BIT(0) 34 + 35 + struct max30208_data { 36 + struct i2c_client *client; 37 + struct iio_dev *indio_dev; 38 + struct mutex lock; /* Lock to prevent concurrent reads of temperature readings */ 39 + }; 40 + 41 + static const struct iio_chan_spec max30208_channels[] = { 42 + { 43 + .type = IIO_TEMP, 44 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), 45 + }, 46 + }; 47 + 48 + /** 49 + * max30208_request() - Request a reading 50 + * @data: Struct comprising member elements of the device 51 + * 52 + * Requests a reading from the device and waits until the conversion is ready. 53 + */ 54 + static int max30208_request(struct max30208_data *data) 55 + { 56 + /* 57 + * Sensor can take up to 500 ms to respond so execute a total of 58 + * 10 retries to give the device sufficient time. 59 + */ 60 + int retries = 10; 61 + u8 regval; 62 + int ret; 63 + 64 + ret = i2c_smbus_read_byte_data(data->client, MAX30208_TEMP_SENSOR_SETUP); 65 + if (ret < 0) 66 + return ret; 67 + 68 + regval = ret | MAX30208_TEMP_SENSOR_SETUP_CONV; 69 + 70 + ret = i2c_smbus_write_byte_data(data->client, MAX30208_TEMP_SENSOR_SETUP, regval); 71 + if (ret) 72 + return ret; 73 + 74 + while (retries--) { 75 + ret = i2c_smbus_read_byte_data(data->client, MAX30208_STATUS); 76 + if (ret < 0) 77 + return ret; 78 + 79 + if (ret & MAX30208_STATUS_TEMP_RDY) 80 + return 0; 81 + 82 + msleep(50); 83 + } 84 + dev_err(&data->client->dev, "Temperature conversion failed\n"); 85 + 86 + return -ETIMEDOUT; 87 + } 88 + 89 + static int max30208_update_temp(struct max30208_data *data) 90 + { 91 + u8 data_count; 92 + int ret; 93 + 94 + mutex_lock(&data->lock); 95 + 96 + ret = max30208_request(data); 97 + if (ret) 98 + goto unlock; 99 + 100 + ret = i2c_smbus_read_byte_data(data->client, MAX30208_FIFO_OVF_CNTR); 101 + if (ret < 0) 102 + goto unlock; 103 + else if (!ret) { 104 + ret = i2c_smbus_read_byte_data(data->client, MAX30208_FIFO_DATA_CNTR); 105 + if (ret < 0) 106 + goto unlock; 107 + 108 + data_count = ret; 109 + } else 110 + data_count = 1; 111 + 112 + while (data_count) { 113 + ret = i2c_smbus_read_word_swapped(data->client, MAX30208_FIFO_DATA); 114 + if (ret < 0) 115 + goto unlock; 116 + 117 + data_count--; 118 + } 119 + 120 + unlock: 121 + mutex_unlock(&data->lock); 122 + return ret; 123 + } 124 + 125 + /** 126 + * max30208_config_setup() - Set up FIFO configuration register 127 + * @data: Struct comprising member elements of the device 128 + * 129 + * Sets the rollover bit to '1' to enable overwriting FIFO during overflow. 130 + */ 131 + static int max30208_config_setup(struct max30208_data *data) 132 + { 133 + u8 regval; 134 + int ret; 135 + 136 + ret = i2c_smbus_read_byte_data(data->client, MAX30208_FIFO_CONFIG); 137 + if (ret < 0) 138 + return ret; 139 + 140 + regval = ret | MAX30208_FIFO_CONFIG_RO; 141 + 142 + ret = i2c_smbus_write_byte_data(data->client, MAX30208_FIFO_CONFIG, regval); 143 + if (ret) 144 + return ret; 145 + 146 + return 0; 147 + } 148 + 149 + static int max30208_read(struct iio_dev *indio_dev, 150 + struct iio_chan_spec const *chan, 151 + int *val, int *val2, long mask) 152 + { 153 + struct max30208_data *data = iio_priv(indio_dev); 154 + int ret; 155 + 156 + switch (mask) { 157 + case IIO_CHAN_INFO_RAW: 158 + ret = max30208_update_temp(data); 159 + if (ret < 0) 160 + return ret; 161 + 162 + *val = sign_extend32(ret, 15); 163 + return IIO_VAL_INT; 164 + 165 + case IIO_CHAN_INFO_SCALE: 166 + *val = 5; 167 + return IIO_VAL_INT; 168 + 169 + default: 170 + return -EINVAL; 171 + } 172 + } 173 + 174 + static const struct iio_info max30208_info = { 175 + .read_raw = max30208_read, 176 + }; 177 + 178 + static int max30208_probe(struct i2c_client *i2c) 179 + { 180 + struct device *dev = &i2c->dev; 181 + struct max30208_data *data; 182 + struct iio_dev *indio_dev; 183 + int ret; 184 + 185 + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); 186 + if (!indio_dev) 187 + return -ENOMEM; 188 + 189 + data = iio_priv(indio_dev); 190 + data->client = i2c; 191 + mutex_init(&data->lock); 192 + 193 + indio_dev->name = "max30208"; 194 + indio_dev->channels = max30208_channels; 195 + indio_dev->num_channels = ARRAY_SIZE(max30208_channels); 196 + indio_dev->info = &max30208_info; 197 + indio_dev->modes = INDIO_DIRECT_MODE; 198 + 199 + ret = i2c_smbus_write_byte_data(data->client, MAX30208_SYSTEM_CTRL, 200 + MAX30208_SYSTEM_CTRL_RESET); 201 + if (ret) { 202 + dev_err(dev, "Failure in performing reset\n"); 203 + return ret; 204 + } 205 + 206 + msleep(50); 207 + 208 + ret = max30208_config_setup(data); 209 + if (ret) 210 + return ret; 211 + 212 + ret = devm_iio_device_register(dev, indio_dev); 213 + if (ret) { 214 + dev_err(dev, "Failed to register IIO device\n"); 215 + return ret; 216 + } 217 + 218 + return 0; 219 + } 220 + 221 + static const struct i2c_device_id max30208_id_table[] = { 222 + { "max30208" }, 223 + { } 224 + }; 225 + MODULE_DEVICE_TABLE(i2c, max30208_id_table); 226 + 227 + static const struct acpi_device_id max30208_acpi_match[] = { 228 + { "MAX30208" }, 229 + { } 230 + }; 231 + MODULE_DEVICE_TABLE(acpi, max30208_acpi_match); 232 + 233 + static const struct of_device_id max30208_of_match[] = { 234 + { .compatible = "maxim,max30208" }, 235 + { } 236 + }; 237 + MODULE_DEVICE_TABLE(of, max30208_of_match); 238 + 239 + static struct i2c_driver max30208_driver = { 240 + .driver = { 241 + .name = "max30208", 242 + .of_match_table = max30208_of_match, 243 + .acpi_match_table = max30208_acpi_match, 244 + }, 245 + .probe_new = max30208_probe, 246 + .id_table = max30208_id_table, 247 + }; 248 + module_i2c_driver(max30208_driver); 249 + 250 + MODULE_AUTHOR("Rajat Khandelwal <rajat.khandelwal@linux.intel.com>"); 251 + MODULE_DESCRIPTION("Maxim MAX30208 digital temperature sensor"); 252 + MODULE_LICENSE("GPL");
+3 -3
drivers/iio/temperature/mlx90614.c
··· 537 537 return (ret & MLX90614_CONFIG_DUAL_MASK) ? 1 : 0; 538 538 } 539 539 540 - static int mlx90614_probe(struct i2c_client *client, 541 - const struct i2c_device_id *id) 540 + static int mlx90614_probe(struct i2c_client *client) 542 541 { 542 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 543 543 struct iio_dev *indio_dev; 544 544 struct mlx90614_data *data; 545 545 int ret; ··· 675 675 .of_match_table = mlx90614_of_match, 676 676 .pm = pm_ptr(&mlx90614_pm_ops), 677 677 }, 678 - .probe = mlx90614_probe, 678 + .probe_new = mlx90614_probe, 679 679 .remove = mlx90614_remove, 680 680 .id_table = mlx90614_id, 681 681 };
+3 -3
drivers/iio/temperature/mlx90632.c
··· 1168 1168 return ret; 1169 1169 } 1170 1170 1171 - static int mlx90632_probe(struct i2c_client *client, 1172 - const struct i2c_device_id *id) 1171 + static int mlx90632_probe(struct i2c_client *client) 1173 1172 { 1173 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1174 1174 struct mlx90632_data *mlx90632; 1175 1175 struct iio_dev *indio_dev; 1176 1176 struct regmap *regmap; ··· 1337 1337 .of_match_table = mlx90632_of_match, 1338 1338 .pm = pm_ptr(&mlx90632_pm_ops), 1339 1339 }, 1340 - .probe = mlx90632_probe, 1340 + .probe_new = mlx90632_probe, 1341 1341 .id_table = mlx90632_id, 1342 1342 }; 1343 1343 module_i2c_driver(mlx90632_driver);
+2 -3
drivers/iio/temperature/tmp006.c
··· 212 212 tmp006_power(dev, false); 213 213 } 214 214 215 - static int tmp006_probe(struct i2c_client *client, 216 - const struct i2c_device_id *id) 215 + static int tmp006_probe(struct i2c_client *client) 217 216 { 218 217 struct iio_dev *indio_dev; 219 218 struct tmp006_data *data; ··· 283 284 .name = "tmp006", 284 285 .pm = pm_sleep_ptr(&tmp006_pm_ops), 285 286 }, 286 - .probe = tmp006_probe, 287 + .probe_new = tmp006_probe, 287 288 .id_table = tmp006_id, 288 289 }; 289 290 module_i2c_driver(tmp006_driver);
+3 -3
drivers/iio/temperature/tmp007.c
··· 446 446 tmp007_powerdown(data); 447 447 } 448 448 449 - static int tmp007_probe(struct i2c_client *client, 450 - const struct i2c_device_id *tmp007_id) 449 + static int tmp007_probe(struct i2c_client *client) 451 450 { 451 + const struct i2c_device_id *tmp007_id = i2c_client_get_device_id(client); 452 452 struct tmp007_data *data; 453 453 struct iio_dev *indio_dev; 454 454 int ret; ··· 574 574 .of_match_table = tmp007_of_match, 575 575 .pm = pm_sleep_ptr(&tmp007_pm_ops), 576 576 }, 577 - .probe = tmp007_probe, 577 + .probe_new = tmp007_probe, 578 578 .id_table = tmp007_id, 579 579 }; 580 580 module_i2c_driver(tmp007_driver);
+2 -3
drivers/iio/temperature/tsys01.c
··· 176 176 return devm_iio_device_register(dev, indio_dev); 177 177 } 178 178 179 - static int tsys01_i2c_probe(struct i2c_client *client, 180 - const struct i2c_device_id *id) 179 + static int tsys01_i2c_probe(struct i2c_client *client) 181 180 { 182 181 struct tsys01_dev *dev_data; 183 182 struct iio_dev *indio_dev; ··· 218 219 MODULE_DEVICE_TABLE(of, tsys01_of_match); 219 220 220 221 static struct i2c_driver tsys01_driver = { 221 - .probe = tsys01_i2c_probe, 222 + .probe_new = tsys01_i2c_probe, 222 223 .id_table = tsys01_id, 223 224 .driver = { 224 225 .name = "tsys01",
+3 -3
drivers/iio/temperature/tsys02d.c
··· 121 121 .attrs = &tsys02d_attribute_group, 122 122 }; 123 123 124 - static int tsys02d_probe(struct i2c_client *client, 125 - const struct i2c_device_id *id) 124 + static int tsys02d_probe(struct i2c_client *client) 126 125 { 126 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 127 127 struct ms_ht_dev *dev_data; 128 128 struct iio_dev *indio_dev; 129 129 int ret; ··· 174 174 MODULE_DEVICE_TABLE(i2c, tsys02d_id); 175 175 176 176 static struct i2c_driver tsys02d_driver = { 177 - .probe = tsys02d_probe, 177 + .probe_new = tsys02d_probe, 178 178 .id_table = tsys02d_id, 179 179 .driver = { 180 180 .name = "tsys02d",
+1 -1
drivers/staging/iio/accel/adis16203.c
··· 285 285 return ret; 286 286 287 287 /* Get the device into a sane initial state */ 288 - ret = adis_initial_startup(st); 288 + ret = __adis_initial_startup(st); 289 289 if (ret) 290 290 return ret; 291 291
+1 -1
drivers/staging/iio/accel/adis16240.c
··· 414 414 return ret; 415 415 416 416 /* Get the device into a sane initial state */ 417 - ret = adis_initial_startup(st); 417 + ret = __adis_initial_startup(st); 418 418 if (ret) 419 419 return ret; 420 420
+3 -3
drivers/staging/iio/addac/adt7316-i2c.c
··· 93 93 * device probe and remove 94 94 */ 95 95 96 - static int adt7316_i2c_probe(struct i2c_client *client, 97 - const struct i2c_device_id *id) 96 + static int adt7316_i2c_probe(struct i2c_client *client) 98 97 { 98 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 99 99 struct adt7316_bus bus = { 100 100 .client = client, 101 101 .irq = client->irq, ··· 138 138 .of_match_table = adt7316_of_match, 139 139 .pm = ADT7316_PM_OPS, 140 140 }, 141 - .probe = adt7316_i2c_probe, 141 + .probe_new = adt7316_i2c_probe, 142 142 .id_table = adt7316_i2c_id, 143 143 }; 144 144 module_i2c_driver(adt7316_driver);
+3 -3
drivers/staging/iio/impedance-analyzer/ad5933.c
··· 674 674 clk_disable_unprepare(st->mclk); 675 675 } 676 676 677 - static int ad5933_probe(struct i2c_client *client, 678 - const struct i2c_device_id *id) 677 + static int ad5933_probe(struct i2c_client *client) 679 678 { 679 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 680 680 int ret; 681 681 struct ad5933_state *st; 682 682 struct iio_dev *indio_dev; ··· 781 781 .name = "ad5933", 782 782 .of_match_table = ad5933_of_match, 783 783 }, 784 - .probe = ad5933_probe, 784 + .probe_new = ad5933_probe, 785 785 .id_table = ad5933_id, 786 786 }; 787 787 module_i2c_driver(ad5933_driver);
+2 -3
drivers/staging/iio/meter/ade7854-i2c.c
··· 112 112 return ret; 113 113 } 114 114 115 - static int ade7854_i2c_probe(struct i2c_client *client, 116 - const struct i2c_device_id *id) 115 + static int ade7854_i2c_probe(struct i2c_client *client) 117 116 { 118 117 struct ade7854_state *st; 119 118 struct iio_dev *indio_dev; ··· 143 144 .driver = { 144 145 .name = "ade7854", 145 146 }, 146 - .probe = ade7854_i2c_probe, 147 + .probe_new = ade7854_i2c_probe, 147 148 .id_table = ade7854_id, 148 149 }; 149 150 module_i2c_driver(ade7854_i2c_driver);
+12 -13
include/linux/iio/imu/adis.h
··· 402 402 __adis_update_bits_base(adis, reg, mask, val, sizeof(val)); \ 403 403 }) 404 404 405 - int adis_enable_irq(struct adis *adis, bool enable); 406 405 int __adis_check_status(struct adis *adis); 407 406 int __adis_initial_startup(struct adis *adis); 407 + int __adis_enable_irq(struct adis *adis, bool enable); 408 + 409 + static inline int adis_enable_irq(struct adis *adis, bool enable) 410 + { 411 + int ret; 412 + 413 + mutex_lock(&adis->state_lock); 414 + ret = __adis_enable_irq(adis, enable); 415 + mutex_unlock(&adis->state_lock); 416 + 417 + return ret; 418 + } 408 419 409 420 static inline int adis_check_status(struct adis *adis) 410 421 { ··· 423 412 424 413 mutex_lock(&adis->state_lock); 425 414 ret = __adis_check_status(adis); 426 - mutex_unlock(&adis->state_lock); 427 - 428 - return ret; 429 - } 430 - 431 - /* locked version of __adis_initial_startup() */ 432 - static inline int adis_initial_startup(struct adis *adis) 433 - { 434 - int ret; 435 - 436 - mutex_lock(&adis->state_lock); 437 - ret = __adis_initial_startup(adis); 438 415 mutex_unlock(&adis->state_lock); 439 416 440 417 return ret;