Lines Matching +full:input +full:- +full:precharge +full:- +full:resistor +full:- +full:ohms

1 // SPDX-License-Identifier: GPL-2.0
181 * Returns the fake increment of (Max-Min)/2047
216 regmap_reg_range(SX9360_REG_IRQ_CFG + 1, SX9360_REG_GNRL_CTRL0 - 1),
217 regmap_reg_range(SX9360_REG_GNRL_CTRL2 + 1, SX9360_REG_AFE_CTRL1 - 1),
219 SX9360_REG_PROX_CTRL0_PHR - 1),
220 regmap_reg_range(SX9360_REG_PROX_CTRL5 + 1, SX9360_REG_REF_CORR0 - 1),
222 SX9360_REG_USEFUL_PHR_MSB - 1),
223 regmap_reg_range(SX9360_REG_USE_FILTER_LSB + 1, SX9360_REG_RESET - 1),
224 regmap_reg_range(SX9360_REG_RESET + 1, SX9360_REG_WHOAMI - 1),
225 regmap_reg_range(SX9360_REG_WHOAMI + 1, SX9360_REG_REVISION - 1),
261 return regmap_bulk_read(data->regmap, chan->address, val, sizeof(*val)); in sx9360_read_prox_data()
273 ret = regmap_bulk_read(data->regmap, SX9360_REG_GNRL_CTRL1, in sx9360_wait_for_sample()
288 reg = SX9360_REG_PROX_CTRL0_PHR + chan->channel; in sx9360_read_gain()
289 ret = regmap_read(data->regmap, reg, &regval); in sx9360_read_gain()
304 ret = regmap_bulk_read(data->regmap, SX9360_REG_GNRL_CTRL1, in sx9360_read_samp_freq()
347 return -EINVAL; in sx9360_read_raw()
358 return sysfs_emit(label, "%s\n", sx9360_channel_labels[chan->channel]); in sx9360_read_label()
368 if (chan->type != IIO_PROXIMITY) in sx9360_read_avail()
369 return -EINVAL; in sx9360_read_avail()
383 return -EINVAL; in sx9360_read_avail()
395 mutex_lock(&data->mutex); in sx9360_set_samp_freq()
397 ret = regmap_bulk_write(data->regmap, SX9360_REG_GNRL_CTRL1, &buf, in sx9360_set_samp_freq()
400 mutex_unlock(&data->mutex); in sx9360_set_samp_freq()
410 ret = regmap_read(data->regmap, SX9360_REG_PROX_CTRL5, &regval); in sx9360_read_thresh()
431 ret = regmap_read(data->regmap, SX9360_REG_PROX_CTRL4, &regval); in sx9360_read_hysteresis()
439 *val = pthresh >> (5 - regval); in sx9360_read_hysteresis()
449 ret = regmap_read(data->regmap, SX9360_REG_PROX_CTRL4, &regval); in sx9360_read_far_debounce()
467 ret = regmap_read(data->regmap, SX9360_REG_PROX_CTRL4, &regval); in sx9360_read_close_debounce()
488 if (chan->type != IIO_PROXIMITY) in sx9360_read_event_val()
489 return -EINVAL; in sx9360_read_event_val()
501 return -EINVAL; in sx9360_read_event_val()
506 return -EINVAL; in sx9360_read_event_val()
519 return -EINVAL; in sx9360_write_thresh()
521 mutex_lock(&data->mutex); in sx9360_write_thresh()
522 ret = regmap_write(data->regmap, SX9360_REG_PROX_CTRL5, val); in sx9360_write_thresh()
523 mutex_unlock(&data->mutex); in sx9360_write_thresh()
546 return -EINVAL; in sx9360_write_hysteresis()
549 mutex_lock(&data->mutex); in sx9360_write_hysteresis()
550 ret = regmap_update_bits(data->regmap, SX9360_REG_PROX_CTRL4, in sx9360_write_hysteresis()
552 mutex_unlock(&data->mutex); in sx9360_write_hysteresis()
565 return -EINVAL; in sx9360_write_far_debounce()
569 mutex_lock(&data->mutex); in sx9360_write_far_debounce()
570 ret = regmap_update_bits(data->regmap, SX9360_REG_PROX_CTRL4, in sx9360_write_far_debounce()
573 mutex_unlock(&data->mutex); in sx9360_write_far_debounce()
586 return -EINVAL; in sx9360_write_close_debounce()
590 mutex_lock(&data->mutex); in sx9360_write_close_debounce()
591 ret = regmap_update_bits(data->regmap, SX9360_REG_PROX_CTRL4, in sx9360_write_close_debounce()
594 mutex_unlock(&data->mutex); in sx9360_write_close_debounce()
607 if (chan->type != IIO_PROXIMITY) in sx9360_write_event_val()
608 return -EINVAL; in sx9360_write_event_val()
620 return -EINVAL; in sx9360_write_event_val()
625 return -EINVAL; in sx9360_write_event_val()
636 reg = SX9360_REG_PROX_CTRL0_PHR + chan->channel; in sx9360_write_gain()
639 mutex_lock(&data->mutex); in sx9360_write_gain()
640 ret = regmap_update_bits(data->regmap, reg, in sx9360_write_gain()
643 mutex_unlock(&data->mutex); in sx9360_write_gain()
660 return -EINVAL; in sx9360_write_raw()
707 ret = regmap_update_bits(data->regmap, SX9360_REG_STAT, in sx9360_init_compensation()
713 return regmap_read_poll_timeout(data->regmap, SX9360_REG_STAT, val, in sx9360_init_compensation()
726 switch (reg_def->reg) { in sx9360_get_default_reg()
729 "semtech,input-precharge-resistor-ohms", in sx9360_get_default_reg()
734 reg_def->def &= ~SX9360_REG_AFE_CTRL1_RESFILTIN_MASK; in sx9360_get_default_reg()
735 reg_def->def |= FIELD_PREP(SX9360_REG_AFE_CTRL1_RESFILTIN_MASK, in sx9360_get_default_reg()
744 raw = ilog2(raw) - 3; in sx9360_get_default_reg()
746 reg_def->def &= ~SX9360_REG_AFE_PARAM0_RESOLUTION_MASK; in sx9360_get_default_reg()
747 reg_def->def |= FIELD_PREP(SX9360_REG_AFE_PARAM0_RESOLUTION_MASK, raw); in sx9360_get_default_reg()
751 ret = device_property_read_u32(dev, "semtech,proxraw-strength", &raw); in sx9360_get_default_reg()
755 reg_def->def &= ~SX9360_REG_PROX_CTRL0_RAWFILT_MASK; in sx9360_get_default_reg()
756 reg_def->def |= FIELD_PREP(SX9360_REG_PROX_CTRL0_RAWFILT_MASK, raw); in sx9360_get_default_reg()
759 ret = device_property_read_u32(dev, "semtech,avg-pos-strength", in sx9360_get_default_reg()
765 raw = clamp(ilog2(pos), 3, 11) - (pos >= 32 ? 4 : 3); in sx9360_get_default_reg()
766 reg_def->def &= ~SX9360_REG_PROX_CTRL3_AVGPOS_FILT_MASK; in sx9360_get_default_reg()
767 reg_def->def |= FIELD_PREP(SX9360_REG_PROX_CTRL3_AVGPOS_FILT_MASK, raw); in sx9360_get_default_reg()
780 indio_dev->name = "sx9360"; in sx9360_check_whoami()
828 disable_irq_nosync(data->client->irq); in sx9360_suspend()
830 mutex_lock(&data->mutex); in sx9360_suspend()
831 ret = regmap_read(data->regmap, SX9360_REG_GNRL_CTRL0, &regval); in sx9360_suspend()
833 data->suspend_ctrl = in sx9360_suspend()
840 ret = regmap_write(data->regmap, SX9360_REG_GNRL_CTRL0, 0); in sx9360_suspend()
843 mutex_unlock(&data->mutex); in sx9360_suspend()
852 mutex_lock(&data->mutex); in sx9360_resume()
853 ret = regmap_update_bits(data->regmap, SX9360_REG_GNRL_CTRL0, in sx9360_resume()
855 data->suspend_ctrl); in sx9360_resume()
856 mutex_unlock(&data->mutex); in sx9360_resume()
860 enable_irq(data->client->irq); in sx9360_resume()