io.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * arch/arm/mach-orion5x/include/mach/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 "orion5x.h"
  13. #define IO_SPACE_LIMIT 0xffffffff
  14. static inline void __iomem *
  15. __arch_ioremap(unsigned long paddr, size_t size, unsigned int mtype)
  16. {
  17. void __iomem *retval;
  18. unsigned long offs = paddr - ORION5X_REGS_PHYS_BASE;
  19. if (mtype == MT_DEVICE && size && offs < ORION5X_REGS_SIZE &&
  20. size <= ORION5X_REGS_SIZE && offs + size <= ORION5X_REGS_SIZE) {
  21. retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + offs;
  22. } else {
  23. retval = __arm_ioremap(paddr, size, mtype);
  24. }
  25. return retval;
  26. }
  27. static inline void
  28. __arch_iounmap(void __iomem *addr)
  29. {
  30. if (addr < (void __iomem *)ORION5X_REGS_VIRT_BASE ||
  31. addr >= (void __iomem *)(ORION5X_REGS_VIRT_BASE + ORION5X_REGS_SIZE))
  32. __iounmap(addr);
  33. }
  34. #define __arch_ioremap(p, s, m) __arch_ioremap(p, s, m)
  35. #define __arch_iounmap(a) __arch_iounmap(a)
  36. #define __io(a) __typesafe_io(a)
  37. #define __mem_pci(a) (a)
  38. /*****************************************************************************
  39. * Helpers to access Orion registers
  40. ****************************************************************************/
  41. /*
  42. * These are not preempt-safe. Locks, if needed, must be taken
  43. * care of by the caller.
  44. */
  45. #define orion5x_setbits(r, mask) writel(readl(r) | (mask), (r))
  46. #define orion5x_clrbits(r, mask) writel(readl(r) & ~(mask), (r))
  47. #endif