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 | |
Magnus Damm | d026e00 | 2011-05-24 10:31:28 +0000 | [diff] [blame] | 20 | #define SH_DMAC_MAX_CHANNELS 20 |
Magnus Damm | 02ca508 | 2010-03-19 04:46:47 +0000 | [diff] [blame] | 21 | #define SH_DMA_SLAVE_NUMBER 256 |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 22 | #define SH_DMA_TCR_MAX 0x00FFFFFF /* 16MB */ |
| 23 | |
Guennadi Liakhovetski | 3542a11 | 2009-12-17 09:41:39 -0700 | [diff] [blame] | 24 | struct device; |
| 25 | |
Guennadi Liakhovetski | 7a1cd9a | 2011-08-18 16:55:27 +0200 | [diff] [blame] | 26 | enum dmae_pm_state { |
| 27 | DMAE_PM_ESTABLISHED, |
| 28 | DMAE_PM_BUSY, |
| 29 | DMAE_PM_PENDING, |
| 30 | }; |
| 31 | |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 32 | struct sh_dmae_chan { |
Guennadi Liakhovetski | 86d61b3 | 2009-12-10 18:35:07 +0100 | [diff] [blame] | 33 | spinlock_t desc_lock; /* Descriptor operation lock */ |
| 34 | struct list_head ld_queue; /* Link descriptors queue */ |
| 35 | struct list_head ld_free; /* Link descriptors free */ |
| 36 | struct dma_chan common; /* DMA common channel */ |
| 37 | struct device *dev; /* Channel device */ |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 38 | struct tasklet_struct tasklet; /* Tasklet */ |
Guennadi Liakhovetski | 86d61b3 | 2009-12-10 18:35:07 +0100 | [diff] [blame] | 39 | int descs_allocated; /* desc count */ |
Guennadi Liakhovetski | cfefe99 | 2010-02-03 14:46:41 +0000 | [diff] [blame] | 40 | int xmit_shift; /* log_2(bytes_per_xfer) */ |
Guennadi Liakhovetski | 027811b | 2010-02-11 16:50:10 +0000 | [diff] [blame] | 41 | int irq; |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 42 | int id; /* Raw id of this channel */ |
Guennadi Liakhovetski | 027811b | 2010-02-11 16:50:10 +0000 | [diff] [blame] | 43 | u32 __iomem *base; |
Guennadi Liakhovetski | 86d61b3 | 2009-12-10 18:35:07 +0100 | [diff] [blame] | 44 | char dev_id[16]; /* unique name per DMAC of channel */ |
Guennadi Liakhovetski | 467017b | 2011-04-29 17:09:25 +0000 | [diff] [blame] | 45 | int pm_error; |
Guennadi Liakhovetski | 7a1cd9a | 2011-08-18 16:55:27 +0200 | [diff] [blame] | 46 | enum dmae_pm_state pm_state; |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | struct sh_dmae_device { |
| 50 | struct dma_device common; |
Guennadi Liakhovetski | 8b1935e | 2010-02-11 16:50:14 +0000 | [diff] [blame] | 51 | struct sh_dmae_chan *chan[SH_DMAC_MAX_CHANNELS]; |
Guennadi Liakhovetski | 027811b | 2010-02-11 16:50:10 +0000 | [diff] [blame] | 52 | struct sh_dmae_pdata *pdata; |
Paul Mundt | 03aa18f | 2010-12-17 19:16:10 +0900 | [diff] [blame] | 53 | struct list_head node; |
Guennadi Liakhovetski | 027811b | 2010-02-11 16:50:10 +0000 | [diff] [blame] | 54 | u32 __iomem *chan_reg; |
| 55 | u16 __iomem *dmars; |
Kuninori Morimoto | 5899a72 | 2011-06-17 08:20:40 +0000 | [diff] [blame] | 56 | unsigned int chcr_offset; |
Kuninori Morimoto | 67c6269 | 2011-06-17 08:20:51 +0000 | [diff] [blame] | 57 | u32 chcr_ie_bit; |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | #define to_sh_chan(chan) container_of(chan, struct sh_dmae_chan, common) |
| 61 | #define to_sh_desc(lh) container_of(lh, struct sh_desc, node) |
| 62 | #define tx_to_sh_desc(tx) container_of(tx, struct sh_desc, async_tx) |
Kuninori Morimoto | c4e0dd7 | 2011-06-16 05:08:09 +0000 | [diff] [blame] | 63 | #define to_sh_dev(chan) container_of(chan->common.device,\ |
| 64 | struct sh_dmae_device, common) |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 65 | |
| 66 | #endif /* __DMA_SHDMA_H */ |