adi-axi-adc.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Analog Devices Generic AXI ADC IP core driver/library
  4. * Link: https://wiki.analog.com/resources/fpga/docs/axi_adc_ip
  5. *
  6. * Copyright 2012-2020 Analog Devices Inc.
  7. */
  8. #ifndef __ADI_AXI_ADC_H__
  9. #define __ADI_AXI_ADC_H__
  10. struct device;
  11. struct iio_chan_spec;
  12. /**
  13. * struct adi_axi_adc_chip_info - Chip specific information
  14. * @name Chip name
  15. * @id Chip ID (usually product ID)
  16. * @channels Channel specifications of type @struct iio_chan_spec
  17. * @num_channels Number of @channels
  18. * @scale_table Supported scales by the chip; tuples of 2 ints
  19. * @num_scales Number of scales in the table
  20. * @max_rate Maximum sampling rate supported by the device
  21. */
  22. struct adi_axi_adc_chip_info {
  23. const char *name;
  24. unsigned int id;
  25. const struct iio_chan_spec *channels;
  26. unsigned int num_channels;
  27. const unsigned int (*scale_table)[2];
  28. int num_scales;
  29. unsigned long max_rate;
  30. };
  31. /**
  32. * struct adi_axi_adc_conv - data of the ADC attached to the AXI ADC
  33. * @chip_info chip info details for the client ADC
  34. * @preenable_setup op to run in the client before enabling the AXI ADC
  35. * @reg_access IIO debugfs_reg_access hook for the client ADC
  36. * @read_raw IIO read_raw hook for the client ADC
  37. * @write_raw IIO write_raw hook for the client ADC
  38. */
  39. struct adi_axi_adc_conv {
  40. const struct adi_axi_adc_chip_info *chip_info;
  41. int (*preenable_setup)(struct adi_axi_adc_conv *conv);
  42. int (*reg_access)(struct adi_axi_adc_conv *conv, unsigned int reg,
  43. unsigned int writeval, unsigned int *readval);
  44. int (*read_raw)(struct adi_axi_adc_conv *conv,
  45. struct iio_chan_spec const *chan,
  46. int *val, int *val2, long mask);
  47. int (*write_raw)(struct adi_axi_adc_conv *conv,
  48. struct iio_chan_spec const *chan,
  49. int val, int val2, long mask);
  50. };
  51. struct adi_axi_adc_conv *devm_adi_axi_adc_conv_register(struct device *dev,
  52. size_t sizeof_priv);
  53. void *adi_axi_adc_conv_priv(struct adi_axi_adc_conv *conv);
  54. #endif