Lines Matching +full:sleep +full:- +full:map

1 // SPDX-License-Identifier: GPL-2.0-or-later
91 /* 3-axis gyro + temperature */
106 unsigned int sleep; in inv_icm42600_gyro_update_scan_mode() local
109 mutex_lock(&st->lock); in inv_icm42600_gyro_update_scan_mode()
130 ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en); in inv_icm42600_gyro_update_scan_mode()
137 mutex_unlock(&st->lock); in inv_icm42600_gyro_update_scan_mode()
138 /* sleep maximum required time */ in inv_icm42600_gyro_update_scan_mode()
140 sleep = sleep_gyro; in inv_icm42600_gyro_update_scan_mode()
142 sleep = sleep_temp; in inv_icm42600_gyro_update_scan_mode()
143 if (sleep) in inv_icm42600_gyro_update_scan_mode()
144 msleep(sleep); in inv_icm42600_gyro_update_scan_mode()
152 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_read_sensor()
158 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_read_sensor()
159 return -EINVAL; in inv_icm42600_gyro_read_sensor()
161 switch (chan->channel2) { in inv_icm42600_gyro_read_sensor()
172 return -EINVAL; in inv_icm42600_gyro_read_sensor()
176 mutex_lock(&st->lock); in inv_icm42600_gyro_read_sensor()
185 data = (__be16 *)&st->buffer[0]; in inv_icm42600_gyro_read_sensor()
186 ret = regmap_bulk_read(st->map, reg, data, sizeof(*data)); in inv_icm42600_gyro_read_sensor()
192 ret = -EINVAL; in inv_icm42600_gyro_read_sensor()
194 mutex_unlock(&st->lock); in inv_icm42600_gyro_read_sensor()
202 /* +/- 2000dps => 0.001065264 rad/s */
205 /* +/- 1000dps => 0.000532632 rad/s */
208 /* +/- 500dps => 0.000266316 rad/s */
211 /* +/- 250dps => 0.000133158 rad/s */
214 /* +/- 125dps => 0.000066579 rad/s */
217 /* +/- 62.5dps => 0.000033290 rad/s */
220 /* +/- 31.25dps => 0.000016645 rad/s */
223 /* +/- 15.625dps => 0.000008322 rad/s */
233 idx = st->conf.gyro.fs; in inv_icm42600_gyro_read_scale()
243 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_write_scale()
254 return -EINVAL; in inv_icm42600_gyro_write_scale()
259 mutex_lock(&st->lock); in inv_icm42600_gyro_write_scale()
263 mutex_unlock(&st->lock); in inv_icm42600_gyro_write_scale()
307 odr = st->conf.gyro.odr; in inv_icm42600_gyro_read_odr()
314 return -EINVAL; in inv_icm42600_gyro_read_odr()
327 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_write_odr()
338 return -EINVAL; in inv_icm42600_gyro_write_odr()
343 mutex_lock(&st->lock); in inv_icm42600_gyro_write_odr()
357 mutex_unlock(&st->lock); in inv_icm42600_gyro_write_odr()
366 * Value is limited to +/-64dps coded on 12 bits signed. Step is 1/32 dps.
369 -1, 117010721, /* min: -1.117010721 rad/s */
378 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_read_offset()
386 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_read_offset()
387 return -EINVAL; in inv_icm42600_gyro_read_offset()
389 switch (chan->channel2) { in inv_icm42600_gyro_read_offset()
400 return -EINVAL; in inv_icm42600_gyro_read_offset()
404 mutex_lock(&st->lock); in inv_icm42600_gyro_read_offset()
406 ret = regmap_bulk_read(st->map, reg, st->buffer, sizeof(data)); in inv_icm42600_gyro_read_offset()
407 memcpy(data, st->buffer, sizeof(data)); in inv_icm42600_gyro_read_offset()
409 mutex_unlock(&st->lock); in inv_icm42600_gyro_read_offset()
416 switch (chan->channel2) { in inv_icm42600_gyro_read_offset()
427 return -EINVAL; in inv_icm42600_gyro_read_offset()
438 /* for rounding, add + or - divisor (2048 * 180) divided by 2 */ in inv_icm42600_gyro_read_offset()
442 val64 -= 2048 * 180 / 2; in inv_icm42600_gyro_read_offset()
454 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_write_offset()
460 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_write_offset()
461 return -EINVAL; in inv_icm42600_gyro_write_offset()
463 switch (chan->channel2) { in inv_icm42600_gyro_write_offset()
474 return -EINVAL; in inv_icm42600_gyro_write_offset()
477 /* inv_icm42600_gyro_calibbias: min - step - max in nano */ in inv_icm42600_gyro_write_offset()
484 return -EINVAL; in inv_icm42600_gyro_write_offset()
494 /* for rounding, add + or - divisor (3141592653 * 64) divided by 2 */ in inv_icm42600_gyro_write_offset()
498 val64 -= 3141592653LL * 64LL / 2LL; in inv_icm42600_gyro_write_offset()
502 if (offset < -2048) in inv_icm42600_gyro_write_offset()
503 offset = -2048; in inv_icm42600_gyro_write_offset()
508 mutex_lock(&st->lock); in inv_icm42600_gyro_write_offset()
510 switch (chan->channel2) { in inv_icm42600_gyro_write_offset()
513 ret = regmap_read(st->map, INV_ICM42600_REG_OFFSET_USER1, in inv_icm42600_gyro_write_offset()
517 st->buffer[0] = offset & 0xFF; in inv_icm42600_gyro_write_offset()
518 st->buffer[1] = (regval & 0xF0) | ((offset & 0xF00) >> 8); in inv_icm42600_gyro_write_offset()
522 ret = regmap_read(st->map, INV_ICM42600_REG_OFFSET_USER1, in inv_icm42600_gyro_write_offset()
526 st->buffer[0] = ((offset & 0xF00) >> 4) | (regval & 0x0F); in inv_icm42600_gyro_write_offset()
527 st->buffer[1] = offset & 0xFF; in inv_icm42600_gyro_write_offset()
531 ret = regmap_read(st->map, INV_ICM42600_REG_OFFSET_USER4, in inv_icm42600_gyro_write_offset()
535 st->buffer[0] = offset & 0xFF; in inv_icm42600_gyro_write_offset()
536 st->buffer[1] = (regval & 0xF0) | ((offset & 0xF00) >> 8); in inv_icm42600_gyro_write_offset()
539 ret = -EINVAL; in inv_icm42600_gyro_write_offset()
543 ret = regmap_bulk_write(st->map, reg, st->buffer, 2); in inv_icm42600_gyro_write_offset()
546 mutex_unlock(&st->lock); in inv_icm42600_gyro_write_offset()
560 switch (chan->type) { in inv_icm42600_gyro_read_raw()
566 return -EINVAL; in inv_icm42600_gyro_read_raw()
587 return -EINVAL; in inv_icm42600_gyro_read_raw()
596 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_read_avail()
597 return -EINVAL; in inv_icm42600_gyro_read_avail()
615 return -EINVAL; in inv_icm42600_gyro_read_avail()
626 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_write_raw()
627 return -EINVAL; in inv_icm42600_gyro_write_raw()
647 return -EINVAL; in inv_icm42600_gyro_write_raw()
655 if (chan->type != IIO_ANGL_VEL) in inv_icm42600_gyro_write_raw_get_fmt()
656 return -EINVAL; in inv_icm42600_gyro_write_raw_get_fmt()
666 return -EINVAL; in inv_icm42600_gyro_write_raw_get_fmt()
676 mutex_lock(&st->lock); in inv_icm42600_gyro_hwfifo_set_watermark()
678 st->fifo.watermark.gyro = val; in inv_icm42600_gyro_hwfifo_set_watermark()
681 mutex_unlock(&st->lock); in inv_icm42600_gyro_hwfifo_set_watermark()
695 mutex_lock(&st->lock); in inv_icm42600_gyro_hwfifo_flush()
699 ret = st->fifo.nb.gyro; in inv_icm42600_gyro_hwfifo_flush()
701 mutex_unlock(&st->lock); in inv_icm42600_gyro_hwfifo_flush()
719 struct device *dev = regmap_get_device(st->map); in inv_icm42600_gyro_init()
726 name = devm_kasprintf(dev, GFP_KERNEL, "%s-gyro", st->name); in inv_icm42600_gyro_init()
728 return ERR_PTR(-ENOMEM); in inv_icm42600_gyro_init()
732 return ERR_PTR(-ENOMEM); in inv_icm42600_gyro_init()
736 return ERR_PTR(-ENOMEM); in inv_icm42600_gyro_init()
739 inv_icm42600_timestamp_init(ts, inv_icm42600_odr_to_period(st->conf.gyro.odr)); in inv_icm42600_gyro_init()
742 indio_dev->name = name; in inv_icm42600_gyro_init()
743 indio_dev->info = &inv_icm42600_gyro_info; in inv_icm42600_gyro_init()
744 indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; in inv_icm42600_gyro_init()
745 indio_dev->channels = inv_icm42600_gyro_channels; in inv_icm42600_gyro_init()
746 indio_dev->num_channels = ARRAY_SIZE(inv_icm42600_gyro_channels); in inv_icm42600_gyro_init()
747 indio_dev->available_scan_masks = inv_icm42600_gyro_scan_masks; in inv_icm42600_gyro_init()
748 indio_dev->setup_ops = &inv_icm42600_buffer_ops; in inv_icm42600_gyro_init()
772 for (i = 0, no = 0; i < st->fifo.count; i += size, ++no) { in inv_icm42600_gyro_parse_fifo()
773 size = inv_icm42600_fifo_decode_packet(&st->fifo.data[i], in inv_icm42600_gyro_parse_fifo()
785 inv_icm42600_timestamp_apply_odr(ts, st->fifo.period, in inv_icm42600_gyro_parse_fifo()
786 st->fifo.nb.total, no); in inv_icm42600_gyro_parse_fifo()