Lines Matching +full:digital +full:- +full:input +full:- +full:threshold +full:- +full:mode +full:- +full:fixed

1 // SPDX-License-Identifier: GPL-2.0
3 * ad2s1210.c support for the ADI Resolver to Digital Converters: AD2S1210
5 * Copyright (c) 2010-2010 Analog Devices Inc.
11 * ----------------------------|------|-------------------------------------------
12 * DOS Overrange Threshold | 0x89 | events/in_altvoltage0_thresh_rising_value
13 * DOS Mismatch Threshold | 0x8A | events/in_altvoltage0_mag_rising_value
14 * DOS Reset Maximum Threshold | 0x8B | events/in_altvoltage0_mag_rising_reset_max
15 * DOS Reset Minimum Threshold | 0x8C | events/in_altvoltage0_mag_rising_reset_min
16 * LOT High Threshold | 0x8D | events/in_angl1_thresh_rising_value
17 * LOT Low Threshold [1] | 0x8E | events/in_angl1_thresh_rising_hysteresis
23 * Resolution | D1:0 | *device tree: assigned-resolution-bits*
34 * ----------------------------------------|----|---------------------------------
118 /* Threshold voltage registers have 1 LSB == 38 mV */
120 /* max voltage for threshold registers is 0x7F * 38 mV */
152 /* adi,fixed-mode property - only valid when mode_gpios == NULL. */
175 static int ad2s1210_set_mode(struct ad2s1210_state *st, enum ad2s1210_mode mode) in ad2s1210_set_mode() argument
177 struct gpio_descs *gpios = st->mode_gpios; in ad2s1210_set_mode()
181 return mode == st->fixed_mode ? 0 : -EOPNOTSUPP; in ad2s1210_set_mode()
183 bitmap[0] = mode; in ad2s1210_set_mode()
185 return gpiod_set_array_value(gpios->ndescs, gpios->desc, gpios->info, in ad2s1210_set_mode()
192 * If the mode is configurable, the device will first be placed in
193 * configuration mode.
202 .rx_buf = &st->rx[0], in ad2s1210_regmap_reg_write()
203 .tx_buf = &st->tx[0], in ad2s1210_regmap_reg_write()
207 .rx_buf = &st->rx[1], in ad2s1210_regmap_reg_write()
208 .tx_buf = &st->tx[1], in ad2s1210_regmap_reg_write()
215 return -EINVAL; in ad2s1210_regmap_reg_write()
217 st->tx[0] = reg; in ad2s1210_regmap_reg_write()
218 st->tx[1] = val; in ad2s1210_regmap_reg_write()
224 ret = spi_sync_transfer(st->sdev, xfers, ARRAY_SIZE(xfers)); in ad2s1210_regmap_reg_write()
230 st->prev_fault_flags = 0; in ad2s1210_regmap_reg_write()
238 * If the mode is configurable, the device will first be placed in
239 * configuration mode.
248 .rx_buf = &st->rx[0], in ad2s1210_regmap_reg_read()
249 .tx_buf = &st->tx[0], in ad2s1210_regmap_reg_read()
253 .rx_buf = &st->rx[1], in ad2s1210_regmap_reg_read()
254 .tx_buf = &st->tx[1], in ad2s1210_regmap_reg_read()
263 st->tx[0] = reg; in ad2s1210_regmap_reg_read()
266 * It doesn't matter which one as long as reading doesn't have side- in ad2s1210_regmap_reg_read()
269 st->tx[1] = AD2S1210_REG_CONTROL; in ad2s1210_regmap_reg_read()
271 ret = spi_sync_transfer(st->sdev, xfers, ARRAY_SIZE(xfers)); in ad2s1210_regmap_reg_read()
277 st->prev_fault_flags = 0; in ad2s1210_regmap_reg_read()
281 * parity error. The fault register is read-only and the D7 bit means in ad2s1210_regmap_reg_read()
285 && st->rx[1] & AD2S1210_ADDRESS_DATA) in ad2s1210_regmap_reg_read()
286 return -EBADMSG; in ad2s1210_regmap_reg_read()
288 *val = st->rx[1]; in ad2s1210_regmap_reg_read()
304 * ~= 350 ns. The same delay is also needed before re-asserting the in ad2s1210_toggle_sample_line()
307 gpiod_set_value(st->sample_gpio, 1); in ad2s1210_toggle_sample_line()
309 gpiod_set_value(st->sample_gpio, 0); in ad2s1210_toggle_sample_line()
327 fcw = fexcit * (1 << 15) / st->clkin_hz; in ad2s1210_reinit_excitation_frequency()
329 return -ERANGE; in ad2s1210_reinit_excitation_frequency()
331 ret = regmap_write(st->regmap, AD2S1210_REG_EXCIT_FREQ, fcw); in ad2s1210_reinit_excitation_frequency()
339 ret = regmap_write(st->regmap, AD2S1210_REG_SOFT_RESET, 0); in ad2s1210_reinit_excitation_frequency()
349 msleep(track_time_ms[st->resolution] * 8192000 / st->clkin_hz); in ad2s1210_reinit_excitation_frequency()
352 ret = regmap_read(st->regmap, AD2S1210_REG_FAULT, &ignored); in ad2s1210_reinit_excitation_frequency()
368 if (FAULT_ONESHOT(AD2S1210_FAULT_CLIP, flags, st->prev_fault_flags)) { in ad2s1210_push_events()
385 /* Sine/cosine inputs below LOS threshold */ in ad2s1210_push_events()
386 if (FAULT_ONESHOT(AD2S1210_FAULT_LOS, flags, st->prev_fault_flags)) in ad2s1210_push_events()
393 /* Sine/cosine inputs exceed DOS overrange threshold */ in ad2s1210_push_events()
394 if (FAULT_ONESHOT(AD2S1210_FAULT_DOS_OVR, flags, st->prev_fault_flags)) in ad2s1210_push_events()
401 /* Sine/cosine inputs exceed DOS mismatch threshold */ in ad2s1210_push_events()
402 if (FAULT_ONESHOT(AD2S1210_FAULT_DOS_MIS, flags, st->prev_fault_flags)) in ad2s1210_push_events()
409 /* Tracking error exceeds LOT threshold */ in ad2s1210_push_events()
410 if (FAULT_ONESHOT(AD2S1210_FAULT_LOT, flags, st->prev_fault_flags)) in ad2s1210_push_events()
418 if (FAULT_ONESHOT(AD2S1210_FAULT_VELOCITY, flags, st->prev_fault_flags)) in ad2s1210_push_events()
426 if (FAULT_ONESHOT(AD2S1210_FAULT_PHASE, flags, st->prev_fault_flags)) in ad2s1210_push_events()
435 st->prev_fault_flags)) in ad2s1210_push_events()
440 dev_err_ratelimited(&indio_dev->dev, in ad2s1210_push_events()
443 st->prev_fault_flags = flags; in ad2s1210_push_events()
454 guard(mutex)(&st->lock); in ad2s1210_single_conversion()
459 if (st->fixed_mode == MOD_CONFIG) { in ad2s1210_single_conversion()
462 switch (chan->type) { in ad2s1210_single_conversion()
464 ret = regmap_bulk_read(st->regmap, in ad2s1210_single_conversion()
466 &st->sample.raw, 2); in ad2s1210_single_conversion()
472 ret = regmap_bulk_read(st->regmap, in ad2s1210_single_conversion()
474 &st->sample.raw, 2); in ad2s1210_single_conversion()
480 return -EINVAL; in ad2s1210_single_conversion()
483 ret = regmap_read(st->regmap, AD2S1210_REG_FAULT, &reg_val); in ad2s1210_single_conversion()
487 st->sample.fault = reg_val; in ad2s1210_single_conversion()
489 switch (chan->type) { in ad2s1210_single_conversion()
497 return -EINVAL; in ad2s1210_single_conversion()
502 ret = spi_read(st->sdev, &st->sample, 3); in ad2s1210_single_conversion()
507 switch (chan->type) { in ad2s1210_single_conversion()
509 *val = be16_to_cpu(st->sample.raw); in ad2s1210_single_conversion()
513 *val = (s16)be16_to_cpu(st->sample.raw); in ad2s1210_single_conversion()
517 return -EINVAL; in ad2s1210_single_conversion()
520 ad2s1210_push_events(indio_dev, st->sample.fault, timestamp); in ad2s1210_single_conversion()
529 guard(mutex)(&st->lock); in ad2s1210_get_hysteresis()
530 ret = regmap_test_bits(st->regmap, AD2S1210_REG_CONTROL, in ad2s1210_get_hysteresis()
535 *val = ret << (2 * (AD2S1210_RES_16 - st->resolution)); in ad2s1210_get_hysteresis()
541 guard(mutex)(&st->lock); in ad2s1210_set_hysteresis()
542 return regmap_update_bits(st->regmap, AD2S1210_REG_CONTROL, in ad2s1210_set_hysteresis()
552 guard(mutex)(&st->lock); in ad2s1210_get_phase_lock_range()
553 ret = regmap_test_bits(st->regmap, AD2S1210_REG_CONTROL, in ad2s1210_get_phase_lock_range()
576 /* convert radians to degrees - only two allowable values */ in ad2s1210_set_phase_lock_range()
583 return -EINVAL; in ad2s1210_set_phase_lock_range()
585 guard(mutex)(&st->lock); in ad2s1210_set_phase_lock_range()
586 return regmap_update_bits(st->regmap, AD2S1210_REG_CONTROL, in ad2s1210_set_phase_lock_range()
593 6184, /* 10-bit: ~0.35 deg/LSB, 45 deg max */
594 2473, /* 12-bit: ~0.14 deg/LSB, 18 deg max */
595 1237, /* 14-bit: ~0.07 deg/LSB, 9 deg max */
596 1237, /* 16-bit: same as 14-bit */
605 guard(mutex)(&st->lock); in ad2s1210_get_voltage_threshold()
606 ret = regmap_read(st->regmap, reg, &reg_val); in ad2s1210_get_voltage_threshold()
621 guard(mutex)(&st->lock); in ad2s1210_set_voltage_threshold()
622 return regmap_write(st->regmap, reg, reg_val); in ad2s1210_set_voltage_threshold()
631 guard(mutex)(&st->lock); in ad2s1210_get_lot_high_threshold()
632 ret = regmap_read(st->regmap, AD2S1210_REG_LOT_HIGH_THRD, &reg_val); in ad2s1210_get_lot_high_threshold()
637 *val2 = reg_val * ad2s1210_lot_threshold_urad_per_lsb[st->resolution]; in ad2s1210_get_lot_high_threshold()
649 return -EINVAL; in ad2s1210_set_lot_high_threshold()
651 guard(mutex)(&st->lock); in ad2s1210_set_lot_high_threshold()
656 ret = regmap_read(st->regmap, AD2S1210_REG_LOT_HIGH_THRD, &high_reg_val); in ad2s1210_set_lot_high_threshold()
660 ret = regmap_read(st->regmap, AD2S1210_REG_LOT_LOW_THRD, &low_reg_val); in ad2s1210_set_lot_high_threshold()
664 hysteresis = high_reg_val - low_reg_val; in ad2s1210_set_lot_high_threshold()
665 high_reg_val = val2 / ad2s1210_lot_threshold_urad_per_lsb[st->resolution]; in ad2s1210_set_lot_high_threshold()
666 low_reg_val = high_reg_val - hysteresis; in ad2s1210_set_lot_high_threshold()
668 ret = regmap_write(st->regmap, AD2S1210_REG_LOT_HIGH_THRD, high_reg_val); in ad2s1210_set_lot_high_threshold()
672 return regmap_write(st->regmap, AD2S1210_REG_LOT_LOW_THRD, low_reg_val); in ad2s1210_set_lot_high_threshold()
681 guard(mutex)(&st->lock); in ad2s1210_get_lot_low_threshold()
683 ret = regmap_read(st->regmap, AD2S1210_REG_LOT_HIGH_THRD, &high_reg_val); in ad2s1210_get_lot_low_threshold()
687 ret = regmap_read(st->regmap, AD2S1210_REG_LOT_LOW_THRD, &low_reg_val); in ad2s1210_get_lot_low_threshold()
693 *val2 = (high_reg_val - low_reg_val) * in ad2s1210_get_lot_low_threshold()
694 ad2s1210_lot_threshold_urad_per_lsb[st->resolution]; in ad2s1210_get_lot_low_threshold()
706 return -EINVAL; in ad2s1210_set_lot_low_threshold()
708 hysteresis = val2 / ad2s1210_lot_threshold_urad_per_lsb[st->resolution]; in ad2s1210_set_lot_low_threshold()
710 guard(mutex)(&st->lock); in ad2s1210_set_lot_low_threshold()
712 ret = regmap_read(st->regmap, AD2S1210_REG_LOT_HIGH_THRD, &reg_val); in ad2s1210_set_lot_low_threshold()
716 return regmap_write(st->regmap, AD2S1210_REG_LOT_LOW_THRD, in ad2s1210_set_lot_low_threshold()
717 reg_val - hysteresis); in ad2s1210_set_lot_low_threshold()
725 guard(mutex)(&st->lock); in ad2s1210_get_excitation_frequency()
727 ret = regmap_read(st->regmap, AD2S1210_REG_EXCIT_FREQ, &reg_val); in ad2s1210_get_excitation_frequency()
731 *val = reg_val * st->clkin_hz / (1 << 15); in ad2s1210_get_excitation_frequency()
738 return -EINVAL; in ad2s1210_set_excitation_frequency()
740 guard(mutex)(&st->lock); in ad2s1210_set_excitation_frequency()
763 switch (chan->type) { in ad2s1210_read_raw()
770 *val = st->clkin_hz; in ad2s1210_read_raw()
771 *val2 = ad2s1210_velocity_scale[st->resolution]; in ad2s1210_read_raw()
774 return -EINVAL; in ad2s1210_read_raw()
777 switch (chan->type) { in ad2s1210_read_raw()
781 return -EINVAL; in ad2s1210_read_raw()
784 switch (chan->type) { in ad2s1210_read_raw()
788 return -EINVAL; in ad2s1210_read_raw()
791 return -EINVAL; in ad2s1210_read_raw()
810 switch (chan->type) { in ad2s1210_read_avail()
816 return -EINVAL; in ad2s1210_read_avail()
819 switch (chan->type) { in ad2s1210_read_avail()
821 *vals = st->hysteresis_available; in ad2s1210_read_avail()
823 *length = ARRAY_SIZE(st->hysteresis_available); in ad2s1210_read_avail()
826 return -EINVAL; in ad2s1210_read_avail()
829 return -EINVAL; in ad2s1210_read_avail()
841 switch (chan->type) { in ad2s1210_write_raw()
845 return -EINVAL; in ad2s1210_write_raw()
848 switch (chan->type) { in ad2s1210_write_raw()
852 return -EINVAL; in ad2s1210_write_raw()
855 return -EINVAL; in ad2s1210_write_raw()
861 /* Tracking error exceeds LOT threshold fault. */
865 /* Loss of tracking high threshold. */
867 /* Loss of tracking low threshold. */
892 /* Sine/cosine below LOS threshold fault. */
895 /* Loss of signal threshold. */
902 /* Degredation of signal overrange threshold. */
960 .scan_index = -1,
969 .scan_index = -1,
978 .scan_index = -1,
986 .scan_index = -1,
990 /* sine input */
994 .scan_index = -1,
998 /* cosine input */
1002 .scan_index = -1,
1017 guard(mutex)(&st->lock); in event_attr_voltage_reg_show()
1018 ret = regmap_read(st->regmap, iattr->address, &value); in event_attr_voltage_reg_show()
1036 return -EINVAL; in event_attr_voltage_reg_store()
1038 guard(mutex)(&st->lock); in event_attr_voltage_reg_store()
1039 ret = regmap_write(st->regmap, iattr->address, in event_attr_voltage_reg_store()
1053 int step = ad2s1210_lot_threshold_urad_per_lsb[st->resolution]; in in_angl1_thresh_rising_value_available_show()
1064 int step = ad2s1210_lot_threshold_urad_per_lsb[st->resolution]; in in_angl1_thresh_rising_hysteresis_available_show()
1114 guard(mutex)(&st->lock); in ad2s1210_initial()
1120 data |= FIELD_PREP(AD2S1210_SET_RES, st->resolution); in ad2s1210_initial()
1122 ret = regmap_write(st->regmap, AD2S1210_REG_CONTROL, data); in ad2s1210_initial()
1133 if (chan->type == IIO_ANGL) { in ad2s1210_read_label()
1134 if (chan->channel == 0) in ad2s1210_read_label()
1136 if (chan->channel == 1) in ad2s1210_read_label()
1139 if (chan->type == IIO_ANGL_VEL) in ad2s1210_read_label()
1141 if (chan->type == IIO_PHASE) in ad2s1210_read_label()
1143 if (chan->type == IIO_ALTVOLTAGE) { in ad2s1210_read_label()
1144 if (chan->output) in ad2s1210_read_label()
1146 if (chan->channel == 0) in ad2s1210_read_label()
1148 if (chan->channel == 1) in ad2s1210_read_label()
1150 if (chan->channel == 2) in ad2s1210_read_label()
1154 return -EINVAL; in ad2s1210_read_label()
1166 switch (chan->type) { in ad2s1210_read_event_value()
1174 return -EINVAL; in ad2s1210_read_event_value()
1177 if (chan->output) in ad2s1210_read_event_value()
1178 return -EINVAL; in ad2s1210_read_event_value()
1188 return -EINVAL; in ad2s1210_read_event_value()
1192 return -EINVAL; in ad2s1210_read_event_value()
1205 switch (chan->type) { in ad2s1210_write_event_value()
1213 return -EINVAL; in ad2s1210_write_event_value()
1216 if (chan->output) in ad2s1210_write_event_value()
1217 return -EINVAL; in ad2s1210_write_event_value()
1227 return -EINVAL; in ad2s1210_write_event_value()
1231 return -EINVAL; in ad2s1210_write_event_value()
1241 if (chan->type == IIO_ANGL) in ad2s1210_read_event_label()
1243 if (chan->type == IIO_ANGL_VEL) in ad2s1210_read_event_label()
1245 if (chan->type == IIO_PHASE) in ad2s1210_read_event_label()
1247 if (chan->type == IIO_ALTVOLTAGE) { in ad2s1210_read_event_label()
1248 if (chan->channel == 0) { in ad2s1210_read_event_label()
1258 if (chan->channel == 1 || chan->channel == 2) in ad2s1210_read_event_label()
1262 return -EINVAL; in ad2s1210_read_event_label()
1271 guard(mutex)(&st->lock); in ad2s1210_debugfs_reg_access()
1274 return regmap_read(st->regmap, reg, readval); in ad2s1210_debugfs_reg_access()
1276 return regmap_write(st->regmap, reg, writeval); in ad2s1210_debugfs_reg_access()
1282 struct iio_dev *indio_dev = pf->indio_dev; in ad2s1210_trigger_handler()
1287 guard(mutex)(&st->lock); in ad2s1210_trigger_handler()
1289 memset(&st->scan, 0, sizeof(st->scan)); in ad2s1210_trigger_handler()
1292 if (test_bit(0, indio_dev->active_scan_mask)) { in ad2s1210_trigger_handler()
1293 if (st->fixed_mode == MOD_CONFIG) { in ad2s1210_trigger_handler()
1294 ret = regmap_bulk_read(st->regmap, in ad2s1210_trigger_handler()
1296 &st->sample.raw, 2); in ad2s1210_trigger_handler()
1304 ret = spi_read(st->sdev, &st->sample, 3); in ad2s1210_trigger_handler()
1309 memcpy(&st->scan.chan[chan++], &st->sample.raw, 2); in ad2s1210_trigger_handler()
1312 if (test_bit(1, indio_dev->active_scan_mask)) { in ad2s1210_trigger_handler()
1313 if (st->fixed_mode == MOD_CONFIG) { in ad2s1210_trigger_handler()
1314 ret = regmap_bulk_read(st->regmap, in ad2s1210_trigger_handler()
1316 &st->sample.raw, 2); in ad2s1210_trigger_handler()
1324 ret = spi_read(st->sdev, &st->sample, 3); in ad2s1210_trigger_handler()
1329 memcpy(&st->scan.chan[chan++], &st->sample.raw, 2); in ad2s1210_trigger_handler()
1332 if (st->fixed_mode == MOD_CONFIG) { in ad2s1210_trigger_handler()
1335 ret = regmap_read(st->regmap, AD2S1210_REG_FAULT, &reg_val); in ad2s1210_trigger_handler()
1339 st->sample.fault = reg_val; in ad2s1210_trigger_handler()
1342 ad2s1210_push_events(indio_dev, st->sample.fault, pf->timestamp); in ad2s1210_trigger_handler()
1343 iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, pf->timestamp); in ad2s1210_trigger_handler()
1346 iio_trigger_notify_done(indio_dev->trig); in ad2s1210_trigger_handler()
1365 struct device *dev = &st->sdev->dev; in ad2s1210_setup_properties()
1370 ret = device_property_read_string(dev, "adi,fixed-mode", &str_val); in ad2s1210_setup_properties()
1371 if (ret == -EINVAL) in ad2s1210_setup_properties()
1372 st->fixed_mode = -1; in ad2s1210_setup_properties()
1375 "failed to read adi,fixed-mode property\n"); in ad2s1210_setup_properties()
1378 return dev_err_probe(dev, -EINVAL, in ad2s1210_setup_properties()
1379 "only adi,fixed-mode=\"config\" is supported\n"); in ad2s1210_setup_properties()
1381 st->fixed_mode = MOD_CONFIG; in ad2s1210_setup_properties()
1384 ret = device_property_read_u32(dev, "assigned-resolution-bits", &val); in ad2s1210_setup_properties()
1387 "failed to read assigned-resolution-bits property\n"); in ad2s1210_setup_properties()
1390 return dev_err_probe(dev, -EINVAL, in ad2s1210_setup_properties()
1393 st->resolution = (val - 10) >> 1; in ad2s1210_setup_properties()
1397 * hysteresis is +/- 1 LSB of the raw position value. Which bit is the in ad2s1210_setup_properties()
1400 st->hysteresis_available[0] = 0; in ad2s1210_setup_properties()
1401 st->hysteresis_available[1] = 1 << (2 * (AD2S1210_RES_16 - in ad2s1210_setup_properties()
1402 st->resolution)); in ad2s1210_setup_properties()
1409 struct device *dev = &st->sdev->dev; in ad2s1210_setup_clocks()
1416 st->clkin_hz = clk_get_rate(clk); in ad2s1210_setup_clocks()
1417 if (st->clkin_hz < AD2S1210_MIN_CLKIN || st->clkin_hz > AD2S1210_MAX_CLKIN) in ad2s1210_setup_clocks()
1418 return dev_err_probe(dev, -EINVAL, in ad2s1210_setup_clocks()
1420 st->clkin_hz); in ad2s1210_setup_clocks()
1427 struct device *dev = &st->sdev->dev; in ad2s1210_setup_gpios()
1434 st->sample_gpio = devm_gpiod_get(dev, "sample", GPIOD_OUT_LOW); in ad2s1210_setup_gpios()
1435 if (IS_ERR(st->sample_gpio)) in ad2s1210_setup_gpios()
1436 return dev_err_probe(dev, PTR_ERR(st->sample_gpio), in ad2s1210_setup_gpios()
1439 /* both pins high means that we start in config mode */ in ad2s1210_setup_gpios()
1440 st->mode_gpios = devm_gpiod_get_array_optional(dev, "mode", in ad2s1210_setup_gpios()
1442 if (IS_ERR(st->mode_gpios)) in ad2s1210_setup_gpios()
1443 return dev_err_probe(dev, PTR_ERR(st->mode_gpios), in ad2s1210_setup_gpios()
1444 "failed to request mode GPIOs\n"); in ad2s1210_setup_gpios()
1446 if (!st->mode_gpios && st->fixed_mode == -1) in ad2s1210_setup_gpios()
1447 return dev_err_probe(dev, -EINVAL, in ad2s1210_setup_gpios()
1448 "must specify either adi,fixed-mode or mode-gpios\n"); in ad2s1210_setup_gpios()
1450 if (st->mode_gpios && st->fixed_mode != -1) in ad2s1210_setup_gpios()
1451 return dev_err_probe(dev, -EINVAL, in ad2s1210_setup_gpios()
1452 "must specify only one of adi,fixed-mode or mode-gpios\n"); in ad2s1210_setup_gpios()
1454 if (st->mode_gpios && st->mode_gpios->ndescs != 2) in ad2s1210_setup_gpios()
1455 return dev_err_probe(dev, -EINVAL, in ad2s1210_setup_gpios()
1456 "requires exactly 2 mode-gpios\n"); in ad2s1210_setup_gpios()
1461 * hard-wired to match the resolution indicated in the devicetree. in ad2s1210_setup_gpios()
1470 if (resolution_gpios->ndescs != 2) in ad2s1210_setup_gpios()
1471 return dev_err_probe(dev, -EINVAL, in ad2s1210_setup_gpios()
1472 "requires exactly 2 resolution-gpios\n"); in ad2s1210_setup_gpios()
1474 bitmap[0] = st->resolution; in ad2s1210_setup_gpios()
1476 ret = gpiod_set_array_value(resolution_gpios->ndescs, in ad2s1210_setup_gpios()
1477 resolution_gpios->desc, in ad2s1210_setup_gpios()
1478 resolution_gpios->info, in ad2s1210_setup_gpios()
1525 struct device *dev = &st->sdev->dev; in ad2s1210_setup_regmap()
1537 st->regmap = devm_regmap_init(dev, NULL, st, &config); in ad2s1210_setup_regmap()
1538 if (IS_ERR(st->regmap)) in ad2s1210_setup_regmap()
1539 return dev_err_probe(dev, PTR_ERR(st->regmap), in ad2s1210_setup_regmap()
1551 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad2s1210_probe()
1553 return -ENOMEM; in ad2s1210_probe()
1556 mutex_init(&st->lock); in ad2s1210_probe()
1557 st->sdev = spi; in ad2s1210_probe()
1579 indio_dev->info = &ad2s1210_info; in ad2s1210_probe()
1580 indio_dev->modes = INDIO_DIRECT_MODE; in ad2s1210_probe()
1581 indio_dev->channels = ad2s1210_channels; in ad2s1210_probe()
1582 indio_dev->num_channels = ARRAY_SIZE(ad2s1210_channels); in ad2s1210_probe()
1583 indio_dev->name = spi_get_device_id(spi)->name; in ad2s1210_probe()
1585 ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, in ad2s1210_probe()
1589 return dev_err_probe(&spi->dev, ret, in ad2s1210_probe()
1592 return devm_iio_device_register(&spi->dev, indio_dev); in ad2s1210_probe()
1618 MODULE_DESCRIPTION("Analog Devices AD2S1210 Resolver to Digital SPI driver");