Rob Herring | af6074f | 2017-12-27 12:55:14 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 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/ |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 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 | |
| 16 | struct device_node; |
| 17 | |
| 18 | struct of_dma { |
| 19 | struct list_head of_dma_controllers; |
| 20 | struct device_node *of_node; |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 21 | struct dma_chan *(*of_dma_xlate) |
| 22 | (struct of_phandle_args *, struct of_dma *); |
Peter Ujfalusi | 56f13c0 | 2015-04-09 12:35:47 +0300 | [diff] [blame] | 23 | void *(*of_dma_route_allocate) |
| 24 | (struct of_phandle_args *, struct of_dma *); |
| 25 | struct dma_router *dma_router; |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 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 | |
Kuninori Morimoto | 9290a16 | 2015-08-21 11:48:37 +0000 | [diff] [blame] | 34 | #ifdef CONFIG_DMA_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); |
Peter Ujfalusi | 56f13c0 | 2015-04-09 12:35:47 +0300 | [diff] [blame] | 40 | |
| 41 | extern 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 | |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 47 | 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] | 48 | const char *name); |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 49 | extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, |
| 50 | struct of_dma *ofdma); |
Alexander Popov | 16369ef | 2014-06-25 14:52:59 +0400 | [diff] [blame] | 51 | extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec, |
| 52 | struct of_dma *ofdma); |
Peter Ujfalusi | 56f13c0 | 2015-04-09 12:35:47 +0300 | [diff] [blame] | 53 | |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 54 | #else |
Vinod Koul | 91f8aec | 2012-11-29 12:17:22 +0530 | [diff] [blame] | 55 | static inline int of_dma_controller_register(struct device_node *np, |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 56 | struct dma_chan *(*of_dma_xlate) |
| 57 | (struct of_phandle_args *, struct of_dma *), |
| 58 | void *data) |
| 59 | { |
| 60 | return -ENODEV; |
| 61 | } |
| 62 | |
Lars-Peter Clausen | de61608 | 2013-04-19 11:42:14 +0200 | [diff] [blame] | 63 | static inline void of_dma_controller_free(struct device_node *np) |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 64 | { |
| 65 | } |
| 66 | |
Peter Ujfalusi | 56f13c0 | 2015-04-09 12:35:47 +0300 | [diff] [blame] | 67 | static 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 | |
Vinod Koul | 91f8aec | 2012-11-29 12:17:22 +0530 | [diff] [blame] | 77 | 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] | 78 | const char *name) |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 79 | { |
Peter Ujfalusi | 500404e | 2015-11-03 12:28:10 +0200 | [diff] [blame] | 80 | return ERR_PTR(-ENODEV); |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 81 | } |
| 82 | |
Vinod Koul | 91f8aec | 2012-11-29 12:17:22 +0530 | [diff] [blame] | 83 | 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] | 84 | struct of_dma *ofdma) |
| 85 | { |
| 86 | return NULL; |
| 87 | } |
| 88 | |
Alexander Popov | 16369ef | 2014-06-25 14:52:59 +0400 | [diff] [blame] | 89 | #define of_dma_xlate_by_chan_id NULL |
| 90 | |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 91 | #endif |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 92 | |
| 93 | #endif /* __LINUX_OF_DMA_H */ |