of_dma.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_route_allocate)
  23. (struct of_phandle_args *, struct of_dma *);
  24. struct dma_router *dma_router;
  25. void *of_dma_data;
  26. };
  27. struct of_dma_filter_info {
  28. dma_cap_mask_t dma_cap;
  29. dma_filter_fn filter_fn;
  30. };
  31. #ifdef CONFIG_DMA_OF
  32. extern int of_dma_controller_register(struct device_node *np,
  33. struct dma_chan *(*of_dma_xlate)
  34. (struct of_phandle_args *, struct of_dma *),
  35. void *data);
  36. extern void of_dma_controller_free(struct device_node *np);
  37. extern int of_dma_router_register(struct device_node *np,
  38. void *(*of_dma_route_allocate)
  39. (struct of_phandle_args *, struct of_dma *),
  40. struct dma_router *dma_router);
  41. #define of_dma_router_free of_dma_controller_free
  42. extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
  43. const char *name);
  44. extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
  45. struct of_dma *ofdma);
  46. extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec,
  47. struct of_dma *ofdma);
  48. #else
  49. static inline int of_dma_controller_register(struct device_node *np,
  50. struct dma_chan *(*of_dma_xlate)
  51. (struct of_phandle_args *, struct of_dma *),
  52. void *data)
  53. {
  54. return -ENODEV;
  55. }
  56. static inline void of_dma_controller_free(struct device_node *np)
  57. {
  58. }
  59. static inline int of_dma_router_register(struct device_node *np,
  60. void *(*of_dma_route_allocate)
  61. (struct of_phandle_args *, struct of_dma *),
  62. struct dma_router *dma_router)
  63. {
  64. return -ENODEV;
  65. }
  66. #define of_dma_router_free of_dma_controller_free
  67. static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
  68. const char *name)
  69. {
  70. return ERR_PTR(-ENODEV);
  71. }
  72. static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
  73. struct of_dma *ofdma)
  74. {
  75. return NULL;
  76. }
  77. #define of_dma_xlate_by_chan_id NULL
  78. #endif
  79. #endif /* __LINUX_OF_DMA_H */