of_dma.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * OF helpers for DMA request / controller
  3. *
  4. * Based on of_gpio.h
  5. *
  6. * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __LINUX_OF_DMA_H
  13. #define __LINUX_OF_DMA_H
  14. #include <linux/of.h>
  15. #include <linux/dmaengine.h>
  16. struct device_node;
  17. struct of_dma {
  18. struct list_head of_dma_controllers;
  19. struct device_node *of_node;
  20. struct dma_chan *(*of_dma_xlate)
  21. (struct of_phandle_args *, struct of_dma *);
  22. void *of_dma_data;
  23. };
  24. struct of_dma_filter_info {
  25. dma_cap_mask_t dma_cap;
  26. dma_filter_fn filter_fn;
  27. };
  28. #ifdef CONFIG_OF
  29. extern int of_dma_controller_register(struct device_node *np,
  30. struct dma_chan *(*of_dma_xlate)
  31. (struct of_phandle_args *, struct of_dma *),
  32. void *data);
  33. extern void of_dma_controller_free(struct device_node *np);
  34. extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
  35. const char *name);
  36. extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
  37. struct of_dma *ofdma);
  38. extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec,
  39. struct of_dma *ofdma);
  40. #else
  41. static inline int of_dma_controller_register(struct device_node *np,
  42. struct dma_chan *(*of_dma_xlate)
  43. (struct of_phandle_args *, struct of_dma *),
  44. void *data)
  45. {
  46. return -ENODEV;
  47. }
  48. static inline void of_dma_controller_free(struct device_node *np)
  49. {
  50. }
  51. static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
  52. const char *name)
  53. {
  54. return NULL;
  55. }
  56. static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
  57. struct of_dma *ofdma)
  58. {
  59. return NULL;
  60. }
  61. #define of_dma_xlate_by_chan_id NULL
  62. #endif
  63. #endif /* __LINUX_OF_DMA_H */