Lines Matching +full:per +full:- +full:mille
1 // SPDX-License-Identifier: GPL-2.0-or-later
92 /* 3-axis gyro + temperature */
103 struct inv_sensors_timestamp *ts = &gyro_st->ts; in inv_icm42600_gyro_update_scan_mode()
111 mutex_lock(&st->lock); in inv_icm42600_gyro_update_scan_mode()
132 ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en); in inv_icm42600_gyro_update_scan_mode()
135 mutex_unlock(&st->lock); in inv_icm42600_gyro_update_scan_mode()
147 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_read_sensor()
153 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_read_sensor()
154 return -EINVAL; in inv_icm42600_gyro_read_sensor()
156 switch (chan->channel2) { in inv_icm42600_gyro_read_sensor()
167 return -EINVAL; in inv_icm42600_gyro_read_sensor()
171 mutex_lock(&st->lock); in inv_icm42600_gyro_read_sensor()
180 data = (__be16 *)&st->buffer[0]; in inv_icm42600_gyro_read_sensor()
181 ret = regmap_bulk_read(st->map, reg, data, sizeof(*data)); in inv_icm42600_gyro_read_sensor()
187 ret = -EINVAL; in inv_icm42600_gyro_read_sensor()
189 mutex_unlock(&st->lock); in inv_icm42600_gyro_read_sensor()
197 /* +/- 2000dps => 0.001065264 rad/s */
200 /* +/- 1000dps => 0.000532632 rad/s */
203 /* +/- 500dps => 0.000266316 rad/s */
206 /* +/- 250dps => 0.000133158 rad/s */
209 /* +/- 125dps => 0.000066579 rad/s */
212 /* +/- 62.5dps => 0.000033290 rad/s */
215 /* +/- 31.25dps => 0.000016645 rad/s */
218 /* +/- 15.625dps => 0.000008322 rad/s */
223 /* +/- 4000dps => 0.002130529 rad/s */
226 /* +/- 2000dps => 0.001065264 rad/s */
229 /* +/- 1000dps => 0.000532632 rad/s */
232 /* +/- 500dps => 0.000266316 rad/s */
235 /* +/- 250dps => 0.000133158 rad/s */
238 /* +/- 125dps => 0.000066579 rad/s */
241 /* +/- 62.5dps => 0.000033290 rad/s */
244 /* +/- 31.25dps => 0.000016645 rad/s */
256 idx = st->conf.gyro.fs; in inv_icm42600_gyro_read_scale()
258 *val = gyro_st->scales[2 * idx]; in inv_icm42600_gyro_read_scale()
259 *val2 = gyro_st->scales[2 * idx + 1]; in inv_icm42600_gyro_read_scale()
268 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_write_scale()
273 for (idx = 0; idx < gyro_st->scales_len; idx += 2) { in inv_icm42600_gyro_write_scale()
274 if (val == gyro_st->scales[idx] && in inv_icm42600_gyro_write_scale()
275 val2 == gyro_st->scales[idx + 1]) in inv_icm42600_gyro_write_scale()
278 if (idx >= gyro_st->scales_len) in inv_icm42600_gyro_write_scale()
279 return -EINVAL; in inv_icm42600_gyro_write_scale()
284 mutex_lock(&st->lock); in inv_icm42600_gyro_write_scale()
288 mutex_unlock(&st->lock); in inv_icm42600_gyro_write_scale()
332 odr = st->conf.gyro.odr; in inv_icm42600_gyro_read_odr()
339 return -EINVAL; in inv_icm42600_gyro_read_odr()
352 struct inv_sensors_timestamp *ts = &gyro_st->ts; in inv_icm42600_gyro_write_odr()
353 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_write_odr()
364 return -EINVAL; in inv_icm42600_gyro_write_odr()
369 mutex_lock(&st->lock); in inv_icm42600_gyro_write_odr()
383 mutex_unlock(&st->lock); in inv_icm42600_gyro_write_odr()
392 * Value is limited to +/-64dps coded on 12 bits signed. Step is 1/32 dps.
395 -1, 117010721, /* min: -1.117010721 rad/s */
404 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_read_offset()
412 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_read_offset()
413 return -EINVAL; in inv_icm42600_gyro_read_offset()
415 switch (chan->channel2) { in inv_icm42600_gyro_read_offset()
426 return -EINVAL; in inv_icm42600_gyro_read_offset()
430 mutex_lock(&st->lock); in inv_icm42600_gyro_read_offset()
432 ret = regmap_bulk_read(st->map, reg, st->buffer, sizeof(data)); in inv_icm42600_gyro_read_offset()
433 memcpy(data, st->buffer, sizeof(data)); in inv_icm42600_gyro_read_offset()
435 mutex_unlock(&st->lock); in inv_icm42600_gyro_read_offset()
442 switch (chan->channel2) { in inv_icm42600_gyro_read_offset()
453 return -EINVAL; in inv_icm42600_gyro_read_offset()
464 /* for rounding, add + or - divisor (2048 * 180) divided by 2 */ in inv_icm42600_gyro_read_offset()
468 val64 -= 2048 * 180 / 2; in inv_icm42600_gyro_read_offset()
480 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_write_offset()
486 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_write_offset()
487 return -EINVAL; in inv_icm42600_gyro_write_offset()
489 switch (chan->channel2) { in inv_icm42600_gyro_write_offset()
500 return -EINVAL; in inv_icm42600_gyro_write_offset()
503 /* inv_icm42600_gyro_calibbias: min - step - max in nano */ in inv_icm42600_gyro_write_offset()
510 return -EINVAL; in inv_icm42600_gyro_write_offset()
520 /* for rounding, add + or - divisor (3141592653 * 64) divided by 2 */ in inv_icm42600_gyro_write_offset()
524 val64 -= 3141592653LL * 64LL / 2LL; in inv_icm42600_gyro_write_offset()
528 if (offset < -2048) in inv_icm42600_gyro_write_offset()
529 offset = -2048; in inv_icm42600_gyro_write_offset()
534 mutex_lock(&st->lock); in inv_icm42600_gyro_write_offset()
536 switch (chan->channel2) { in inv_icm42600_gyro_write_offset()
539 ret = regmap_read(st->map, INV_ICM42600_REG_OFFSET_USER1, in inv_icm42600_gyro_write_offset()
543 st->buffer[0] = offset & 0xFF; in inv_icm42600_gyro_write_offset()
544 st->buffer[1] = (regval & 0xF0) | ((offset & 0xF00) >> 8); in inv_icm42600_gyro_write_offset()
548 ret = regmap_read(st->map, INV_ICM42600_REG_OFFSET_USER1, in inv_icm42600_gyro_write_offset()
552 st->buffer[0] = ((offset & 0xF00) >> 4) | (regval & 0x0F); in inv_icm42600_gyro_write_offset()
553 st->buffer[1] = offset & 0xFF; in inv_icm42600_gyro_write_offset()
557 ret = regmap_read(st->map, INV_ICM42600_REG_OFFSET_USER4, in inv_icm42600_gyro_write_offset()
561 st->buffer[0] = offset & 0xFF; in inv_icm42600_gyro_write_offset()
562 st->buffer[1] = (regval & 0xF0) | ((offset & 0xF00) >> 8); in inv_icm42600_gyro_write_offset()
565 ret = -EINVAL; in inv_icm42600_gyro_write_offset()
569 ret = regmap_bulk_write(st->map, reg, st->buffer, 2); in inv_icm42600_gyro_write_offset()
572 mutex_unlock(&st->lock); in inv_icm42600_gyro_write_offset()
586 switch (chan->type) { in inv_icm42600_gyro_read_raw()
592 return -EINVAL; in inv_icm42600_gyro_read_raw()
613 return -EINVAL; in inv_icm42600_gyro_read_raw()
624 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_read_avail()
625 return -EINVAL; in inv_icm42600_gyro_read_avail()
629 *vals = gyro_st->scales; in inv_icm42600_gyro_read_avail()
631 *length = gyro_st->scales_len; in inv_icm42600_gyro_read_avail()
643 return -EINVAL; in inv_icm42600_gyro_read_avail()
654 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_write_raw()
655 return -EINVAL; in inv_icm42600_gyro_write_raw()
675 return -EINVAL; in inv_icm42600_gyro_write_raw()
683 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_write_raw_get_fmt()
684 return -EINVAL; in inv_icm42600_gyro_write_raw_get_fmt()
694 return -EINVAL; in inv_icm42600_gyro_write_raw_get_fmt()
704 mutex_lock(&st->lock); in inv_icm42600_gyro_hwfifo_set_watermark()
706 st->fifo.watermark.gyro = val; in inv_icm42600_gyro_hwfifo_set_watermark()
709 mutex_unlock(&st->lock); in inv_icm42600_gyro_hwfifo_set_watermark()
723 mutex_lock(&st->lock); in inv_icm42600_gyro_hwfifo_flush()
727 ret = st->fifo.nb.gyro; in inv_icm42600_gyro_hwfifo_flush()
729 mutex_unlock(&st->lock); in inv_icm42600_gyro_hwfifo_flush()
747 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_init()
754 name = devm_kasprintf(dev, GFP_KERNEL, "%s-gyro", st->name); in inv_icm42600_gyro_init()
756 return ERR_PTR(-ENOMEM); in inv_icm42600_gyro_init()
760 return ERR_PTR(-ENOMEM); in inv_icm42600_gyro_init()
763 switch (st->chip) { in inv_icm42600_gyro_init()
765 gyro_st->scales = inv_icm42686_gyro_scale; in inv_icm42600_gyro_init()
766 gyro_st->scales_len = ARRAY_SIZE(inv_icm42686_gyro_scale); in inv_icm42600_gyro_init()
769 gyro_st->scales = inv_icm42600_gyro_scale; in inv_icm42600_gyro_init()
770 gyro_st->scales_len = ARRAY_SIZE(inv_icm42600_gyro_scale); in inv_icm42600_gyro_init()
776 * jitter is +/- 2% (20 per mille) in inv_icm42600_gyro_init()
780 ts_chip.init_period = inv_icm42600_odr_to_period(st->conf.accel.odr); in inv_icm42600_gyro_init()
781 inv_sensors_timestamp_init(&gyro_st->ts, &ts_chip); in inv_icm42600_gyro_init()
784 indio_dev->name = name; in inv_icm42600_gyro_init()
785 indio_dev->info = &inv_icm42600_gyro_info; in inv_icm42600_gyro_init()
786 indio_dev->modes = INDIO_DIRECT_MODE; in inv_icm42600_gyro_init()
787 indio_dev->channels = inv_icm42600_gyro_channels; in inv_icm42600_gyro_init()
788 indio_dev->num_channels = ARRAY_SIZE(inv_icm42600_gyro_channels); in inv_icm42600_gyro_init()
789 indio_dev->available_scan_masks = inv_icm42600_gyro_scan_masks; in inv_icm42600_gyro_init()
790 indio_dev->setup_ops = &inv_icm42600_buffer_ops; in inv_icm42600_gyro_init()
808 struct inv_sensors_timestamp *ts = &gyro_st->ts; in inv_icm42600_gyro_parse_fifo()
818 for (i = 0, no = 0; i < st->fifo.count; i += size, ++no) { in inv_icm42600_gyro_parse_fifo()
819 size = inv_icm42600_fifo_decode_packet(&st->fifo.data[i], in inv_icm42600_gyro_parse_fifo()
831 inv_sensors_timestamp_apply_odr(ts, st->fifo.period, in inv_icm42600_gyro_parse_fifo()
832 st->fifo.nb.total, no); in inv_icm42600_gyro_parse_fifo()