| 1 | /***************************************************************************//** |
| 2 | * @file cf_axi_dds.h |
| 3 | * @brief Header file of AD9122 Driver helper functions. |
| 4 | * @author DBogdan ([email protected]) |
| 5 | ******************************************************************************** |
| 6 | * Copyright 2012(c) Analog Devices, Inc. |
| 7 | * |
| 8 | * All rights reserved. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions are met: |
| 12 | * - Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * - Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in |
| 16 | * the documentation and/or other materials provided with the |
| 17 | * distribution. |
| 18 | * - Neither the name of Analog Devices, Inc. nor the names of its |
| 19 | * contributors may be used to endorse or promote products derived |
| 20 | * from this software without specific prior written permission. |
| 21 | * - The use of this software may or may not infringe the patent rights |
| 22 | * of one or more patent holders. This license does not release you |
| 23 | * from the requirement that you obtain separate licenses from these |
| 24 | * patent holders to use this software. |
| 25 | * - Use of the software either in source or binary form, must be run |
| 26 | * on or directly connected to an Analog Devices Inc. component. |
| 27 | * |
| 28 | * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR |
| 29 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
| 30 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 31 | * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 33 | * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 | * |
| 39 | ******************************************************************************** |
| 40 | * SVN Revision: $WCREV$ |
| 41 | *******************************************************************************/ |
| 42 | |
| 43 | #ifndef __ADI_AXI_DDS_H__ |
| 44 | #define __ADI_AXI_DDS_H__ |
| 45 | |
| 46 | /* This define controls the use of the DDS module by the AD9122 driver */ |
| 47 | #define CF_AXI_DDS |
| 48 | |
| 49 | #ifdef CUSTOM_DAC_PCORE |
| 50 | #undef CF_AXI_DDS |
| 51 | #endif |
| 52 | |
| 53 | /******************************************************************************/ |
| 54 | /************************ Data Types ******************************************/ |
| 55 | /******************************************************************************/ |
| 56 | enum |
| 57 | { |
| 58 | IIO_CHAN_INFO_SCALE = 1, |
| 59 | IIO_CHAN_INFO_FREQUENCY, |
| 60 | IIO_CHAN_INFO_PHASE, |
| 61 | IIO_CHAN_INFO_SAMP_FREQ |
| 62 | }; |
| 63 | |
| 64 | enum |
| 65 | { |
| 66 | CLK_DATA, |
| 67 | CLK_DAC, |
| 68 | CLK_REF, |
| 69 | CLK_NUM, |
| 70 | }; |
| 71 | |
| 72 | #ifdef CF_AXI_DDS |
| 73 | struct cf_axi_dds_state |
| 74 | { |
| 75 | uint32_t dac_clk; |
| 76 | }; |
| 77 | #endif //CF_AXI_DDS |
| 78 | |
| 79 | struct cf_axi_converter |
| 80 | { |
| 81 | int32_t* spi; |
| 82 | uint32_t clk[CLK_NUM]; |
| 83 | uint32_t id; |
| 84 | uint32_t interp_factor; |
| 85 | uint32_t fcenter_shift; |
| 86 | uint32_t intp_modes[5]; |
| 87 | uint32_t cs_modes[17]; |
| 88 | int32_t (*read)(uint8_t reg); |
| 89 | int32_t (*write)(uint8_t reg, uint8_t val); |
| 90 | int32_t (*setup)(struct cf_axi_converter *conv); |
| 91 | int32_t (*get_fifo_status)(struct cf_axi_converter *conv); |
| 92 | uint32_t (*get_data_clk)(struct cf_axi_converter *conv); |
| 93 | int32_t (*read_raw)(uint32_t channel, |
| 94 | int32_t *val, |
| 95 | int32_t *val2, |
| 96 | int32_t mask); |
| 97 | int32_t (*write_raw)(uint32_t channel, |
| 98 | int32_t val, |
| 99 | int32_t val2, |
| 100 | int32_t mask); |
| 101 | void (*pcore_set_sed_pattern)(unsigned chan, |
| 102 | unsigned pat1, |
| 103 | unsigned pat2); |
| 104 | void (*pcore_sync)(); |
| 105 | }; |
| 106 | |
| 107 | /******************************************************************************/ |
| 108 | /************************ Functions Declarations ******************************/ |
| 109 | /******************************************************************************/ |
| 110 | int32_t cf_axi_dds_of_probe(); |
| 111 | #ifdef CF_AXI_DDS |
| 112 | int32_t cf_axi_dds_write_raw(uint32_t channel, |
| 113 | uint32_t address, |
| 114 | int32_t val, |
| 115 | int32_t val2, |
| 116 | int32_t mask); |
| 117 | #endif //CF_AXI_DDS |
| 118 | |
| 119 | #endif //__ADI_AXI_DDS_H__ |