Lines Matching +full:- +full:32000

1 // SPDX-License-Identifier: GPL-2.0-only
116 ADIS16480_REG((page) + 1, (x) - 60 + 8))
199 struct adis16480 *adis16480 = file->private_data; in adis16480_show_firmware_revision()
205 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_REV, &rev); in adis16480_show_firmware_revision()
224 struct adis16480 *adis16480 = file->private_data; in adis16480_show_firmware_date()
230 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_Y, &year); in adis16480_show_firmware_date()
234 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_DM, &md); in adis16480_show_firmware_date()
238 len = snprintf(buf, sizeof(buf), "%.2x-%.2x-%.4x\n", in adis16480_show_firmware_date()
257 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_SERIAL_NUM, in adis16480_show_serial_number()
275 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_PROD_ID, in adis16480_show_product_id()
293 ret = adis_read_reg_32(&adis16480->adis, ADIS16480_REG_FLASH_CNT, in adis16480_show_flash_count()
328 unsigned int t, sample_rate = st->clk_freq; in adis16480_set_freq()
332 return -EINVAL; in adis16480_set_freq()
336 return -EINVAL; in adis16480_set_freq()
338 adis_dev_auto_lock(&st->adis); in adis16480_set_freq()
351 if (st->clk_mode == ADIS16480_CLK_PPS) { in adis16480_set_freq()
352 unsigned long scaled_rate = lcm(st->clk_freq, t); in adis16480_set_freq()
360 if (scaled_rate > st->chip_info->int_clk) in adis16480_set_freq()
361 scaled_rate = st->chip_info->int_clk / st->clk_freq * st->clk_freq; in adis16480_set_freq()
363 scaled_rate = st->chip_info->int_clk / scaled_rate * scaled_rate; in adis16480_set_freq()
376 scaled_rate = roundup(4000000, st->clk_freq); in adis16480_set_freq()
378 sync_scale = scaled_rate / st->clk_freq; in adis16480_set_freq()
379 ret = __adis_write_reg_16(&st->adis, ADIS16495_REG_SYNC_SCALE, sync_scale); in adis16480_set_freq()
388 t--; in adis16480_set_freq()
390 if (t > st->chip_info->max_dec_rate) in adis16480_set_freq()
391 t = st->chip_info->max_dec_rate; in adis16480_set_freq()
393 return __adis_write_reg_16(&st->adis, ADIS16480_REG_DEC_RATE, t); in adis16480_set_freq()
401 unsigned int freq, sample_rate = st->clk_freq; in adis16480_get_freq()
403 adis_dev_auto_lock(&st->adis); in adis16480_get_freq()
405 if (st->clk_mode == ADIS16480_CLK_PPS) { in adis16480_get_freq()
408 ret = __adis_read_reg_16(&st->adis, ADIS16495_REG_SYNC_SCALE, &sync_scale); in adis16480_get_freq()
412 sample_rate = st->clk_freq * sync_scale; in adis16480_get_freq()
415 ret = __adis_read_reg_16(&st->adis, ADIS16480_REG_DEC_RATE, &t); in adis16480_get_freq()
472 unsigned int reg = adis16480_calibbias_regs[chan->scan_index]; in adis16480_set_calibbias()
475 switch (chan->type) { in adis16480_set_calibbias()
478 if (bias < -0x8000 || bias >= 0x8000) in adis16480_set_calibbias()
479 return -EINVAL; in adis16480_set_calibbias()
480 return adis_write_reg_16(&st->adis, reg, bias); in adis16480_set_calibbias()
483 return adis_write_reg_32(&st->adis, reg, bias); in adis16480_set_calibbias()
488 return -EINVAL; in adis16480_set_calibbias()
494 unsigned int reg = adis16480_calibbias_regs[chan->scan_index]; in adis16480_get_calibbias()
500 switch (chan->type) { in adis16480_get_calibbias()
503 ret = adis_read_reg_16(&st->adis, reg, &val16); in adis16480_get_calibbias()
509 ret = adis_read_reg_32(&st->adis, reg, &val32); in adis16480_get_calibbias()
514 ret = -EINVAL; in adis16480_get_calibbias()
526 unsigned int reg = adis16480_calibscale_regs[chan->scan_index]; in adis16480_set_calibscale()
529 if (scale < -0x8000 || scale >= 0x8000) in adis16480_set_calibscale()
530 return -EINVAL; in adis16480_set_calibscale()
532 return adis_write_reg_16(&st->adis, reg, scale); in adis16480_set_calibscale()
538 unsigned int reg = adis16480_calibscale_regs[chan->scan_index]; in adis16480_get_calibscale()
543 ret = adis_read_reg_16(&st->adis, reg, &val16); in adis16480_get_calibscale()
585 reg = ad16480_filter_data[chan->scan_index][0]; in adis16480_get_filter_freq()
586 offset = ad16480_filter_data[chan->scan_index][1]; in adis16480_get_filter_freq()
589 ret = adis_read_reg_16(&st->adis, reg, &val); in adis16480_get_filter_freq()
596 *freq = st->chip_info->filter_freqs[(val >> offset) & 0x3]; in adis16480_get_filter_freq()
611 reg = ad16480_filter_data[chan->scan_index][0]; in adis16480_set_filter_freq()
612 offset = ad16480_filter_data[chan->scan_index][1]; in adis16480_set_filter_freq()
615 adis_dev_auto_lock(&st->adis); in adis16480_set_filter_freq()
617 ret = __adis_read_reg_16(&st->adis, reg, &val); in adis16480_set_filter_freq()
625 best_diff = st->chip_info->filter_freqs[0]; in adis16480_set_filter_freq()
627 if (st->chip_info->filter_freqs[i] >= freq) { in adis16480_set_filter_freq()
628 diff = st->chip_info->filter_freqs[i] - freq; in adis16480_set_filter_freq()
641 return __adis_write_reg_16(&st->adis, reg, val); in adis16480_set_filter_freq()
654 switch (chan->type) { in adis16480_read_raw()
656 *val = st->chip_info->gyro_max_scale; in adis16480_read_raw()
657 *val2 = st->chip_info->gyro_max_val; in adis16480_read_raw()
660 *val = st->chip_info->accel_max_scale; in adis16480_read_raw()
661 *val2 = st->chip_info->accel_max_val; in adis16480_read_raw()
673 *val = st->chip_info->temp_scale / 1000; in adis16480_read_raw()
674 *val2 = (st->chip_info->temp_scale % 1000) * 1000; in adis16480_read_raw()
685 *val = st->chip_info->deltang_max_val; in adis16480_read_raw()
689 *val = st->chip_info->deltvel_max_val; in adis16480_read_raw()
693 return -EINVAL; in adis16480_read_raw()
698 *val = DIV_ROUND_CLOSEST_ULL(temp, st->chip_info->temp_scale); in adis16480_read_raw()
709 return -EINVAL; in adis16480_read_raw()
727 return -EINVAL; in adis16480_write_raw()
772 ADIS16480_REG_ ## _mod ## _DELTAANG_OUT, -1, 0, 32)
781 ADIS16480_REG_ ## _mod ## _DELTAVEL_OUT, -1, 0, 32)
934 [ADIS16480_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
935 [ADIS16480_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
936 [ADIS16480_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
937 [ADIS16480_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
938 [ADIS16480_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
939 [ADIS16480_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
940 [ADIS16480_DIAG_STAT_XMAGN_FAIL] = "X-axis magnetometer self-test failure",
941 [ADIS16480_DIAG_STAT_YMAGN_FAIL] = "Y-axis magnetometer self-test failure",
942 [ADIS16480_DIAG_STAT_ZMAGN_FAIL] = "Z-axis magnetometer self-test failure",
943 [ADIS16480_DIAG_STAT_BARO_FAIL] = "Barometer self-test failure",
1147 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1166 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1185 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1204 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1223 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1242 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1261 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1281 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1301 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1321 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1341 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1361 .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
1396 struct iio_dev *indio_dev = pf->indio_dev; in adis16480_trigger_handler()
1398 struct adis *adis = &st->adis; in adis16480_trigger_handler()
1399 struct device *dev = &adis->spi->dev; in adis16480_trigger_handler()
1406 if (adis->current_page != 0) { in adis16480_trigger_handler()
1407 adis->tx[0] = ADIS_WRITE_REG(ADIS_REG_PAGE_ID); in adis16480_trigger_handler()
1408 adis->tx[1] = 0; in adis16480_trigger_handler()
1409 ret = spi_write(adis->spi, adis->tx, 2); in adis16480_trigger_handler()
1415 adis->current_page = 0; in adis16480_trigger_handler()
1418 ret = spi_sync(adis->spi, &adis->msg); in adis16480_trigger_handler()
1427 * 16-bit responses containing the BURST_ID depending on the sclk. If in adis16480_trigger_handler()
1434 buffer = adis->buffer; in adis16480_trigger_handler()
1439 if (curr == st->burst_id && next != st->burst_id) { in adis16480_trigger_handler()
1465 st->data[i++] = buffer[offset + 1]; in adis16480_trigger_handler()
1467 * The temperature channel has 16-bit storage size. in adis16480_trigger_handler()
1470 * 32-bit storage size channels enabled which are added in adis16480_trigger_handler()
1475 st->data[i++] = 0; in adis16480_trigger_handler()
1482 st->data[i++] = buffer[2 * (bit - buff_offset) + offset + 3]; in adis16480_trigger_handler()
1483 st->data[i++] = buffer[2 * (bit - buff_offset) + offset + 2]; in adis16480_trigger_handler()
1488 iio_push_to_buffers_with_timestamp(indio_dev, st->data, pf->timestamp); in adis16480_trigger_handler()
1490 iio_trigger_notify_done(indio_dev->trig); in adis16480_trigger_handler()
1508 if (st->chip_info->has_burst_delta_data) { in adis16480_update_scan_mode()
1511 st->burst_id = ADIS16495_GYRO_ACCEL_BURST_ID; in adis16480_update_scan_mode()
1514 st->burst_id = ADIS16545_DELTA_ANG_VEL_BURST_ID; in adis16480_update_scan_mode()
1517 ret = __adis_update_bits(&st->adis, ADIS16480_REG_CONFIG, in adis16480_update_scan_mode()
1536 struct device *dev = &st->adis.spi->dev; in adis16480_stop_device()
1539 ret = adis_write_reg_16(&st->adis, ADIS16480_REG_SLP_CNT, BIT(9)); in adis16480_stop_device()
1563 struct device *dev = &st->adis.spi->dev; in adis16480_config_irq_pin()
1574 * Get the interrupt from the devicetre by reading the interrupt-names in adis16480_config_irq_pin()
1597 irq_type = irq_get_trigger_type(st->adis.spi->irq); in adis16480_config_irq_pin()
1604 return -EINVAL; in adis16480_config_irq_pin()
1607 return adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val); in adis16480_config_irq_pin()
1612 struct device *dev = &st->adis.spi->dev; in adis16480_fw_get_ext_clk_pin()
1618 if (device_property_read_string(dev, "adi,ext-clk-pin", &ext_clk_pin)) in adis16480_fw_get_ext_clk_pin()
1633 struct device *dev = &st->adis.spi->dev; in adis16480_ext_clk_config()
1639 ret = adis_read_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, &val); in adis16480_ext_clk_config()
1655 if (st->chip_info->has_pps_clk_mode) { in adis16480_ext_clk_config()
1656 mode |= ADIS16480_SYNC_MODE(st->clk_mode); in adis16480_ext_clk_config()
1663 ret = adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val); in adis16480_ext_clk_config()
1667 return clk_prepare_enable(st->ext_clk); in adis16480_ext_clk_config()
1672 struct device *dev = &st->adis.spi->dev; in adis16480_get_ext_clocks()
1674 st->ext_clk = devm_clk_get_optional(dev, "sync"); in adis16480_get_ext_clocks()
1675 if (IS_ERR(st->ext_clk)) in adis16480_get_ext_clocks()
1676 return dev_err_probe(dev, PTR_ERR(st->ext_clk), "failed to get ext clk\n"); in adis16480_get_ext_clocks()
1677 if (st->ext_clk) { in adis16480_get_ext_clocks()
1678 st->clk_mode = ADIS16480_CLK_SYNC; in adis16480_get_ext_clocks()
1682 if (st->chip_info->has_pps_clk_mode) { in adis16480_get_ext_clocks()
1683 st->ext_clk = devm_clk_get_optional(dev, "pps"); in adis16480_get_ext_clocks()
1684 if (IS_ERR(st->ext_clk)) in adis16480_get_ext_clocks()
1685 return dev_err_probe(dev, PTR_ERR(st->ext_clk), "failed to get ext clk\n"); in adis16480_get_ext_clocks()
1686 if (st->ext_clk) { in adis16480_get_ext_clocks()
1687 st->clk_mode = ADIS16480_CLK_PPS; in adis16480_get_ext_clocks()
1692 st->clk_mode = ADIS16480_CLK_INT; in adis16480_get_ext_clocks()
1711 struct device *dev = &spi->dev; in adis16480_probe()
1718 return -ENOMEM; in adis16480_probe()
1722 st->chip_info = &adis16480_chip_info[id->driver_data]; in adis16480_probe()
1723 indio_dev->name = spi_get_device_id(spi)->name; in adis16480_probe()
1724 indio_dev->channels = st->chip_info->channels; in adis16480_probe()
1725 indio_dev->num_channels = st->chip_info->num_channels; in adis16480_probe()
1726 if (st->chip_info->has_burst_delta_data) in adis16480_probe()
1727 indio_dev->available_scan_masks = adis16545_channel_masks; in adis16480_probe()
1728 indio_dev->info = &adis16480_info; in adis16480_probe()
1729 indio_dev->modes = INDIO_DIRECT_MODE; in adis16480_probe()
1731 adis16480_data = &st->chip_info->adis_data; in adis16480_probe()
1733 ret = adis_init(&st->adis, indio_dev, spi, adis16480_data); in adis16480_probe()
1737 ret = __adis_initial_startup(&st->adis); in adis16480_probe()
1746 st->burst_id = ADIS16495_GYRO_ACCEL_BURST_ID; in adis16480_probe()
1748 if (st->chip_info->has_sleep_cnt) { in adis16480_probe()
1762 if (st->ext_clk) { in adis16480_probe()
1767 ret = devm_add_action_or_reset(dev, adis16480_clk_disable, st->ext_clk); in adis16480_probe()
1771 st->clk_freq = clk_get_rate(st->ext_clk); in adis16480_probe()
1772 st->clk_freq *= 1000; /* micro */ in adis16480_probe()
1773 if (st->clk_mode == ADIS16480_CLK_PPS) { in adis16480_probe()
1782 sync_scale = st->chip_info->int_clk / st->clk_freq; in adis16480_probe()
1783 ret = __adis_write_reg_16(&st->adis, ADIS16495_REG_SYNC_SCALE, sync_scale); in adis16480_probe()
1788 st->clk_freq = st->chip_info->int_clk; in adis16480_probe()
1792 if (adis16480_data->burst_len) in adis16480_probe()
1795 ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, in adis16480_probe()
1818 { "adis16495-1", ADIS16495_1 },
1819 { "adis16495-2", ADIS16495_2 },
1820 { "adis16495-3", ADIS16495_3 },
1821 { "adis16497-1", ADIS16497_1 },
1822 { "adis16497-2", ADIS16497_2 },
1823 { "adis16497-3", ADIS16497_3 },
1824 { "adis16545-1", ADIS16545_1 },
1825 { "adis16545-2", ADIS16545_2 },
1826 { "adis16545-3", ADIS16545_3 },
1827 { "adis16547-1", ADIS16547_1 },
1828 { "adis16547-2", ADIS16547_2 },
1829 { "adis16547-3", ADIS16547_3 },
1843 { .compatible = "adi,adis16495-1" },
1844 { .compatible = "adi,adis16495-2" },
1845 { .compatible = "adi,adis16495-3" },
1846 { .compatible = "adi,adis16497-1" },
1847 { .compatible = "adi,adis16497-2" },
1848 { .compatible = "adi,adis16497-3" },
1849 { .compatible = "adi,adis16545-1" },
1850 { .compatible = "adi,adis16545-2" },
1851 { .compatible = "adi,adis16545-3" },
1852 { .compatible = "adi,adis16547-1" },
1853 { .compatible = "adi,adis16547-2" },
1854 { .compatible = "adi,adis16547-3" },
1869 MODULE_AUTHOR("Lars-Peter Clausen <[email protected]>");