Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 1 | /* arch/arm/mach-lh7a40x/include/mach/memory.h |
| 2 | * |
| 3 | * Copyright (C) 2004 Coastal Environmental Systems |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * version 2 as published by the Free Software Foundation. |
| 8 | * |
| 9 | * |
| 10 | * Refer to <file:Documentation/arm/Sharp-LH/SDRAM> for more information. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef __ASM_ARCH_MEMORY_H |
| 15 | #define __ASM_ARCH_MEMORY_H |
| 16 | |
| 17 | /* |
| 18 | * Physical DRAM offset. |
| 19 | */ |
| 20 | #define PHYS_OFFSET UL(0xc0000000) |
| 21 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 22 | #ifdef CONFIG_DISCONTIGMEM |
| 23 | |
| 24 | /* |
| 25 | * Given a kernel address, find the home node of the underlying memory. |
| 26 | */ |
| 27 | |
| 28 | # ifdef CONFIG_LH7A40X_ONE_BANK_PER_NODE |
| 29 | # define KVADDR_TO_NID(addr) \ |
| 30 | ( ((((unsigned long) (addr) - PAGE_OFFSET) >> 24) & 1)\ |
| 31 | | ((((unsigned long) (addr) - PAGE_OFFSET) >> 25) & ~1)) |
| 32 | # else /* 2 banks per node */ |
| 33 | # define KVADDR_TO_NID(addr) \ |
| 34 | (((unsigned long) (addr) - PAGE_OFFSET) >> 26) |
| 35 | # endif |
| 36 | |
| 37 | /* |
| 38 | * Given a page frame number, convert it to a node id. |
| 39 | */ |
| 40 | |
| 41 | # ifdef CONFIG_LH7A40X_ONE_BANK_PER_NODE |
| 42 | # define PFN_TO_NID(pfn) \ |
| 43 | (((((pfn) - PHYS_PFN_OFFSET) >> (24 - PAGE_SHIFT)) & 1)\ |
| 44 | | ((((pfn) - PHYS_PFN_OFFSET) >> (25 - PAGE_SHIFT)) & ~1)) |
| 45 | # else /* 2 banks per node */ |
| 46 | # define PFN_TO_NID(pfn) \ |
| 47 | (((pfn) - PHYS_PFN_OFFSET) >> (26 - PAGE_SHIFT)) |
| 48 | #endif |
| 49 | |
| 50 | /* |
| 51 | * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory |
| 52 | * and returns the index corresponding to the appropriate page in the |
| 53 | * node's mem_map. |
| 54 | */ |
| 55 | |
| 56 | # ifdef CONFIG_LH7A40X_ONE_BANK_PER_NODE |
| 57 | # define LOCAL_MAP_NR(addr) \ |
| 58 | (((unsigned long)(addr) & 0x003fffff) >> PAGE_SHIFT) |
| 59 | # else /* 2 banks per node */ |
| 60 | # define LOCAL_MAP_NR(addr) \ |
| 61 | (((unsigned long)(addr) & 0x01ffffff) >> PAGE_SHIFT) |
| 62 | # endif |
| 63 | |
| 64 | #endif |
| 65 | |
Russell King | 4ba3f7c | 2008-10-01 21:38:23 +0100 | [diff] [blame] | 66 | /* |
| 67 | * Sparsemem version of the above |
| 68 | */ |
| 69 | #define MAX_PHYSMEM_BITS 32 |
| 70 | #define SECTION_SIZE_BITS 24 |
| 71 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 72 | #endif |