Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Handling of a sram zone for bestcomm
0003  *
0004  *
0005  * Copyright (C) 2007 Sylvain Munaut <tnt@246tNt.com>
0006  *
0007  * This file is licensed under the terms of the GNU General Public License
0008  * version 2. This program is licensed "as is" without any warranty of any
0009  * kind, whether express or implied.
0010  */
0011 
0012 #ifndef __BESTCOMM_SRAM_H__
0013 #define __BESTCOMM_SRAM_H__
0014 
0015 #include <asm/rheap.h>
0016 #include <asm/mmu.h>
0017 #include <linux/spinlock.h>
0018 
0019 
0020 /* Structure used internally */
0021     /* The internals are here for the inline functions
0022      * sake, certainly not for the user to mess with !
0023      */
0024 struct bcom_sram {
0025     phys_addr_t      base_phys;
0026     void            *base_virt;
0027     unsigned int         size;
0028     rh_info_t       *rh;
0029     spinlock_t       lock;
0030 };
0031 
0032 extern struct bcom_sram *bcom_sram;
0033 
0034 
0035 /* Public API */
0036 extern int  bcom_sram_init(struct device_node *sram_node, char *owner);
0037 extern void bcom_sram_cleanup(void);
0038 
0039 extern void* bcom_sram_alloc(int size, int align, phys_addr_t *phys);
0040 extern void  bcom_sram_free(void *ptr);
0041 
0042 static inline phys_addr_t bcom_sram_va2pa(void *va) {
0043     return bcom_sram->base_phys +
0044         (unsigned long)(va - bcom_sram->base_virt);
0045 }
0046 
0047 static inline void *bcom_sram_pa2va(phys_addr_t pa) {
0048     return bcom_sram->base_virt +
0049         (unsigned long)(pa - bcom_sram->base_phys);
0050 }
0051 
0052 
0053 #endif  /* __BESTCOMM_SRAM_H__ */
0054