Commit | Line | Data |
---|---|---|
aa3da644 JH |
1 | /* |
2 | * OF helpers for DMA request / controller | |
3 | * | |
4 | * Based on of_gpio.h | |
5 | * | |
6 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | */ | |
12 | ||
13 | #ifndef __LINUX_OF_DMA_H | |
14 | #define __LINUX_OF_DMA_H | |
15 | ||
16 | #include <linux/of.h> | |
17 | #include <linux/dmaengine.h> | |
18 | ||
19 | struct device_node; | |
20 | ||
21 | struct of_dma { | |
22 | struct list_head of_dma_controllers; | |
23 | struct device_node *of_node; | |
aa3da644 JH |
24 | struct dma_chan *(*of_dma_xlate) |
25 | (struct of_phandle_args *, struct of_dma *); | |
56f13c0d PU |
26 | void *(*of_dma_route_allocate) |
27 | (struct of_phandle_args *, struct of_dma *); | |
28 | struct dma_router *dma_router; | |
aa3da644 JH |
29 | void *of_dma_data; |
30 | }; | |
31 | ||
32 | struct of_dma_filter_info { | |
33 | dma_cap_mask_t dma_cap; | |
34 | dma_filter_fn filter_fn; | |
35 | }; | |
36 | ||
9290a16c | 37 | #ifdef CONFIG_DMA_OF |
aa3da644 JH |
38 | extern int of_dma_controller_register(struct device_node *np, |
39 | struct dma_chan *(*of_dma_xlate) | |
40 | (struct of_phandle_args *, struct of_dma *), | |
41 | void *data); | |
de61608a | 42 | extern void of_dma_controller_free(struct device_node *np); |
56f13c0d PU |
43 | |
44 | extern int of_dma_router_register(struct device_node *np, | |
45 | void *(*of_dma_route_allocate) | |
46 | (struct of_phandle_args *, struct of_dma *), | |
47 | struct dma_router *dma_router); | |
48 | #define of_dma_router_free of_dma_controller_free | |
49 | ||
aa3da644 | 50 | extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np, |
bef29ec5 | 51 | const char *name); |
aa3da644 JH |
52 | extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, |
53 | struct of_dma *ofdma); | |
16369efb AP |
54 | extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec, |
55 | struct of_dma *ofdma); | |
56f13c0d | 56 | |
4c26bc60 | 57 | #else |
91f8aecc | 58 | static inline int of_dma_controller_register(struct device_node *np, |
4c26bc60 VK |
59 | struct dma_chan *(*of_dma_xlate) |
60 | (struct of_phandle_args *, struct of_dma *), | |
61 | void *data) | |
62 | { | |
63 | return -ENODEV; | |
64 | } | |
65 | ||
de61608a | 66 | static inline void of_dma_controller_free(struct device_node *np) |
4c26bc60 VK |
67 | { |
68 | } | |
69 | ||
56f13c0d PU |
70 | static inline int of_dma_router_register(struct device_node *np, |
71 | void *(*of_dma_route_allocate) | |
72 | (struct of_phandle_args *, struct of_dma *), | |
73 | struct dma_router *dma_router) | |
74 | { | |
75 | return -ENODEV; | |
76 | } | |
77 | ||
78 | #define of_dma_router_free of_dma_controller_free | |
79 | ||
91f8aecc | 80 | static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np, |
bef29ec5 | 81 | const char *name) |
4c26bc60 | 82 | { |
500404eb | 83 | return ERR_PTR(-ENODEV); |
4c26bc60 VK |
84 | } |
85 | ||
91f8aecc | 86 | static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, |
4c26bc60 VK |
87 | struct of_dma *ofdma) |
88 | { | |
89 | return NULL; | |
90 | } | |
91 | ||
16369efb AP |
92 | #define of_dma_xlate_by_chan_id NULL |
93 | ||
4c26bc60 | 94 | #endif |
aa3da644 JH |
95 | |
96 | #endif /* __LINUX_OF_DMA_H */ |