Path: blob/master/arch/loongarch/include/asm/addrspace.h
50920 views
/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright (C) 2020-2022 Loongson Technology Corporation Limited3*4* Derived from MIPS:5* Copyright (C) 1996, 99 Ralf Baechle6* Copyright (C) 2000, 2002 Maciej W. Rozycki7* Copyright (C) 1990, 1999 by Silicon Graphics, Inc.8*/9#ifndef _ASM_ADDRSPACE_H10#define _ASM_ADDRSPACE_H1112#include <linux/const.h>13#include <linux/sizes.h>1415#include <asm/loongarch.h>1617/*18* This gives the physical RAM offset.19*/20#ifndef __ASSEMBLER__21#ifndef PHYS_OFFSET22#define PHYS_OFFSET _UL(0)23#endif24extern unsigned long vm_map_base;25#endif /* __ASSEMBLER__ */2627#ifndef IO_BASE28#define IO_BASE CSR_DMW0_BASE29#endif3031#ifndef CACHE_BASE32#define CACHE_BASE CSR_DMW1_BASE33#endif3435#ifndef UNCACHE_BASE36#define UNCACHE_BASE CSR_DMW0_BASE37#endif3839#ifndef WRITECOMBINE_BASE40#ifdef CONFIG_32BIT41#define WRITECOMBINE_BASE CSR_DMW0_BASE42#else43#define WRITECOMBINE_BASE CSR_DMW2_BASE44#endif45#endif4647#ifdef CONFIG_32BIT48#define DMW_PABITS 2949#define TO_PHYS_MASK ((_UL(1) << _UL(DMW_PABITS)) - 1)50#else51#define DMW_PABITS 4852#define TO_PHYS_MASK ((_ULL(1) << _ULL(DMW_PABITS)) - 1)53#endif5455/*56* Memory above this physical address will be considered highmem.57*/58#ifndef HIGHMEM_START59#define HIGHMEM_START (_UL(1) << _UL(DMW_PABITS))60#endif6162#define TO_PHYS(x) ( ((x) & TO_PHYS_MASK))63#define TO_CACHE(x) (CACHE_BASE | ((x) & TO_PHYS_MASK))64#define TO_UNCACHE(x) (UNCACHE_BASE | ((x) & TO_PHYS_MASK))6566/*67* This handles the memory map.68*/69#ifndef PAGE_OFFSET70#define PAGE_OFFSET (CACHE_BASE + PHYS_OFFSET)71#endif7273#ifndef FIXADDR_TOP74#define FIXADDR_TOP ((unsigned long)(long)(int)0xfffe0000)75#endif7677#ifdef __ASSEMBLER__78#define _ATYPE_79#define _ATYPE32_80#define _ATYPE64_81#else82#define _ATYPE_ __PTRDIFF_TYPE__83#define _ATYPE32_ int84#define _ATYPE64_ __s6485#endif8687#ifdef CONFIG_64BIT88#define _CONST64_(x) _UL(x)89#else90#define _CONST64_(x) _ULL(x)91#endif9293/*94* 32/64-bit LoongArch address spaces95*/96#ifdef __ASSEMBLER__97#define _ACAST32_98#define _ACAST64_99#else100#define _ACAST32_ (_ATYPE_)(_ATYPE32_) /* widen if necessary */101#define _ACAST64_ (_ATYPE64_) /* do _not_ narrow */102#endif103104#ifdef CONFIG_32BIT105106#define UVRANGE 0x00000000107#define KPRANGE0 0x80000000108#define KPRANGE1 0xa0000000109#define KVRANGE 0xc0000000110111#else112113#define XUVRANGE _CONST64_(0x0000000000000000)114#define XSPRANGE _CONST64_(0x4000000000000000)115#define XKPRANGE _CONST64_(0x8000000000000000)116#define XKVRANGE _CONST64_(0xc000000000000000)117118#endif119120/*121* Returns the physical address of a KPRANGEx / XKPRANGE address122*/123#ifdef CONFIG_32BIT124#define PHYSADDR(a) ((_ACAST32_(a)) & TO_PHYS_MASK)125#else126#define PHYSADDR(a) ((_ACAST64_(a)) & TO_PHYS_MASK)127#endif128129/*130* On LoongArch, I/O ports mappring is following:131*132* | .... |133* |-----------------------|134* | pci io ports(16K~32M) |135* |-----------------------|136* | isa io ports(0 ~16K) |137* PCI_IOBASE ->|-----------------------|138* | .... |139*/140#define PCI_IOBASE ((void __iomem *)(vm_map_base + (2 * PAGE_SIZE)))141#define PCI_IOSIZE SZ_32M142#define ISA_IOSIZE SZ_16K143#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)144145#define PHYS_LINK_KADDR PHYSADDR(VMLINUX_LOAD_ADDRESS)146147#endif /* _ASM_ADDRSPACE_H */148149150