Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Function

This section provides DMA M-HAL APIs(defined as Common Interface) to fully control the MediaTek DMA HW. More...

Overview

This section provides DMA M-HAL APIs(defined as Common Interface) to fully control the MediaTek DMA HW.

Functions

int mtk_mhal_dma_config (struct dma_controller *controller)
 This function is used to configure one DMA channel. More...
 
int mtk_mhal_dma_start (struct dma_controller *controller)
 This function is used to start one DMA channel. More...
 
int mtk_mhal_dma_stop (struct dma_controller *controller)
 This function is used to stop one DMA channel. More...
 
int mtk_mhal_dma_pause (struct dma_controller *controller)
 This function is used to pause one DMA channel. More...
 
int mtk_mhal_dma_resume (struct dma_controller *controller)
 This function is used to resume one DMA channel. More...
 
int mtk_mhal_dma_get_status (struct dma_controller *controller)
 This function is used to get DMA channel status. More...
 
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. More...
 
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. More...
 
int mtk_mhal_dma_clear_irq_status (struct dma_controller *controller)
 This function is used to clear DMA HW status. More...
 
int mtk_mhal_dma_dump_reg (struct dma_controller *controller)
 This function is used to dump DMA register for debug. More...
 
int mtk_mhal_dma_clock_enable (struct dma_controller *controller)
 This function is used to enable DMA channel clock. More...
 
int mtk_mhal_dma_clock_disable (struct dma_controller *controller)
 This function is used to disable DMA channel clock. More...
 
int mtk_mhal_dma_reset (struct dma_controller *controller)
 This function is used to reset DMA channel. More...
 
int mtk_mhal_dma_update_swptr (struct dma_controller *controller, u32 length_byte)
 This function is used to update VFF DMA channel swptr. More...
 
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. More...
 
int mtk_mhal_dma_clr_dreq (struct dma_controller *controller)
 This function is used to clear dreq signal of DMA channel. More...
 

Function Documentation

int mtk_mhal_dma_config ( struct dma_controller controller)

This function is used to configure one DMA channel.

Usage: OS-HAL driver should call it before starting DMA. According to the DMA channel type,
users should set right dma_ctrl and dma_config value in dma_controller. Stop the DMA channel first
before calling this function.

Parameters
[in]controller: The pointer of struct dma_controller.
Returns
Return 0 if users configure DMA channel successfully.
Return -DMA_EPARAM if users input error parameters.
Return -DMA_EBUSY if DMA channel is running.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_start ( struct dma_controller controller)

This function is used to start one DMA channel.

Usage: OS-HAL driver should call it after configuring DMA successfully.

Parameters
[in]controller: The pointer of struct dma_controller.
Returns
Return 0 if users start DMA channel successfully.
Return -DMA_EBUSY if DMA channel is running.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_stop ( struct dma_controller controller)

This function is used to stop one DMA channel.

Usage: OS-HAL driver should call it after starting DMA. Calling this function will stop transfer immediately and DMA channel will return idle status.

Parameters
[in]controller: The pointer of struct dma_controller.
Returns
Return 0 if users stop DMA channel successfully.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_pause ( struct dma_controller controller)

This function is used to pause one DMA channel.

Usage: OS-HAL driver should call it after starting DMA. After calling this function, DMA channel will complete last count data transfer and then be into pause status.

Parameters
[in]controller: The pointer of struct dma_controller.
Returns
Return 0 if users pause DMA channel successfully.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_resume ( struct dma_controller controller)

This function is used to resume one DMA channel.

Usage: OS-HAL driver should call it after pausing DMA. Users call this function to cancel pause status for DMA channel.

Parameters
[in]controller: The pointer of struct dma_controller.
Returns
Return 0 if users resume DMA channel successfully.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_get_status ( struct dma_controller controller)

This function is used to get DMA channel status.

