Ignore:
Timestamp:
Jan 1, 2021, 5:31:48 AM (5 years ago)
Author:
Paul Smedley
Message:

Add source for uniaud32 based on code from linux kernel 5.4.86

Location:
GPL/branches/uniaud32-next
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-next/include/linux/dma-mapping.h

    r441 r615  
    11#ifndef _ASM_LINUX_DMA_MAPPING_H
    22#define _ASM_LINUX_DMA_MAPPING_H
     3#include <linux/pci.h>
     4#include <linux/errno.h>
    35
    46/* These definitions mirror those in pci.h, so they can be used
     
    1012        DMA_NONE = 3,
    1113};
     14
     15/*
     16 * A dma_addr_t can hold any valid DMA or bus address for the platform.
     17 * It can be given to a device to use as a DMA source or target.  A CPU cannot
     18 * reference a dma_addr_t directly because there may be translation between
     19 * its physical address space and the bus address space.
     20 */
     21struct dma_map_ops {
     22#if 0
     23        void* (*alloc)(struct device *dev, size_t size,
     24                                dma_addr_t *dma_handle, gfp_t gfp,
     25                                struct dma_attrs *attrs);
     26        void (*free)(struct device *dev, size_t size,
     27                              void *vaddr, dma_addr_t dma_handle,
     28                              struct dma_attrs *attrs);
     29        int (*mmap)(struct device *, struct vm_area_struct *,
     30                          void *, dma_addr_t, size_t, struct dma_attrs *attrs);
     31
     32        int (*get_sgtable)(struct device *dev, struct sg_table *sgt, void *,
     33                           dma_addr_t, size_t, struct dma_attrs *attrs);
     34
     35        dma_addr_t (*map_page)(struct device *dev, struct page *page,
     36                               unsigned long offset, size_t size,
     37                               enum dma_data_direction dir,
     38                               struct dma_attrs *attrs);
     39        void (*unmap_page)(struct device *dev, dma_addr_t dma_handle,
     40                           size_t size, enum dma_data_direction dir,
     41                           struct dma_attrs *attrs);
     42        /*
     43         * map_sg returns 0 on error and a value > 0 on success.
     44         * It should never return a value < 0.
     45         */
     46        int (*map_sg)(struct device *dev, struct scatterlist *sg,
     47                      int nents, enum dma_data_direction dir,
     48                      struct dma_attrs *attrs);
     49        void (*unmap_sg)(struct device *dev,
     50                         struct scatterlist *sg, int nents,
     51                         enum dma_data_direction dir,
     52                         struct dma_attrs *attrs);
     53        void (*sync_single_for_cpu)(struct device *dev,
     54                                    dma_addr_t dma_handle, size_t size,
     55                                    enum dma_data_direction dir);
     56        void (*sync_single_for_device)(struct device *dev,
     57                                       dma_addr_t dma_handle, size_t size,
     58                                       enum dma_data_direction dir);
     59        void (*sync_sg_for_cpu)(struct device *dev,
     60                                struct scatterlist *sg, int nents,
     61                                enum dma_data_direction dir);
     62        void (*sync_sg_for_device)(struct device *dev,
     63                                   struct scatterlist *sg, int nents,
     64                                   enum dma_data_direction dir);
     65        int (*mapping_error)(struct device *dev, dma_addr_t dma_addr);
     66#endif
     67        int (*dma_supported)(struct device *dev, u64 mask);
     68        int (*set_dma_mask)(struct device *dev, u64 mask);
     69#ifdef ARCH_HAS_DMA_GET_REQUIRED_MASK
     70        u64 (*get_required_mask)(struct device *dev);
     71#endif
     72        int is_phys;
     73};
     74
     75
     76#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
     77
     78#define DMA_MASK_NONE   0x0ULL
    1279
    1380#define DMA_64BIT_MASK  0xffffffffffffffffULL
     
    3097#endif
    3198#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
     99
     100extern struct dma_map_ops *dma_ops;
     101
     102static inline struct dma_map_ops *get_dma_ops(struct device *dev)
     103{
     104        if (dev->dma_ops)
     105                return dev->dma_ops;
     106        return NULL;
     107}
     108
     109static inline void set_dma_ops(struct device *dev,
     110                               const struct dma_map_ops *dma_ops)
     111{
     112        dev->dma_ops = dma_ops;
     113}
     114
     115int dma_supported(struct device *dev, u64 mask);
     116int dma_set_mask(struct device *dev, u64 mask);
     117int dma_set_coherent_mask(struct device *dev, u64 mask);
     118
     119/*
     120 * Set both the DMA mask and the coherent DMA mask to the same thing.
     121 * Note that we don't check the return value from dma_set_coherent_mask()
     122 * as the DMA API guarantees that the coherent DMA mask can be set to
     123 * the same or smaller than the streaming DMA mask.
     124 */
     125static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
     126{
     127        int rc = dma_set_mask(dev, mask);
     128        if (rc == 0)
     129                dma_set_coherent_mask(dev, mask);
     130        return rc;
     131}
     132
     133#if 1
     134#define dma_alloc_coherent(dev,size,addr,flags) pci_alloc_consistent((struct pci_dev *)(dev),size,addr)
     135#else
     136extern void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp);
    32137#endif
     138#define dma_free_coherent(dev,size,ptr,addr) pci_free_consistent((struct pci_dev *)(dev),size,ptr,addr)
     139static inline bool dma_can_mmap(struct device *dev)
     140{
     141        return false;
     142}
    33143
    34 
     144#endif
Note: See TracChangeset for help on using the changeset viewer.