]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/asm-arm/arch-s3c24x0/memory.h
Big white-space cleanup.
[karo-tx-uboot.git] / include / asm-arm / arch-s3c24x0 / memory.h
1 /*
2  * linux/include/asm-arm/arch-s3c2400/memory.h by gj@denx.de
3  * based on
4  * linux/include/asm-arm/arch-sa1100/memory.h
5  *
6  * Copyright (c) 1999 Nicolas Pitre <nico@visuaide.com>
7  */
8
9 #ifndef __ASM_ARCH_MEMORY_H
10 #define __ASM_ARCH_MEMORY_H
11
12
13 /*
14  * Task size: 3GB
15  */
16 #define TASK_SIZE       (0xc0000000UL)
17 #define TASK_SIZE_26    (0x04000000UL)
18
19 /*
20  * This decides where the kernel will search for a free chunk of vm
21  * space during mmap's.
22  */
23 #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
24
25 /*
26  * Page offset: 3GB
27  */
28 #define PAGE_OFFSET     (0xc0000000UL)
29
30 /*
31  * Physical DRAM offset is 0x0c000000 on the S3C2400
32  */
33 #define PHYS_OFFSET     (0x0c000000UL)
34
35 #include <linux/config.h>
36
37
38 /* Modified for S3C2400, by chc, 20010509 */
39 #define RAM_IN_BANK_0  32*1024*1024
40 #define RAM_IN_BANK_1  0
41 #define RAM_IN_BANK_2  0
42 #define RAM_IN_BANK_3  0
43
44 #define MEM_SIZE  (RAM_IN_BANK_0+RAM_IN_BANK_1+RAM_IN_BANK_2+RAM_IN_BANK_3)
45
46
47 /* translation macros */
48 #define __virt_to_phys__is_a_macro
49 #define __phys_to_virt__is_a_macro
50
51 #if (RAM_IN_BANK_1 + RAM_IN_BANK_2 + RAM_IN_BANK_3 == 0)
52
53 #define __virt_to_phys(x) ( (x) - PAGE_OFFSET + 0x0c000000 )
54 #define __phys_to_virt(x) ( (x) - 0x0c000000 + PAGE_OFFSET )
55
56 #elif (RAM_IN_BANK_0 == RAM_IN_BANK_1) && \
57       (RAM_IN_BANK_2 + RAM_IN_BANK_3 == 0)
58
59 /* Two identical banks */
60 #define __virt_to_phys(x) \
61           ( ((x) < PAGE_OFFSET+RAM_IN_BANK_0) ? \
62             ((x) - PAGE_OFFSET + _DRAMBnk0) : \
63             ((x) - PAGE_OFFSET - RAM_IN_BANK_0 + _DRAMBnk1) )
64 #define __phys_to_virt(x) \
65           ( ((x)&0x07ffffff) + \
66             (((x)&0x08000000) ? PAGE_OFFSET+RAM_IN_BANK_0 : PAGE_OFFSET) )
67 #else
68
69 /* It's more efficient for all other cases to use the function call */
70 #undef __virt_to_phys__is_a_macro
71 #undef __phys_to_virt__is_a_macro
72 extern unsigned long __virt_to_phys(unsigned long vpage);
73 extern unsigned long __phys_to_virt(unsigned long ppage);
74
75 #endif
76
77 /*
78  * Virtual view <-> DMA view memory address translations
79  * virt_to_bus: Used to translate the virtual address to an
80  *              address suitable to be passed to set_dma_addr
81  * bus_to_virt: Used to convert an address for DMA operations
82  *              to an address that the kernel can use.
83  *
84  * On the SA1100, bus addresses are equivalent to physical addresses.
85  */
86 #define __virt_to_bus__is_a_macro
87 #define __virt_to_bus(x)        __virt_to_phys(x)
88 #define __bus_to_virt__is_a_macro
89 #define __bus_to_virt(x)        __phys_to_virt(x)
90
91
92 #ifdef CONFIG_DISCONTIGMEM
93 #error "CONFIG_DISCONTIGMEM will not work on S3C2400"
94 /*
95  * Because of the wide memory address space between physical RAM banks on the
96  * SA1100, it's much more convenient to use Linux's NUMA support to implement
97  * our memory map representation.  Assuming all memory nodes have equal access
98  * characteristics, we then have generic discontiguous memory support.
99  *
100  * Of course, all this isn't mandatory for SA1100 implementations with only
101  * one used memory bank.  For those, simply undefine CONFIG_DISCONTIGMEM.
102  *
103  * The nodes are matched with the physical memory bank addresses which are
104  * incidentally the same as virtual addresses.
105  *
106  *      node 0:  0xc0000000 - 0xc7ffffff
107  *      node 1:  0xc8000000 - 0xcfffffff
108  *      node 2:  0xd0000000 - 0xd7ffffff
109  *      node 3:  0xd8000000 - 0xdfffffff
110  */
111
112 #define NR_NODES        4
113
114 /*
115  * Given a kernel address, find the home node of the underlying memory.
116  */
117 #define KVADDR_TO_NID(addr) \
118                 (((unsigned long)(addr) - 0xc0000000) >> 27)
119
120 /*
121  * Given a physical address, convert it to a node id.
122  */
123 #define PHYS_TO_NID(addr) KVADDR_TO_NID(__phys_to_virt(addr))
124
125 /*
126  * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
127  * and returns the mem_map of that node.
128  */
129 #define ADDR_TO_MAPBASE(kaddr) \
130                         NODE_MEM_MAP(KVADDR_TO_NID((unsigned long)(kaddr)))
131
132 /*
133  * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
134  * and returns the index corresponding to the appropriate page in the
135  * node's mem_map.
136  */
137 #define LOCAL_MAP_NR(kvaddr) \
138         (((unsigned long)(kvaddr) & 0x07ffffff) >> PAGE_SHIFT)
139
140 /*
141  * Given a kaddr, virt_to_page returns a pointer to the corresponding
142  * mem_map entry.
143  */
144 #define virt_to_page(kaddr) \
145         (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr))
146
147 /*
148  * VALID_PAGE returns a non-zero value if given page pointer is valid.
149  * This assumes all node's mem_maps are stored within the node they refer to.
150  */
151 #define VALID_PAGE(page) \
152 ({ unsigned int node = KVADDR_TO_NID(page); \
153    ( (node < NR_NODES) && \
154      ((unsigned)((page) - NODE_MEM_MAP(node)) < NODE_DATA(node)->node_size) ); \
155 })
156
157 #else
158
159 #define PHYS_TO_NID(addr)       (0)
160
161 #endif
162 #endif /* __ASM_ARCH_MEMORY_H */