Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * OF helpers for DMA request / controller
0004  *
0005  * Based on of_gpio.h
0006  *
0007  * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
0008  */
0009 
0010 #ifndef __LINUX_OF_DMA_H
0011 #define __LINUX_OF_DMA_H
0012 
0013 #include <linux/of.h>
0014 #include <linux/dmaengine.h>
0015 
0016 struct device_node;
0017 
0018 struct of_dma {
0019     struct list_head    of_dma_controllers;
0020     struct device_node  *of_node;
0021     struct dma_chan     *(*of_dma_xlate)
0022                 (struct of_phandle_args *, struct of_dma *);
0023     void            *(*of_dma_route_allocate)
0024                 (struct of_phandle_args *, struct of_dma *);
0025     struct dma_router   *dma_router;
0026     void            *of_dma_data;
0027 };
0028 
0029 struct of_dma_filter_info {
0030     dma_cap_mask_t  dma_cap;
0031     dma_filter_fn   filter_fn;
0032 };
0033 
0034 #ifdef CONFIG_DMA_OF
0035 extern int of_dma_controller_register(struct device_node *np,
0036         struct dma_chan *(*of_dma_xlate)
0037         (struct of_phandle_args *, struct of_dma *),
0038         void *data);
0039 extern void of_dma_controller_free(struct device_node *np);
0040 
0041 extern int of_dma_router_register(struct device_node *np,
0042         void *(*of_dma_route_allocate)
0043         (struct of_phandle_args *, struct of_dma *),
0044         struct dma_router *dma_router);
0045 #define of_dma_router_free of_dma_controller_free
0046 
0047 extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
0048                              const char *name);
0049 extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
0050         struct of_dma *ofdma);
0051 extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec,
0052         struct of_dma *ofdma);
0053 
0054 #else
0055 static inline int of_dma_controller_register(struct device_node *np,
0056         struct dma_chan *(*of_dma_xlate)
0057         (struct of_phandle_args *, struct of_dma *),
0058         void *data)
0059 {
0060     return -ENODEV;
0061 }
0062 
0063 static inline void of_dma_controller_free(struct device_node *np)
0064 {
0065 }
0066 
0067 static inline int of_dma_router_register(struct device_node *np,
0068         void *(*of_dma_route_allocate)
0069         (struct of_phandle_args *, struct of_dma *),
0070         struct dma_router *dma_router)
0071 {
0072     return -ENODEV;
0073 }
0074 
0075 #define of_dma_router_free of_dma_controller_free
0076 
0077 static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
0078                              const char *name)
0079 {
0080     return ERR_PTR(-ENODEV);
0081 }
0082 
0083 static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
0084         struct of_dma *ofdma)
0085 {
0086     return NULL;
0087 }
0088 
0089 #define of_dma_xlate_by_chan_id NULL
0090 
0091 #endif
0092 
0093 #endif /* __LINUX_OF_DMA_H */