Lines Matching +full:sens +full:-
1 // SPDX-License-Identifier: GPL-2.0
8 * http://www.meas-spec.com/downloads/MS5611-01BA03.pdf
9 * http://www.meas-spec.com/downloads/MS5607-02BA03.pdf
88 ret = st->read_prom_word(st, i, &st->prom[i]); in ms5611_read_prom()
90 dev_err(&indio_dev->dev, in ms5611_read_prom()
96 if (!ms5611_prom_is_valid(st->prom, MS5611_PROM_WORDS_NB)) { in ms5611_read_prom()
97 dev_err(&indio_dev->dev, "PROM integrity check failed\n"); in ms5611_read_prom()
98 return -ENODEV; in ms5611_read_prom()
110 ret = st->read_adc_temp_and_pressure(st, temp, pressure); in ms5611_read_temp_and_pressure()
112 dev_err(&indio_dev->dev, in ms5611_read_temp_and_pressure()
117 return st->compensate_temp_and_pressure(st, temp, pressure); in ms5611_read_temp_and_pressure()
124 s64 off, sens, dt; in ms5611_temp_and_pressure_compensate() local
126 dt = t - (st->prom[5] << 8); in ms5611_temp_and_pressure_compensate()
127 off = ((s64)st->prom[2] << 16) + ((st->prom[4] * dt) >> 7); in ms5611_temp_and_pressure_compensate()
128 sens = ((s64)st->prom[1] << 15) + ((st->prom[3] * dt) >> 8); in ms5611_temp_and_pressure_compensate()
130 t = 2000 + ((st->prom[6] * dt) >> 23); in ms5611_temp_and_pressure_compensate()
135 off2 = (5 * (t - 2000) * (t - 2000)) >> 1; in ms5611_temp_and_pressure_compensate()
138 if (t < -1500) { in ms5611_temp_and_pressure_compensate()
145 t -= t2; in ms5611_temp_and_pressure_compensate()
146 off -= off2; in ms5611_temp_and_pressure_compensate()
147 sens -= sens2; in ms5611_temp_and_pressure_compensate()
151 *pressure = (((p * sens) >> 21) - off) >> 15; in ms5611_temp_and_pressure_compensate()
160 s64 off, sens, dt; in ms5607_temp_and_pressure_compensate() local
162 dt = t - (st->prom[5] << 8); in ms5607_temp_and_pressure_compensate()
163 off = ((s64)st->prom[2] << 17) + ((st->prom[4] * dt) >> 6); in ms5607_temp_and_pressure_compensate()
164 sens = ((s64)st->prom[1] << 16) + ((st->prom[3] * dt) >> 7); in ms5607_temp_and_pressure_compensate()
166 t = 2000 + ((st->prom[6] * dt) >> 23); in ms5607_temp_and_pressure_compensate()
171 tmp = (t - 2000) * (t - 2000); in ms5607_temp_and_pressure_compensate()
175 if (t < -1500) { in ms5607_temp_and_pressure_compensate()
181 t -= t2; in ms5607_temp_and_pressure_compensate()
182 off -= off2; in ms5607_temp_and_pressure_compensate()
183 sens -= sens2; in ms5607_temp_and_pressure_compensate()
187 *pressure = (((p * sens) >> 21) - off) >> 15; in ms5607_temp_and_pressure_compensate()
197 ret = st->reset(st); in ms5611_reset()
199 dev_err(&indio_dev->dev, "failed to reset device\n"); in ms5611_reset()
211 struct iio_dev *indio_dev = pf->indio_dev; in ms5611_trigger_handler()
220 mutex_lock(&st->lock); in ms5611_trigger_handler()
223 mutex_unlock(&st->lock); in ms5611_trigger_handler()
231 iio_trigger_notify_done(indio_dev->trig); in ms5611_trigger_handler()
246 mutex_lock(&st->lock); in ms5611_read_raw()
249 mutex_unlock(&st->lock); in ms5611_read_raw()
253 switch (chan->type) { in ms5611_read_raw()
262 return -EINVAL; in ms5611_read_raw()
265 switch (chan->type) { in ms5611_read_raw()
274 return -EINVAL; in ms5611_read_raw()
277 if (chan->type != IIO_TEMP && chan->type != IIO_PRESSURE) in ms5611_read_raw()
279 mutex_lock(&st->lock); in ms5611_read_raw()
280 if (chan->type == IIO_TEMP) in ms5611_read_raw()
281 *val = (int)st->temp_osr->rate; in ms5611_read_raw()
283 *val = (int)st->pressure_osr->rate; in ms5611_read_raw()
284 mutex_unlock(&st->lock); in ms5611_read_raw()
288 return -EINVAL; in ms5611_read_raw()
314 return -EINVAL; in ms5611_write_raw()
316 if (chan->type == IIO_TEMP) in ms5611_write_raw()
319 else if (chan->type == IIO_PRESSURE) in ms5611_write_raw()
323 return -EINVAL; in ms5611_write_raw()
329 mutex_lock(&st->lock); in ms5611_write_raw()
331 if (chan->type == IIO_TEMP) in ms5611_write_raw()
332 st->temp_osr = osr; in ms5611_write_raw()
334 st->pressure_osr = osr; in ms5611_write_raw()
336 mutex_unlock(&st->lock); in ms5611_write_raw()
385 ret = devm_regulator_get_enable(indio_dev->dev.parent, "vdd"); in ms5611_init()
406 mutex_init(&st->lock); in ms5611_probe()
410 st->compensate_temp_and_pressure = in ms5611_probe()
414 st->compensate_temp_and_pressure = in ms5611_probe()
418 return -EINVAL; in ms5611_probe()
421 st->temp_osr = in ms5611_probe()
422 &ms5611_avail_temp_osr[ARRAY_SIZE(ms5611_avail_temp_osr) - 1]; in ms5611_probe()
423 st->pressure_osr = in ms5611_probe()
425 - 1]; in ms5611_probe()
426 indio_dev->name = name; in ms5611_probe()
427 indio_dev->info = &ms5611_info; in ms5611_probe()
428 indio_dev->channels = ms5611_channels; in ms5611_probe()
429 indio_dev->num_channels = ARRAY_SIZE(ms5611_channels); in ms5611_probe()
430 indio_dev->modes = INDIO_DIRECT_MODE; in ms5611_probe()
431 indio_dev->available_scan_masks = ms5611_scan_masks; in ms5611_probe()