Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
mhal_dma.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 #ifndef __MHAL_DMA_H__
37 #define __MHAL_DMA_H__
38 
39 #include "mhal_osai.h"
40 
155 #define DMA_EPTR 1
156 
157 #define DMA_EPARAM 2
158 
159 #define DMA_EBUSY 3
160 
178 enum dma_dir {
183 };
184 
191 enum dma_type {
198 };
199 
204 enum dma_param {
226 };
227 
238  DMA_STATUS_PAUSE = 1U << 2,
239 };
240 
251 };
252 
269 };
270 
294 typedef void (*dma_isr_callback)(void *user_data);
295 
311 struct dma_ctrl {
315  enum dma_dir dir;
330  u8 int_en;
346  u8 dreq;
359 };
360 
366 struct dma_config {
370  u32 addr_1;
374  u32 addr_2;
392  u32 count;
420 };
421 
427  void __iomem *base;;
429  u8 chn;
433  struct dma_ctrl *ctrls;
435  struct dma_config *cfg;
436 };
437 
448 #ifdef __cplusplus
449 extern "C" {
450 #endif
451 
466 int mtk_mhal_dma_config(struct dma_controller *controller);
467 
479 int mtk_mhal_dma_start(struct dma_controller *controller);
480 
492 int mtk_mhal_dma_stop(struct dma_controller *controller);
493 
505 int mtk_mhal_dma_pause(struct dma_controller *controller);
506 
517 int mtk_mhal_dma_resume(struct dma_controller *controller);
518 
535 int mtk_mhal_dma_get_status(struct dma_controller *controller);
536 
551 int mtk_mhal_dma_set_param(struct dma_controller *controller,
552  enum dma_param param, u32 value);
553 
567 int mtk_mhal_dma_get_param(struct dma_controller *controller,
568  enum dma_param param);
569 
579 int mtk_mhal_dma_clear_irq_status(struct dma_controller *controller);
580 
590 int mtk_mhal_dma_dump_reg(struct dma_controller *controller);
591 
601 int mtk_mhal_dma_clock_enable(struct dma_controller *controller);
602 
612 int mtk_mhal_dma_clock_disable(struct dma_controller *controller);
613 
623 int mtk_mhal_dma_reset(struct dma_controller *controller);
624 
639 int mtk_mhal_dma_update_swptr(struct dma_controller *controller,
640  u32 length_byte);
641 
655 int mtk_mhal_dma_vff_read_data(struct dma_controller *controller,
656  u8 *buffer, u32 length);
657 
667 int mtk_mhal_dma_clr_dreq(struct dma_controller *controller);
668 
669 #ifdef __cplusplus
670 }
671 #endif
672 
682 #endif
enum dma_type chn_type
DMA channel type.
Definition: mhal_dma.h:431
dma_isr_callback isr_callback_1
For FULL-SIZE DMA and HALF-SIZE DMA, isr_callback_1 is completion isr callback.
Definition: mhal_dma.h:411
void * isr_cb_data_1
isr_callback_1 data
Definition: mhal_dma.h:417
Select DMA burst type as 16-beat.
Definition: mhal_dma.h:268
enum dma_dir dir
Transfer direction, only for HALF-SIZE DMA and VFF DMA.
Definition: mhal_dma.h:315
u32 wrap_point
Wrap point from start address.
Definition: mhal_dma.h:379
The interrupt of DMA channel is pending and waitting for service.
Definition: mhal_dma.h:234
int mtk_mhal_dma_resume(struct dma_controller *controller)
This function is used to resume one DMA channel.
u8 dreq
Throttle and handshake control for DMA Transfer between DMA and Peripheral.
Definition: mhal_dma.h:346
dma_isr_callback isr_callback_2
For HALF-SIZE DMA, isr_callback_2 is half completion isr callback.
Definition: mhal_dma.h:415
struct dma_config * cfg
DMA config.
Definition: mhal_dma.h:435
u8 timeout_int_en
Enable FIFO data timeout interrupt for VFF DMA.
Definition: mhal_dma.h:332
u8 wrap_en
Flag of transfer address-wrapping feature.
Definition: mhal_dma.h:320
u32 alert_len
Specifies the Alert Length of Virtual FIFO DMA.
Definition: mhal_dma.h:400
remaining length of current transfer, only for FULL-SIZE DMA and HALF-SIZE DMA.
Definition: mhal_dma.h:208
int mtk_mhal_dma_get_param(struct dma_controller *controller, enum dma_param param)
This function is used to get DMA parameter which is defined in the dma_param.
u32 timeout_cnt
Interrupt will assert if there is no new data into FIFO more than n T(Bus Clock)
Definition: mhal_dma.h:406
u8 dst_inc_en
Destination addresses automatically increase after every transfer, only for FULL-SIZE DMA and HALF-SI...
Definition: mhal_dma.h:350
int mtk_mhal_dma_update_swptr(struct dma_controller *controller, u32 length_byte)
This function is used to update VFF DMA channel swptr.
Data count of FIFO, only for VFF DMA.
Definition: mhal_dma.h:221
u8 bw_transfer_en
Word to byte or byte to word transfer flag, only for HALF-SIZE DMA.
Definition: mhal_dma.h:342
Interface to DMA, used to pass arguments between OS_HAL and M-HAL.
Definition: mhal_dma.h:425
int mtk_mhal_dma_reset(struct dma_controller *controller)
This function is used to reset DMA channel.
fix_addr specifies the address for peripheral; must be 4-Byte alignment; only for HALF-SIZE DMA and V...
Definition: mhal_dma.h:213
u8 src_inc_en
Source addresses automatically increase after every transfer, only for FULL-SIZE DMA and HALF-SIZE DM...
Definition: mhal_dma.h:354
u8 chn
DMA channel.
Definition: mhal_dma.h:428
dma_burst_type
DMA dma_burst_type definition.
Definition: mhal_dma.h:260
HALF-SIZE DMA.
Definition: mhal_dma.h:195
FIFO size, only for VFF DMA.
Definition: mhal_dma.h:219
u8 half_int_en
Enable half transfer completion interrupt for HALF-SIZE DMA.
Definition: mhal_dma.h:334
u32 wrap_to_addr
The address which DMA will wrap to.
Definition: mhal_dma.h:385
u32 fifo_size
Virtual fifo size, only for VFF DMA.
Definition: mhal_dma.h:402
int mtk_mhal_dma_config(struct dma_controller *controller)
This function is used to configure one DMA channel.
Hardware pointer, only for VFF DMA.
Definition: mhal_dma.h:223
dma_transize
DMA dma_transize definition.
Definition: mhal_dma.h:244
int mtk_mhal_dma_clr_dreq(struct dma_controller *controller)
This function is used to clear dreq signal of DMA channel.
void * isr_cb_data_2
isr_callback_2 data
Definition: mhal_dma.h:419
int mtk_mhal_dma_dump_reg(struct dma_controller *controller)
This function is used to dump DMA register for debug.
The DMA channel is paused.
Definition: mhal_dma.h:238
Select DMA burst type as 4-beat.
Definition: mhal_dma.h:264
dma_param
DMA parameter-type definition.
Definition: mhal_dma.h:204
Select DMA burst type as 8-beat.
Definition: mhal_dma.h:266
int mtk_mhal_dma_clock_disable(struct dma_controller *controller)
This function is used to disable DMA channel clock.
Select DMA transaction size as Long (4-byte)
Definition: mhal_dma.h:250
enum dma_transize transize
Data size within the confine of a bus cycle per transfer.
Definition: mhal_dma.h:358
Select DMA transaction size as Short (2-byte)
Definition: mhal_dma.h:248
int mtk_mhal_dma_start(struct dma_controller *controller)
This function is used to start one DMA channel.
u8 bw_limiter
Bandwidth limiter.
Definition: mhal_dma.h:394
int mtk_mhal_dma_set_param(struct dma_controller *controller, enum dma_param param, u32 value)
This function is used to set DMA parameter which is defined in the dma_param.
u8 alert_cmp_type
Specifies the Compare Equation Between ALTLEN and FIFO_SIZE - FIFO_CNT.
Definition: mhal_dma.h:398
Virtual FIFO DMA.
Definition: mhal_dma.h:197
int mtk_mhal_dma_clear_irq_status(struct dma_controller *controller)
This function is used to clear DMA HW status.
u32 count
For FULL-SIZE DMA and HALF-SIZE DMA, it specifies transfer byte count.
Definition: mhal_dma.h:392
dma_type
DMA channel type definition.
Definition: mhal_dma.h:191
int mtk_mhal_dma_stop(struct dma_controller *controller)
This function is used to stop one DMA channel.
u8 reload_en
Reload transfer count flag, only for HALF-SIZE DMA.
Definition: mhal_dma.h:387
u32 addr_1
For FULL-SIZE DMA, addr_1 is src_addr.
Definition: mhal_dma.h:370
The DMA channel is currently running.
Definition: mhal_dma.h:236
dma_config specifies the DMA channel parameters for data transfer, such as transfer source...
Definition: mhal_dma.h:366
Software pointer, only for VFF DMA.
Definition: mhal_dma.h:225
int mtk_mhal_dma_pause(struct dma_controller *controller)
This function is used to pause one DMA channel.
move data from memory to peripheral
Definition: mhal_dma.h:180
dma_status
DMA dma_status definition.
Definition: mhal_dma.h:232
u32 addr_2
For FULL-SIZE DMA, addr_2 is dst_addr.
Definition: mhal_dma.h:374
int mtk_mhal_dma_vff_read_data(struct dma_controller *controller, u8 *buffer, u32 length)
This function is used to read data from FIFO of VFF DMA channel.
FULL-SIZE DMA.
Definition: mhal_dma.h:193
dma_dir
DMA data transfer direction definition.
Definition: mhal_dma.h:178
move data from peripheral to memory
Definition: mhal_dma.h:182
int mtk_mhal_dma_get_status(struct dma_controller *controller)
This function is used to get DMA channel status.
int mtk_mhal_dma_clock_enable(struct dma_controller *controller)
This function is used to enable DMA channel clock.
Select DMA transaction size as Byte (1-byte)
Definition: mhal_dma.h:246
enum dma_burst_type burst_type
Burst-type, only for FULL-SIZE DMA and HALF-SIZE DMA.
Definition: mhal_dma.h:338
void(* dma_isr_callback)(void *user_data)
This defines the function prototype of DMA interrupt service routines callback.
Definition: mhal_dma.h:294
void __iomem * base
DMA base address.
Definition: mhal_dma.h:427
prog_addr specifies the memory space address; only for HALF-SIZE DMA and VFF DMA. ...
Definition: mhal_dma.h:217
u8 int_en
Enable transfer completion interrupt for FULL-SIZE DMA and HALF-SIZE DMA, or enable FIFO data interru...
Definition: mhal_dma.h:330
Select DMA burst type as single-beat.
Definition: mhal_dma.h:262
u8 wrap_side
The side for using address-wrapping: source or destination, and only one side can activate address-wr...
Definition: mhal_dma.h:325
struct dma_ctrl * ctrls
DMA control setting.
Definition: mhal_dma.h:433
dma_ctrl specifies the DMA channel settings which control the DMA channel transfer mode...
Definition: mhal_dma.h:311