aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2013-04-09 07:05:43 -0400
committerVinod Koul <vinod.koul@intel.com>2013-04-15 12:34:10 -0400
commit1b2e98bc1e35ebe1f65c3db62c8317096ad7f2c8 (patch)
tree326e1f7e6f311f1107f27eb048d521e880944360 /include
parenteceec44ecd7f3285468a684e7216df2316b178f3 (diff)
dma: acpi-dma: introduce ACPI DMA helpers
There is a new generic API to get a DMA channel for a slave device (commit 9a6cecc8 "dmaengine: add helper function to request a slave DMA channel"). In similar fashion to the DT case (commit aa3da644 "of: Add generic device tree DMA helpers") we introduce helpers to the DMAC drivers which are enumerated by ACPI. The proposed extension provides the following API calls: acpi_dma_controller_register(), devm_acpi_dma_controller_register() acpi_dma_controller_free(), devm_acpi_dma_controller_free() acpi_dma_simple_xlate() acpi_dma_request_slave_chan_by_index() acpi_dma_request_slave_chan_by_name() The first two should be used, for example, at probe() and remove() of the corresponding DMAC driver. At the register stage the DMAC driver supplies a custom xlate() function to translate a struct dma_spec into struct dma_chan. Accordingly to the ACPI Fixed DMA resource specification the only two pieces of information the slave device has are the channel id and the request line (slave id). Those two are represented by struct dma_spec. The acpi_dma_request_slave_chan_by_index() provides access to the specifix FixedDMA resource by its index. Whereas dma_request_slave_channel() takes a string parameter to identify the DMA resources required by the slave device. To make a slave device driver work with both DeviceTree and ACPI enumeration a simple convention is established: "tx" corresponds to the index 0 and "rx" to the index 1. In case of robust configuration the slave device driver unfortunately needs to call acpi_dma_request_slave_chan_by_index() directly. Additionally the patch provides "managed" version of the register/free pair i.e. devm_acpi_dma_controller_register() and devm_acpi_dma_controller_free(). Usually, the driver uses only devm_acpi_dma_controller_register(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/acpi_dma.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/include/linux/acpi_dma.h b/include/linux/acpi_dma.h
new file mode 100644
index 000000000000..d09deabc7bf6
--- /dev/null
+++ b/include/linux/acpi_dma.h
@@ -0,0 +1,116 @@
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 */
41struct acpi_dma {
42 struct list_head dma_controllers;
43 struct device *dev;
44 struct dma_chan *(*acpi_dma_xlate)
45 (struct acpi_dma_spec *, struct acpi_dma *);
46 void *data;
47};
48
49/* Used with acpi_dma_simple_xlate() */
50struct acpi_dma_filter_info {
51 dma_cap_mask_t dma_cap;
52 dma_filter_fn filter_fn;
53};
54
55#ifdef CONFIG_DMA_ACPI
56
57int 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);
61int acpi_dma_controller_free(struct device *dev);
62int devm_acpi_dma_controller_register(struct device *dev,
63 struct dma_chan *(*acpi_dma_xlate)
64 (struct acpi_dma_spec *, struct acpi_dma *),
65 void *data);
66void devm_acpi_dma_controller_free(struct device *dev);
67
68struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
69 size_t index);
70struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
71 const char *name);
72
73struct dma_chan *acpi_dma_simple_xlate(struct acpi_dma_spec *dma_spec,
74 struct acpi_dma *adma);
75#else
76
77static inline int acpi_dma_controller_register(struct device *dev,
78 struct dma_chan *(*acpi_dma_xlate)
79 (struct acpi_dma_spec *, struct acpi_dma *),
80 void *data)
81{
82 return -ENODEV;
83}
84static inline int acpi_dma_controller_free(struct device *dev)
85{
86 return -ENODEV;
87}
88static inline int devm_acpi_dma_controller_register(struct device *dev,
89 struct dma_chan *(*acpi_dma_xlate)
90 (struct acpi_dma_spec *, struct acpi_dma *),
91 void *data)
92{
93 return -ENODEV;
94}
95static inline void devm_acpi_dma_controller_free(struct device *dev)
96{
97}
98
99static inline struct dma_chan *acpi_dma_request_slave_chan_by_index(
100 struct device *dev, size_t index)
101{
102 return NULL;
103}
104static inline struct dma_chan *acpi_dma_request_slave_chan_by_name(
105 struct device *dev, const char *name)
106{
107 return NULL;
108}
109
110#define acpi_dma_simple_xlate NULL
111
112#endif
113
114#define acpi_dma_request_slave_channel acpi_dma_request_slave_chan_by_index
115
116#endif /* __LINUX_ACPI_DMA_H */