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 (2428B)


      1 /*
      2  * Copyright 2017 Broadcom
      3  * 
      4  * This program is free software; you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License, version 2, as
      6  * published by the Free Software Foundation (the "GPL").
      7  * 
      8  * This program is distributed in the hope that it will be useful, but
      9  * WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     11  * General Public License version 2 (GPLv2) for more details.
     12  * 
     13  * You should have received a copy of the GNU General Public License
     14  * version 2 (GPLv2) along with this source code.
     15  */
     16 /***********************************************************************
     17  *
     18  * $Id: linux_dma.h,v 1.24 Broadcom SDK $
     19  * $Copyright: (c) 2016 Broadcom Corp.
     20  * All Rights Reserved.$
     21  *
     22  **********************************************************************/
     23 
     24 #ifndef __LINUX_DMA_H__
     25 #define __LINUX_DMA_H__
     26 
     27 #include <sal/types.h>
     28 
     29 #ifdef __KERNEL__
     30 
     31 #ifdef SAL_BDE_XLP
     32 #define KMALLOC(size, flags)    __kmalloc(size, flags)
     33 #else
     34 #define KMALLOC(size, flags)    kmalloc(size, flags)
     35 #endif
     36 
     37 #if defined(CONFIG_IDT_79EB334) || defined(CONFIG_BCM4702)
     38 /* ioremap is broken in kernel */
     39 #define IOREMAP(addr, size) ((void *)KSEG1ADDR(addr))
     40 #else
     41 #define IOREMAP(addr, size) ioremap_nocache(addr, size)
     42 #endif
     43 
     44 #if defined (__mips__)
     45 #if defined(CONFIG_NONCOHERENT_IO) || defined(CONFIG_DMA_NONCOHERENT)
     46 /* Use flush/invalidate for cached memory */
     47 #define NONCOHERENT_DMA_MEMORY
     48 /* Remap virtual DMA addresses to non-cached segment */
     49 #define REMAP_DMA_NONCACHED
     50 #endif /* CONFIG_NONCOHERENT_IO || CONFIG_DMA_NONCOHERENT */
     51 #endif /* __mips__ */
     52 
     53 #if defined(BCM958525) && (LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,5))
     54 #define REMAP_DMA_NONCACHED
     55 #endif
     56 
     57 #ifndef DMA_BIT_MASK
     58 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
     59 #endif
     60 
     61 extern void _dma_init(int dev_index);
     62 extern int _dma_cleanup(void);
     63 extern void _dma_pprint(void);
     64 extern uint32_t *_salloc(int d, int size, const char *name);
     65 extern void _sfree(int d, void *ptr);
     66 extern int _sinval(int d, void *ptr, int length);
     67 extern int _sflush(int d, void *ptr, int length);
     68 extern sal_paddr_t _l2p(int d, void *vaddr);
     69 extern void *_p2l(int d, sal_paddr_t paddr);
     70 extern int _dma_pool_allocated(void);
     71 extern int _dma_mmap(struct file *filp, struct vm_area_struct *vma);
     72 
     73 #endif /* __KERNEL__ */
     74 
     75 #endif /* __LINUX_DMA_H__ */