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
41 static int max1241_read(struct max1241 *adc) in max1241_read() argument
57 .rx_buf = &adc->data, in max1241_read()
62 return spi_sync_transfer(adc->spi, xfers, ARRAY_SIZE(xfers)); in max1241_read()
70 struct max1241 *adc = iio_priv(indio_dev); in max1241_read_raw()
74 mutex_lock(&adc->lock); in max1241_read_raw()
76 if (adc->shutdown) { in max1241_read_raw()
77 gpiod_set_value(adc->shutdown, 0); in max1241_read_raw()
80 gpiod_set_value(adc->shutdown, 1); in max1241_read_raw()
85 mutex_unlock(&adc->lock); in max1241_read_raw()
89 *val = (be16_to_cpu(adc->data) >> 3) & MAX1241_VAL_MASK; in max1241_read_raw()
91 mutex_unlock(&adc->lock); in max1241_read_raw()
94 vref_uV = regulator_get_voltage(adc->vref); in max1241_read_raw()
104 return -EINVAL; in max1241_read_raw()
114 struct max1241 *adc = data; in max1241_disable_vref_action()
115 struct device *dev = &adc->spi->dev; in max1241_disable_vref_action()
118 err = regulator_disable(adc->vref); in max1241_disable_vref_action()
125 struct device *dev = &spi->dev; in max1241_probe()
127 struct max1241 *adc; in max1241_probe()
132 return -ENOMEM; in max1241_probe()
135 adc->spi = spi; in max1241_probe()
136 mutex_init(&adc->lock); in max1241_probe()
143 adc->vref = devm_regulator_get(dev, "vref"); in max1241_probe()
144 if (IS_ERR(adc->vref)) in max1241_probe()
145 return dev_err_probe(dev, PTR_ERR(adc->vref), in max1241_probe()
148 ret = regulator_enable(adc->vref); in max1241_probe()
158 adc->shutdown = devm_gpiod_get_optional(dev, "shutdown", in max1241_probe()
160 if (IS_ERR(adc->shutdown)) in max1241_probe()
161 return dev_err_probe(dev, PTR_ERR(adc->shutdown), in max1241_probe()
164 if (adc->shutdown) in max1241_probe()
165 dev_dbg(dev, "shutdown pin passed, low-power mode enabled"); in max1241_probe()
167 dev_dbg(dev, "no shutdown pin passed, low-power mode disabled"); in max1241_probe()
169 indio_dev->name = spi_get_device_id(spi)->name; in max1241_probe()
170 indio_dev->info = &max1241_info; in max1241_probe()
171 indio_dev->modes = INDIO_DIRECT_MODE; in max1241_probe()
172 indio_dev->channels = max1241_channels; in max1241_probe()
173 indio_dev->num_channels = ARRAY_SIZE(max1241_channels); in max1241_probe()
179 { "max1241", max1241 },
184 { .compatible = "maxim,max1241" },
191 .name = "max1241",
200 MODULE_DESCRIPTION("MAX1241 ADC driver");