Usage: If OS-HAL driver call MHAL API without DMA callback, it can call this API to get DMA channel status so as to check DMA channel working status.

Parameters
[in]controller: The pointer of struct dma_controller.
Returns
Return the DMA channel status if get status successfully.
Return -DMA_EPTR if controller is NULL.
Bit 0 specifies interrupt status, Bit 1 specifies running status and Bit 2 specifies pause status. Bit 0 is 1 when interrupt is pending and is 0 when
no interrupt is generated. Bit 1 is 0 when DMA channel has been stopped or has completed transfer already and is 1 when DMA channel is running.
Refer to dma_status.
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.

Usage: Users should call this function carefully if DMA channel is running.

Parameters
[in]controller: The pointer of struct dma_controller.
[in]param: The parameter type whose value to be set.
[in]value: The new parameter value.
Returns
Return 0 if users set DMA channel parameter successfully.
Return -DMA_EPARAM if users input error parameter type or value.
Return -DMA_EPTR if controller is NULL.
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.

Usage: Users should call this function carefully if DMA channel is running.

Parameters
[in]controller: The pointer of struct dma_controller.
[in]param: The parameter type whose value to be got.
Returns
Return the parameter value if users get DMA parameters successfully.
Return -DMA_EPARAM if users input error parameter type.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_clear_irq_status ( struct dma_controller controller)

This function is used to clear DMA HW status.

Usage: It's called in IRQ function to clear DMA HW IRQ status.

Parameters
[in]controller: DMA controller used with the device.
Returns
Return 0 if users resume DMA channel successfully.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_dump_reg ( struct dma_controller controller)

This function is used to dump DMA register for debug.

Usage:Used for OS-HAL to dump DMA register.

Parameters
[in]controller: DMA controller used with the device.
Returns
Return 0 if users resume DMA channel successfully.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_clock_enable ( struct dma_controller controller)

This function is used to enable DMA channel clock.

Usage:Used for OS-HAL to enable DMA channel clock before config.

Parameters
[in]controller: DMA controller used with the device.
Returns
Return 0 if users enable DMA channel clock successfully.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_clock_disable ( struct dma_controller controller)

This function is used to disable DMA channel clock.

Usage:Used for OS-HAL to disable DMA channel clock.

Parameters
[in]controller: DMA controller used with the device.
Returns
Return 0 if users disable DMA channel clock successfully.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_reset ( struct dma_controller controller)

This function is used to reset DMA channel.

Usage:Used for OS-HAL to reset DMA channel.

Parameters
[in]controller: DMA controller used with the device.
Returns
Return 0 if users reset DMA channel successfully.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_update_swptr ( struct dma_controller controller,
u32  length_byte 
)

This function is used to update VFF DMA channel swptr.

Usage: Used for OS-HAL to update VFF DMA channel swptr. If user read data from vfifo or write data into vfifo, user should update swptr to control read pointer or write pointer of fifo control engine.

Parameters
[in]controller: DMA controller used with the device.
[in]length_byte: The updated byte count. It cannot be larger than vfifo size.
Returns
Return 0 if users update VFF DMA channel swptr successfully.
Return -DMA_EPTR if controller is NULL.
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.

Usage:Used for OS-HAL to read data from FIFO of VFF DMA channel. This api will also update swptr after reading data.

Parameters
[in]controller: DMA controller used with the device.
[out]buffer: buffer for saving read data.
[in]length: byte number which users want to read. It cannot be larger than vfifo size.
Returns
Return the actual read data byte count if successfully.
Return -DMA_EPTR if controller is NULL.
int mtk_mhal_dma_clr_dreq ( struct dma_controller controller)

This function is used to clear dreq signal of DMA channel.

Usage:Used for OS-HAL to clear dreq signal of DMA channel.

Parameters
[in]controller: DMA controller used with the device.
Returns
Return 0 if users clear dreq signal of DMA channel successfully.
Return -DMA_EPTR if controller is NULL.