blob: b90d8ec57c1fb43fcc182b59e3d3267c79c68865 [file] [log] [blame]
Jon Hunteraa3da642012-09-14 17:41:56 -05001/*
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
19struct device_node;
20
21struct of_dma {
22 struct list_head of_dma_controllers;
23 struct device_node *of_node;
Jon Hunteraa3da642012-09-14 17:41:56 -050024 struct dma_chan *(*of_dma_xlate)
25 (struct of_phandle_args *, struct of_dma *);
Peter Ujfalusi56f13c02015-04-09 12:35:47 +030026 void *(*of_dma_route_allocate)
27 (struct of_phandle_args *, struct of_dma *);
28 struct dma_router *dma_router;
Jon Hunteraa3da642012-09-14 17:41:56 -050029 void *of_dma_data;
30};
31
32struct of_dma_filter_info {
33 dma_cap_mask_t dma_cap;
34 dma_filter_fn filter_fn;
35};
36
Kuninori Morimoto9290a162015-08-21 11:48:37 +000037#ifdef CONFIG_DMA_OF
Jon Hunteraa3da642012-09-14 17:41:56 -050038extern 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);
Lars-Peter Clausende616082013-04-19 11:42:14 +020042extern void of_dma_controller_free(struct device_node *np);
Peter Ujfalusi56f13c02015-04-09 12:35:47 +030043
44extern 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
Jon Hunteraa3da642012-09-14 17:41:56 -050050extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
Markus Pargmannbef29ec2013-02-24 16:36:09 +010051 const char *name);
Jon Hunteraa3da642012-09-14 17:41:56 -050052extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
53 struct of_dma *ofdma);
Alexander Popov16369ef2014-06-25 14:52:59 +040054extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec,
55 struct of_dma *ofdma);
Peter Ujfalusi56f13c02015-04-09 12:35:47 +030056
Vinod Koul4c26bc62012-09-25 09:57:36 +053057#else
Vinod Koul91f8aec2012-11-29 12:17:22 +053058static inline int of_dma_controller_register(struct device_node *np,
Vinod Koul4c26bc62012-09-25 09:57:36 +053059 struct dma_chan *(*of_dma_xlate)
60 (struct of_phandle_args *, struct of_dma *),
61 void *data)
62{
63 return -ENODEV;
64}
65
Lars-Peter Clausende616082013-04-19 11:42:14 +020066static inline void of_dma_controller_free(struct device_node *np)
Vinod Koul4c26bc62012-09-25 09:57:36 +053067{
68}
69
Peter Ujfalusi56f13c02015-04-09 12:35:47 +030070static 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
Vinod Koul91f8aec2012-11-29 12:17:22 +053080static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
Markus Pargmannbef29ec2013-02-24 16:36:09 +010081 const char *name)
Vinod Koul4c26bc62012-09-25 09:57:36 +053082{
Peter Ujfalusi500404e2015-11-03 12:28:10 +020083 return ERR_PTR(-ENODEV);
Vinod Koul4c26bc62012-09-25 09:57:36 +053084}
85
Vinod Koul91f8aec2012-11-29 12:17:22 +053086static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
Vinod Koul4c26bc62012-09-25 09:57:36 +053087 struct of_dma *ofdma)
88{
89 return NULL;
90}
91
Alexander Popov16369ef2014-06-25 14:52:59 +040092#define of_dma_xlate_by_chan_id NULL
93
Vinod Koul4c26bc62012-09-25 09:57:36 +053094#endif
Jon Hunteraa3da642012-09-14 17:41:56 -050095
96#endif /* __LINUX_OF_DMA_H */