BDMA API¶
REVISION HISTORY¶
| Revision No. | Description |
Date |
|---|---|---|
| 1.0 | 11/18/2024 | |
| 1.1 | 11/25/2025 |
1. Overview¶
Byte-aligned data transfer DMA engine (byte-aligned data transfer direct memory access controller), referred to as BDMA, is mainly used for high-speed data transmission between peripherals and memory, and between memory and memory, and does not require CPU participation.
This article mainly introduces the operation of BDMA for data transmission under Rtos and Linux systems.
2. Hardware functions¶
-
Memory data transfer (mem copy)
-
Memory data filling (mem pattern fill)
-
Memory data search (mem pattern search)
-
Memory data crc calculation (mem crc)
-
The clock is the same frequency as the MIU clock
The number of BDMA supported by different chips is as follows
| **chipname** | **mspi number** |
| ------------- | --------------- |
| iford | 3 |
| souffle | 3 |
| ifado | 2 |
| pcupid | 3 |
| ibopper | 2 |
| ifackel | 2 |
3. Hardware connection diagram¶
4. Rtos usage reference¶
4.1. Rtos Config configuration¶
Rtos uses BDMA, which requires configuration:
CONFIG_BDMA_SUPPORT=y
Enter the rtos/proj directory,make menuconfig select config as follows:
BSP Driver Options --->
[*] Support BDMA driver
4.2. Rtos SYS configuration¶
4.2.1. bdma node configuration¶
<bdma0>
[camclk_u16] CAMCLK_VOID;
[interrupts_u8] INT_IRQ_BDMA;
[regs_u32] 0x1F200400;
| Attribute | Description | Remark |
|---|---|---|
| camclk_u16 | Used to specify the clock source of BDMA | No need to modify |
| interrupts_u8 | Used to specify the interrupt number of BDMA | No need to modify |
| regs_u32 | Used to specify the address of the BDMA register bank | No need to modify |
5. Linux usage reference¶
5.1. Linux Config configuration¶
Linux uses BDMA, which requires configuration:
CONFIG_SSTAR_BDMA=y
Enter the kernel directory,make menuconfig select config as follows:
Device Drivers --->
[*] Sstar SoC platform drivers --->
[*] Sstar BDMA
5.2. dtsi node description¶
bdma0 {
compatible = "sstar,bdma0";
interrupts = <GIC_SPI INT_IRQ_BDMA IRQ_TYPE_LEVEL_HIGH>;
reg = <0x1F200400 0x80>;
clocks = <&xtal>;
status = "ok";
};
The properties supported for configuration in the master driver are as follows:
| Property | Description | Remark |
|---|---|---|
| compatible | Used to match the driver for driver registration, must be consistent with the code | Modification prohibited |
| reg | Used to specify the address of the BDMA register bank | No modification required |
| interrupts | Used to specify the hardware interrupt number and properties used | No modification required |
| clocks | Used to specify the clock source used | No modification required |
| status | Used to select whether to enable the BDMA driver | Can be modified as needed |
6. API reference¶
The API in drv_bdma.h is used the same in Rtos and Linux.
Linux path: drivers/sstar_common/include/drv_bdma.h
Rtos path: proj/sc/driver/sysdriver_common/include/drv_bdma.h
| API name | Function |
|---|---|
| drv_bdma_initialize | Initialize the channel corresponding to BDMA |
| drv_bdma_uninitialize | Uninitialize BDMA channel |
| drv_bdma_transfer | BDMA function operation |
6.1. drv_bdma_initialize¶
-
Function
Initialize BDMA channel
-
Syntax
bdma_err drv_bdma_initialize(u8 channel); -
Parameters
Parameter name Description Input/Output channel Channel selection Input -
Return value
-
0: Success.
-
Non-0: Failure.
-
-
Dependencies
- Header file: drv_bdma.h
6.2. drv_bdma_uninitialize¶
-
Function
Uninitialize BDMA channel
-
Syntax
bdma_err drv_bdma_uninitialize(u8 channel); -
Parameters
Parameter name Description Input/Output channel Channel selection Input -
Return value
-
0: Success.
-
Non-0: Failure.
-
-
Dependencies
- Header file: drv_bdma.h
6.3. drv_bdma_transfer¶
-
Function
Run BDMA function.
-
Syntax
bdma_err drv_bdma_transfer(u8 channel, bdma_param *param); -
Parameters
Parameter name Description Input/Output channel Channel selection Input param Transmission configuration parameters Input -
Return value
-
0: Success.
-
Non-0: Failure.
-
-
Dependencies
- Header file: drv_bdma.h
-
Notes
- The corresponding channel must be initialized first.
7. Data structure description¶
The relevant data structure is defined as follows.
| Data type | Definition |
|---|---|
| bdma_param | Function-related configuration |
| bdma_line_offset | Line offset configuration |
| bdma_crc | CRC32 configuration |
| bdma_search | Memory data search configuration |
7.1. bdma_param¶
-
Description
Data structure related to function configuration.
-
Definition
typedef struct { u8 bIntMode; u8 bEnLineOfst; bdma_src_select eSrcSel; bdma_dst_select eDstSel; bdma_data_width eSrcDataWidth; bdma_data_width eDstDataWidth; bdma_addr_mode eDstAddrMode; ss_miu_addr_t pSrcAddr; ss_miu_addr_t pDstAddr; u32 u32TxCount; u32 u32Pattern; bdma_line_offset *pstLineOfst; bdma_crc * pstCrcst; bdma_search * pstSearchst; bdma_callback pfTxCbFunc; void * pTxCbParm; } bdma_param; -
Members
Member Name Description bIntMode Interrupt enable bEnLineOfst Configure transmission Width enable eSrcSel Source device selection eDstSel Target device selection eSrcDataWidth Source device transfer width setting eDstDataWidth Target device transfer width setting eDstAddrMode Target device data entry mode pSrcAddr Source device address pDstAddr Target device address u32TxCount Data transfer size u32Pattern Memory data search for specified data pstLineOfst Line offset function configuration pstCrcst CRC calculation function configuration bdma_search Memory search Function configuration bdma_callback Interrupt callback function pTxCbParm Interrupt callback pointer, private pointer
7.2. bdma_line_offset¶
-
Description
Line offset function configuration.
-
Definition
typedef struct { u32 u32SrcWidth; u32 u32SrcOffset; u32 u32DstWidth; u32 u32DstOffset; } bdma_line_offset; -
Members
member name description u32SrcWidth Source device width u32SrcOffset Source device valid data width u32DstWidth Destination device width u32DstOffset Target device valid data width
7.3. bdma_crc¶
-
Description
The configuration of the crc function.
-
Definition
typedef struct { u8 reflection; u32 polynomial; u32 seedvalue; } bdma_crc; -
Members
member name description reflection Byte reversal configuration polynomial Calculate polynomial seedvalue Initial value, calculated as crc value
7.4. bdma_search¶
-
Description
the memory data search settings.
-
Definition
typedef struct { u8 antimatch; u8 mobf; u32 patternmask; u32 mobfkey; u32 patternaddr; } bdma_search; -
Members
member name description antimatch reverse match enable mobf MOBF mode enable patternmask Search target position mobfkey MOBF mode target value patternaddr Returned search target address
8. Test case description¶
-
Linux reference: drivers/sstar_common/bdma/ut/lnx/bdma_ut.c
-
Rtos reference: proj/sc/driver/sysdriver_common/bdma/ut/lnx/bdma_ut.c
9. FAQ¶
9.1 No data at the target address after memory data is moved¶
- Use the CamOsMemFlush() interface to flush the source and target addresses before and after data movement.