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 if (adis->data->enable_irq) in __adis_enable_irq()
285 return adis->data->enable_irq(adis, enable); in __adis_enable_irq()
287 if (adis->data->unmasked_drdy) { in __adis_enable_irq()
289 enable_irq(adis->spi->irq); in __adis_enable_irq()
291 disable_irq(adis->spi->irq); in __adis_enable_irq()
296 ret = __adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc); in __adis_enable_irq()
307 return __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc); in __adis_enable_irq()
317 int __adis_check_status(struct adis *adis) in __adis_check_status() argument
323 ret = __adis_read_reg_16(adis, adis->data->diag_stat_reg, &status); in __adis_check_status()
327 status &= adis->data->status_error_mask; in __adis_check_status()
334 dev_err(&adis->spi->dev, "%s.\n", in __adis_check_status()
335 adis->data->status_error_msgs[i]); in __adis_check_status()
349 int __adis_reset(struct adis *adis) in __adis_reset() argument
352 const struct adis_timeout *timeouts = adis->data->timeouts; in __adis_reset()
354 ret = __adis_write_reg_8(adis, adis->data->glob_cmd_reg, in __adis_reset()
357 dev_err(&adis->spi->dev, "Failed to reset device: %d\n", ret); in __adis_reset()
367 static int adis_self_test(struct adis *adis) in adis_self_test() argument
370 const struct adis_timeout *timeouts = adis->data->timeouts; in adis_self_test()
372 ret = __adis_write_reg_16(adis, adis->data->self_test_reg, in adis_self_test()
373 adis->data->self_test_mask); in adis_self_test()
375 dev_err(&adis->spi->dev, "Failed to initiate self test: %d\n", in adis_self_test()
382 ret = __adis_check_status(adis); in adis_self_test()
384 if (adis->data->self_test_no_autoclear) in adis_self_test()
385 __adis_write_reg_16(adis, adis->data->self_test_reg, 0x00); in adis_self_test()
407 int __adis_initial_startup(struct adis *adis) in __adis_initial_startup() argument
409 const struct adis_timeout *timeouts = adis->data->timeouts; in __adis_initial_startup()
415 gpio = devm_gpiod_get_optional(&adis->spi->dev, "reset", GPIOD_OUT_HIGH); in __adis_initial_startup()
425 ret = __adis_reset(adis); in __adis_initial_startup()
430 ret = adis_self_test(adis); in __adis_initial_startup()
439 if (!adis->data->unmasked_drdy) in __adis_initial_startup()
440 __adis_enable_irq(adis, false); in __adis_initial_startup()
442 if (!adis->data->prod_id_reg) in __adis_initial_startup()
445 ret = adis_read_reg_16(adis, adis->data->prod_id_reg, &prod_id); in __adis_initial_startup()
449 if (prod_id != adis->data->prod_id) in __adis_initial_startup()
450 dev_warn(&adis->spi->dev, in __adis_initial_startup()
452 adis->data->prod_id, prod_id); in __adis_initial_startup()
477 struct adis *adis = iio_device_get_drvdata(indio_dev); in adis_single_conversion() local
481 mutex_lock(&adis->state_lock); in adis_single_conversion()
483 ret = __adis_read_reg(adis, chan->address, &uval, in adis_single_conversion()
489 ret = __adis_check_status(adis); in adis_single_conversion()
501 mutex_unlock(&adis->state_lock); in adis_single_conversion()
518 int adis_init(struct adis *adis, struct iio_dev *indio_dev, in adis_init() argument
526 mutex_init(&adis->state_lock); in adis_init()
527 adis->spi = spi; in adis_init()
528 adis->data = data; in adis_init()
529 iio_device_set_drvdata(indio_dev, adis); in adis_init()
533 adis->current_page = -1; in adis_init()
536 adis->current_page = 0; in adis_init()