mem.c 845 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include <asm/bootinfo.h>
  9. #include <loongson.h>
  10. #include <mem.h>
  11. #include <pci.h>
  12. u32 memsize, highmemsize;
  13. void __init prom_init_memory(void)
  14. {
  15. memblock_add(0x0, (memsize << 20));
  16. #ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG
  17. {
  18. int bit;
  19. bit = fls(memsize + highmemsize);
  20. if (bit != ffs(memsize + highmemsize))
  21. bit += 20;
  22. else
  23. bit = bit + 20 - 1;
  24. /* set cpu window3 to map CPU to DDR: 2G -> 2G */
  25. LOONGSON_ADDRWIN_CPUTODDR(ADDRWIN_WIN3, 0x80000000ul,
  26. 0x80000000ul, (1 << bit));
  27. mmiowb();
  28. }
  29. #endif /* !CONFIG_CPU_SUPPORTS_ADDRWINCFG */
  30. #ifdef CONFIG_64BIT
  31. if (highmemsize > 0)
  32. memblock_add(LOONGSON_HIGHMEM_START, highmemsize << 20);
  33. #endif /* !CONFIG_64BIT */
  34. }