Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
mhal_adc.h
1 /*
2  * (C) 2005-2020 MediaTek Inc. All rights reserved.
3  *
4  * Copyright Statement:
5  *
6  * This MT3620 driver software/firmware and related documentation
7  * ("MediaTek Software") are protected under relevant copyright laws.
8  * The information contained herein is confidential and proprietary to
9  * MediaTek Inc. ("MediaTek"). You may only use, reproduce, modify, or
10  * distribute (as applicable) MediaTek Software if you have agreed to and been
11  * bound by this Statement and the applicable license agreement with MediaTek
12  * ("License Agreement") and been granted explicit permission to do so within
13  * the License Agreement ("Permitted User"). If you are not a Permitted User,
14  * please cease any access or use of MediaTek Software immediately.
15  *
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
18  * PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS
19  * ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
21  * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
22  * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
23  * INCORPORATED IN, OR SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO
24  * LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
25  * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
26  * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
27  * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
28  * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
29  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
30  * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED
31  * HEREUNDER WILL BE ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
32  * RECEIVER TO MEDIATEK DURING THE PRECEDING TWELVE (12) MONTHS FOR SUCH
33  * MEDIATEK SOFTWARE AT ISSUE.
34  */
35 
36 
37 #ifndef __MHAL_ADC_H__
38 #define __MHAL_ADC_H__
39 
40 #include "mhal_osai.h"
41 
104 #define ADC_EPTR 1
105 
106 #define ADC_EPARAMETER 2
107 
108 #define ADC_ENOMEM 3
109 
110 #define ADC_EFAULT 4
111 
112 #define ADC_EAGAIN 5
113 
119 /***************************************************************************
120  * enums
121  **************************************************************************/
132 typedef enum {
137 } adc_pmode;
138 
140 typedef enum {
155 } adc_avg_mode;
156 
158 typedef enum {
163 } adc_fifo_mode;
164 
166 typedef enum {
174 
176 typedef enum {
177  ADC_BIT0 = 0x0001,
179  ADC_BIT1 = 0x0002,
181  ADC_BIT2 = 0x0004,
183  ADC_BIT3 = 0x0008,
185  ADC_BIT4 = 0x0010,
187  ADC_BIT5 = 0x0020,
189  ADC_BIT6 = 0x0040,
191  ADC_BIT7 = 0x0080,
194 
196 typedef enum {
215 } adc_channel;
216 
232 typedef void (*adc_dma_callback_func) (void *user_data);
233 
317 };
318 
324  void __iomem *base;
326  void __iomem *cg_base;
332  dma_addr_t rx_addr;
335 };
336 
353 #ifdef __cplusplus
354 extern "C" {
355 #endif
356 
367 int mtk_mhal_adc_init(struct mtk_adc_controller *ctlr);
368 
379 int mtk_mhal_adc_deinit(struct mtk_adc_controller *ctlr);
394  struct adc_fsm_param *adc_fsm_parameter);
395 
407 int mtk_mhal_adc_start(struct mtk_adc_controller *ctlr);
408 
419 int mtk_mhal_adc_stop(struct mtk_adc_controller *ctlr);
420 
433 
452 
453 #ifdef __cplusplus
454 }
455 #endif
456 
470 #endif /* __MHAL_ADC_H__ */
471 
ADC channel3 bit map.
Definition: mhal_adc.h:183
adc_fifo_mode fifo_mode
ADC operation mode: FIFO or DMA mode, one shot mode use ADC_FIFO_DIRECT, periodic mode use ADC_FIFO_D...
Definition: mhal_adc.h:283
This structure defines ADC related parameters, such as ADC mode, sample times, channel map...
Definition: mhal_adc.h:249
ADC channel7 bit map.
Definition: mhal_adc.h:191
ADC channel1 bit map.
Definition: mhal_adc.h:179
ADC state machine samples 32 times.
Definition: mhal_adc.h:151
int mtk_mhal_adc_enable_clk(struct mtk_adc_controller *ctlr)
This function is used to enable ADC clock.
ADC channel0 bit map.
Definition: mhal_adc.h:177
void __iomem * base
ADC controller base address.
Definition: mhal_adc.h:324
u8 dma_channel
ADC DMA channel number.
Definition: mhal_adc.h:334
ADC state machine samples 1 time.
Definition: mhal_adc.h:141
ADC rxfull and timeout interrupt enable.
Definition: mhal_adc.h:167
ADC state machine samples 16 times.
Definition: mhal_adc.h:149
ADC periodic mode.
Definition: mhal_adc.h:135
int mtk_mhal_adc_deinit(struct mtk_adc_controller *ctlr)
This function is used to de-initialize an ADC hardware controller.
int mtk_mhal_adc_init(struct mtk_adc_controller *ctlr)
This function is used to initialize an ADC hardware controller.
adc_channel_bit_map
This enum defines ADC channel bit map.
Definition: mhal_adc.h:176
ADC state machine samples 4 times.
Definition: mhal_adc.h:145
adc_fifo_mode
This enum defines ADC operation mode: FIFO or DMA mode.
Definition: mhal_adc.h:158
adc_pmode pmode
ADC mode, one shot or periodic mode.
Definition: mhal_adc.h:250
int mtk_mhal_adc_fsm_param_set(struct mtk_adc_controller *ctlr, struct adc_fsm_param *adc_fsm_parameter)
This function is used to configure ADC controller parameters.
void(* adc_dma_callback_func)(void *user_data)
This defines the callback function prototype.
Definition: mhal_adc.h:232
ADC state machine samples 64 times.
Definition: mhal_adc.h:153
u32 sample_rate
Sample rate used in periodic mode, for example, the sampling rate can be set as 10K, ch_num * sample_rate <= 90K.
Definition: mhal_adc.h:254
ADC channel 2.
Definition: mhal_adc.h:201
ADC channel 3.
Definition: mhal_adc.h:203
ADC channel 5.
Definition: mhal_adc.h:207
adc_channel
This enum defines ADC channel number.
Definition: mhal_adc.h:196
ADC rxfull interrupt enable.
Definition: mhal_adc.h:169
u32 vfifo_len
ADC Virtual FIFO length.
Definition: mhal_adc.h:297
adc_avg_mode
This enum defines ADC finite state machine sampling times.
Definition: mhal_adc.h:140
ADC state machine samples 2 times.
Definition: mhal_adc.h:143
ADC FIFO sample.
Definition: mhal_adc.h:159
ADC state machine samples 8 times.
Definition: mhal_adc.h:147
ADC channel4 bit map.
Definition: mhal_adc.h:185
ADC channel 0.
Definition: mhal_adc.h:197
int mtk_mhal_adc_disable_clk(struct mtk_adc_controller *ctlr)
This function is used to disable ADC clock.
Interface to ADC, used to store the hardware register base address, clock, Rx done callback API...
Definition: mhal_adc.h:322
ADC DMA sample.
Definition: mhal_adc.h:161
ADC channel2 bit map.
Definition: mhal_adc.h:181
ADC channel 7.
Definition: mhal_adc.h:211
adc_fifo_ier_mode ier_mode
ADC interrupt mode, config ADC_FIFO_IER_RXFULL irq enable.
Definition: mhal_adc.h:311
ADC channel6 bit map.
Definition: mhal_adc.h:189
ADC channel5 bit map.
Definition: mhal_adc.h:187
u16 adc_processing
ADC hardware is sampling data.
Definition: mhal_adc.h:330
u16 channel_map
ADC bit map, REG_CH_MAP[7:0]=8'0000_0011, enable CH0 & CH1.
Definition: mhal_adc.h:252
struct adc_fsm_param * adc_fsm_parameter
ADC fsm related parameters.
Definition: mhal_adc.h:328
ADC one shot mode.
Definition: mhal_adc.h:133
ADC channel 4.
Definition: mhal_adc.h:205
adc_dma_callback_func rx_callback_func
RX DMA callback function.
Definition: mhal_adc.h:313
ADC timeout interrupt enable.
Definition: mhal_adc.h:171
adc_fifo_ier_mode
This enum defines ADC interrupt enable.
Definition: mhal_adc.h:166
ADC channel 1.
Definition: mhal_adc.h:199
void __iomem * cg_base
Clock gate base address.
Definition: mhal_adc.h:326
ADC max channel(invalid)
Definition: mhal_adc.h:213
dma_addr_t rx_addr
Rx DMA physical address.
Definition: mhal_adc.h:332
void * rx_callback_data
RX DMA callback data.
Definition: mhal_adc.h:315
ADC channel 6.
Definition: mhal_adc.h:209
int mtk_mhal_adc_stop(struct mtk_adc_controller *ctlr)
This function is used to stop ADC controller.
int mtk_mhal_adc_fifo_handle_rx(struct mtk_adc_controller *ctlr)
This function is used to read FIFO data from HW.
int mtk_mhal_adc_start(struct mtk_adc_controller *ctlr)
This function is used to start the predefined channels by ADC parameter configre API...
u32 rx_period_len
ADC rx period length.
Definition: mhal_adc.h:304
u32 * vfifo_addr
ADC Virtual FIFO address for periodic or one shot mode, record the data storage the SRAM address pass...
Definition: mhal_adc.h:287
adc_pmode
This enum defines ADC one shot or periodic mode.
Definition: mhal_adc.h:132