Lines Matching +full:oversampling +full:- +full:ratio

1 // SPDX-License-Identifier: GPL-2.0-only
132 err = regmap_read(hw->regmap, HTS221_REG_WHOAMI_ADDR, &data); in hts221_check_whoami()
134 dev_err(hw->dev, "failed to read whoami register\n"); in hts221_check_whoami()
139 dev_err(hw->dev, "wrong whoami {%02x vs %02x}\n", in hts221_check_whoami()
141 return -ENODEV; in hts221_check_whoami()
156 return -EINVAL; in hts221_update_odr()
158 err = regmap_update_bits(hw->regmap, HTS221_REG_CNTRL1_ADDR, in hts221_update_odr()
165 hw->odr = odr; in hts221_update_odr()
178 if (avg->avg_avl[i] == val) in hts221_update_avg()
182 return -EINVAL; in hts221_update_avg()
184 data = ((i << __ffs(avg->mask)) & avg->mask); in hts221_update_avg()
185 err = regmap_update_bits(hw->regmap, avg->addr, in hts221_update_avg()
186 avg->mask, data); in hts221_update_avg()
190 hw->sensors[type].cur_avg_idx = i; in hts221_update_avg()
203 len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", in hts221_sysfs_sampling_freq()
205 buf[len - 1] = '\n'; in hts221_sysfs_sampling_freq()
219 for (i = 0; i < ARRAY_SIZE(avg->avg_avl); i++) in hts221_sysfs_rh_oversampling_avail()
220 len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", in hts221_sysfs_rh_oversampling_avail()
221 avg->avg_avl[i]); in hts221_sysfs_rh_oversampling_avail()
222 buf[len - 1] = '\n'; in hts221_sysfs_rh_oversampling_avail()
236 for (i = 0; i < ARRAY_SIZE(avg->avg_avl); i++) in hts221_sysfs_temp_oversampling_avail()
237 len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", in hts221_sysfs_temp_oversampling_avail()
238 avg->avg_avl[i]); in hts221_sysfs_temp_oversampling_avail()
239 buf[len - 1] = '\n'; in hts221_sysfs_temp_oversampling_avail()
248 err = regmap_update_bits(hw->regmap, HTS221_REG_CNTRL1_ADDR, in hts221_set_enable()
254 hw->enabled = enable; in hts221_set_enable()
265 err = regmap_read(hw->regmap, HTS221_REG_0T_CAL_Y_H, &cal0); in hts221_parse_temp_caldata()
269 err = regmap_read(hw->regmap, HTS221_REG_T1_T0_CAL_Y_H, &cal1); in hts221_parse_temp_caldata()
274 err = regmap_read(hw->regmap, HTS221_REG_1T_CAL_Y_H, &cal0); in hts221_parse_temp_caldata()
279 err = regmap_bulk_read(hw->regmap, HTS221_REG_0T_CAL_X_L, in hts221_parse_temp_caldata()
285 err = regmap_bulk_read(hw->regmap, HTS221_REG_1T_CAL_X_L, in hts221_parse_temp_caldata()
291 slope = &hw->sensors[HTS221_SENSOR_T].slope; in hts221_parse_temp_caldata()
292 b_gen = &hw->sensors[HTS221_SENSOR_T].b_gen; in hts221_parse_temp_caldata()
294 *slope = ((cal_y1 - cal_y0) * 8000) / (cal_x1 - cal_x0); in hts221_parse_temp_caldata()
295 *b_gen = (((s32)cal_x1 * cal_y0 - (s32)cal_x0 * cal_y1) * 1000) / in hts221_parse_temp_caldata()
296 (cal_x1 - cal_x0); in hts221_parse_temp_caldata()
308 err = regmap_read(hw->regmap, HTS221_REG_0RH_CAL_Y_H, &data); in hts221_parse_rh_caldata()
313 err = regmap_read(hw->regmap, HTS221_REG_1RH_CAL_Y_H, &data); in hts221_parse_rh_caldata()
318 err = regmap_bulk_read(hw->regmap, HTS221_REG_0RH_CAL_X_H, in hts221_parse_rh_caldata()
324 err = regmap_bulk_read(hw->regmap, HTS221_REG_1RH_CAL_X_H, in hts221_parse_rh_caldata()
330 slope = &hw->sensors[HTS221_SENSOR_H].slope; in hts221_parse_rh_caldata()
331 b_gen = &hw->sensors[HTS221_SENSOR_H].b_gen; in hts221_parse_rh_caldata()
333 *slope = ((cal_y1 - cal_y0) * 8000) / (cal_x1 - cal_x0); in hts221_parse_rh_caldata()
334 *b_gen = (((s32)cal_x1 * cal_y0 - (s32)cal_x0 * cal_y1) * 1000) / in hts221_parse_rh_caldata()
335 (cal_x1 - cal_x0); in hts221_parse_rh_caldata()
350 data = hw->sensors[HTS221_SENSOR_H].slope; in hts221_get_sensor_scale()
354 data = hw->sensors[HTS221_SENSOR_T].slope; in hts221_get_sensor_scale()
358 return -EINVAL; in hts221_get_sensor_scale()
379 data = hw->sensors[HTS221_SENSOR_H].b_gen; in hts221_get_sensor_offset()
380 div = hw->sensors[HTS221_SENSOR_H].slope; in hts221_get_sensor_offset()
383 data = hw->sensors[HTS221_SENSOR_T].b_gen; in hts221_get_sensor_offset()
384 div = hw->sensors[HTS221_SENSOR_T].slope; in hts221_get_sensor_offset()
387 return -EINVAL; in hts221_get_sensor_offset()
410 err = regmap_bulk_read(hw->regmap, addr, &data, sizeof(data)); in hts221_read_oneshot()
434 ret = hts221_read_oneshot(hw, ch->address, val); in hts221_read_raw()
437 ret = hts221_get_sensor_scale(hw, ch->type, val, val2); in hts221_read_raw()
440 ret = hts221_get_sensor_offset(hw, ch->type, val, val2); in hts221_read_raw()
443 *val = hw->odr; in hts221_read_raw()
450 switch (ch->type) { in hts221_read_raw()
453 idx = hw->sensors[HTS221_SENSOR_H].cur_avg_idx; in hts221_read_raw()
454 *val = avg->avg_avl[idx]; in hts221_read_raw()
459 idx = hw->sensors[HTS221_SENSOR_T].cur_avg_idx; in hts221_read_raw()
460 *val = avg->avg_avl[idx]; in hts221_read_raw()
464 ret = -EINVAL; in hts221_read_raw()
470 ret = -EINVAL; in hts221_read_raw()
495 switch (chan->type) { in hts221_write_raw()
503 ret = -EINVAL; in hts221_write_raw()
508 ret = -EINVAL; in hts221_write_raw()
522 return hw->trig == trig ? 0 : -EINVAL; in hts221_validate_trigger()
574 return -ENOMEM; in hts221_probe()
579 hw->name = name; in hts221_probe()
580 hw->dev = dev; in hts221_probe()
581 hw->irq = irq; in hts221_probe()
582 hw->regmap = regmap; in hts221_probe()
592 iio_dev->modes = INDIO_DIRECT_MODE; in hts221_probe()
593 iio_dev->available_scan_masks = hts221_scan_masks; in hts221_probe()
594 iio_dev->channels = hts221_channels; in hts221_probe()
595 iio_dev->num_channels = ARRAY_SIZE(hts221_channels); in hts221_probe()
596 iio_dev->name = HTS221_DEV_NAME; in hts221_probe()
597 iio_dev->info = &hts221_info; in hts221_probe()
600 err = regmap_update_bits(hw->regmap, HTS221_REG_CNTRL1_ADDR, in hts221_probe()
613 dev_err(hw->dev, "failed to get rh calibration data\n"); in hts221_probe()
620 dev_err(hw->dev, "failed to set rh oversampling ratio\n"); in hts221_probe()
627 dev_err(hw->dev, in hts221_probe()
635 dev_err(hw->dev, in hts221_probe()
636 "failed to set temperature oversampling ratio\n"); in hts221_probe()
640 if (hw->irq > 0) { in hts221_probe()
650 return devm_iio_device_register(hw->dev, iio_dev); in hts221_probe()
659 return regmap_update_bits(hw->regmap, HTS221_REG_CNTRL1_ADDR, in hts221_suspend()
670 if (hw->enabled) in hts221_resume()
671 err = regmap_update_bits(hw->regmap, HTS221_REG_CNTRL1_ADDR, in hts221_resume()