memory.h 1.7 KB

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