Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[linux-block.git] / include / linux / of_dma.h
CommitLineData
af6074fc 1/* SPDX-License-Identifier: GPL-2.0 */
aa3da644
JH
2/*
3 * OF helpers for DMA request / controller
4 *
5 * Based on of_gpio.h
6 *
7 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
aa3da644
JH
8 */
9
10#ifndef __LINUX_OF_DMA_H
11#define __LINUX_OF_DMA_H
12
13#include <linux/of.h>
14#include <linux/dmaengine.h>
15
16struct device_node;
17
18struct of_dma {
19 struct list_head of_dma_controllers;
20 struct device_node *of_node;
aa3da644
JH
21 struct dma_chan *(*of_dma_xlate)
22 (struct of_phandle_args *, struct of_dma *);
56f13c0d
PU
23 void *(*of_dma_route_allocate)
24 (struct of_phandle_args *, struct of_dma *);
25 struct dma_router *dma_router;
aa3da644
JH
26 void *of_dma_data;
27};
28
29struct of_dma_filter_info {
30 dma_cap_mask_t dma_cap;
31 dma_filter_fn filter_fn;
32};
33
9290a16c 34#ifdef CONFIG_DMA_OF
aa3da644
JH
35extern int of_dma_controller_register(struct device_node *np,
36 struct dma_chan *(*of_dma_xlate)
37 (struct of_phandle_args *, struct of_dma *),
38 void *data);
de61608a 39extern void of_dma_controller_free(struct device_node *np);
56f13c0d
PU
40
41extern int of_dma_router_register(struct device_node *np,
42 void *(*of_dma_route_allocate)
43 (struct of_phandle_args *, struct of_dma *),
44 struct dma_router *dma_router);
45#define of_dma_router_free of_dma_controller_free
46
aa3da644 47extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
bef29ec5 48 const char *name);
aa3da644
JH
49extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
50 struct of_dma *ofdma);
16369efb
AP
51extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec,
52 struct of_dma *ofdma);
56f13c0d 53
4c26bc60 54#else
91f8aecc 55static inline int of_dma_controller_register(struct device_node *np,
4c26bc60
VK
56 struct dma_chan *(*of_dma_xlate)
57 (struct of_phandle_args *, struct of_dma *),
58 void *data)
59{
60 return -ENODEV;
61}
62
de61608a 63static inline void of_dma_controller_free(struct device_node *np)
4c26bc60
VK
64{
65}
66
56f13c0d
PU
67static inline int of_dma_router_register(struct device_node *np,
68 void *(*of_dma_route_allocate)
69 (struct of_phandle_args *, struct of_dma *),
70 struct dma_router *dma_router)
71{
72 return -ENODEV;
73}
74
75#define of_dma_router_free of_dma_controller_free
76
91f8aecc 77static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
bef29ec5 78 const char *name)
4c26bc60 79{
500404eb 80 return ERR_PTR(-ENODEV);
4c26bc60
VK
81}
82
91f8aecc 83static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
4c26bc60
VK
84 struct of_dma *ofdma)
85{
86 return NULL;
87}
88
16369efb
AP
89#define of_dma_xlate_by_chan_id NULL
90
4c26bc60 91#endif
aa3da644
JH
92
93#endif /* __LINUX_OF_DMA_H */