Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Renesas SuperH DMA Engine support |
| 3 | * |
| 4 | * Copyright (C) 2009 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com> |
| 5 | * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved. |
| 6 | * |
| 7 | * This is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | */ |
| 13 | #ifndef __DMA_SHDMA_H |
| 14 | #define __DMA_SHDMA_H |
| 15 | |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 16 | #include <linux/dmaengine.h> |
Guennadi Liakhovetski | 3542a11 | 2009-12-17 09:41:39 -0700 | [diff] [blame] | 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/list.h> |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 19 | |
Guennadi Liakhovetski | 8b1935e | 2010-02-11 16:50:14 +0000 | [diff] [blame^] | 20 | #include <asm/dmaengine.h> |
| 21 | |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 22 | #define SH_DMA_TCR_MAX 0x00FFFFFF /* 16MB */ |
| 23 | |
| 24 | struct sh_dmae_regs { |
| 25 | u32 sar; /* SAR / source address */ |
| 26 | u32 dar; /* DAR / destination address */ |
| 27 | u32 tcr; /* TCR / transfer count */ |
| 28 | }; |
| 29 | |
| 30 | struct sh_desc { |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 31 | struct sh_dmae_regs hw; |
| 32 | struct list_head node; |
| 33 | struct dma_async_tx_descriptor async_tx; |
Guennadi Liakhovetski | cfefe99 | 2010-02-03 14:46:41 +0000 | [diff] [blame] | 34 | enum dma_data_direction direction; |
Guennadi Liakhovetski | 3542a11 | 2009-12-17 09:41:39 -0700 | [diff] [blame] | 35 | dma_cookie_t cookie; |
| 36 | int chunks; |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 37 | int mark; |
| 38 | }; |
| 39 | |
Guennadi Liakhovetski | 3542a11 | 2009-12-17 09:41:39 -0700 | [diff] [blame] | 40 | struct device; |
| 41 | |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 42 | struct sh_dmae_chan { |
| 43 | dma_cookie_t completed_cookie; /* The maximum cookie completed */ |
Guennadi Liakhovetski | 86d61b3 | 2009-12-10 18:35:07 +0100 | [diff] [blame] | 44 | spinlock_t desc_lock; /* Descriptor operation lock */ |
| 45 | struct list_head ld_queue; /* Link descriptors queue */ |
| 46 | struct list_head ld_free; /* Link descriptors free */ |
| 47 | struct dma_chan common; /* DMA common channel */ |
| 48 | struct device *dev; /* Channel device */ |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 49 | struct tasklet_struct tasklet; /* Tasklet */ |
Guennadi Liakhovetski | 86d61b3 | 2009-12-10 18:35:07 +0100 | [diff] [blame] | 50 | int descs_allocated; /* desc count */ |
Guennadi Liakhovetski | cfefe99 | 2010-02-03 14:46:41 +0000 | [diff] [blame] | 51 | int xmit_shift; /* log_2(bytes_per_xfer) */ |
Guennadi Liakhovetski | 027811b | 2010-02-11 16:50:10 +0000 | [diff] [blame] | 52 | int irq; |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 53 | int id; /* Raw id of this channel */ |
Guennadi Liakhovetski | 027811b | 2010-02-11 16:50:10 +0000 | [diff] [blame] | 54 | u32 __iomem *base; |
Guennadi Liakhovetski | 86d61b3 | 2009-12-10 18:35:07 +0100 | [diff] [blame] | 55 | char dev_id[16]; /* unique name per DMAC of channel */ |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | struct sh_dmae_device { |
| 59 | struct dma_device common; |
Guennadi Liakhovetski | 8b1935e | 2010-02-11 16:50:14 +0000 | [diff] [blame^] | 60 | struct sh_dmae_chan *chan[SH_DMAC_MAX_CHANNELS]; |
Guennadi Liakhovetski | 027811b | 2010-02-11 16:50:10 +0000 | [diff] [blame] | 61 | struct sh_dmae_pdata *pdata; |
| 62 | u32 __iomem *chan_reg; |
| 63 | u16 __iomem *dmars; |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | #define to_sh_chan(chan) container_of(chan, struct sh_dmae_chan, common) |
| 67 | #define to_sh_desc(lh) container_of(lh, struct sh_desc, node) |
| 68 | #define tx_to_sh_desc(tx) container_of(tx, struct sh_desc, async_tx) |
| 69 | |
| 70 | #endif /* __DMA_SHDMA_H */ |