Lines Matching +full:y +full:- +full:axis

1 // SPDX-License-Identifier: GPL-2.0-only
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 */
165 * struct adis16400_state - device instance specific data
210 struct adis16400_state *st = file->private_data; in adis16400_show_serial_number()
216 ret = adis_read_reg_16(&st->adis, ADIS16334_LOT_ID1, &lot1); in adis16400_show_serial_number()
220 ret = adis_read_reg_16(&st->adis, ADIS16334_LOT_ID2, &lot2); in adis16400_show_serial_number()
224 ret = adis_read_reg_16(&st->adis, ADIS16334_SERIAL_NUMBER, in adis16400_show_serial_number()
229 len = snprintf(buf, sizeof(buf), "%.4x-%.4x-%.4x\n", lot1, lot2, in adis16400_show_serial_number()
248 ret = adis_read_reg_16(&st->adis, ADIS16400_PRODUCT_ID, &prod_id); in adis16400_show_product_id()
265 ret = adis_read_reg_16(&st->adis, ADIS16400_FLASH_CNT, &flash_count); in adis16400_show_flash_count()
281 if (st->variant->flags & ADIS16400_HAS_SERIAL_NUMBER) in adis16400_debugfs_init()
284 if (st->variant->flags & ADIS16400_HAS_PROD_ID) in adis16400_debugfs_init()
320 ret = __adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t); in adis16334_get_freq()
344 return __adis_write_reg_16(&st->adis, ADIS16400_SMPL_PRD, t); in adis16334_set_freq()
352 ret = __adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t); in adis16400_get_freq()
374 t--; in adis16400_set_freq()
380 st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW; in adis16400_set_freq()
382 st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST; in adis16400_set_freq()
384 return __adis_write_reg_8(&st->adis, ADIS16400_SMPL_PRD, val); in adis16400_set_freq()
404 for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) { in __adis16400_set_filter()
409 ret = __adis_read_reg_16(&st->adis, ADIS16400_SENS_AVG, &val16); in __adis16400_set_filter()
413 ret = __adis_write_reg_16(&st->adis, ADIS16400_SENS_AVG, in __adis16400_set_filter()
424 ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, in adis16400_stop_device()
427 dev_err(&indio_dev->dev, in adis16400_stop_device()
441 if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) in adis16400_initial_setup()
442 st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW; in adis16400_initial_setup()
444 st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST; in adis16400_initial_setup()
445 st->adis.spi->mode = SPI_MODE_3; in adis16400_initial_setup()
446 spi_setup(st->adis.spi); in adis16400_initial_setup()
448 ret = adis_initial_startup(&st->adis); in adis16400_initial_setup()
452 if (st->variant->flags & ADIS16400_HAS_PROD_ID) { in adis16400_initial_setup()
453 ret = adis_read_reg_16(&st->adis, in adis16400_initial_setup()
458 if (sscanf(indio_dev->name, "adis%u\n", &device_id) != 1) { in adis16400_initial_setup()
459 ret = -EINVAL; in adis16400_initial_setup()
464 dev_warn(&indio_dev->dev, "Device ID(%u) and product ID(%u) do not match.", in adis16400_initial_setup()
467 dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n", in adis16400_initial_setup()
468 indio_dev->name, prod_id, in adis16400_initial_setup()
469 st->adis.spi->chip_select, st->adis.spi->irq); in adis16400_initial_setup()
472 if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) { in adis16400_initial_setup()
473 ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &smp_prd); in adis16400_initial_setup()
478 st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST; in adis16400_initial_setup()
479 spi_setup(st->adis.spi); in adis16400_initial_setup()
504 ret = adis_write_reg_16(&st->adis, in adis16400_write_raw()
505 adis16400_addresses[chan->scan_index], val); in adis16400_write_raw()
512 adis_dev_lock(&st->adis); in adis16400_write_raw()
513 st->filt_int = val; in adis16400_write_raw()
515 sps = st->variant->get_freq(st); in adis16400_write_raw()
517 adis_dev_unlock(&st->adis); in adis16400_write_raw()
523 adis_dev_unlock(&st->adis); in adis16400_write_raw()
529 return -EINVAL; in adis16400_write_raw()
531 adis_dev_lock(&st->adis); in adis16400_write_raw()
532 ret = st->variant->set_freq(st, sps); in adis16400_write_raw()
533 adis_dev_unlock(&st->adis); in adis16400_write_raw()
536 return -EINVAL; in adis16400_write_raw()
551 switch (chan->type) { in adis16400_read_raw()
554 *val2 = st->variant->gyro_scale_micro; in adis16400_read_raw()
558 if (chan->channel == 0) { in adis16400_read_raw()
568 *val2 = st->variant->accel_scale_micro; in adis16400_read_raw()
575 *val = st->variant->temp_scale_nano / 1000000; in adis16400_read_raw()
576 *val2 = (st->variant->temp_scale_nano % 1000000); in adis16400_read_raw()
584 return -EINVAL; in adis16400_read_raw()
587 ret = adis_read_reg_16(&st->adis, in adis16400_read_raw()
588 adis16400_addresses[chan->scan_index], &val16); in adis16400_read_raw()
596 *val = st->variant->temp_offset; in adis16400_read_raw()
599 adis_dev_lock(&st->adis); in adis16400_read_raw()
601 ret = __adis_read_reg_16(&st->adis, in adis16400_read_raw()
605 adis_dev_unlock(&st->adis); in adis16400_read_raw()
608 ret = st->variant->get_freq(st); in adis16400_read_raw()
609 adis_dev_unlock(&st->adis); in adis16400_read_raw()
617 adis_dev_lock(&st->adis); in adis16400_read_raw()
618 ret = st->variant->get_freq(st); in adis16400_read_raw()
619 adis_dev_unlock(&st->adis); in adis16400_read_raw()
626 return -EINVAL; in adis16400_read_raw()
634 struct iio_dev *indio_dev = pf->indio_dev; in adis16400_trigger_handler()
636 struct adis *adis = &st->adis; in adis16400_trigger_handler()
640 ret = spi_sync(adis->spi, &adis->msg); in adis16400_trigger_handler()
642 dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret); in adis16400_trigger_handler()
644 if (st->variant->flags & ADIS16400_BURST_DIAG_STAT) { in adis16400_trigger_handler()
645 buffer = adis->buffer + sizeof(u16); in adis16400_trigger_handler()
650 * buffer->scan_bytes this will be safe. in adis16400_trigger_handler()
653 indio_dev->scan_bytes - sizeof(pf->timestamp), in adis16400_trigger_handler()
654 pf->timestamp); in adis16400_trigger_handler()
657 adis->buffer, in adis16400_trigger_handler()
658 pf->timestamp); in adis16400_trigger_handler()
662 iio_trigger_notify_done(indio_dev->trig); in adis16400_trigger_handler()
755 #define ADIS16400_MOD_TEMP_NAME_Y "y"
820 ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 14),
823 ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
826 ADIS16400_MAGN_CHAN(Y, ADIS16400_YMAGN_OUT, 14),
835 ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 16),
838 ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 16),
846 ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 16),
849 ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 16),
852 ADIS16400_MAGN_CHAN(Y, ADIS16400_YMAGN_OUT, 16),
875 ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 14),
878 ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
881 ADIS16400_MAGN_CHAN(Y, ADIS16400_YMAGN_OUT, 14),
885 ADIS16400_MOD_TEMP_CHAN(Y, ADIS16350_YTEMP_OUT, 12),
894 ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
899 ADIS16400_INCLI_CHAN(Y, ADIS16300_ROLL_OUT, 13),
905 ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 14),
908 ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
915 [ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
916 [ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
917 [ADIS16400_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
918 [ADIS16400_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
919 [ADIS16400_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
920 [ADIS16400_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
1141 const struct adis16400_chip_info *chip_info = st->variant; in adis16400_setup_chan_mask()
1144 for (i = 0; i < chip_info->num_channels; i++) { in adis16400_setup_chan_mask()
1145 const struct iio_chan_spec *ch = &chip_info->channels[i]; in adis16400_setup_chan_mask()
1147 if (ch->scan_index >= 0 && in adis16400_setup_chan_mask()
1148 ch->scan_index != ADIS16400_SCAN_TIMESTAMP) in adis16400_setup_chan_mask()
1149 st->avail_scan_mask[0] |= BIT(ch->scan_index); in adis16400_setup_chan_mask()
1165 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in adis16400_probe()
1167 return -ENOMEM; in adis16400_probe()
1172 st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data]; in adis16400_probe()
1173 indio_dev->name = spi_get_device_id(spi)->name; in adis16400_probe()
1174 indio_dev->channels = st->variant->channels; in adis16400_probe()
1175 indio_dev->num_channels = st->variant->num_channels; in adis16400_probe()
1176 indio_dev->info = &adis16400_info; in adis16400_probe()
1177 indio_dev->modes = INDIO_DIRECT_MODE; in adis16400_probe()
1179 if (!(st->variant->flags & ADIS16400_NO_BURST)) { in adis16400_probe()
1181 indio_dev->available_scan_masks = st->avail_scan_mask; in adis16400_probe()
1184 adis16400_data = &st->variant->adis_data; in adis16400_probe()
1186 ret = adis_init(&st->adis, indio_dev, spi, adis16400_data); in adis16400_probe()
1190 ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, adis16400_trigger_handler); in adis16400_probe()
1199 ret = devm_add_action_or_reset(&spi->dev, adis16400_stop, indio_dev); in adis16400_probe()
1203 ret = devm_iio_device_register(&spi->dev, indio_dev); in adis16400_probe()