Lines Matching +full:proxraw +full:- +full:strength
1 // SPDX-License-Identifier: GPL-2.0
8 * linux-driver-SX9310_NoSmartHSensing>.
264 ret = regmap_write(data->regmap, SX9310_REG_SENSOR_SEL, chan->channel); in sx9310_read_prox_data()
268 return regmap_bulk_read(data->regmap, chan->address, val, sizeof(*val)); in sx9310_read_prox_data()
280 ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, &val); in sx9310_wait_for_sample()
297 ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL3, ®val); in sx9310_read_gain()
301 switch (chan->channel) { in sx9310_read_gain()
311 return -EINVAL; in sx9310_read_gain()
324 ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, ®val); in sx9310_read_samp_freq()
341 if (chan->type != IIO_PROXIMITY) in sx9310_read_raw()
342 return -EINVAL; in sx9310_read_raw()
346 iio_device_claim_direct_scoped(return -EBUSY, indio_dev) in sx9310_read_raw()
350 iio_device_claim_direct_scoped(return -EBUSY, indio_dev) in sx9310_read_raw()
356 return -EINVAL; in sx9310_read_raw()
367 if (chan->type != IIO_PROXIMITY) in sx9310_read_avail()
368 return -EINVAL; in sx9310_read_avail()
382 return -EINVAL; in sx9310_read_avail()
401 return -EINVAL; in sx9310_get_thresh_reg()
412 reg = ret = sx9310_get_thresh_reg(chan->channel); in sx9310_read_thresh()
416 ret = regmap_read(data->regmap, reg, ®val); in sx9310_read_thresh()
422 return -EINVAL; in sx9310_read_thresh()
438 ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL10, ®val); in sx9310_read_hysteresis()
447 *val = pthresh >> (5 - regval); in sx9310_read_hysteresis()
457 ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL10, ®val); in sx9310_read_far_debounce()
475 ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL10, ®val); in sx9310_read_close_debounce()
496 if (chan->type != IIO_PROXIMITY) in sx9310_read_event_val()
497 return -EINVAL; in sx9310_read_event_val()
509 return -EINVAL; in sx9310_read_event_val()
514 return -EINVAL; in sx9310_read_event_val()
525 reg = ret = sx9310_get_thresh_reg(chan->channel); in sx9310_write_thresh()
537 return -EINVAL; in sx9310_write_thresh()
541 guard(mutex)(&data->mutex); in sx9310_write_thresh()
542 return regmap_update_bits(data->regmap, reg, in sx9310_write_thresh()
565 return -EINVAL; in sx9310_write_hysteresis()
569 guard(mutex)(&data->mutex); in sx9310_write_hysteresis()
570 return regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL10, in sx9310_write_hysteresis()
581 return -EINVAL; in sx9310_write_far_debounce()
585 guard(mutex)(&data->mutex); in sx9310_write_far_debounce()
586 return regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL10, in sx9310_write_far_debounce()
598 return -EINVAL; in sx9310_write_close_debounce()
602 guard(mutex)(&data->mutex); in sx9310_write_close_debounce()
603 return regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL10, in sx9310_write_close_debounce()
616 if (chan->type != IIO_PROXIMITY) in sx9310_write_event_val()
617 return -EINVAL; in sx9310_write_event_val()
629 return -EINVAL; in sx9310_write_event_val()
634 return -EINVAL; in sx9310_write_event_val()
648 return -EINVAL; in sx9310_set_samp_freq()
650 guard(mutex)(&data->mutex); in sx9310_set_samp_freq()
652 data->regmap, SX9310_REG_PROX_CTRL0, in sx9310_set_samp_freq()
664 switch (chan->channel) { in sx9310_write_gain()
676 return -EINVAL; in sx9310_write_gain()
679 guard(mutex)(&data->mutex); in sx9310_write_gain()
680 return regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL3, mask, in sx9310_write_gain()
690 if (chan->type != IIO_PROXIMITY) in sx9310_write_raw()
691 return -EINVAL; in sx9310_write_raw()
699 return -EINVAL; in sx9310_write_raw()
753 ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, &ctrl0); in sx9310_init_compensation()
758 ret = regmap_write(data->regmap, SX9310_REG_PROX_CTRL0, in sx9310_init_compensation()
763 ret = regmap_read_poll_timeout(data->regmap, SX9310_REG_STAT1, val, in sx9310_init_compensation()
769 regmap_write(data->regmap, SX9310_REG_PROX_CTRL0, ctrl0); in sx9310_init_compensation()
784 switch (reg_def->reg) { in sx9310_get_default_reg()
786 if (device_property_read_bool(dev, "semtech,cs0-ground")) { in sx9310_get_default_reg()
787 reg_def->def &= ~SX9310_REG_PROX_CTRL2_SHIELDEN_MASK; in sx9310_get_default_reg()
788 reg_def->def |= SX9310_REG_PROX_CTRL2_SHIELDEN_GROUND; in sx9310_get_default_reg()
791 count = device_property_count_u32(dev, "semtech,combined-sensors"); in sx9310_get_default_reg()
794 ret = device_property_read_u32_array(dev, "semtech,combined-sensors", in sx9310_get_default_reg()
802 reg_def->def &= ~SX9310_REG_PROX_CTRL2_COMBMODE_MASK; in sx9310_get_default_reg()
804 reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1_CS2_CS3; in sx9310_get_default_reg()
806 reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS1_CS2; in sx9310_get_default_reg()
808 reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1; in sx9310_get_default_reg()
810 reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS3; in sx9310_get_default_reg()
818 reg_def->def &= ~SX9310_REG_PROX_CTRL4_RESOLUTION_MASK; in sx9310_get_default_reg()
820 reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_COARSEST; in sx9310_get_default_reg()
821 else if (!strcmp(res, "very-coarse")) in sx9310_get_default_reg()
822 reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_VERY_COARSE; in sx9310_get_default_reg()
824 reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_COARSE; in sx9310_get_default_reg()
825 else if (!strcmp(res, "medium-coarse")) in sx9310_get_default_reg()
826 reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_MEDIUM_COARSE; in sx9310_get_default_reg()
828 reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_MEDIUM; in sx9310_get_default_reg()
830 reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_FINE; in sx9310_get_default_reg()
831 else if (!strcmp(res, "very-fine")) in sx9310_get_default_reg()
832 reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_VERY_FINE; in sx9310_get_default_reg()
834 reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_FINEST; in sx9310_get_default_reg()
838 ret = device_property_read_u32(dev, "semtech,startup-sensor", &start); in sx9310_get_default_reg()
841 reg_def->def); in sx9310_get_default_reg()
844 reg_def->def &= ~SX9310_REG_PROX_CTRL5_STARTUPSENS_MASK; in sx9310_get_default_reg()
845 reg_def->def |= FIELD_PREP(SX9310_REG_PROX_CTRL5_STARTUPSENS_MASK, in sx9310_get_default_reg()
848 ret = device_property_read_u32(dev, "semtech,proxraw-strength", &raw); in sx9310_get_default_reg()
851 reg_def->def); in sx9310_get_default_reg()
856 reg_def->def &= ~SX9310_REG_PROX_CTRL5_RAWFILT_MASK; in sx9310_get_default_reg()
857 reg_def->def |= FIELD_PREP(SX9310_REG_PROX_CTRL5_RAWFILT_MASK, in sx9310_get_default_reg()
861 ret = device_property_read_u32(dev, "semtech,avg-pos-strength", &pos); in sx9310_get_default_reg()
866 pos = clamp(ilog2(pos), 3, 11) - (pos >= 32 ? 4 : 3); in sx9310_get_default_reg()
867 reg_def->def &= ~SX9310_REG_PROX_CTRL7_AVGPOSFILT_MASK; in sx9310_get_default_reg()
868 reg_def->def |= FIELD_PREP(SX9310_REG_PROX_CTRL7_AVGPOSFILT_MASK, in sx9310_get_default_reg()
884 ret = regmap_read(data->regmap, SX9310_REG_WHOAMI, &whoami); in sx9310_check_whoami()
889 if (ddata->whoami != whoami) in sx9310_check_whoami()
890 return -ENODEV; in sx9310_check_whoami()
892 indio_dev->name = ddata->name; in sx9310_check_whoami()
940 disable_irq_nosync(data->client->irq); in sx9310_suspend()
942 guard(mutex)(&data->mutex); in sx9310_suspend()
943 ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, in sx9310_suspend()
944 &data->suspend_ctrl); in sx9310_suspend()
948 ctrl0 = data->suspend_ctrl & ~SX9310_REG_PROX_CTRL0_SENSOREN_MASK; in sx9310_suspend()
949 ret = regmap_write(data->regmap, SX9310_REG_PROX_CTRL0, ctrl0); in sx9310_suspend()
953 return regmap_write(data->regmap, SX9310_REG_PAUSE, 0); in sx9310_suspend()
961 scoped_guard(mutex, &data->mutex) { in sx9310_resume()
962 ret = regmap_write(data->regmap, SX9310_REG_PAUSE, 1); in sx9310_resume()
966 ret = regmap_write(data->regmap, SX9310_REG_PROX_CTRL0, in sx9310_resume()
967 data->suspend_ctrl); in sx9310_resume()
972 enable_irq(data->client->irq); in sx9310_resume()