Lines Matching +full:datasheet +full:- +full:recommended
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright 2015-2024 Analog Devices Inc.
65 #define AD9739A_FSC_RANGE (AD9739A_FSC_MAX - AD9739A_FSC_MIN + 1)
69 #define AD9739A_DAC_CLK_RANGE (AD9739A_MAX_DAC_CLK - AD9739A_MIN_DAC_CLK + 1)
70 /* as recommended by the datasheet */
86 ret = regmap_read(st->regmap, AD9739A_REG_DEC_CNT, &mode); in ad9739a_oper_mode_get()
93 return -EIO; in ad9739a_oper_mode_get()
101 return AD9739A_MIXED_MODE - 1; in ad9739a_oper_mode_get()
113 if (mode == AD9739A_MIXED_MODE - 1) in ad9739a_oper_mode_set()
116 return regmap_update_bits(st->regmap, AD9739A_REG_DEC_CNT, in ad9739a_oper_mode_set()
128 *val = st->sample_rate; in ad9739a_read_raw()
132 return -EINVAL; in ad9739a_read_raw()
140 return iio_backend_data_source_set(st->back, 0, IIO_BACKEND_EXTERNAL); in ad9739a_buffer_preenable()
147 return iio_backend_data_source_set(st->back, 0, in ad9739a_buffer_postdisable()
177 ret = regmap_set_bits(st->regmap, AD9739A_REG_MODE, AD9739A_RESET_MASK); in ad9739a_reset()
183 return regmap_clear_bits(st->regmap, AD9739A_REG_MODE, in ad9739a_reset()
188 * Recommended values (as per datasheet) for the dac clk common mode voltage
208 ret = regmap_multi_reg_write(st->regmap, ad9739a_clk_mu_ctrl, in ad9739a_init()
215 * (as specified by the datasheet) until we get the lock. in ad9739a_init()
218 ret = regmap_write(st->regmap, AD9739A_REG_MU_CNT4, in ad9739a_init()
224 ret = regmap_write(st->regmap, AD9739A_REG_MU_CNT1, in ad9739a_init()
230 ret = regmap_read_poll_timeout(st->regmap, AD9739A_REG_MU_STAT1, in ad9739a_init()
233 if (ret && ret != -ETIMEDOUT) in ad9739a_init()
243 ret = regmap_update_bits(st->regmap, AD9739A_REG_LVDS_REC_CNT4, in ad9739a_init()
250 ret = regmap_write(st->regmap, AD9739A_REG_LVDS_REC_CNT1, 0); in ad9739a_init()
255 * Re-enable the loop so it falls out of lock and begins the in ad9739a_init()
258 ret = regmap_set_bits(st->regmap, AD9739A_REG_LVDS_REC_CNT1, in ad9739a_init()
264 ret = regmap_read_poll_timeout(st->regmap, in ad9739a_init()
268 if (ret && ret != -ETIMEDOUT) in ad9739a_init()
275 ret = device_property_read_u32(dev, "adi,full-scale-microamp", &fsc); in ad9739a_init()
276 if (ret && ret == -EINVAL) in ad9739a_init()
281 return dev_err_probe(dev, -EINVAL, in ad9739a_init()
290 fsc_raw = DIV_ROUND_CLOSEST(fsc * 10 - 85800, 226); in ad9739a_init()
292 ret = regmap_write(st->regmap, AD9739A_REG_FSC_1, fsc_raw & 0xff); in ad9739a_init()
296 return regmap_update_bits(st->regmap, AD9739A_REG_FSC_2, in ad9739a_init()
300 static const char * const ad9739a_modes_avail[] = { "normal", "mixed-mode" };
329 .scan_index = -1,
364 struct device *dev = &spi->dev; in ad9739a_probe()
373 return -ENOMEM; in ad9739a_probe()
381 st->sample_rate = clk_get_rate(clk); in ad9739a_probe()
382 if (!in_range(st->sample_rate, AD9739A_MIN_DAC_CLK, in ad9739a_probe()
384 return dev_err_probe(dev, -EINVAL, in ad9739a_probe()
386 st->sample_rate, AD9739A_MIN_DAC_CLK, in ad9739a_probe()
389 st->regmap = devm_regmap_init_spi(spi, &ad9739a_regmap_config); in ad9739a_probe()
390 if (IS_ERR(st->regmap)) in ad9739a_probe()
391 return PTR_ERR(st->regmap); in ad9739a_probe()
393 ret = regmap_read(st->regmap, AD9739A_REG_ID, &id); in ad9739a_probe()
408 st->back = devm_iio_backend_get(dev, NULL); in ad9739a_probe()
409 if (IS_ERR(st->back)) in ad9739a_probe()
410 return PTR_ERR(st->back); in ad9739a_probe()
412 ret = devm_iio_backend_request_buffer(dev, st->back, indio_dev); in ad9739a_probe()
416 ret = iio_backend_extend_chan_spec(st->back, &ad9739a_channels[0]); in ad9739a_probe()
420 ret = iio_backend_set_sampling_freq(st->back, 0, st->sample_rate); in ad9739a_probe()
424 ret = devm_iio_backend_enable(dev, st->back); in ad9739a_probe()
428 indio_dev->name = "ad9739a"; in ad9739a_probe()
429 indio_dev->info = &ad9739a_info; in ad9739a_probe()
430 indio_dev->channels = ad9739a_channels; in ad9739a_probe()
431 indio_dev->num_channels = ARRAY_SIZE(ad9739a_channels); in ad9739a_probe()
432 indio_dev->setup_ops = &ad9739a_buffer_setup_ops; in ad9739a_probe()
434 ret = devm_iio_device_register(&spi->dev, indio_dev); in ad9739a_probe()
438 iio_backend_debugfs_add(st->back, indio_dev); in ad9739a_probe()