summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/dma-dm320.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tms320dm320/dma-dm320.c')
-rw-r--r--firmware/target/arm/tms320dm320/dma-dm320.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/firmware/target/arm/tms320dm320/dma-dm320.c b/firmware/target/arm/tms320dm320/dma-dm320.c
new file mode 100644
index 0000000000..e60102b6fb
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/dma-dm320.c
@@ -0,0 +1,78 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
10 * Copyright (C) 2011 by Tomasz Moń
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "kernel.h"
24#include "thread.h"
25#include "system.h"
26#include "dma-target.h"
27#include "dm320.h"
28#include <stdbool.h>
29
30void dma_init(void)
31{
32 /* TODO */
33}
34
35/*
36 Requests channel for peripheral.
37 Returns channel assigned for caller which must be released after
38 transfer complete using dma_release_channel().
39*/
40int dma_request_channel(int peripheral, int mode)
41{
42 /* TODO: proper checking if channel is already taken
43 currently only SDMMC and DSP uses DMA on this target */
44 int channel = -1;
45
46 if (peripheral == DMA_PERIPHERAL_MMCSD)
47 {
48 /* Set first DMA channel */
49 IO_SDRAM_SDDMASEL = (IO_SDRAM_SDDMASEL & 0xFFE0) | peripheral |
50 (mode << 3);
51 channel = 1;
52 }
53 else if (peripheral == DMA_PERIPHERAL_DSP)
54 {
55 /* Set second DMA channel */
56 IO_SDRAM_SDDMASEL = (IO_SDRAM_SDDMASEL & 0xFC1F) |
57 (peripheral << 5) |
58 (mode << 8);
59 channel = 2;
60 }
61 else if (peripheral == DMA_PERIPHERAL_SIF)
62 {
63 IO_SDRAM_SDDMASEL = (IO_SDRAM_SDDMASEL & 0x83FF) |
64 (peripheral << 10) |
65 (mode << 13);
66 channel = 3;
67 }
68
69 return channel;
70}
71
72void dma_release_channel(int channel)
73{
74 (void)channel;
75 /* TODO */
76}
77
78