acpi_dma.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * ACPI helpers for DMA request / controller
  4. *
  5. * Based on of_dma.h
  6. *
  7. * Copyright (C) 2013, Intel Corporation
  8. * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  9. */
  10. #ifndef __LINUX_ACPI_DMA_H
  11. #define __LINUX_ACPI_DMA_H
  12. #include <linux/list.h>
  13. #include <linux/device.h>
  14. #include <linux/err.h>
  15. #include <linux/dmaengine.h>
  16. /**
  17. * struct acpi_dma_spec - slave device DMA resources
  18. * @chan_id: channel unique id
  19. * @slave_id: request line unique id
  20. * @dev: struct device of the DMA controller to be used in the filter
  21. * function
  22. */
  23. struct acpi_dma_spec {
  24. int chan_id;
  25. int slave_id;
  26. struct device *dev;
  27. };
  28. /**
  29. * struct acpi_dma - representation of the registered DMAC
  30. * @dma_controllers: linked list node
  31. * @dev: struct device of this controller
  32. * @acpi_dma_xlate: callback function to find a suitable channel
  33. * @data: private data used by a callback function
  34. * @base_request_line: first supported request line (CSRT)
  35. * @end_request_line: last supported request line (CSRT)
  36. */
  37. struct acpi_dma {
  38. struct list_head dma_controllers;
  39. struct device *dev;
  40. struct dma_chan *(*acpi_dma_xlate)
  41. (struct acpi_dma_spec *, struct acpi_dma *);
  42. void *data;
  43. unsigned short base_request_line;
  44. unsigned short end_request_line;
  45. };
  46. /* Used with acpi_dma_simple_xlate() */
  47. struct acpi_dma_filter_info {
  48. dma_cap_mask_t dma_cap;
  49. dma_filter_fn filter_fn;
  50. };
  51. #ifdef CONFIG_DMA_ACPI
  52. int acpi_dma_controller_register(struct device *dev,
  53. struct dma_chan *(*acpi_dma_xlate)
  54. (struct acpi_dma_spec *, struct acpi_dma *),
  55. void *data);
  56. int acpi_dma_controller_free(struct device *dev);
  57. int devm_acpi_dma_controller_register(struct device *dev,
  58. struct dma_chan *(*acpi_dma_xlate)
  59. (struct acpi_dma_spec *, struct acpi_dma *),
  60. void *data);
  61. void devm_acpi_dma_controller_free(struct device *dev);
  62. struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
  63. size_t index);
  64. struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
  65. const char *name);
  66. struct dma_chan *acpi_dma_simple_xlate(struct acpi_dma_spec *dma_spec,
  67. struct acpi_dma *adma);
  68. #else
  69. static inline int acpi_dma_controller_register(struct device *dev,
  70. struct dma_chan *(*acpi_dma_xlate)
  71. (struct acpi_dma_spec *, struct acpi_dma *),
  72. void *data)
  73. {
  74. return -ENODEV;
  75. }
  76. static inline int acpi_dma_controller_free(struct device *dev)
  77. {
  78. return -ENODEV;
  79. }
  80. static inline int devm_acpi_dma_controller_register(struct device *dev,
  81. struct dma_chan *(*acpi_dma_xlate)
  82. (struct acpi_dma_spec *, struct acpi_dma *),
  83. void *data)
  84. {
  85. return -ENODEV;
  86. }
  87. static inline void devm_acpi_dma_controller_free(struct device *dev)
  88. {
  89. }
  90. static inline struct dma_chan *acpi_dma_request_slave_chan_by_index(
  91. struct device *dev, size_t index)
  92. {
  93. return ERR_PTR(-ENODEV);
  94. }
  95. static inline struct dma_chan *acpi_dma_request_slave_chan_by_name(
  96. struct device *dev, const char *name)
  97. {
  98. return ERR_PTR(-ENODEV);
  99. }
  100. #define acpi_dma_simple_xlate NULL
  101. #endif
  102. #define acpi_dma_request_slave_channel acpi_dma_request_slave_chan_by_index
  103. #endif /* __LINUX_ACPI_DMA_H */