Lines Matching +full:ph1 +full:- +full:pin

1 // SPDX-License-Identifier: GPL-2.0
169 /* 4 channels, as defined in STAT0: PH0, PH1, PH2 and PH3. */
186 ret = regmap_read(data->regmap, SX9324_REG_AFE_PH0 + chan->channel, &val); in sx9324_phase_configuration_show()
195 buf[len - 1] = '\n'; in sx9324_phase_configuration_show()
315 regmap_reg_range(SX9324_REG_IRQ_CFG2 + 1, SX9324_REG_GNRL_CTRL0 - 1),
316 regmap_reg_range(SX9324_REG_GNRL_CTRL1 + 1, SX9324_REG_AFE_CTRL0 - 1),
317 regmap_reg_range(SX9324_REG_AFE_CTRL9 + 1, SX9324_REG_PROX_CTRL0 - 1),
318 regmap_reg_range(SX9324_REG_PROX_CTRL7 + 1, SX9324_REG_ADV_CTRL0 - 1),
319 regmap_reg_range(SX9324_REG_ADV_CTRL20 + 1, SX9324_REG_PHASE_SEL - 1),
320 regmap_reg_range(SX9324_REG_SAR_LSB + 1, SX9324_REG_RESET - 1),
321 regmap_reg_range(SX9324_REG_RESET + 1, SX9324_REG_WHOAMI - 1),
322 regmap_reg_range(SX9324_REG_WHOAMI + 1, SX9324_REG_REVISION - 1),
361 ret = regmap_write(data->regmap, SX9324_REG_PHASE_SEL, chan->channel); in sx9324_read_prox_data()
365 return regmap_bulk_read(data->regmap, chan->address, val, sizeof(*val)); in sx9324_read_prox_data()
377 ret = regmap_read(data->regmap, SX9324_REG_GNRL_CTRL0, &val); in sx9324_wait_for_sample()
393 reg = SX9324_REG_PROX_CTRL0 + chan->channel / 2; in sx9324_read_gain()
394 ret = regmap_read(data->regmap, reg, &regval); in sx9324_read_gain()
400 regval--; in sx9324_read_gain()
403 return -EINVAL; in sx9324_read_gain()
416 ret = regmap_read(data->regmap, SX9324_REG_GNRL_CTRL0, &regval); in sx9324_read_samp_freq()
454 return -EINVAL; in sx9324_read_raw()
465 if (chan->type != IIO_PROXIMITY) in sx9324_read_avail()
466 return -EINVAL; in sx9324_read_avail()
480 return -EINVAL; in sx9324_read_avail()
495 return -EINVAL; in sx9324_set_samp_freq()
497 mutex_lock(&data->mutex); in sx9324_set_samp_freq()
499 ret = regmap_update_bits(data->regmap, in sx9324_set_samp_freq()
503 mutex_unlock(&data->mutex); in sx9324_set_samp_freq()
520 reg = SX9324_REG_PROX_CTRL6 + chan->channel / 2; in sx9324_read_thresh()
521 ret = regmap_read(data->regmap, reg, &regval); in sx9324_read_thresh()
543 ret = regmap_read(data->regmap, SX9324_REG_PROX_CTRL5, &regval); in sx9324_read_hysteresis()
551 *val = pthresh >> (5 - regval); in sx9324_read_hysteresis()
561 ret = regmap_read(data->regmap, SX9324_REG_PROX_CTRL5, &regval); in sx9324_read_far_debounce()
579 ret = regmap_read(data->regmap, SX9324_REG_PROX_CTRL5, &regval); in sx9324_read_close_debounce()
600 if (chan->type != IIO_PROXIMITY) in sx9324_read_event_val()
601 return -EINVAL; in sx9324_read_event_val()
613 return -EINVAL; in sx9324_read_event_val()
618 return -EINVAL; in sx9324_read_event_val()
628 reg = SX9324_REG_PROX_CTRL6 + chan->channel / 2; in sx9324_write_thresh()
634 return -EINVAL; in sx9324_write_thresh()
636 mutex_lock(&data->mutex); in sx9324_write_thresh()
637 ret = regmap_write(data->regmap, reg, val); in sx9324_write_thresh()
638 mutex_unlock(&data->mutex); in sx9324_write_thresh()
662 return -EINVAL; in sx9324_write_hysteresis()
665 mutex_lock(&data->mutex); in sx9324_write_hysteresis()
666 ret = regmap_update_bits(data->regmap, SX9324_REG_PROX_CTRL5, in sx9324_write_hysteresis()
668 mutex_unlock(&data->mutex); in sx9324_write_hysteresis()
681 return -EINVAL; in sx9324_write_far_debounce()
685 mutex_lock(&data->mutex); in sx9324_write_far_debounce()
686 ret = regmap_update_bits(data->regmap, SX9324_REG_PROX_CTRL5, in sx9324_write_far_debounce()
689 mutex_unlock(&data->mutex); in sx9324_write_far_debounce()
702 return -EINVAL; in sx9324_write_close_debounce()
706 mutex_lock(&data->mutex); in sx9324_write_close_debounce()
707 ret = regmap_update_bits(data->regmap, SX9324_REG_PROX_CTRL5, in sx9324_write_close_debounce()
710 mutex_unlock(&data->mutex); in sx9324_write_close_debounce()
723 if (chan->type != IIO_PROXIMITY) in sx9324_write_event_val()
724 return -EINVAL; in sx9324_write_event_val()
736 return -EINVAL; in sx9324_write_event_val()
741 return -EINVAL; in sx9324_write_event_val()
751 reg = SX9324_REG_PROX_CTRL0 + chan->channel / 2; in sx9324_write_gain()
755 return -EINVAL; in sx9324_write_gain()
759 mutex_lock(&data->mutex); in sx9324_write_gain()
760 ret = regmap_update_bits(data->regmap, reg, in sx9324_write_gain()
763 mutex_unlock(&data->mutex); in sx9324_write_gain()
780 return -EINVAL; in sx9324_write_raw()
865 ret = regmap_update_bits(data->regmap, SX9324_REG_STAT2, in sx9324_init_compensation()
871 return regmap_read_poll_timeout(data->regmap, SX9324_REG_STAT2, val, in sx9324_init_compensation()
882 static const char * const sx9324_csidle[] = { "hi-z", "hi-z", "gnd", in sx9324_get_default_reg()
884 #define SX9324_PIN_DEF "semtech,ph0-pin" in sx9324_get_default_reg()
885 #define SX9324_RESOLUTION_DEF "semtech,ph01-resolution" in sx9324_get_default_reg()
886 #define SX9324_PROXRAW_DEF "semtech,ph01-proxraw-strength" in sx9324_get_default_reg()
890 int ret, count, ph, pin; in sx9324_get_default_reg() local
896 switch (reg_def->reg) { in sx9324_get_default_reg()
901 ph = reg_def->reg - SX9324_REG_AFE_PH0; in sx9324_get_default_reg()
902 snprintf(prop, ARRAY_SIZE(prop), "semtech,ph%d-pin", ph); in sx9324_get_default_reg()
912 for (pin = 0; pin < SX9324_NUM_PINS; pin++) in sx9324_get_default_reg()
913 raw |= (pin_defs[pin] << (2 * pin)) & in sx9324_get_default_reg()
914 SX9324_REG_AFE_PH0_PIN_MASK(pin); in sx9324_get_default_reg()
915 reg_def->def = raw; in sx9324_get_default_reg()
919 "semtech,cs-idle-sleep", &res); in sx9324_get_default_reg()
923 reg_def->def &= ~SX9324_REG_AFE_CTRL0_CSIDLE_MASK; in sx9324_get_default_reg()
924 reg_def->def |= ret << SX9324_REG_AFE_CTRL0_CSIDLE_SHIFT; in sx9324_get_default_reg()
928 "semtech,int-comp-resistor", &res); in sx9324_get_default_reg()
934 reg_def->def &= ~SX9324_REG_AFE_CTRL0_RINT_MASK; in sx9324_get_default_reg()
935 reg_def->def |= ret << SX9324_REG_AFE_CTRL0_RINT_SHIFT; in sx9324_get_default_reg()
939 if (reg_def->reg == SX9324_REG_AFE_CTRL4) in sx9324_get_default_reg()
940 strncpy(prop, "semtech,ph01-resolution", in sx9324_get_default_reg()
943 strncpy(prop, "semtech,ph23-resolution", in sx9324_get_default_reg()
950 raw = ilog2(raw) - 3; in sx9324_get_default_reg()
952 reg_def->def &= ~SX9324_REG_AFE_CTRL4_RESOLUTION_MASK; in sx9324_get_default_reg()
953 reg_def->def |= FIELD_PREP(SX9324_REG_AFE_CTRL4_RESOLUTION_MASK, in sx9324_get_default_reg()
958 "semtech,input-precharge-resistor-ohms", in sx9324_get_default_reg()
963 reg_def->def &= ~SX9324_REG_AFE_CTRL8_RESFILTIN_MASK; in sx9324_get_default_reg()
964 reg_def->def |= FIELD_PREP(SX9324_REG_AFE_CTRL8_RESFILTIN_MASK, in sx9324_get_default_reg()
970 "semtech,input-analog-gain", &raw); in sx9324_get_default_reg()
975 * +---------+----------------+----------------+ in sx9324_get_default_reg()
977 * +---------+----------------+----------------+ in sx9324_get_default_reg()
982 * +---------+----------------+----------------+ in sx9324_get_default_reg()
984 reg_def->def &= ~SX9324_REG_AFE_CTRL9_AGAIN_MASK; in sx9324_get_default_reg()
985 reg_def->def |= FIELD_PREP(SX9324_REG_AFE_CTRL9_AGAIN_MASK, in sx9324_get_default_reg()
990 ret = device_property_read_u32(dev, "semtech,startup-sensor", in sx9324_get_default_reg()
995 reg_def->def &= ~SX9324_REG_ADV_CTRL5_STARTUPSENS_MASK; in sx9324_get_default_reg()
996 reg_def->def |= FIELD_PREP(SX9324_REG_ADV_CTRL5_STARTUPSENS_MASK, in sx9324_get_default_reg()
1000 ret = device_property_read_u32(dev, "semtech,avg-pos-strength", in sx9324_get_default_reg()
1006 raw = clamp(ilog2(pos), 3, 11) - (pos >= 32 ? 4 : 3); in sx9324_get_default_reg()
1008 reg_def->def &= ~SX9324_REG_PROX_CTRL4_AVGPOSFILT_MASK; in sx9324_get_default_reg()
1009 reg_def->def |= FIELD_PREP(SX9324_REG_PROX_CTRL4_AVGPOSFILT_MASK, in sx9324_get_default_reg()
1014 if (reg_def->reg == SX9324_REG_PROX_CTRL0) in sx9324_get_default_reg()
1015 strncpy(prop, "semtech,ph01-proxraw-strength", in sx9324_get_default_reg()
1018 strncpy(prop, "semtech,ph23-proxraw-strength", in sx9324_get_default_reg()
1024 reg_def->def &= ~SX9324_REG_PROX_CTRL0_RAWFILT_MASK; in sx9324_get_default_reg()
1025 reg_def->def |= FIELD_PREP(SX9324_REG_PROX_CTRL0_RAWFILT_MASK, in sx9324_get_default_reg()
1039 indio_dev->name = "sx9324"; in sx9324_check_whoami()
1086 disable_irq_nosync(data->client->irq); in sx9324_suspend()
1088 mutex_lock(&data->mutex); in sx9324_suspend()
1089 ret = regmap_read(data->regmap, SX9324_REG_GNRL_CTRL1, &regval); in sx9324_suspend()
1091 data->suspend_ctrl = in sx9324_suspend()
1098 ret = regmap_write(data->regmap, SX9324_REG_GNRL_CTRL1, 0); in sx9324_suspend()
1101 mutex_unlock(&data->mutex); in sx9324_suspend()
1110 mutex_lock(&data->mutex); in sx9324_resume()
1111 ret = regmap_write(data->regmap, SX9324_REG_GNRL_CTRL1, in sx9324_resume()
1112 data->suspend_ctrl | SX9324_REG_GNRL_CTRL1_PAUSECTRL); in sx9324_resume()
1113 mutex_unlock(&data->mutex); in sx9324_resume()
1117 enable_irq(data->client->irq); in sx9324_resume()