25. CBDMA

25. CBDMA

25.1 Introduction

The CB_DMA provides CBUS (CPU Bus) MASTER storage space for use as DATA RAM, and also provides DMA function. DATA RAM can be used without any settings, and reading and writing is very efficient. Both d DATA RAM and CACHE are two forms of on-chip memory. The goal is to improve system performance (read-write speed is faster than DRAM), but the implementation is completely different. The cache is fully automatic. Software colleagues can be used as no such hardware. For data ram, software needs to specify the location to access.
Data ram In addition to the temporary storage data in operation, another function is to let the system have some place to store the data before the system has been initialized. In addition, this hardware also provides DMA function, which is quite flexible. Let software In the future, there is an opportunity to use hardware acceleration in critical places to perform memset, read/write/move the flexibility of large amounts of data.
SP7021 CB_DMA support internal SRAM that size is 128Kbytes. CB_DMA is accessed by DMA_CTRL (master) and also access to DRAM (slave). CB_DMA also support security function.
The control registers locate at RGST table Group 26 which memory map in 0x9C000D00~0x9C000D7F.

25.2 Function Diagram

The function diagram of CBDMA is shown in Figure 25-1.


Figure 25-1 CBDMA Functional Blocks

  • REG_IO: Judging by the AXI command coming in from the slave end, when read / write is interleaved, there is a corresponding arbitration mechanism to determine which read / write command is first served.

  • Exclusive access: The CB_DMA slave side supports AXI Exclusive access, but only supports it at most once.

  • Write response: The write command is received by the slave side, and the feedback will be sent when the wdata is received.

  • CB_DMA_REG: HE_RGST BUS slave, used to control the internal settings of register.

  • CBUS interface: Receive the command sent by the BUS master and convert it to the interface of CBSRAM_CTRL to access CBSRAM.

  • CBSRAM_CTRL: As Internal SRAM, the CBDMA slave / master may be accessed at the same time, so it needs to be arbiration. The priority of the slave is defined to be greater than the master.

  • DMA_CTRL: As the master, parse the DMA settings issued by CB_DMA_REG and convert them to AXI command to send them out.

 

25.3 System Operation Mode

CMD_QUE_DEPTH, MEMSET_VALUE, DMA_MODE, DMA_LENGTH, DMA_SRC_ADR and DMA_DES_ADR cannot be changed during DMA_GO == 1. If it is violated, H/W can self-protect, and the software will not be written in until DMA_GO = 0, which can be determined by a bit. Owner. The Semaphore mechanism may be safer and better.
CMD_QUE_DEPTH, MEMSET_VALUE, DMA_MODE, DMA_LENGTH, DMA_SRC_ADR, DMA_DES_ADR and DMA_GO parameters are defined in registers map segments.

25.3.1 MEMSET Mode

  • Set below registers:

    • dma_mode: Set dma_mode to MEMSET mode

    • memset: Value is the value you want to fill in main memory.

    • Length: The number of bytes to memset this time.

    • Dest Addr: The number of bytes to memset this time.

    • Src addr[1:0]: The offset of memset data.

  • After DMA Go, the result will be the memset value filled to Dest Addr, totally filled "length" byte.

  • Write data flow :

Please refer figure 25-2 Step8 ~ step9.

25.3.2 DMA Write Mode

  • Set below registers:

    • dma_mode: Set dma_mode to DMA Write mode.

    • Length: The number of bytes to be transferred from CBSRAM Write to SDRAM this time.

    • Dest Addr: Write out data into DRAM address.

    • Src Addr: From which address of CBSRAM, read data and write to DRAM.

  • After DMA Go, CB_DMA will move data from the CBSRAM of Src_Addr to the SDRAM starting with Dest_Addr, with a total of "length" bytes. DMA_DONE_FLAG will be set after Write ends. If the interrupt of DMA_DONE is not masked, there will be an interrupt of DMA_DONE.

  • Write data flow :

Please refer figure 25-2 Step1 ~ step5.


Figure 25-2 Write Data Flow

