Lines Matching refs:adis

33 int __adis_write_reg(struct adis *adis, unsigned int reg, unsigned int value,  in __adis_write_reg()  argument
41 .tx_buf = adis->tx, in __adis_write_reg()
45 .delay.value = adis->data->write_delay, in __adis_write_reg()
47 .cs_change_delay.value = adis->data->cs_change_delay, in __adis_write_reg()
50 .tx_buf = adis->tx + 2, in __adis_write_reg()
54 .delay.value = adis->data->write_delay, in __adis_write_reg()
56 .cs_change_delay.value = adis->data->cs_change_delay, in __adis_write_reg()
59 .tx_buf = adis->tx + 4, in __adis_write_reg()
63 .delay.value = adis->data->write_delay, in __adis_write_reg()
65 .cs_change_delay.value = adis->data->cs_change_delay, in __adis_write_reg()
68 .tx_buf = adis->tx + 6, in __adis_write_reg()
71 .delay.value = adis->data->write_delay, in __adis_write_reg()
74 .tx_buf = adis->tx + 8, in __adis_write_reg()
77 .delay.value = adis->data->write_delay, in __adis_write_reg()
84 if (adis->current_page != page) { in __adis_write_reg()
85 adis->tx[0] = ADIS_WRITE_REG(ADIS_REG_PAGE_ID); in __adis_write_reg()
86 adis->tx[1] = page; in __adis_write_reg()
92 adis->tx[8] = ADIS_WRITE_REG(reg + 3); in __adis_write_reg()
93 adis->tx[9] = (value >> 24) & 0xff; in __adis_write_reg()
94 adis->tx[6] = ADIS_WRITE_REG(reg + 2); in __adis_write_reg()
95 adis->tx[7] = (value >> 16) & 0xff; in __adis_write_reg()
98 adis->tx[4] = ADIS_WRITE_REG(reg + 1); in __adis_write_reg()
99 adis->tx[5] = (value >> 8) & 0xff; in __adis_write_reg()
102 adis->tx[2] = ADIS_WRITE_REG(reg); in __adis_write_reg()
103 adis->tx[3] = value & 0xff; in __adis_write_reg()
114 ret = spi_sync(adis->spi, &msg); in __adis_write_reg()
116 dev_err(&adis->spi->dev, "Failed to write register 0x%02X: %d\n", in __adis_write_reg()
119 adis->current_page = page; in __adis_write_reg()
133 int __adis_read_reg(struct adis *adis, unsigned int reg, unsigned int *val, in __adis_read_reg() argument
141 .tx_buf = adis->tx, in __adis_read_reg()
145 .delay.value = adis->data->write_delay, in __adis_read_reg()
147 .cs_change_delay.value = adis->data->cs_change_delay, in __adis_read_reg()
150 .tx_buf = adis->tx + 2, in __adis_read_reg()
154 .delay.value = adis->data->read_delay, in __adis_read_reg()
156 .cs_change_delay.value = adis->data->cs_change_delay, in __adis_read_reg()
159 .tx_buf = adis->tx + 4, in __adis_read_reg()
160 .rx_buf = adis->rx, in __adis_read_reg()
164 .delay.value = adis->data->read_delay, in __adis_read_reg()
166 .cs_change_delay.value = adis->data->cs_change_delay, in __adis_read_reg()
169 .rx_buf = adis->rx + 2, in __adis_read_reg()
172 .delay.value = adis->data->read_delay, in __adis_read_reg()
179 if (adis->current_page != page) { in __adis_read_reg()
180 adis->tx[0] = ADIS_WRITE_REG(ADIS_REG_PAGE_ID); in __adis_read_reg()
181 adis->tx[1] = page; in __adis_read_reg()
187 adis->tx[2] = ADIS_READ_REG(reg + 2); in __adis_read_reg()
188 adis->tx[3] = 0; in __adis_read_reg()
192 adis->tx[4] = ADIS_READ_REG(reg); in __adis_read_reg()
193 adis->tx[5] = 0; in __adis_read_reg()
201 ret = spi_sync(adis->spi, &msg); in __adis_read_reg()
203 dev_err(&adis->spi->dev, "Failed to read register 0x%02X: %d\n", in __adis_read_reg()
208 adis->current_page = page; in __adis_read_reg()
212 *val = get_unaligned_be32(adis->rx); in __adis_read_reg()
215 *val = get_unaligned_be16(adis->rx + 2); in __adis_read_reg()
232 int __adis_update_bits_base(struct adis *adis, unsigned int reg, const u32 mask, in __adis_update_bits_base() argument
238 ret = __adis_read_reg(adis, reg, &__val, size); in __adis_update_bits_base()
244 return __adis_write_reg(adis, reg, __val, size); in __adis_update_bits_base()
253 struct adis *adis = iio_device_get_drvdata(indio_dev); in adis_debugfs_reg_access() local
259 ret = adis_read_reg_16(adis, reg, &val16); in adis_debugfs_reg_access()
266 return adis_write_reg_16(adis, reg, writeval); in adis_debugfs_reg_access()
279 int adis_enable_irq(struct adis *adis, bool enable) in adis_enable_irq() argument
284 mutex_lock(&adis->state_lock); in adis_enable_irq()
286 if (adis->data->enable_irq) { in adis_enable_irq()
287 ret = adis->data->enable_irq(adis, enable); in adis_enable_irq()
291 if (adis->data->unmasked_drdy) { in adis_enable_irq()
293 enable_irq(adis->spi->irq); in adis_enable_irq()
295 disable_irq(adis->spi->irq); in adis_enable_irq()
300 ret = __adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc); in adis_enable_irq()
311 ret = __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc); in adis_enable_irq()
314 mutex_unlock(&adis->state_lock); in adis_enable_irq()
325 int __adis_check_status(struct adis *adis) in __adis_check_status() argument
331 ret = __adis_read_reg_16(adis, adis->data->diag_stat_reg, &status); in __adis_check_status()
335 status &= adis->data->status_error_mask; in __adis_check_status()
342 dev_err(&adis->spi->dev, "%s.\n", in __adis_check_status()
343 adis->data->status_error_msgs[i]); in __adis_check_status()
357 int __adis_reset(struct adis *adis) in __adis_reset() argument
360 const struct adis_timeout *timeouts = adis->data->timeouts; in __adis_reset()
362 ret = __adis_write_reg_8(adis, adis->data->glob_cmd_reg, in __adis_reset()
365 dev_err(&adis->spi->dev, "Failed to reset device: %d\n", ret); in __adis_reset()
375 static int adis_self_test(struct adis *adis) in adis_self_test() argument
378 const struct adis_timeout *timeouts = adis->data->timeouts; in adis_self_test()
380 ret = __adis_write_reg_16(adis, adis->data->self_test_reg, in adis_self_test()
381 adis->data->self_test_mask); in adis_self_test()
383 dev_err(&adis->spi->dev, "Failed to initiate self test: %d\n", in adis_self_test()
390 ret = __adis_check_status(adis); in adis_self_test()
392 if (adis->data->self_test_no_autoclear) in adis_self_test()
393 __adis_write_reg_16(adis, adis->data->self_test_reg, 0x00); in adis_self_test()
415 int __adis_initial_startup(struct adis *adis) in __adis_initial_startup() argument
417 const struct adis_timeout *timeouts = adis->data->timeouts; in __adis_initial_startup()
423 gpio = devm_gpiod_get_optional(&adis->spi->dev, "reset", GPIOD_OUT_HIGH); in __adis_initial_startup()
433 ret = __adis_reset(adis); in __adis_initial_startup()
438 ret = adis_self_test(adis); in __adis_initial_startup()
447 if (!adis->data->unmasked_drdy) in __adis_initial_startup()
448 adis_enable_irq(adis, false); in __adis_initial_startup()
450 if (!adis->data->prod_id_reg) in __adis_initial_startup()
453 ret = adis_read_reg_16(adis, adis->data->prod_id_reg, &prod_id); in __adis_initial_startup()
457 if (prod_id != adis->data->prod_id) in __adis_initial_startup()
458 dev_warn(&adis->spi->dev, in __adis_initial_startup()
460 adis->data->prod_id, prod_id); in __adis_initial_startup()
485 struct adis *adis = iio_device_get_drvdata(indio_dev); in adis_single_conversion() local
489 mutex_lock(&adis->state_lock); in adis_single_conversion()
491 ret = __adis_read_reg(adis, chan->address, &uval, in adis_single_conversion()
497 ret = __adis_check_status(adis); in adis_single_conversion()
509 mutex_unlock(&adis->state_lock); in adis_single_conversion()
526 int adis_init(struct adis *adis, struct iio_dev *indio_dev, in adis_init() argument
534 mutex_init(&adis->state_lock); in adis_init()
535 adis->spi = spi; in adis_init()
536 adis->data = data; in adis_init()
537 iio_device_set_drvdata(indio_dev, adis); in adis_init()
541 adis->current_page = -1; in adis_init()
544 adis->current_page = 0; in adis_init()