pvr.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Support for MicroBlaze PVR (processor version register)
  3. *
  4. * Copyright (C) 2007-2009 Michal Simek <[email protected]>
  5. * Copyright (C) 2007-2009 PetaLogix
  6. * Copyright (C) 2007 John Williams <[email protected]>
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/compiler.h>
  14. #include <asm/exceptions.h>
  15. #include <asm/pvr.h>
  16. #include <linux/irqflags.h>
  17. /*
  18. * Until we get an assembler that knows about the pvr registers,
  19. * this horrible cruft will have to do.
  20. * That hardcoded opcode is mfs r3, rpvrNN
  21. */
  22. #define get_single_pvr(pvrid, val) \
  23. { \
  24. register unsigned tmp __asm__("r3"); \
  25. tmp = 0x0; /* Prevent warning about unused */ \
  26. __asm__ __volatile__ ( \
  27. "mfs %0, rpvr" #pvrid ";" \
  28. : "=r" (tmp) : : "memory"); \
  29. val = tmp; \
  30. }
  31. /*
  32. * Does the CPU support the PVR register?
  33. * return value:
  34. * 0: no PVR
  35. * 1: simple PVR
  36. * 2: full PVR
  37. *
  38. * This must work on all CPU versions, including those before the
  39. * PVR was even an option.
  40. */
  41. int cpu_has_pvr(void)
  42. {
  43. unsigned long flags;
  44. unsigned pvr0;
  45. local_save_flags(flags);
  46. /* PVR bit in MSR tells us if there is any support */
  47. if (!(flags & PVR_MSR_BIT))
  48. return 0;
  49. get_single_pvr(0, pvr0);
  50. pr_debug("%s: pvr0 is 0x%08x\n", __func__, pvr0);
  51. if (pvr0 & PVR0_PVR_FULL_MASK)
  52. return 1;
  53. /* for partial PVR use static cpuinfo */
  54. return 2;
  55. }
  56. void get_pvr(struct pvr_s *p)
  57. {
  58. get_single_pvr(0, p->pvr[0]);
  59. get_single_pvr(1, p->pvr[1]);
  60. get_single_pvr(2, p->pvr[2]);
  61. get_single_pvr(3, p->pvr[3]);
  62. get_single_pvr(4, p->pvr[4]);
  63. get_single_pvr(5, p->pvr[5]);
  64. get_single_pvr(6, p->pvr[6]);
  65. get_single_pvr(7, p->pvr[7]);
  66. get_single_pvr(8, p->pvr[8]);
  67. get_single_pvr(9, p->pvr[9]);
  68. get_single_pvr(10, p->pvr[10]);
  69. get_single_pvr(11, p->pvr[11]);
  70. }