Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 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; |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 24 | struct dma_chan *(*of_dma_xlate) |
| 25 | (struct of_phandle_args *, struct of_dma *); |
| 26 | void *of_dma_data; |
| 27 | }; |
| 28 | |
| 29 | struct of_dma_filter_info { |
| 30 | dma_cap_mask_t dma_cap; |
| 31 | dma_filter_fn filter_fn; |
| 32 | }; |
| 33 | |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 34 | #ifdef CONFIG_OF |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 35 | extern 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 Clausen | de61608 | 2013-04-19 11:42:14 +0200 | [diff] [blame] | 39 | extern void of_dma_controller_free(struct device_node *np); |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 40 | extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np, |
Markus Pargmann | bef29ec | 2013-02-24 16:36:09 +0100 | [diff] [blame] | 41 | const char *name); |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 42 | extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, |
| 43 | struct of_dma *ofdma); |
Alexander Popov | 16369ef | 2014-06-25 14:52:59 +0400 | [diff] [blame] | 44 | extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec, |
| 45 | struct of_dma *ofdma); |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 46 | #else |
Vinod Koul | 91f8aec | 2012-11-29 12:17:22 +0530 | [diff] [blame] | 47 | static inline int of_dma_controller_register(struct device_node *np, |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 48 | struct dma_chan *(*of_dma_xlate) |
| 49 | (struct of_phandle_args *, struct of_dma *), |
| 50 | void *data) |
| 51 | { |
| 52 | return -ENODEV; |
| 53 | } |
| 54 | |
Lars-Peter Clausen | de61608 | 2013-04-19 11:42:14 +0200 | [diff] [blame] | 55 | static inline void of_dma_controller_free(struct device_node *np) |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 56 | { |
| 57 | } |
| 58 | |
Vinod Koul | 91f8aec | 2012-11-29 12:17:22 +0530 | [diff] [blame] | 59 | static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np, |
Markus Pargmann | bef29ec | 2013-02-24 16:36:09 +0100 | [diff] [blame] | 60 | const char *name) |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 61 | { |
| 62 | return NULL; |
| 63 | } |
| 64 | |
Vinod Koul | 91f8aec | 2012-11-29 12:17:22 +0530 | [diff] [blame] | 65 | static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 66 | struct of_dma *ofdma) |
| 67 | { |
| 68 | return NULL; |
| 69 | } |
| 70 | |
Alexander Popov | 16369ef | 2014-06-25 14:52:59 +0400 | [diff] [blame] | 71 | #define of_dma_xlate_by_chan_id NULL |
| 72 | |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 73 | #endif |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 74 | |
| 75 | #endif /* __LINUX_OF_DMA_H */ |