blob: 800fd884be835f8af2cd9ae93243a0c5bf4e00cb [file] [log] [blame]
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +00001/*
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 Iwamatsud8902ad2009-09-07 03:26:23 +000016#include <linux/dmaengine.h>
Guennadi Liakhovetski3542a112009-12-17 09:41:39 -070017#include <linux/interrupt.h>
18#include <linux/list.h>
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000019
20#define SH_DMA_TCR_MAX 0x00FFFFFF /* 16MB */
21
22struct sh_dmae_regs {
23 u32 sar; /* SAR / source address */
24 u32 dar; /* DAR / destination address */
25 u32 tcr; /* TCR / transfer count */
26};
27
28struct sh_desc {
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000029 struct sh_dmae_regs hw;
30 struct list_head node;
31 struct dma_async_tx_descriptor async_tx;
Guennadi Liakhovetskicfefe992010-02-03 14:46:41 +000032 enum dma_data_direction direction;
Guennadi Liakhovetski3542a112009-12-17 09:41:39 -070033 dma_cookie_t cookie;
34 int chunks;
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000035 int mark;
36};
37
Guennadi Liakhovetski3542a112009-12-17 09:41:39 -070038struct device;
39
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000040struct sh_dmae_chan {
41 dma_cookie_t completed_cookie; /* The maximum cookie completed */
Guennadi Liakhovetski86d61b32009-12-10 18:35:07 +010042 spinlock_t desc_lock; /* Descriptor operation lock */
43 struct list_head ld_queue; /* Link descriptors queue */
44 struct list_head ld_free; /* Link descriptors free */
45 struct dma_chan common; /* DMA common channel */
46 struct device *dev; /* Channel device */
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000047 struct tasklet_struct tasklet; /* Tasklet */
Guennadi Liakhovetski86d61b32009-12-10 18:35:07 +010048 int descs_allocated; /* desc count */
Guennadi Liakhovetskicfefe992010-02-03 14:46:41 +000049 int xmit_shift; /* log_2(bytes_per_xfer) */
Guennadi Liakhovetski027811b2010-02-11 16:50:10 +000050 int irq;
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000051 int id; /* Raw id of this channel */
Guennadi Liakhovetski027811b2010-02-11 16:50:10 +000052 u32 __iomem *base;
Guennadi Liakhovetski86d61b32009-12-10 18:35:07 +010053 char dev_id[16]; /* unique name per DMAC of channel */
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000054};
55
56struct sh_dmae_device {
57 struct dma_device common;
58 struct sh_dmae_chan *chan[MAX_DMA_CHANNELS];
Guennadi Liakhovetski027811b2010-02-11 16:50:10 +000059 struct sh_dmae_pdata *pdata;
60 u32 __iomem *chan_reg;
61 u16 __iomem *dmars;
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000062};
63
64#define to_sh_chan(chan) container_of(chan, struct sh_dmae_chan, common)
65#define to_sh_desc(lh) container_of(lh, struct sh_desc, node)
66#define tx_to_sh_desc(tx) container_of(tx, struct sh_desc, async_tx)
67
68#endif /* __DMA_SHDMA_H */