dma.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* linux/arch/arm/plat-samsung/dma.c
  2. *
  3. * Copyright (c) 2003-2009 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. * http://armlinux.simtec.co.uk/
  6. *
  7. * S3C DMA core
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. struct s3c2410_dma_buf;
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/errno.h>
  17. #include <mach/dma.h>
  18. #include <mach/irqs.h>
  19. /* dma channel state information */
  20. struct s3c2410_dma_chan s3c2410_chans[S3C_DMA_CHANNELS];
  21. struct s3c2410_dma_chan *s3c_dma_chan_map[DMACH_MAX];
  22. /* s3c_dma_lookup_channel
  23. *
  24. * change the dma channel number given into a real dma channel id
  25. */
  26. struct s3c2410_dma_chan *s3c_dma_lookup_channel(unsigned int channel)
  27. {
  28. if (channel & DMACH_LOW_LEVEL)
  29. return &s3c2410_chans[channel & ~DMACH_LOW_LEVEL];
  30. else
  31. return s3c_dma_chan_map[channel];
  32. }
  33. /* do we need to protect the settings of the fields from
  34. * irq?
  35. */
  36. int s3c2410_dma_set_opfn(enum dma_ch channel, s3c2410_dma_opfn_t rtn)
  37. {
  38. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  39. if (chan == NULL)
  40. return -EINVAL;
  41. pr_debug("%s: chan=%p, op rtn=%p\n", __func__, chan, rtn);
  42. chan->op_fn = rtn;
  43. return 0;
  44. }
  45. EXPORT_SYMBOL(s3c2410_dma_set_opfn);
  46. int s3c2410_dma_set_buffdone_fn(enum dma_ch channel, s3c2410_dma_cbfn_t rtn)
  47. {
  48. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  49. if (chan == NULL)
  50. return -EINVAL;
  51. pr_debug("%s: chan=%p, callback rtn=%p\n", __func__, chan, rtn);
  52. chan->callback_fn = rtn;
  53. return 0;
  54. }
  55. EXPORT_SYMBOL(s3c2410_dma_set_buffdone_fn);
  56. int s3c2410_dma_setflags(enum dma_ch channel, unsigned int flags)
  57. {
  58. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  59. if (chan == NULL)
  60. return -EINVAL;
  61. chan->flags = flags;
  62. return 0;
  63. }
  64. EXPORT_SYMBOL(s3c2410_dma_setflags);