acpi_dma.h 3.2 KB

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