Path: blob/master/arch/loongarch/include/asm/addrspace.h
26488 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#define WRITECOMBINE_BASE CSR_DMW2_BASE41#endif4243#define DMW_PABITS 4844#define TO_PHYS_MASK ((1ULL << DMW_PABITS) - 1)4546/*47* Memory above this physical address will be considered highmem.48*/49#ifndef HIGHMEM_START50#define HIGHMEM_START (_UL(1) << _UL(DMW_PABITS))51#endif5253#define TO_PHYS(x) ( ((x) & TO_PHYS_MASK))54#define TO_CACHE(x) (CACHE_BASE | ((x) & TO_PHYS_MASK))55#define TO_UNCACHE(x) (UNCACHE_BASE | ((x) & TO_PHYS_MASK))5657/*58* This handles the memory map.59*/60#ifndef PAGE_OFFSET61#define PAGE_OFFSET (CACHE_BASE + PHYS_OFFSET)62#endif6364#ifndef FIXADDR_TOP65#define FIXADDR_TOP ((unsigned long)(long)(int)0xfffe0000)66#endif6768#ifdef __ASSEMBLER__69#define _ATYPE_70#define _ATYPE32_71#define _ATYPE64_72#else73#define _ATYPE_ __PTRDIFF_TYPE__74#define _ATYPE32_ int75#define _ATYPE64_ __s6476#endif7778#ifdef CONFIG_64BIT79#define _CONST64_(x) _UL(x)80#else81#define _CONST64_(x) _ULL(x)82#endif8384/*85* 32/64-bit LoongArch address spaces86*/87#ifdef __ASSEMBLER__88#define _ACAST32_89#define _ACAST64_90#else91#define _ACAST32_ (_ATYPE_)(_ATYPE32_) /* widen if necessary */92#define _ACAST64_ (_ATYPE64_) /* do _not_ narrow */93#endif9495#ifdef CONFIG_32BIT9697#define UVRANGE 0x0000000098#define KPRANGE0 0x8000000099#define KPRANGE1 0xa0000000100#define KVRANGE 0xc0000000101102#else103104#define XUVRANGE _CONST64_(0x0000000000000000)105#define XSPRANGE _CONST64_(0x4000000000000000)106#define XKPRANGE _CONST64_(0x8000000000000000)107#define XKVRANGE _CONST64_(0xc000000000000000)108109#endif110111/*112* Returns the physical address of a KPRANGEx / XKPRANGE address113*/114#define PHYSADDR(a) ((_ACAST64_(a)) & TO_PHYS_MASK)115116/*117* On LoongArch, I/O ports mappring is following:118*119* | .... |120* |-----------------------|121* | pci io ports(16K~32M) |122* |-----------------------|123* | isa io ports(0 ~16K) |124* PCI_IOBASE ->|-----------------------|125* | .... |126*/127#define PCI_IOBASE ((void __iomem *)(vm_map_base + (2 * PAGE_SIZE)))128#define PCI_IOSIZE SZ_32M129#define ISA_IOSIZE SZ_16K130#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)131132#define PHYS_LINK_KADDR PHYSADDR(VMLINUX_LOAD_ADDRESS)133134#endif /* _ASM_ADDRSPACE_H */135136137