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