Lines Matching +full:max1240 +full:- +full:max1241
1 // SPDX-License-Identifier: GPL-2.0-only
3 * MAX1241 low-power, 12-bit serial ADC
5 * Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX1240-MAX1241.pdf
19 max1241, enumerator
22 struct max1241 { struct
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()
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()
81 gpiod_set_value(adc->shutdown, 1); 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()
105 return -EINVAL; in max1241_read_raw()
115 struct max1241 *adc = data; in max1241_disable_vdd_action()
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()
127 struct device *dev = &adc->spi->dev; in max1241_disable_vref_action()
130 err = regulator_disable(adc->vref); in max1241_disable_vref_action()
137 struct device *dev = &spi->dev; in max1241_probe()
139 struct max1241 *adc; in max1241_probe()
144 return -ENOMEM; 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()
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()
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()
187 dev_dbg(dev, "shutdown pin passed, low-power mode enabled"); in max1241_probe()
189 dev_dbg(dev, "no shutdown pin passed, low-power mode disabled"); in max1241_probe()
191 indio_dev->name = spi_get_device_id(spi)->name; in max1241_probe()
192 indio_dev->info = &max1241_info; in max1241_probe()
193 indio_dev->modes = INDIO_DIRECT_MODE; in max1241_probe()
194 indio_dev->channels = max1241_channels; in max1241_probe()
195 indio_dev->num_channels = ARRAY_SIZE(max1241_channels); in max1241_probe()
201 { "max1241", max1241 },
206 { .compatible = "maxim,max1241" },
213 .name = "max1241",
222 MODULE_DESCRIPTION("MAX1241 ADC driver");