at v3.13 3.3 kB view raw
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 14#ifndef __LINUX_ACPI_DMA_H 15#define __LINUX_ACPI_DMA_H 16 17#include <linux/list.h> 18#include <linux/device.h> 19#include <linux/dmaengine.h> 20 21/** 22 * struct acpi_dma_spec - slave device DMA resources 23 * @chan_id: channel unique id 24 * @slave_id: request line unique id 25 * @dev: struct device of the DMA controller to be used in the filter 26 * function 27 */ 28struct acpi_dma_spec { 29 int chan_id; 30 int slave_id; 31 struct device *dev; 32}; 33 34/** 35 * struct acpi_dma - representation of the registered DMAC 36 * @dma_controllers: linked list node 37 * @dev: struct device of this controller 38 * @acpi_dma_xlate: callback function to find a suitable channel 39 * @data: private data used by a callback function 40 * @base_request_line: first supported request line (CSRT) 41 * @end_request_line: last supported request line (CSRT) 42 */ 43struct acpi_dma { 44 struct list_head dma_controllers; 45 struct device *dev; 46 struct dma_chan *(*acpi_dma_xlate) 47 (struct acpi_dma_spec *, struct acpi_dma *); 48 void *data; 49 unsigned short base_request_line; 50 unsigned short end_request_line; 51}; 52 53/* Used with acpi_dma_simple_xlate() */ 54struct acpi_dma_filter_info { 55 dma_cap_mask_t dma_cap; 56 dma_filter_fn filter_fn; 57}; 58 59#ifdef CONFIG_DMA_ACPI 60 61int acpi_dma_controller_register(struct device *dev, 62 struct dma_chan *(*acpi_dma_xlate) 63 (struct acpi_dma_spec *, struct acpi_dma *), 64 void *data); 65int acpi_dma_controller_free(struct device *dev); 66int devm_acpi_dma_controller_register(struct device *dev, 67 struct dma_chan *(*acpi_dma_xlate) 68 (struct acpi_dma_spec *, struct acpi_dma *), 69 void *data); 70void devm_acpi_dma_controller_free(struct device *dev); 71 72struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev, 73 size_t index); 74struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev, 75 const char *name); 76 77struct dma_chan *acpi_dma_simple_xlate(struct acpi_dma_spec *dma_spec, 78 struct acpi_dma *adma); 79#else 80 81static inline int acpi_dma_controller_register(struct device *dev, 82 struct dma_chan *(*acpi_dma_xlate) 83 (struct acpi_dma_spec *, struct acpi_dma *), 84 void *data) 85{ 86 return -ENODEV; 87} 88static inline int acpi_dma_controller_free(struct device *dev) 89{ 90 return -ENODEV; 91} 92static inline int devm_acpi_dma_controller_register(struct device *dev, 93 struct dma_chan *(*acpi_dma_xlate) 94 (struct acpi_dma_spec *, struct acpi_dma *), 95 void *data) 96{ 97 return -ENODEV; 98} 99static inline void devm_acpi_dma_controller_free(struct device *dev) 100{ 101} 102 103static inline struct dma_chan *acpi_dma_request_slave_chan_by_index( 104 struct device *dev, size_t index) 105{ 106 return NULL; 107} 108static inline struct dma_chan *acpi_dma_request_slave_chan_by_name( 109 struct device *dev, const char *name) 110{ 111 return NULL; 112} 113 114#define acpi_dma_simple_xlate NULL 115 116#endif 117 118#define acpi_dma_request_slave_channel acpi_dma_request_slave_chan_by_index 119 120#endif /* __LINUX_ACPI_DMA_H */