Lines Matching +full:vref +full:- +full:mv
1 // SPDX-License-Identifier: GPL-2.0
57 *val = priv->value[chan->channel]; in ltc1660_read_raw()
60 *val = regulator_get_voltage(priv->vref_reg); in ltc1660_read_raw()
62 dev_err(&priv->spi->dev, "failed to read vref regulator: %d\n", in ltc1660_read_raw()
67 /* Convert to mV */ in ltc1660_read_raw()
69 *val2 = chan->scan_type.realbits; in ltc1660_read_raw()
72 return -EINVAL; in ltc1660_read_raw()
88 return -EINVAL; in ltc1660_write_raw()
90 if (val < 0 || val > GENMASK(chan->scan_type.realbits - 1, 0)) in ltc1660_write_raw()
91 return -EINVAL; in ltc1660_write_raw()
93 ret = regmap_write(priv->regmap, chan->channel, in ltc1660_write_raw()
94 (val << chan->scan_type.shift)); in ltc1660_write_raw()
96 priv->value[chan->channel] = val; in ltc1660_write_raw()
100 return -EINVAL; in ltc1660_write_raw()
115 .shift = 12 - (bits), \
144 return regmap_write(priv->regmap, LTC1660_REG_SLEEP, 0x00); in ltc1660_suspend()
151 return regmap_write(priv->regmap, LTC1660_REG_WAKE, 0x00); in ltc1660_resume()
163 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*priv)); in ltc1660_probe()
165 return -ENOMEM; in ltc1660_probe()
168 priv->regmap = devm_regmap_init_spi(spi, <c1660_regmap_config); in ltc1660_probe()
169 if (IS_ERR(priv->regmap)) { in ltc1660_probe()
170 dev_err(&spi->dev, "failed to register spi regmap %ld\n", in ltc1660_probe()
171 PTR_ERR(priv->regmap)); in ltc1660_probe()
172 return PTR_ERR(priv->regmap); in ltc1660_probe()
175 priv->vref_reg = devm_regulator_get(&spi->dev, "vref"); in ltc1660_probe()
176 if (IS_ERR(priv->vref_reg)) in ltc1660_probe()
177 return dev_err_probe(&spi->dev, PTR_ERR(priv->vref_reg), in ltc1660_probe()
178 "vref regulator not specified\n"); in ltc1660_probe()
180 ret = regulator_enable(priv->vref_reg); in ltc1660_probe()
182 dev_err(&spi->dev, "failed to enable vref regulator: %d\n", in ltc1660_probe()
187 priv->spi = spi; in ltc1660_probe()
189 indio_dev->info = <c1660_info; in ltc1660_probe()
190 indio_dev->modes = INDIO_DIRECT_MODE; in ltc1660_probe()
191 indio_dev->channels = ltc1660_channels[id->driver_data]; in ltc1660_probe()
192 indio_dev->num_channels = LTC1660_NUM_CHANNELS; in ltc1660_probe()
193 indio_dev->name = id->name; in ltc1660_probe()
197 dev_err(&spi->dev, "failed to register iio device: %d\n", in ltc1660_probe()
205 regulator_disable(priv->vref_reg); in ltc1660_probe()
216 regulator_disable(priv->vref_reg); in ltc1660_remove()