cpucfg-emul.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_MACH_LOONGSON64_CPUCFG_EMUL_H_
  3. #define _ASM_MACH_LOONGSON64_CPUCFG_EMUL_H_
  4. #include <asm/cpu-info.h>
  5. #ifdef CONFIG_CPU_LOONGSON3_CPUCFG_EMULATION
  6. #include <loongson_regs.h>
  7. #define LOONGSON_FPREV_MASK 0x7
  8. void loongson3_cpucfg_synthesize_data(struct cpuinfo_mips *c);
  9. static inline bool loongson3_cpucfg_emulation_enabled(struct cpuinfo_mips *c)
  10. {
  11. /* All supported cores have non-zero LOONGSON_CFG1 data. */
  12. return c->loongson3_cpucfg_data[0] != 0;
  13. }
  14. static inline u32 loongson3_cpucfg_read_synthesized(struct cpuinfo_mips *c,
  15. __u64 sel)
  16. {
  17. switch (sel) {
  18. case LOONGSON_CFG0:
  19. return c->processor_id;
  20. case LOONGSON_CFG1:
  21. case LOONGSON_CFG2:
  22. case LOONGSON_CFG3:
  23. return c->loongson3_cpucfg_data[sel - 1];
  24. case LOONGSON_CFG4:
  25. case LOONGSON_CFG5:
  26. /* CPUCFG selects 4 and 5 are related to the input clock
  27. * signal.
  28. *
  29. * Unimplemented for now.
  30. */
  31. return 0;
  32. case LOONGSON_CFG6:
  33. /* CPUCFG select 6 is for the undocumented Safe Extension. */
  34. return 0;
  35. case LOONGSON_CFG7:
  36. /* CPUCFG select 7 is for the virtualization extension.
  37. * We don't know if the two currently known features are
  38. * supported on older cores according to the public
  39. * documentation, so leave this at zero.
  40. */
  41. return 0;
  42. }
  43. /*
  44. * Return 0 for unrecognized CPUCFG selects, which is real hardware
  45. * behavior observed on Loongson 3A R4.
  46. */
  47. return 0;
  48. }
  49. #else
  50. static inline void loongson3_cpucfg_synthesize_data(struct cpuinfo_mips *c)
  51. {
  52. }
  53. static inline bool loongson3_cpucfg_emulation_enabled(struct cpuinfo_mips *c)
  54. {
  55. return false;
  56. }
  57. static inline u32 loongson3_cpucfg_read_synthesized(struct cpuinfo_mips *c,
  58. __u64 sel)
  59. {
  60. return 0;
  61. }
  62. #endif
  63. #endif /* _ASM_MACH_LOONGSON64_CPUCFG_EMUL_H_ */