Debian Codegraph @

thirdparty/analogdevicesinc/no-OS_local/platform_bladerf2/adc_core.h

raw symbols SCIP
1 /***************************************************************************//**
2 * @file adc_core.h
3 * @brief Header file of ADC Core Driver.
4 * @author DBogdan ([email protected])
5 ********************************************************************************
6 * Copyright 2013(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 #ifndef ADC_CORE_API_H_
40 #define ADC_CORE_API_H_
41
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include "ad9361.h"
46
47 /******************************************************************************/
48 /********************** Macros and Constants Definitions **********************/
49 /******************************************************************************/
50 /* ADC COMMON */
51 #define ADC_REG_RSTN 0x0040
52 #define ADC_RSTN (1 << 0)
53 #define ADC_MMCM_RSTN (1 << 1)
54
55 #define ADC_REG_CNTRL 0x0044
56 #define ADC_R1_MODE (1 << 2)
57 #define ADC_DDR_EDGESEL (1 << 1)
58 #define ADC_PIN_MODE (1 << 0)
59
60 #define ADC_REG_STATUS 0x005C
61 #define ADC_MUX_PN_ERR (1 << 3)
62 #define ADC_MUX_PN_OOS (1 << 2)
63 #define ADC_MUX_OVER_RANGE (1 << 1)
64 #define ADC_STATUS (1 << 0)
65
66 #define ADC_REG_DMA_CNTRL 0x0080
67 #define ADC_DMA_STREAM (1 << 1)
68 #define ADC_DMA_START (1 << 0)
69
70 #define ADC_REG_DMA_COUNT 0x0084
71 #define ADC_DMA_COUNT(x) (((x) & 0xFFFFFFFF) << 0)
72 #define ADC_TO_DMA_COUNT(x) (((x) >> 0) & 0xFFFFFFFF)
73
74 #define ADC_REG_DMA_STATUS 0x0088
75 #define ADC_DMA_OVF (1 << 2)
76 #define ADC_DMA_UNF (1 << 1)
77 #define ADC_DMA_STATUS (1 << 0)
78
79 #define ADC_REG_DMA_BUSWIDTH 0x008C
80 #define ADC_DMA_BUSWIDTH(x) (((x) & 0xFFFFFFFF) << 0)
81 #define ADC_TO_DMA_BUSWIDTH(x) (((x) >> 0) & 0xFFFFFFFF)
82
83 /* ADC CHANNEL */
84 #define ADC_REG_CHAN_CNTRL(c) (0x0400 + (c) * 0x40)
85 #define ADC_LB_EN (1 << 11)
86 #define ADC_PN_SEL (1 << 10)
87 #define ADC_IQCOR_ENB (1 << 9)
88 #define ADC_DCFILT_ENB (1 << 8)
89 #define ADC_FORMAT_SIGNEXT (1 << 6)
90 #define ADC_FORMAT_TYPE (1 << 5)
91 #define ADC_FORMAT_ENABLE (1 << 4)
92 #define ADC_PN23_TYPE (1 << 1)
93 #define ADC_ENABLE (1 << 0)
94
95 #define ADC_REG_CHAN_STATUS(c) (0x0404 + (c) * 0x40)
96 #define ADC_PN_ERR (1 << 2)
97 #define ADC_PN_OOS (1 << 1)
98 #define ADC_OVER_RANGE (1 << 0)
99
100 #define ADC_REG_CHAN_CNTRL_1(c) (0x0410 + (c) * 0x40)
101 #define ADC_DCFILT_OFFSET(x) (((x) & 0xFFFF) << 16)
102 #define ADC_TO_DCFILT_OFFSET(x) (((x) >> 16) & 0xFFFF)
103 #define ADC_DCFILT_COEFF(x) (((x) & 0xFFFF) << 0)
104 #define ADC_TO_DCFILT_COEFF(x) (((x) >> 0) & 0xFFFF)
105
106 #define ADC_REG_CHAN_CNTRL_2(c) (0x0414 + (c) * 0x40)
107 #define ADC_IQCOR_COEFF_1(x) (((x) & 0xFFFF) << 16)
108 #define ADC_TO_IQCOR_COEFF_1(x) (((x) >> 16) & 0xFFFF)
109 #define ADC_IQCOR_COEFF_2(x) (((x) & 0xFFFF) << 0)
110 #define ADC_TO_IQCOR_COEFF_2(x) (((x) >> 0) & 0xFFFF)
111
112 #define ADC_REG_CHAN_CNTRL_3(c) (0x0418 + (c) * 0x40) /* v8.0 */
113 #define ADC_ADC_PN_SEL(x) (((x) & 0xF) << 16)
114 #define ADC_TO_ADC_PN_SEL(x) (((x) >> 16) & 0xF)
115 #define ADC_ADC_DATA_SEL(x) (((x) & 0xF) << 0)
116 #define ADC_TO_ADC_DATA_SEL(x) (((x) >> 0) & 0xF)
117
118 #define AXI_DMAC_REG_IRQ_MASK 0x80
119 #define AXI_DMAC_REG_IRQ_PENDING 0x84
120 #define AXI_DMAC_REG_IRQ_SOURCE 0x88
121
122 #define AXI_DMAC_REG_CTRL 0x400
123 #define AXI_DMAC_REG_TRANSFER_ID 0x404
124 #define AXI_DMAC_REG_START_TRANSFER 0x408
125 #define AXI_DMAC_REG_FLAGS 0x40c
126 #define AXI_DMAC_REG_DEST_ADDRESS 0x410
127 #define AXI_DMAC_REG_SRC_ADDRESS 0x414
128 #define AXI_DMAC_REG_X_LENGTH 0x418
129 #define AXI_DMAC_REG_Y_LENGTH 0x41c
130 #define AXI_DMAC_REG_DEST_STRIDE 0x420
131 #define AXI_DMAC_REG_SRC_STRIDE 0x424
132 #define AXI_DMAC_REG_TRANSFER_DONE 0x428
133 #define AXI_DMAC_REG_ACTIVE_TRANSFER_ID 0x42c
134 #define AXI_DMAC_REG_STATUS 0x430
135 #define AXI_DMAC_REG_CURRENT_DEST_ADDR 0x434
136 #define AXI_DMAC_REG_CURRENT_SRC_ADDR 0x438
137 #define AXI_DMAC_REG_DBG0 0x43c
138 #define AXI_DMAC_REG_DBG1 0x440
139
140 #define AXI_DMAC_CTRL_ENABLE (1 << 0)
141 #define AXI_DMAC_CTRL_PAUSE (1 << 1)
142
143 #define AXI_DMAC_IRQ_SOT (1 << 0)
144 #define AXI_DMAC_IRQ_EOT (1 << 1)
145
146 /******************************************************************************/
147 /************************ Functions Declarations ******************************/
148 /******************************************************************************/
149
150 int adc_init(struct ad9361_rf_phy *phy);
151 int adc_read(struct ad9361_rf_phy *phy, uint32_t regAddr, uint32_t *data);
152 int adc_write(struct ad9361_rf_phy *phy, uint32_t regAddr, uint32_t data);
153 int32_t adc_set_calib_scale(struct ad9361_rf_phy *phy,
154 uint32_t chan,
155 int32_t val,
156 int32_t val2);
157 int32_t adc_get_calib_scale(struct ad9361_rf_phy *phy,
158 uint32_t chan,
159 int32_t *val,
160 int32_t *val2);
161 int32_t adc_set_calib_phase(struct ad9361_rf_phy *phy,
162 uint32_t chan,
163 int32_t val,
164 int32_t val2);
165 int32_t adc_get_calib_phase(struct ad9361_rf_phy *phy,
166 uint32_t chan,
167 int32_t *val,
168 int32_t *val2);
169 #endif