io.c 986 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * DaVinci I/O mapping code
  3. *
  4. * Copyright (C) 2005-2006 Texas Instruments
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/io.h>
  12. #include <asm/tlb.h>
  13. #define BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz)))
  14. #define XLATE(p, pst, vst) ((void __iomem *)((p) - (pst) + (vst)))
  15. /*
  16. * Intercept ioremap() requests for addresses in our fixed mapping regions.
  17. */
  18. void __iomem *davinci_ioremap(unsigned long p, size_t size, unsigned int type)
  19. {
  20. if (BETWEEN(p, IO_PHYS, IO_SIZE))
  21. return XLATE(p, IO_PHYS, IO_VIRT);
  22. return __arm_ioremap(p, size, type);
  23. }
  24. EXPORT_SYMBOL(davinci_ioremap);
  25. void davinci_iounmap(volatile void __iomem *addr)
  26. {
  27. unsigned long virt = (unsigned long)addr;
  28. if (virt >= VMALLOC_START && virt < VMALLOC_END)
  29. __iounmap(addr);
  30. }
  31. EXPORT_SYMBOL(davinci_iounmap);