Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/plat-omap/include/mach/memory.h |
| 3 | * |
| 4 | * Memory map for OMAP-1510 and 1610 |
| 5 | * |
| 6 | * Copyright (C) 2000 RidgeRun, Inc. |
| 7 | * Author: Greg Lonnon <glonnon@ridgerun.com> |
| 8 | * |
| 9 | * This file was derived from arch/arm/mach-intergrator/include/mach/memory.h |
| 10 | * Copyright (C) 1999 ARM Limited |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License as published by the |
| 14 | * Free Software Foundation; either version 2 of the License, or (at your |
| 15 | * option) any later version. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 20 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 23 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 24 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | * |
| 28 | * You should have received a copy of the GNU General Public License along |
| 29 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 30 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 31 | */ |
| 32 | |
| 33 | #ifndef __ASM_ARCH_MEMORY_H |
| 34 | #define __ASM_ARCH_MEMORY_H |
| 35 | |
| 36 | /* |
| 37 | * Physical DRAM offset. |
| 38 | */ |
| 39 | #if defined(CONFIG_ARCH_OMAP1) |
Russell King | f4117ac | 2011-01-04 18:07:14 +0000 | [diff] [blame] | 40 | #define PLAT_PHYS_OFFSET UL(0x10000000) |
Tony Lindgren | 140455f | 2010-02-12 12:26:48 -0800 | [diff] [blame] | 41 | #else |
Russell King | f4117ac | 2011-01-04 18:07:14 +0000 | [diff] [blame] | 42 | #define PLAT_PHYS_OFFSET UL(0x80000000) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 43 | #endif |
| 44 | |
| 45 | /* |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 46 | * Bus address is physical address, except for OMAP-1510 Local Bus. |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 47 | * OMAP-1510 bus address is translated into a Local Bus address if the |
| 48 | * OMAP bus type is lbus. We do the address translation based on the |
| 49 | * device overriding the defaults used in the dma-mapping API. |
| 50 | * Note that the is_lbus_device() test is not very efficient on 1510 |
| 51 | * because of the strncmp(). |
| 52 | */ |
| 53 | #ifdef CONFIG_ARCH_OMAP15XX |
| 54 | |
| 55 | /* |
| 56 | * OMAP-1510 Local Bus address offset |
| 57 | */ |
| 58 | #define OMAP1510_LB_OFFSET UL(0x30000000) |
| 59 | |
| 60 | #define virt_to_lbus(x) ((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET) |
| 61 | #define lbus_to_virt(x) ((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET) |
Kay Sievers | 1d559e2 | 2009-01-06 10:44:43 -0800 | [diff] [blame] | 62 | #define is_lbus_device(dev) (cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0)) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 63 | |
Russell King | 9eedd96 | 2011-01-03 00:00:17 +0000 | [diff] [blame] | 64 | #define __arch_pfn_to_dma(dev, pfn) \ |
| 65 | ({ dma_addr_t __dma = __pfn_to_phys(pfn); \ |
Nicolas Pitre | 58edb51 | 2008-09-09 15:54:13 -0400 | [diff] [blame] | 66 | if (is_lbus_device(dev)) \ |
| 67 | __dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \ |
| 68 | __dma; }) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 69 | |
Russell King | 9eedd96 | 2011-01-03 00:00:17 +0000 | [diff] [blame] | 70 | #define __arch_dma_to_pfn(dev, addr) \ |
Russell King | ef1baed | 2009-10-31 16:07:16 +0000 | [diff] [blame] | 71 | ({ dma_addr_t __dma = addr; \ |
| 72 | if (is_lbus_device(dev)) \ |
| 73 | __dma += PHYS_OFFSET - OMAP1510_LB_OFFSET; \ |
Russell King | 9eedd96 | 2011-01-03 00:00:17 +0000 | [diff] [blame] | 74 | __phys_to_pfn(__dma); \ |
Russell King | ef1baed | 2009-10-31 16:07:16 +0000 | [diff] [blame] | 75 | }) |
| 76 | |
Russell King | 98ed7d4 | 2008-08-10 12:10:49 +0100 | [diff] [blame] | 77 | #define __arch_dma_to_virt(dev, addr) ({ (void *) (is_lbus_device(dev) ? \ |
| 78 | lbus_to_virt(addr) : \ |
Nicolas Pitre | b5ee900 | 2008-09-05 21:53:30 -0400 | [diff] [blame] | 79 | __phys_to_virt(addr)); }) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 80 | |
Russell King | 98ed7d4 | 2008-08-10 12:10:49 +0100 | [diff] [blame] | 81 | #define __arch_virt_to_dma(dev, addr) ({ unsigned long __addr = (unsigned long)(addr); \ |
| 82 | (dma_addr_t) (is_lbus_device(dev) ? \ |
| 83 | virt_to_lbus(__addr) : \ |
Nicolas Pitre | b5ee900 | 2008-09-05 21:53:30 -0400 | [diff] [blame] | 84 | __virt_to_phys(__addr)); }) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 85 | |
| 86 | #endif /* CONFIG_ARCH_OMAP15XX */ |
| 87 | |
| 88 | /* Override the ARM default */ |
| 89 | #ifdef CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE |
| 90 | |
| 91 | #if (CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE == 0) |
| 92 | #undef CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE |
| 93 | #define CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE 2 |
| 94 | #endif |
| 95 | |
| 96 | #define CONSISTENT_DMA_SIZE \ |
| 97 | (((CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE + 1) & ~1) * 1024 * 1024) |
| 98 | |
| 99 | #endif |
| 100 | |
| 101 | #endif |
| 102 | |