Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Analog Devices Generic AXI ADC IP core driver/library
0004  * Link: https://wiki.analog.com/resources/fpga/docs/axi_adc_ip
0005  *
0006  * Copyright 2012-2020 Analog Devices Inc.
0007  */
0008 #ifndef __ADI_AXI_ADC_H__
0009 #define __ADI_AXI_ADC_H__
0010 
0011 struct device;
0012 struct iio_chan_spec;
0013 
0014 /**
0015  * struct adi_axi_adc_chip_info - Chip specific information
0016  * @name        Chip name
0017  * @id          Chip ID (usually product ID)
0018  * @channels        Channel specifications of type @struct iio_chan_spec
0019  * @num_channels    Number of @channels
0020  * @scale_table     Supported scales by the chip; tuples of 2 ints
0021  * @num_scales      Number of scales in the table
0022  * @max_rate        Maximum sampling rate supported by the device
0023  */
0024 struct adi_axi_adc_chip_info {
0025     const char          *name;
0026     unsigned int            id;
0027 
0028     const struct iio_chan_spec  *channels;
0029     unsigned int            num_channels;
0030 
0031     const unsigned int      (*scale_table)[2];
0032     int             num_scales;
0033 
0034     unsigned long           max_rate;
0035 };
0036 
0037 /**
0038  * struct adi_axi_adc_conv - data of the ADC attached to the AXI ADC
0039  * @chip_info       chip info details for the client ADC
0040  * @preenable_setup op to run in the client before enabling the AXI ADC
0041  * @reg_access      IIO debugfs_reg_access hook for the client ADC
0042  * @read_raw        IIO read_raw hook for the client ADC
0043  * @write_raw       IIO write_raw hook for the client ADC
0044  */
0045 struct adi_axi_adc_conv {
0046     const struct adi_axi_adc_chip_info      *chip_info;
0047 
0048     int (*preenable_setup)(struct adi_axi_adc_conv *conv);
0049     int (*reg_access)(struct adi_axi_adc_conv *conv, unsigned int reg,
0050               unsigned int writeval, unsigned int *readval);
0051     int (*read_raw)(struct adi_axi_adc_conv *conv,
0052             struct iio_chan_spec const *chan,
0053             int *val, int *val2, long mask);
0054     int (*write_raw)(struct adi_axi_adc_conv *conv,
0055              struct iio_chan_spec const *chan,
0056              int val, int val2, long mask);
0057 };
0058 
0059 struct adi_axi_adc_conv *devm_adi_axi_adc_conv_register(struct device *dev,
0060                             size_t sizeof_priv);
0061 
0062 void *adi_axi_adc_conv_priv(struct adi_axi_adc_conv *conv);
0063 
0064 #endif