dma.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* linux/arch/arm/plat-s3c/dma.c
  2. *
  3. * Copyright (c) 2003-2005,2006,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. #include <plat/dma-plat.h>
  20. /* dma channel state information */
  21. struct s3c2410_dma_chan s3c2410_chans[S3C_DMA_CHANNELS];
  22. struct s3c2410_dma_chan *s3c_dma_chan_map[DMACH_MAX];
  23. /* s3c_dma_lookup_channel
  24. *
  25. * change the dma channel number given into a real dma channel id
  26. */
  27. struct s3c2410_dma_chan *s3c_dma_lookup_channel(unsigned int channel)
  28. {
  29. if (channel & DMACH_LOW_LEVEL)
  30. return &s3c2410_chans[channel & ~DMACH_LOW_LEVEL];
  31. else
  32. return s3c_dma_chan_map[channel];
  33. }
  34. /* do we need to protect the settings of the fields from
  35. * irq?
  36. */
  37. int s3c2410_dma_set_opfn(unsigned int channel, s3c2410_dma_opfn_t rtn)
  38. {
  39. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  40. if (chan == NULL)
  41. return -EINVAL;
  42. pr_debug("%s: chan=%p, op rtn=%p\n", __func__, chan, rtn);
  43. chan->op_fn = rtn;
  44. return 0;
  45. }
  46. EXPORT_SYMBOL(s3c2410_dma_set_opfn);
  47. int s3c2410_dma_set_buffdone_fn(unsigned int channel, s3c2410_dma_cbfn_t rtn)
  48. {
  49. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  50. if (chan == NULL)
  51. return -EINVAL;
  52. pr_debug("%s: chan=%p, callback rtn=%p\n", __func__, chan, rtn);
  53. chan->callback_fn = rtn;
  54. return 0;
  55. }
  56. EXPORT_SYMBOL(s3c2410_dma_set_buffdone_fn);
  57. int s3c2410_dma_setflags(unsigned int channel, unsigned int flags)
  58. {
  59. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  60. if (chan == NULL)
  61. return -EINVAL;
  62. chan->flags = flags;
  63. return 0;
  64. }
  65. EXPORT_SYMBOL(s3c2410_dma_setflags);