Ben Dooks | 2c420fe | 2010-01-29 09:02:15 +0000 | [diff] [blame] | 1 | /* arch/arm/plat-samsung/include/plat/dma.h |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 2 | * |
Ben Dooks | ccae941 | 2009-11-13 22:54:14 +0000 | [diff] [blame] | 3 | * Copyright (C) 2003-2006 Simtec Electronics |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 4 | * Ben Dooks <ben@simtec.co.uk> |
| 5 | * |
| 6 | * Samsung S3C DMA support |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
Boojin Kim | 51ddf31 | 2011-09-02 09:44:44 +0900 | [diff] [blame^] | 13 | #include <linux/dma-mapping.h> |
| 14 | |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 15 | enum s3c2410_dma_buffresult { |
| 16 | S3C2410_RES_OK, |
| 17 | S3C2410_RES_ERR, |
| 18 | S3C2410_RES_ABORT |
| 19 | }; |
| 20 | |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 21 | /* enum s3c2410_chan_op |
| 22 | * |
| 23 | * operation codes passed to the DMA code by the user, and also used |
| 24 | * to inform the current channel owner of any changes to the system state |
| 25 | */ |
| 26 | |
| 27 | enum s3c2410_chan_op { |
| 28 | S3C2410_DMAOP_START, |
| 29 | S3C2410_DMAOP_STOP, |
| 30 | S3C2410_DMAOP_PAUSE, |
| 31 | S3C2410_DMAOP_RESUME, |
| 32 | S3C2410_DMAOP_FLUSH, |
| 33 | S3C2410_DMAOP_TIMEOUT, /* internal signal to handler */ |
| 34 | S3C2410_DMAOP_STARTED, /* indicate channel started */ |
| 35 | }; |
| 36 | |
| 37 | struct s3c2410_dma_client { |
| 38 | char *name; |
| 39 | }; |
| 40 | |
| 41 | struct s3c2410_dma_chan; |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 42 | enum dma_ch; |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 43 | |
| 44 | /* s3c2410_dma_cbfn_t |
| 45 | * |
| 46 | * buffer callback routine type |
| 47 | */ |
| 48 | |
| 49 | typedef void (*s3c2410_dma_cbfn_t)(struct s3c2410_dma_chan *, |
| 50 | void *buf, int size, |
| 51 | enum s3c2410_dma_buffresult result); |
| 52 | |
| 53 | typedef int (*s3c2410_dma_opfn_t)(struct s3c2410_dma_chan *, |
| 54 | enum s3c2410_chan_op ); |
| 55 | |
| 56 | |
| 57 | |
| 58 | /* s3c2410_dma_request |
| 59 | * |
| 60 | * request a dma channel exclusivley |
| 61 | */ |
| 62 | |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 63 | extern int s3c2410_dma_request(enum dma_ch channel, |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 64 | struct s3c2410_dma_client *, void *dev); |
| 65 | |
| 66 | |
| 67 | /* s3c2410_dma_ctrl |
| 68 | * |
| 69 | * change the state of the dma channel |
| 70 | */ |
| 71 | |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 72 | extern int s3c2410_dma_ctrl(enum dma_ch channel, enum s3c2410_chan_op op); |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 73 | |
| 74 | /* s3c2410_dma_setflags |
| 75 | * |
| 76 | * set the channel's flags to a given state |
| 77 | */ |
| 78 | |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 79 | extern int s3c2410_dma_setflags(enum dma_ch channel, |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 80 | unsigned int flags); |
| 81 | |
| 82 | /* s3c2410_dma_free |
| 83 | * |
| 84 | * free the dma channel (will also abort any outstanding operations) |
| 85 | */ |
| 86 | |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 87 | extern int s3c2410_dma_free(enum dma_ch channel, struct s3c2410_dma_client *); |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 88 | |
| 89 | /* s3c2410_dma_enqueue |
| 90 | * |
| 91 | * place the given buffer onto the queue of operations for the channel. |
| 92 | * The buffer must be allocated from dma coherent memory, or the Dcache/WB |
| 93 | * drained before the buffer is given to the DMA system. |
| 94 | */ |
| 95 | |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 96 | extern int s3c2410_dma_enqueue(enum dma_ch channel, void *id, |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 97 | dma_addr_t data, int size); |
| 98 | |
| 99 | /* s3c2410_dma_config |
| 100 | * |
| 101 | * configure the dma channel |
| 102 | */ |
| 103 | |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 104 | extern int s3c2410_dma_config(enum dma_ch channel, int xferunit); |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 105 | |
| 106 | /* s3c2410_dma_devconfig |
| 107 | * |
| 108 | * configure the device we're talking to |
| 109 | */ |
| 110 | |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 111 | extern int s3c2410_dma_devconfig(enum dma_ch channel, |
Boojin Kim | 51ddf31 | 2011-09-02 09:44:44 +0900 | [diff] [blame^] | 112 | enum dma_data_direction source, unsigned long devaddr); |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 113 | |
| 114 | /* s3c2410_dma_getposition |
| 115 | * |
| 116 | * get the position that the dma transfer is currently at |
| 117 | */ |
| 118 | |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 119 | extern int s3c2410_dma_getposition(enum dma_ch channel, |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 120 | dma_addr_t *src, dma_addr_t *dest); |
| 121 | |
Sangwook Lee | d670ac0 | 2011-07-16 15:50:19 +0900 | [diff] [blame] | 122 | extern int s3c2410_dma_set_opfn(enum dma_ch, s3c2410_dma_opfn_t rtn); |
| 123 | extern int s3c2410_dma_set_buffdone_fn(enum dma_ch, s3c2410_dma_cbfn_t rtn); |
Ben Dooks | c133c29 | 2009-03-19 15:02:37 +0000 | [diff] [blame] | 124 | |
| 125 | |
Boojin Kim | c4e1662 | 2011-09-02 09:44:35 +0900 | [diff] [blame] | 126 | #include <plat/dma-ops.h> |