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 *); |
Peter Ujfalusi | 56f13c0 | 2015-04-09 12:35:47 +0300 | [diff] [blame] | 26 | void *(*of_dma_route_allocate) |
| 27 | (struct of_phandle_args *, struct of_dma *); |
| 28 | struct dma_router *dma_router; |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 29 | void *of_dma_data; |
| 30 | }; |
| 31 | |
| 32 | struct of_dma_filter_info { |
| 33 | dma_cap_mask_t dma_cap; |
| 34 | dma_filter_fn filter_fn; |
| 35 | }; |
| 36 | |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 37 | #ifdef CONFIG_OF |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 38 | extern 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 Clausen | de61608 | 2013-04-19 11:42:14 +0200 | [diff] [blame] | 42 | extern void of_dma_controller_free(struct device_node *np); |
Peter Ujfalusi | 56f13c0 | 2015-04-09 12:35:47 +0300 | [diff] [blame] | 43 | |
| 44 | extern 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 Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 50 | 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] | 51 | const char *name); |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 52 | extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, |
| 53 | struct of_dma *ofdma); |
Alexander Popov | 16369ef | 2014-06-25 14:52:59 +0400 | [diff] [blame] | 54 | extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec, |
| 55 | struct of_dma *ofdma); |
Peter Ujfalusi | 56f13c0 | 2015-04-09 12:35:47 +0300 | [diff] [blame] | 56 | |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 57 | #else |
Vinod Koul | 91f8aec | 2012-11-29 12:17:22 +0530 | [diff] [blame] | 58 | static inline int of_dma_controller_register(struct device_node *np, |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 59 | 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 Clausen | de61608 | 2013-04-19 11:42:14 +0200 | [diff] [blame] | 66 | static inline void of_dma_controller_free(struct device_node *np) |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 67 | { |
| 68 | } |
| 69 | |
Peter Ujfalusi | 56f13c0 | 2015-04-09 12:35:47 +0300 | [diff] [blame] | 70 | static 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 Koul | 91f8aec | 2012-11-29 12:17:22 +0530 | [diff] [blame] | 80 | 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] | 81 | const char *name) |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 82 | { |
| 83 | return NULL; |
| 84 | } |
| 85 | |
Vinod Koul | 91f8aec | 2012-11-29 12:17:22 +0530 | [diff] [blame] | 86 | 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] | 87 | struct of_dma *ofdma) |
| 88 | { |
| 89 | return NULL; |
| 90 | } |
| 91 | |
Alexander Popov | 16369ef | 2014-06-25 14:52:59 +0400 | [diff] [blame] | 92 | #define of_dma_xlate_by_chan_id NULL |
| 93 | |
Vinod Koul | 4c26bc6 | 2012-09-25 09:57:36 +0530 | [diff] [blame] | 94 | #endif |
Jon Hunter | aa3da64 | 2012-09-14 17:41:56 -0500 | [diff] [blame] | 95 | |
| 96 | #endif /* __LINUX_OF_DMA_H */ |