io.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #ifdef __KERNEL__
  13. #include <asm/byteorder.h>
  14. #include <asm/page.h>
  15. #include <asm/vectors.h>
  16. #include <linux/bug.h>
  17. #include <linux/kernel.h>
  18. #include <linux/types.h>
  19. #define IOADDR(x) (XCHAL_KIO_BYPASS_VADDR + (x))
  20. #define IO_SPACE_LIMIT ~0
  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_nocache(unsigned long offset,
  29. unsigned long size)
  30. {
  31. if (offset >= XCHAL_KIO_PADDR
  32. && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
  33. return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
  34. else
  35. return xtensa_ioremap_nocache(offset, size);
  36. }
  37. static inline void __iomem *ioremap_cache(unsigned long offset,
  38. unsigned long size)
  39. {
  40. if (offset >= XCHAL_KIO_PADDR
  41. && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
  42. return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
  43. else
  44. return xtensa_ioremap_cache(offset, size);
  45. }
  46. #define ioremap_cache ioremap_cache
  47. #define ioremap_wc ioremap_nocache
  48. #define ioremap_wt ioremap_nocache
  49. static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
  50. {
  51. return ioremap_nocache(offset, size);
  52. }
  53. static inline void iounmap(volatile void __iomem *addr)
  54. {
  55. unsigned long va = (unsigned long) addr;
  56. if (!(va >= XCHAL_KIO_CACHED_VADDR &&
  57. va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) &&
  58. !(va >= XCHAL_KIO_BYPASS_VADDR &&
  59. va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
  60. xtensa_iounmap(addr);
  61. }
  62. #define virt_to_bus virt_to_phys
  63. #define bus_to_virt phys_to_virt
  64. #endif /* CONFIG_MMU */
  65. #endif /* __KERNEL__ */
  66. #include <asm-generic/io.h>
  67. #endif /* _XTENSA_IO_H */