io.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * include/asm-xtensa/io.h
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2001 - 2005 Tensilica Inc.
  9. */
  10. #ifndef _XTENSA_IO_H
  11. #define _XTENSA_IO_H
  12. #include <asm/byteorder.h>
  13. #include <asm/page.h>
  14. #include <asm/vectors.h>
  15. #include <linux/bug.h>
  16. #include <linux/kernel.h>
  17. #include <linux/types.h>
  18. #define IOADDR(x) (XCHAL_KIO_BYPASS_VADDR + (x))
  19. #define IO_SPACE_LIMIT ~0
  20. #define PCI_IOBASE ((void __iomem *)XCHAL_KIO_BYPASS_VADDR)
  21. #ifdef CONFIG_MMU
  22. void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size);
  23. void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size);
  24. void xtensa_iounmap(volatile void __iomem *addr);
  25. /*
  26. * Return the virtual address for the specified bus memory.
  27. */
  28. static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
  29. {
  30. if (offset >= XCHAL_KIO_PADDR
  31. && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
  32. return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
  33. else
  34. return xtensa_ioremap_nocache(offset, size);
  35. }
  36. static inline void __iomem *ioremap_cache(unsigned long offset,
  37. unsigned long size)
  38. {
  39. if (offset >= XCHAL_KIO_PADDR
  40. && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
  41. return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
  42. else
  43. return xtensa_ioremap_cache(offset, size);
  44. }
  45. #define ioremap_cache ioremap_cache
  46. static inline void iounmap(volatile void __iomem *addr)
  47. {
  48. unsigned long va = (unsigned long) addr;
  49. if (!(va >= XCHAL_KIO_CACHED_VADDR &&
  50. va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) &&
  51. !(va >= XCHAL_KIO_BYPASS_VADDR &&
  52. va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
  53. xtensa_iounmap(addr);
  54. }
  55. #endif /* CONFIG_MMU */
  56. #include <asm-generic/io.h>
  57. #endif /* _XTENSA_IO_H */