Date:2012-10-09 13:13:33 (7 years 2 months ago)
Author:Maarten ter Huurne
Commit:974336c91932f1fb26fe8fdb84904744e19a334c
Message:MIPS: JZ4740: Use round robin DMA channel priority mode

Round robin is performed over two priority groups of 3 channels each,
so an argument was added to jz4740_dma_request() to select priority group.

TODO: Verify if the hardware actually has the channels grouped [0..2] and
[3..5] or whether it uses [0..3] and [4..5].
Files: arch/mips/include/asm/mach-jz4740/dma.h (1 diff)
arch/mips/jz4740/dma.c (3 diffs)
sound/soc/jz4740/jz4740-pcm.c (1 diff)

Change Details

arch/mips/include/asm/mach-jz4740/dma.h
6868
6969typedef void (*jz4740_dma_complete_callback_t)(struct jz4740_dma_chan *, int, void *);
7070
71struct jz4740_dma_chan *jz4740_dma_request(void *dev, const char *name);
71/*
72 * The 'prio' argument selects priority group: 0 (high) or 1 (low).
73 * There are 3 DMA channels available per group.
74 */
75struct jz4740_dma_chan *jz4740_dma_request(void *dev, const char *name, int prio);
7276void jz4740_dma_free(struct jz4740_dma_chan *dma);
7377
7478void jz4740_dma_configure(struct jz4740_dma_chan *dma,
arch/mips/jz4740/dma.c
6464#define JZ_DMA_CMD_TRANSFER_SIZE_OFFSET 8
6565#define JZ_DMA_CMD_MODE_OFFSET 7
6666
67#define JZ_DMA_CTRL_PRIORITY_MASK (0x3 << 8)
68#define JZ_DMA_CTRL_HALT BIT(3)
69#define JZ_DMA_CTRL_ADDRESS_ERROR BIT(2)
70#define JZ_DMA_CTRL_ENABLE BIT(0)
67#define JZ_DMA_CTRL_PRIORITY_012345 (0x0 << 8)
68#define JZ_DMA_CTRL_PRIORITY_023145 (0x1 << 8)
69#define JZ_DMA_CTRL_PRIORITY_201345 (0x2 << 8)
70#define JZ_DMA_CTRL_PRIORITY_ROUND_ROBIN (0x3 << 8)
71#define JZ_DMA_CTRL_PRIORITY_MASK (0x3 << 8)
72#define JZ_DMA_CTRL_HALT BIT(3)
73#define JZ_DMA_CTRL_ADDRESS_ERROR BIT(2)
74#define JZ_DMA_CTRL_ENABLE BIT(0)
7175
7276
7377static void __iomem *jz4740_dma_base;
...... 
116120    JZ4740_DMA_CHANNEL(5),
117121};
118122
119struct jz4740_dma_chan *jz4740_dma_request(void *dev, const char *name)
123struct jz4740_dma_chan *jz4740_dma_request(void *dev, const char *name,
124                       int prio)
120125{
121126    unsigned int i;
122127    struct jz4740_dma_chan *dma = NULL;
123128
129    if (prio < 0 || prio > 1)
130        return NULL;
131
124132    spin_lock(&jz4740_dma_lock);
125133
126    for (i = 0; i < ARRAY_SIZE(jz4740_dma_channels); ++i) {
134    for (i = prio * 3; i < prio * 3 + 3; ++i) {
127135        if (!jz4740_dma_channels[i].used) {
128136            dma = &jz4740_dma_channels[i];
129137            dma->used = 1;
...... 
295303
296304    clk_enable(clk);
297305
306    jz4740_dma_write_mask(JZ_REG_DMA_CTRL,
307                  JZ_DMA_CTRL_PRIORITY_ROUND_ROBIN,
308                  JZ_DMA_CTRL_PRIORITY_MASK);
309
298310    return 0;
299311
300312err_clkput:
sound/soc/jz4740/jz4740-pcm.c
109109
110110    if (!prtd->dma) {
111111        if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
112            prtd->dma = jz4740_dma_request(substream, "PCM Capture");
112            prtd->dma = jz4740_dma_request(substream,
113                               "PCM Capture", 0);
113114        else
114            prtd->dma = jz4740_dma_request(substream, "PCM Playback");
115            prtd->dma = jz4740_dma_request(substream,
116                               "PCM Playback", 0);
115117    }
116118
117119    if (!prtd->dma)

Archive Download the corresponding diff file



interactive