shdma.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Renesas SuperH DMA Engine support
  3. *
  4. * Copyright (C) 2009 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
  5. * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. */
  13. #ifndef __DMA_SHDMA_H
  14. #define __DMA_SHDMA_H
  15. #include <linux/dmaengine.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/list.h>
  18. #define SH_DMA_TCR_MAX 0x00FFFFFF /* 16MB */
  19. struct sh_dmae_regs {
  20. u32 sar; /* SAR / source address */
  21. u32 dar; /* DAR / destination address */
  22. u32 tcr; /* TCR / transfer count */
  23. };
  24. struct sh_desc {
  25. struct sh_dmae_regs hw;
  26. struct list_head node;
  27. struct dma_async_tx_descriptor async_tx;
  28. dma_cookie_t cookie;
  29. int chunks;
  30. int mark;
  31. };
  32. struct device;
  33. struct sh_dmae_chan {
  34. dma_cookie_t completed_cookie; /* The maximum cookie completed */
  35. spinlock_t desc_lock; /* Descriptor operation lock */
  36. struct list_head ld_queue; /* Link descriptors queue */
  37. struct list_head ld_free; /* Link descriptors free */
  38. struct dma_chan common; /* DMA common channel */
  39. struct device *dev; /* Channel device */
  40. struct tasklet_struct tasklet; /* Tasklet */
  41. int descs_allocated; /* desc count */
  42. int id; /* Raw id of this channel */
  43. char dev_id[16]; /* unique name per DMAC of channel */
  44. /* Set chcr */
  45. int (*set_chcr)(struct sh_dmae_chan *sh_chan, u32 regs);
  46. /* Set DMA resource */
  47. int (*set_dmars)(struct sh_dmae_chan *sh_chan, u16 res);
  48. };
  49. struct sh_dmae_device {
  50. struct dma_device common;
  51. struct sh_dmae_chan *chan[MAX_DMA_CHANNELS];
  52. struct sh_dmae_pdata pdata;
  53. };
  54. #define to_sh_chan(chan) container_of(chan, struct sh_dmae_chan, common)
  55. #define to_sh_desc(lh) container_of(lh, struct sh_desc, node)
  56. #define tx_to_sh_desc(tx) container_of(tx, struct sh_desc, async_tx)
  57. #endif /* __DMA_SHDMA_H */