io.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * include/asm-arm/arch-orion/io.h
  3. *
  4. * Tzachi Perelstein <tzachi@marvell.com>
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #ifndef __ASM_ARCH_IO_H
  11. #define __ASM_ARCH_IO_H
  12. #include "orion.h"
  13. #define IO_SPACE_LIMIT 0xffffffff
  14. #define IO_SPACE_REMAP ORION_PCI_SYS_IO_BASE
  15. static inline void __iomem *
  16. __arch_ioremap(unsigned long paddr, size_t size, unsigned int mtype)
  17. {
  18. void __iomem *retval;
  19. if (mtype == MT_DEVICE && size && paddr >= ORION_REGS_PHYS_BASE &&
  20. paddr + size <= ORION_REGS_PHYS_BASE + ORION_REGS_SIZE) {
  21. retval = (void __iomem *)ORION_REGS_VIRT_BASE +
  22. (paddr - ORION_REGS_PHYS_BASE);
  23. } else {
  24. retval = __arm_ioremap(paddr, size, mtype);
  25. }
  26. return retval;
  27. }
  28. static inline void
  29. __arch_iounmap(void __iomem *addr)
  30. {
  31. if (addr < (void __iomem *)ORION_REGS_VIRT_BASE ||
  32. addr >= (void __iomem *)(ORION_REGS_VIRT_BASE + ORION_REGS_SIZE))
  33. __iounmap(addr);
  34. }
  35. static inline void __iomem *__io(unsigned long addr)
  36. {
  37. return (void __iomem *)addr;
  38. }
  39. #define __arch_ioremap(p, s, m) __arch_ioremap(p, s, m)
  40. #define __arch_iounmap(a) __arch_iounmap(a)
  41. #define __io(a) __io(a)
  42. #define __mem_pci(a) (a)
  43. /*****************************************************************************
  44. * Helpers to access Orion registers
  45. ****************************************************************************/
  46. #define orion_read(r) __raw_readl(r)
  47. #define orion_write(r, val) __raw_writel(val, r)
  48. /*
  49. * These are not preempt-safe. Locks, if needed, must be taken
  50. * care of by the caller.
  51. */
  52. #define orion_setbits(r, mask) orion_write((r), orion_read(r) | (mask))
  53. #define orion_clrbits(r, mask) orion_write((r), orion_read(r) & ~(mask))
  54. #endif