1*af6074fcSRob Herring /* SPDX-License-Identifier: GPL-2.0 */
2aa3da644SJon Hunter /*
3aa3da644SJon Hunter * OF helpers for DMA request / controller
4aa3da644SJon Hunter *
5aa3da644SJon Hunter * Based on of_gpio.h
6aa3da644SJon Hunter *
7aa3da644SJon Hunter * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
8aa3da644SJon Hunter */
9aa3da644SJon Hunter
10aa3da644SJon Hunter #ifndef __LINUX_OF_DMA_H
11aa3da644SJon Hunter #define __LINUX_OF_DMA_H
12aa3da644SJon Hunter
13aa3da644SJon Hunter #include <linux/of.h>
14aa3da644SJon Hunter #include <linux/dmaengine.h>
15aa3da644SJon Hunter
16aa3da644SJon Hunter struct device_node;
17aa3da644SJon Hunter
18aa3da644SJon Hunter struct of_dma {
19aa3da644SJon Hunter struct list_head of_dma_controllers;
20aa3da644SJon Hunter struct device_node *of_node;
21aa3da644SJon Hunter struct dma_chan *(*of_dma_xlate)
22aa3da644SJon Hunter (struct of_phandle_args *, struct of_dma *);
2356f13c0dSPeter Ujfalusi void *(*of_dma_route_allocate)
2456f13c0dSPeter Ujfalusi (struct of_phandle_args *, struct of_dma *);
2556f13c0dSPeter Ujfalusi struct dma_router *dma_router;
26aa3da644SJon Hunter void *of_dma_data;
27aa3da644SJon Hunter };
28aa3da644SJon Hunter
29aa3da644SJon Hunter struct of_dma_filter_info {
30aa3da644SJon Hunter dma_cap_mask_t dma_cap;
31aa3da644SJon Hunter dma_filter_fn filter_fn;
32aa3da644SJon Hunter };
33aa3da644SJon Hunter
349290a16cSKuninori Morimoto #ifdef CONFIG_DMA_OF
35aa3da644SJon Hunter extern int of_dma_controller_register(struct device_node *np,
36aa3da644SJon Hunter struct dma_chan *(*of_dma_xlate)
37aa3da644SJon Hunter (struct of_phandle_args *, struct of_dma *),
38aa3da644SJon Hunter void *data);
39de61608aSLars-Peter Clausen extern void of_dma_controller_free(struct device_node *np);
4056f13c0dSPeter Ujfalusi
4156f13c0dSPeter Ujfalusi extern int of_dma_router_register(struct device_node *np,
4256f13c0dSPeter Ujfalusi void *(*of_dma_route_allocate)
4356f13c0dSPeter Ujfalusi (struct of_phandle_args *, struct of_dma *),
4456f13c0dSPeter Ujfalusi struct dma_router *dma_router);
4556f13c0dSPeter Ujfalusi #define of_dma_router_free of_dma_controller_free
4656f13c0dSPeter Ujfalusi
47aa3da644SJon Hunter extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
48bef29ec5SMarkus Pargmann const char *name);
49aa3da644SJon Hunter extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
50aa3da644SJon Hunter struct of_dma *ofdma);
5116369efbSAlexander Popov extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec,
5216369efbSAlexander Popov struct of_dma *ofdma);
5356f13c0dSPeter Ujfalusi
544c26bc60SVinod Koul #else
of_dma_controller_register(struct device_node * np,struct dma_chan * (* of_dma_xlate)(struct of_phandle_args *,struct of_dma *),void * data)5591f8aeccSVinod Koul static inline int of_dma_controller_register(struct device_node *np,
564c26bc60SVinod Koul struct dma_chan *(*of_dma_xlate)
574c26bc60SVinod Koul (struct of_phandle_args *, struct of_dma *),
584c26bc60SVinod Koul void *data)
594c26bc60SVinod Koul {
604c26bc60SVinod Koul return -ENODEV;
614c26bc60SVinod Koul }
624c26bc60SVinod Koul
of_dma_controller_free(struct device_node * np)63de61608aSLars-Peter Clausen static inline void of_dma_controller_free(struct device_node *np)
644c26bc60SVinod Koul {
654c26bc60SVinod Koul }
664c26bc60SVinod Koul
of_dma_router_register(struct device_node * np,void * (* of_dma_route_allocate)(struct of_phandle_args *,struct of_dma *),struct dma_router * dma_router)6756f13c0dSPeter Ujfalusi static inline int of_dma_router_register(struct device_node *np,
6856f13c0dSPeter Ujfalusi void *(*of_dma_route_allocate)
6956f13c0dSPeter Ujfalusi (struct of_phandle_args *, struct of_dma *),
7056f13c0dSPeter Ujfalusi struct dma_router *dma_router)
7156f13c0dSPeter Ujfalusi {
7256f13c0dSPeter Ujfalusi return -ENODEV;
7356f13c0dSPeter Ujfalusi }
7456f13c0dSPeter Ujfalusi
7556f13c0dSPeter Ujfalusi #define of_dma_router_free of_dma_controller_free
7656f13c0dSPeter Ujfalusi
of_dma_request_slave_channel(struct device_node * np,const char * name)7791f8aeccSVinod Koul static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
78bef29ec5SMarkus Pargmann const char *name)
794c26bc60SVinod Koul {
80500404ebSPeter Ujfalusi return ERR_PTR(-ENODEV);
814c26bc60SVinod Koul }
824c26bc60SVinod Koul
of_dma_simple_xlate(struct of_phandle_args * dma_spec,struct of_dma * ofdma)8391f8aeccSVinod Koul static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
844c26bc60SVinod Koul struct of_dma *ofdma)
854c26bc60SVinod Koul {
864c26bc60SVinod Koul return NULL;
874c26bc60SVinod Koul }
884c26bc60SVinod Koul
8916369efbSAlexander Popov #define of_dma_xlate_by_chan_id NULL
9016369efbSAlexander Popov
914c26bc60SVinod Koul #endif
92aa3da644SJon Hunter
93aa3da644SJon Hunter #endif /* __LINUX_OF_DMA_H */
94