Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. |
| 3 | * |
| 4 | * Refer to drivers/dma/imx-sdma.c |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/types.h> |
| 13 | #include <linux/mm.h> |
| 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/clk.h> |
| 16 | #include <linux/wait.h> |
| 17 | #include <linux/sched.h> |
| 18 | #include <linux/semaphore.h> |
| 19 | #include <linux/device.h> |
| 20 | #include <linux/dma-mapping.h> |
| 21 | #include <linux/slab.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/dmaengine.h> |
| 24 | #include <linux/delay.h> |
Huang Shijie | 3946860 | 2012-02-16 14:17:32 +0800 | [diff] [blame] | 25 | #include <linux/fsl/mxs-dma.h> |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 26 | #include <linux/stmp_device.h> |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 27 | |
| 28 | #include <asm/irq.h> |
| 29 | #include <mach/mxs.h> |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 30 | |
Russell King - ARM Linux | d2ebfb3 | 2012-03-06 22:34:26 +0000 | [diff] [blame] | 31 | #include "dmaengine.h" |
| 32 | |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 33 | /* |
| 34 | * NOTE: The term "PIO" throughout the mxs-dma implementation means |
| 35 | * PIO mode of mxs apbh-dma and apbx-dma. With this working mode, |
| 36 | * dma can program the controller registers of peripheral devices. |
| 37 | */ |
| 38 | |
Shawn Guo | 8c92013 | 2012-05-10 06:23:26 +0800 | [diff] [blame^] | 39 | #define dma_is_apbh(mxs_dma) ((mxs_dma)->type == MXS_DMA_APBH) |
| 40 | #define apbh_is_old(mxs_dma) ((mxs_dma)->dev_id == IMX23_DMA) |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 41 | |
| 42 | #define HW_APBHX_CTRL0 0x000 |
| 43 | #define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29) |
| 44 | #define BM_APBH_CTRL0_APB_BURST_EN (1 << 28) |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 45 | #define BP_APBH_CTRL0_RESET_CHANNEL 16 |
| 46 | #define HW_APBHX_CTRL1 0x010 |
| 47 | #define HW_APBHX_CTRL2 0x020 |
| 48 | #define HW_APBHX_CHANNEL_CTRL 0x030 |
| 49 | #define BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL 16 |
Shawn Guo | bb11fb6 | 2012-05-07 14:14:08 +0800 | [diff] [blame] | 50 | /* |
| 51 | * The offset of NXTCMDAR register is different per both dma type and version, |
| 52 | * while stride for each channel is all the same 0x70. |
| 53 | */ |
| 54 | #define HW_APBHX_CHn_NXTCMDAR(d, n) \ |
| 55 | (((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70) |
| 56 | #define HW_APBHX_CHn_SEMA(d, n) \ |
| 57 | (((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70) |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * ccw bits definitions |
| 61 | * |
| 62 | * COMMAND: 0..1 (2) |
| 63 | * CHAIN: 2 (1) |
| 64 | * IRQ: 3 (1) |
| 65 | * NAND_LOCK: 4 (1) - not implemented |
| 66 | * NAND_WAIT4READY: 5 (1) - not implemented |
| 67 | * DEC_SEM: 6 (1) |
| 68 | * WAIT4END: 7 (1) |
| 69 | * HALT_ON_TERMINATE: 8 (1) |
| 70 | * TERMINATE_FLUSH: 9 (1) |
| 71 | * RESERVED: 10..11 (2) |
| 72 | * PIO_NUM: 12..15 (4) |
| 73 | */ |
| 74 | #define BP_CCW_COMMAND 0 |
| 75 | #define BM_CCW_COMMAND (3 << 0) |
| 76 | #define CCW_CHAIN (1 << 2) |
| 77 | #define CCW_IRQ (1 << 3) |
| 78 | #define CCW_DEC_SEM (1 << 6) |
| 79 | #define CCW_WAIT4END (1 << 7) |
| 80 | #define CCW_HALT_ON_TERM (1 << 8) |
| 81 | #define CCW_TERM_FLUSH (1 << 9) |
| 82 | #define BP_CCW_PIO_NUM 12 |
| 83 | #define BM_CCW_PIO_NUM (0xf << 12) |
| 84 | |
| 85 | #define BF_CCW(value, field) (((value) << BP_CCW_##field) & BM_CCW_##field) |
| 86 | |
| 87 | #define MXS_DMA_CMD_NO_XFER 0 |
| 88 | #define MXS_DMA_CMD_WRITE 1 |
| 89 | #define MXS_DMA_CMD_READ 2 |
| 90 | #define MXS_DMA_CMD_DMA_SENSE 3 /* not implemented */ |
| 91 | |
| 92 | struct mxs_dma_ccw { |
| 93 | u32 next; |
| 94 | u16 bits; |
| 95 | u16 xfer_bytes; |
| 96 | #define MAX_XFER_BYTES 0xff00 |
| 97 | u32 bufaddr; |
| 98 | #define MXS_PIO_WORDS 16 |
| 99 | u32 pio_words[MXS_PIO_WORDS]; |
| 100 | }; |
| 101 | |
| 102 | #define NUM_CCW (int)(PAGE_SIZE / sizeof(struct mxs_dma_ccw)) |
| 103 | |
| 104 | struct mxs_dma_chan { |
| 105 | struct mxs_dma_engine *mxs_dma; |
| 106 | struct dma_chan chan; |
| 107 | struct dma_async_tx_descriptor desc; |
| 108 | struct tasklet_struct tasklet; |
| 109 | int chan_irq; |
| 110 | struct mxs_dma_ccw *ccw; |
| 111 | dma_addr_t ccw_phys; |
Lothar Waßmann | 6d23ea4 | 2011-12-08 09:15:43 +0100 | [diff] [blame] | 112 | int desc_count; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 113 | enum dma_status status; |
| 114 | unsigned int flags; |
| 115 | #define MXS_DMA_SG_LOOP (1 << 0) |
| 116 | }; |
| 117 | |
| 118 | #define MXS_DMA_CHANNELS 16 |
| 119 | #define MXS_DMA_CHANNELS_MASK 0xffff |
| 120 | |
Shawn Guo | 8c92013 | 2012-05-10 06:23:26 +0800 | [diff] [blame^] | 121 | enum mxs_dma_devtype { |
| 122 | MXS_DMA_APBH, |
| 123 | MXS_DMA_APBX, |
| 124 | }; |
| 125 | |
| 126 | enum mxs_dma_id { |
| 127 | IMX23_DMA, |
| 128 | IMX28_DMA, |
| 129 | }; |
| 130 | |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 131 | struct mxs_dma_engine { |
Shawn Guo | 8c92013 | 2012-05-10 06:23:26 +0800 | [diff] [blame^] | 132 | enum mxs_dma_id dev_id; |
| 133 | enum mxs_dma_devtype type; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 134 | void __iomem *base; |
| 135 | struct clk *clk; |
| 136 | struct dma_device dma_device; |
| 137 | struct device_dma_parameters dma_parms; |
| 138 | struct mxs_dma_chan mxs_chans[MXS_DMA_CHANNELS]; |
| 139 | }; |
| 140 | |
Shawn Guo | 8c92013 | 2012-05-10 06:23:26 +0800 | [diff] [blame^] | 141 | struct mxs_dma_type { |
| 142 | enum mxs_dma_id id; |
| 143 | enum mxs_dma_devtype type; |
| 144 | }; |
| 145 | |
| 146 | static struct mxs_dma_type mxs_dma_types[] = { |
| 147 | { |
| 148 | .id = IMX23_DMA, |
| 149 | .type = MXS_DMA_APBH, |
| 150 | }, { |
| 151 | .id = IMX23_DMA, |
| 152 | .type = MXS_DMA_APBX, |
| 153 | }, { |
| 154 | .id = IMX28_DMA, |
| 155 | .type = MXS_DMA_APBH, |
| 156 | }, { |
| 157 | .id = IMX28_DMA, |
| 158 | .type = MXS_DMA_APBX, |
| 159 | } |
| 160 | }; |
| 161 | |
| 162 | static struct platform_device_id mxs_dma_ids[] = { |
| 163 | { |
| 164 | .name = "imx23-dma-apbh", |
| 165 | .driver_data = (kernel_ulong_t) &mxs_dma_types[0], |
| 166 | }, { |
| 167 | .name = "imx23-dma-apbx", |
| 168 | .driver_data = (kernel_ulong_t) &mxs_dma_types[1], |
| 169 | }, { |
| 170 | .name = "imx28-dma-apbh", |
| 171 | .driver_data = (kernel_ulong_t) &mxs_dma_types[2], |
| 172 | }, { |
| 173 | .name = "imx28-dma-apbx", |
| 174 | .driver_data = (kernel_ulong_t) &mxs_dma_types[3], |
| 175 | }, { |
| 176 | /* end of list */ |
| 177 | } |
| 178 | }; |
| 179 | |
| 180 | static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan) |
| 181 | { |
| 182 | return container_of(chan, struct mxs_dma_chan, chan); |
| 183 | } |
| 184 | |
| 185 | int mxs_dma_is_apbh(struct dma_chan *chan) |
| 186 | { |
| 187 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
| 188 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 189 | |
| 190 | return dma_is_apbh(mxs_dma); |
| 191 | } |
| 192 | |
| 193 | int mxs_dma_is_apbx(struct dma_chan *chan) |
| 194 | { |
| 195 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
| 196 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 197 | |
| 198 | return !dma_is_apbh(mxs_dma); |
| 199 | } |
| 200 | |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 201 | static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan) |
| 202 | { |
| 203 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 204 | int chan_id = mxs_chan->chan.chan_id; |
| 205 | |
Shawn Guo | bb11fb6 | 2012-05-07 14:14:08 +0800 | [diff] [blame] | 206 | if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma)) |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 207 | writel(1 << (chan_id + BP_APBH_CTRL0_RESET_CHANNEL), |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 208 | mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 209 | else |
| 210 | writel(1 << (chan_id + BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL), |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 211 | mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_SET); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | static void mxs_dma_enable_chan(struct mxs_dma_chan *mxs_chan) |
| 215 | { |
| 216 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 217 | int chan_id = mxs_chan->chan.chan_id; |
| 218 | |
| 219 | /* set cmd_addr up */ |
| 220 | writel(mxs_chan->ccw_phys, |
Shawn Guo | bb11fb6 | 2012-05-07 14:14:08 +0800 | [diff] [blame] | 221 | mxs_dma->base + HW_APBHX_CHn_NXTCMDAR(mxs_dma, chan_id)); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 222 | |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 223 | /* write 1 to SEMA to kick off the channel */ |
Shawn Guo | bb11fb6 | 2012-05-07 14:14:08 +0800 | [diff] [blame] | 224 | writel(1, mxs_dma->base + HW_APBHX_CHn_SEMA(mxs_dma, chan_id)); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | static void mxs_dma_disable_chan(struct mxs_dma_chan *mxs_chan) |
| 228 | { |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 229 | mxs_chan->status = DMA_SUCCESS; |
| 230 | } |
| 231 | |
| 232 | static void mxs_dma_pause_chan(struct mxs_dma_chan *mxs_chan) |
| 233 | { |
| 234 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 235 | int chan_id = mxs_chan->chan.chan_id; |
| 236 | |
| 237 | /* freeze the channel */ |
Shawn Guo | bb11fb6 | 2012-05-07 14:14:08 +0800 | [diff] [blame] | 238 | if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma)) |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 239 | writel(1 << chan_id, |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 240 | mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 241 | else |
| 242 | writel(1 << chan_id, |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 243 | mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_SET); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 244 | |
| 245 | mxs_chan->status = DMA_PAUSED; |
| 246 | } |
| 247 | |
| 248 | static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan) |
| 249 | { |
| 250 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 251 | int chan_id = mxs_chan->chan.chan_id; |
| 252 | |
| 253 | /* unfreeze the channel */ |
Shawn Guo | bb11fb6 | 2012-05-07 14:14:08 +0800 | [diff] [blame] | 254 | if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma)) |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 255 | writel(1 << chan_id, |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 256 | mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_CLR); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 257 | else |
| 258 | writel(1 << chan_id, |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 259 | mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_CLR); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 260 | |
| 261 | mxs_chan->status = DMA_IN_PROGRESS; |
| 262 | } |
| 263 | |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 264 | static dma_cookie_t mxs_dma_tx_submit(struct dma_async_tx_descriptor *tx) |
| 265 | { |
Russell King - ARM Linux | 884485e | 2012-03-06 22:34:46 +0000 | [diff] [blame] | 266 | return dma_cookie_assign(tx); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | static void mxs_dma_tasklet(unsigned long data) |
| 270 | { |
| 271 | struct mxs_dma_chan *mxs_chan = (struct mxs_dma_chan *) data; |
| 272 | |
| 273 | if (mxs_chan->desc.callback) |
| 274 | mxs_chan->desc.callback(mxs_chan->desc.callback_param); |
| 275 | } |
| 276 | |
| 277 | static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id) |
| 278 | { |
| 279 | struct mxs_dma_engine *mxs_dma = dev_id; |
| 280 | u32 stat1, stat2; |
| 281 | |
| 282 | /* completion status */ |
| 283 | stat1 = readl(mxs_dma->base + HW_APBHX_CTRL1); |
| 284 | stat1 &= MXS_DMA_CHANNELS_MASK; |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 285 | writel(stat1, mxs_dma->base + HW_APBHX_CTRL1 + STMP_OFFSET_REG_CLR); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 286 | |
| 287 | /* error status */ |
| 288 | stat2 = readl(mxs_dma->base + HW_APBHX_CTRL2); |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 289 | writel(stat2, mxs_dma->base + HW_APBHX_CTRL2 + STMP_OFFSET_REG_CLR); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 290 | |
| 291 | /* |
| 292 | * When both completion and error of termination bits set at the |
| 293 | * same time, we do not take it as an error. IOW, it only becomes |
Lothar Waßmann | 4003122 | 2011-12-08 09:15:41 +0100 | [diff] [blame] | 294 | * an error we need to handle here in case of either it's (1) a bus |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 295 | * error or (2) a termination error with no completion. |
| 296 | */ |
| 297 | stat2 = ((stat2 >> MXS_DMA_CHANNELS) & stat2) | /* (1) */ |
| 298 | (~(stat2 >> MXS_DMA_CHANNELS) & stat2 & ~stat1); /* (2) */ |
| 299 | |
| 300 | /* combine error and completion status for checking */ |
| 301 | stat1 = (stat2 << MXS_DMA_CHANNELS) | stat1; |
| 302 | while (stat1) { |
| 303 | int channel = fls(stat1) - 1; |
| 304 | struct mxs_dma_chan *mxs_chan = |
| 305 | &mxs_dma->mxs_chans[channel % MXS_DMA_CHANNELS]; |
| 306 | |
| 307 | if (channel >= MXS_DMA_CHANNELS) { |
| 308 | dev_dbg(mxs_dma->dma_device.dev, |
| 309 | "%s: error in channel %d\n", __func__, |
| 310 | channel - MXS_DMA_CHANNELS); |
| 311 | mxs_chan->status = DMA_ERROR; |
| 312 | mxs_dma_reset_chan(mxs_chan); |
| 313 | } else { |
| 314 | if (mxs_chan->flags & MXS_DMA_SG_LOOP) |
| 315 | mxs_chan->status = DMA_IN_PROGRESS; |
| 316 | else |
| 317 | mxs_chan->status = DMA_SUCCESS; |
| 318 | } |
| 319 | |
| 320 | stat1 &= ~(1 << channel); |
| 321 | |
| 322 | if (mxs_chan->status == DMA_SUCCESS) |
Russell King - ARM Linux | f7fbce0 | 2012-03-06 22:35:07 +0000 | [diff] [blame] | 323 | dma_cookie_complete(&mxs_chan->desc); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 324 | |
| 325 | /* schedule tasklet on this channel */ |
| 326 | tasklet_schedule(&mxs_chan->tasklet); |
| 327 | } |
| 328 | |
| 329 | return IRQ_HANDLED; |
| 330 | } |
| 331 | |
| 332 | static int mxs_dma_alloc_chan_resources(struct dma_chan *chan) |
| 333 | { |
| 334 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
| 335 | struct mxs_dma_data *data = chan->private; |
| 336 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 337 | int ret; |
| 338 | |
| 339 | if (!data) |
| 340 | return -EINVAL; |
| 341 | |
| 342 | mxs_chan->chan_irq = data->chan_irq; |
| 343 | |
| 344 | mxs_chan->ccw = dma_alloc_coherent(mxs_dma->dma_device.dev, PAGE_SIZE, |
| 345 | &mxs_chan->ccw_phys, GFP_KERNEL); |
| 346 | if (!mxs_chan->ccw) { |
| 347 | ret = -ENOMEM; |
| 348 | goto err_alloc; |
| 349 | } |
| 350 | |
| 351 | memset(mxs_chan->ccw, 0, PAGE_SIZE); |
| 352 | |
Shawn Guo | 95bfea1 | 2011-06-30 16:06:33 +0800 | [diff] [blame] | 353 | if (mxs_chan->chan_irq != NO_IRQ) { |
| 354 | ret = request_irq(mxs_chan->chan_irq, mxs_dma_int_handler, |
| 355 | 0, "mxs-dma", mxs_dma); |
| 356 | if (ret) |
| 357 | goto err_irq; |
| 358 | } |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 359 | |
Shawn Guo | 759a2e3 | 2011-12-20 13:54:00 +0800 | [diff] [blame] | 360 | ret = clk_prepare_enable(mxs_dma->clk); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 361 | if (ret) |
| 362 | goto err_clk; |
| 363 | |
| 364 | mxs_dma_reset_chan(mxs_chan); |
| 365 | |
| 366 | dma_async_tx_descriptor_init(&mxs_chan->desc, chan); |
| 367 | mxs_chan->desc.tx_submit = mxs_dma_tx_submit; |
| 368 | |
| 369 | /* the descriptor is ready */ |
| 370 | async_tx_ack(&mxs_chan->desc); |
| 371 | |
| 372 | return 0; |
| 373 | |
| 374 | err_clk: |
| 375 | free_irq(mxs_chan->chan_irq, mxs_dma); |
| 376 | err_irq: |
| 377 | dma_free_coherent(mxs_dma->dma_device.dev, PAGE_SIZE, |
| 378 | mxs_chan->ccw, mxs_chan->ccw_phys); |
| 379 | err_alloc: |
| 380 | return ret; |
| 381 | } |
| 382 | |
| 383 | static void mxs_dma_free_chan_resources(struct dma_chan *chan) |
| 384 | { |
| 385 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
| 386 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 387 | |
| 388 | mxs_dma_disable_chan(mxs_chan); |
| 389 | |
| 390 | free_irq(mxs_chan->chan_irq, mxs_dma); |
| 391 | |
| 392 | dma_free_coherent(mxs_dma->dma_device.dev, PAGE_SIZE, |
| 393 | mxs_chan->ccw, mxs_chan->ccw_phys); |
| 394 | |
Shawn Guo | 759a2e3 | 2011-12-20 13:54:00 +0800 | [diff] [blame] | 395 | clk_disable_unprepare(mxs_dma->clk); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 396 | } |
| 397 | |
Huang Shijie | 921de86 | 2012-02-16 14:17:33 +0800 | [diff] [blame] | 398 | /* |
| 399 | * How to use the flags for ->device_prep_slave_sg() : |
| 400 | * [1] If there is only one DMA command in the DMA chain, the code should be: |
| 401 | * ...... |
| 402 | * ->device_prep_slave_sg(DMA_CTRL_ACK); |
| 403 | * ...... |
| 404 | * [2] If there are two DMA commands in the DMA chain, the code should be |
| 405 | * ...... |
| 406 | * ->device_prep_slave_sg(0); |
| 407 | * ...... |
| 408 | * ->device_prep_slave_sg(DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
| 409 | * ...... |
| 410 | * [3] If there are more than two DMA commands in the DMA chain, the code |
| 411 | * should be: |
| 412 | * ...... |
| 413 | * ->device_prep_slave_sg(0); // First |
| 414 | * ...... |
| 415 | * ->device_prep_slave_sg(DMA_PREP_INTERRUPT [| DMA_CTRL_ACK]); |
| 416 | * ...... |
| 417 | * ->device_prep_slave_sg(DMA_PREP_INTERRUPT | DMA_CTRL_ACK); // Last |
| 418 | * ...... |
| 419 | */ |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 420 | static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg( |
| 421 | struct dma_chan *chan, struct scatterlist *sgl, |
Vinod Koul | db8196d | 2011-10-13 22:34:23 +0530 | [diff] [blame] | 422 | unsigned int sg_len, enum dma_transfer_direction direction, |
Linus Torvalds | 623ff77 | 2012-03-30 17:31:56 -0700 | [diff] [blame] | 423 | unsigned long flags, void *context) |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 424 | { |
| 425 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
| 426 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 427 | struct mxs_dma_ccw *ccw; |
| 428 | struct scatterlist *sg; |
| 429 | int i, j; |
| 430 | u32 *pio; |
Huang Shijie | 921de86 | 2012-02-16 14:17:33 +0800 | [diff] [blame] | 431 | bool append = flags & DMA_PREP_INTERRUPT; |
Lothar Waßmann | 6d23ea4 | 2011-12-08 09:15:43 +0100 | [diff] [blame] | 432 | int idx = append ? mxs_chan->desc_count : 0; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 433 | |
| 434 | if (mxs_chan->status == DMA_IN_PROGRESS && !append) |
| 435 | return NULL; |
| 436 | |
| 437 | if (sg_len + (append ? idx : 0) > NUM_CCW) { |
| 438 | dev_err(mxs_dma->dma_device.dev, |
| 439 | "maximum number of sg exceeded: %d > %d\n", |
| 440 | sg_len, NUM_CCW); |
| 441 | goto err_out; |
| 442 | } |
| 443 | |
| 444 | mxs_chan->status = DMA_IN_PROGRESS; |
| 445 | mxs_chan->flags = 0; |
| 446 | |
| 447 | /* |
| 448 | * If the sg is prepared with append flag set, the sg |
| 449 | * will be appended to the last prepared sg. |
| 450 | */ |
| 451 | if (append) { |
| 452 | BUG_ON(idx < 1); |
| 453 | ccw = &mxs_chan->ccw[idx - 1]; |
| 454 | ccw->next = mxs_chan->ccw_phys + sizeof(*ccw) * idx; |
| 455 | ccw->bits |= CCW_CHAIN; |
| 456 | ccw->bits &= ~CCW_IRQ; |
| 457 | ccw->bits &= ~CCW_DEC_SEM; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 458 | } else { |
| 459 | idx = 0; |
| 460 | } |
| 461 | |
Shawn Guo | 62268ce | 2011-12-13 23:48:03 +0800 | [diff] [blame] | 462 | if (direction == DMA_TRANS_NONE) { |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 463 | ccw = &mxs_chan->ccw[idx++]; |
| 464 | pio = (u32 *) sgl; |
| 465 | |
| 466 | for (j = 0; j < sg_len;) |
| 467 | ccw->pio_words[j++] = *pio++; |
| 468 | |
| 469 | ccw->bits = 0; |
| 470 | ccw->bits |= CCW_IRQ; |
| 471 | ccw->bits |= CCW_DEC_SEM; |
Huang Shijie | 921de86 | 2012-02-16 14:17:33 +0800 | [diff] [blame] | 472 | if (flags & DMA_CTRL_ACK) |
| 473 | ccw->bits |= CCW_WAIT4END; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 474 | ccw->bits |= CCW_HALT_ON_TERM; |
| 475 | ccw->bits |= CCW_TERM_FLUSH; |
| 476 | ccw->bits |= BF_CCW(sg_len, PIO_NUM); |
| 477 | ccw->bits |= BF_CCW(MXS_DMA_CMD_NO_XFER, COMMAND); |
| 478 | } else { |
| 479 | for_each_sg(sgl, sg, sg_len, i) { |
| 480 | if (sg->length > MAX_XFER_BYTES) { |
| 481 | dev_err(mxs_dma->dma_device.dev, "maximum bytes for sg entry exceeded: %d > %d\n", |
| 482 | sg->length, MAX_XFER_BYTES); |
| 483 | goto err_out; |
| 484 | } |
| 485 | |
| 486 | ccw = &mxs_chan->ccw[idx++]; |
| 487 | |
| 488 | ccw->next = mxs_chan->ccw_phys + sizeof(*ccw) * idx; |
| 489 | ccw->bufaddr = sg->dma_address; |
| 490 | ccw->xfer_bytes = sg->length; |
| 491 | |
| 492 | ccw->bits = 0; |
| 493 | ccw->bits |= CCW_CHAIN; |
| 494 | ccw->bits |= CCW_HALT_ON_TERM; |
| 495 | ccw->bits |= CCW_TERM_FLUSH; |
Vinod Koul | db8196d | 2011-10-13 22:34:23 +0530 | [diff] [blame] | 496 | ccw->bits |= BF_CCW(direction == DMA_DEV_TO_MEM ? |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 497 | MXS_DMA_CMD_WRITE : MXS_DMA_CMD_READ, |
| 498 | COMMAND); |
| 499 | |
| 500 | if (i + 1 == sg_len) { |
| 501 | ccw->bits &= ~CCW_CHAIN; |
| 502 | ccw->bits |= CCW_IRQ; |
| 503 | ccw->bits |= CCW_DEC_SEM; |
Huang Shijie | 921de86 | 2012-02-16 14:17:33 +0800 | [diff] [blame] | 504 | if (flags & DMA_CTRL_ACK) |
| 505 | ccw->bits |= CCW_WAIT4END; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 506 | } |
| 507 | } |
| 508 | } |
Lothar Waßmann | 6d23ea4 | 2011-12-08 09:15:43 +0100 | [diff] [blame] | 509 | mxs_chan->desc_count = idx; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 510 | |
| 511 | return &mxs_chan->desc; |
| 512 | |
| 513 | err_out: |
| 514 | mxs_chan->status = DMA_ERROR; |
| 515 | return NULL; |
| 516 | } |
| 517 | |
| 518 | static struct dma_async_tx_descriptor *mxs_dma_prep_dma_cyclic( |
| 519 | struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len, |
Alexandre Bounine | 185ecb5 | 2012-03-08 15:35:13 -0500 | [diff] [blame] | 520 | size_t period_len, enum dma_transfer_direction direction, |
| 521 | void *context) |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 522 | { |
| 523 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
| 524 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
| 525 | int num_periods = buf_len / period_len; |
| 526 | int i = 0, buf = 0; |
| 527 | |
| 528 | if (mxs_chan->status == DMA_IN_PROGRESS) |
| 529 | return NULL; |
| 530 | |
| 531 | mxs_chan->status = DMA_IN_PROGRESS; |
| 532 | mxs_chan->flags |= MXS_DMA_SG_LOOP; |
| 533 | |
| 534 | if (num_periods > NUM_CCW) { |
| 535 | dev_err(mxs_dma->dma_device.dev, |
| 536 | "maximum number of sg exceeded: %d > %d\n", |
| 537 | num_periods, NUM_CCW); |
| 538 | goto err_out; |
| 539 | } |
| 540 | |
| 541 | if (period_len > MAX_XFER_BYTES) { |
| 542 | dev_err(mxs_dma->dma_device.dev, |
| 543 | "maximum period size exceeded: %d > %d\n", |
| 544 | period_len, MAX_XFER_BYTES); |
| 545 | goto err_out; |
| 546 | } |
| 547 | |
| 548 | while (buf < buf_len) { |
| 549 | struct mxs_dma_ccw *ccw = &mxs_chan->ccw[i]; |
| 550 | |
| 551 | if (i + 1 == num_periods) |
| 552 | ccw->next = mxs_chan->ccw_phys; |
| 553 | else |
| 554 | ccw->next = mxs_chan->ccw_phys + sizeof(*ccw) * (i + 1); |
| 555 | |
| 556 | ccw->bufaddr = dma_addr; |
| 557 | ccw->xfer_bytes = period_len; |
| 558 | |
| 559 | ccw->bits = 0; |
| 560 | ccw->bits |= CCW_CHAIN; |
| 561 | ccw->bits |= CCW_IRQ; |
| 562 | ccw->bits |= CCW_HALT_ON_TERM; |
| 563 | ccw->bits |= CCW_TERM_FLUSH; |
Vinod Koul | db8196d | 2011-10-13 22:34:23 +0530 | [diff] [blame] | 564 | ccw->bits |= BF_CCW(direction == DMA_DEV_TO_MEM ? |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 565 | MXS_DMA_CMD_WRITE : MXS_DMA_CMD_READ, COMMAND); |
| 566 | |
| 567 | dma_addr += period_len; |
| 568 | buf += period_len; |
| 569 | |
| 570 | i++; |
| 571 | } |
Lothar Waßmann | 6d23ea4 | 2011-12-08 09:15:43 +0100 | [diff] [blame] | 572 | mxs_chan->desc_count = i; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 573 | |
| 574 | return &mxs_chan->desc; |
| 575 | |
| 576 | err_out: |
| 577 | mxs_chan->status = DMA_ERROR; |
| 578 | return NULL; |
| 579 | } |
| 580 | |
| 581 | static int mxs_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, |
| 582 | unsigned long arg) |
| 583 | { |
| 584 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
| 585 | int ret = 0; |
| 586 | |
| 587 | switch (cmd) { |
| 588 | case DMA_TERMINATE_ALL: |
Dong Aisheng | a62bae9 | 2011-07-19 12:09:56 +0800 | [diff] [blame] | 589 | mxs_dma_reset_chan(mxs_chan); |
Lothar Waßmann | 7ad7a34 | 2011-12-08 09:15:44 +0100 | [diff] [blame] | 590 | mxs_dma_disable_chan(mxs_chan); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 591 | break; |
| 592 | case DMA_PAUSE: |
| 593 | mxs_dma_pause_chan(mxs_chan); |
| 594 | break; |
| 595 | case DMA_RESUME: |
| 596 | mxs_dma_resume_chan(mxs_chan); |
| 597 | break; |
| 598 | default: |
| 599 | ret = -ENOSYS; |
| 600 | } |
| 601 | |
| 602 | return ret; |
| 603 | } |
| 604 | |
| 605 | static enum dma_status mxs_dma_tx_status(struct dma_chan *chan, |
| 606 | dma_cookie_t cookie, struct dma_tx_state *txstate) |
| 607 | { |
| 608 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
| 609 | dma_cookie_t last_used; |
| 610 | |
| 611 | last_used = chan->cookie; |
Russell King - ARM Linux | 4d4e58d | 2012-03-06 22:34:06 +0000 | [diff] [blame] | 612 | dma_set_tx_state(txstate, chan->completed_cookie, last_used, 0); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 613 | |
| 614 | return mxs_chan->status; |
| 615 | } |
| 616 | |
| 617 | static void mxs_dma_issue_pending(struct dma_chan *chan) |
| 618 | { |
Shawn Guo | d04525e | 2012-04-11 13:29:31 +0800 | [diff] [blame] | 619 | struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); |
| 620 | |
| 621 | mxs_dma_enable_chan(mxs_chan); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma) |
| 625 | { |
| 626 | int ret; |
| 627 | |
Shawn Guo | 759a2e3 | 2011-12-20 13:54:00 +0800 | [diff] [blame] | 628 | ret = clk_prepare_enable(mxs_dma->clk); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 629 | if (ret) |
Lothar Waßmann | feb397d | 2011-12-08 09:15:42 +0100 | [diff] [blame] | 630 | return ret; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 631 | |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 632 | ret = stmp_reset_block(mxs_dma->base); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 633 | if (ret) |
| 634 | goto err_out; |
| 635 | |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 636 | /* enable apbh burst */ |
Shawn Guo | bb11fb6 | 2012-05-07 14:14:08 +0800 | [diff] [blame] | 637 | if (dma_is_apbh(mxs_dma)) { |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 638 | writel(BM_APBH_CTRL0_APB_BURST_EN, |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 639 | mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 640 | writel(BM_APBH_CTRL0_APB_BURST8_EN, |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 641 | mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | /* enable irq for all the channels */ |
| 645 | writel(MXS_DMA_CHANNELS_MASK << MXS_DMA_CHANNELS, |
Dong Aisheng | f5b7efc | 2012-05-04 20:12:15 +0800 | [diff] [blame] | 646 | mxs_dma->base + HW_APBHX_CTRL1 + STMP_OFFSET_REG_SET); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 647 | |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 648 | err_out: |
Linus Torvalds | 57f2685 | 2012-01-17 18:40:24 -0800 | [diff] [blame] | 649 | clk_disable_unprepare(mxs_dma->clk); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 650 | return ret; |
| 651 | } |
| 652 | |
| 653 | static int __init mxs_dma_probe(struct platform_device *pdev) |
| 654 | { |
| 655 | const struct platform_device_id *id_entry = |
| 656 | platform_get_device_id(pdev); |
Shawn Guo | 8c92013 | 2012-05-10 06:23:26 +0800 | [diff] [blame^] | 657 | const struct mxs_dma_type *dma_type = |
| 658 | (struct mxs_dma_type *)id_entry->driver_data; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 659 | struct mxs_dma_engine *mxs_dma; |
| 660 | struct resource *iores; |
| 661 | int ret, i; |
| 662 | |
| 663 | mxs_dma = kzalloc(sizeof(*mxs_dma), GFP_KERNEL); |
| 664 | if (!mxs_dma) |
| 665 | return -ENOMEM; |
| 666 | |
Shawn Guo | 8c92013 | 2012-05-10 06:23:26 +0800 | [diff] [blame^] | 667 | mxs_dma->dev_id = dma_type->id; |
| 668 | mxs_dma->type = dma_type->type; |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 669 | |
| 670 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 671 | |
| 672 | if (!request_mem_region(iores->start, resource_size(iores), |
| 673 | pdev->name)) { |
| 674 | ret = -EBUSY; |
| 675 | goto err_request_region; |
| 676 | } |
| 677 | |
| 678 | mxs_dma->base = ioremap(iores->start, resource_size(iores)); |
| 679 | if (!mxs_dma->base) { |
| 680 | ret = -ENOMEM; |
| 681 | goto err_ioremap; |
| 682 | } |
| 683 | |
| 684 | mxs_dma->clk = clk_get(&pdev->dev, NULL); |
| 685 | if (IS_ERR(mxs_dma->clk)) { |
| 686 | ret = PTR_ERR(mxs_dma->clk); |
| 687 | goto err_clk; |
| 688 | } |
| 689 | |
| 690 | dma_cap_set(DMA_SLAVE, mxs_dma->dma_device.cap_mask); |
| 691 | dma_cap_set(DMA_CYCLIC, mxs_dma->dma_device.cap_mask); |
| 692 | |
| 693 | INIT_LIST_HEAD(&mxs_dma->dma_device.channels); |
| 694 | |
| 695 | /* Initialize channel parameters */ |
| 696 | for (i = 0; i < MXS_DMA_CHANNELS; i++) { |
| 697 | struct mxs_dma_chan *mxs_chan = &mxs_dma->mxs_chans[i]; |
| 698 | |
| 699 | mxs_chan->mxs_dma = mxs_dma; |
| 700 | mxs_chan->chan.device = &mxs_dma->dma_device; |
Russell King - ARM Linux | 8ac6954 | 2012-03-06 22:36:27 +0000 | [diff] [blame] | 701 | dma_cookie_init(&mxs_chan->chan); |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 702 | |
| 703 | tasklet_init(&mxs_chan->tasklet, mxs_dma_tasklet, |
| 704 | (unsigned long) mxs_chan); |
| 705 | |
| 706 | |
| 707 | /* Add the channel to mxs_chan list */ |
| 708 | list_add_tail(&mxs_chan->chan.device_node, |
| 709 | &mxs_dma->dma_device.channels); |
| 710 | } |
| 711 | |
| 712 | ret = mxs_dma_init(mxs_dma); |
| 713 | if (ret) |
| 714 | goto err_init; |
| 715 | |
| 716 | mxs_dma->dma_device.dev = &pdev->dev; |
| 717 | |
| 718 | /* mxs_dma gets 65535 bytes maximum sg size */ |
| 719 | mxs_dma->dma_device.dev->dma_parms = &mxs_dma->dma_parms; |
| 720 | dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES); |
| 721 | |
| 722 | mxs_dma->dma_device.device_alloc_chan_resources = mxs_dma_alloc_chan_resources; |
| 723 | mxs_dma->dma_device.device_free_chan_resources = mxs_dma_free_chan_resources; |
| 724 | mxs_dma->dma_device.device_tx_status = mxs_dma_tx_status; |
| 725 | mxs_dma->dma_device.device_prep_slave_sg = mxs_dma_prep_slave_sg; |
| 726 | mxs_dma->dma_device.device_prep_dma_cyclic = mxs_dma_prep_dma_cyclic; |
| 727 | mxs_dma->dma_device.device_control = mxs_dma_control; |
| 728 | mxs_dma->dma_device.device_issue_pending = mxs_dma_issue_pending; |
| 729 | |
| 730 | ret = dma_async_device_register(&mxs_dma->dma_device); |
| 731 | if (ret) { |
| 732 | dev_err(mxs_dma->dma_device.dev, "unable to register\n"); |
| 733 | goto err_init; |
| 734 | } |
| 735 | |
| 736 | dev_info(mxs_dma->dma_device.dev, "initialized\n"); |
| 737 | |
| 738 | return 0; |
| 739 | |
| 740 | err_init: |
| 741 | clk_put(mxs_dma->clk); |
| 742 | err_clk: |
| 743 | iounmap(mxs_dma->base); |
| 744 | err_ioremap: |
| 745 | release_mem_region(iores->start, resource_size(iores)); |
| 746 | err_request_region: |
| 747 | kfree(mxs_dma); |
| 748 | return ret; |
| 749 | } |
| 750 | |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 751 | static struct platform_driver mxs_dma_driver = { |
| 752 | .driver = { |
| 753 | .name = "mxs-dma", |
| 754 | }, |
Shawn Guo | 8c92013 | 2012-05-10 06:23:26 +0800 | [diff] [blame^] | 755 | .id_table = mxs_dma_ids, |
Shawn Guo | a580b8c | 2011-02-27 00:47:42 +0800 | [diff] [blame] | 756 | }; |
| 757 | |
| 758 | static int __init mxs_dma_module_init(void) |
| 759 | { |
| 760 | return platform_driver_probe(&mxs_dma_driver, mxs_dma_probe); |
| 761 | } |
| 762 | subsys_initcall(mxs_dma_module_init); |