pmu.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * linux/arch/arm/include/asm/pmu.h
  3. *
  4. * Copyright (C) 2009 picoChip Designs Ltd, Jamie Iles
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #ifndef __ARM_PMU_H__
  12. #define __ARM_PMU_H__
  13. enum arm_pmu_type {
  14. ARM_PMU_DEVICE_CPU = 0,
  15. ARM_NUM_PMU_DEVICES,
  16. };
  17. #ifdef CONFIG_CPU_HAS_PMU
  18. struct pmu_irqs {
  19. const int *irqs;
  20. int num_irqs;
  21. };
  22. /**
  23. * reserve_pmu() - reserve the hardware performance counters
  24. *
  25. * Reserve the hardware performance counters in the system for exclusive use.
  26. * The 'struct pmu_irqs' for the system is returned on success, ERR_PTR()
  27. * encoded error on failure.
  28. */
  29. extern const struct pmu_irqs *
  30. reserve_pmu(void);
  31. /**
  32. * release_pmu() - Relinquish control of the performance counters
  33. *
  34. * Release the performance counters and allow someone else to use them.
  35. * Callers must have disabled the counters and released IRQs before calling
  36. * this. The 'struct pmu_irqs' returned from reserve_pmu() must be passed as
  37. * a cookie.
  38. */
  39. extern int
  40. release_pmu(const struct pmu_irqs *irqs);
  41. /**
  42. * init_pmu() - Initialise the PMU.
  43. *
  44. * Initialise the system ready for PMU enabling. This should typically set the
  45. * IRQ affinity and nothing else. The users (oprofile/perf events etc) will do
  46. * the actual hardware initialisation.
  47. */
  48. extern int
  49. init_pmu(void);
  50. #else /* CONFIG_CPU_HAS_PMU */
  51. static inline const struct pmu_irqs *
  52. reserve_pmu(void)
  53. {
  54. return ERR_PTR(-ENODEV);
  55. }
  56. static inline int
  57. release_pmu(const struct pmu_irqs *irqs)
  58. {
  59. return -ENODEV;
  60. }
  61. static inline int
  62. init_pmu(void)
  63. {
  64. return -ENODEV;
  65. }
  66. #endif /* CONFIG_CPU_HAS_PMU */
  67. #endif /* __ARM_PMU_H__ */