Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 1 | #ifndef __ASM_ARCH_MEMORY_H |
| 2 | #define __ASM_ARCH_MEMORY_H |
| 3 | |
| 4 | #include <asm/arch/hardware.h> |
| 5 | |
| 6 | /* |
| 7 | * Physical DRAM offset. |
| 8 | */ |
| 9 | #define PHYS_OFFSET UL(0x00000000) |
| 10 | #define TASK_SIZE UL(0x3f000000) |
| 11 | #define PAGE_OFFSET UL(0x40000000) |
| 12 | #define TASK_UNMAPPED_BASE ((TASK_SIZE + 0x01000000) / 3) |
| 13 | |
| 14 | #ifndef __ASSEMBLY__ |
| 15 | |
| 16 | #if defined(CONFIG_ARCH_IOP13XX) |
| 17 | #define IOP13XX_PMMR_V_START (IOP13XX_PMMR_VIRT_MEM_BASE) |
| 18 | #define IOP13XX_PMMR_V_END (IOP13XX_PMMR_VIRT_MEM_BASE + IOP13XX_PMMR_SIZE) |
| 19 | #define IOP13XX_PMMR_P_START (IOP13XX_PMMR_PHYS_MEM_BASE) |
| 20 | #define IOP13XX_PMMR_P_END (IOP13XX_PMMR_PHYS_MEM_BASE + IOP13XX_PMMR_SIZE) |
| 21 | |
| 22 | /* |
| 23 | * Virtual view <-> PCI DMA view memory address translations |
| 24 | * virt_to_bus: Used to translate the virtual address to an |
| 25 | * address suitable to be passed to set_dma_addr |
| 26 | * bus_to_virt: Used to convert an address for DMA operations |
| 27 | * to an address that the kernel can use. |
| 28 | */ |
| 29 | |
| 30 | /* RAM has 1:1 mapping on the PCIe/x Busses */ |
| 31 | #define __virt_to_bus(x) (__virt_to_phys(x)) |
| 32 | #define __bus_to_virt(x) (__phys_to_virt(x)) |
| 33 | |
| 34 | #define virt_to_lbus(x) \ |
| 35 | (( ((void*)(x) >= (void*)IOP13XX_PMMR_V_START) && \ |
| 36 | ((void*)(x) < (void*)IOP13XX_PMMR_V_END) ) ? \ |
| 37 | ((x) - IOP13XX_PMMR_VIRT_MEM_BASE + IOP13XX_PMMR_PHYS_MEM_BASE) : \ |
| 38 | ((x) - PAGE_OFFSET + PHYS_OFFSET)) |
| 39 | |
| 40 | #define lbus_to_virt(x) \ |
| 41 | (( ((x) >= IOP13XX_PMMR_P_START) && ((x) < IOP13XX_PMMR_P_END) ) ? \ |
| 42 | ((x) - IOP13XX_PMMR_PHYS_MEM_BASE + IOP13XX_PMMR_VIRT_MEM_BASE ) : \ |
| 43 | ((x) - PHYS_OFFSET + PAGE_OFFSET)) |
| 44 | |
| 45 | /* Device is an lbus device if it is on the platform bus of the IOP13XX */ |
| 46 | #define is_lbus_device(dev) (dev &&\ |
| 47 | (strncmp(dev->bus->name, "platform", 8) == 0)) |
| 48 | |
| 49 | #define __arch_page_to_dma(dev, page) \ |
| 50 | ({is_lbus_device(dev) ? (dma_addr_t)virt_to_lbus(page_address(page)) : \ |
| 51 | (dma_addr_t)__virt_to_bus(page_address(page));}) |
| 52 | |
| 53 | #define __arch_dma_to_virt(dev, addr) \ |
| 54 | ({is_lbus_device(dev) ? lbus_to_virt(addr) : __bus_to_virt(addr);}) |
| 55 | |
| 56 | #define __arch_virt_to_dma(dev, addr) \ |
| 57 | ({is_lbus_device(dev) ? virt_to_lbus(addr) : __virt_to_bus(addr);}) |
| 58 | |
| 59 | #endif /* CONFIG_ARCH_IOP13XX */ |
| 60 | #endif /* !ASSEMBLY */ |
| 61 | |
| 62 | #define PFN_TO_NID(addr) (0) |
| 63 | |
| 64 | #endif |