blob: 2c0a969adc9fb73e7795c1bbdd7b2aa072037827 [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
Guennadi Liakhovetskiecf90fb2012-07-05 12:29:40 +020016#include <linux/sh_dma.h>
Guennadi Liakhovetskice3a1ab2012-05-09 17:09:21 +020017#include <linux/shdma-base.h>
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000018#include <linux/dmaengine.h>
Guennadi Liakhovetski3542a112009-12-17 09:41:39 -070019#include <linux/interrupt.h>
20#include <linux/list.h>
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000021
Guennadi Liakhovetskice3a1ab2012-05-09 17:09:21 +020022#define SH_DMAE_MAX_CHANNELS 20
23#define SH_DMAE_TCR_MAX 0x00FFFFFF /* 16MB */
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000024
Guennadi Liakhovetski3542a112009-12-17 09:41:39 -070025struct device;
26
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000027struct sh_dmae_chan {
Guennadi Liakhovetskice3a1ab2012-05-09 17:09:21 +020028 struct shdma_chan shdma_chan;
Guennadi Liakhovetskiecf90fb2012-07-05 12:29:40 +020029 const struct sh_dmae_slave_config *config; /* Slave DMA configuration */
Guennadi Liakhovetskicfefe992010-02-03 14:46:41 +000030 int xmit_shift; /* log_2(bytes_per_xfer) */
Guennadi Liakhovetski115357e2013-07-02 17:46:01 +020031 void __iomem *base;
Guennadi Liakhovetski86d61b32009-12-10 18:35:07 +010032 char dev_id[16]; /* unique name per DMAC of channel */
Guennadi Liakhovetski467017b2011-04-29 17:09:25 +000033 int pm_error;
Guennadi Liakhovetski4981c4d2013-08-02 16:50:36 +020034 dma_addr_t slave_addr;
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000035};
36
37struct sh_dmae_device {
Guennadi Liakhovetskice3a1ab2012-05-09 17:09:21 +020038 struct shdma_dev shdma_dev;
39 struct sh_dmae_chan *chan[SH_DMAE_MAX_CHANNELS];
Guennadi Liakhovetski2833c472013-08-02 16:18:09 +020040 const struct sh_dmae_pdata *pdata;
Paul Mundt03aa18f2010-12-17 19:16:10 +090041 struct list_head node;
Guennadi Liakhovetski115357e2013-07-02 17:46:01 +020042 void __iomem *chan_reg;
43 void __iomem *dmars;
Kuninori Morimoto5899a722011-06-17 08:20:40 +000044 unsigned int chcr_offset;
Kuninori Morimoto67c62692011-06-17 08:20:51 +000045 u32 chcr_ie_bit;
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000046};
47
Guennadi Liakhovetskice3a1ab2012-05-09 17:09:21 +020048struct sh_dmae_regs {
49 u32 sar; /* SAR / source address */
50 u32 dar; /* DAR / destination address */
51 u32 tcr; /* TCR / transfer count */
52};
53
54struct 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 Iwamatsud8902ad2009-09-07 03:26:23 +000060#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 Liakhovetskice3a1ab2012-05-09 17:09:21 +020062#define to_sh_dev(chan) container_of(chan->shdma_chan.dma_chan.device,\
63 struct sh_dmae_device, shdma_dev.dma_dev)
Nobuhiro Iwamatsud8902ad2009-09-07 03:26:23 +000064
Laurent Pinchart9f2c2bb2014-07-31 09:34:04 +090065#ifdef CONFIG_SH_DMAE_R8A73A4
Guennadi Liakhovetski1e696532013-08-02 16:50:39 +020066extern 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 Iwamatsud8902ad2009-09-07 03:26:23 +000072#endif /* __DMA_SHDMA_H */