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