Lines Matching +full:scaled +full:- +full:output +full:- +full:hz

1 // SPDX-License-Identifier: GPL-2.0
125 struct adis16475 *st = file->private_data; in adis16475_show_firmware_revision()
131 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FIRM_REV, &rev); in adis16475_show_firmware_revision()
151 struct adis16475 *st = file->private_data; in adis16475_show_firmware_date()
157 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FIRM_Y, &year); in adis16475_show_firmware_date()
161 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FIRM_DM, &md); in adis16475_show_firmware_date()
165 len = snprintf(buf, sizeof(buf), "%.2x-%.2x-%.4x\n", md >> 8, md & 0xff, in adis16475_show_firmware_date()
184 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_SERIAL_NUM, &serial); in adis16475_show_serial_number()
201 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_PROD_ID, &prod_id); in adis16475_show_product_id()
218 ret = adis_read_reg_32(&st->adis, ADIS16475_REG_FLASH_CNT, in adis16475_show_flash_count()
257 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, &dec); in adis16475_get_freq()
259 return -EINVAL; in adis16475_get_freq()
261 *freq = DIV_ROUND_CLOSEST(st->clk_freq, dec + 1); in adis16475_get_freq()
272 return -EINVAL; in adis16475_set_freq()
274 dec = DIV_ROUND_CLOSEST(st->clk_freq, freq); in adis16475_set_freq()
277 dec--; in adis16475_set_freq()
279 if (dec > st->info->max_dec) in adis16475_set_freq()
280 dec = st->info->max_dec; in adis16475_set_freq()
282 ret = adis_write_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, dec); in adis16475_set_freq()
290 assign_bit(ADIS16475_LSB_DEC_MASK, &st->lsb_flag, dec); in adis16475_set_freq()
297 [0] = 720, /* Filter disabled, full BW (~720Hz) */
312 ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FILT_CTRL, &filter_sz); in adis16475_get_filter()
326 while (--i) { in adis16475_set_filter()
331 ret = adis_write_reg_16(&st->adis, ADIS16475_REG_FILT_CTRL, in adis16475_set_filter()
340 assign_bit(ADIS16475_LSB_FIR_MASK, &st->lsb_flag, i); in adis16475_set_filter()
366 switch (chan->type) { in adis16475_read_raw()
368 *val = st->info->gyro_max_val; in adis16475_read_raw()
369 *val2 = st->info->gyro_max_scale; in adis16475_read_raw()
372 *val = st->info->accel_max_val; in adis16475_read_raw()
373 *val2 = st->info->accel_max_scale; in adis16475_read_raw()
376 *val = st->info->temp_scale; in adis16475_read_raw()
379 return -EINVAL; in adis16475_read_raw()
382 ret = adis_read_reg_32(&st->adis, in adis16475_read_raw()
383 adis16475_calib_regs[chan->scan_index], in adis16475_read_raw()
404 return -EINVAL; in adis16475_read_raw()
422 return adis_write_reg_32(&st->adis, in adis16475_write_raw()
423 adis16475_calib_regs[chan->scan_index], in adis16475_write_raw()
426 return -EINVAL; in adis16475_write_raw()
535 * There is no way to gate the data-ready signal internally inside the in adis16475_enable_irq()
539 enable_irq(adis->spi->irq); in adis16475_enable_irq()
541 disable_irq(adis->spi->irq); in adis16475_enable_irq()
609 .name = "adis16475-1",
624 .name = "adis16475-2",
639 .name = "adis16475-3",
654 .name = "adis16477-1",
669 .name = "adis16477-2",
684 .name = "adis16477-3",
699 .name = "adis16465-1",
714 .name = "adis16465-2",
729 .name = "adis16465-3",
744 .name = "adis16467-1",
759 .name = "adis16467-2",
774 .name = "adis16467-3",
801 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
806 .name = "adis16505-1",
818 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
823 .name = "adis16505-2",
835 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
840 .name = "adis16505-3",
852 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
857 .name = "adis16507-1",
869 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
874 .name = "adis16507-2",
886 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
891 .name = "adis16507-3",
903 .num_sync = ARRAY_SIZE(adis16475_sync_mode) - 1,
924 for (i = 0; i < sz - 2; i++) in adis16475_validate_crc()
925 crc -= buffer[i]; in adis16475_validate_crc()
933 struct adis *adis = &st->adis; in adis16475_burst32_check()
935 if (!st->info->has_burst32) in adis16475_burst32_check()
938 if (st->lsb_flag && !st->burst32) { in adis16475_burst32_check()
941 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL, in adis16475_burst32_check()
946 st->burst32 = true; in adis16475_burst32_check()
949 * In 32-bit mode we need extra 2 bytes for all gyro in adis16475_burst32_check()
952 adis->burst_extra_len = 6 * sizeof(u16); in adis16475_burst32_check()
953 adis->xfer[1].len += 6 * sizeof(u16); in adis16475_burst32_check()
954 dev_dbg(&adis->spi->dev, "Enable burst32 mode, xfer:%d", in adis16475_burst32_check()
955 adis->xfer[1].len); in adis16475_burst32_check()
957 } else if (!st->lsb_flag && st->burst32) { in adis16475_burst32_check()
960 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL, in adis16475_burst32_check()
965 st->burst32 = false; in adis16475_burst32_check()
968 adis->burst_extra_len = 0; in adis16475_burst32_check()
969 adis->xfer[1].len -= 6 * sizeof(u16); in adis16475_burst32_check()
970 dev_dbg(&adis->spi->dev, "Disable burst32 mode, xfer:%d\n", in adis16475_burst32_check()
971 adis->xfer[1].len); in adis16475_burst32_check()
978 struct iio_dev *indio_dev = pf->indio_dev; in adis16475_trigger_handler()
980 struct adis *adis = &st->adis; in adis16475_trigger_handler()
986 const u8 offset = st->burst32 ? 13 : 7; in adis16475_trigger_handler()
987 const u32 cached_spi_speed_hz = adis->spi->max_speed_hz; in adis16475_trigger_handler()
989 adis->spi->max_speed_hz = ADIS16475_BURST_MAX_SPEED; in adis16475_trigger_handler()
991 ret = spi_sync(adis->spi, &adis->msg); in adis16475_trigger_handler()
995 adis->spi->max_speed_hz = cached_spi_speed_hz; in adis16475_trigger_handler()
996 buffer = adis->buffer; in adis16475_trigger_handler()
999 valid = adis16475_validate_crc(adis->buffer, crc, st->burst32); in adis16475_trigger_handler()
1001 dev_err(&adis->spi->dev, "Invalid crc\n"); in adis16475_trigger_handler()
1005 for_each_set_bit(bit, indio_dev->active_scan_mask, in adis16475_trigger_handler()
1006 indio_dev->masklength) { in adis16475_trigger_handler()
1013 st->data[i++] = buffer[offset]; in adis16475_trigger_handler()
1020 if (st->burst32) { in adis16475_trigger_handler()
1022 st->data[i++] = buffer[bit * 2 + 2]; in adis16475_trigger_handler()
1024 st->data[i++] = buffer[bit * 2 + 1]; in adis16475_trigger_handler()
1026 st->data[i++] = buffer[bit + 1]; in adis16475_trigger_handler()
1033 if (st->lsb_flag && !st->info->has_burst32) { in adis16475_trigger_handler()
1039 st->data[i++] = cpu_to_be16(val); in adis16475_trigger_handler()
1042 st->data[i++] = 0; in adis16475_trigger_handler()
1049 iio_push_to_buffers_with_timestamp(indio_dev, st->data, pf->timestamp); in adis16475_trigger_handler()
1057 iio_trigger_notify_done(indio_dev->trig); in adis16475_trigger_handler()
1070 struct device *dev = &st->adis.spi->dev; in adis16475_config_sync_mode()
1075 st->clk_freq = st->info->int_clk * 1000; in adis16475_config_sync_mode()
1077 ret = device_property_read_u32(dev, "adi,sync-mode", &sync_mode); in adis16475_config_sync_mode()
1081 if (sync_mode >= st->info->num_sync) { in adis16475_config_sync_mode()
1083 st->info->name); in adis16475_config_sync_mode()
1084 return -EINVAL; in adis16475_config_sync_mode()
1087 sync = &st->info->sync[sync_mode]; in adis16475_config_sync_mode()
1090 if (sync->sync_mode != ADIS16475_SYNC_OUTPUT) { in adis16475_config_sync_mode()
1104 st->clk_freq = clk_get_rate(clk); in adis16475_config_sync_mode()
1105 if (st->clk_freq < sync->min_rate || in adis16475_config_sync_mode()
1106 st->clk_freq > sync->max_rate) { in adis16475_config_sync_mode()
1109 st->clk_freq, sync->min_rate, sync->max_rate); in adis16475_config_sync_mode()
1110 return -EINVAL; in adis16475_config_sync_mode()
1113 if (sync->sync_mode == ADIS16475_SYNC_SCALED) { in adis16475_config_sync_mode()
1117 * If we are in scaled mode, we must have an up_scale. in adis16475_config_sync_mode()
1118 * In scaled mode the allowable input clock range is in adis16475_config_sync_mode()
1119 * 1 Hz to 128 Hz, and the allowable output range is in adis16475_config_sync_mode()
1120 * 1900 to 2100 Hz. Hence, a scale must be given to in adis16475_config_sync_mode()
1121 * get the allowable output. in adis16475_config_sync_mode()
1124 "adi,scaled-output-hz", in adis16475_config_sync_mode()
1127 dev_err(dev, "adi,scaled-output-hz must be given when in scaled sync mode"); in adis16475_config_sync_mode()
1128 return -EINVAL; in adis16475_config_sync_mode()
1131 dev_err(dev, "Invalid value: %u for adi,scaled-output-hz", in adis16475_config_sync_mode()
1133 return -EINVAL; in adis16475_config_sync_mode()
1137 st->clk_freq); in adis16475_config_sync_mode()
1139 ret = __adis_write_reg_16(&st->adis, in adis16475_config_sync_mode()
1145 st->clk_freq = scaled_out_freq; in adis16475_config_sync_mode()
1148 st->clk_freq *= 1000; in adis16475_config_sync_mode()
1158 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL, in adis16475_config_sync_mode()
1159 ADIS16475_SYNC_MODE_MASK, sync->sync_mode); in adis16475_config_sync_mode()
1175 struct spi_device *spi = st->adis.spi; in adis16475_config_irq_pin()
1177 desc = irq_get_irq_data(spi->irq); in adis16475_config_irq_pin()
1179 dev_err(&spi->dev, "Could not find IRQ %d\n", spi->irq); in adis16475_config_irq_pin()
1180 return -EINVAL; in adis16475_config_irq_pin()
1189 st->adis.irq_flag = IRQF_TRIGGER_RISING; in adis16475_config_irq_pin()
1192 st->adis.irq_flag = IRQF_TRIGGER_FALLING; in adis16475_config_irq_pin()
1194 dev_err(&spi->dev, "Invalid interrupt type 0x%x specified\n", in adis16475_config_irq_pin()
1196 return -EINVAL; in adis16475_config_irq_pin()
1200 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL, in adis16475_config_irq_pin()
1217 { .compatible = "adi,adis16475-1",
1219 { .compatible = "adi,adis16475-2",
1221 { .compatible = "adi,adis16475-3",
1223 { .compatible = "adi,adis16477-1",
1225 { .compatible = "adi,adis16477-2",
1227 { .compatible = "adi,adis16477-3",
1229 { .compatible = "adi,adis16465-1",
1231 { .compatible = "adi,adis16465-2",
1233 { .compatible = "adi,adis16465-3",
1235 { .compatible = "adi,adis16467-1",
1237 { .compatible = "adi,adis16467-2",
1239 { .compatible = "adi,adis16467-3",
1243 { .compatible = "adi,adis16505-1",
1245 { .compatible = "adi,adis16505-2",
1247 { .compatible = "adi,adis16505-3",
1249 { .compatible = "adi,adis16507-1",
1251 { .compatible = "adi,adis16507-2",
1253 { .compatible = "adi,adis16507-3",
1265 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in adis16475_probe()
1267 return -ENOMEM; in adis16475_probe()
1272 st->info = device_get_match_data(&spi->dev); in adis16475_probe()
1273 if (!st->info) in adis16475_probe()
1274 return -EINVAL; in adis16475_probe()
1276 ret = adis_init(&st->adis, indio_dev, spi, &st->info->adis_data); in adis16475_probe()
1280 indio_dev->name = st->info->name; in adis16475_probe()
1281 indio_dev->channels = st->info->channels; in adis16475_probe()
1282 indio_dev->num_channels = st->info->num_channels; in adis16475_probe()
1283 indio_dev->info = &adis16475_info; in adis16475_probe()
1284 indio_dev->modes = INDIO_DIRECT_MODE; in adis16475_probe()
1286 ret = __adis_initial_startup(&st->adis); in adis16475_probe()
1298 ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, in adis16475_probe()
1303 adis16475_enable_irq(&st->adis, false); in adis16475_probe()
1305 ret = devm_iio_device_register(&spi->dev, indio_dev); in adis16475_probe()