sram.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Handling of a sram zone for bestcomm
  3. *
  4. *
  5. * Copyright (C) 2007 Sylvain Munaut <tnt@246tNt.com>
  6. *
  7. * This file is licensed under the terms of the GNU General Public License
  8. * version 2. This program is licensed "as is" without any warranty of any
  9. * kind, whether express or implied.
  10. */
  11. #ifndef __BESTCOMM_SRAM_H__
  12. #define __BESTCOMM_SRAM_H__
  13. #include <asm/rheap.h>
  14. #include <asm/mmu.h>
  15. #include <linux/spinlock.h>
  16. /* Structure used internally */
  17. /* The internals are here for the inline functions
  18. * sake, certainly not for the user to mess with !
  19. */
  20. struct bcom_sram {
  21. phys_addr_t base_phys;
  22. void *base_virt;
  23. unsigned int size;
  24. rh_info_t *rh;
  25. spinlock_t lock;
  26. };
  27. extern struct bcom_sram *bcom_sram;
  28. /* Public API */
  29. extern int bcom_sram_init(struct device_node *sram_node, char *owner);
  30. extern void bcom_sram_cleanup(void);
  31. extern void* bcom_sram_alloc(int size, int align, phys_addr_t *phys);
  32. extern void bcom_sram_free(void *ptr);
  33. static inline phys_addr_t bcom_sram_va2pa(void *va) {
  34. return bcom_sram->base_phys +
  35. (unsigned long)(va - bcom_sram->base_virt);
  36. }
  37. static inline void *bcom_sram_pa2va(phys_addr_t pa) {
  38. return bcom_sram->base_virt +
  39. (unsigned long)(pa - bcom_sram->base_phys);
  40. }
  41. #endif /* __BESTCOMM_SRAM_H__ */