shdma.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/device.h>
  16. #include <linux/dmapool.h>
  17. #include <linux/dmaengine.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 list_head tx_list;
  26. struct sh_dmae_regs hw;
  27. struct list_head node;
  28. struct dma_async_tx_descriptor async_tx;
  29. int mark;
  30. };
  31. struct sh_dmae_chan {
  32. dma_cookie_t completed_cookie; /* The maximum cookie completed */
  33. spinlock_t desc_lock; /* Descriptor operation lock */
  34. struct list_head ld_queue; /* Link descriptors queue */
  35. struct list_head ld_free; /* Link descriptors free */
  36. struct dma_chan common; /* DMA common channel */
  37. struct device *dev; /* Channel device */
  38. struct tasklet_struct tasklet; /* Tasklet */
  39. int descs_allocated; /* desc count */
  40. int id; /* Raw id of this channel */
  41. char dev_id[16]; /* unique name per DMAC of channel */
  42. /* Set chcr */
  43. int (*set_chcr)(struct sh_dmae_chan *sh_chan, u32 regs);
  44. /* Set DMA resource */
  45. int (*set_dmars)(struct sh_dmae_chan *sh_chan, u16 res);
  46. };
  47. struct sh_dmae_device {
  48. struct dma_device common;
  49. struct sh_dmae_chan *chan[MAX_DMA_CHANNELS];
  50. struct sh_dmae_pdata pdata;
  51. };
  52. #define to_sh_chan(chan) container_of(chan, struct sh_dmae_chan, common)
  53. #define to_sh_desc(lh) container_of(lh, struct sh_desc, node)
  54. #define tx_to_sh_desc(tx) container_of(tx, struct sh_desc, async_tx)
  55. #endif /* __DMA_SHDMA_H */