Lines Matching +full:diff +full:- +full:channels

1 // SPDX-License-Identifier: GPL-2.0-only
117 ADIS16480_REG((page) + 1, (x) - 60 + 8))
139 const struct iio_chan_spec *channels; member
194 struct adis16480 *adis16480 = file->private_data; in adis16480_show_firmware_revision()
200 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_REV, &rev); in adis16480_show_firmware_revision()
219 struct adis16480 *adis16480 = file->private_data; in adis16480_show_firmware_date()
225 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_Y, &year); in adis16480_show_firmware_date()
229 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_DM, &md); in adis16480_show_firmware_date()
233 len = snprintf(buf, sizeof(buf), "%.2x-%.2x-%.4x\n", in adis16480_show_firmware_date()
252 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_SERIAL_NUM, in adis16480_show_serial_number()
270 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_PROD_ID, in adis16480_show_product_id()
288 ret = adis_read_reg_32(&adis16480->adis, ADIS16480_REG_FLASH_CNT, in adis16480_show_flash_count()
331 unsigned int t, sample_rate = st->clk_freq; in adis16480_set_freq()
335 return -EINVAL; in adis16480_set_freq()
339 return -EINVAL; in adis16480_set_freq()
341 adis_dev_lock(&st->adis); in adis16480_set_freq()
354 if (st->clk_mode == ADIS16480_CLK_PPS) { in adis16480_set_freq()
355 unsigned long scaled_rate = lcm(st->clk_freq, t); in adis16480_set_freq()
363 if (scaled_rate > st->chip_info->int_clk) in adis16480_set_freq()
364 scaled_rate = st->chip_info->int_clk / st->clk_freq * st->clk_freq; in adis16480_set_freq()
366 scaled_rate = st->chip_info->int_clk / scaled_rate * scaled_rate; in adis16480_set_freq()
379 scaled_rate = roundup(4000000, st->clk_freq); in adis16480_set_freq()
381 sync_scale = scaled_rate / st->clk_freq; in adis16480_set_freq()
382 ret = __adis_write_reg_16(&st->adis, ADIS16495_REG_SYNC_SCALE, sync_scale); in adis16480_set_freq()
391 t--; in adis16480_set_freq()
393 if (t > st->chip_info->max_dec_rate) in adis16480_set_freq()
394 t = st->chip_info->max_dec_rate; in adis16480_set_freq()
396 ret = __adis_write_reg_16(&st->adis, ADIS16480_REG_DEC_RATE, t); in adis16480_set_freq()
398 adis_dev_unlock(&st->adis); in adis16480_set_freq()
407 unsigned int freq, sample_rate = st->clk_freq; in adis16480_get_freq()
409 adis_dev_lock(&st->adis); in adis16480_get_freq()
411 if (st->clk_mode == ADIS16480_CLK_PPS) { in adis16480_get_freq()
414 ret = __adis_read_reg_16(&st->adis, ADIS16495_REG_SYNC_SCALE, &sync_scale); in adis16480_get_freq()
418 sample_rate = st->clk_freq * sync_scale; in adis16480_get_freq()
421 ret = __adis_read_reg_16(&st->adis, ADIS16480_REG_DEC_RATE, &t); in adis16480_get_freq()
425 adis_dev_unlock(&st->adis); in adis16480_get_freq()
434 adis_dev_unlock(&st->adis); in adis16480_get_freq()
477 unsigned int reg = adis16480_calibbias_regs[chan->scan_index]; in adis16480_set_calibbias()
480 switch (chan->type) { in adis16480_set_calibbias()
483 if (bias < -0x8000 || bias >= 0x8000) in adis16480_set_calibbias()
484 return -EINVAL; in adis16480_set_calibbias()
485 return adis_write_reg_16(&st->adis, reg, bias); in adis16480_set_calibbias()
488 return adis_write_reg_32(&st->adis, reg, bias); in adis16480_set_calibbias()
493 return -EINVAL; in adis16480_set_calibbias()
499 unsigned int reg = adis16480_calibbias_regs[chan->scan_index]; in adis16480_get_calibbias()
505 switch (chan->type) { in adis16480_get_calibbias()
508 ret = adis_read_reg_16(&st->adis, reg, &val16); in adis16480_get_calibbias()
514 ret = adis_read_reg_32(&st->adis, reg, &val32); in adis16480_get_calibbias()
519 ret = -EINVAL; in adis16480_get_calibbias()
531 unsigned int reg = adis16480_calibscale_regs[chan->scan_index]; in adis16480_set_calibscale()
534 if (scale < -0x8000 || scale >= 0x8000) in adis16480_set_calibscale()
535 return -EINVAL; in adis16480_set_calibscale()
537 return adis_write_reg_16(&st->adis, reg, scale); in adis16480_set_calibscale()
543 unsigned int reg = adis16480_calibscale_regs[chan->scan_index]; in adis16480_get_calibscale()
548 ret = adis_read_reg_16(&st->adis, reg, &val16); in adis16480_get_calibscale()
590 reg = ad16480_filter_data[chan->scan_index][0]; in adis16480_get_filter_freq()
591 offset = ad16480_filter_data[chan->scan_index][1]; in adis16480_get_filter_freq()
594 ret = adis_read_reg_16(&st->adis, reg, &val); in adis16480_get_filter_freq()
601 *freq = st->chip_info->filter_freqs[(val >> offset) & 0x3]; in adis16480_get_filter_freq()
611 unsigned int diff, best_diff; in adis16480_set_filter_freq() local
616 reg = ad16480_filter_data[chan->scan_index][0]; in adis16480_set_filter_freq()
617 offset = ad16480_filter_data[chan->scan_index][1]; in adis16480_set_filter_freq()
620 adis_dev_lock(&st->adis); in adis16480_set_filter_freq()
622 ret = __adis_read_reg_16(&st->adis, reg, &val); in adis16480_set_filter_freq()
630 best_diff = st->chip_info->filter_freqs[0]; in adis16480_set_filter_freq()
632 if (st->chip_info->filter_freqs[i] >= freq) { in adis16480_set_filter_freq()
633 diff = st->chip_info->filter_freqs[i] - freq; in adis16480_set_filter_freq()
634 if (diff < best_diff) { in adis16480_set_filter_freq()
635 best_diff = diff; in adis16480_set_filter_freq()
646 ret = __adis_write_reg_16(&st->adis, reg, val); in adis16480_set_filter_freq()
648 adis_dev_unlock(&st->adis); in adis16480_set_filter_freq()
663 switch (chan->type) { in adis16480_read_raw()
665 *val = st->chip_info->gyro_max_scale; in adis16480_read_raw()
666 *val2 = st->chip_info->gyro_max_val; in adis16480_read_raw()
669 *val = st->chip_info->accel_max_scale; in adis16480_read_raw()
670 *val2 = st->chip_info->accel_max_val; in adis16480_read_raw()
682 *val = st->chip_info->temp_scale / 1000; in adis16480_read_raw()
683 *val2 = (st->chip_info->temp_scale % 1000) * 1000; in adis16480_read_raw()
694 return -EINVAL; in adis16480_read_raw()
699 *val = DIV_ROUND_CLOSEST_ULL(temp, st->chip_info->temp_scale); in adis16480_read_raw()
710 return -EINVAL; in adis16480_read_raw()
728 return -EINVAL; in adis16480_write_raw()
861 [ADIS16480_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
862 [ADIS16480_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
863 [ADIS16480_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
864 [ADIS16480_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
865 [ADIS16480_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
866 [ADIS16480_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
867 [ADIS16480_DIAG_STAT_XMAGN_FAIL] = "X-axis magnetometer self-test failure",
868 [ADIS16480_DIAG_STAT_YMAGN_FAIL] = "Y-axis magnetometer self-test failure",
869 [ADIS16480_DIAG_STAT_ZMAGN_FAIL] = "Z-axis magnetometer self-test failure",
870 [ADIS16480_DIAG_STAT_BARO_FAIL] = "Barometer self-test failure",
930 .channels = adis16485_channels,
950 .channels = adis16480_channels,
964 .channels = adis16485_channels,
978 .channels = adis16480_channels,
992 .channels = adis16485_channels,
1006 .channels = adis16485_channels,
1022 .channels = adis16485_channels,
1038 .channels = adis16485_channels,
1054 .channels = adis16485_channels,
1070 .channels = adis16485_channels,
1086 .channels = adis16485_channels,
1121 struct iio_dev *indio_dev = pf->indio_dev; in adis16480_trigger_handler()
1123 struct adis *adis = &st->adis; in adis16480_trigger_handler()
1124 struct device *dev = &adis->spi->dev; in adis16480_trigger_handler()
1131 if (adis->current_page != 0) { in adis16480_trigger_handler()
1132 adis->tx[0] = ADIS_WRITE_REG(ADIS_REG_PAGE_ID); in adis16480_trigger_handler()
1133 adis->tx[1] = 0; in adis16480_trigger_handler()
1134 ret = spi_write(adis->spi, adis->tx, 2); in adis16480_trigger_handler()
1141 adis->current_page = 0; in adis16480_trigger_handler()
1144 ret = spi_sync(adis->spi, &adis->msg); in adis16480_trigger_handler()
1155 * 16-bit responses containing the BURST_ID depending on the sclk. If in adis16480_trigger_handler()
1162 buffer = adis->buffer; in adis16480_trigger_handler()
1185 for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { in adis16480_trigger_handler()
1193 st->data[i++] = buffer[offset + 1]; in adis16480_trigger_handler()
1197 st->data[i++] = buffer[2 * bit + offset + 3]; in adis16480_trigger_handler()
1198 st->data[i++] = buffer[2 * bit + offset + 2]; in adis16480_trigger_handler()
1203 iio_push_to_buffers_with_timestamp(indio_dev, st->data, pf->timestamp); in adis16480_trigger_handler()
1205 iio_trigger_notify_done(indio_dev->trig); in adis16480_trigger_handler()
1220 struct device *dev = &st->adis.spi->dev; in adis16480_stop_device()
1223 ret = adis_write_reg_16(&st->adis, ADIS16480_REG_SLP_CNT, BIT(9)); in adis16480_stop_device()
1247 struct device *dev = &st->adis.spi->dev; in adis16480_config_irq_pin()
1255 desc = irq_get_irq_data(st->adis.spi->irq); in adis16480_config_irq_pin()
1258 return -EINVAL; in adis16480_config_irq_pin()
1265 * Get the interrupt from the devicetre by reading the interrupt-names in adis16480_config_irq_pin()
1295 return -EINVAL; in adis16480_config_irq_pin()
1298 return adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val); in adis16480_config_irq_pin()
1303 struct device *dev = &st->adis.spi->dev; in adis16480_fw_get_ext_clk_pin()
1309 if (device_property_read_string(dev, "adi,ext-clk-pin", &ext_clk_pin)) in adis16480_fw_get_ext_clk_pin()
1324 struct device *dev = &st->adis.spi->dev; in adis16480_ext_clk_config()
1330 ret = adis_read_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, &val); in adis16480_ext_clk_config()
1346 if (st->chip_info->has_pps_clk_mode) { in adis16480_ext_clk_config()
1347 mode |= ADIS16480_SYNC_MODE(st->clk_mode); in adis16480_ext_clk_config()
1354 ret = adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val); in adis16480_ext_clk_config()
1358 return clk_prepare_enable(st->ext_clk); in adis16480_ext_clk_config()
1363 struct device *dev = &st->adis.spi->dev; in adis16480_get_ext_clocks()
1365 st->ext_clk = devm_clk_get_optional(dev, "sync"); in adis16480_get_ext_clocks()
1366 if (IS_ERR(st->ext_clk)) in adis16480_get_ext_clocks()
1367 return dev_err_probe(dev, PTR_ERR(st->ext_clk), "failed to get ext clk\n"); in adis16480_get_ext_clocks()
1368 if (st->ext_clk) { in adis16480_get_ext_clocks()
1369 st->clk_mode = ADIS16480_CLK_SYNC; in adis16480_get_ext_clocks()
1373 if (st->chip_info->has_pps_clk_mode) { in adis16480_get_ext_clocks()
1374 st->ext_clk = devm_clk_get_optional(dev, "pps"); in adis16480_get_ext_clocks()
1375 if (IS_ERR(st->ext_clk)) in adis16480_get_ext_clocks()
1376 return dev_err_probe(dev, PTR_ERR(st->ext_clk), "failed to get ext clk\n"); in adis16480_get_ext_clocks()
1377 if (st->ext_clk) { in adis16480_get_ext_clocks()
1378 st->clk_mode = ADIS16480_CLK_PPS; in adis16480_get_ext_clocks()
1383 st->clk_mode = ADIS16480_CLK_INT; in adis16480_get_ext_clocks()
1402 struct device *dev = &spi->dev; in adis16480_probe()
1409 return -ENOMEM; in adis16480_probe()
1413 st->chip_info = &adis16480_chip_info[id->driver_data]; in adis16480_probe()
1414 indio_dev->name = spi_get_device_id(spi)->name; in adis16480_probe()
1415 indio_dev->channels = st->chip_info->channels; in adis16480_probe()
1416 indio_dev->num_channels = st->chip_info->num_channels; in adis16480_probe()
1417 indio_dev->info = &adis16480_info; in adis16480_probe()
1418 indio_dev->modes = INDIO_DIRECT_MODE; in adis16480_probe()
1420 adis16480_data = &st->chip_info->adis_data; in adis16480_probe()
1422 ret = adis_init(&st->adis, indio_dev, spi, adis16480_data); in adis16480_probe()
1426 ret = __adis_initial_startup(&st->adis); in adis16480_probe()
1430 if (st->chip_info->has_sleep_cnt) { in adis16480_probe()
1444 if (st->ext_clk) { in adis16480_probe()
1449 ret = devm_add_action_or_reset(dev, adis16480_clk_disable, st->ext_clk); in adis16480_probe()
1453 st->clk_freq = clk_get_rate(st->ext_clk); in adis16480_probe()
1454 st->clk_freq *= 1000; /* micro */ in adis16480_probe()
1455 if (st->clk_mode == ADIS16480_CLK_PPS) { in adis16480_probe()
1464 sync_scale = st->chip_info->int_clk / st->clk_freq; in adis16480_probe()
1465 ret = __adis_write_reg_16(&st->adis, ADIS16495_REG_SYNC_SCALE, sync_scale); in adis16480_probe()
1470 st->clk_freq = st->chip_info->int_clk; in adis16480_probe()
1474 if (adis16480_data->burst_len) in adis16480_probe()
1477 ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, in adis16480_probe()
1497 { "adis16495-1", ADIS16495_1 },
1498 { "adis16495-2", ADIS16495_2 },
1499 { "adis16495-3", ADIS16495_3 },
1500 { "adis16497-1", ADIS16497_1 },
1501 { "adis16497-2", ADIS16497_2 },
1502 { "adis16497-3", ADIS16497_3 },
1513 { .compatible = "adi,adis16495-1" },
1514 { .compatible = "adi,adis16495-2" },
1515 { .compatible = "adi,adis16495-3" },
1516 { .compatible = "adi,adis16497-1" },
1517 { .compatible = "adi,adis16497-2" },
1518 { .compatible = "adi,adis16497-3" },
1533 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");