diff options
Diffstat (limited to 'arch/arm/plat-s3c24xx/dma.c')
-rw-r--r-- | arch/arm/plat-s3c24xx/dma.c | 151 |
1 files changed, 56 insertions, 95 deletions
diff --git a/arch/arm/plat-s3c24xx/dma.c b/arch/arm/plat-s3c24xx/dma.c index 07326f632361..196b19123653 100644 --- a/arch/arm/plat-s3c24xx/dma.c +++ b/arch/arm/plat-s3c24xx/dma.c | |||
@@ -31,10 +31,10 @@ | |||
31 | #include <asm/irq.h> | 31 | #include <asm/irq.h> |
32 | #include <mach/hardware.h> | 32 | #include <mach/hardware.h> |
33 | #include <mach/dma.h> | 33 | #include <mach/dma.h> |
34 | |||
35 | #include <mach/map.h> | 34 | #include <mach/map.h> |
36 | 35 | ||
37 | #include <plat/dma.h> | 36 | #include <plat/dma-plat.h> |
37 | #include <plat/regs-dma.h> | ||
38 | 38 | ||
39 | /* io map for dma */ | 39 | /* io map for dma */ |
40 | static void __iomem *dma_base; | 40 | static void __iomem *dma_base; |
@@ -44,8 +44,6 @@ static int dma_channels; | |||
44 | 44 | ||
45 | static struct s3c24xx_dma_selection dma_sel; | 45 | static struct s3c24xx_dma_selection dma_sel; |
46 | 46 | ||
47 | /* dma channel state information */ | ||
48 | struct s3c2410_dma_chan s3c2410_chans[S3C2410_DMA_CHANNELS]; | ||
49 | 47 | ||
50 | /* debugging functions */ | 48 | /* debugging functions */ |
51 | 49 | ||
@@ -135,21 +133,6 @@ dmadbg_showregs(const char *fname, int line, struct s3c2410_dma_chan *chan) | |||
135 | #define dbg_showchan(chan) do { } while(0) | 133 | #define dbg_showchan(chan) do { } while(0) |
136 | #endif /* CONFIG_S3C2410_DMA_DEBUG */ | 134 | #endif /* CONFIG_S3C2410_DMA_DEBUG */ |
137 | 135 | ||
138 | static struct s3c2410_dma_chan *dma_chan_map[DMACH_MAX]; | ||
139 | |||
140 | /* lookup_dma_channel | ||
141 | * | ||
142 | * change the dma channel number given into a real dma channel id | ||
143 | */ | ||
144 | |||
145 | static struct s3c2410_dma_chan *lookup_dma_channel(unsigned int channel) | ||
146 | { | ||
147 | if (channel & DMACH_LOW_LEVEL) | ||
148 | return &s3c2410_chans[channel & ~DMACH_LOW_LEVEL]; | ||
149 | else | ||
150 | return dma_chan_map[channel]; | ||
151 | } | ||
152 | |||
153 | /* s3c2410_dma_stats_timeout | 136 | /* s3c2410_dma_stats_timeout |
154 | * | 137 | * |
155 | * Update DMA stats from timeout info | 138 | * Update DMA stats from timeout info |
@@ -214,8 +197,6 @@ s3c2410_dma_waitforload(struct s3c2410_dma_chan *chan, int line) | |||
214 | return 0; | 197 | return 0; |
215 | } | 198 | } |
216 | 199 | ||
217 | |||
218 | |||
219 | /* s3c2410_dma_loadbuffer | 200 | /* s3c2410_dma_loadbuffer |
220 | * | 201 | * |
221 | * load a buffer, and update the channel state | 202 | * load a buffer, and update the channel state |
@@ -453,7 +434,7 @@ s3c2410_dma_canload(struct s3c2410_dma_chan *chan) | |||
453 | int s3c2410_dma_enqueue(unsigned int channel, void *id, | 434 | int s3c2410_dma_enqueue(unsigned int channel, void *id, |
454 | dma_addr_t data, int size) | 435 | dma_addr_t data, int size) |
455 | { | 436 | { |
456 | struct s3c2410_dma_chan *chan = lookup_dma_channel(channel); | 437 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); |
457 | struct s3c2410_dma_buf *buf; | 438 | struct s3c2410_dma_buf *buf; |
458 | unsigned long flags; | 439 | unsigned long flags; |
459 | 440 | ||
@@ -804,7 +785,7 @@ EXPORT_SYMBOL(s3c2410_dma_request); | |||
804 | 785 | ||
805 | int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *client) | 786 | int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *client) |
806 | { | 787 | { |
807 | struct s3c2410_dma_chan *chan = lookup_dma_channel(channel); | 788 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); |
808 | unsigned long flags; | 789 | unsigned long flags; |
809 | 790 | ||
810 | if (chan == NULL) | 791 | if (chan == NULL) |
@@ -836,7 +817,7 @@ int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *client) | |||
836 | chan->irq_claimed = 0; | 817 | chan->irq_claimed = 0; |
837 | 818 | ||
838 | if (!(channel & DMACH_LOW_LEVEL)) | 819 | if (!(channel & DMACH_LOW_LEVEL)) |
839 | dma_chan_map[channel] = NULL; | 820 | s3c_dma_chan_map[channel] = NULL; |
840 | 821 | ||
841 | local_irq_restore(flags); | 822 | local_irq_restore(flags); |
842 | 823 | ||
@@ -995,7 +976,7 @@ static int s3c2410_dma_started(struct s3c2410_dma_chan *chan) | |||
995 | int | 976 | int |
996 | s3c2410_dma_ctrl(unsigned int channel, enum s3c2410_chan_op op) | 977 | s3c2410_dma_ctrl(unsigned int channel, enum s3c2410_chan_op op) |
997 | { | 978 | { |
998 | struct s3c2410_dma_chan *chan = lookup_dma_channel(channel); | 979 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); |
999 | 980 | ||
1000 | if (chan == NULL) | 981 | if (chan == NULL) |
1001 | return -EINVAL; | 982 | return -EINVAL; |
@@ -1038,14 +1019,13 @@ EXPORT_SYMBOL(s3c2410_dma_ctrl); | |||
1038 | /* s3c2410_dma_config | 1019 | /* s3c2410_dma_config |
1039 | * | 1020 | * |
1040 | * xfersize: size of unit in bytes (1,2,4) | 1021 | * xfersize: size of unit in bytes (1,2,4) |
1041 | * dcon: base value of the DCONx register | ||
1042 | */ | 1022 | */ |
1043 | 1023 | ||
1044 | int s3c2410_dma_config(unsigned int channel, | 1024 | int s3c2410_dma_config(unsigned int channel, |
1045 | int xferunit, | 1025 | int xferunit) |
1046 | int dcon) | ||
1047 | { | 1026 | { |
1048 | struct s3c2410_dma_chan *chan = lookup_dma_channel(channel); | 1027 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); |
1028 | unsigned int dcon; | ||
1049 | 1029 | ||
1050 | pr_debug("%s: chan=%d, xfer_unit=%d, dcon=%08x\n", | 1030 | pr_debug("%s: chan=%d, xfer_unit=%d, dcon=%08x\n", |
1051 | __func__, channel, xferunit, dcon); | 1031 | __func__, channel, xferunit, dcon); |
@@ -1055,10 +1035,33 @@ int s3c2410_dma_config(unsigned int channel, | |||
1055 | 1035 | ||
1056 | pr_debug("%s: Initial dcon is %08x\n", __func__, dcon); | 1036 | pr_debug("%s: Initial dcon is %08x\n", __func__, dcon); |
1057 | 1037 | ||
1058 | dcon |= chan->dcon & dma_sel.dcon_mask; | 1038 | dcon = chan->dcon & dma_sel.dcon_mask; |
1059 | 1039 | ||
1060 | pr_debug("%s: New dcon is %08x\n", __func__, dcon); | 1040 | pr_debug("%s: New dcon is %08x\n", __func__, dcon); |
1061 | 1041 | ||
1042 | switch (chan->req_ch) { | ||
1043 | case DMACH_I2S_IN: | ||
1044 | case DMACH_I2S_OUT: | ||
1045 | case DMACH_PCM_IN: | ||
1046 | case DMACH_PCM_OUT: | ||
1047 | case DMACH_MIC_IN: | ||
1048 | default: | ||
1049 | dcon |= S3C2410_DCON_HANDSHAKE; | ||
1050 | dcon |= S3C2410_DCON_SYNC_PCLK; | ||
1051 | break; | ||
1052 | |||
1053 | case DMACH_SDI: | ||
1054 | /* note, ensure if need HANDSHAKE or not */ | ||
1055 | dcon |= S3C2410_DCON_SYNC_PCLK; | ||
1056 | break; | ||
1057 | |||
1058 | case DMACH_XD0: | ||
1059 | case DMACH_XD1: | ||
1060 | dcon |= S3C2410_DCON_HANDSHAKE; | ||
1061 | dcon |= S3C2410_DCON_SYNC_HCLK; | ||
1062 | break; | ||
1063 | } | ||
1064 | |||
1062 | switch (xferunit) { | 1065 | switch (xferunit) { |
1063 | case 1: | 1066 | case 1: |
1064 | dcon |= S3C2410_DCON_BYTE; | 1067 | dcon |= S3C2410_DCON_BYTE; |
@@ -1090,58 +1093,6 @@ int s3c2410_dma_config(unsigned int channel, | |||
1090 | 1093 | ||
1091 | EXPORT_SYMBOL(s3c2410_dma_config); | 1094 | EXPORT_SYMBOL(s3c2410_dma_config); |
1092 | 1095 | ||
1093 | int s3c2410_dma_setflags(unsigned int channel, unsigned int flags) | ||
1094 | { | ||
1095 | struct s3c2410_dma_chan *chan = lookup_dma_channel(channel); | ||
1096 | |||
1097 | if (chan == NULL) | ||
1098 | return -EINVAL; | ||
1099 | |||
1100 | pr_debug("%s: chan=%p, flags=%08x\n", __func__, chan, flags); | ||
1101 | |||
1102 | chan->flags = flags; | ||
1103 | |||
1104 | return 0; | ||
1105 | } | ||
1106 | |||
1107 | EXPORT_SYMBOL(s3c2410_dma_setflags); | ||
1108 | |||
1109 | |||
1110 | /* do we need to protect the settings of the fields from | ||
1111 | * irq? | ||
1112 | */ | ||
1113 | |||
1114 | int s3c2410_dma_set_opfn(unsigned int channel, s3c2410_dma_opfn_t rtn) | ||
1115 | { | ||
1116 | struct s3c2410_dma_chan *chan = lookup_dma_channel(channel); | ||
1117 | |||
1118 | if (chan == NULL) | ||
1119 | return -EINVAL; | ||
1120 | |||
1121 | pr_debug("%s: chan=%p, op rtn=%p\n", __func__, chan, rtn); | ||
1122 | |||
1123 | chan->op_fn = rtn; | ||
1124 | |||
1125 | return 0; | ||
1126 | } | ||
1127 | |||
1128 | EXPORT_SYMBOL(s3c2410_dma_set_opfn); | ||
1129 | |||
1130 | int s3c2410_dma_set_buffdone_fn(unsigned int channel, s3c2410_dma_cbfn_t rtn) | ||
1131 | { | ||
1132 | struct s3c2410_dma_chan *chan = lookup_dma_channel(channel); | ||
1133 | |||
1134 | if (chan == NULL) | ||
1135 | return -EINVAL; | ||
1136 | |||
1137 | pr_debug("%s: chan=%p, callback rtn=%p\n", __func__, chan, rtn); | ||
1138 | |||
1139 | chan->callback_fn = rtn; | ||
1140 | |||
1141 | return 0; | ||
1142 | } | ||
1143 | |||
1144 | EXPORT_SYMBOL(s3c2410_dma_set_buffdone_fn); | ||
1145 | 1096 | ||
1146 | /* s3c2410_dma_devconfig | 1097 | /* s3c2410_dma_devconfig |
1147 | * | 1098 | * |
@@ -1150,29 +1101,38 @@ EXPORT_SYMBOL(s3c2410_dma_set_buffdone_fn); | |||
1150 | * source: S3C2410_DMASRC_HW: source is hardware | 1101 | * source: S3C2410_DMASRC_HW: source is hardware |
1151 | * S3C2410_DMASRC_MEM: source is memory | 1102 | * S3C2410_DMASRC_MEM: source is memory |
1152 | * | 1103 | * |
1153 | * hwcfg: the value for xxxSTCn register, | ||
1154 | * bit 0: 0=increment pointer, 1=leave pointer | ||
1155 | * bit 1: 0=source is AHB, 1=source is APB | ||
1156 | * | ||
1157 | * devaddr: physical address of the source | 1104 | * devaddr: physical address of the source |
1158 | */ | 1105 | */ |
1159 | 1106 | ||
1160 | int s3c2410_dma_devconfig(int channel, | 1107 | int s3c2410_dma_devconfig(int channel, |
1161 | enum s3c2410_dmasrc source, | 1108 | enum s3c2410_dmasrc source, |
1162 | int hwcfg, | ||
1163 | unsigned long devaddr) | 1109 | unsigned long devaddr) |
1164 | { | 1110 | { |
1165 | struct s3c2410_dma_chan *chan = lookup_dma_channel(channel); | 1111 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); |
1112 | unsigned int hwcfg; | ||
1166 | 1113 | ||
1167 | if (chan == NULL) | 1114 | if (chan == NULL) |
1168 | return -EINVAL; | 1115 | return -EINVAL; |
1169 | 1116 | ||
1170 | pr_debug("%s: source=%d, hwcfg=%08x, devaddr=%08lx\n", | 1117 | pr_debug("%s: source=%d, devaddr=%08lx\n", |
1171 | __func__, (int)source, hwcfg, devaddr); | 1118 | __func__, (int)source, devaddr); |
1172 | 1119 | ||
1173 | chan->source = source; | 1120 | chan->source = source; |
1174 | chan->dev_addr = devaddr; | 1121 | chan->dev_addr = devaddr; |
1175 | chan->hw_cfg = hwcfg; | 1122 | |
1123 | switch (chan->req_ch) { | ||
1124 | case DMACH_XD0: | ||
1125 | case DMACH_XD1: | ||
1126 | hwcfg = 0; /* AHB */ | ||
1127 | break; | ||
1128 | |||
1129 | default: | ||
1130 | hwcfg = S3C2410_DISRCC_APB; | ||
1131 | } | ||
1132 | |||
1133 | /* always assume our peripheral desintation is a fixed | ||
1134 | * address in memory. */ | ||
1135 | hwcfg |= S3C2410_DISRCC_INC; | ||
1176 | 1136 | ||
1177 | switch (source) { | 1137 | switch (source) { |
1178 | case S3C2410_DMASRC_HW: | 1138 | case S3C2410_DMASRC_HW: |
@@ -1219,7 +1179,7 @@ EXPORT_SYMBOL(s3c2410_dma_devconfig); | |||
1219 | 1179 | ||
1220 | int s3c2410_dma_getposition(unsigned int channel, dma_addr_t *src, dma_addr_t *dst) | 1180 | int s3c2410_dma_getposition(unsigned int channel, dma_addr_t *src, dma_addr_t *dst) |
1221 | { | 1181 | { |
1222 | struct s3c2410_dma_chan *chan = lookup_dma_channel(channel); | 1182 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); |
1223 | 1183 | ||
1224 | if (chan == NULL) | 1184 | if (chan == NULL) |
1225 | return -EINVAL; | 1185 | return -EINVAL; |
@@ -1278,8 +1238,8 @@ static int s3c2410_dma_resume(struct sys_device *dev) | |||
1278 | 1238 | ||
1279 | printk(KERN_INFO "dma%d: restoring configuration\n", cp->number); | 1239 | printk(KERN_INFO "dma%d: restoring configuration\n", cp->number); |
1280 | 1240 | ||
1281 | s3c2410_dma_config(no, cp->xfer_unit, cp->dcon); | 1241 | s3c2410_dma_config(no, cp->xfer_unit); |
1282 | s3c2410_dma_devconfig(no, cp->source, cp->hw_cfg, cp->dev_addr); | 1242 | s3c2410_dma_devconfig(no, cp->source, cp->dev_addr); |
1283 | 1243 | ||
1284 | /* re-select the dma source for this channel */ | 1244 | /* re-select the dma source for this channel */ |
1285 | 1245 | ||
@@ -1476,7 +1436,8 @@ static struct s3c2410_dma_chan *s3c2410_dma_map_channel(int channel) | |||
1476 | found: | 1436 | found: |
1477 | dmach = &s3c2410_chans[ch]; | 1437 | dmach = &s3c2410_chans[ch]; |
1478 | dmach->map = ch_map; | 1438 | dmach->map = ch_map; |
1479 | dma_chan_map[channel] = dmach; | 1439 | dmach->req_ch = channel; |
1440 | s3c_dma_chan_map[channel] = dmach; | ||
1480 | 1441 | ||
1481 | /* select the channel */ | 1442 | /* select the channel */ |
1482 | 1443 | ||