Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/sh/drivers/dma/dma-sh.c |
| 3 | * |
| 4 | * SuperH On-chip DMAC Support |
| 5 | * |
| 6 | * Copyright (C) 2000 Takashi YOSHII |
| 7 | * Copyright (C) 2003, 2004 Paul Mundt |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 8 | * Copyright (C) 2005 Andriy Skulysh |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
| 10 | * This file is subject to the terms and conditions of the GNU General Public |
| 11 | * License. See the file "COPYING" in the main directory of this archive |
| 12 | * for more details. |
| 13 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/module.h> |
Paul Mundt | 71b8064 | 2008-07-29 20:20:36 +0900 | [diff] [blame] | 17 | #include <mach-dreamcast/mach/dma.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/dma.h> |
| 19 | #include <asm/io.h> |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 20 | #include <asm/dma-sh.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 22 | #if defined(CONFIG_CPU_SUBTYPE_SH7763) || \ |
| 23 | defined(CONFIG_CPU_SUBTYPE_SH7764) || \ |
| 24 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
| 25 | defined(CONFIG_CPU_SUBTYPE_SH7785) |
| 26 | #define DMAC_IRQ_MULTI 1 |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 27 | #endif |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 28 | |
| 29 | #if defined(DMAE1_IRQ) |
| 30 | #define NR_DMAE 2 |
| 31 | #else |
| 32 | #define NR_DMAE 1 |
Jamie Lenehan | bd71ab8 | 2006-10-31 12:35:02 +0900 | [diff] [blame] | 33 | #endif |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 34 | |
| 35 | static const char *dmae_name[] = { |
| 36 | "DMAC Address Error0", "DMAC Address Error1" |
Jamie Lenehan | bd71ab8 | 2006-10-31 12:35:02 +0900 | [diff] [blame] | 37 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Jamie Lenehan | bd71ab8 | 2006-10-31 12:35:02 +0900 | [diff] [blame] | 39 | static inline unsigned int get_dmte_irq(unsigned int chan) |
| 40 | { |
| 41 | unsigned int irq = 0; |
Manuel Lauss | 9f8a5e3 | 2007-01-25 15:22:11 +0900 | [diff] [blame] | 42 | if (chan < ARRAY_SIZE(dmte_irq_map)) |
| 43 | irq = dmte_irq_map[chan]; |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 44 | |
| 45 | #if defined(DMAC_IRQ_MULTI) |
| 46 | if (irq > DMTE6_IRQ) |
| 47 | return DMTE6_IRQ; |
| 48 | return DMTE0_IRQ; |
| 49 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | return irq; |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 51 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /* |
| 55 | * We determine the correct shift size based off of the CHCR transmit size |
| 56 | * for the given channel. Since we know that it will take: |
| 57 | * |
| 58 | * info->count >> ts_shift[transmit_size] |
| 59 | * |
| 60 | * iterations to complete the transfer. |
| 61 | */ |
| 62 | static inline unsigned int calc_xmit_shift(struct dma_channel *chan) |
| 63 | { |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 64 | u32 chcr = ctrl_inl(dma_base_addr[chan->chan] + CHCR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 66 | return ts_shift[(chcr & CHCR_TS_MASK)>>CHCR_TS_SHIFT]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | /* |
| 70 | * The transfer end interrupt must read the chcr register to end the |
| 71 | * hardware interrupt active condition. |
| 72 | * Besides that it needs to waken any waiting process, which should handle |
| 73 | * setting up the next transfer. |
| 74 | */ |
Paul Mundt | 35f3c51 | 2006-10-06 15:31:16 +0900 | [diff] [blame] | 75 | static irqreturn_t dma_tei(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
Paul Mundt | 35f3c51 | 2006-10-06 15:31:16 +0900 | [diff] [blame] | 77 | struct dma_channel *chan = dev_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | u32 chcr; |
| 79 | |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 80 | chcr = ctrl_inl(dma_base_addr[chan->chan] + CHCR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
| 82 | if (!(chcr & CHCR_TE)) |
| 83 | return IRQ_NONE; |
| 84 | |
| 85 | chcr &= ~(CHCR_IE | CHCR_DE); |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 86 | ctrl_outl(chcr, (dma_base_addr[chan->chan] + CHCR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | wake_up(&chan->wait_queue); |
| 89 | |
| 90 | return IRQ_HANDLED; |
| 91 | } |
| 92 | |
| 93 | static int sh_dmac_request_dma(struct dma_channel *chan) |
| 94 | { |
Julia Lawall | b2d7c7f | 2008-02-26 21:42:11 +0100 | [diff] [blame] | 95 | if (unlikely(!(chan->flags & DMA_TEI_CAPABLE))) |
Paul Mundt | 9e3043c | 2006-09-27 16:55:24 +0900 | [diff] [blame] | 96 | return 0; |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | return request_irq(get_dmte_irq(chan->chan), dma_tei, |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 99 | #if defined(DMAC_IRQ_MULTI) |
| 100 | IRQF_SHARED, |
| 101 | #else |
| 102 | IRQF_DISABLED, |
| 103 | #endif |
| 104 | chan->dev_id, chan); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | static void sh_dmac_free_dma(struct dma_channel *chan) |
| 108 | { |
| 109 | free_irq(get_dmte_irq(chan->chan), chan); |
| 110 | } |
| 111 | |
Manuel Lauss | 9f8a5e3 | 2007-01-25 15:22:11 +0900 | [diff] [blame] | 112 | static int |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 113 | sh_dmac_configure_channel(struct dma_channel *chan, unsigned long chcr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | { |
| 115 | if (!chcr) |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 116 | chcr = RS_DUAL | CHCR_IE; |
| 117 | |
| 118 | if (chcr & CHCR_IE) { |
| 119 | chcr &= ~CHCR_IE; |
| 120 | chan->flags |= DMA_TEI_CAPABLE; |
| 121 | } else { |
| 122 | chan->flags &= ~DMA_TEI_CAPABLE; |
| 123 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 125 | ctrl_outl(chcr, (dma_base_addr[chan->chan] + CHCR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
| 127 | chan->flags |= DMA_CONFIGURED; |
Manuel Lauss | 9f8a5e3 | 2007-01-25 15:22:11 +0900 | [diff] [blame] | 128 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | static void sh_dmac_enable_dma(struct dma_channel *chan) |
| 132 | { |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 133 | int irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | u32 chcr; |
| 135 | |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 136 | chcr = ctrl_inl(dma_base_addr[chan->chan] + CHCR); |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 137 | chcr |= CHCR_DE; |
| 138 | |
| 139 | if (chan->flags & DMA_TEI_CAPABLE) |
| 140 | chcr |= CHCR_IE; |
| 141 | |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 142 | ctrl_outl(chcr, (dma_base_addr[chan->chan] + CHCR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 144 | if (chan->flags & DMA_TEI_CAPABLE) { |
| 145 | irq = get_dmte_irq(chan->chan); |
| 146 | enable_irq(irq); |
| 147 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static void sh_dmac_disable_dma(struct dma_channel *chan) |
| 151 | { |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 152 | int irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | u32 chcr; |
| 154 | |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 155 | if (chan->flags & DMA_TEI_CAPABLE) { |
| 156 | irq = get_dmte_irq(chan->chan); |
| 157 | disable_irq(irq); |
| 158 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 160 | chcr = ctrl_inl(dma_base_addr[chan->chan] + CHCR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | chcr &= ~(CHCR_DE | CHCR_TE | CHCR_IE); |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 162 | ctrl_outl(chcr, (dma_base_addr[chan->chan] + CHCR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | static int sh_dmac_xfer_dma(struct dma_channel *chan) |
| 166 | { |
| 167 | /* |
| 168 | * If we haven't pre-configured the channel with special flags, use |
| 169 | * the defaults. |
| 170 | */ |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 171 | if (unlikely(!(chan->flags & DMA_CONFIGURED))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | sh_dmac_configure_channel(chan, 0); |
| 173 | |
| 174 | sh_dmac_disable_dma(chan); |
| 175 | |
| 176 | /* |
| 177 | * Single-address mode usage note! |
| 178 | * |
| 179 | * It's important that we don't accidentally write any value to SAR/DAR |
| 180 | * (this includes 0) that hasn't been directly specified by the user if |
| 181 | * we're in single-address mode. |
| 182 | * |
| 183 | * In this case, only one address can be defined, anything else will |
| 184 | * result in a DMA address error interrupt (at least on the SH-4), |
| 185 | * which will subsequently halt the transfer. |
| 186 | * |
| 187 | * Channel 2 on the Dreamcast is a special case, as this is used for |
| 188 | * cascading to the PVR2 DMAC. In this case, we still need to write |
| 189 | * SAR and DAR, regardless of value, in order for cascading to work. |
| 190 | */ |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 191 | if (chan->sar || (mach_is_dreamcast() && |
| 192 | chan->chan == PVR2_CASCADE_CHAN)) |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 193 | ctrl_outl(chan->sar, (dma_base_addr[chan->chan]+SAR)); |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 194 | if (chan->dar || (mach_is_dreamcast() && |
| 195 | chan->chan == PVR2_CASCADE_CHAN)) |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 196 | ctrl_outl(chan->dar, (dma_base_addr[chan->chan] + DAR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 198 | ctrl_outl(chan->count >> calc_xmit_shift(chan), |
| 199 | (dma_base_addr[chan->chan] + TCR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
| 201 | sh_dmac_enable_dma(chan); |
| 202 | |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | static int sh_dmac_get_dma_residue(struct dma_channel *chan) |
| 207 | { |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 208 | if (!(ctrl_inl(dma_base_addr[chan->chan] + CHCR) & CHCR_DE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | return 0; |
| 210 | |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 211 | return ctrl_inl(dma_base_addr[chan->chan] + TCR) |
| 212 | << calc_xmit_shift(chan); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 215 | static inline int dmaor_reset(int no) |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 216 | { |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 217 | unsigned long dmaor = dmaor_read_reg(no); |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 218 | |
| 219 | /* Try to clear the error flags first, incase they are set */ |
| 220 | dmaor &= ~(DMAOR_NMIF | DMAOR_AE); |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 221 | dmaor_write_reg(no, dmaor); |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 222 | |
| 223 | dmaor |= DMAOR_INIT; |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 224 | dmaor_write_reg(no, dmaor); |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 225 | |
| 226 | /* See if we got an error again */ |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 227 | if ((dmaor_read_reg(no) & (DMAOR_AE | DMAOR_NMIF))) { |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 228 | printk(KERN_ERR "dma-sh: Can't initialize DMAOR.\n"); |
| 229 | return -EINVAL; |
| 230 | } |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | #if defined(CONFIG_CPU_SH4) |
Paul Mundt | 35f3c51 | 2006-10-06 15:31:16 +0900 | [diff] [blame] | 236 | static irqreturn_t dma_err(int irq, void *dummy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | { |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 238 | #if defined(DMAC_IRQ_MULTI) |
| 239 | int cnt = 0; |
| 240 | switch (irq) { |
| 241 | #if defined(DMTE6_IRQ) && defined(DMAE1_IRQ) |
| 242 | case DMTE6_IRQ: |
| 243 | cnt++; |
| 244 | #endif |
| 245 | case DMTE0_IRQ: |
| 246 | if (dmaor_read_reg(cnt) & (DMAOR_NMIF | DMAOR_AE)) { |
| 247 | disable_irq(irq); |
| 248 | /* DMA multi and error IRQ */ |
| 249 | return IRQ_HANDLED; |
| 250 | } |
| 251 | default: |
| 252 | return IRQ_NONE; |
| 253 | } |
| 254 | #else |
| 255 | dmaor_reset(0); |
| 256 | #if defined(CONFIG_CPU_SUBTYPE_SH7723) || \ |
| 257 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
| 258 | defined(CONFIG_CPU_SUBTYPE_SH7785) |
| 259 | dmaor_reset(1); |
| 260 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | disable_irq(irq); |
| 262 | |
| 263 | return IRQ_HANDLED; |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 264 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | } |
| 266 | #endif |
| 267 | |
| 268 | static struct dma_ops sh_dmac_ops = { |
| 269 | .request = sh_dmac_request_dma, |
| 270 | .free = sh_dmac_free_dma, |
| 271 | .get_residue = sh_dmac_get_dma_residue, |
| 272 | .xfer = sh_dmac_xfer_dma, |
| 273 | .configure = sh_dmac_configure_channel, |
| 274 | }; |
| 275 | |
| 276 | static struct dma_info sh_dmac_info = { |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 277 | .name = "sh_dmac", |
| 278 | .nr_channels = CONFIG_NR_ONCHIP_DMA_CHANNELS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | .ops = &sh_dmac_ops, |
| 280 | .flags = DMAC_CHANNELS_TEI_CAPABLE, |
| 281 | }; |
| 282 | |
Nobuhiro Iwamatsu | 02ebd32 | 2009-03-13 04:31:34 +0000 | [diff] [blame] | 283 | #ifdef CONFIG_CPU_SH4 |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 284 | static unsigned int get_dma_error_irq(int n) |
| 285 | { |
| 286 | #if defined(DMAC_IRQ_MULTI) |
| 287 | return (n == 0) ? get_dmte_irq(0) : get_dmte_irq(6); |
| 288 | #else |
| 289 | return (n == 0) ? DMAE0_IRQ : |
| 290 | #if defined(DMAE1_IRQ) |
| 291 | DMAE1_IRQ; |
| 292 | #else |
| 293 | -1; |
| 294 | #endif |
| 295 | #endif |
| 296 | } |
Nobuhiro Iwamatsu | 02ebd32 | 2009-03-13 04:31:34 +0000 | [diff] [blame] | 297 | #endif |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 298 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | static int __init sh_dmac_init(void) |
| 300 | { |
| 301 | struct dma_info *info = &sh_dmac_info; |
| 302 | int i; |
| 303 | |
| 304 | #ifdef CONFIG_CPU_SH4 |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 305 | int n; |
| 306 | |
| 307 | for (n = 0; n < NR_DMAE; n++) { |
| 308 | i = request_irq(get_dma_error_irq(n), dma_err, |
| 309 | #if defined(DMAC_IRQ_MULTI) |
| 310 | IRQF_SHARED, |
| 311 | #else |
| 312 | IRQF_DISABLED, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | #endif |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 314 | dmae_name[n], (void *)dmae_name[n]); |
| 315 | if (unlikely(i < 0)) { |
| 316 | printk(KERN_ERR "%s request_irq fail\n", dmae_name[n]); |
| 317 | return i; |
| 318 | } |
| 319 | } |
| 320 | #endif /* CONFIG_CPU_SH4 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 322 | /* |
| 323 | * Initialize DMAOR, and clean up any error flags that may have |
| 324 | * been set. |
| 325 | */ |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 326 | i = dmaor_reset(0); |
Paul Mundt | 9e3043c | 2006-09-27 16:55:24 +0900 | [diff] [blame] | 327 | if (unlikely(i != 0)) |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 328 | return i; |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 329 | #if defined(CONFIG_CPU_SUBTYPE_SH7723) || \ |
| 330 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
| 331 | defined(CONFIG_CPU_SUBTYPE_SH7785) |
| 332 | i = dmaor_reset(1); |
| 333 | if (unlikely(i != 0)) |
| 334 | return i; |
| 335 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | |
| 337 | return register_dmac(info); |
| 338 | } |
| 339 | |
| 340 | static void __exit sh_dmac_exit(void) |
| 341 | { |
| 342 | #ifdef CONFIG_CPU_SH4 |
Nobuhiro Iwamatsu | 71b973a | 2009-03-10 17:26:49 +0900 | [diff] [blame] | 343 | int n; |
| 344 | |
| 345 | for (n = 0; n < NR_DMAE; n++) { |
| 346 | free_irq(get_dma_error_irq(n), (void *)dmae_name[n]); |
| 347 | } |
| 348 | #endif /* CONFIG_CPU_SH4 */ |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 349 | unregister_dmac(&sh_dmac_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | subsys_initcall(sh_dmac_init); |
| 353 | module_exit(sh_dmac_exit); |
| 354 | |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 355 | MODULE_AUTHOR("Takashi YOSHII, Paul Mundt, Andriy Skulysh"); |
| 356 | MODULE_DESCRIPTION("SuperH On-Chip DMAC Support"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | MODULE_LICENSE("GPL"); |