of_dma.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * OF helpers for DMA request / controller
  4. *
  5. * Based on of_gpio.h
  6. *
  7. * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
  8. */
  9. #ifndef __LINUX_OF_DMA_H
  10. #define __LINUX_OF_DMA_H
  11. #include <linux/of.h>
  12. #include <linux/dmaengine.h>
  13. struct device_node;
  14. struct of_dma {
  15. struct list_head of_dma_controllers;
  16. struct device_node *of_node;
  17. struct dma_chan *(*of_dma_xlate)
  18. (struct of_phandle_args *, struct of_dma *);
  19. void *(*of_dma_route_allocate)
  20. (struct of_phandle_args *, struct of_dma *);
  21. struct dma_router *dma_router;
  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_DMA_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 int of_dma_router_register(struct device_node *np,
  35. void *(*of_dma_route_allocate)
  36. (struct of_phandle_args *, struct of_dma *),
  37. struct dma_router *dma_router);
  38. #define of_dma_router_free of_dma_controller_free
  39. extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
  40. const char *name);
  41. extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
  42. struct of_dma *ofdma);
  43. extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec,
  44. struct of_dma *ofdma);
  45. #else
  46. static inline int of_dma_controller_register(struct device_node *np,
  47. struct dma_chan *(*of_dma_xlate)
  48. (struct of_phandle_args *, struct of_dma *),
  49. void *data)
  50. {
  51. return -ENODEV;
  52. }
  53. static inline void of_dma_controller_free(struct device_node *np)
  54. {
  55. }
  56. static inline int of_dma_router_register(struct device_node *np,
  57. void *(*of_dma_route_allocate)
  58. (struct of_phandle_args *, struct of_dma *),
  59. struct dma_router *dma_router)
  60. {
  61. return -ENODEV;
  62. }
  63. #define of_dma_router_free of_dma_controller_free
  64. static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
  65. const char *name)
  66. {
  67. return ERR_PTR(-ENODEV);
  68. }
  69. static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
  70. struct of_dma *ofdma)
  71. {
  72. return NULL;
  73. }
  74. #define of_dma_xlate_by_chan_id NULL
  75. #endif
  76. #endif /* __LINUX_OF_DMA_H */