env.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Based on Ocelot Linux port, which is
  4. * Copyright 2001 MontaVista Software Inc.
  5. * Author: [email protected] or [email protected]
  6. *
  7. * Copyright 2003 ICT CAS
  8. * Author: Michael Guo <[email protected]>
  9. *
  10. * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology
  11. * Author: Fuxin Zhang, [email protected]
  12. *
  13. * Copyright (C) 2009 Lemote Inc.
  14. * Author: Wu Zhangjin, [email protected]
  15. */
  16. #include <linux/export.h>
  17. #include <asm/bootinfo.h>
  18. #include <asm/fw/fw.h>
  19. #include <loongson.h>
  20. u32 cpu_clock_freq;
  21. EXPORT_SYMBOL(cpu_clock_freq);
  22. void __init prom_init_env(void)
  23. {
  24. /* pmon passes arguments in 32bit pointers */
  25. unsigned int processor_id;
  26. cpu_clock_freq = fw_getenvl("cpuclock");
  27. memsize = fw_getenvl("memsize");
  28. highmemsize = fw_getenvl("highmemsize");
  29. if (memsize == 0)
  30. memsize = 256;
  31. pr_info("memsize=%u, highmemsize=%u\n", memsize, highmemsize);
  32. if (cpu_clock_freq == 0) {
  33. processor_id = (&current_cpu_data)->processor_id;
  34. switch (processor_id & PRID_REV_MASK) {
  35. case PRID_REV_LOONGSON2E:
  36. cpu_clock_freq = 533080000;
  37. break;
  38. case PRID_REV_LOONGSON2F:
  39. cpu_clock_freq = 797000000;
  40. break;
  41. default:
  42. cpu_clock_freq = 100000000;
  43. break;
  44. }
  45. }
  46. pr_info("CpuClock = %u\n", cpu_clock_freq);
  47. }