io.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * linux/arch/unicore32/include/asm/io.h
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __UNICORE_IO_H__
  13. #define __UNICORE_IO_H__
  14. #ifdef __KERNEL__
  15. #include <asm/byteorder.h>
  16. #include <asm/memory.h>
  17. #define PCI_IOBASE PKUNITY_PCILIO_BASE
  18. #include <asm-generic/io.h>
  19. /*
  20. * __uc32_ioremap and __uc32_ioremap_cached takes CPU physical address.
  21. */
  22. extern void __iomem *__uc32_ioremap(unsigned long, size_t);
  23. extern void __iomem *__uc32_ioremap_cached(unsigned long, size_t);
  24. extern void __uc32_iounmap(volatile void __iomem *addr);
  25. /*
  26. * ioremap and friends.
  27. *
  28. * ioremap takes a PCI memory address, as specified in
  29. * Documentation/io-mapping.txt.
  30. *
  31. */
  32. #define ioremap(cookie, size) __uc32_ioremap(cookie, size)
  33. #define ioremap_cached(cookie, size) __uc32_ioremap_cached(cookie, size)
  34. #define ioremap_nocache(cookie, size) __uc32_ioremap(cookie, size)
  35. #define iounmap(cookie) __uc32_iounmap(cookie)
  36. #define readb_relaxed readb
  37. #define readw_relaxed readw
  38. #define readl_relaxed readl
  39. #define HAVE_ARCH_PIO_SIZE
  40. #define PIO_OFFSET (unsigned int)(PCI_IOBASE)
  41. #define PIO_MASK (unsigned int)(IO_SPACE_LIMIT)
  42. #define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1)
  43. #ifdef CONFIG_STRICT_DEVMEM
  44. #include <linux/ioport.h>
  45. #include <linux/mm.h>
  46. /*
  47. * devmem_is_allowed() checks to see if /dev/mem access to a certain
  48. * address is valid. The argument is a physical page number.
  49. * We mimic x86 here by disallowing access to system RAM as well as
  50. * device-exclusive MMIO regions. This effectively disable read()/write()
  51. * on /dev/mem.
  52. */
  53. static inline int devmem_is_allowed(unsigned long pfn)
  54. {
  55. if (iomem_is_exclusive(pfn << PAGE_SHIFT))
  56. return 0;
  57. if (!page_is_ram(pfn))
  58. return 1;
  59. return 0;
  60. }
  61. #endif /* CONFIG_STRICT_DEVMEM */
  62. #endif /* __KERNEL__ */
  63. #endif /* __UNICORE_IO_H__ */