blob: ae36298ba076eb5187b1fff7bffc96f8c0b6a28a [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 *);
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
Vinod Koul4c26bc62012-09-25 09:57:36 +053034#ifdef CONFIG_OF
Jon Hunteraa3da642012-09-14 17:41:56 -050035extern 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);
Lars-Peter Clausende616082013-04-19 11:42:14 +020039extern void of_dma_controller_free(struct device_node *np);
Jon Hunteraa3da642012-09-14 17:41:56 -050040extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
Markus Pargmannbef29ec2013-02-24 16:36:09 +010041 const char *name);
Jon Hunteraa3da642012-09-14 17:41:56 -050042extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
43 struct of_dma *ofdma);
Vinod Koul4c26bc62012-09-25 09:57:36 +053044#else
Vinod Koul91f8aec2012-11-29 12:17:22 +053045static inline int of_dma_controller_register(struct device_node *np,
Vinod Koul4c26bc62012-09-25 09:57:36 +053046 struct dma_chan *(*of_dma_xlate)
47 (struct of_phandle_args *, struct of_dma *),
48 void *data)
49{
50 return -ENODEV;
51}
52
Lars-Peter Clausende616082013-04-19 11:42:14 +020053static inline void of_dma_controller_free(struct device_node *np)
Vinod Koul4c26bc62012-09-25 09:57:36 +053054{
55}
56
Vinod Koul91f8aec2012-11-29 12:17:22 +053057static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
Markus Pargmannbef29ec2013-02-24 16:36:09 +010058 const char *name)
Vinod Koul4c26bc62012-09-25 09:57:36 +053059{
60 return NULL;
61}
62
Vinod Koul91f8aec2012-11-29 12:17:22 +053063static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
Vinod Koul4c26bc62012-09-25 09:57:36 +053064 struct of_dma *ofdma)
65{
66 return NULL;
67}
68
69#endif
Jon Hunteraa3da642012-09-14 17:41:56 -050070
71#endif /* __LINUX_OF_DMA_H */