Lines Matching +full:3 +full:- +full:axis
1 // SPDX-License-Identifier: GPL-2.0-only
4 * 3d 2g Linear Accelerometers,
5 * 3d Gyroscopes,
6 * 3d Magnetometers via SPI
31 #define ADIS16400_XGYRO_OUT 0x04 /* X-axis gyroscope output */
32 #define ADIS16400_YGYRO_OUT 0x06 /* Y-axis gyroscope output */
33 #define ADIS16400_ZGYRO_OUT 0x08 /* Z-axis gyroscope output */
34 #define ADIS16400_XACCL_OUT 0x0A /* X-axis accelerometer output */
35 #define ADIS16400_YACCL_OUT 0x0C /* Y-axis accelerometer output */
36 #define ADIS16400_ZACCL_OUT 0x0E /* Z-axis accelerometer output */
37 #define ADIS16400_XMAGN_OUT 0x10 /* X-axis magnetometer measurement */
38 #define ADIS16400_YMAGN_OUT 0x12 /* Y-axis magnetometer measurement */
39 #define ADIS16400_ZMAGN_OUT 0x14 /* Z-axis magnetometer measurement */
43 #define ADIS16350_XTEMP_OUT 0x10 /* X-axis gyroscope temperature measurement */
44 #define ADIS16350_YTEMP_OUT 0x12 /* Y-axis gyroscope temperature measurement */
45 #define ADIS16350_ZTEMP_OUT 0x14 /* Z-axis gyroscope temperature measurement */
47 #define ADIS16300_PITCH_OUT 0x12 /* X axis inclinometer output measurement */
48 #define ADIS16300_ROLL_OUT 0x14 /* Y axis inclinometer output measurement */
55 #define ADIS16400_XGYRO_OFF 0x1A /* X-axis gyroscope bias offset factor */
56 #define ADIS16400_YGYRO_OFF 0x1C /* Y-axis gyroscope bias offset factor */
57 #define ADIS16400_ZGYRO_OFF 0x1E /* Z-axis gyroscope bias offset factor */
58 #define ADIS16400_XACCL_OFF 0x20 /* X-axis acceleration bias offset factor */
59 #define ADIS16400_YACCL_OFF 0x22 /* Y-axis acceleration bias offset factor */
60 #define ADIS16400_ZACCL_OFF 0x24 /* Z-axis acceleration bias offset factor */
61 #define ADIS16400_XMAGN_HIF 0x26 /* X-axis magnetometer, hard-iron factor */
62 #define ADIS16400_YMAGN_HIF 0x28 /* Y-axis magnetometer, hard-iron factor */
63 #define ADIS16400_ZMAGN_HIF 0x2A /* Z-axis magnetometer, hard-iron factor */
64 #define ADIS16400_XMAGN_SIF 0x2C /* X-axis magnetometer, soft-iron factor */
65 #define ADIS16400_YMAGN_SIF 0x2E /* Y-axis magnetometer, soft-iron factor */
66 #define ADIS16400_ZMAGN_SIF 0x30 /* Z-axis magnetometer, soft-iron factor */
119 #define ADIS16400_DIAG_STAT_SPI_FAIL 3
127 #define ADIS16400_GLOB_CMD_FLASH_UPD (1<<3)
145 #define ADIS16400_HAS_SERIAL_NUMBER BIT(3)
165 * struct adis16400_state - device instance specific data
208 struct adis16400_state *st = file->private_data; in adis16400_show_serial_number()
214 ret = adis_read_reg_16(&st->adis, ADIS16334_LOT_ID1, &lot1); in adis16400_show_serial_number()
218 ret = adis_read_reg_16(&st->adis, ADIS16334_LOT_ID2, &lot2); in adis16400_show_serial_number()
222 ret = adis_read_reg_16(&st->adis, ADIS16334_SERIAL_NUMBER, in adis16400_show_serial_number()
227 len = snprintf(buf, sizeof(buf), "%.4x-%.4x-%.4x\n", lot1, lot2, in adis16400_show_serial_number()
246 ret = adis_read_reg_16(&st->adis, ADIS16400_PRODUCT_ID, &prod_id); in adis16400_show_product_id()
263 ret = adis_read_reg_16(&st->adis, ADIS16400_FLASH_CNT, &flash_count); in adis16400_show_flash_count()
282 if (st->variant->flags & ADIS16400_HAS_SERIAL_NUMBER) in adis16400_debugfs_init()
285 if (st->variant->flags & ADIS16400_HAS_PROD_ID) in adis16400_debugfs_init()
310 ret = __adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t); in adis16334_get_freq()
334 return __adis_write_reg_16(&st->adis, ADIS16400_SMPL_PRD, t); in adis16334_set_freq()
342 ret = __adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t); in adis16400_get_freq()
364 t--; in adis16400_set_freq()
370 st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW; in adis16400_set_freq()
372 st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST; in adis16400_set_freq()
374 return __adis_write_reg_8(&st->adis, ADIS16400_SMPL_PRD, val); in adis16400_set_freq()
381 [3] = 25,
394 for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) { in __adis16400_set_filter()
399 ret = __adis_read_reg_16(&st->adis, ADIS16400_SENS_AVG, &val16); in __adis16400_set_filter()
403 ret = __adis_write_reg_16(&st->adis, ADIS16400_SENS_AVG, in __adis16400_set_filter()
414 ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, in adis16400_stop_device()
417 dev_err(&indio_dev->dev, in adis16400_stop_device()
431 if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) in adis16400_initial_setup()
432 st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW; in adis16400_initial_setup()
434 st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST; in adis16400_initial_setup()
435 st->adis.spi->mode = SPI_MODE_3; in adis16400_initial_setup()
436 spi_setup(st->adis.spi); in adis16400_initial_setup()
438 ret = __adis_initial_startup(&st->adis); in adis16400_initial_setup()
442 if (st->variant->flags & ADIS16400_HAS_PROD_ID) { in adis16400_initial_setup()
443 ret = adis_read_reg_16(&st->adis, in adis16400_initial_setup()
448 if (sscanf(indio_dev->name, "adis%u\n", &device_id) != 1) { in adis16400_initial_setup()
449 ret = -EINVAL; in adis16400_initial_setup()
454 dev_warn(&indio_dev->dev, "Device ID(%u) and product ID(%u) do not match.", in adis16400_initial_setup()
457 dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n", in adis16400_initial_setup()
458 indio_dev->name, prod_id, in adis16400_initial_setup()
459 spi_get_chipselect(st->adis.spi, 0), st->adis.spi->irq); in adis16400_initial_setup()
462 if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) { in adis16400_initial_setup()
463 ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &smp_prd); in adis16400_initial_setup()
468 st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST; in adis16400_initial_setup()
469 spi_setup(st->adis.spi); in adis16400_initial_setup()
494 return adis_write_reg_16(&st->adis, in adis16400_write_raw()
495 adis16400_addresses[chan->scan_index], in adis16400_write_raw()
502 adis_dev_auto_scoped_lock(&st->adis) { in adis16400_write_raw()
503 st->filt_int = val; in adis16400_write_raw()
505 sps = st->variant->get_freq(st); in adis16400_write_raw()
517 return -EINVAL; in adis16400_write_raw()
519 adis_dev_auto_scoped_lock(&st->adis) in adis16400_write_raw()
520 return st->variant->set_freq(st, sps); in adis16400_write_raw()
523 return -EINVAL; in adis16400_write_raw()
538 switch (chan->type) { in adis16400_read_raw()
541 *val2 = st->variant->gyro_scale_micro; in adis16400_read_raw()
545 if (chan->channel == 0) { in adis16400_read_raw()
555 *val2 = st->variant->accel_scale_micro; in adis16400_read_raw()
562 *val = st->variant->temp_scale_nano / 1000000; in adis16400_read_raw()
563 *val2 = (st->variant->temp_scale_nano % 1000000); in adis16400_read_raw()
571 return -EINVAL; in adis16400_read_raw()
574 ret = adis_read_reg_16(&st->adis, in adis16400_read_raw()
575 adis16400_addresses[chan->scan_index], &val16); in adis16400_read_raw()
583 *val = st->variant->temp_offset; in adis16400_read_raw()
586 adis_dev_auto_scoped_lock(&st->adis) { in adis16400_read_raw()
591 ret = __adis_read_reg_16(&st->adis, ADIS16400_SENS_AVG, in adis16400_read_raw()
596 ret = st->variant->get_freq(st); in adis16400_read_raw()
605 adis_dev_auto_scoped_lock(&st->adis) { in adis16400_read_raw()
606 ret = st->variant->get_freq(st); in adis16400_read_raw()
614 return -EINVAL; in adis16400_read_raw()
622 struct iio_dev *indio_dev = pf->indio_dev; in adis16400_trigger_handler()
624 struct adis *adis = &st->adis; in adis16400_trigger_handler()
628 ret = spi_sync(adis->spi, &adis->msg); in adis16400_trigger_handler()
630 dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret); in adis16400_trigger_handler()
632 if (st->variant->flags & ADIS16400_BURST_DIAG_STAT) { in adis16400_trigger_handler()
633 buffer = adis->buffer + sizeof(u16); in adis16400_trigger_handler()
638 * buffer->scan_bytes this will be safe. in adis16400_trigger_handler()
641 indio_dev->scan_bytes - sizeof(pf->timestamp), in adis16400_trigger_handler()
642 pf->timestamp); in adis16400_trigger_handler()
645 adis->buffer, in adis16400_trigger_handler()
646 pf->timestamp); in adis16400_trigger_handler()
650 iio_trigger_notify_done(indio_dev->trig); in adis16400_trigger_handler()
903 [ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
904 [ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
905 [ADIS16400_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
906 [ADIS16400_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
907 [ADIS16400_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
908 [ADIS16400_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
1129 const struct adis16400_chip_info *chip_info = st->variant; in adis16400_setup_chan_mask()
1132 for (i = 0; i < chip_info->num_channels; i++) { in adis16400_setup_chan_mask()
1133 const struct iio_chan_spec *ch = &chip_info->channels[i]; in adis16400_setup_chan_mask()
1135 if (ch->scan_index >= 0 && in adis16400_setup_chan_mask()
1136 ch->scan_index != ADIS16400_SCAN_TIMESTAMP) in adis16400_setup_chan_mask()
1137 st->avail_scan_mask[0] |= BIT(ch->scan_index); in adis16400_setup_chan_mask()
1153 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in adis16400_probe()
1155 return -ENOMEM; in adis16400_probe()
1160 st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data]; in adis16400_probe()
1161 indio_dev->name = spi_get_device_id(spi)->name; in adis16400_probe()
1162 indio_dev->channels = st->variant->channels; in adis16400_probe()
1163 indio_dev->num_channels = st->variant->num_channels; in adis16400_probe()
1164 indio_dev->info = &adis16400_info; in adis16400_probe()
1165 indio_dev->modes = INDIO_DIRECT_MODE; in adis16400_probe()
1167 if (!(st->variant->flags & ADIS16400_NO_BURST)) { in adis16400_probe()
1169 indio_dev->available_scan_masks = st->avail_scan_mask; in adis16400_probe()
1172 adis16400_data = &st->variant->adis_data; in adis16400_probe()
1174 ret = adis_init(&st->adis, indio_dev, spi, adis16400_data); in adis16400_probe()
1178 ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, adis16400_trigger_handler); in adis16400_probe()
1187 ret = devm_add_action_or_reset(&spi->dev, adis16400_stop, indio_dev); in adis16400_probe()
1191 ret = devm_iio_device_register(&spi->dev, indio_dev); in adis16400_probe()