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 | |
Guennadi Liakhovetski | ecf90fb | 2012-07-05 12:29:40 +0200 | [diff] [blame] | 16 | #include <linux/sh_dma.h> |
Guennadi Liakhovetski | ce3a1ab | 2012-05-09 17:09:21 +0200 | [diff] [blame] | 17 | #include <linux/shdma-base.h> |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 18 | #include <linux/dmaengine.h> |
Guennadi Liakhovetski | 3542a11 | 2009-12-17 09:41:39 -0700 | [diff] [blame] | 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/list.h> |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 21 | |
Guennadi Liakhovetski | ce3a1ab | 2012-05-09 17:09:21 +0200 | [diff] [blame] | 22 | #define SH_DMAE_MAX_CHANNELS 20 |
| 23 | #define SH_DMAE_TCR_MAX 0x00FFFFFF /* 16MB */ |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 24 | |
Guennadi Liakhovetski | 3542a11 | 2009-12-17 09:41:39 -0700 | [diff] [blame] | 25 | struct device; |
| 26 | |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 27 | struct sh_dmae_chan { |
Guennadi Liakhovetski | ce3a1ab | 2012-05-09 17:09:21 +0200 | [diff] [blame] | 28 | struct shdma_chan shdma_chan; |
Guennadi Liakhovetski | ecf90fb | 2012-07-05 12:29:40 +0200 | [diff] [blame] | 29 | const struct sh_dmae_slave_config *config; /* Slave DMA configuration */ |
Guennadi Liakhovetski | cfefe99 | 2010-02-03 14:46:41 +0000 | [diff] [blame] | 30 | int xmit_shift; /* log_2(bytes_per_xfer) */ |
Guennadi Liakhovetski | 115357e | 2013-07-02 17:46:01 +0200 | [diff] [blame] | 31 | void __iomem *base; |
Guennadi Liakhovetski | 86d61b3 | 2009-12-10 18:35:07 +0100 | [diff] [blame] | 32 | char dev_id[16]; /* unique name per DMAC of channel */ |
Guennadi Liakhovetski | 467017b | 2011-04-29 17:09:25 +0000 | [diff] [blame] | 33 | int pm_error; |
Guennadi Liakhovetski | 4981c4d | 2013-08-02 16:50:36 +0200 | [diff] [blame] | 34 | dma_addr_t slave_addr; |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | struct sh_dmae_device { |
Guennadi Liakhovetski | ce3a1ab | 2012-05-09 17:09:21 +0200 | [diff] [blame] | 38 | struct shdma_dev shdma_dev; |
| 39 | struct sh_dmae_chan *chan[SH_DMAE_MAX_CHANNELS]; |
Guennadi Liakhovetski | 2833c47 | 2013-08-02 16:18:09 +0200 | [diff] [blame] | 40 | const struct sh_dmae_pdata *pdata; |
Paul Mundt | 03aa18f | 2010-12-17 19:16:10 +0900 | [diff] [blame] | 41 | struct list_head node; |
Guennadi Liakhovetski | 115357e | 2013-07-02 17:46:01 +0200 | [diff] [blame] | 42 | void __iomem *chan_reg; |
| 43 | void __iomem *dmars; |
Kuninori Morimoto | 5899a72 | 2011-06-17 08:20:40 +0000 | [diff] [blame] | 44 | unsigned int chcr_offset; |
Kuninori Morimoto | 67c6269 | 2011-06-17 08:20:51 +0000 | [diff] [blame] | 45 | u32 chcr_ie_bit; |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
Guennadi Liakhovetski | ce3a1ab | 2012-05-09 17:09:21 +0200 | [diff] [blame] | 48 | struct sh_dmae_regs { |
| 49 | u32 sar; /* SAR / source address */ |
| 50 | u32 dar; /* DAR / destination address */ |
| 51 | u32 tcr; /* TCR / transfer count */ |
| 52 | }; |
| 53 | |
| 54 | struct sh_dmae_desc { |
| 55 | struct sh_dmae_regs hw; |
| 56 | struct shdma_desc shdma_desc; |
| 57 | }; |
| 58 | |
| 59 | #define to_sh_chan(chan) container_of(chan, struct sh_dmae_chan, shdma_chan) |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 60 | #define to_sh_desc(lh) container_of(lh, struct sh_desc, node) |
| 61 | #define tx_to_sh_desc(tx) container_of(tx, struct sh_desc, async_tx) |
Guennadi Liakhovetski | ce3a1ab | 2012-05-09 17:09:21 +0200 | [diff] [blame] | 62 | #define to_sh_dev(chan) container_of(chan->shdma_chan.dma_chan.device,\ |
| 63 | struct sh_dmae_device, shdma_dev.dma_dev) |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 64 | |
Laurent Pinchart | 9f2c2bb | 2014-07-31 09:34:04 +0900 | [diff] [blame] | 65 | #ifdef CONFIG_SH_DMAE_R8A73A4 |
Guennadi Liakhovetski | 1e69653 | 2013-08-02 16:50:39 +0200 | [diff] [blame] | 66 | extern const struct sh_dmae_pdata r8a73a4_dma_pdata; |
| 67 | #define r8a73a4_shdma_devid (&r8a73a4_dma_pdata) |
| 68 | #else |
| 69 | #define r8a73a4_shdma_devid NULL |
| 70 | #endif |
| 71 | |
Nobuhiro Iwamatsu | d8902ad | 2009-09-07 03:26:23 +0000 | [diff] [blame] | 72 | #endif /* __DMA_SHDMA_H */ |