Lines Matching +full:lvds +full:- +full:cnv +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-only
201 return regmap_read(st->regmap, reg, readval); in ad4080_reg_access()
203 return regmap_write(st->regmap, reg, writeval); in ad4080_reg_access()
210 tmp = (st->info->scale_table[0][0] * 1000000ULL) >> in ad4080_get_scale()
211 st->info->channels[0].scan_type.realbits; in ad4080_get_scale()
225 ret = regmap_read(st->regmap, AD4080_REG_FILTER_CONFIG, &data); in ad4080_get_dec_rate()
238 guard(mutex)(&st->lock); in ad4080_set_dec_rate()
240 if ((st->filter_type >= SINC_5 && mode >= 512) || mode < 2) in ad4080_set_dec_rate()
241 return -EINVAL; in ad4080_set_dec_rate()
243 return regmap_update_bits(st->regmap, AD4080_REG_FILTER_CONFIG, in ad4080_set_dec_rate()
246 (ilog2(mode) - 1))); in ad4080_set_dec_rate()
263 if (st->filter_type == SINC_5_COMP) in ad4080_read_raw()
265 if (st->filter_type) in ad4080_read_raw()
266 *val = DIV_ROUND_CLOSEST(st->clk_rate, dec_rate); in ad4080_read_raw()
268 *val = st->clk_rate; in ad4080_read_raw()
271 if (st->filter_type == FILTER_NONE) { in ad4080_read_raw()
280 return -EINVAL; in ad4080_read_raw()
292 if (st->filter_type == FILTER_NONE && val > 1) in ad4080_write_raw()
293 return -EINVAL; in ad4080_write_raw()
297 return -EINVAL; in ad4080_write_raw()
303 struct device *dev = regmap_get_device(st->regmap); in ad4080_lvds_sync_write()
306 ret = regmap_set_bits(st->regmap, AD4080_REG_ADC_DATA_INTF_CONFIG_A, in ad4080_lvds_sync_write()
311 ret = iio_backend_interface_data_align(st->back, 10000); in ad4080_lvds_sync_write()
317 return regmap_clear_bits(st->regmap, AD4080_REG_ADC_DATA_INTF_CONFIG_A, in ad4080_lvds_sync_write()
328 ret = regmap_read(st->regmap, AD4080_REG_FILTER_CONFIG, &data); in ad4080_get_filter_type()
343 guard(mutex)(&st->lock); in ad4080_set_filter_type()
350 return -EINVAL; in ad4080_set_filter_type()
352 ret = iio_backend_filter_type_set(st->back, mode); in ad4080_set_filter_type()
356 ret = regmap_update_bits(st->regmap, AD4080_REG_FILTER_CONFIG, in ad4080_set_filter_type()
363 st->filter_type = mode; in ad4080_set_filter_type()
377 switch (st->filter_type) { in ad4080_read_avail()
384 *length = st->filter_type >= SINC_5 ? in ad4080_read_avail()
385 (ARRAY_SIZE(ad4080_dec_rate_avail) - 2) : in ad4080_read_avail()
392 return -EINVAL; in ad4080_read_avail()
447 struct device *dev = regmap_get_device(st->regmap); in ad4080_setup()
451 ret = regmap_write(st->regmap, AD4080_REG_INTERFACE_CONFIG_A, in ad4080_setup()
456 ret = regmap_write(st->regmap, AD4080_REG_INTERFACE_CONFIG_A, in ad4080_setup()
461 ret = regmap_read(st->regmap, AD4080_REG_CHIP_TYPE, &id); in ad4080_setup()
468 ret = regmap_set_bits(st->regmap, AD4080_REG_GPIO_CONFIG_A, in ad4080_setup()
473 ret = regmap_write(st->regmap, AD4080_REG_GPIO_CONFIG_B, in ad4080_setup()
479 ret = iio_backend_num_lanes_set(st->back, st->num_lanes); in ad4080_setup()
483 if (!st->lvds_cnv_en) in ad4080_setup()
486 /* Set maximum LVDS Data Transfer Latency */ in ad4080_setup()
487 ret = regmap_update_bits(st->regmap, in ad4080_setup()
495 if (st->num_lanes > 1) { in ad4080_setup()
496 ret = regmap_set_bits(st->regmap, AD4080_REG_ADC_DATA_INTF_CONFIG_A, in ad4080_setup()
502 ret = regmap_set_bits(st->regmap, in ad4080_setup()
513 struct device *dev = regmap_get_device(st->regmap); in ad4080_properties_parse()
515 st->lvds_cnv_en = device_property_read_bool(dev, "adi,lvds-cnv-enable"); in ad4080_properties_parse()
517 st->num_lanes = 1; in ad4080_properties_parse()
518 device_property_read_u32(dev, "adi,num-lanes", &st->num_lanes); in ad4080_properties_parse()
519 if (!st->num_lanes || st->num_lanes > 2) in ad4080_properties_parse()
520 return dev_err_probe(dev, -EINVAL, in ad4080_properties_parse()
521 "Invalid 'adi,num-lanes' value: %u", in ad4080_properties_parse()
522 st->num_lanes); in ad4080_properties_parse()
530 struct device *dev = &spi->dev; in ad4080_probe()
535 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad4080_probe()
537 return -ENOMEM; in ad4080_probe()
546 "failed to get and enable supplies\n"); in ad4080_probe()
548 st->regmap = devm_regmap_init_spi(spi, &ad4080_regmap_config); in ad4080_probe()
549 if (IS_ERR(st->regmap)) in ad4080_probe()
550 return PTR_ERR(st->regmap); in ad4080_probe()
552 st->info = spi_get_device_match_data(spi); in ad4080_probe()
553 if (!st->info) in ad4080_probe()
554 return -ENODEV; in ad4080_probe()
556 ret = devm_mutex_init(dev, &st->lock); in ad4080_probe()
560 indio_dev->name = st->info->name; in ad4080_probe()
561 indio_dev->channels = st->info->channels; in ad4080_probe()
562 indio_dev->num_channels = st->info->num_channels; in ad4080_probe()
563 indio_dev->info = &ad4080_iio_info; in ad4080_probe()
569 clk = devm_clk_get_enabled(&spi->dev, "cnv"); in ad4080_probe()
573 st->clk_rate = clk_get_rate(clk); in ad4080_probe()
575 st->back = devm_iio_backend_get(dev, NULL); in ad4080_probe()
576 if (IS_ERR(st->back)) in ad4080_probe()
577 return PTR_ERR(st->back); in ad4080_probe()
579 ret = devm_iio_backend_request_buffer(dev, st->back, indio_dev); in ad4080_probe()
583 ret = devm_iio_backend_enable(dev, st->back); in ad4080_probe()
591 return devm_iio_device_register(&spi->dev, indio_dev); in ad4080_probe()