| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * STMicroelectronics hts221 sensor driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2016 STMicroelectronics Inc. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Lorenzo Bianconi <lorenzo.bianconi@st.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * Licensed under the GPL-2. |
|---|
| 9 | 8 | */ |
|---|
| 10 | 9 | |
|---|
| 11 | 10 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 24 | 23 | |
|---|
| 25 | 24 | #define HTS221_REG_CNTRL1_ADDR 0x20 |
|---|
| 26 | 25 | #define HTS221_REG_CNTRL2_ADDR 0x21 |
|---|
| 27 | | - |
|---|
| 28 | | -#define HTS221_REG_AVG_ADDR 0x10 |
|---|
| 29 | | -#define HTS221_REG_H_OUT_L 0x28 |
|---|
| 30 | | -#define HTS221_REG_T_OUT_L 0x2a |
|---|
| 31 | | - |
|---|
| 32 | | -#define HTS221_HUMIDITY_AVG_MASK 0x07 |
|---|
| 33 | | -#define HTS221_TEMP_AVG_MASK 0x38 |
|---|
| 34 | 26 | |
|---|
| 35 | 27 | #define HTS221_ODR_MASK 0x03 |
|---|
| 36 | 28 | #define HTS221_BDU_MASK BIT(2) |
|---|
| .. | .. |
|---|
| 67 | 59 | |
|---|
| 68 | 60 | static const struct hts221_avg hts221_avg_list[] = { |
|---|
| 69 | 61 | { |
|---|
| 70 | | - .addr = HTS221_REG_AVG_ADDR, |
|---|
| 71 | | - .mask = HTS221_HUMIDITY_AVG_MASK, |
|---|
| 62 | + .addr = 0x10, |
|---|
| 63 | + .mask = 0x07, |
|---|
| 72 | 64 | .avg_avl = { |
|---|
| 73 | 65 | 4, /* 0.4 %RH */ |
|---|
| 74 | 66 | 8, /* 0.3 %RH */ |
|---|
| .. | .. |
|---|
| 81 | 73 | }, |
|---|
| 82 | 74 | }, |
|---|
| 83 | 75 | { |
|---|
| 84 | | - .addr = HTS221_REG_AVG_ADDR, |
|---|
| 85 | | - .mask = HTS221_TEMP_AVG_MASK, |
|---|
| 76 | + .addr = 0x10, |
|---|
| 77 | + .mask = 0x38, |
|---|
| 86 | 78 | .avg_avl = { |
|---|
| 87 | 79 | 2, /* 0.08 degC */ |
|---|
| 88 | 80 | 4, /* 0.05 degC */ |
|---|
| .. | .. |
|---|
| 99 | 91 | static const struct iio_chan_spec hts221_channels[] = { |
|---|
| 100 | 92 | { |
|---|
| 101 | 93 | .type = IIO_HUMIDITYRELATIVE, |
|---|
| 102 | | - .address = HTS221_REG_H_OUT_L, |
|---|
| 94 | + .address = 0x28, |
|---|
| 103 | 95 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
|---|
| 104 | 96 | BIT(IIO_CHAN_INFO_OFFSET) | |
|---|
| 105 | 97 | BIT(IIO_CHAN_INFO_SCALE) | |
|---|
| .. | .. |
|---|
| 115 | 107 | }, |
|---|
| 116 | 108 | { |
|---|
| 117 | 109 | .type = IIO_TEMP, |
|---|
| 118 | | - .address = HTS221_REG_T_OUT_L, |
|---|
| 110 | + .address = 0x2a, |
|---|
| 119 | 111 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
|---|
| 120 | 112 | BIT(IIO_CHAN_INFO_OFFSET) | |
|---|
| 121 | 113 | BIT(IIO_CHAN_INFO_SCALE) | |
|---|
| .. | .. |
|---|
| 580 | 572 | return err; |
|---|
| 581 | 573 | |
|---|
| 582 | 574 | iio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 583 | | - iio_dev->dev.parent = hw->dev; |
|---|
| 584 | 575 | iio_dev->available_scan_masks = hts221_scan_masks; |
|---|
| 585 | 576 | iio_dev->channels = hts221_channels; |
|---|
| 586 | 577 | iio_dev->num_channels = ARRAY_SIZE(hts221_channels); |
|---|
| .. | .. |
|---|
| 629 | 620 | } |
|---|
| 630 | 621 | |
|---|
| 631 | 622 | if (hw->irq > 0) { |
|---|
| 632 | | - err = hts221_allocate_buffers(hw); |
|---|
| 623 | + err = hts221_allocate_buffers(iio_dev); |
|---|
| 633 | 624 | if (err < 0) |
|---|
| 634 | 625 | return err; |
|---|
| 635 | 626 | |
|---|
| 636 | | - err = hts221_allocate_trigger(hw); |
|---|
| 627 | + err = hts221_allocate_trigger(iio_dev); |
|---|
| 637 | 628 | if (err) |
|---|
| 638 | 629 | return err; |
|---|
| 639 | 630 | } |
|---|