1/*
2 * arch/arm/mach-omap1/include/mach/memory.h
3 */
4
5#ifndef __ASM_ARCH_MEMORY_H
6#define __ASM_ARCH_MEMORY_H
7
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#include <mach/soc.h>
18
19/*
20 * OMAP-1510 Local Bus address offset
21 */
22#define OMAP1510_LB_OFFSET	UL(0x30000000)
23
24#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
25#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
26#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
27
28#define __arch_pfn_to_dma(dev, pfn)	\
29	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
30	   if (is_lbus_device(dev)) \
31		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
32	   __dma; })
33
34#define __arch_dma_to_pfn(dev, addr)	\
35	({ dma_addr_t __dma = addr;				\
36	   if (is_lbus_device(dev))				\
37		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
38	   __phys_to_pfn(__dma);				\
39	})
40
41#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
42						lbus_to_virt(addr) : \
43						__phys_to_virt(addr)); })
44
45#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
46					   (dma_addr_t) (is_lbus_device(dev) ? \
47						virt_to_lbus(__addr) : \
48						__virt_to_phys(__addr)); })
49
50#endif	/* CONFIG_ARCH_OMAP15XX */
51
52#endif
53