25.3.3 DMA Read Mode

  • Set below registers:

    • dma_mode: Set dma_mode to DMA Read mode.

    • Length: The number of bytes to be returned from DRAM read this time.

    • Dest Addr: Read back data into the address of CBSRAM.

    • Src Addr: Read data from which address of DRAM.

  • After DMA Go, CB_DMA will move data from the SDRAM of Src_Addr to the CBSRAM starting with Dest_Addr, for a total of "length" bytes. After the Read ends, DMA_DONE_FLAG will be set to 1. If the interrupt of DMA_DONE is not masked, there will be an interrupt of DMA_DONE.

  • Read data flow :

Please refer figure 25-3 Step1 ~ step5.


Figure 25-3 Read Data Flow

25.3.4 DMA Copy Mode

  • Set below registers:

    • dma_mode: Set dma_mode to DMA Copy mode.

    • Length: The number of bytes to copy.

    • Dest Addr: Copy the data into the address of the DRAM.

    • Src Addr: Read the data from the address of the DRAM and write it to Dest DRAM.

  • After DMA Go, CB_DMA will move data from the DRAM of Src_Addr to the DRAM starting with Dest_Addr, for a total of "length" bytes. After the copy ends, DMA_DONE_FLAG will be set to 1. If the interrupt of DMA_DONE is not masked, there will be an interrupt of DMA_DONE.

  • The last 256 bytes inside CB_DMA will be treated as buffer and the contents will be destroyed.

  • Copy data flow :

Please refer figure 25-4 Step1 ~ step9.


Figure 25-4 Copy Data Flow

 

25.3.5 SG(Scatter-gather) DMA Mode

The SG DMA mode is like auto repeat mode of MEMSET or DMA write or DMA read or DMA copy. Through this function, user can read several area data and write to a gather area. User also can read data in a continue area and write to several discontinue area. The max operation times is 32. The control registers are G26.10~15. Below shows the registers setting flow for continue DMA copy:

  • Set below registers:

    • LLI_ACCESS_INDEX: Determine which LLI(Link List Item) mapping to following registers.

    • LAST_LLI_IN_TASK: If this flag setup, it indicate the last LLI.

    • dma_mode: Set dma_mode to DMA Copy mode.

    • Length: The number of bytes to copy.

    • Dest Addr: Copy the data into the address of the DRAM.

    • Src Addr: Read the data from the address of the DRAM and write it to Dest DRAM.

    • Repeat above action.

  • After SG DMA Go, CB_DMA will move data from the DRAM of Src_Addr to the DRAM starting with Dest_Addr according index. After the copy ends, DMA_DONE_FLAG will be set to 1. If the interrupt of DMA_DONE is not masked, there will be an interrupt of DMA_DONE.

Figure 25-5 shows an example of SG DMA with DMA copy mode

Figure 25-5 SG DMA with DMA copy mode

25.4 CBDMA Interrupts

The CBDMA interrupt events are connected to the same interrupt vector, please refer to Group 26.5 register. These events generate an interrupt if the corresponding "Enable Control Bit" is set, please refer to Group 26.6 register.






25.5 Registers Map

25.5.1 Registers Memory Map

Address

Group No.

Register Name

Register Description

0x9C000D00

G26.0

CBDMA_HW_VERSION

HW Version Register

0x9C000D04

G26.1

CBDMA_CONFIG

Configure CBDMA mode Register

0x9C000D08

G26.2

CBDMA_LENGTH

Set CBDMA Transfer Length Register

0x9C000D0C

G26.3

CBDMA_SRC_ADDR

CBDMA Source Address Register

0x9C000D10

G26.4

CBDMA_DES_ADDR

CBDMA Destination Address Register

0x9C000D14

G26.5

CBDMA_INT_FLAG

CBDMA Interrupt Flag

0x9C000D18

G26.6

CBDMA_INT_ENABLE

CBDMA Interrupt Enable

0x9C000D1C

G26.7

CBDMA_MEMSET_VALUE

MEMSET Value Register

0x9C000D20

G26.8

CBDMA_SDRAM_SIZE_CFG

SDRAM A/B size Configuration

0x9C000D24

G26.9

CBDMA_ILLEGLE_RECORD

CBDMA Illegal Access Record

0x9C000D28

G26.10

SG_CBDMA_INDEX

SG_CBDMA_INDEX Setting

0x9C000D2C

G26.11

SG_CBDMA_CONFIG

SG_CBDMA_CONFIG Setting

0x9C000D30

G26.12

SG_CBDMA_LENGTH

