memory.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * arch/arm/mach-omap1/include/mach/memory.h
  3. */
  4. #ifndef __ASM_ARCH_MEMORY_H
  5. #define __ASM_ARCH_MEMORY_H
  6. /* REVISIT: omap1 legacy drivers still rely on this */
  7. #include <mach/soc.h>
  8. /*
  9. * Bus address is physical address, except for OMAP-1510 Local Bus.
  10. * OMAP-1510 bus address is translated into a Local Bus address if the
  11. * OMAP bus type is lbus. We do the address translation based on the
  12. * device overriding the defaults used in the dma-mapping API.
  13. * Note that the is_lbus_device() test is not very efficient on 1510
  14. * because of the strncmp().
  15. */
  16. #if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
  17. /*
  18. * OMAP-1510 Local Bus address offset
  19. */
  20. #define OMAP1510_LB_OFFSET UL(0x30000000)
  21. #define virt_to_lbus(x) ((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
  22. #define lbus_to_virt(x) ((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
  23. #define is_lbus_device(dev) (cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
  24. #define __arch_pfn_to_dma(dev, pfn) \
  25. ({ dma_addr_t __dma = __pfn_to_phys(pfn); \
  26. if (is_lbus_device(dev)) \
  27. __dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
  28. __dma; })
  29. #define __arch_dma_to_pfn(dev, addr) \
  30. ({ dma_addr_t __dma = addr; \
  31. if (is_lbus_device(dev)) \
  32. __dma += PHYS_OFFSET - OMAP1510_LB_OFFSET; \
  33. __phys_to_pfn(__dma); \
  34. })
  35. #define __arch_dma_to_virt(dev, addr) ({ (void *) (is_lbus_device(dev) ? \
  36. lbus_to_virt(addr) : \
  37. __phys_to_virt(addr)); })
  38. #define __arch_virt_to_dma(dev, addr) ({ unsigned long __addr = (unsigned long)(addr); \
  39. (dma_addr_t) (is_lbus_device(dev) ? \
  40. virt_to_lbus(__addr) : \
  41. __virt_to_phys(__addr)); })
  42. #endif /* CONFIG_ARCH_OMAP15XX */
  43. #endif