1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 */ 4 #include <linux/fs.h> 5 #include <linux/fcntl.h> 6 #include <linux/memblock.h> 7 #include <linux/mm.h> 8 9 #include <asm/bootinfo.h> 10 11 #include <loongson.h> 12 #include <mem.h> 13 #include <pci.h> 14 15 16 u32 memsize, highmemsize; 17 18 void __init prom_init_memory(void) 19 { 20 memblock_add(0x0, (memsize << 20)); 21 22 #ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG 23 { 24 int bit; 25 26 bit = fls(memsize + highmemsize); 27 if (bit != ffs(memsize + highmemsize)) 28 bit += 20; 29 else 30 bit = bit + 20 - 1; 31 32 /* set cpu window3 to map CPU to DDR: 2G -> 2G */ 33 LOONGSON_ADDRWIN_CPUTODDR(ADDRWIN_WIN3, 0x80000000ul, 34 0x80000000ul, (1 << bit)); 35 mmiowb(); 36 } 37 #endif /* !CONFIG_CPU_SUPPORTS_ADDRWINCFG */ 38 39 #ifdef CONFIG_64BIT 40 if (highmemsize > 0) 41 memblock_add(LOONGSON_HIGHMEM_START, highmemsize << 20); 42 #endif /* !CONFIG_64BIT */ 43 } 44 45 /* override of arch/mips/mm/cache.c: __uncached_access */ 46 int __uncached_access(struct file *file, unsigned long addr) 47 { 48 if (file->f_flags & O_DSYNC) 49 return 1; 50 51 return addr >= __pa(high_memory) || 52 ((addr >= LOONGSON_MMIO_MEM_START) && 53 (addr < LOONGSON_MMIO_MEM_END)); 54 } 55