io.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * include/asm-arm/arch-orion5x/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. #define IO_SPACE_REMAP ORION5X_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. unsigned long offs = paddr - ORION5X_REGS_PHYS_BASE;
  20. if (mtype == MT_DEVICE && size && offs < ORION5X_REGS_SIZE &&
  21. size <= ORION5X_REGS_SIZE && offs + size <= ORION5X_REGS_SIZE) {
  22. retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + offs;
  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 *)ORION5X_REGS_VIRT_BASE ||
  32. addr >= (void __iomem *)(ORION5X_REGS_VIRT_BASE + ORION5X_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 orion5x_read(r) __raw_readl(r)
  47. #define orion5x_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 orion5x_setbits(r, mask) orion5x_write((r), orion5x_read(r) | (mask))
  53. #define orion5x_clrbits(r, mask) orion5x_write((r), orion5x_read(r) & ~(mask))
  54. #endif