Lines Matching +full:high +full:- +full:accuracy
1 // SPDX-License-Identifier: GPL-2.0-only
3 * si7020.c - Silicon Labs Si7013/20/21 Relative Humidity and Temp Sensors
63 if (chan->type == IIO_CURRENT) { in si7020_read_raw()
64 *val = data->heater_reg; in si7020_read_raw()
68 ret = i2c_smbus_read_word_swapped(data->client, in si7020_read_raw()
69 chan->type == IIO_TEMP ? in si7020_read_raw()
76 * Humidity values can slightly exceed the 0-100%RH in si7020_read_raw()
79 if (chan->type == IIO_HUMIDITYRELATIVE) in si7020_read_raw()
83 if (chan->type == IIO_TEMP) in si7020_read_raw()
93 * accuracy. in si7020_read_raw()
94 * Relative humidity will be 0.0032959% too high and in si7020_read_raw()
95 * temperature will be 0.00277344 degrees too high. in si7020_read_raw()
96 * This is no big deal because it's within the accuracy of the in si7020_read_raw()
99 if (chan->type == IIO_TEMP) in si7020_read_raw()
100 *val = -4368; /* = -46.85 * (65536 >> 2) / 175.72 */ in si7020_read_raw()
102 *val = -786; /* = -6 * (65536 >> 2) / 125 */ in si7020_read_raw()
108 return -EINVAL; in si7020_read_raw()
136 ret = i2c_smbus_write_byte_data(data->client, cmd, new); in si7020_update_reg()
154 if (chan->type != IIO_CURRENT || val2 != 0 || in si7020_write_raw()
156 return -EINVAL; in si7020_write_raw()
158 scoped_guard(mutex, &data->lock) in si7020_write_raw()
159 ret = si7020_update_reg(data, &data->heater_reg, in si7020_write_raw()
163 return -EINVAL; in si7020_write_raw()
172 if (mask != IIO_CHAN_INFO_RAW || chan->type != IIO_CURRENT) in si7020_read_available()
173 return -EINVAL; in si7020_read_available()
187 return sysfs_emit(buf, "%d\n", !!(data->user_reg & SI7020_USR_HEATER_EN)); in si7020_show_heater_en()
203 scoped_guard(mutex, &data->lock) in si7020_store_heater_en()
204 ret = si7020_update_reg(data, &data->user_reg, SI7020CMD_USR_WRITE, in si7020_store_heater_en()
235 if (!i2c_check_functionality(client->adapter, in si7020_probe()
238 return -EOPNOTSUPP; in si7020_probe()
244 /* Wait the maximum power-up time after software reset. */ in si7020_probe()
247 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in si7020_probe()
249 return -ENOMEM; in si7020_probe()
253 data->client = client; in si7020_probe()
254 mutex_init(&data->lock); in si7020_probe()
256 indio_dev->name = dev_name(&client->dev); in si7020_probe()
257 indio_dev->modes = INDIO_DIRECT_MODE; in si7020_probe()
258 indio_dev->info = &si7020_info; in si7020_probe()
259 indio_dev->channels = si7020_channels; in si7020_probe()
260 indio_dev->num_channels = ARRAY_SIZE(si7020_channels); in si7020_probe()
263 data->user_reg = 0x3A; in si7020_probe()
264 data->heater_reg = 0x0; in si7020_probe()
266 return devm_iio_device_register(&client->dev, indio_dev); in si7020_probe()