io.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include <asm/mach/map.h>
  14. #include <mach/common.h>
  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. struct map_desc *desc = davinci_soc_info.io_desc;
  21. int desc_num = davinci_soc_info.io_desc_num;
  22. int i;
  23. for (i = 0; i < desc_num; i++, desc++) {
  24. unsigned long iophys = __pfn_to_phys(desc->pfn);
  25. unsigned long iosize = desc->length;
  26. if (p >= iophys && (p + size) <= (iophys + iosize))
  27. return __io(desc->virtual + p - iophys);
  28. }
  29. return __arm_ioremap_caller(p, size, type,
  30. __builtin_return_address(0));
  31. }
  32. EXPORT_SYMBOL(davinci_ioremap);
  33. void davinci_iounmap(volatile void __iomem *addr)
  34. {
  35. unsigned long virt = (unsigned long)addr;
  36. if (virt >= VMALLOC_START && virt < VMALLOC_END)
  37. __iounmap(addr);
  38. }
  39. EXPORT_SYMBOL(davinci_iounmap);