Lines Matching +full:reg +full:- +full:names

1 // SPDX-License-Identifier: GPL-2.0-only
30 #define ADIS16480_REG(page, reg) ((page) * ADIS16480_PAGE_SIZE + (reg)) argument
109 ADIS16480_REG((page) + 1, (x) - 60 + 8))
178 struct adis16480 *adis16480 = file->private_data; in adis16480_show_firmware_revision()
184 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_REV, &rev); in adis16480_show_firmware_revision()
203 struct adis16480 *adis16480 = file->private_data; in adis16480_show_firmware_date()
209 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_Y, &year); in adis16480_show_firmware_date()
213 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_DM, &md); in adis16480_show_firmware_date()
217 len = snprintf(buf, sizeof(buf), "%.2x-%.2x-%.4x\n", in adis16480_show_firmware_date()
236 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_SERIAL_NUM, in adis16480_show_serial_number()
254 ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_PROD_ID, in adis16480_show_product_id()
272 ret = adis_read_reg_32(&adis16480->adis, ADIS16480_REG_FLASH_CNT, in adis16480_show_flash_count()
315 unsigned int t, reg; in adis16480_set_freq() local
318 return -EINVAL; in adis16480_set_freq()
322 return -EINVAL; in adis16480_set_freq()
331 if (st->clk_mode == ADIS16480_CLK_PPS) { in adis16480_set_freq()
332 t = t / st->clk_freq; in adis16480_set_freq()
333 reg = ADIS16495_REG_SYNC_SCALE; in adis16480_set_freq()
335 t = st->clk_freq / t; in adis16480_set_freq()
336 reg = ADIS16480_REG_DEC_RATE; in adis16480_set_freq()
339 if (t > st->chip_info->max_dec_rate) in adis16480_set_freq()
340 t = st->chip_info->max_dec_rate; in adis16480_set_freq()
342 if ((t != 0) && (st->clk_mode != ADIS16480_CLK_PPS)) in adis16480_set_freq()
343 t--; in adis16480_set_freq()
345 return adis_write_reg_16(&st->adis, reg, t); in adis16480_set_freq()
354 unsigned int reg; in adis16480_get_freq() local
356 if (st->clk_mode == ADIS16480_CLK_PPS) in adis16480_get_freq()
357 reg = ADIS16495_REG_SYNC_SCALE; in adis16480_get_freq()
359 reg = ADIS16480_REG_DEC_RATE; in adis16480_get_freq()
361 ret = adis_read_reg_16(&st->adis, reg, &t); in adis16480_get_freq()
372 if (st->clk_mode == ADIS16480_CLK_PPS) in adis16480_get_freq()
373 freq = st->clk_freq * t; in adis16480_get_freq()
375 freq = st->clk_freq / (t + 1); in adis16480_get_freq()
422 unsigned int reg = adis16480_calibbias_regs[chan->scan_index]; in adis16480_set_calibbias() local
425 switch (chan->type) { in adis16480_set_calibbias()
428 if (bias < -0x8000 || bias >= 0x8000) in adis16480_set_calibbias()
429 return -EINVAL; in adis16480_set_calibbias()
430 return adis_write_reg_16(&st->adis, reg, bias); in adis16480_set_calibbias()
433 return adis_write_reg_32(&st->adis, reg, bias); in adis16480_set_calibbias()
438 return -EINVAL; in adis16480_set_calibbias()
444 unsigned int reg = adis16480_calibbias_regs[chan->scan_index]; in adis16480_get_calibbias() local
450 switch (chan->type) { in adis16480_get_calibbias()
453 ret = adis_read_reg_16(&st->adis, reg, &val16); in adis16480_get_calibbias()
459 ret = adis_read_reg_32(&st->adis, reg, &val32); in adis16480_get_calibbias()
464 ret = -EINVAL; in adis16480_get_calibbias()
476 unsigned int reg = adis16480_calibscale_regs[chan->scan_index]; in adis16480_set_calibscale() local
479 if (scale < -0x8000 || scale >= 0x8000) in adis16480_set_calibscale()
480 return -EINVAL; in adis16480_set_calibscale()
482 return adis_write_reg_16(&st->adis, reg, scale); in adis16480_set_calibscale()
488 unsigned int reg = adis16480_calibscale_regs[chan->scan_index]; in adis16480_get_calibscale() local
493 ret = adis_read_reg_16(&st->adis, reg, &val16); in adis16480_get_calibscale()
531 unsigned int enable_mask, offset, reg; in adis16480_get_filter_freq() local
535 reg = ad16480_filter_data[chan->scan_index][0]; in adis16480_get_filter_freq()
536 offset = ad16480_filter_data[chan->scan_index][1]; in adis16480_get_filter_freq()
539 ret = adis_read_reg_16(&st->adis, reg, &val); in adis16480_get_filter_freq()
546 *freq = st->chip_info->filter_freqs[(val >> offset) & 0x3]; in adis16480_get_filter_freq()
555 struct mutex *slock = &st->adis.state_lock; in adis16480_set_filter_freq()
556 unsigned int enable_mask, offset, reg; in adis16480_set_filter_freq() local
562 reg = ad16480_filter_data[chan->scan_index][0]; in adis16480_set_filter_freq()
563 offset = ad16480_filter_data[chan->scan_index][1]; in adis16480_set_filter_freq()
568 ret = __adis_read_reg_16(&st->adis, reg, &val); in adis16480_set_filter_freq()
576 best_diff = st->chip_info->filter_freqs[0]; in adis16480_set_filter_freq()
578 if (st->chip_info->filter_freqs[i] >= freq) { in adis16480_set_filter_freq()
579 diff = st->chip_info->filter_freqs[i] - freq; in adis16480_set_filter_freq()
592 ret = __adis_write_reg_16(&st->adis, reg, val); in adis16480_set_filter_freq()
609 switch (chan->type) { in adis16480_read_raw()
611 *val = st->chip_info->gyro_max_scale; in adis16480_read_raw()
612 *val2 = st->chip_info->gyro_max_val; in adis16480_read_raw()
615 *val = st->chip_info->accel_max_scale; in adis16480_read_raw()
616 *val2 = st->chip_info->accel_max_val; in adis16480_read_raw()
628 *val = st->chip_info->temp_scale / 1000; in adis16480_read_raw()
629 *val2 = (st->chip_info->temp_scale % 1000) * 1000; in adis16480_read_raw()
640 return -EINVAL; in adis16480_read_raw()
645 *val = DIV_ROUND_CLOSEST_ULL(temp, st->chip_info->temp_scale); in adis16480_read_raw()
656 return -EINVAL; in adis16480_read_raw()
674 return -EINVAL; in adis16480_write_raw()
807 [ADIS16480_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
808 [ADIS16480_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
809 [ADIS16480_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
810 [ADIS16480_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
811 [ADIS16480_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
812 [ADIS16480_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
813 [ADIS16480_DIAG_STAT_XMAGN_FAIL] = "X-axis magnetometer self-test failure",
814 [ADIS16480_DIAG_STAT_YMAGN_FAIL] = "Y-axis magnetometer self-test failure",
815 [ADIS16480_DIAG_STAT_ZMAGN_FAIL] = "Z-axis magnetometer self-test failure",
816 [ADIS16480_DIAG_STAT_BARO_FAIL] = "Barometer self-test failure",
1042 ret = adis_write_reg_16(&st->adis, ADIS16480_REG_SLP_CNT, BIT(9)); in adis16480_stop_device()
1044 dev_err(&indio_dev->dev, in adis16480_stop_device()
1074 desc = irq_get_irq_data(st->adis.spi->irq); in adis16480_config_irq_pin()
1076 dev_err(&st->adis.spi->dev, "Could not find IRQ %d\n", irq); in adis16480_config_irq_pin()
1077 return -EINVAL; in adis16480_config_irq_pin()
1084 * Get the interrupt from the devicetre by reading the interrupt-names in adis16480_config_irq_pin()
1113 dev_err(&st->adis.spi->dev, in adis16480_config_irq_pin()
1115 return -EINVAL; in adis16480_config_irq_pin()
1118 return adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val); in adis16480_config_irq_pin()
1129 if (of_property_read_string(of_node, "adi,ext-clk-pin", &ext_clk_pin)) in adis16480_of_get_ext_clk_pin()
1138 dev_info(&st->adis.spi->dev, in adis16480_of_get_ext_clk_pin()
1152 ret = adis_read_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, &val); in adis16480_ext_clk_config()
1163 dev_warn(&st->adis.spi->dev, in adis16480_ext_clk_config()
1170 if (st->chip_info->has_pps_clk_mode) { in adis16480_ext_clk_config()
1171 mode |= ADIS16480_SYNC_MODE(st->clk_mode); in adis16480_ext_clk_config()
1178 ret = adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val); in adis16480_ext_clk_config()
1182 return clk_prepare_enable(st->ext_clk); in adis16480_ext_clk_config()
1187 st->clk_mode = ADIS16480_CLK_INT; in adis16480_get_ext_clocks()
1188 st->ext_clk = devm_clk_get(&st->adis.spi->dev, "sync"); in adis16480_get_ext_clocks()
1189 if (!IS_ERR_OR_NULL(st->ext_clk)) { in adis16480_get_ext_clocks()
1190 st->clk_mode = ADIS16480_CLK_SYNC; in adis16480_get_ext_clocks()
1194 if (PTR_ERR(st->ext_clk) != -ENOENT) { in adis16480_get_ext_clocks()
1195 dev_err(&st->adis.spi->dev, "failed to get ext clk\n"); in adis16480_get_ext_clocks()
1196 return PTR_ERR(st->ext_clk); in adis16480_get_ext_clocks()
1199 if (st->chip_info->has_pps_clk_mode) { in adis16480_get_ext_clocks()
1200 st->ext_clk = devm_clk_get(&st->adis.spi->dev, "pps"); in adis16480_get_ext_clocks()
1201 if (!IS_ERR_OR_NULL(st->ext_clk)) { in adis16480_get_ext_clocks()
1202 st->clk_mode = ADIS16480_CLK_PPS; in adis16480_get_ext_clocks()
1206 if (PTR_ERR(st->ext_clk) != -ENOENT) { in adis16480_get_ext_clocks()
1207 dev_err(&st->adis.spi->dev, "failed to get ext clk\n"); in adis16480_get_ext_clocks()
1208 return PTR_ERR(st->ext_clk); in adis16480_get_ext_clocks()
1233 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in adis16480_probe()
1235 return -ENOMEM; in adis16480_probe()
1241 st->chip_info = &adis16480_chip_info[id->driver_data]; in adis16480_probe()
1242 indio_dev->name = spi_get_device_id(spi)->name; in adis16480_probe()
1243 indio_dev->channels = st->chip_info->channels; in adis16480_probe()
1244 indio_dev->num_channels = st->chip_info->num_channels; in adis16480_probe()
1245 indio_dev->info = &adis16480_info; in adis16480_probe()
1246 indio_dev->modes = INDIO_DIRECT_MODE; in adis16480_probe()
1248 adis16480_data = &st->chip_info->adis_data; in adis16480_probe()
1250 ret = adis_init(&st->adis, indio_dev, spi, adis16480_data); in adis16480_probe()
1254 ret = __adis_initial_startup(&st->adis); in adis16480_probe()
1258 ret = devm_add_action_or_reset(&spi->dev, adis16480_stop, indio_dev); in adis16480_probe()
1262 ret = adis16480_config_irq_pin(spi->dev.of_node, st); in adis16480_probe()
1270 if (!IS_ERR_OR_NULL(st->ext_clk)) { in adis16480_probe()
1271 ret = adis16480_ext_clk_config(st, spi->dev.of_node, true); in adis16480_probe()
1275 ret = devm_add_action_or_reset(&spi->dev, adis16480_clk_disable, st->ext_clk); in adis16480_probe()
1279 st->clk_freq = clk_get_rate(st->ext_clk); in adis16480_probe()
1280 st->clk_freq *= 1000; /* micro */ in adis16480_probe()
1282 st->clk_freq = st->chip_info->int_clk; in adis16480_probe()
1285 ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, NULL); in adis16480_probe()
1289 ret = devm_iio_device_register(&spi->dev, indio_dev); in adis16480_probe()
1304 { "adis16495-1", ADIS16495_1 },
1305 { "adis16495-2", ADIS16495_2 },
1306 { "adis16495-3", ADIS16495_3 },
1307 { "adis16497-1", ADIS16497_1 },
1308 { "adis16497-2", ADIS16497_2 },
1309 { "adis16497-3", ADIS16497_3 },
1320 { .compatible = "adi,adis16495-1" },
1321 { .compatible = "adi,adis16495-2" },
1322 { .compatible = "adi,adis16495-3" },
1323 { .compatible = "adi,adis16497-1" },
1324 { .compatible = "adi,adis16497-2" },
1325 { .compatible = "adi,adis16497-3" },
1340 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");