SG_CBDMA_LENGTH Setting

0x9C000D34

G26.13

SG_CBDMA_SRC_ADDR

SG_CBDMA_SRC_ADDR Setting

0x9C000D38

G26.14

SG_CBDMA_DES_ADDR

SG_CBDMA_DES_ADDR Setting

0x9C000D3C

G26.15

SG_CBDMA_MEMSET_VALUE

SG_CBDMA_MEMSET_VALUE Setting

0x9C000D40

G26.16

SG_CBDMA_SETTING

SG_SETTING for SG_DMA_ENABLE and SG_DMA_GO

0x9C000D44

G26.17

SG_LOOP_MODE_SETTING

SG_LOOP_SRAM_START Setting

0x9C000D48

G26.18

SG_LOOP_SRAM_START

SG_LOOP_SRAM_SIZE Setting

0x9C000D4C

G26.19

SG_LOOP_SRAM_SIZE

SG_LOOP_SRAM_SIZE Setting

0x9C000D50

G26.20

CBDMA_CHECK_MODE

CBDMA_CHECK_MODE Setting

0x9C000D54

G26.21

CBDMA_CHECK_SUM_RESULT

CBDMA_CHECK_SUM_RESULT

0x9C000D58

G26.22

CBDMA_CHECK_XOR_RESULT

CBDMA_CHECK_XOR_RESULT

 

 

25.5.2 Registers Description

 

RGST Table Group 26 CB DMA: CBUS DMA Controller

26.0 DMA HW VER (dma hw ver)
Address: 0x9C000D00
Reset: 0x1751300


Field Name

Bit

Access

Description

DMA HW VER

31:0

RO

Hardware Version
A constant, usually stands for h/w delivery date, such as
32'h20150803



26.1 DMA CONFIG (dma config)
Address: 0x9C000D04
Reset: 0x80030000


Field Name

Bit

Access

Description

DMA TOUCH PROT SRAM

31

RW

DMA TOUCH PROT SRAM
0 : if normal access touch the prot sram, the HW will fix the ADDR and LEN
make this access in normal range. 1 : if normal access touch the prot sram, DMA has no any modify, only trig-
ger DMA DONE and Interrupt.

Reserved

30:18

RO

RESERVED

CMD QUE DEPTH

17:16

RW

Set MEMSET Send CMD Queue Depth
0x0: depth = 1;
0x1: depth = 2;
0x2: depth = 4;
0x3: depth = 8 (default);

Reserved

15:9

RO

RESERVED

DMA GO

8

RU

DMA GO Signal
Write 1 to trigger DMA hardware, self clear to zero when current operation has been finished.

Reserved

7:2

RO

RESERVED

DMA MODE

1:0

RW

Set DMA Mode

0x0: MEMSET (memset value to main memory) (default)

0x1: DMA WRITE (write data from internal SRAM to main memory)

0x2: DMA READ (read data from main memory to internal SRAM)

0x3: DMA COPY (read data from main memory then write to other space of main memory)



26.2 DMA LENGTH (dma length)
Address: 0x9C000D08
Reset: 0x00000000


Field Name

Bit

Access

Description

Reserved

31:25

RO

RESERVED

DMA LENGTH

24:0

RW

Set DMA Length

DMA read and write function support length from 1bytes to 64Kbytes.

Valid when DMA GO is set to 1, and can not be changed when DMA GO assert.



26.3 DMA SRC ADR (dma src adr)
Address: 0x9C000D0C
Reset: 0x00000000 

 

Field Name

Bit

Access

Description

Reserved

31

RO

RESERVED

DMA SRC ADR

30:0

RW

DMA Source Address
MEMSET: indicate the byte offset of memset value, only [1:0] valid.
DMA WRITE: indicate SRAM address,range
0x0000 0000 ∼ 0x0001 ffff,
DMA READ: indicate DRAM address, MBUS0's range 0x0000 0000 ∼ 0x0fff ffff,
DMA COPY: indicate DRAM address, MBUS0's range 0x0000 0000 ∼ 0x0fff ffff,
Valid when DMA GO is set to 1, and can not be changed when DMA GO assert.



26.4 DMA DES ADR (dma des adr)
Address: 0x9C000D10
Reset: 0x00000000


Field Name

Bit

Access

Description

Reserved