Lines Matching +full:n +full:- +full:factor

1 // SPDX-License-Identifier: GPL-2.0
92 st->d8[0] = AD7292_RD_FLAG_MSK(addr); in ad7292_spi_reg_read()
94 ret = spi_write_then_read(st->spi, st->d8, 1, &st->d16, 2); in ad7292_spi_reg_read()
98 return be16_to_cpu(st->d16); in ad7292_spi_reg_read()
104 unsigned int shift = 16 - (8 * len); in ad7292_spi_subreg_read()
107 st->d8[0] = AD7292_RD_FLAG_MSK(addr); in ad7292_spi_subreg_read()
108 st->d8[1] = sub_addr; in ad7292_spi_subreg_read()
110 ret = spi_write_then_read(st->spi, st->d8, 2, &st->d16, len); in ad7292_spi_subreg_read()
114 return (be16_to_cpu(st->d16) >> shift); in ad7292_spi_subreg_read()
124 .tx_buf = &st->d8, in ad7292_single_conversion()
131 .rx_buf = &st->d16, in ad7292_single_conversion()
136 st->d8[0] = chan_addr; in ad7292_single_conversion()
137 st->d8[1] = AD7292_RD_FLAG_MSK(AD7292_REG_CONV_COMM); in ad7292_single_conversion()
139 ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); in ad7292_single_conversion()
144 return be16_to_cpu(st->d16); in ad7292_single_conversion()
149 int samp_mode, range0, range1, factor = 1; in ad7292_vin_range_multiplier() local
155 * may be increased by a multiplier factor of 2 or 4 according to the in ad7292_vin_range_multiplier()
158 * factor = 4 if VIN range0 and VIN range1 equal 0 in ad7292_vin_range_multiplier()
159 * factor = 2 if only one of VIN ranges equal 1 in ad7292_vin_range_multiplier()
160 * factor = 1 if both VIN range0 and VIN range1 equal 1 in ad7292_vin_range_multiplier()
162 * factor = 4 if VIN range0 and VIN range1 equal 0 in ad7292_vin_range_multiplier()
187 factor *= 2; in ad7292_vin_range_multiplier()
190 factor *= 2; in ad7292_vin_range_multiplier()
196 return -EPERM; in ad7292_vin_range_multiplier()
198 factor = 4; in ad7292_vin_range_multiplier()
201 return factor; in ad7292_vin_range_multiplier()
214 ch_addr = AD7292_REG_ADC_CH(chan->channel); in ad7292_read_raw()
235 ret = ad7292_vin_range_multiplier(st, chan->channel); in ad7292_read_raw()
239 *val = st->vref_mv * ret; in ad7292_read_raw()
245 return -EINVAL; in ad7292_read_raw()
256 regulator_disable(st->reg); in ad7292_regulator_disable()
267 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7292_probe()
269 return -ENOMEM; in ad7292_probe()
272 st->spi = spi; in ad7292_probe()
276 dev_err(&spi->dev, "Wrong vendor id 0x%x\n", ret); in ad7292_probe()
277 return -EINVAL; in ad7292_probe()
280 st->reg = devm_regulator_get_optional(&spi->dev, "vref"); in ad7292_probe()
281 if (!IS_ERR(st->reg)) { in ad7292_probe()
282 ret = regulator_enable(st->reg); in ad7292_probe()
284 dev_err(&spi->dev, in ad7292_probe()
285 "Failed to enable external vref supply\n"); in ad7292_probe()
289 ret = devm_add_action_or_reset(&spi->dev, in ad7292_probe()
294 ret = regulator_get_voltage(st->reg); in ad7292_probe()
298 st->vref_mv = ret / 1000; in ad7292_probe()
301 st->vref_mv = 1250; in ad7292_probe()
304 indio_dev->name = spi_get_device_id(spi)->name; in ad7292_probe()
305 indio_dev->modes = INDIO_DIRECT_MODE; in ad7292_probe()
306 indio_dev->info = &ad7292_info; in ad7292_probe()
308 for_each_available_child_of_node(spi->dev.of_node, child) { in ad7292_probe()
309 diff_channels = of_property_read_bool(child, "diff-channels"); in ad7292_probe()
317 indio_dev->num_channels = ARRAY_SIZE(ad7292_channels_diff); in ad7292_probe()
318 indio_dev->channels = ad7292_channels_diff; in ad7292_probe()
320 indio_dev->num_channels = ARRAY_SIZE(ad7292_channels); in ad7292_probe()
321 indio_dev->channels = ad7292_channels; in ad7292_probe()
324 return devm_iio_device_register(&spi->dev, indio_dev); in ad7292_probe()