2008-08-05 23:14:15 +08:00
|
|
|
/* arch/arm/mach-s3c2410/include/mach/dma.h
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2009-11-14 06:54:14 +08:00
|
|
|
* Copyright (C) 2003-2006 Simtec Electronics
|
2005-04-17 06:20:36 +08:00
|
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
|
|
*
|
2009-03-19 23:02:35 +08:00
|
|
|
* Samsung S3C24XX DMA support
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ASM_ARCH_DMA_H
|
|
|
|
#define __ASM_ARCH_DMA_H __FILE__
|
|
|
|
|
2011-12-22 08:01:38 +08:00
|
|
|
#include <linux/device.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define MAX_DMA_TRANSFER_SIZE 0x100000 /* Data Unit is half word */
|
|
|
|
|
2006-09-16 06:42:24 +08:00
|
|
|
/* We use `virtual` dma channels to hide the fact we have only a limited
|
2011-03-31 09:57:33 +08:00
|
|
|
* number of DMA channels, and not of all of them (dependent on the device)
|
2006-09-16 06:42:24 +08:00
|
|
|
* can be attached to any DMA source. We therefore let the DMA core handle
|
|
|
|
* the allocation of hardware channels to clients.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum dma_ch {
|
|
|
|
DMACH_XD0,
|
|
|
|
DMACH_XD1,
|
|
|
|
DMACH_SDI,
|
|
|
|
DMACH_SPI0,
|
|
|
|
DMACH_SPI1,
|
|
|
|
DMACH_UART0,
|
|
|
|
DMACH_UART1,
|
|
|
|
DMACH_UART2,
|
|
|
|
DMACH_TIMER,
|
|
|
|
DMACH_I2S_IN,
|
|
|
|
DMACH_I2S_OUT,
|
|
|
|
DMACH_PCM_IN,
|
|
|
|
DMACH_PCM_OUT,
|
|
|
|
DMACH_MIC_IN,
|
|
|
|
DMACH_USB_EP1,
|
|
|
|
DMACH_USB_EP2,
|
|
|
|
DMACH_USB_EP3,
|
|
|
|
DMACH_USB_EP4,
|
2006-09-19 06:52:03 +08:00
|
|
|
DMACH_UART0_SRC2, /* s3c2412 second uart sources */
|
|
|
|
DMACH_UART1_SRC2,
|
|
|
|
DMACH_UART2_SRC2,
|
2007-02-17 22:05:17 +08:00
|
|
|
DMACH_UART3, /* s3c2443 has extra uart */
|
|
|
|
DMACH_UART3_SRC2,
|
2012-04-25 09:06:53 +08:00
|
|
|
DMACH_SPI0_TX, /* s3c2443/2416/2450 hsspi0 */
|
|
|
|
DMACH_SPI0_RX, /* s3c2443/2416/2450 hsspi0 */
|
|
|
|
DMACH_SPI1_TX, /* s3c2443/2450 hsspi1 */
|
|
|
|
DMACH_SPI1_RX, /* s3c2443/2450 hsspi1 */
|
2006-09-16 06:42:24 +08:00
|
|
|
DMACH_MAX, /* the end entry */
|
|
|
|
};
|
|
|
|
|
2011-09-02 08:44:43 +08:00
|
|
|
static inline bool samsung_dma_has_circular(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-02 08:44:35 +08:00
|
|
|
static inline bool samsung_dma_is_dmadev(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <plat/dma.h>
|
|
|
|
|
2006-09-16 06:42:24 +08:00
|
|
|
#define DMACH_LOW_LEVEL (1<<28) /* use this to specifiy hardware ch no */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* we have 4 dma channels */
|
2009-08-19 21:31:03 +08:00
|
|
|
#if !defined(CONFIG_CPU_S3C2443) && !defined(CONFIG_CPU_S3C2416)
|
2009-03-19 23:02:39 +08:00
|
|
|
#define S3C_DMA_CHANNELS (4)
|
2007-02-17 22:05:17 +08:00
|
|
|
#else
|
2009-03-19 23:02:39 +08:00
|
|
|
#define S3C_DMA_CHANNELS (6)
|
2007-02-17 22:05:17 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* types */
|
|
|
|
|
2006-08-31 22:26:37 +08:00
|
|
|
enum s3c2410_dma_state {
|
2005-04-17 06:20:36 +08:00
|
|
|
S3C2410_DMA_IDLE,
|
|
|
|
S3C2410_DMA_RUNNING,
|
|
|
|
S3C2410_DMA_PAUSED
|
2006-08-31 22:26:37 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-08-31 22:26:37 +08:00
|
|
|
/* enum s3c2410_dma_loadst
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* This represents the state of the DMA engine, wrt to the loaded / running
|
|
|
|
* transfers. Since we don't have any way of knowing exactly the state of
|
|
|
|
* the DMA transfers, we need to know the state to make decisions on wether
|
|
|
|
* we can
|
|
|
|
*
|
|
|
|
* S3C2410_DMA_NONE
|
|
|
|
*
|
|
|
|
* There are no buffers loaded (the channel should be inactive)
|
|
|
|
*
|
|
|
|
* S3C2410_DMA_1LOADED
|
|
|
|
*
|
|
|
|
* There is one buffer loaded, however it has not been confirmed to be
|
|
|
|
* loaded by the DMA engine. This may be because the channel is not
|
|
|
|
* yet running, or the DMA driver decided that it was too costly to
|
|
|
|
* sit and wait for it to happen.
|
|
|
|
*
|
|
|
|
* S3C2410_DMA_1RUNNING
|
|
|
|
*
|
|
|
|
* The buffer has been confirmed running, and not finisged
|
|
|
|
*
|
|
|
|
* S3C2410_DMA_1LOADED_1RUNNING
|
|
|
|
*
|
|
|
|
* There is a buffer waiting to be loaded by the DMA engine, and one
|
|
|
|
* currently running.
|
|
|
|
*/
|
|
|
|
|
2006-08-31 22:26:37 +08:00
|
|
|
enum s3c2410_dma_loadst {
|
2005-04-17 06:20:36 +08:00
|
|
|
S3C2410_DMALOAD_NONE,
|
|
|
|
S3C2410_DMALOAD_1LOADED,
|
|
|
|
S3C2410_DMALOAD_1RUNNING,
|
|
|
|
S3C2410_DMALOAD_1LOADED_1RUNNING,
|
2006-08-31 22:26:37 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
|
|
|
#define S3C2410_DMAF_SLOW (1<<0) /* slow, so don't worry about
|
|
|
|
* waiting for reloads */
|
|
|
|
#define S3C2410_DMAF_AUTOSTART (1<<1) /* auto-start if buffer queued */
|
|
|
|
|
2009-09-22 23:48:56 +08:00
|
|
|
#define S3C2410_DMAF_CIRCULAR (1 << 2) /* no circular dma support */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* dma buffer */
|
|
|
|
|
2009-03-19 23:02:37 +08:00
|
|
|
struct s3c2410_dma_buf;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-03-19 23:02:37 +08:00
|
|
|
/* s3c2410_dma_buf
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* internally used buffer structure to describe a queued or running
|
|
|
|
* buffer.
|
|
|
|
*/
|
|
|
|
|
2006-08-31 22:26:37 +08:00
|
|
|
struct s3c2410_dma_buf {
|
2006-08-31 22:26:41 +08:00
|
|
|
struct s3c2410_dma_buf *next;
|
|
|
|
int magic; /* magic */
|
|
|
|
int size; /* buffer size in bytes */
|
|
|
|
dma_addr_t data; /* start of DMA data */
|
|
|
|
dma_addr_t ptr; /* where the DMA got to [1] */
|
|
|
|
void *id; /* client's id */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* [1] is this updated for both recv/send modes? */
|
|
|
|
|
2006-08-31 22:26:37 +08:00
|
|
|
struct s3c2410_dma_stats {
|
2006-08-31 22:26:41 +08:00
|
|
|
unsigned long loads;
|
|
|
|
unsigned long timeout_longest;
|
|
|
|
unsigned long timeout_shortest;
|
|
|
|
unsigned long timeout_avg;
|
|
|
|
unsigned long timeout_failed;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2006-09-16 06:42:24 +08:00
|
|
|
struct s3c2410_dma_map;
|
|
|
|
|
2006-08-31 22:26:37 +08:00
|
|
|
/* struct s3c2410_dma_chan
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* full state information for each DMA channel
|
|
|
|
*/
|
|
|
|
|
2006-08-31 22:26:37 +08:00
|
|
|
struct s3c2410_dma_chan {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* channel state flags and information */
|
2006-08-31 22:26:41 +08:00
|
|
|
unsigned char number; /* number of this dma channel */
|
|
|
|
unsigned char in_use; /* channel allocated */
|
|
|
|
unsigned char irq_claimed; /* irq claimed for channel */
|
|
|
|
unsigned char irq_enabled; /* irq enabled for channel */
|
|
|
|
unsigned char xfer_unit; /* size of an transfer */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* channel state */
|
|
|
|
|
2006-08-31 22:26:41 +08:00
|
|
|
enum s3c2410_dma_state state;
|
|
|
|
enum s3c2410_dma_loadst load_state;
|
|
|
|
struct s3c2410_dma_client *client;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* channel configuration */
|
2011-09-02 08:44:44 +08:00
|
|
|
enum dma_data_direction source;
|
2009-03-19 23:02:34 +08:00
|
|
|
enum dma_ch req_ch;
|
2006-08-31 22:26:41 +08:00
|
|
|
unsigned long dev_addr;
|
|
|
|
unsigned long load_timeout;
|
|
|
|
unsigned int flags; /* channel flags */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-16 06:42:24 +08:00
|
|
|
struct s3c24xx_dma_map *map; /* channel hw maps */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* channel's hardware position and configuration */
|
2006-08-31 22:26:41 +08:00
|
|
|
void __iomem *regs; /* channels registers */
|
|
|
|
void __iomem *addr_reg; /* data address register */
|
|
|
|
unsigned int irq; /* channel irq */
|
|
|
|
unsigned long dcon; /* default value of DCON */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* driver handles */
|
2006-08-31 22:26:41 +08:00
|
|
|
s3c2410_dma_cbfn_t callback_fn; /* buffer done callback */
|
|
|
|
s3c2410_dma_opfn_t op_fn; /* channel op callback */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* stats gathering */
|
2006-08-31 22:26:41 +08:00
|
|
|
struct s3c2410_dma_stats *stats;
|
|
|
|
struct s3c2410_dma_stats stats_store;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* buffer list and information */
|
2006-08-31 22:26:41 +08:00
|
|
|
struct s3c2410_dma_buf *curr; /* current dma buffer */
|
|
|
|
struct s3c2410_dma_buf *next; /* next buffer to load */
|
|
|
|
struct s3c2410_dma_buf *end; /* end of queue */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* system device */
|
2011-12-22 08:01:38 +08:00
|
|
|
struct device dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef unsigned long dma_device_t;
|
|
|
|
|
|
|
|
#endif /* __ASM_ARCH_DMA_H */
|