Lines Matching +full:per +full:- +full:mille

1 // SPDX-License-Identifier: GPL-2.0-or-later
92 /* 3-axis gyro + temperature */
110 mutex_lock(&st->lock); in inv_icm42600_gyro_update_scan_mode()
131 ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en); in inv_icm42600_gyro_update_scan_mode()
138 mutex_unlock(&st->lock); in inv_icm42600_gyro_update_scan_mode()
150 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_read_sensor()
156 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_read_sensor()
157 return -EINVAL; in inv_icm42600_gyro_read_sensor()
159 switch (chan->channel2) { in inv_icm42600_gyro_read_sensor()
170 return -EINVAL; in inv_icm42600_gyro_read_sensor()
174 mutex_lock(&st->lock); in inv_icm42600_gyro_read_sensor()
183 data = (__be16 *)&st->buffer[0]; in inv_icm42600_gyro_read_sensor()
184 ret = regmap_bulk_read(st->map, reg, data, sizeof(*data)); in inv_icm42600_gyro_read_sensor()
190 ret = -EINVAL; in inv_icm42600_gyro_read_sensor()
192 mutex_unlock(&st->lock); in inv_icm42600_gyro_read_sensor()
200 /* +/- 2000dps => 0.001065264 rad/s */
203 /* +/- 1000dps => 0.000532632 rad/s */
206 /* +/- 500dps => 0.000266316 rad/s */
209 /* +/- 250dps => 0.000133158 rad/s */
212 /* +/- 125dps => 0.000066579 rad/s */
215 /* +/- 62.5dps => 0.000033290 rad/s */
218 /* +/- 31.25dps => 0.000016645 rad/s */
221 /* +/- 15.625dps => 0.000008322 rad/s */
231 idx = st->conf.gyro.fs; in inv_icm42600_gyro_read_scale()
241 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_write_scale()
252 return -EINVAL; in inv_icm42600_gyro_write_scale()
257 mutex_lock(&st->lock); in inv_icm42600_gyro_write_scale()
261 mutex_unlock(&st->lock); in inv_icm42600_gyro_write_scale()
305 odr = st->conf.gyro.odr; in inv_icm42600_gyro_read_odr()
312 return -EINVAL; in inv_icm42600_gyro_read_odr()
325 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_write_odr()
336 return -EINVAL; in inv_icm42600_gyro_write_odr()
341 mutex_lock(&st->lock); in inv_icm42600_gyro_write_odr()
355 mutex_unlock(&st->lock); in inv_icm42600_gyro_write_odr()
364 * Value is limited to +/-64dps coded on 12 bits signed. Step is 1/32 dps.
367 -1, 117010721, /* min: -1.117010721 rad/s */
376 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_read_offset()
384 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_read_offset()
385 return -EINVAL; in inv_icm42600_gyro_read_offset()
387 switch (chan->channel2) { in inv_icm42600_gyro_read_offset()
398 return -EINVAL; in inv_icm42600_gyro_read_offset()
402 mutex_lock(&st->lock); in inv_icm42600_gyro_read_offset()
404 ret = regmap_bulk_read(st->map, reg, st->buffer, sizeof(data)); in inv_icm42600_gyro_read_offset()
405 memcpy(data, st->buffer, sizeof(data)); in inv_icm42600_gyro_read_offset()
407 mutex_unlock(&st->lock); in inv_icm42600_gyro_read_offset()
414 switch (chan->channel2) { in inv_icm42600_gyro_read_offset()
425 return -EINVAL; in inv_icm42600_gyro_read_offset()
436 /* for rounding, add + or - divisor (2048 * 180) divided by 2 */ in inv_icm42600_gyro_read_offset()
440 val64 -= 2048 * 180 / 2; in inv_icm42600_gyro_read_offset()
452 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_write_offset()
458 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_write_offset()
459 return -EINVAL; in inv_icm42600_gyro_write_offset()
461 switch (chan->channel2) { in inv_icm42600_gyro_write_offset()
472 return -EINVAL; in inv_icm42600_gyro_write_offset()
475 /* inv_icm42600_gyro_calibbias: min - step - max in nano */ in inv_icm42600_gyro_write_offset()
482 return -EINVAL; in inv_icm42600_gyro_write_offset()
492 /* for rounding, add + or - divisor (3141592653 * 64) divided by 2 */ in inv_icm42600_gyro_write_offset()
496 val64 -= 3141592653LL * 64LL / 2LL; in inv_icm42600_gyro_write_offset()
500 if (offset < -2048) in inv_icm42600_gyro_write_offset()
501 offset = -2048; in inv_icm42600_gyro_write_offset()
506 mutex_lock(&st->lock); in inv_icm42600_gyro_write_offset()
508 switch (chan->channel2) { in inv_icm42600_gyro_write_offset()
511 ret = regmap_read(st->map, INV_ICM42600_REG_OFFSET_USER1, in inv_icm42600_gyro_write_offset()
515 st->buffer[0] = offset & 0xFF; in inv_icm42600_gyro_write_offset()
516 st->buffer[1] = (regval & 0xF0) | ((offset & 0xF00) >> 8); in inv_icm42600_gyro_write_offset()
520 ret = regmap_read(st->map, INV_ICM42600_REG_OFFSET_USER1, in inv_icm42600_gyro_write_offset()
524 st->buffer[0] = ((offset & 0xF00) >> 4) | (regval & 0x0F); in inv_icm42600_gyro_write_offset()
525 st->buffer[1] = offset & 0xFF; in inv_icm42600_gyro_write_offset()
529 ret = regmap_read(st->map, INV_ICM42600_REG_OFFSET_USER4, in inv_icm42600_gyro_write_offset()
533 st->buffer[0] = offset & 0xFF; in inv_icm42600_gyro_write_offset()
534 st->buffer[1] = (regval & 0xF0) | ((offset & 0xF00) >> 8); in inv_icm42600_gyro_write_offset()
537 ret = -EINVAL; in inv_icm42600_gyro_write_offset()
541 ret = regmap_bulk_write(st->map, reg, st->buffer, 2); in inv_icm42600_gyro_write_offset()
544 mutex_unlock(&st->lock); in inv_icm42600_gyro_write_offset()
558 switch (chan->type) { in inv_icm42600_gyro_read_raw()
564 return -EINVAL; in inv_icm42600_gyro_read_raw()
585 return -EINVAL; in inv_icm42600_gyro_read_raw()
594 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_read_avail()
595 return -EINVAL; in inv_icm42600_gyro_read_avail()
613 return -EINVAL; in inv_icm42600_gyro_read_avail()
624 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_write_raw()
625 return -EINVAL; in inv_icm42600_gyro_write_raw()
645 return -EINVAL; in inv_icm42600_gyro_write_raw()
653 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_write_raw_get_fmt()
654 return -EINVAL; in inv_icm42600_gyro_write_raw_get_fmt()
664 return -EINVAL; in inv_icm42600_gyro_write_raw_get_fmt()
674 mutex_lock(&st->lock); in inv_icm42600_gyro_hwfifo_set_watermark()
676 st->fifo.watermark.gyro = val; in inv_icm42600_gyro_hwfifo_set_watermark()
679 mutex_unlock(&st->lock); in inv_icm42600_gyro_hwfifo_set_watermark()
693 mutex_lock(&st->lock); in inv_icm42600_gyro_hwfifo_flush()
697 ret = st->fifo.nb.gyro; in inv_icm42600_gyro_hwfifo_flush()
699 mutex_unlock(&st->lock); in inv_icm42600_gyro_hwfifo_flush()
717 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_init()
724 name = devm_kasprintf(dev, GFP_KERNEL, "%s-gyro", st->name); in inv_icm42600_gyro_init()
726 return ERR_PTR(-ENOMEM); in inv_icm42600_gyro_init()
730 return ERR_PTR(-ENOMEM); in inv_icm42600_gyro_init()
734 * jitter is +/- 2% (20 per mille) in inv_icm42600_gyro_init()
738 ts_chip.init_period = inv_icm42600_odr_to_period(st->conf.accel.odr); in inv_icm42600_gyro_init()
743 indio_dev->name = name; in inv_icm42600_gyro_init()
744 indio_dev->info = &inv_icm42600_gyro_info; in inv_icm42600_gyro_init()
745 indio_dev->modes = INDIO_DIRECT_MODE; in inv_icm42600_gyro_init()
746 indio_dev->channels = inv_icm42600_gyro_channels; in inv_icm42600_gyro_init()
747 indio_dev->num_channels = ARRAY_SIZE(inv_icm42600_gyro_channels); in inv_icm42600_gyro_init()
748 indio_dev->available_scan_masks = inv_icm42600_gyro_scan_masks; in inv_icm42600_gyro_init()
749 indio_dev->setup_ops = &inv_icm42600_buffer_ops; in inv_icm42600_gyro_init()
776 for (i = 0, no = 0; i < st->fifo.count; i += size, ++no) { in inv_icm42600_gyro_parse_fifo()
777 size = inv_icm42600_fifo_decode_packet(&st->fifo.data[i], in inv_icm42600_gyro_parse_fifo()
789 inv_sensors_timestamp_apply_odr(ts, st->fifo.period, in inv_icm42600_gyro_parse_fifo()
790 st->fifo.nb.total, no); in inv_icm42600_gyro_parse_fifo()