| 
									
										
										
										
											2010-01-29 09:02:16 +00:00
										 |  |  | /* linux/arch/arm/plat-samsung/dma.c
 | 
					
						
							| 
									
										
										
										
											2009-03-19 15:02:39 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2009-11-13 22:54:14 +00:00
										 |  |  |  * Copyright (c) 2003-2009 Simtec Electronics | 
					
						
							| 
									
										
										
										
											2009-03-19 15:02:39 +00:00
										 |  |  |  *	Ben Dooks <ben@simtec.co.uk> | 
					
						
							|  |  |  |  *	http://armlinux.simtec.co.uk/
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * S3C DMA core | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct s3c2410_dma_buf; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/module.h>
 | 
					
						
							|  |  |  | #include <linux/errno.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <mach/dma.h>
 | 
					
						
							|  |  |  | #include <mach/irqs.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* dma channel state information */ | 
					
						
							|  |  |  | struct s3c2410_dma_chan s3c2410_chans[S3C_DMA_CHANNELS]; | 
					
						
							|  |  |  | struct s3c2410_dma_chan *s3c_dma_chan_map[DMACH_MAX]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* s3c_dma_lookup_channel
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * change the dma channel number given into a real dma channel id | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct s3c2410_dma_chan *s3c_dma_lookup_channel(unsigned int channel) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (channel & DMACH_LOW_LEVEL) | 
					
						
							|  |  |  | 		return &s3c2410_chans[channel & ~DMACH_LOW_LEVEL]; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return s3c_dma_chan_map[channel]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* do we need to protect the settings of the fields from
 | 
					
						
							|  |  |  |  * irq? | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-16 15:50:19 +09:00
										 |  |  | int s3c2410_dma_set_opfn(enum dma_ch channel, s3c2410_dma_opfn_t rtn) | 
					
						
							| 
									
										
										
										
											2009-03-19 15:02:39 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (chan == NULL) | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pr_debug("%s: chan=%p, op rtn=%p\n", __func__, chan, rtn); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	chan->op_fn = rtn; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | EXPORT_SYMBOL(s3c2410_dma_set_opfn); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-16 15:50:19 +09:00
										 |  |  | int s3c2410_dma_set_buffdone_fn(enum dma_ch channel, s3c2410_dma_cbfn_t rtn) | 
					
						
							| 
									
										
										
										
											2009-03-19 15:02:39 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (chan == NULL) | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pr_debug("%s: chan=%p, callback rtn=%p\n", __func__, chan, rtn); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	chan->callback_fn = rtn; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | EXPORT_SYMBOL(s3c2410_dma_set_buffdone_fn); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-16 15:50:19 +09:00
										 |  |  | int s3c2410_dma_setflags(enum dma_ch channel, unsigned int flags) | 
					
						
							| 
									
										
										
										
											2009-03-19 15:02:39 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (chan == NULL) | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	chan->flags = flags; | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | EXPORT_SYMBOL(s3c2410_dma_setflags); |