You are looking at an old revision of the page DMA. This revision was created by Paul Boddie.
The direct memory access peripheral
DMA
The JZ4730 has a slightly different memory layout for DMA registers compared to the JZ4740 and related SoCs. However, the general base location for the DMA peripheral remains at 0x10020000.
(On the JZ4780, the peripheral is at 0x13420000 with global registers at 0x13421000.)
There are two kinds of registers: global and channel. The global registers appear in one location relative to the DMA base address and control the peripheral generally.
Register | Offset | Purpose |
---|---|---|
IRQP | 0xf8 | IRQ pending |
DMAC | 0xfc | Control |
Note that the order of these is reversed from the JZ4740 which also exposes more global registers.
Meanwhile, channel registers appear in as many locations as there are distinct channels, starting at 0x10020000. There are 6 channels in the JZ4730 peripheral.
Banks of channel registers occur at intervals of 0x20, with the registers being defined relative to the base of each bank as follows:
Register | Offset | Purpose |
---|---|---|
DSA | 0x00 | Source address |
DTA/DDA | 0x04 | Target address |
DTC | 0x08 | Transfer count |
DRT/DRS | 0x0c | Request type/source |
DCS/DCCSR | 0x10 | Channel command/status |
Other registers provided by the JZ4740 do not appear to be supported.
Global Registers
DMAC
Bit | Field | Purpose |
---|---|---|
8..9 | PR | Channel priorities |
3 | HTR | Halt error occurred |
2 | AER | Address error occurred |
0 | DME | Enable |
Channel priorities are indicated in the above field using the following values:
Value | Policy |
---|---|
0 | 01234567 |
1 | 02314675 |
2 | 20136457 |
3 | Round robin |
The above policies are taken from the legacy JZ4730 definitions. It is not clear whether there really are channels 6 and 7.
Round robin mode (according to JZ4740 documentation) employs two priority levels (channels 0 to 3, channels 4 to 7) with channels being serviced in turn within each level.
IRQP
Bit | Purpose |
---|---|
15..8 | IRQ pending for channels |
Following the hints in the JZ4740 definitions, it seems likely that bits 13..8 are used to indicate interrupt conditions for channels 5..0.
Channel Registers
DSA
This register holds the 32-bit source address involved in a transfer.
DDA
The descriptor address register is structured as follows:
Bits | Purpose |
---|---|
31..12 | Descriptor base address |
11..4 | Descriptor offset address |
3..0 | (Zero) |
In practice, a descriptor address is just a 32-bit address which must be aligned to a 16-byte boundary.
DRT/DRS
According to the legacy JZ4730 kernel definitions, request sources/types are associated with bits in the DRT register as follows:
Bit | Request Type/Source |
---|---|
0 | EXTREXTR |
4 | PCMCIAOUT |
5 | PCMCIAIN |
8 | AUTO |
10 | DESOUT |
11 | DESIN |
14 | UART3OUT |
15 | UART3IN |
16 | UART2OUT |
17 | UART2IN |
18 | UART1OUT |
19 | UART1IN |
20 | UART0OUT |
21 | UART0IN |
22 | SSIOUT |
23 | SSIIN |
24 | AICOUT |
25 | AICIN |
26 | MSCOUT |
27 | MSCIN |
28 | OST2 |
The JZ4740 provides request types 8 and 20-27, plus 28 being TCU, and additionally 29 being SADC and 30 being SLCD.
DCS/DCCSR
The channel command and status register incorporates command settings that appear to be on the dedicated command register (DCMD) in the JZ4740.
Bits | Field | Purpose |
---|---|---|
31 | EACKS | External DMA DACKn output polarity select |
30 | EACKM | External DMA DACKn output mode select |
29..28 | ERDM | External DMA request detection mode |
27 | EOPM | External DMA end of process mode |
26..24 | (Reserved) | |
23 | SAM | Source address increment (set to increment) |
22 | DAM | Destination address increment (set to increment) |
21..20 | (Reserved) | |
19..16 | RDIL | Request detection interval length |
15..14 | SP/SWDH | Source port width |
13..12 | DP/DWDH | Destination port width |
11 | (Reserved) | |
10..8 | DS | Transfer unit data size |
7 | TM | Transfer mode (unset: single; set: block) |
6..5 | (Reserved) | |
4 | AR | Address error occurred |
3 | TT/TC | Transfer completed |
2 | HLT | Transfer halted |
1 | TCIE | Channel IRQ enable |
0 | CHDE | Channel enable/enabled |
The output mode select (EACKM) field appears to be used for writes to peripherals.
The request detection mode (ERDM) field employs the following values:
Value | Mode |
---|---|
0 | Low level |
1 | Falling edge |
2 | High level |
3 | Rising edge |
Request detection interval length (RDIL) appears to dictate the frequency of transfer events by indicating how ofter, in terms of transfer units, a transfer request condition may be detected and acted upon.
Value | Interval |
---|---|
0 | 0 (ignored) |
1 | 2 |
2 | 4 |
3 | 8 |
4 | 12 |
5 | 16 |
6 | 20 |
7 | 24 |
8 | 28 |
9 | 32 |
10 | 48 |
11 | 60 |
12 | 64 |
13 | 124 |
14 | 128 |
15 | 200 |
Port widths (SWDH and DWDH) employ the following values:
Value | Width |
---|---|
0 | 4 bytes (32 bits) |
1 | 1 byte (8 bits) |
2 | 2 bytes (16 bits) |
3 | (Reserved) |
The transfer unit data size is specified using the following values:
Value | Size |
---|---|
0 | 4 bytes (32 bits) |
1 | 1 byte (8 bits) |
2 | 2 bytes (16 bits) |
3 | 16 bytes |
4 | 32 bytes |
Block mode dedicates the bus to a transfer whereas single mode (TM cleared) introduces the request detection interval length (RDIL) mechanism, allowing multiplexing of accesses to the bus.
Descriptors
Other JZ4700-series SoCs support transfer descriptors that follow the layout of the command register, with the lowest five bits being defined as follows:
Bits | Field | Purpose |
---|---|---|
4 | V | Descriptor valid |
3 | VM | Descriptor valid mode |
2 | VIE | Descriptor invalid interrupt enable |
1 | TIE | Transfer interrupt enable |
0 | LINK | Descriptor link enable |
However, the JZ4730 does not provide a separate command register, and it seems as if no provision exists for descriptor-driven transfers.
Interrupts
The DMA controller interrupt number applicable to the interrupt controller (INTC) registers is 21. However, there are also channel-level interrupts from 31 to 36.
Conditions and Operations
A transfer has ceased on a channel if DCS.AR/DCCSR.AR, DCS.TT/DCCSR.TC or DCS.HLT/DCCSR.HLT are set. The corresponding global indication involves the DMAC.AR and DMAC.HLT bits.
Enabling a channel involves clearing the above channel bits, setting the DCCSR.CHDE bit and then setting the DCCSR.TCIE bit.
Examples
The dma.c
and dma.h
files in the legacy kernel provide definitions for various DMA operations, particularly sound-related transfers.
Resources
In recent kernels, the DMA support has been located in the following file:
- drivers/dma/dma-jz4780.c
In the legacy vendor kernel:
- arch/mips/jz4730/dma.c
- linux/include/asm-mips/mach-jz4730/dma.h
- linux/include/asm-mips/mach-jz4730/ops.h
- linux/include/asm-mips/mach-jz4730/regs.h