1 // SPDX-License-Identifier: GPL-2.0-or-later
5 #include <linux/fcntl.h>
6 #include <linux/memblock.h>
9 #include <asm/bootinfo.h>
16 u32 memsize
, highmemsize
;
18 void __init
prom_init_memory(void)
20 add_memory_region(0x0, (memsize
<< 20), BOOT_MEM_RAM
);
22 add_memory_region(memsize
<< 20, LOONGSON_PCI_MEM_START
- (memsize
<<
23 20), BOOT_MEM_RESERVED
);
25 #ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG
29 bit
= fls(memsize
+ highmemsize
);
30 if (bit
!= ffs(memsize
+ highmemsize
))
35 /* set cpu window3 to map CPU to DDR: 2G -> 2G */
36 LOONGSON_ADDRWIN_CPUTODDR(ADDRWIN_WIN3
, 0x80000000ul
,
37 0x80000000ul
, (1 << bit
));
40 #endif /* !CONFIG_CPU_SUPPORTS_ADDRWINCFG */
44 add_memory_region(LOONGSON_HIGHMEM_START
,
45 highmemsize
<< 20, BOOT_MEM_RAM
);
47 add_memory_region(LOONGSON_PCI_MEM_END
+ 1, LOONGSON_HIGHMEM_START
-
48 LOONGSON_PCI_MEM_END
- 1, BOOT_MEM_RESERVED
);
50 #endif /* !CONFIG_64BIT */
53 /* override of arch/mips/mm/cache.c: __uncached_access */
54 int __uncached_access(struct file
*file
, unsigned long addr
)
56 if (file
->f_flags
& O_DSYNC
)
59 return addr
>= __pa(high_memory
) ||
60 ((addr
>= LOONGSON_MMIO_MEM_START
) &&
61 (addr
< LOONGSON_MMIO_MEM_END
));