Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * ACPI helpers for DMA request / controller
0004  *
0005  * Based on of_dma.h
0006  *
0007  * Copyright (C) 2013, Intel Corporation
0008  * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
0009  */
0010 
0011 #ifndef __LINUX_ACPI_DMA_H
0012 #define __LINUX_ACPI_DMA_H
0013 
0014 #include <linux/list.h>
0015 #include <linux/device.h>
0016 #include <linux/err.h>
0017 #include <linux/dmaengine.h>
0018 
0019 /**
0020  * struct acpi_dma_spec - slave device DMA resources
0021  * @chan_id:    channel unique id
0022  * @slave_id:   request line unique id
0023  * @dev:    struct device of the DMA controller to be used in the filter
0024  *      function
0025  */
0026 struct acpi_dma_spec {
0027     int     chan_id;
0028     int     slave_id;
0029     struct device   *dev;
0030 };
0031 
0032 /**
0033  * struct acpi_dma - representation of the registered DMAC
0034  * @dma_controllers:    linked list node
0035  * @dev:        struct device of this controller
0036  * @acpi_dma_xlate: callback function to find a suitable channel
0037  * @data:       private data used by a callback function
0038  * @base_request_line:  first supported request line (CSRT)
0039  * @end_request_line:   last supported request line (CSRT)
0040  */
0041 struct acpi_dma {
0042     struct list_head    dma_controllers;
0043     struct device       *dev;
0044     struct dma_chan     *(*acpi_dma_xlate)
0045                 (struct acpi_dma_spec *, struct acpi_dma *);
0046     void            *data;
0047     unsigned short      base_request_line;
0048     unsigned short      end_request_line;
0049 };
0050 
0051 /* Used with acpi_dma_simple_xlate() */
0052 struct acpi_dma_filter_info {
0053     dma_cap_mask_t  dma_cap;
0054     dma_filter_fn   filter_fn;
0055 };
0056 
0057 #ifdef CONFIG_DMA_ACPI
0058 
0059 int acpi_dma_controller_register(struct device *dev,
0060         struct dma_chan *(*acpi_dma_xlate)
0061         (struct acpi_dma_spec *, struct acpi_dma *),
0062         void *data);
0063 int acpi_dma_controller_free(struct device *dev);
0064 int devm_acpi_dma_controller_register(struct device *dev,
0065         struct dma_chan *(*acpi_dma_xlate)
0066         (struct acpi_dma_spec *, struct acpi_dma *),
0067         void *data);
0068 void devm_acpi_dma_controller_free(struct device *dev);
0069 
0070 struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
0071                               size_t index);
0072 struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
0073                              const char *name);
0074 
0075 struct dma_chan *acpi_dma_simple_xlate(struct acpi_dma_spec *dma_spec,
0076                        struct acpi_dma *adma);
0077 #else
0078 
0079 static inline int acpi_dma_controller_register(struct device *dev,
0080         struct dma_chan *(*acpi_dma_xlate)
0081         (struct acpi_dma_spec *, struct acpi_dma *),
0082         void *data)
0083 {
0084     return -ENODEV;
0085 }
0086 static inline int acpi_dma_controller_free(struct device *dev)
0087 {
0088     return -ENODEV;
0089 }
0090 static inline int devm_acpi_dma_controller_register(struct device *dev,
0091         struct dma_chan *(*acpi_dma_xlate)
0092         (struct acpi_dma_spec *, struct acpi_dma *),
0093         void *data)
0094 {
0095     return -ENODEV;
0096 }
0097 static inline void devm_acpi_dma_controller_free(struct device *dev)
0098 {
0099 }
0100 
0101 static inline struct dma_chan *acpi_dma_request_slave_chan_by_index(
0102         struct device *dev, size_t index)
0103 {
0104     return ERR_PTR(-ENODEV);
0105 }
0106 static inline struct dma_chan *acpi_dma_request_slave_chan_by_name(
0107         struct device *dev, const char *name)
0108 {
0109     return ERR_PTR(-ENODEV);
0110 }
0111 
0112 #define acpi_dma_simple_xlate   NULL
0113 
0114 #endif
0115 
0116 #define acpi_dma_request_slave_channel  acpi_dma_request_slave_chan_by_index
0117 
0118 #endif /* __LINUX_ACPI_DMA_H */