Lines Matching full:adc

3  * MAX1241 low-power, 12-bit serial ADC
42 static int max1241_read(struct max1241 *adc) in max1241_read() argument
58 .rx_buf = &adc->data, in max1241_read()
63 return spi_sync_transfer(adc->spi, xfers, ARRAY_SIZE(xfers)); in max1241_read()
71 struct max1241 *adc = iio_priv(indio_dev); in max1241_read_raw() local
75 mutex_lock(&adc->lock); in max1241_read_raw()
77 if (adc->shutdown) { in max1241_read_raw()
78 gpiod_set_value(adc->shutdown, 0); in max1241_read_raw()
80 ret = max1241_read(adc); in max1241_read_raw()
81 gpiod_set_value(adc->shutdown, 1); in max1241_read_raw()
83 ret = max1241_read(adc); in max1241_read_raw()
86 mutex_unlock(&adc->lock); in max1241_read_raw()
90 *val = (be16_to_cpu(adc->data) >> 3) & MAX1241_VAL_MASK; in max1241_read_raw()
92 mutex_unlock(&adc->lock); in max1241_read_raw()
95 vref_uV = regulator_get_voltage(adc->vref); in max1241_read_raw()
115 struct max1241 *adc = data; in max1241_disable_vdd_action() local
116 struct device *dev = &adc->spi->dev; in max1241_disable_vdd_action()
119 err = regulator_disable(adc->vdd); in max1241_disable_vdd_action()
126 struct max1241 *adc = data; in max1241_disable_vref_action() local
127 struct device *dev = &adc->spi->dev; in max1241_disable_vref_action()
130 err = regulator_disable(adc->vref); in max1241_disable_vref_action()
139 struct max1241 *adc; in max1241_probe() local
142 indio_dev = devm_iio_device_alloc(dev, sizeof(*adc)); in max1241_probe()
146 adc = iio_priv(indio_dev); in max1241_probe()
147 adc->spi = spi; in max1241_probe()
148 mutex_init(&adc->lock); in max1241_probe()
150 adc->vdd = devm_regulator_get(dev, "vdd"); in max1241_probe()
151 if (IS_ERR(adc->vdd)) in max1241_probe()
152 return dev_err_probe(dev, PTR_ERR(adc->vdd), in max1241_probe()
155 ret = regulator_enable(adc->vdd); in max1241_probe()
159 ret = devm_add_action_or_reset(dev, max1241_disable_vdd_action, adc); in max1241_probe()
165 adc->vref = devm_regulator_get(dev, "vref"); in max1241_probe()
166 if (IS_ERR(adc->vref)) in max1241_probe()
167 return dev_err_probe(dev, PTR_ERR(adc->vref), in max1241_probe()
170 ret = regulator_enable(adc->vref); in max1241_probe()
174 ret = devm_add_action_or_reset(dev, max1241_disable_vref_action, adc); in max1241_probe()
180 adc->shutdown = devm_gpiod_get_optional(dev, "shutdown", in max1241_probe()
182 if (IS_ERR(adc->shutdown)) in max1241_probe()
183 return dev_err_probe(dev, PTR_ERR(adc->shutdown), in max1241_probe()
186 if (adc->shutdown) in max1241_probe()
222 MODULE_DESCRIPTION("MAX1241 ADC driver");