1 /* include/asm-arm/arch-lh7a40x/memory.h
3 * Copyright (C) 2004 Coastal Environmental Systems
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.
11 #ifndef __ASM_ARCH_MEMORY_H
12 #define __ASM_ARCH_MEMORY_H
15 #define BANKS_PER_NODE 1 /* Define as either 1 or 2 */
18 * Physical DRAM offset.
20 #define PHYS_OFFSET (0xc0000000UL)
23 * Virtual view <-> 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.
29 #define __virt_to_bus(x) __virt_to_phys(x)
30 #define __bus_to_virt(x) __phys_to_virt(x)
32 #ifdef CONFIG_DISCONTIGMEM
34 * Because of the wide memory address space between physical RAM
35 * banks, it's convenient to use Linux's NUMA support to represent our
36 * memory map. Assuming all memory nodes have equal access
37 * characteristics, we then have a generic discontiguous memory setup.
39 * Of course, all this isn't mandatory for implementations with only
40 * one used memory bank. For those, simply undefine
41 * CONFIG_DISCONTIGMEM. However, keep in mind that a featurefull
42 * system will need more than 4MiB of RAM.
44 * The contiguous memory blocks are small enough that it pays to
45 * aggregate two banks into one node. Setting BANKS_PER_NODE to 2
46 * puts pairs of banks into a node.
48 * A typical layout would start like this:
57 * The proximity of the pairs of blocks makes it feasible to combine them.
62 * Given a kernel address, find the home node of the underlying memory.
66 #define KVADDR_TO_NID(addr) \
67 ( ((((unsigned long) (addr) - PAGE_OFFSET) >> 24) & 1)\
68 | ((((unsigned long) (addr) - PAGE_OFFSET) >> 25) & ~1))
69 #else /* 2 banks per node */
70 #define KVADDR_TO_NID(addr) \
71 ((unsigned long) (addr) - PAGE_OFFSET) >> 26)
75 * Given a page frame number, convert it to a node id.
79 #define PFN_TO_NID(pfn) \
80 (((((pfn) - PHYS_PFN_OFFSET) >> (24 - PAGE_SHIFT)) & 1)\
81 | ((((pfn) - PHYS_PFN_OFFSET) >> (25 - PAGE_SHIFT)) & ~1))
82 #else /* 2 banks per node */
83 #define PFN_TO_NID(addr) \
84 (((pfn) - PHYS_PFN_OFFSET) >> (26 - PAGE_SHIFT))
88 * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
89 * and return the mem_map of that node.
91 #define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
94 * Given a page frame number, find the owning node of the memory
95 * and return the mem_map of that node.
97 #define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn))
100 * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
101 * and returns the index corresponding to the appropriate page in the
105 #if BANKS_PER_NODE==1
106 #define LOCAL_MAP_NR(addr) \
107 (((unsigned long)(addr) & 0x003fffff) >> PAGE_SHIFT)
108 #else /* 2 banks per node */
109 #define LOCAL_MAP_NR(addr) \
110 (((unsigned long)(addr) & 0x01ffffff) >> PAGE_SHIFT)
115 #define PFN_TO_NID(addr) (0)