pmu.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /**
  19. * reserve_pmu() - reserve the hardware performance counters
  20. *
  21. * Reserve the hardware performance counters in the system for exclusive use.
  22. * The platform_device for the system is returned on success, ERR_PTR()
  23. * encoded error on failure.
  24. */
  25. extern struct platform_device *
  26. reserve_pmu(enum arm_pmu_type device);
  27. /**
  28. * release_pmu() - Relinquish control of the performance counters
  29. *
  30. * Release the performance counters and allow someone else to use them.
  31. * Callers must have disabled the counters and released IRQs before calling
  32. * this. The platform_device returned from reserve_pmu() must be passed as
  33. * a cookie.
  34. */
  35. extern int
  36. release_pmu(struct platform_device *pdev);
  37. /**
  38. * init_pmu() - Initialise the PMU.
  39. *
  40. * Initialise the system ready for PMU enabling. This should typically set the
  41. * IRQ affinity and nothing else. The users (oprofile/perf events etc) will do
  42. * the actual hardware initialisation.
  43. */
  44. extern int
  45. init_pmu(enum arm_pmu_type device);
  46. #else /* CONFIG_CPU_HAS_PMU */
  47. #include <linux/err.h>
  48. static inline struct platform_device *
  49. reserve_pmu(enum arm_pmu_type device)
  50. {
  51. return ERR_PTR(-ENODEV);
  52. }
  53. static inline int
  54. release_pmu(struct platform_device *pdev)
  55. {
  56. return -ENODEV;
  57. }
  58. static inline int
  59. init_pmu(enum arm_pmu_type device)
  60. {
  61. return -ENODEV;
  62. }
  63. #endif /* CONFIG_CPU_HAS_PMU */
  64. #endif /* __ARM_PMU_H__ */