openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

linux_dma.h (1821B)


      1 /***********************************************************************
      2  *
      3  * 
      4  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5  * 
      6  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      7  */
      8 
      9 #ifndef __LINUX_DMA_H__
     10 #define __LINUX_DMA_H__
     11 
     12 #include <sal/types.h>
     13 
     14 #ifdef __KERNEL__
     15 
     16 #ifdef SAL_BDE_XLP
     17 #define KMALLOC(size, flags)    __kmalloc(size, flags)
     18 #else
     19 #define KMALLOC(size, flags)    kmalloc(size, flags)
     20 #endif
     21 
     22 #if defined(CONFIG_IDT_79EB334) || defined(CONFIG_BCM4702)
     23 /* ioremap is broken in kernel */
     24 #define IOREMAP(addr, size) ((void *)KSEG1ADDR(addr))
     25 #else
     26 #define IOREMAP(addr, size) ioremap_nocache(addr, size)
     27 #endif
     28 
     29 #if defined (__mips__)
     30 #if defined(CONFIG_NONCOHERENT_IO) || defined(CONFIG_DMA_NONCOHERENT)
     31 /* Use flush/invalidate for cached memory */
     32 #define NONCOHERENT_DMA_MEMORY
     33 /* Remap virtual DMA addresses to non-cached segment */
     34 #define REMAP_DMA_NONCACHED
     35 #endif /* CONFIG_NONCOHERENT_IO || CONFIG_DMA_NONCOHERENT */
     36 #endif /* __mips__ */
     37 
     38 #if defined(BCM958525) && (LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,5))
     39 #define REMAP_DMA_NONCACHED
     40 #endif
     41 
     42 #ifndef DMA_BIT_MASK
     43 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
     44 #endif
     45 
     46 extern void _dma_init(int dev_index);
     47 extern int _dma_cleanup(void);
     48 extern void _dma_pprint(void);
     49 extern uint32_t *_salloc(int d, int size, const char *name);
     50 extern void _sfree(int d, void *ptr);
     51 extern int _sinval(int d, void *ptr, int length);
     52 extern int _sflush(int d, void *ptr, int length);
     53 extern sal_paddr_t _l2p(int d, void *vaddr);
     54 extern void *_p2l(int d, sal_paddr_t paddr);
     55 extern int _dma_pool_allocated(void);
     56 extern int _dma_mmap(struct file *filp, struct vm_area_struct *vma);
     57 
     58 #endif /* __KERNEL__ */
     59 
     60 #endif /* __LINUX_DMA_H__ */