blob: 018a9f0e3986d2d8f2c53f7f33b7ef17cfb86dc2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/include/asm-arm/arch-sa1100/memory.h
3 *
4 * Copyright (C) 1999-2000 Nicolas Pitre <nico@cam.org>
5 */
6
7#ifndef __ASM_ARCH_MEMORY_H
8#define __ASM_ARCH_MEMORY_H
9
10#include <linux/config.h>
11#include <asm/sizes.h>
12
13/*
14 * Physical DRAM offset is 0xc0000000 on the SA1100
15 */
Nicolas Pitref09b9972005-10-29 21:44:55 +010016#define PHYS_OFFSET UL(0xc0000000)
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18#ifndef __ASSEMBLY__
19
20#ifdef CONFIG_SA1111
Russell King1b120502005-11-16 17:38:40 +000021void sa1111_adjust_zones(int node, unsigned long *size, unsigned long *holes);
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23#define arch_adjust_zones(node, size, holes) \
Russell King1b120502005-11-16 17:38:40 +000024 sa1111_adjust_zones(node, size, holes)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_1M - 1)
27
28#endif
29#endif
30
31/*
32 * Virtual view <-> DMA view memory address translations
33 * virt_to_bus: Used to translate the virtual address to an
34 * address suitable to be passed to set_dma_addr
35 * bus_to_virt: Used to convert an address for DMA operations
36 * to an address that the kernel can use.
37 *
38 * On the SA1100, bus addresses are equivalent to physical addresses.
39 */
40#define __virt_to_bus(x) __virt_to_phys(x)
41#define __bus_to_virt(x) __phys_to_virt(x)
42
43#ifdef CONFIG_DISCONTIGMEM
44/*
45 * Because of the wide memory address space between physical RAM banks on the
46 * SA1100, it's much convenient to use Linux's NUMA support to implement our
47 * memory map representation. Assuming all memory nodes have equal access
48 * characteristics, we then have generic discontiguous memory support.
49 *
50 * Of course, all this isn't mandatory for SA1100 implementations with only
51 * one used memory bank. For those, simply undefine CONFIG_DISCONTIGMEM.
52 *
53 * The nodes are matched with the physical memory bank addresses which are
54 * incidentally the same as virtual addresses.
55 *
56 * node 0: 0xc0000000 - 0xc7ffffff
57 * node 1: 0xc8000000 - 0xcfffffff
58 * node 2: 0xd0000000 - 0xd7ffffff
59 * node 3: 0xd8000000 - 0xdfffffff
60 */
61
62/*
63 * Given a kernel address, find the home node of the underlying memory.
64 */
65#define KVADDR_TO_NID(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> 27)
66
67/*
68 * Given a page frame number, convert it to a node id.
69 */
70#define PFN_TO_NID(pfn) (((pfn) - PHYS_PFN_OFFSET) >> (27 - PAGE_SHIFT))
71
72/*
73 * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
74 * and return the mem_map of that node.
75 */
76#define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
77
78/*
79 * Given a page frame number, find the owning node of the memory
80 * and return the mem_map of that node.
81 */
82#define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn))
83
84/*
85 * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
86 * and returns the index corresponding to the appropriate page in the
87 * node's mem_map.
88 */
89#define LOCAL_MAP_NR(addr) \
90 (((unsigned long)(addr) & 0x07ffffff) >> PAGE_SHIFT)
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#endif
93
94#endif