1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
6 * Copyright (C) 1996, 99 Ralf Baechle
7 * Copyright (C) 2000, 2002 Maciej W. Rozycki
8 * Copyright (C) 1990, 1999 by Silicon Graphics, Inc.
10 #ifndef _ASM_ADDRSPACE_H
11 #define _ASM_ADDRSPACE_H
13 #include <linux/const.h>
14 #include <linux/sizes.h>
16 #include <asm/loongarch.h>
19 * This gives the physical RAM offset.
23 #define PHYS_OFFSET _UL(0)
25 extern unsigned long vm_map_base
;
26 #endif /* __ASSEMBLY__ */
29 #define IO_BASE CSR_DMW0_BASE
33 #define CACHE_BASE CSR_DMW1_BASE
37 #define UNCACHE_BASE CSR_DMW0_BASE
40 #ifndef WRITECOMBINE_BASE
41 #define WRITECOMBINE_BASE CSR_DMW2_BASE
45 #define TO_PHYS_MASK ((1ULL << DMW_PABITS) - 1)
48 * Memory above this physical address will be considered highmem.
51 #define HIGHMEM_START (_UL(1) << _UL(DMW_PABITS))
54 #define TO_PHYS(x) ( ((x) & TO_PHYS_MASK))
55 #define TO_CACHE(x) (CACHE_BASE | ((x) & TO_PHYS_MASK))
56 #define TO_UNCACHE(x) (UNCACHE_BASE | ((x) & TO_PHYS_MASK))
59 * This handles the memory map.
62 #define PAGE_OFFSET (CACHE_BASE + PHYS_OFFSET)
66 #define FIXADDR_TOP ((unsigned long)(long)(int)0xfffe0000)
74 #define _ATYPE_ __PTRDIFF_TYPE__
76 #define _ATYPE64_ __s64
80 #define _CONST64_(x) _UL(x)
82 #define _CONST64_(x) _ULL(x)
86 * 32/64-bit LoongArch address spaces
92 #define _ACAST32_ (_ATYPE_)(_ATYPE32_) /* widen if necessary */
93 #define _ACAST64_ (_ATYPE64_) /* do _not_ narrow */
98 #define UVRANGE 0x00000000
99 #define KPRANGE0 0x80000000
100 #define KPRANGE1 0xa0000000
101 #define KVRANGE 0xc0000000
105 #define XUVRANGE _CONST64_(0x0000000000000000)
106 #define XSPRANGE _CONST64_(0x4000000000000000)
107 #define XKPRANGE _CONST64_(0x8000000000000000)
108 #define XKVRANGE _CONST64_(0xc000000000000000)
113 * Returns the physical address of a KPRANGEx / XKPRANGE address
115 #define PHYSADDR(a) ((_ACAST64_(a)) & TO_PHYS_MASK)
118 * On LoongArch, I/O ports mappring is following:
121 * |-----------------------|
122 * | pci io ports(16K~32M) |
123 * |-----------------------|
124 * | isa io ports(0 ~16K) |
125 * PCI_IOBASE ->|-----------------------|
128 #define PCI_IOBASE ((void __iomem *)(vm_map_base + (2 * PAGE_SIZE)))
129 #define PCI_IOSIZE SZ_32M
130 #define ISA_IOSIZE SZ_16K
131 #define IO_SPACE_LIMIT (PCI_IOSIZE - 1)
133 #define PHYS_LINK_KADDR PHYSADDR(VMLINUX_LOAD_ADDRESS)
135 #endif /* _ASM_ADDRSPACE_H */