memory.h 1.6 KB

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