Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 1 | #ifndef __ASM_ARCH_MEMORY_H |
| 2 | #define __ASM_ARCH_MEMORY_H |
| 3 | |
| 4 | #include <mach/hardware.h> |
| 5 | |
| 6 | /* |
| 7 | * Physical DRAM offset. |
| 8 | */ |
| 9 | #define PHYS_OFFSET UL(0x00000000) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 10 | |
| 11 | #ifndef __ASSEMBLY__ |
| 12 | |
| 13 | #if defined(CONFIG_ARCH_IOP13XX) |
| 14 | #define IOP13XX_PMMR_V_START (IOP13XX_PMMR_VIRT_MEM_BASE) |
| 15 | #define IOP13XX_PMMR_V_END (IOP13XX_PMMR_VIRT_MEM_BASE + IOP13XX_PMMR_SIZE) |
| 16 | #define IOP13XX_PMMR_P_START (IOP13XX_PMMR_PHYS_MEM_BASE) |
| 17 | #define IOP13XX_PMMR_P_END (IOP13XX_PMMR_PHYS_MEM_BASE + IOP13XX_PMMR_SIZE) |
| 18 | |
| 19 | /* |
| 20 | * Virtual view <-> PCI DMA view memory address translations |
| 21 | * virt_to_bus: Used to translate the virtual address to an |
| 22 | * address suitable to be passed to set_dma_addr |
| 23 | * bus_to_virt: Used to convert an address for DMA operations |
| 24 | * to an address that the kernel can use. |
| 25 | */ |
| 26 | |
| 27 | /* RAM has 1:1 mapping on the PCIe/x Busses */ |
| 28 | #define __virt_to_bus(x) (__virt_to_phys(x)) |
Russell King | 1562f98 | 2008-09-17 20:36:49 +0100 | [diff] [blame^] | 29 | #define __bus_to_virt(x) (__phys_to_virt(x)) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 30 | |
Russell King | 1562f98 | 2008-09-17 20:36:49 +0100 | [diff] [blame^] | 31 | static inline dma_addr_t __virt_to_lbus(unsigned long x) |
| 32 | { |
| 33 | return x + IOP13XX_PMMR_PHYS_MEM_BASE - IOP13XX_PMMR_VIRT_MEM_BASE; |
| 34 | } |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 35 | |
Russell King | 1562f98 | 2008-09-17 20:36:49 +0100 | [diff] [blame^] | 36 | static inline unsigned long __lbus_to_virt(dma_addr_t x) |
| 37 | { |
| 38 | return x + IOP13XX_PMMR_VIRT_MEM_BASE - IOP13XX_PMMR_PHYS_MEM_BASE; |
| 39 | } |
| 40 | |
| 41 | #define __is_lbus_dma(a) \ |
| 42 | ((a) >= IOP13XX_PMMR_P_START && (a) < IOP13XX_PMMR_P_END) |
| 43 | |
| 44 | #define __is_lbus_virt(a) \ |
| 45 | ((a) >= IOP13XX_PMMR_V_START && (a) < IOP13XX_PMMR_V_END) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 46 | |
| 47 | /* Device is an lbus device if it is on the platform bus of the IOP13XX */ |
Russell King | 1562f98 | 2008-09-17 20:36:49 +0100 | [diff] [blame^] | 48 | #define is_lbus_device(dev) \ |
| 49 | (dev && strncmp(dev->bus->name, "platform", 8) == 0) |
| 50 | |
| 51 | #define __arch_dma_to_virt(dev, addr) \ |
| 52 | ({ \ |
| 53 | unsigned long __virt; \ |
| 54 | dma_addr_t __dma = addr; \ |
| 55 | if (is_lbus_device(dev) && __is_lbus_dma(__dma)) \ |
| 56 | __virt = __lbus_to_virt(__dma); \ |
| 57 | else \ |
| 58 | __virt = __bus_to_virt(__dma); \ |
| 59 | (void *)__virt; \ |
| 60 | }) |
| 61 | |
| 62 | #define __arch_virt_to_dma(dev, addr) \ |
| 63 | ({ \ |
| 64 | unsigned long __virt = (unsigned long)addr; \ |
| 65 | dma_addr_t __dma; \ |
| 66 | if (is_lbus_device(dev) && __is_lbus_virt(__virt)) \ |
| 67 | __dma = __virt_to_lbus(__virt); \ |
| 68 | else \ |
| 69 | __dma = __virt_to_bus(__virt); \ |
| 70 | __dma; \ |
| 71 | }) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 72 | |
| 73 | #define __arch_page_to_dma(dev, page) \ |
Russell King | 1562f98 | 2008-09-17 20:36:49 +0100 | [diff] [blame^] | 74 | __arch_virt_to_dma(dev, page_address(page)) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 75 | |
| 76 | #endif /* CONFIG_ARCH_IOP13XX */ |
| 77 | #endif /* !ASSEMBLY */ |
| 78 | |
| 79 | #define PFN_TO_NID(addr) (0) |
| 80 | |
| 81 | #endif |